From: drh Date: Tue, 8 Dec 2009 14:34:08 +0000 (+0000) Subject: Allow zero-length names for tables, columns, and indices. X-Git-Tag: version-3.7.2~732 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=972a23119e32020f98d0685267500886617ec4db;p=thirdparty%2Fsqlite.git Allow zero-length names for tables, columns, and indices. Fix for ticket [78e04e52eaf]. FossilOrigin-Name: 7b1cfd65a6f7c85ef8f6e4622973457cff9d007c --- diff --git a/manifest b/manifest index 135c4245d7..f0c10b2e4f 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Add\stest\scases\sfor\sticket\s[abe728bbc311]. -D 2009-12-08T13:44:22 +C Allow\szero-length\snames\sfor\stables,\scolumns,\sand\sindices.\nFix\sfor\sticket\s[78e04e52eaf]. +D 2009-12-08T14:34:08 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -114,7 +114,7 @@ F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff F src/btree.c efdef3953c49e28f8b8fa9cc0ac5754cc1a7489a F src/btree.h 7944a9dac59eb3e541aad45fd2747f1051e7c63d F src/btreeInt.h 54f4245decd0409ea52cf9aee422d3d761d7ac10 -F src/build.c a48e74d24897100017d39ceba5de255e53ec9488 +F src/build.c 5a18b6846e99cb923008a8c888d3fd520f0bea52 F src/callback.c 908f3e0172c3d4058f4ca0acd42c637c52e9669f F src/complete.c 417df1ef5ea798532bb6290b0cc4265fef82980a F src/date.c a79c0a8f219370b972e320741f995a3bef9df33f @@ -605,6 +605,7 @@ F test/tkt-2ea2425d34.test 1cf13e6f75d149b3209a0cb32927a82d3d79fb28 F test/tkt-3fe897352e.test 8084dad39807eac10b10720c84193bd1a5980973 F test/tkt-4a03edc4c8.test 2865e4edbc075b954daa82f8da7cc973033ec76e F test/tkt-5ee23731f.test 3581260f2a71e51db94e1506ba6b0f7311d002a9 +F test/tkt-78e04e52ea.test fb5430c675e708f5cbafdf3e7e5593da5145a527 F test/tkt-94c04eaadb.test be5ea61cb04dfdc047d19b5c5a9e75fa3da67a7f F test/tkt-d82e3f3721.txt cbed12b1a1e4740382de43ef1bb45c6bc0f8f473 F test/tkt-f777251dc7a.test 6f24c053bc5cdb7e1e19be9a72c8887cf41d5e87 @@ -779,14 +780,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P f43e37e0a4cc7c15c996f4404dc775636396567d -R a6057ef92cd48c83669480ba55d2643b +P 4eb9bf0b93a564844f133691936593245aa792fc +R 7eeb7797797e30a8ad051eacc36b8fb3 U drh -Z fd58c7a3cb08c42b6b4250242de672b0 +Z e526c487a3b49cc4dcbee58d5a1860ea -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLHlg5oxKgR168RlERAvB9AJ4nxLXTHzdJNAWzf6gE5d3v6rF0PwCdFQAo -Yt9AhO556H3dKXJY78hPmrU= -=P/Ej +iD8DBQFLHmPjoxKgR168RlERAn8sAJ4zKC7D2a/28/ZL3xk1TkNKmpgL5gCfQVhb +CrcH8bMVvWBkMeQMDvUm5sA= +=MAb9 -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index e4c27740c0..c3154e88f7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4eb9bf0b93a564844f133691936593245aa792fc \ No newline at end of file +7b1cfd65a6f7c85ef8f6e4622973457cff9d007c \ No newline at end of file diff --git a/src/build.c b/src/build.c index d8097a760f..7772c4114c 100644 --- a/src/build.c +++ b/src/build.c @@ -549,7 +549,8 @@ void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char *zTabName){ assert( db!=0 ); assert( iDb>=0 && iDbnDb ); - assert( zTabName && zTabName[0] ); + assert( zTabName ); + testcase( zTabName[0]==0 ); /* Zero-length table names are allowed */ pDb = &db->aDb[iDb]; p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName, sqlite3Strlen30(zTabName),0); diff --git a/test/tkt-78e04e52ea.test b/test/tkt-78e04e52ea.test new file mode 100644 index 0000000000..9cd25f5d40 --- /dev/null +++ b/test/tkt-78e04e52ea.test @@ -0,0 +1,68 @@ +# 2009 December 8 +# +# 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. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. +# +# Verify that we can create zero-length tables. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +do_test tkt-78e04-1.0 { + execsql { + CREATE TABLE ""("" UNIQUE); + CREATE TABLE t2(x); + INSERT INTO "" VALUES(1); + INSERT INTO t2 VALUES(2); + SELECT * FROM "", t2; + } +} {1 2} +do_test tkt-78e04-1.1 { + catchsql { + INSERT INTO "" VALUES(1); + } +} {1 {column is not unique}} +do_test tkt-78e04-1.2 { + execsql { + PRAGMA table_info(""); + } +} {0 {} {} 0 {} 0} +do_test tkt-78e04-1.3 { + execsql { + CREATE INDEX i1 ON ""("" COLLATE nocase); + } +} {} +do_test tkt-78e04-1.4 { + execsql { + EXPLAIN QUERY PLAN SELECT * FROM "" WHERE "" LIKE 'abc%'; + } +} {0 0 {TABLE }} +do_test tkt-78e04-1.5 { + execsql { + DROP TABLE ""; + SELECT name FROM sqlite_master; + } +} {t2} + +do_test tkt-78e04-2.1 { + execsql { + CREATE INDEX "" ON t2(x); + EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE x=5; + } +} {0 0 {TABLE t2 WITH INDEX }} +do_test tkt-78e04-2.2 { + execsql { + DROP INDEX ""; + EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE x=2; + } +} {0 0 {TABLE t2}} + +finish_test