Merge trunk changes into experimental branch.
FossilOrigin-Name: aa81900153a2762cb2ad41e6710c1f1e7dc8b41e
This commit is contained in:
commit
76d5918243
25
manifest
25
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\serrors\sin\swal3.test\scaused\sby\srecent\smodifications.
|
||||
D 2010-07-28T15:10:38
|
||||
C Merge\strunk\schanges\sinto\sexperimental\sbranch.
|
||||
D 2010-07-28T18:35:50
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -122,7 +122,7 @@ F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac
|
||||
F src/ctime.c 4f3aadad62c6c9f0d4e5a96718516ac4e3c598df
|
||||
F src/date.c 5dd8448a0bfea8d31fb14cff487d0c06ff8c8b20
|
||||
F src/delete.c 7ed8a8c8b5f748ece92df173d7e0f7810c899ebd
|
||||
F src/expr.c 7490fc3b16414d1a45d5acadf559317f9244891f
|
||||
F src/expr.c a0fd9c5e248229851077de92f2e9346f2c43ed46
|
||||
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
|
||||
F src/fkey.c cacfe3e24b311e4e089a9c470bdb73196af6f729
|
||||
F src/func.c 75dc1fd91e5692cadb80d257bab68d7343060467
|
||||
@ -156,12 +156,12 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f
|
||||
F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e
|
||||
F src/os_unix.c ae5ca8a6031380708f3fec7be325233d49944914
|
||||
F src/os_win.c 51cb62f76262d961ea4249489383d714501315a7
|
||||
F src/pager.c 27ace2e07c8bfe2e04428eba03b2ddb5b03abd7d
|
||||
F src/pager.c 4cf634d80958f69fa3882624067423cd7547d976
|
||||
F src/pager.h 879fdde5a102d2f21a3135d6f647530b21c2796c
|
||||
F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58
|
||||
F src/pcache.c 1e9aa2dbc0845b52e1b51cc39753b6d1e041cb07
|
||||
F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050
|
||||
F src/pcache1.c 3a7c28f46a61b43ff0b5c087a7983c154f4b264c
|
||||
F src/pcache1.c 638844c118163e3a10e1e3265703adf74870312d
|
||||
F src/pragma.c 8b24ce00a93de345b6c3bd1e1e2cfba9f63d2325
|
||||
F src/prepare.c ce4c35a2b1d5fe916e4a46b70d24a6e997d7c4c6
|
||||
F src/printf.c 8ae5082dd38a1b5456030c3755ec3a392cd51506
|
||||
@ -169,8 +169,8 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
|
||||
F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706
|
||||
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
|
||||
F src/select.c 74fef1334bec27e606ef0b19e5c41cd0a639e69c
|
||||
F src/shell.c fd4ccdb37c3b68de0623eb938a649e0990710714
|
||||
F src/sqlite.h.in 10bd4aed244fc0eadb10ec01cedb60bafc2d7bfe
|
||||
F src/shell.c 8517fc1f9c59ae4007e6cc8b9af91ab231ea2056
|
||||
F src/sqlite.h.in 77af8becd95ddd5149448fa667b20845da98072d
|
||||
F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89
|
||||
F src/sqliteInt.h a9be6badc6cd6a3c1ae54475a98661cf351ecad5
|
||||
F src/sqliteLimit.h 196e2f83c3b444c4548fc1874f52f84fdbda40f3
|
||||
@ -255,7 +255,7 @@ F test/auth.test 8f21c160a4562f54f27618e85bac869efcecbcaf
|
||||
F test/auth2.test 270baddc8b9c273682760cffba6739d907bd2882
|
||||
F test/auth3.test a4755e6a2a2fea547ffe63c874eb569e60a28eb5
|
||||
F test/autoinc.test 85ef3180a737e6580086a018c09c6f1a52759b46
|
||||
F test/autoindex1.test ffb06a246e2c1f89cfbe3d93eca513c9e78d4063
|
||||
F test/autoindex1.test 7df441bf0e7a88644eb80993339dbf1db3a12c68
|
||||
F test/autovacuum.test bb7c0885e6f8f1d633045de48f2b66082162766d
|
||||
F test/autovacuum_ioerr2.test 598b0663074d3673a9c1bc9a16e80971313bafe6
|
||||
F test/avtrans.test 0252654f4295ddda3b2cce0e894812259e655a85
|
||||
@ -824,9 +824,10 @@ F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87
|
||||
F tool/omittest.tcl 27d6f6e3b1e95aeb26a1c140e6eb57771c6d794a
|
||||
F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
|
||||
F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a
|
||||
F tool/shell1.test a738c71bc08ea9162baee9a14b3cf9994f181921
|
||||
F tool/shell1.test 930444cadb71ce9ce78bc6cd14ec21e6b69776ea
|
||||
F tool/shell2.test 5dc76b8005b465f420fed8241621da7513060ff3
|
||||
F tool/shell3.test 4fad469e8003938426355afdf34155f08c587836
|
||||
F tool/shell4.test b8d99dc22399a256f1090f6d755f666f394ba02b
|
||||
F tool/showdb.c 01c20e8181941b714fe07f72c64a7560fee17ff9
|
||||
F tool/showjournal.c ec3b171be148656827c4949fbfb8ab4370822f87
|
||||
F tool/showwal.c f09e5a80a293919290ec85a6a37c85a5ddcf37d9
|
||||
@ -839,7 +840,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
P a038688c991435967b935946c2283707820bb5da
|
||||
R 27913a854c524e2ed86aec3ca2a1108c
|
||||
P 0714aeccd82d82686c074c1bb74ea794b7bfa3a3 ae89777e7f8bae2cdd3407395ea84c1b39577c4b
|
||||
R 929440acfba750114000a8118fc5b2ef
|
||||
U dan
|
||||
Z bf8c1f74204eb606b6c5a25382962d26
|
||||
Z 1bb342ebf679301c7cb8840574e16573
|
||||
|
@ -1 +1 @@
|
||||
0714aeccd82d82686c074c1bb74ea794b7bfa3a3
|
||||
aa81900153a2762cb2ad41e6710c1f1e7dc8b41e
|
10
src/expr.c
10
src/expr.c
@ -1512,14 +1512,20 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, int *prNotFound){
|
||||
/* Could not found an existing table or index to use as the RHS b-tree.
|
||||
** We will have to generate an ephemeral table to do the job.
|
||||
*/
|
||||
double savedNQueryLoop = pParse->nQueryLoop;
|
||||
int rMayHaveNull = 0;
|
||||
eType = IN_INDEX_EPH;
|
||||
if( prNotFound ){
|
||||
*prNotFound = rMayHaveNull = ++pParse->nMem;
|
||||
}else if( pX->pLeft->iColumn<0 && !ExprHasAnyProperty(pX, EP_xIsSelect) ){
|
||||
eType = IN_INDEX_ROWID;
|
||||
}else{
|
||||
testcase( pParse->nQueryLoop>(double)1 );
|
||||
pParse->nQueryLoop = (double)1;
|
||||
if( pX->pLeft->iColumn<0 && !ExprHasAnyProperty(pX, EP_xIsSelect) ){
|
||||
eType = IN_INDEX_ROWID;
|
||||
}
|
||||
}
|
||||
sqlite3CodeSubselect(pParse, pX, rMayHaveNull, eType==IN_INDEX_ROWID);
|
||||
pParse->nQueryLoop = savedNQueryLoop;
|
||||
}else{
|
||||
pX->iTable = iTab;
|
||||
}
|
||||
|
@ -5414,9 +5414,11 @@ int sqlite3PagerRefcount(Pager *pPager){
|
||||
** used by the pager and its associated cache.
|
||||
*/
|
||||
int sqlite3PagerMemUsed(Pager *pPager){
|
||||
int perPageSize = pPager->pageSize + pPager->nExtra + 20;
|
||||
int perPageSize = pPager->pageSize + pPager->nExtra + sizeof(PgHdr)
|
||||
+ 5*sizeof(void*);
|
||||
return perPageSize*sqlite3PcachePagecount(pPager->pPCache)
|
||||
+ sqlite3MallocSize(pPager);
|
||||
+ sqlite3MallocSize(pPager)
|
||||
+ (pPager->pTmpSpace ? pPager->pageSize : 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -152,11 +152,11 @@ void sqlite3PCacheBufferSetup(void *pBuf, int sz, int n){
|
||||
static void *pcache1Alloc(int nByte){
|
||||
void *p;
|
||||
assert( sqlite3_mutex_held(pcache1.mutex) );
|
||||
sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte);
|
||||
if( nByte<=pcache1.szSlot && pcache1.pFree ){
|
||||
assert( pcache1.isInit );
|
||||
p = (PgHdr1 *)pcache1.pFree;
|
||||
pcache1.pFree = pcache1.pFree->pNext;
|
||||
sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte);
|
||||
sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, 1);
|
||||
}else{
|
||||
|
||||
|
118
src/shell.c
118
src/shell.c
@ -398,6 +398,7 @@ struct previous_mode_data {
|
||||
struct callback_data {
|
||||
sqlite3 *db; /* The database */
|
||||
int echoOn; /* True to echo input commands */
|
||||
int statsOn; /* True to display memory stats before each finalize */
|
||||
int cnt; /* Number of records displayed so far */
|
||||
FILE *out; /* Write results here */
|
||||
int mode; /* An output mode setting */
|
||||
@ -961,6 +962,86 @@ static char *save_err_msg(
|
||||
return zErrMsg;
|
||||
}
|
||||
|
||||
/*
|
||||
** Display memory stats.
|
||||
*/
|
||||
static int display_stats(
|
||||
sqlite3 *db, /* Database to query */
|
||||
struct callback_data *pArg, /* Pointer to struct callback_data */
|
||||
int bReset /* True to reset the stats */
|
||||
){
|
||||
int iCur;
|
||||
int iHiwtr;
|
||||
|
||||
if( pArg && pArg->out ){
|
||||
|
||||
iHiwtr = iCur = -1;
|
||||
sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset);
|
||||
fprintf(pArg->out, "Memory Used: %d (max %d) bytes\n", iCur, iHiwtr);
|
||||
iHiwtr = iCur = -1;
|
||||
sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset);
|
||||
fprintf(pArg->out, "Number of Allocations: %d (max %d)\n", iCur, iHiwtr);
|
||||
/*
|
||||
** Not currently used by the CLI.
|
||||
** iHiwtr = iCur = -1;
|
||||
** sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset);
|
||||
** fprintf(pArg->out, "Number of Pcache Pages Used: %d (max %d) pages\n", iCur, iHiwtr);
|
||||
*/
|
||||
iHiwtr = iCur = -1;
|
||||
sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset);
|
||||
fprintf(pArg->out, "Number of Pcache Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr);
|
||||
/*
|
||||
** Not currently used by the CLI.
|
||||
** iHiwtr = iCur = -1;
|
||||
** sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &iCur, &iHiwtr, bReset);
|
||||
** fprintf(pArg->out, "Number of Scratch Allocations Used: %d (max %d)\n", iCur, iHiwtr);
|
||||
*/
|
||||
iHiwtr = iCur = -1;
|
||||
sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHiwtr, bReset);
|
||||
fprintf(pArg->out, "Number of Scratch Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr);
|
||||
iHiwtr = iCur = -1;
|
||||
sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset);
|
||||
fprintf(pArg->out, "Largest Allocation: %d bytes\n", iHiwtr);
|
||||
iHiwtr = iCur = -1;
|
||||
sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, bReset);
|
||||
fprintf(pArg->out, "Largest Pcache Allocation: %d bytes\n", iHiwtr);
|
||||
iHiwtr = iCur = -1;
|
||||
sqlite3_status(SQLITE_STATUS_SCRATCH_SIZE, &iCur, &iHiwtr, bReset);
|
||||
fprintf(pArg->out, "Largest Scratch Allocation: %d bytes\n", iHiwtr);
|
||||
#ifdef YYTRACKMAXSTACKDEPTH
|
||||
iHiwtr = iCur = -1;
|
||||
sqlite3_status(SQLITE_STATUS_PARSER_STACK, &iCur, &iHiwtr, bReset);
|
||||
fprintf(pArg->out, "Deepest Parser Stack: %d (max %d)\n", iCur, iHiwtr);
|
||||
#endif
|
||||
}
|
||||
|
||||
if( pArg && pArg->out && db ){
|
||||
iHiwtr = iCur = -1;
|
||||
sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, bReset);
|
||||
fprintf(pArg->out, "Lookaside Slots Used: %d (max %d)\n", iCur, iHiwtr);
|
||||
iHiwtr = iCur = -1;
|
||||
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset);
|
||||
fprintf(pArg->out, "Pager Heap Usage: %d bytes\n", iCur);
|
||||
iHiwtr = iCur = -1;
|
||||
sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset);
|
||||
fprintf(pArg->out, "Schema Heap Usage: %d bytes\n", iCur);
|
||||
iHiwtr = iCur = -1;
|
||||
sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset);
|
||||
fprintf(pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n", iCur);
|
||||
}
|
||||
|
||||
if( pArg && pArg->out && db && pArg->pStmt ){
|
||||
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP, bReset);
|
||||
fprintf(pArg->out, "Fullscan Steps: %d\n", iCur);
|
||||
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset);
|
||||
fprintf(pArg->out, "Sort Operations: %d\n", iCur);
|
||||
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX, bReset);
|
||||
fprintf(pArg->out, "Autoindex Inserts: %d\n", iCur);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Execute a statement or set of statements. Print
|
||||
** any result rows/columns depending on the current mode
|
||||
@ -1000,10 +1081,16 @@ static int shell_exec(
|
||||
continue;
|
||||
}
|
||||
|
||||
/* save off the prepared statment handle and reset row count */
|
||||
if( pArg ){
|
||||
pArg->pStmt = pStmt;
|
||||
pArg->cnt = 0;
|
||||
}
|
||||
|
||||
/* echo the sql statement if echo on */
|
||||
if( pArg->echoOn ){
|
||||
if( pArg && pArg->echoOn ){
|
||||
const char *zStmtSql = sqlite3_sql(pStmt);
|
||||
fprintf(pArg->out,"%s\n", zStmtSql ? zStmtSql : zSql);
|
||||
fprintf(pArg->out, "%s\n", zStmtSql ? zStmtSql : zSql);
|
||||
}
|
||||
|
||||
/* perform the first step. this will tell us if we
|
||||
@ -1029,11 +1116,6 @@ static int shell_exec(
|
||||
for(i=0; i<nCol; i++){
|
||||
azCols[i] = (char *)sqlite3_column_name(pStmt, i);
|
||||
}
|
||||
/* save off the prepared statment handle and reset row count */
|
||||
if( pArg ){
|
||||
pArg->pStmt = pStmt;
|
||||
pArg->cnt = 0;
|
||||
}
|
||||
do{
|
||||
/* extract the data and data types */
|
||||
for(i=0; i<nCol; i++){
|
||||
@ -1056,9 +1138,6 @@ static int shell_exec(
|
||||
}
|
||||
} while( SQLITE_ROW == rc );
|
||||
sqlite3_free(pData);
|
||||
if( pArg ){
|
||||
pArg->pStmt = NULL;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
do{
|
||||
@ -1067,6 +1146,11 @@ static int shell_exec(
|
||||
}
|
||||
}
|
||||
|
||||
/* print usage stats if stats on */
|
||||
if( pArg && pArg->statsOn ){
|
||||
display_stats(db, pArg, 0);
|
||||
}
|
||||
|
||||
/* Finalize the statement just executed. If this fails, save a
|
||||
** copy of the error message. Otherwise, set zSql to point to the
|
||||
** next statement to execute. */
|
||||
@ -1077,6 +1161,11 @@ static int shell_exec(
|
||||
}else if( pzErrMsg ){
|
||||
*pzErrMsg = save_err_msg(db);
|
||||
}
|
||||
|
||||
/* clear saved stmt handle */
|
||||
if( pArg ){
|
||||
pArg->pStmt = NULL;
|
||||
}
|
||||
}
|
||||
} /* end while */
|
||||
|
||||
@ -1256,6 +1345,7 @@ static char zHelp[] =
|
||||
" LIKE pattern TABLE.\n"
|
||||
".separator STRING Change separator used by output mode and .import\n"
|
||||
".show Show the current values for various settings\n"
|
||||
".stats ON|OFF Turn stats on or off\n"
|
||||
".tables ?TABLE? List names of tables\n"
|
||||
" If TABLE specified, only list tables matching\n"
|
||||
" LIKE pattern TABLE.\n"
|
||||
@ -2001,6 +2091,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){
|
||||
fprintf(p->out,"%9.9s: ", "separator");
|
||||
output_c_string(p->out, p->separator);
|
||||
fprintf(p->out, "\n");
|
||||
fprintf(p->out,"%9.9s: %s\n","stats", p->statsOn ? "on" : "off");
|
||||
fprintf(p->out,"%9.9s: ","width");
|
||||
for (i=0;i<(int)ArraySize(p->colWidth) && p->colWidth[i] != 0;i++) {
|
||||
fprintf(p->out,"%d ",p->colWidth[i]);
|
||||
@ -2008,6 +2099,10 @@ static int do_meta_command(char *zLine, struct callback_data *p){
|
||||
fprintf(p->out,"\n");
|
||||
}else
|
||||
|
||||
if( c=='s' && strncmp(azArg[0], "stats", n)==0 && nArg>1 && nArg<3 ){
|
||||
p->statsOn = booleanValue(azArg[1]);
|
||||
}else
|
||||
|
||||
if( c=='t' && n>1 && strncmp(azArg[0], "tables", n)==0 && nArg<3 ){
|
||||
char **azResult;
|
||||
int nRow;
|
||||
@ -2391,6 +2486,7 @@ static const char zOptions[] =
|
||||
" -line set output mode to 'line'\n"
|
||||
" -list set output mode to 'list'\n"
|
||||
" -separator 'x' set output field separator (|)\n"
|
||||
" -stats print memory stats before each finalize\n"
|
||||
" -nullvalue 'text' set text string for NULL values\n"
|
||||
" -version show SQLite version\n"
|
||||
;
|
||||
@ -2555,6 +2651,8 @@ int main(int argc, char **argv){
|
||||
data.showHeader = 0;
|
||||
}else if( strcmp(z,"-echo")==0 ){
|
||||
data.echoOn = 1;
|
||||
}else if( strcmp(z,"-stats")==0 ){
|
||||
data.statsOn = 1;
|
||||
}else if( strcmp(z,"-bail")==0 ){
|
||||
bail_on_error = 1;
|
||||
}else if( strcmp(z,"-version")==0 ){
|
||||
|
@ -5152,6 +5152,9 @@ int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
|
||||
** *pHighwater parameter to [sqlite3_status()] is of interest.
|
||||
** The value written into the *pCurrent parameter is undefined.</dd>)^
|
||||
**
|
||||
** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt>
|
||||
** <dd>This parameter records the number of separate memory allocations.</dd>)^
|
||||
**
|
||||
** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>
|
||||
** <dd>This parameter returns the number of pages used out of the
|
||||
** [pagecache memory allocator] that was configured using
|
||||
@ -5260,7 +5263,7 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
|
||||
**
|
||||
** ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
|
||||
** <dd>This parameter returns the approximate number of of bytes of heap
|
||||
** and lookaside memory used to store the schema for all databases associated
|
||||
** memory used to store the schema for all databases associated
|
||||
** with the connection - main, temp, and any [ATTACH]-ed databases.)^
|
||||
** ^The full amount of memory used by the schemas is reported, even if the
|
||||
** schema memory is shared with other database connections due to
|
||||
|
@ -136,4 +136,34 @@ do_test autoindex1-401 {
|
||||
}
|
||||
} {4087}
|
||||
|
||||
# Ticket [8011086c85c6c404014c947fcf3eb9f42b184a0d] from 2010-07-08
|
||||
# Make sure automatic indices are not created for the RHS of an IN expression
|
||||
# that is not a correlated subquery.
|
||||
#
|
||||
do_test autoindex1-500 {
|
||||
db eval {
|
||||
CREATE TABLE t501(a INTEGER PRIMARY KEY, b);
|
||||
CREATE TABLE t502(x INTEGER PRIMARY KEY, y);
|
||||
EXPLAIN QUERY PLAN
|
||||
SELECT b FROM t501
|
||||
WHERE t501.a IN (SELECT x FROM t502 WHERE y=?);
|
||||
}
|
||||
} {0 0 {TABLE t501 USING PRIMARY KEY} 0 0 {TABLE t502}}
|
||||
do_test autoindex1-501 {
|
||||
db eval {
|
||||
EXPLAIN QUERY PLAN
|
||||
SELECT b FROM t501
|
||||
WHERE t501.a IN (SELECT x FROM t502 WHERE y=t501.b);
|
||||
}
|
||||
} {0 0 {TABLE t501} 0 0 {TABLE t502 WITH AUTOMATIC INDEX}}
|
||||
do_test autoindex1-502 {
|
||||
db eval {
|
||||
EXPLAIN QUERY PLAN
|
||||
SELECT b FROM t501
|
||||
WHERE t501.a=123
|
||||
AND t501.a IN (SELECT x FROM t502 WHERE y=t501.b);
|
||||
}
|
||||
} {0 0 {TABLE t501 USING PRIMARY KEY} 0 0 {TABLE t502}}
|
||||
|
||||
|
||||
finish_test
|
||||
|
@ -178,6 +178,11 @@ do_test shell1-1.14.3 {
|
||||
[regexp {Error: missing argument for option: -separator} $res]
|
||||
} {1 1}
|
||||
|
||||
# -stats print memory stats before each finalize
|
||||
do_test shell1-1.14b.1 {
|
||||
catchcmd "-stats test.db" ""
|
||||
} {0 {}}
|
||||
|
||||
# -nullvalue 'text' set text string for NULL values
|
||||
do_test shell1-1.15.1 {
|
||||
catchcmd "-nullvalue 'x' test.db" ""
|
||||
@ -195,7 +200,7 @@ do_test shell1-1.15.3 {
|
||||
# -version show SQLite version
|
||||
do_test shell1-1.16.1 {
|
||||
catchcmd "-version test.db" ""
|
||||
} {0 3.7.0}
|
||||
} {0 3.7.1}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test cases shell1-2.*: Basic "dot" command token parsing.
|
||||
@ -621,13 +626,29 @@ do_test shell1-3.23.1 {
|
||||
[regexp {nullvalue:} $res] \
|
||||
[regexp {output:} $res] \
|
||||
[regexp {separator:} $res] \
|
||||
[regexp {stats:} $res] \
|
||||
[regexp {width:} $res]
|
||||
} {1 1 1 1 1 1 1 1}
|
||||
} {1 1 1 1 1 1 1 1 1}
|
||||
do_test shell1-3.23.2 {
|
||||
# too many arguments
|
||||
catchcmd "test.db" ".show BAD"
|
||||
} {1 {Error: unknown command or invalid arguments: "show". Enter ".help" for help}}
|
||||
|
||||
# .stats ON|OFF Turn stats on or off
|
||||
do_test shell1-3.23b.1 {
|
||||
catchcmd "test.db" ".stats"
|
||||
} {1 {Error: unknown command or invalid arguments: "stats". Enter ".help" for help}}
|
||||
do_test shell1-3.23b.2 {
|
||||
catchcmd "test.db" ".stats ON"
|
||||
} {0 {}}
|
||||
do_test shell1-3.23b.3 {
|
||||
catchcmd "test.db" ".stats OFF"
|
||||
} {0 {}}
|
||||
do_test shell1-3.23b.4 {
|
||||
# too many arguments
|
||||
catchcmd "test.db" ".stats OFF BAD"
|
||||
} {1 {Error: unknown command or invalid arguments: "stats". Enter ".help" for help}}
|
||||
|
||||
# .tables ?TABLE? List names of tables
|
||||
# If TABLE specified, only list tables matching
|
||||
# LIKE pattern TABLE.
|
||||
|
140
tool/shell4.test
Normal file
140
tool/shell4.test
Normal file
@ -0,0 +1,140 @@
|
||||
# 2010 July 28
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# The focus of this file is testing the CLI shell tool.
|
||||
#
|
||||
# $Id: shell4.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $
|
||||
#
|
||||
|
||||
# Test plan:
|
||||
#
|
||||
# shell4-1.*: Basic tests specific to the "stats" command.
|
||||
#
|
||||
|
||||
package require sqlite3
|
||||
|
||||
set CLI "./sqlite3"
|
||||
|
||||
proc do_test {name cmd expected} {
|
||||
puts -nonewline "$name ..."
|
||||
set res [uplevel $cmd]
|
||||
if {$res eq $expected} {
|
||||
puts Ok
|
||||
} else {
|
||||
puts Error
|
||||
puts " Got: $res"
|
||||
puts " Expected: $expected"
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
proc execsql {sql} {
|
||||
uplevel [list db eval $sql]
|
||||
}
|
||||
|
||||
proc catchsql {sql} {
|
||||
set rc [catch {uplevel [list db eval $sql]} msg]
|
||||
list $rc $msg
|
||||
}
|
||||
|
||||
proc catchcmd {db {cmd ""}} {
|
||||
global CLI
|
||||
set out [open cmds.txt w]
|
||||
puts $out $cmd
|
||||
close $out
|
||||
set line "exec $CLI $db < cmds.txt"
|
||||
set rc [catch { eval $line } msg]
|
||||
list $rc $msg
|
||||
}
|
||||
|
||||
file delete -force test.db test.db.journal
|
||||
sqlite3 db test.db
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test cases shell4-1.*: Tests specific to the "stats" command.
|
||||
#
|
||||
|
||||
# should default to off
|
||||
do_test shell4-1.1.1 {
|
||||
set res [catchcmd "test.db" ".show"]
|
||||
list [regexp {stats: off} $res]
|
||||
} {1}
|
||||
|
||||
do_test shell4-1.1.2 {
|
||||
set res [catchcmd "test.db" ".show"]
|
||||
list [regexp {stats: on} $res]
|
||||
} {0}
|
||||
|
||||
# -stats should turn it on
|
||||
do_test shell4-1.2.1 {
|
||||
set res [catchcmd "-stats test.db" ".show"]
|
||||
list [regexp {stats: on} $res]
|
||||
} {1}
|
||||
|
||||
do_test shell4-1.2.2 {
|
||||
set res [catchcmd "-stats test.db" ".show"]
|
||||
list [regexp {stats: off} $res]
|
||||
} {0}
|
||||
|
||||
# .stats ON|OFF Turn stats on or off
|
||||
do_test shell4-1.3.1 {
|
||||
catchcmd "test.db" ".stats"
|
||||
} {1 {Error: unknown command or invalid arguments: "stats". Enter ".help" for help}}
|
||||
do_test shell4-1.3.2 {
|
||||
catchcmd "test.db" ".stats ON"
|
||||
} {0 {}}
|
||||
do_test shell4-1.3.3 {
|
||||
catchcmd "test.db" ".stats OFF"
|
||||
} {0 {}}
|
||||
do_test shell4-1.3.4 {
|
||||
# too many arguments
|
||||
catchcmd "test.db" ".stats OFF BAD"
|
||||
} {1 {Error: unknown command or invalid arguments: "stats". Enter ".help" for help}}
|
||||
|
||||
# NB. whitespace is important
|
||||
do_test shell4-1.4.1 {
|
||||
set res [catchcmd "test.db" {.show}]
|
||||
list [regexp {stats: off} $res]
|
||||
} {1}
|
||||
|
||||
do_test shell4-1.4.2 {
|
||||
set res [catchcmd "test.db" {.stats ON
|
||||
.show
|
||||
}]
|
||||
list [regexp {stats: on} $res]
|
||||
} {1}
|
||||
|
||||
do_test shell4-1.4.3 {
|
||||
set res [catchcmd "test.db" {.stats OFF
|
||||
.show
|
||||
}]
|
||||
list [regexp {stats: off} $res]
|
||||
} {1}
|
||||
|
||||
# make sure stats not present when off
|
||||
do_test shell4-1.5.1 {
|
||||
set res [catchcmd "test.db" {SELECT 1;}]
|
||||
list [regexp {Memory Used} $res] \
|
||||
[regexp {Heap Usage} $res] \
|
||||
[regexp {Autoindex Inserts} $res]
|
||||
} {0 0 0}
|
||||
|
||||
# make sure stats are present when on
|
||||
do_test shell4-1.5.2 {
|
||||
set res [catchcmd "test.db" {.stats ON
|
||||
SELECT 1;
|
||||
}]
|
||||
list [regexp {Memory Used} $res] \
|
||||
[regexp {Heap Usage} $res] \
|
||||
[regexp {Autoindex Inserts} $res]
|
||||
} {1 1 1}
|
||||
|
||||
puts "CLI tests completed successfully"
|
Loading…
x
Reference in New Issue
Block a user