From: drh Date: Tue, 22 Oct 2013 01:18:17 +0000 (+0000) Subject: Previous refactor is not going to be helpful because implied indices must be X-Git-Tag: version-3.8.2~137^2~72 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8ea30bfcbc1b70aff6abac7bc7daefc5078fc00e;p=thirdparty%2Fsqlite.git Previous refactor is not going to be helpful because implied indices must be created in the same order that they appear in the CREATE TABLE statement for backwards compatibility. This is a much smaller change to clean up a few loose ends. FossilOrigin-Name: 824b549f9b42935609b283d51f6c386da89a08a7 --- diff --git a/manifest b/manifest index c5c2651232..38f44944ea 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplification\sof\sthe\ssyntax:\s\sMerely\sappend\s"WITHOUT\srowid"\sto\sthe\send\sof\nthe\stable\sdefinition. -D 2013-10-21T02:14:45.234 +C Previous\srefactor\sis\snot\sgoing\sto\sbe\shelpful\sbecause\simplied\sindices\smust\sbe\ncreated\sin\sthe\ssame\sorder\sthat\sthey\sappear\sin\sthe\sCREATE\sTABLE\sstatement\nfor\sbackwards\scompatibility.\s\sThis\sis\sa\smuch\ssmaller\schange\sto\sclean\sup\sa\nfew\sloose\sends. +D 2013-10-22T01:18:17.015 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 0522b53cdc1fcfc18f3a98e0246add129136c654 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -168,7 +168,7 @@ F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c 509722ce305471b626d3401c0631a808fd33237b F src/btree.h bfe0e8c5759b4ec77b0d18390064a6ef3cdffaaf F src/btreeInt.h f038e818bfadf75afbd09819ed93c26a333d39e0 -F src/build.c 34096edeeb606354dc7e4b3e5b5b4aa66552d64a +F src/build.c 06b5fbc1f50b274388129f6438cbfdfe43733384 F src/callback.c f99a8957ba2adf369645fac0db09ad8adcf1caa2 F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c ea4b7f3623a0fcb1146e7f245d7410033e86859c @@ -1127,7 +1127,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 0248ec5e6e3797575388f046d8c27f7445fe2a39 -R e0ffffb04f34ea8648db0bbf67f5a7fc +P 131cc6e152abe1a2d48e6d8d40d2c2f8dbe723e7 +R 54bdf6646aff1f9967ce8b64fbd84f07 U drh -Z 31b116f5cf081a48ed8c95100c024626 +Z 08be2e08ad7edb9bab0058e9dd4f6679 diff --git a/manifest.uuid b/manifest.uuid index 5c592f0b91..4bc28c27fc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -131cc6e152abe1a2d48e6d8d40d2c2f8dbe723e7 \ No newline at end of file +824b549f9b42935609b283d51f6c386da89a08a7 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 8cee89200d..cac5c89d41 100644 --- a/src/build.c +++ b/src/build.c @@ -1214,6 +1214,7 @@ void sqlite3AddPrimaryKey( Table *pTab = pParse->pNewTable; char *zType = 0; int iCol = -1, i; + int nTerm; if( pTab==0 || IN_DECLARE_VTAB ) goto primary_key_exit; if( pTab->tabFlags & TF_HasPrimaryKey ){ sqlite3ErrorMsg(pParse, @@ -1224,24 +1225,24 @@ void sqlite3AddPrimaryKey( if( pList==0 ){ iCol = pTab->nCol - 1; pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY; + zType = pTab->aCol[iCol].zType; + nTerm = 1; }else{ - for(i=0; inExpr; i++){ + nTerm = pList->nExpr; + for(i=0; inCol; iCol++){ if( sqlite3StrICmp(pList->a[i].zName, pTab->aCol[iCol].zName)==0 ){ + pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY; + zType = pTab->aCol[iCol].zType; break; } } - if( iColnCol ){ - pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY; - } } - if( pList->nExpr>1 ) iCol = -1; - } - if( iCol>=0 && iColnCol ){ - zType = pTab->aCol[iCol].zType; } - if( zType && sqlite3StrICmp(zType, "INTEGER")==0 - && sortOrder==SQLITE_SO_ASC ){ + if( nTerm==1 + && zType && sqlite3StrICmp(zType, "INTEGER")==0 + && sortOrder==SQLITE_SO_ASC + ){ pTab->iPKey = iCol; pTab->keyConf = (u8)onError; assert( autoInc==0 || autoInc==1 ); @@ -1679,8 +1680,9 @@ void sqlite3EndTable( if( pSelect ){ zStmt = createTableStmt(db, p); }else{ - n = (int)(pParse->sLastToken.z - pParse->sNameToken.z); - if( pParse->sLastToken.z[0]!=';' ) n += pParse->sLastToken.n; + Token *pEnd2 = tabOpts ? &pParse->sLastToken : pEnd; + n = (int)(pEnd2->z - pParse->sNameToken.z); + if( pEnd2->z[0]!=';' ) n += pEnd2->n; zStmt = sqlite3MPrintf(db, "CREATE %s %.*s", zType2, n, pParse->sNameToken.z );