From: drh Date: Fri, 14 Jul 2017 15:14:21 +0000 (+0000) Subject: Change the name of the STMT virtual table to SQLITE_STMT. Also remove the X-Git-Tag: version-3.20.0~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e83b847b75cc39bdb20268a5976b395adb68e9c4;p=thirdparty%2Fsqlite.git Change the name of the STMT virtual table to SQLITE_STMT. Also remove the first column of that virtual table, which was a pointer leak. FossilOrigin-Name: 1bc4e93407b7894b0271fbde3720930dcaadda6070e871d9719c4e8dc65b915f --- diff --git a/ext/misc/stmt.c b/ext/misc/stmt.c index b06191e938..dbaa0bd64d 100644 --- a/ext/misc/stmt.c +++ b/ext/misc/stmt.c @@ -30,23 +30,6 @@ SQLITE_EXTENSION_INIT1 #ifndef SQLITE_OMIT_VIRTUALTABLE -/* -** The following macros are used to cast pointers to integers. -** The way you do this varies from one compiler -** to the next, so we have developed the following set of #if statements -** to generate appropriate macros for a wide range of compilers. -*/ -#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */ -# define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(__PTRDIFF_TYPE__)(X)) -#elif !defined(__GNUC__) /* Works for compilers other than LLVM */ -# define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(((char*)X)-(char*)0)) -#elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */ -# define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(intptr_t)(X)) -#else /* Generates a warning - but it always works */ -# define SQLITE_PTR_TO_INT64(X) ((sqlite3_int64)(X)) -#endif - - /* stmt_vtab is a subclass of sqlite3_vtab which will ** serve as the underlying representation of a stmt virtual table */ @@ -92,22 +75,21 @@ static int stmtConnect( int rc; /* Column numbers */ -#define STMT_COLUMN_PTR 0 /* Numeric value of the statement pointer */ -#define STMT_COLUMN_SQL 1 /* SQL for the statement */ -#define STMT_COLUMN_NCOL 2 /* Number of result columns */ -#define STMT_COLUMN_RO 3 /* True if read-only */ -#define STMT_COLUMN_BUSY 4 /* True if currently busy */ -#define STMT_COLUMN_NSCAN 5 /* SQLITE_STMTSTATUS_FULLSCAN_STEP */ -#define STMT_COLUMN_NSORT 6 /* SQLITE_STMTSTATUS_SORT */ -#define STMT_COLUMN_NAIDX 7 /* SQLITE_STMTSTATUS_AUTOINDEX */ -#define STMT_COLUMN_NSTEP 8 /* SQLITE_STMTSTATUS_VM_STEP */ -#define STMT_COLUMN_REPREP 9 /* SQLITE_STMTSTATUS_REPREPARE */ -#define STMT_COLUMN_RUN 10 /* SQLITE_STMTSTATUS_RUN */ -#define STMT_COLUMN_MEM 11 /* SQLITE_STMTSTATUS_MEMUSED */ +#define STMT_COLUMN_SQL 0 /* SQL for the statement */ +#define STMT_COLUMN_NCOL 1 /* Number of result columns */ +#define STMT_COLUMN_RO 2 /* True if read-only */ +#define STMT_COLUMN_BUSY 3 /* True if currently busy */ +#define STMT_COLUMN_NSCAN 4 /* SQLITE_STMTSTATUS_FULLSCAN_STEP */ +#define STMT_COLUMN_NSORT 5 /* SQLITE_STMTSTATUS_SORT */ +#define STMT_COLUMN_NAIDX 6 /* SQLITE_STMTSTATUS_AUTOINDEX */ +#define STMT_COLUMN_NSTEP 7 /* SQLITE_STMTSTATUS_VM_STEP */ +#define STMT_COLUMN_REPREP 8 /* SQLITE_STMTSTATUS_REPREPARE */ +#define STMT_COLUMN_RUN 9 /* SQLITE_STMTSTATUS_RUN */ +#define STMT_COLUMN_MEM 10 /* SQLITE_STMTSTATUS_MEMUSED */ rc = sqlite3_declare_vtab(db, - "CREATE TABLE x(ptr,sql,ncol,ro,busy,nscan,nsort,naidx,nstep," + "CREATE TABLE x(sql,ncol,ro,busy,nscan,nsort,naidx,nstep," "reprep,run,mem)"); if( rc==SQLITE_OK ){ pNew = sqlite3_malloc( sizeof(*pNew) ); @@ -170,10 +152,6 @@ static int stmtColumn( ){ stmt_cursor *pCur = (stmt_cursor*)cur; switch( i ){ - case STMT_COLUMN_PTR: { - sqlite3_result_int64(ctx, SQLITE_PTR_TO_INT64(pCur->pStmt)); - break; - } case STMT_COLUMN_SQL: { sqlite3_result_text(ctx, sqlite3_sql(pCur->pStmt), -1, SQLITE_TRANSIENT); break; @@ -295,7 +273,7 @@ static sqlite3_module stmtModule = { int sqlite3StmtVtabInit(sqlite3 *db){ int rc = SQLITE_OK; #ifndef SQLITE_OMIT_VIRTUALTABLE - rc = sqlite3_create_module(db, "stmt", &stmtModule, 0); + rc = sqlite3_create_module(db, "sqlite_stmt", &stmtModule, 0); #endif return rc; } diff --git a/manifest b/manifest index 3ab2c8e415..4badf1977d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\supdates\sto\srequirements\smarks\sand\sdocumention.\s\sNo\schanges\sto\scode. -D 2017-07-14T13:24:31.730 +C Change\sthe\sname\sof\sthe\sSTMT\svirtual\stable\sto\sSQLITE_STMT.\s\sAlso\sremove\sthe\nfirst\scolumn\sof\sthat\svirtual\stable,\swhich\swas\sa\spointer\sleak. +D 2017-07-14T15:14:21.567 F Makefile.in 081e48dfe7f995d57ce1a88ddf4d2917b4349158648a6cd45b42beae30de3a12 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 20850e3e8d4d4791e0531955852d768eb06f24138214870d543abb1a47346fba @@ -279,7 +279,7 @@ F ext/misc/sha1.c 0b9e9b855354910d3ca467bf39099d570e73db56 F ext/misc/shathree.c fa185d7aee0ad0aca5e091b4a2db7baff11796170e5793b5de99e511a13af448 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c a4723b6aff748a417b5091b68a46443265c40f0d -F ext/misc/stmt.c de7f8e172b319f9f708bd31b15a048e31dc4f73639454fe23a6b31bf8a7ea1d6 +F ext/misc/stmt.c 6f16443abb3551e3f5813bb13ba19a30e7032830015b0f92fe0c0453045c0a11 F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95 F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178 @@ -1219,7 +1219,7 @@ F test/sqllog.test 6af6cb0b09f4e44e1917e06ce85be7670302517a F test/stat.test f8f1279ffffabe6df825723af18cc6e0ae70a893 F test/statfault.test f525a7bf633e50afd027700e9a486090684b1ac1 F test/stmt.test 64844332db69cf1a735fcb3e11548557fc95392f -F test/stmtvtab1.test 2a3cee496574ee9515e5e7a92fb8d9447903ccc14536a21545debeda267ff3c8 +F test/stmtvtab1.test b80b7f094a8f6d2169b1829b8de560854a8a75a9133a91a0720d7e070ad5b78d F test/subjournal.test 8d4e2572c0ee9a15549f0d8e40863161295107e52f07a3e8012a2e1fdd093c49 F test/subquery.test d7268d193dd33d5505df965399d3a594e76ae13f F test/subquery2.test 438f8a7da1457277b22e4176510f7659b286995f @@ -1633,7 +1633,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5e0a97930b08fff1c3a29f5c8b2962b856e3302209228c0e71b9f1a1bd2a4be3 -R dd78cda04979d081da1d882e6fd9450f +P 8f6dd5e2907d6df230fcbceadd226496bcc35a33c117da58215f7d333c1cc7b8 +R d7ac96e41b37a88b9f135fb6c72561d0 U drh -Z 7de81f651ca39e245dd8aa975678bc00 +Z 482dd4c891cb2dc290167d2cf7fdb136 diff --git a/manifest.uuid b/manifest.uuid index 9636ec81a8..cf87dd9abe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8f6dd5e2907d6df230fcbceadd226496bcc35a33c117da58215f7d333c1cc7b8 \ No newline at end of file +1bc4e93407b7894b0271fbde3720930dcaadda6070e871d9719c4e8dc65b915f \ No newline at end of file diff --git a/test/stmtvtab1.test b/test/stmtvtab1.test index 4c80836f6a..34abdfc108 100644 --- a/test/stmtvtab1.test +++ b/test/stmtvtab1.test @@ -32,21 +32,21 @@ do_execsql_test stmtvtab1-100 { CREATE TABLE t1(a,b,c); INSERT INTO t1 VALUES($a,$b,$c); CREATE INDEX t1a ON t1(a); - SELECT run, sql FROM stmt ORDER BY 1; -} {1 {SELECT run, sql FROM stmt ORDER BY 1;} 1 {CREATE INDEX t1a ON t1(a);} 1 {INSERT INTO t1 VALUES($a,$b,$c);} 1 {CREATE TABLE t1(a,b,c);}} + SELECT run, sql FROM sqlite_stmt ORDER BY 1; +} {1 {SELECT run, sql FROM sqlite_stmt ORDER BY 1;} 1 {CREATE INDEX t1a ON t1(a);} 1 {INSERT INTO t1 VALUES($a,$b,$c);} 1 {CREATE TABLE t1(a,b,c);}} set x neon set y event set z future do_execsql_test stmtvtab1-110 { INSERT INTO t1 VALUES($a,$b,$c); - SELECT reprep,run,SQL FROM stmt WHERE sql LIKE '%INSERT%' AND NOT busy; + SELECT reprep,run,SQL FROM sqlite_stmt WHERE sql LIKE '%INSERT%' AND NOT busy; } {1 2 {INSERT INTO t1 VALUES($a,$b,$c);}} set x network set y fit set z metal do_execsql_test stmtvtab1-120 { INSERT INTO t1 VALUES($a,$b,$c); - SELECT reprep,run,SQL FROM stmt WHERE sql LIKE '%INSERT%' AND NOT busy; + SELECT reprep,run,SQL FROM sqlite_stmt WHERE sql LIKE '%INSERT%' AND NOT busy; } {1 3 {INSERT INTO t1 VALUES($a,$b,$c);}} set x history set y detail @@ -54,26 +54,26 @@ set z grace do_execsql_test stmtvtab1-130 { CREATE INDEX t1b ON t1(b); INSERT INTO t1 VALUES($a,$b,$c); - SELECT reprep,run,SQL FROM stmt WHERE sql LIKE '%INSERT%' AND NOT busy; + SELECT reprep,run,SQL FROM sqlite_stmt WHERE sql LIKE '%INSERT%' AND NOT busy; } {2 4 {INSERT INTO t1 VALUES($a,$b,$c);}} # All statements are still in cache # do_execsql_test stmtvtab1-140 { - SELECT count(*) FROM stmt WHERE NOT busy; + SELECT count(*) FROM sqlite_stmt WHERE NOT busy; } {6} # None of the prepared statements should use more than a couple thousand # bytes of memory # -#db eval {SELECT mem, sql FROM stmt} {puts [format {%5d %s} $mem $sql]} +#db eval {SELECT mem, sql FROM sqlite_stmt} {puts [format {%5d %s} $mem $sql]} do_execsql_test stmtvtab1-150 { - SELECT count(*) FROM stmt WHERE mem>5000; + SELECT count(*) FROM sqlite_stmt WHERE mem>5000; } {0} # Flushing the cache clears all of the prepared statements. # db cache flush do_execsql_test stmtvtab1-160 { - SELECT * FROM stmt WHERE NOT busy; + SELECT * FROM sqlite_stmt WHERE NOT busy; } {}