]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Have the dbstat module dequote any argument passed to the CREATE VIRTUAL TABLE statem...
authordan <dan@noemail.net>
Fri, 22 Jan 2016 15:44:07 +0000 (15:44 +0000)
committerdan <dan@noemail.net>
Fri, 22 Jan 2016 15:44:07 +0000 (15:44 +0000)
FossilOrigin-Name: e60461e984b8df09256bb0d733dbfae52568a145

manifest
manifest.uuid
src/dbstat.c
test/stat.test

index 5d0ee23cca88fee2ee79cd394e19730b4f9a8104..c4697a9a83e1b4c7324e420298ecf9f8c7c1d90a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Enable\sFTS4\swhen\sbuilding\sthe\sshell\swith\sthe\sMSVC\smakefile.
-D 2016-01-22T04:22:36.961
+C Have\sthe\sdbstat\smodule\sdequote\sany\sargument\spassed\sto\sthe\sCREATE\sVIRTUAL\sTABLE\sstatement\sbefore\sattempting\sto\smatch\sit\sagainst\sthe\snames\sof\sattached\sdatabases.
+D 2016-01-22T15:44:07.317
 F Makefile.in 027c1603f255390c43a426671055a31c0a65fdb4
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc d2b93511a969c0c8fcf52aeb5e426571e8c610d2
@@ -296,7 +296,7 @@ F src/callback.c 29ae4faba226c7ebb9aee93016b5ce8a8f071261
 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f
 F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198
 F src/date.c 997651e3ee6c2818fbf7fcdb7156cef9eb3ece20
-F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78
+F src/dbstat.c d33af6b426449d7bfd5b3d9f77911c20d1c8abdc
 F src/delete.c 00af9f08a15ddc5cba5962d3d3e5bf2d67b2e7da
 F src/expr.c df0d7c3230d59abd679da22ff5ce4cfd0e3a0e63
 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
@@ -1052,7 +1052,7 @@ F test/spellfix3.test f7bf7b3482971473d32b6b00f6944c5c066cff97
 F test/sqldiff1.test 8f6bc7c6a5b3585d350d779c6078869ba402f8f5
 F test/sqllimits1.test a74ee2a3740b9f9c2437c246d8fb77354862a142
 F test/sqllog.test a8faa2df39610a037dd372ed872d124260d32953
-F test/stat.test 8de91498c99f5298b303f70f1d1f3b9557af91bf
+F test/stat.test fafe6e82dfdb97d8c8be31cd83e36e973079ce0f
 F test/statfault.test f525a7bf633e50afd027700e9a486090684b1ac1
 F test/stmt.test 25d64e3dbf9a3ce89558667d7f39d966fe2a71b9
 F test/subquery.test d7268d193dd33d5505df965399d3a594e76ae13f
@@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 67625b963a6f5a0c6dff1a04a323e693569c2d94
-R a9194694e295a05f59bbd77f1c470bc0
-U mistachkin
-Z bf1c280948a8257fdbbacb5c97da93b0
+P e4c07df557cd50786b05eecf011bf94708e6e31b
+R ccbd95b5668f9b5a41b204404932d800
+U dan
+Z ad5fc4f27f7e976928da8b4460d48d82
index 533751ec8ab1e30ea50142a731575363f7aa63eb..800a36102ebc1e81cff762c7fd9f2a056eae2e75 100644 (file)
@@ -1 +1 @@
-e4c07df557cd50786b05eecf011bf94708e6e31b
\ No newline at end of file
+e60461e984b8df09256bb0d733dbfae52568a145
\ No newline at end of file
index ae55d6b803800f9ae5c76401e3ccc9b330fe7105..e404c71dd3456db37dab159064251635c7b64485 100644 (file)
@@ -149,7 +149,11 @@ static int statConnect(
   int iDb;
 
   if( argc>=4 ){
-    iDb = sqlite3FindDbName(db, argv[3]);
+    char *zDb = sqlite3DbStrDup(db, argv[3]);
+    if( zDb==0 ) return SQLITE_NOMEM;
+    sqlite3Dequote(zDb);
+    iDb = sqlite3FindDbName(db, zDb);
+    sqlite3DbFree(db, zDb);
     if( iDb<0 ){
       *pzErr = sqlite3_mprintf("no such database: %s", argv[3]);
       return SQLITE_ERROR;
index 57c1b9eae166b684cd579dda324cd46d53b683fc..14751bd6ff36401fd3e03ae155f89b4e18d4dae3 100644 (file)
@@ -14,6 +14,7 @@
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
+set testprefix stat
 
 ifcapable !vtab||!compound {
   finish_test
@@ -184,4 +185,69 @@ do_catchsql_test stat-6.1 {
   CREATE VIRTUAL TABLE temp.s2 USING dbstat(mainx);
 } {1 {no such database: mainx}}
 
+#-------------------------------------------------------------------------
+# Test that the argument passed to the dbstat constructor is dequoted
+# before it is matched against the names of attached databases.
+#
+forcedelete test.db2
+do_execsql_test 7.1 {
+  ATTACH 'test.db2' AS '123';
+  CREATE TABLE "123".x1(a, b);
+  INSERT INTO x1 VALUES(1, 2);
+}
+
+do_execsql_test 7.1.1 {
+  SELECT * FROM dbstat('123');
+} {
+  sqlite_master / 1 leaf 1 37 875 37 0 1024 
+  x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+do_execsql_test 7.1.2 {
+  SELECT * FROM dbstat(123);
+} {
+  sqlite_master / 1 leaf 1 37 875 37 0 1024 
+  x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+do_execsql_test 7.1.3 {
+  CREATE VIRTUAL TABLE x2 USING dbstat('123');
+  SELECT * FROM x2;
+} {
+  sqlite_master / 1 leaf 1 37 875 37 0 1024 
+  x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+do_execsql_test 7.1.4 {
+  CREATE VIRTUAL TABLE x3 USING dbstat(123);
+  SELECT * FROM x3;
+} {
+  sqlite_master / 1 leaf 1 37 875 37 0 1024 
+  x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+
+do_execsql_test 7.2 {
+  DETACH 123;
+  DROP TABLE x2;
+  DROP TABLE x3;
+  ATTACH 'test.db2' AS '123corp';
+}
+do_execsql_test 7.2.1 {
+  SELECT * FROM dbstat('123corp');
+} {
+  sqlite_master / 1 leaf 1 37 875 37 0 1024 
+  x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+do_catchsql_test 7.2.2 {
+  SELECT * FROM dbstat(123corp);
+} {1 {unrecognized token: "123corp"}}
+do_execsql_test 7.2.3 {
+  CREATE VIRTUAL TABLE x2 USING dbstat('123corp');
+  SELECT * FROM x2;
+} {
+  sqlite_master / 1 leaf 1 37 875 37 0 1024 
+  x1 / 2 leaf 1 4 1008 4 1024 1024
+}
+do_catchsql_test 7.2.4 {
+  CREATE VIRTUAL TABLE x3 USING dbstat(123corp);
+  SELECT * FROM x3;
+} {1 {unrecognized token: "123corp"}}
+
 finish_test