]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
If a table-constraint PRIMARY KEY lists a single column in single-quotes and
authordrh <drh@noemail.net>
Sun, 1 Nov 2015 21:35:04 +0000 (21:35 +0000)
committerdrh <drh@noemail.net>
Sun, 1 Nov 2015 21:35:04 +0000 (21:35 +0000)
that column has type INTEGER, then make that column an integer primary key,
for historical compatibility.  Fix for ticket [ac661962a2aeab3c331].

FossilOrigin-Name: dab0e60768aa93edf44ff380198c64475fb2a67f

manifest
manifest.uuid
src/build.c
test/index3.test

index 4136b6383dbf9c06ef4dad180acdd53002f48ca7..f42292b85ab59a1fcc37e4d79fe628597472ce87 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Version\s3.9.1
-D 2015-10-16T17:31:12.550
+C If\sa\stable-constraint\sPRIMARY\sKEY\slists\sa\ssingle\scolumn\sin\ssingle-quotes\sand\nthat\scolumn\shas\stype\sINTEGER,\sthen\smake\sthat\scolumn\san\sinteger\sprimary\skey,\nfor\shistorical\scompatibility.\s\sFix\sfor\sticket\s[ac661962a2aeab3c331].
+D 2015-11-01T21:35:04.854
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in f0088ff0d2ac949fce6de7c00f13a99ac5bdb663
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -288,7 +288,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79
 F src/btree.c 0b74bc28b2dc907cba03b5b4b3b81584273be699
 F src/btree.h 40189aefdc2b830d25c8b58fd7d56538481bfdd7
 F src/btreeInt.h 8177c9ab90d772d6d2c6c517e05bed774b7c92c0
-F src/build.c d6162335d690396dfc5c4bd59e8b2b0c14ba6285
+F src/build.c ca574d33ffb1763cfd2979383f4d507095bfbe19
 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0
 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f
 F src/ctime.c 509ef9c64d1321f42448f111da86400b1799218a
@@ -783,7 +783,7 @@ F test/incrvacuum3.test 75256fb1377e7c39ef2de62bfc42bbff67be295a
 F test/incrvacuum_ioerr.test 6ae2f783424e47a0033304808fe27789cf93e635
 F test/index.test fe3c7a1aad82af92623747e9c3f3aa94ccd51238
 F test/index2.test f835d5e13ca163bd78c4459ca15fd2e4ed487407
-F test/index3.test fa3e49bbaa4f38091c9c742e36a1abe67c4ef1fc
+F test/index3.test 81bc47890b8abfb181bc35f8d10b56c069803386
 F test/index4.test ab92e736d5946840236cd61ac3191f91a7856bf6
 F test/index5.test 8621491915800ec274609e42e02a97d67e9b13e7
 F test/index6.test 7102ec371414c42dfb1d5ca37eb4519aa9edc23a
@@ -1390,10 +1390,8 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 746fcd2fd412ddc27071827fb20eb6df0741dfb1
-R d66bf398f8de1fb81851cd37ab3877c3
-T +bgcolor * #d0c0ff
-T +sym-release *
-T +sym-version-3.9.1 *
+P 767c1727fec4ce11b83f25b3f1bfcfe68a2c8b02
+Q +db319a035feeb6f8fcd04f90fb10cd4b06e68184
+R 67fbe85b4337b6b1381d2d40883a103e
 U drh
-Z 1827cdee71f363c0f73376b432ed6e27
+Z 2cf6025ddb52bc68956133a240e5a6b3
index b00e53a180816b396be0f848e2361f66a5d219c4..37cb1ecd85d25c69c375360210cdf4d1f68df2b2 100644 (file)
@@ -1 +1 @@
-767c1727fec4ce11b83f25b3f1bfcfe68a2c8b02
\ No newline at end of file
+dab0e60768aa93edf44ff380198c64475fb2a67f
\ No newline at end of file
index 7c79fe54007a2948558918246dea4dffcf31510a..8cb2d44ac79ab619e0c565b2a4d0410a1b671e51 100644 (file)
@@ -1271,6 +1271,30 @@ void sqlite3AddDefaultValue(Parse *pParse, ExprSpan *pSpan){
   sqlite3ExprDelete(db, pSpan->pExpr);
 }
 
+/*
+** Backwards Compatibility Hack:
+** 
+** Historical versions of SQLite accepted strings as column names in
+** indexes and PRIMARY KEY constraints and in UNIQUE constraints.  Example:
+**
+**     CREATE TABLE xyz(a,b,c,d,e,PRIMARY KEY('a'),UNIQUE('b','c' COLLATE trim)
+**     CREATE INDEX abc ON xyz('c','d' DESC,'e' COLLATE nocase DESC);
+**
+** This is goofy.  But to preserve backwards compatibility we continue to
+** accept it.  This routine does the necessary conversion.  It converts
+** the expression given in its argument from a TK_STRING into a TK_ID
+** if the expression is just a TK_STRING with an optional COLLATE clause.
+** If the epxression is anything other than TK_STRING, the expression is
+** unchanged.
+*/
+static void sqlite3StringToId(Expr *p){
+  if( p->op==TK_STRING ){
+    p->op = TK_ID;
+  }else if( p->op==TK_COLLATE && p->pLeft->op==TK_STRING ){
+    p->pLeft->op = TK_ID;
+  }
+}
+
 /*
 ** Designate the PRIMARY KEY for the table.  pList is a list of names 
 ** of columns that form the primary key.  If pList is NULL, then the
@@ -1317,6 +1341,7 @@ void sqlite3AddPrimaryKey(
     for(i=0; i<nTerm; i++){
       Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr);
       assert( pCExpr!=0 );
+      sqlite3StringToId(pCExpr);
       if( pCExpr->op==TK_ID ){
         const char *zCName = pCExpr->u.zToken;
         for(iCol=0; iCol<pTab->nCol; iCol++){
@@ -2855,30 +2880,6 @@ Index *sqlite3AllocateIndexObject(
   return p;
 }
 
-/*
-** Backwards Compatibility Hack:
-** 
-** Historical versions of SQLite accepted strings as column names in
-** indexes and PRIMARY KEY constraints and in UNIQUE constraints.  Example:
-**
-**     CREATE TABLE xyz(a,b,c,d,e,PRIMARY KEY('a'),UNIQUE('b','c' COLLATE trim)
-**     CREATE INDEX abc ON xyz('c','d' DESC,'e' COLLATE nocase DESC);
-**
-** This is goofy.  But to preserve backwards compatibility we continue to
-** accept it.  This routine does the necessary conversion.  It converts
-** the expression given in its argument from a TK_STRING into a TK_ID
-** if the expression is just a TK_STRING with an optional COLLATE clause.
-** If the epxression is anything other than TK_STRING, the expression is
-** unchanged.
-*/
-static void sqlite3StringToId(Expr *p){
-  if( p->op==TK_STRING ){
-    p->op = TK_ID;
-  }else if( p->op==TK_COLLATE && p->pLeft->op==TK_STRING ){
-    p->pLeft->op = TK_ID;
-  }
-}
-
 /*
 ** Create a new index for an SQL table.  pName1.pName2 is the name of the index 
 ** and pTblList is the name of the table that is to be indexed.  Both will 
index 1d90de1b9bbc3cec0ce6d18e19ee60de5f95f5b9..4c00a852d214bda62d3bc241751da2eee80c705b 100644 (file)
@@ -62,6 +62,21 @@ do_execsql_test index3-2.2eqp {
   EXPLAIN QUERY PLAN
   SELECT a FROM t1 WHERE b='ab005xy' COLLATE nocase;
 } {/USING INDEX/}
+do_execsql_test index3-2.3 {
+  SELECT name FROM sqlite_master WHERE tbl_name='t1' ORDER BY name
+} {sqlite_autoindex_t1_1 sqlite_autoindex_t1_2 t1 t1c t1d}
+do_execsql_test index3-2.4 {
+  CREATE TABLE t2a(a integer, b, PRIMARY KEY(a));
+  CREATE TABLE t2b("a" integer, b, PRIMARY KEY("a"));
+  CREATE TABLE t2c([a] integer, b, PRIMARY KEY([a]));
+  CREATE TABLE t2d('a' integer, b, PRIMARY KEY('a'));
+}
+do_execsql_test index3-2.5 {
+  SELECT name FROM sqlite_master WHERE tbl_name LIKE 't2_' ORDER BY name
+} {t2a t2b t2c t2d}
+
+
 
 
 # This test corrupts the database file so it must be the last test