Fossil SCM
Update SQLite to the latest trunk, with support for the foreign_key_check pragma.
Commit
558a17a686249c788569e696156314cc4cd930bf
Parent
c89a694d5462bd0…
2 files changed
+190
-39
+1
-1
+190
-39
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -673,11 +673,11 @@ | ||
| 673 | 673 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 674 | 674 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 675 | 675 | */ |
| 676 | 676 | #define SQLITE_VERSION "3.7.16" |
| 677 | 677 | #define SQLITE_VERSION_NUMBER 3007016 |
| 678 | -#define SQLITE_SOURCE_ID "2012-12-14 17:54:38 3d65c70343196b8f69c5293e7703839846fade85" | |
| 678 | +#define SQLITE_SOURCE_ID "2012-12-21 16:15:35 ff6857b6ed6a46671006b75157d8cf853a816ef9" | |
| 679 | 679 | |
| 680 | 680 | /* |
| 681 | 681 | ** CAPI3REF: Run-Time Library Version Numbers |
| 682 | 682 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 683 | 683 | ** |
| @@ -11171,10 +11171,11 @@ | ||
| 11171 | 11171 | #define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */ |
| 11172 | 11172 | #define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */ |
| 11173 | 11173 | #define SF_UseSorter 0x0040 /* Sort using a sorter */ |
| 11174 | 11174 | #define SF_Values 0x0080 /* Synthesized from VALUES clause */ |
| 11175 | 11175 | #define SF_Materialize 0x0100 /* Force materialization of views */ |
| 11176 | +#define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */ | |
| 11176 | 11177 | |
| 11177 | 11178 | |
| 11178 | 11179 | /* |
| 11179 | 11180 | ** The results of a select can be distributed in several ways. The |
| 11180 | 11181 | ** "SRT" prefix means "SELECT Result Type". |
| @@ -11883,11 +11884,11 @@ | ||
| 11883 | 11884 | SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, |
| 11884 | 11885 | Token*, int, int); |
| 11885 | 11886 | SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int); |
| 11886 | 11887 | SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*); |
| 11887 | 11888 | SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, |
| 11888 | - Expr*,ExprList*,int,Expr*,Expr*); | |
| 11889 | + Expr*,ExprList*,u16,Expr*,Expr*); | |
| 11889 | 11890 | SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*); |
| 11890 | 11891 | SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*); |
| 11891 | 11892 | SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int); |
| 11892 | 11893 | SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); |
| 11893 | 11894 | #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) |
| @@ -12278,12 +12279,14 @@ | ||
| 12278 | 12279 | #define sqlite3FkOldmask(a,b) 0 |
| 12279 | 12280 | #define sqlite3FkRequired(a,b,c,d) 0 |
| 12280 | 12281 | #endif |
| 12281 | 12282 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 12282 | 12283 | SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*); |
| 12284 | +SQLITE_PRIVATE int sqlite3FkLocateIndex(Parse*,Table*,FKey*,Index**,int**); | |
| 12283 | 12285 | #else |
| 12284 | 12286 | #define sqlite3FkDelete(a,b) |
| 12287 | + #define sqlite3FkLocateIndex(a,b,c,d,e) | |
| 12285 | 12288 | #endif |
| 12286 | 12289 | |
| 12287 | 12290 | |
| 12288 | 12291 | /* |
| 12289 | 12292 | ** Available fault injectors. Should be numbered beginning with 0. |
| @@ -56869,11 +56872,16 @@ | ||
| 56869 | 56872 | /* |
| 56870 | 56873 | ** Parameter zSrcData points to a buffer containing the data for |
| 56871 | 56874 | ** page iSrcPg from the source database. Copy this data into the |
| 56872 | 56875 | ** destination database. |
| 56873 | 56876 | */ |
| 56874 | -static int backupOnePage(sqlite3_backup *p, Pgno iSrcPg, const u8 *zSrcData){ | |
| 56877 | +static int backupOnePage( | |
| 56878 | + sqlite3_backup *p, /* Backup handle */ | |
| 56879 | + Pgno iSrcPg, /* Source database page to backup */ | |
| 56880 | + const u8 *zSrcData, /* Source database page data */ | |
| 56881 | + int bUpdate /* True for an update, false otherwise */ | |
| 56882 | +){ | |
| 56875 | 56883 | Pager * const pDestPager = sqlite3BtreePager(p->pDest); |
| 56876 | 56884 | const int nSrcPgsz = sqlite3BtreeGetPageSize(p->pSrc); |
| 56877 | 56885 | int nDestPgsz = sqlite3BtreeGetPageSize(p->pDest); |
| 56878 | 56886 | const int nCopy = MIN(nSrcPgsz, nDestPgsz); |
| 56879 | 56887 | const i64 iEnd = (i64)iSrcPg*(i64)nSrcPgsz; |
| @@ -56942,10 +56950,13 @@ | ||
| 56942 | 56950 | ** cached parse of the page). MemPage.isInit is marked |
| 56943 | 56951 | ** "MUST BE FIRST" for this purpose. |
| 56944 | 56952 | */ |
| 56945 | 56953 | memcpy(zOut, zIn, nCopy); |
| 56946 | 56954 | ((u8 *)sqlite3PagerGetExtra(pDestPg))[0] = 0; |
| 56955 | + if( iOff==0 && bUpdate==0 ){ | |
| 56956 | + sqlite3Put4byte(&zOut[28], sqlite3BtreeLastPage(p->pSrc)); | |
| 56957 | + } | |
| 56947 | 56958 | } |
| 56948 | 56959 | sqlite3PagerUnref(pDestPg); |
| 56949 | 56960 | } |
| 56950 | 56961 | |
| 56951 | 56962 | return rc; |
| @@ -57048,11 +57059,11 @@ | ||
| 57048 | 57059 | const Pgno iSrcPg = p->iNext; /* Source page number */ |
| 57049 | 57060 | if( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) ){ |
| 57050 | 57061 | DbPage *pSrcPg; /* Source page object */ |
| 57051 | 57062 | rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg); |
| 57052 | 57063 | if( rc==SQLITE_OK ){ |
| 57053 | - rc = backupOnePage(p, iSrcPg, sqlite3PagerGetData(pSrcPg)); | |
| 57064 | + rc = backupOnePage(p, iSrcPg, sqlite3PagerGetData(pSrcPg), 0); | |
| 57054 | 57065 | sqlite3PagerUnref(pSrcPg); |
| 57055 | 57066 | } |
| 57056 | 57067 | } |
| 57057 | 57068 | p->iNext++; |
| 57058 | 57069 | } |
| @@ -57296,11 +57307,11 @@ | ||
| 57296 | 57307 | ** the new data into the backup. |
| 57297 | 57308 | */ |
| 57298 | 57309 | int rc; |
| 57299 | 57310 | assert( p->pDestDb ); |
| 57300 | 57311 | sqlite3_mutex_enter(p->pDestDb->mutex); |
| 57301 | - rc = backupOnePage(p, iPage, aData); | |
| 57312 | + rc = backupOnePage(p, iPage, aData, 1); | |
| 57302 | 57313 | sqlite3_mutex_leave(p->pDestDb->mutex); |
| 57303 | 57314 | assert( rc!=SQLITE_BUSY && rc!=SQLITE_LOCKED ); |
| 57304 | 57315 | if( rc!=SQLITE_OK ){ |
| 57305 | 57316 | p->rc = rc; |
| 57306 | 57317 | } |
| @@ -71890,10 +71901,18 @@ | ||
| 71890 | 71901 | p->pReal = pReal; |
| 71891 | 71902 | if( p->iSize>0 ){ |
| 71892 | 71903 | assert(p->iSize<=p->nBuf); |
| 71893 | 71904 | rc = sqlite3OsWrite(p->pReal, p->zBuf, p->iSize, 0); |
| 71894 | 71905 | } |
| 71906 | + if( rc!=SQLITE_OK ){ | |
| 71907 | + /* If an error occurred while writing to the file, close it before | |
| 71908 | + ** returning. This way, SQLite uses the in-memory journal data to | |
| 71909 | + ** roll back changes made to the internal page-cache before this | |
| 71910 | + ** function was called. */ | |
| 71911 | + sqlite3OsClose(pReal); | |
| 71912 | + p->pReal = 0; | |
| 71913 | + } | |
| 71895 | 71914 | } |
| 71896 | 71915 | } |
| 71897 | 71916 | return rc; |
| 71898 | 71917 | } |
| 71899 | 71918 | |
| @@ -73519,27 +73538,10 @@ | ||
| 73519 | 73538 | if( sqlite3ResolveExprNames(&sNC, p->pLimit) || |
| 73520 | 73539 | sqlite3ResolveExprNames(&sNC, p->pOffset) ){ |
| 73521 | 73540 | return WRC_Abort; |
| 73522 | 73541 | } |
| 73523 | 73542 | |
| 73524 | - /* Set up the local name-context to pass to sqlite3ResolveExprNames() to | |
| 73525 | - ** resolve the result-set expression list. | |
| 73526 | - */ | |
| 73527 | - sNC.ncFlags = NC_AllowAgg; | |
| 73528 | - sNC.pSrcList = p->pSrc; | |
| 73529 | - sNC.pNext = pOuterNC; | |
| 73530 | - | |
| 73531 | - /* Resolve names in the result set. */ | |
| 73532 | - pEList = p->pEList; | |
| 73533 | - assert( pEList!=0 ); | |
| 73534 | - for(i=0; i<pEList->nExpr; i++){ | |
| 73535 | - Expr *pX = pEList->a[i].pExpr; | |
| 73536 | - if( sqlite3ResolveExprNames(&sNC, pX) ){ | |
| 73537 | - return WRC_Abort; | |
| 73538 | - } | |
| 73539 | - } | |
| 73540 | - | |
| 73541 | 73543 | /* Recursively resolve names in all subqueries |
| 73542 | 73544 | */ |
| 73543 | 73545 | for(i=0; i<p->pSrc->nSrc; i++){ |
| 73544 | 73546 | struct SrcList_item *pItem = &p->pSrc->a[i]; |
| 73545 | 73547 | if( pItem->pSelect ){ |
| @@ -73562,10 +73564,27 @@ | ||
| 73562 | 73564 | for(pNC=pOuterNC; pNC; pNC=pNC->pNext) nRef -= pNC->nRef; |
| 73563 | 73565 | assert( pItem->isCorrelated==0 && nRef<=0 ); |
| 73564 | 73566 | pItem->isCorrelated = (nRef!=0); |
| 73565 | 73567 | } |
| 73566 | 73568 | } |
| 73569 | + | |
| 73570 | + /* Set up the local name-context to pass to sqlite3ResolveExprNames() to | |
| 73571 | + ** resolve the result-set expression list. | |
| 73572 | + */ | |
| 73573 | + sNC.ncFlags = NC_AllowAgg; | |
| 73574 | + sNC.pSrcList = p->pSrc; | |
| 73575 | + sNC.pNext = pOuterNC; | |
| 73576 | + | |
| 73577 | + /* Resolve names in the result set. */ | |
| 73578 | + pEList = p->pEList; | |
| 73579 | + assert( pEList!=0 ); | |
| 73580 | + for(i=0; i<pEList->nExpr; i++){ | |
| 73581 | + Expr *pX = pEList->a[i].pExpr; | |
| 73582 | + if( sqlite3ResolveExprNames(&sNC, pX) ){ | |
| 73583 | + return WRC_Abort; | |
| 73584 | + } | |
| 73585 | + } | |
| 73567 | 73586 | |
| 73568 | 73587 | /* If there are no aggregate functions in the result-set, and no GROUP BY |
| 73569 | 73588 | ** expression, do not allow aggregates in any of the other expressions. |
| 73570 | 73589 | */ |
| 73571 | 73590 | assert( (p->selFlags & SF_Aggregate)==0 ); |
| @@ -87523,11 +87542,11 @@ | ||
| 87523 | 87542 | |
| 87524 | 87543 | /* |
| 87525 | 87544 | ** A foreign key constraint requires that the key columns in the parent |
| 87526 | 87545 | ** table are collectively subject to a UNIQUE or PRIMARY KEY constraint. |
| 87527 | 87546 | ** Given that pParent is the parent table for foreign key constraint pFKey, |
| 87528 | -** search the schema a unique index on the parent key columns. | |
| 87547 | +** search the schema for a unique index on the parent key columns. | |
| 87529 | 87548 | ** |
| 87530 | 87549 | ** If successful, zero is returned. If the parent key is an INTEGER PRIMARY |
| 87531 | 87550 | ** KEY column, then output variable *ppIdx is set to NULL. Otherwise, *ppIdx |
| 87532 | 87551 | ** is set to point to the unique index. |
| 87533 | 87552 | ** |
| @@ -87559,11 +87578,11 @@ | ||
| 87559 | 87578 | ** |
| 87560 | 87579 | ** then non-zero is returned, and a "foreign key mismatch" error loaded |
| 87561 | 87580 | ** into pParse. If an OOM error occurs, non-zero is returned and the |
| 87562 | 87581 | ** pParse->db->mallocFailed flag is set. |
| 87563 | 87582 | */ |
| 87564 | -static int locateFkeyIndex( | |
| 87583 | +SQLITE_PRIVATE int sqlite3FkLocateIndex( | |
| 87565 | 87584 | Parse *pParse, /* Parse context to store any error in */ |
| 87566 | 87585 | Table *pParent, /* Parent table of FK constraint pFKey */ |
| 87567 | 87586 | FKey *pFKey, /* Foreign key to find index for */ |
| 87568 | 87587 | Index **ppIdx, /* OUT: Unique index on parent table */ |
| 87569 | 87588 | int **paiCol /* OUT: Map of index columns in pFKey */ |
| @@ -87656,11 +87675,13 @@ | ||
| 87656 | 87675 | } |
| 87657 | 87676 | } |
| 87658 | 87677 | |
| 87659 | 87678 | if( !pIdx ){ |
| 87660 | 87679 | if( !pParse->disableTriggers ){ |
| 87661 | - sqlite3ErrorMsg(pParse, "foreign key mismatch"); | |
| 87680 | + sqlite3ErrorMsg(pParse, | |
| 87681 | + "foreign key mismatch - \"%w\" referencing \"%w\"", | |
| 87682 | + pFKey->pFrom->zName, pFKey->zTo); | |
| 87662 | 87683 | } |
| 87663 | 87684 | sqlite3DbFree(pParse->db, aiCol); |
| 87664 | 87685 | return 1; |
| 87665 | 87686 | } |
| 87666 | 87687 | |
| @@ -88117,11 +88138,11 @@ | ||
| 88117 | 88138 | if( pParse->disableTriggers ){ |
| 88118 | 88139 | pTo = sqlite3FindTable(db, pFKey->zTo, zDb); |
| 88119 | 88140 | }else{ |
| 88120 | 88141 | pTo = sqlite3LocateTable(pParse, 0, pFKey->zTo, zDb); |
| 88121 | 88142 | } |
| 88122 | - if( !pTo || locateFkeyIndex(pParse, pTo, pFKey, &pIdx, &aiFree) ){ | |
| 88143 | + if( !pTo || sqlite3FkLocateIndex(pParse, pTo, pFKey, &pIdx, &aiFree) ){ | |
| 88123 | 88144 | assert( isIgnoreErrors==0 || (regOld!=0 && regNew==0) ); |
| 88124 | 88145 | if( !isIgnoreErrors || db->mallocFailed ) return; |
| 88125 | 88146 | if( pTo==0 ){ |
| 88126 | 88147 | /* If isIgnoreErrors is true, then a table is being dropped. In this |
| 88127 | 88148 | ** case SQLite runs a "DELETE FROM xxx" on the table being dropped |
| @@ -88197,11 +88218,11 @@ | ||
| 88197 | 88218 | /* Inserting a single row into a parent table cannot cause an immediate |
| 88198 | 88219 | ** foreign key violation. So do nothing in this case. */ |
| 88199 | 88220 | continue; |
| 88200 | 88221 | } |
| 88201 | 88222 | |
| 88202 | - if( locateFkeyIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ){ | |
| 88223 | + if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ){ | |
| 88203 | 88224 | if( !isIgnoreErrors || db->mallocFailed ) return; |
| 88204 | 88225 | continue; |
| 88205 | 88226 | } |
| 88206 | 88227 | assert( aiCol || pFKey->nCol==1 ); |
| 88207 | 88228 | |
| @@ -88252,11 +88273,11 @@ | ||
| 88252 | 88273 | for(p=pTab->pFKey; p; p=p->pNextFrom){ |
| 88253 | 88274 | for(i=0; i<p->nCol; i++) mask |= COLUMN_MASK(p->aCol[i].iFrom); |
| 88254 | 88275 | } |
| 88255 | 88276 | for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){ |
| 88256 | 88277 | Index *pIdx = 0; |
| 88257 | - locateFkeyIndex(pParse, pTab, p, &pIdx, 0); | |
| 88278 | + sqlite3FkLocateIndex(pParse, pTab, p, &pIdx, 0); | |
| 88258 | 88279 | if( pIdx ){ |
| 88259 | 88280 | for(i=0; i<pIdx->nColumn; i++) mask |= COLUMN_MASK(pIdx->aiColumn[i]); |
| 88260 | 88281 | } |
| 88261 | 88282 | } |
| 88262 | 88283 | } |
| @@ -88378,11 +88399,11 @@ | ||
| 88378 | 88399 | ExprList *pList = 0; /* Changes list if ON UPDATE CASCADE */ |
| 88379 | 88400 | Select *pSelect = 0; /* If RESTRICT, "SELECT RAISE(...)" */ |
| 88380 | 88401 | int i; /* Iterator variable */ |
| 88381 | 88402 | Expr *pWhen = 0; /* WHEN clause for the trigger */ |
| 88382 | 88403 | |
| 88383 | - if( locateFkeyIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ) return 0; | |
| 88404 | + if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ) return 0; | |
| 88384 | 88405 | assert( aiCol || pFKey->nCol==1 ); |
| 88385 | 88406 | |
| 88386 | 88407 | for(i=0; i<pFKey->nCol; i++){ |
| 88387 | 88408 | Token tOld = { "old", 3 }; /* Literal "old" token */ |
| 88388 | 88409 | Token tNew = { "new", 3 }; /* Literal "new" token */ |
| @@ -92884,10 +92905,124 @@ | ||
| 92884 | 92905 | } |
| 92885 | 92906 | } |
| 92886 | 92907 | }else |
| 92887 | 92908 | #endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */ |
| 92888 | 92909 | |
| 92910 | +#ifndef SQLITE_OMIT_FOREIGN_KEY | |
| 92911 | + if( sqlite3StrICmp(zLeft, "foreign_key_check")==0 ){ | |
| 92912 | + FKey *pFK; /* A foreign key constraint */ | |
| 92913 | + Table *pTab; /* Child table contain "REFERENCES" keyword */ | |
| 92914 | + Table *pParent; /* Parent table that child points to */ | |
| 92915 | + Index *pIdx; /* Index in the parent table */ | |
| 92916 | + int i; /* Loop counter: Foreign key number for pTab */ | |
| 92917 | + int j; /* Loop counter: Field of the foreign key */ | |
| 92918 | + HashElem *k; /* Loop counter: Next table in schema */ | |
| 92919 | + int x; /* result variable */ | |
| 92920 | + int regResult; /* 3 registers to hold a result row */ | |
| 92921 | + int regKey; /* Register to hold key for checking the FK */ | |
| 92922 | + int regRow; /* Registers to hold a row from pTab */ | |
| 92923 | + int addrTop; /* Top of a loop checking foreign keys */ | |
| 92924 | + int addrOk; /* Jump here if the key is OK */ | |
| 92925 | + int *aiCols; /* child to parent column mapping */ | |
| 92926 | + | |
| 92927 | + if( sqlite3ReadSchema(pParse) ) goto pragma_out; | |
| 92928 | + regResult = pParse->nMem+1; | |
| 92929 | + pParse->nMem += 4; | |
| 92930 | + regKey = ++pParse->nMem; | |
| 92931 | + regRow = ++pParse->nMem; | |
| 92932 | + v = sqlite3GetVdbe(pParse); | |
| 92933 | + sqlite3VdbeSetNumCols(v, 4); | |
| 92934 | + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "table", SQLITE_STATIC); | |
| 92935 | + sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "rowid", SQLITE_STATIC); | |
| 92936 | + sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "parent", SQLITE_STATIC); | |
| 92937 | + sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "fkid", SQLITE_STATIC); | |
| 92938 | + sqlite3CodeVerifySchema(pParse, iDb); | |
| 92939 | + k = sqliteHashFirst(&db->aDb[iDb].pSchema->tblHash); | |
| 92940 | + while( k ){ | |
| 92941 | + if( zRight ){ | |
| 92942 | + pTab = sqlite3LocateTable(pParse, 0, zRight, zDb); | |
| 92943 | + k = 0; | |
| 92944 | + }else{ | |
| 92945 | + pTab = (Table*)sqliteHashData(k); | |
| 92946 | + k = sqliteHashNext(k); | |
| 92947 | + } | |
| 92948 | + if( pTab==0 || pTab->pFKey==0 ) continue; | |
| 92949 | + sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName); | |
| 92950 | + if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow; | |
| 92951 | + sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead); | |
| 92952 | + sqlite3VdbeAddOp4(v, OP_String8, 0, regResult, 0, pTab->zName, | |
| 92953 | + P4_TRANSIENT); | |
| 92954 | + for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){ | |
| 92955 | + pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb); | |
| 92956 | + if( pParent==0 ) break; | |
| 92957 | + pIdx = 0; | |
| 92958 | + sqlite3TableLock(pParse, iDb, pParent->tnum, 0, pParent->zName); | |
| 92959 | + x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0); | |
| 92960 | + if( x==0 ){ | |
| 92961 | + if( pIdx==0 ){ | |
| 92962 | + sqlite3OpenTable(pParse, i, iDb, pParent, OP_OpenRead); | |
| 92963 | + }else{ | |
| 92964 | + KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx); | |
| 92965 | + sqlite3VdbeAddOp3(v, OP_OpenRead, i, pIdx->tnum, iDb); | |
| 92966 | + sqlite3VdbeChangeP4(v, -1, (char*)pKey, P4_KEYINFO_HANDOFF); | |
| 92967 | + } | |
| 92968 | + }else{ | |
| 92969 | + k = 0; | |
| 92970 | + break; | |
| 92971 | + } | |
| 92972 | + } | |
| 92973 | + if( pFK ) break; | |
| 92974 | + if( pParse->nTab<i ) pParse->nTab = i; | |
| 92975 | + addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0); | |
| 92976 | + for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){ | |
| 92977 | + pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb); | |
| 92978 | + assert( pParent!=0 ); | |
| 92979 | + pIdx = 0; | |
| 92980 | + aiCols = 0; | |
| 92981 | + x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols); | |
| 92982 | + assert( x==0 ); | |
| 92983 | + addrOk = sqlite3VdbeMakeLabel(v); | |
| 92984 | + if( pIdx==0 ){ | |
| 92985 | + int iKey = pFK->aCol[0].iFrom; | |
| 92986 | + assert( iKey>=0 && iKey<pTab->nCol ); | |
| 92987 | + if( iKey!=pTab->iPKey ){ | |
| 92988 | + sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow); | |
| 92989 | + sqlite3ColumnDefault(v, pTab, iKey, regRow); | |
| 92990 | + sqlite3VdbeAddOp2(v, OP_IsNull, regRow, addrOk); | |
| 92991 | + sqlite3VdbeAddOp2(v, OP_MustBeInt, regRow, | |
| 92992 | + sqlite3VdbeCurrentAddr(v)+3); | |
| 92993 | + }else{ | |
| 92994 | + sqlite3VdbeAddOp2(v, OP_Rowid, 0, regRow); | |
| 92995 | + } | |
| 92996 | + sqlite3VdbeAddOp3(v, OP_NotExists, i, 0, regRow); | |
| 92997 | + sqlite3VdbeAddOp2(v, OP_Goto, 0, addrOk); | |
| 92998 | + sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2); | |
| 92999 | + }else{ | |
| 93000 | + for(j=0; j<pFK->nCol; j++){ | |
| 93001 | + sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, | |
| 93002 | + aiCols ? aiCols[j] : pFK->aCol[0].iFrom, regRow+j); | |
| 93003 | + sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk); | |
| 93004 | + } | |
| 93005 | + sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey); | |
| 93006 | + sqlite3VdbeChangeP4(v, -1, | |
| 93007 | + sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT); | |
| 93008 | + sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0); | |
| 93009 | + } | |
| 93010 | + sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1); | |
| 93011 | + sqlite3VdbeAddOp4(v, OP_String8, 0, regResult+2, 0, | |
| 93012 | + pFK->zTo, P4_TRANSIENT); | |
| 93013 | + sqlite3VdbeAddOp2(v, OP_Integer, i-1, regResult+3); | |
| 93014 | + sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 4); | |
| 93015 | + sqlite3VdbeResolveLabel(v, addrOk); | |
| 93016 | + sqlite3DbFree(db, aiCols); | |
| 93017 | + } | |
| 93018 | + sqlite3VdbeAddOp2(v, OP_Next, 0, addrTop+1); | |
| 93019 | + sqlite3VdbeJumpHere(v, addrTop); | |
| 93020 | + } | |
| 93021 | + }else | |
| 93022 | +#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */ | |
| 93023 | + | |
| 92889 | 93024 | #ifndef NDEBUG |
| 92890 | 93025 | if( sqlite3StrICmp(zLeft, "parser_trace")==0 ){ |
| 92891 | 93026 | if( zRight ){ |
| 92892 | 93027 | if( sqlite3GetBoolean(zRight, 0) ){ |
| 92893 | 93028 | sqlite3ParserTrace(stderr, "parser: "); |
| @@ -94340,11 +94475,11 @@ | ||
| 94340 | 94475 | SrcList *pSrc, /* the FROM clause -- which tables to scan */ |
| 94341 | 94476 | Expr *pWhere, /* the WHERE clause */ |
| 94342 | 94477 | ExprList *pGroupBy, /* the GROUP BY clause */ |
| 94343 | 94478 | Expr *pHaving, /* the HAVING clause */ |
| 94344 | 94479 | ExprList *pOrderBy, /* the ORDER BY clause */ |
| 94345 | - int isDistinct, /* true if the DISTINCT keyword is present */ | |
| 94480 | + u16 selFlags, /* Flag parameters, such as SF_Distinct */ | |
| 94346 | 94481 | Expr *pLimit, /* LIMIT value. NULL means not used */ |
| 94347 | 94482 | Expr *pOffset /* OFFSET value. NULL means no offset */ |
| 94348 | 94483 | ){ |
| 94349 | 94484 | Select *pNew; |
| 94350 | 94485 | Select standin; |
| @@ -94364,11 +94499,11 @@ | ||
| 94364 | 94499 | pNew->pSrc = pSrc; |
| 94365 | 94500 | pNew->pWhere = pWhere; |
| 94366 | 94501 | pNew->pGroupBy = pGroupBy; |
| 94367 | 94502 | pNew->pHaving = pHaving; |
| 94368 | 94503 | pNew->pOrderBy = pOrderBy; |
| 94369 | - pNew->selFlags = isDistinct ? SF_Distinct : 0; | |
| 94504 | + pNew->selFlags = selFlags; | |
| 94370 | 94505 | pNew->op = TK_SELECT; |
| 94371 | 94506 | pNew->pLimit = pLimit; |
| 94372 | 94507 | pNew->pOffset = pOffset; |
| 94373 | 94508 | assert( pOffset==0 || pLimit!=0 ); |
| 94374 | 94509 | pNew->addrOpenEphm[0] = -1; |
| @@ -102869,11 +103004,11 @@ | ||
| 102869 | 103004 | sqlite3DbFree(db, pOld); |
| 102870 | 103005 | } |
| 102871 | 103006 | pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]); |
| 102872 | 103007 | } |
| 102873 | 103008 | pTerm = &pWC->a[idx = pWC->nTerm++]; |
| 102874 | - pTerm->pExpr = p; | |
| 103009 | + pTerm->pExpr = sqlite3ExprSkipCollate(p); | |
| 102875 | 103010 | pTerm->wtFlags = wtFlags; |
| 102876 | 103011 | pTerm->pWC = pWC; |
| 102877 | 103012 | pTerm->iParent = -1; |
| 102878 | 103013 | return idx; |
| 102879 | 103014 | } |
| @@ -103654,11 +103789,12 @@ | ||
| 103654 | 103789 | if( db->mallocFailed ){ |
| 103655 | 103790 | return; |
| 103656 | 103791 | } |
| 103657 | 103792 | pTerm = &pWC->a[idxTerm]; |
| 103658 | 103793 | pMaskSet = pWC->pMaskSet; |
| 103659 | - pExpr = sqlite3ExprSkipCollate(pTerm->pExpr); | |
| 103794 | + pExpr = pTerm->pExpr; | |
| 103795 | + assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE ); | |
| 103660 | 103796 | prereqLeft = exprTableUsage(pMaskSet, pExpr->pLeft); |
| 103661 | 103797 | op = pExpr->op; |
| 103662 | 103798 | if( op==TK_IN ){ |
| 103663 | 103799 | assert( pExpr->pRight==0 ); |
| 103664 | 103800 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| @@ -108237,10 +108373,11 @@ | ||
| 108237 | 108373 | Expr* yy122; |
| 108238 | 108374 | Select* yy159; |
| 108239 | 108375 | IdList* yy180; |
| 108240 | 108376 | struct {int value; int mask;} yy207; |
| 108241 | 108377 | u8 yy258; |
| 108378 | + u16 yy305; | |
| 108242 | 108379 | struct LikeOp yy318; |
| 108243 | 108380 | TriggerStep* yy327; |
| 108244 | 108381 | ExprSpan yy342; |
| 108245 | 108382 | SrcList* yy347; |
| 108246 | 108383 | int yy392; |
| @@ -110187,22 +110324,19 @@ | ||
| 110187 | 110324 | case 82: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==82); |
| 110188 | 110325 | case 84: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==84); |
| 110189 | 110326 | case 86: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==86); |
| 110190 | 110327 | case 98: /* defer_subclause_opt ::= */ yytestcase(yyruleno==98); |
| 110191 | 110328 | case 109: /* ifexists ::= */ yytestcase(yyruleno==109); |
| 110192 | - case 120: /* distinct ::= ALL */ yytestcase(yyruleno==120); | |
| 110193 | - case 121: /* distinct ::= */ yytestcase(yyruleno==121); | |
| 110194 | 110329 | case 221: /* between_op ::= BETWEEN */ yytestcase(yyruleno==221); |
| 110195 | 110330 | case 224: /* in_op ::= IN */ yytestcase(yyruleno==224); |
| 110196 | 110331 | {yygotominor.yy392 = 0;} |
| 110197 | 110332 | break; |
| 110198 | 110333 | case 29: /* ifnotexists ::= IF NOT EXISTS */ |
| 110199 | 110334 | case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30); |
| 110200 | 110335 | case 70: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==70); |
| 110201 | 110336 | case 85: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==85); |
| 110202 | 110337 | case 108: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==108); |
| 110203 | - case 119: /* distinct ::= DISTINCT */ yytestcase(yyruleno==119); | |
| 110204 | 110338 | case 222: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==222); |
| 110205 | 110339 | case 225: /* in_op ::= NOT IN */ yytestcase(yyruleno==225); |
| 110206 | 110340 | {yygotominor.yy392 = 1;} |
| 110207 | 110341 | break; |
| 110208 | 110342 | case 32: /* create_table_args ::= LP columnlist conslist_opt RP */ |
| @@ -110438,12 +110572,19 @@ | ||
| 110438 | 110572 | case 116: /* multiselect_op ::= UNION ALL */ |
| 110439 | 110573 | {yygotominor.yy392 = TK_ALL;} |
| 110440 | 110574 | break; |
| 110441 | 110575 | case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 110442 | 110576 | { |
| 110443 | - yygotominor.yy159 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy347,yymsp[-4].minor.yy122,yymsp[-3].minor.yy442,yymsp[-2].minor.yy122,yymsp[-1].minor.yy442,yymsp[-7].minor.yy392,yymsp[0].minor.yy64.pLimit,yymsp[0].minor.yy64.pOffset); | |
| 110577 | + yygotominor.yy159 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy347,yymsp[-4].minor.yy122,yymsp[-3].minor.yy442,yymsp[-2].minor.yy122,yymsp[-1].minor.yy442,yymsp[-7].minor.yy305,yymsp[0].minor.yy64.pLimit,yymsp[0].minor.yy64.pOffset); | |
| 110444 | 110578 | } |
| 110579 | + break; | |
| 110580 | + case 119: /* distinct ::= DISTINCT */ | |
| 110581 | +{yygotominor.yy305 = SF_Distinct;} | |
| 110582 | + break; | |
| 110583 | + case 120: /* distinct ::= ALL */ | |
| 110584 | + case 121: /* distinct ::= */ yytestcase(yyruleno==121); | |
| 110585 | +{yygotominor.yy305 = 0;} | |
| 110445 | 110586 | break; |
| 110446 | 110587 | case 122: /* sclp ::= selcollist COMMA */ |
| 110447 | 110588 | case 246: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==246); |
| 110448 | 110589 | {yygotominor.yy442 = yymsp[-1].minor.yy442;} |
| 110449 | 110590 | break; |
| @@ -110509,14 +110650,24 @@ | ||
| 110509 | 110650 | break; |
| 110510 | 110651 | case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 110511 | 110652 | { |
| 110512 | 110653 | if( yymsp[-6].minor.yy347==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy122==0 && yymsp[0].minor.yy180==0 ){ |
| 110513 | 110654 | yygotominor.yy347 = yymsp[-4].minor.yy347; |
| 110655 | + }else if( yymsp[-4].minor.yy347->nSrc==1 ){ | |
| 110656 | + yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180); | |
| 110657 | + if( yygotominor.yy347 ){ | |
| 110658 | + struct SrcList_item *pNew = &yygotominor.yy347->a[yygotominor.yy347->nSrc-1]; | |
| 110659 | + struct SrcList_item *pOld = yymsp[-4].minor.yy347->a; | |
| 110660 | + pNew->zName = pOld->zName; | |
| 110661 | + pNew->zDatabase = pOld->zDatabase; | |
| 110662 | + pOld->zName = pOld->zDatabase = 0; | |
| 110663 | + } | |
| 110664 | + sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy347); | |
| 110514 | 110665 | }else{ |
| 110515 | 110666 | Select *pSubquery; |
| 110516 | 110667 | sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy347); |
| 110517 | - pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy347,0,0,0,0,0,0,0); | |
| 110668 | + pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy347,0,0,0,0,SF_NestedFrom,0,0); | |
| 110518 | 110669 | yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy122,yymsp[0].minor.yy180); |
| 110519 | 110670 | } |
| 110520 | 110671 | } |
| 110521 | 110672 | break; |
| 110522 | 110673 | case 137: /* dbnm ::= */ |
| @@ -110745,11 +110896,11 @@ | ||
| 110745 | 110896 | if( yymsp[-1].minor.yy442 && yymsp[-1].minor.yy442->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){ |
| 110746 | 110897 | sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0); |
| 110747 | 110898 | } |
| 110748 | 110899 | yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0); |
| 110749 | 110900 | spanSet(&yygotominor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 110750 | - if( yymsp[-2].minor.yy392 && yygotominor.yy342.pExpr ){ | |
| 110901 | + if( yymsp[-2].minor.yy305 && yygotominor.yy342.pExpr ){ | |
| 110751 | 110902 | yygotominor.yy342.pExpr->flags |= EP_Distinct; |
| 110752 | 110903 | } |
| 110753 | 110904 | } |
| 110754 | 110905 | break; |
| 110755 | 110906 | case 197: /* expr ::= ID LP STAR RP */ |
| 110756 | 110907 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -673,11 +673,11 @@ | |
| 673 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 674 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 675 | */ |
| 676 | #define SQLITE_VERSION "3.7.16" |
| 677 | #define SQLITE_VERSION_NUMBER 3007016 |
| 678 | #define SQLITE_SOURCE_ID "2012-12-14 17:54:38 3d65c70343196b8f69c5293e7703839846fade85" |
| 679 | |
| 680 | /* |
| 681 | ** CAPI3REF: Run-Time Library Version Numbers |
| 682 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 683 | ** |
| @@ -11171,10 +11171,11 @@ | |
| 11171 | #define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */ |
| 11172 | #define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */ |
| 11173 | #define SF_UseSorter 0x0040 /* Sort using a sorter */ |
| 11174 | #define SF_Values 0x0080 /* Synthesized from VALUES clause */ |
| 11175 | #define SF_Materialize 0x0100 /* Force materialization of views */ |
| 11176 | |
| 11177 | |
| 11178 | /* |
| 11179 | ** The results of a select can be distributed in several ways. The |
| 11180 | ** "SRT" prefix means "SELECT Result Type". |
| @@ -11883,11 +11884,11 @@ | |
| 11883 | SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, |
| 11884 | Token*, int, int); |
| 11885 | SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int); |
| 11886 | SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*); |
| 11887 | SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, |
| 11888 | Expr*,ExprList*,int,Expr*,Expr*); |
| 11889 | SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*); |
| 11890 | SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*); |
| 11891 | SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int); |
| 11892 | SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); |
| 11893 | #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) |
| @@ -12278,12 +12279,14 @@ | |
| 12278 | #define sqlite3FkOldmask(a,b) 0 |
| 12279 | #define sqlite3FkRequired(a,b,c,d) 0 |
| 12280 | #endif |
| 12281 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 12282 | SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*); |
| 12283 | #else |
| 12284 | #define sqlite3FkDelete(a,b) |
| 12285 | #endif |
| 12286 | |
| 12287 | |
| 12288 | /* |
| 12289 | ** Available fault injectors. Should be numbered beginning with 0. |
| @@ -56869,11 +56872,16 @@ | |
| 56869 | /* |
| 56870 | ** Parameter zSrcData points to a buffer containing the data for |
| 56871 | ** page iSrcPg from the source database. Copy this data into the |
| 56872 | ** destination database. |
| 56873 | */ |
| 56874 | static int backupOnePage(sqlite3_backup *p, Pgno iSrcPg, const u8 *zSrcData){ |
| 56875 | Pager * const pDestPager = sqlite3BtreePager(p->pDest); |
| 56876 | const int nSrcPgsz = sqlite3BtreeGetPageSize(p->pSrc); |
| 56877 | int nDestPgsz = sqlite3BtreeGetPageSize(p->pDest); |
| 56878 | const int nCopy = MIN(nSrcPgsz, nDestPgsz); |
| 56879 | const i64 iEnd = (i64)iSrcPg*(i64)nSrcPgsz; |
| @@ -56942,10 +56950,13 @@ | |
| 56942 | ** cached parse of the page). MemPage.isInit is marked |
| 56943 | ** "MUST BE FIRST" for this purpose. |
| 56944 | */ |
| 56945 | memcpy(zOut, zIn, nCopy); |
| 56946 | ((u8 *)sqlite3PagerGetExtra(pDestPg))[0] = 0; |
| 56947 | } |
| 56948 | sqlite3PagerUnref(pDestPg); |
| 56949 | } |
| 56950 | |
| 56951 | return rc; |
| @@ -57048,11 +57059,11 @@ | |
| 57048 | const Pgno iSrcPg = p->iNext; /* Source page number */ |
| 57049 | if( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) ){ |
| 57050 | DbPage *pSrcPg; /* Source page object */ |
| 57051 | rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg); |
| 57052 | if( rc==SQLITE_OK ){ |
| 57053 | rc = backupOnePage(p, iSrcPg, sqlite3PagerGetData(pSrcPg)); |
| 57054 | sqlite3PagerUnref(pSrcPg); |
| 57055 | } |
| 57056 | } |
| 57057 | p->iNext++; |
| 57058 | } |
| @@ -57296,11 +57307,11 @@ | |
| 57296 | ** the new data into the backup. |
| 57297 | */ |
| 57298 | int rc; |
| 57299 | assert( p->pDestDb ); |
| 57300 | sqlite3_mutex_enter(p->pDestDb->mutex); |
| 57301 | rc = backupOnePage(p, iPage, aData); |
| 57302 | sqlite3_mutex_leave(p->pDestDb->mutex); |
| 57303 | assert( rc!=SQLITE_BUSY && rc!=SQLITE_LOCKED ); |
| 57304 | if( rc!=SQLITE_OK ){ |
| 57305 | p->rc = rc; |
| 57306 | } |
| @@ -71890,10 +71901,18 @@ | |
| 71890 | p->pReal = pReal; |
| 71891 | if( p->iSize>0 ){ |
| 71892 | assert(p->iSize<=p->nBuf); |
| 71893 | rc = sqlite3OsWrite(p->pReal, p->zBuf, p->iSize, 0); |
| 71894 | } |
| 71895 | } |
| 71896 | } |
| 71897 | return rc; |
| 71898 | } |
| 71899 | |
| @@ -73519,27 +73538,10 @@ | |
| 73519 | if( sqlite3ResolveExprNames(&sNC, p->pLimit) || |
| 73520 | sqlite3ResolveExprNames(&sNC, p->pOffset) ){ |
| 73521 | return WRC_Abort; |
| 73522 | } |
| 73523 | |
| 73524 | /* Set up the local name-context to pass to sqlite3ResolveExprNames() to |
| 73525 | ** resolve the result-set expression list. |
| 73526 | */ |
| 73527 | sNC.ncFlags = NC_AllowAgg; |
| 73528 | sNC.pSrcList = p->pSrc; |
| 73529 | sNC.pNext = pOuterNC; |
| 73530 | |
| 73531 | /* Resolve names in the result set. */ |
| 73532 | pEList = p->pEList; |
| 73533 | assert( pEList!=0 ); |
| 73534 | for(i=0; i<pEList->nExpr; i++){ |
| 73535 | Expr *pX = pEList->a[i].pExpr; |
| 73536 | if( sqlite3ResolveExprNames(&sNC, pX) ){ |
| 73537 | return WRC_Abort; |
| 73538 | } |
| 73539 | } |
| 73540 | |
| 73541 | /* Recursively resolve names in all subqueries |
| 73542 | */ |
| 73543 | for(i=0; i<p->pSrc->nSrc; i++){ |
| 73544 | struct SrcList_item *pItem = &p->pSrc->a[i]; |
| 73545 | if( pItem->pSelect ){ |
| @@ -73562,10 +73564,27 @@ | |
| 73562 | for(pNC=pOuterNC; pNC; pNC=pNC->pNext) nRef -= pNC->nRef; |
| 73563 | assert( pItem->isCorrelated==0 && nRef<=0 ); |
| 73564 | pItem->isCorrelated = (nRef!=0); |
| 73565 | } |
| 73566 | } |
| 73567 | |
| 73568 | /* If there are no aggregate functions in the result-set, and no GROUP BY |
| 73569 | ** expression, do not allow aggregates in any of the other expressions. |
| 73570 | */ |
| 73571 | assert( (p->selFlags & SF_Aggregate)==0 ); |
| @@ -87523,11 +87542,11 @@ | |
| 87523 | |
| 87524 | /* |
| 87525 | ** A foreign key constraint requires that the key columns in the parent |
| 87526 | ** table are collectively subject to a UNIQUE or PRIMARY KEY constraint. |
| 87527 | ** Given that pParent is the parent table for foreign key constraint pFKey, |
| 87528 | ** search the schema a unique index on the parent key columns. |
| 87529 | ** |
| 87530 | ** If successful, zero is returned. If the parent key is an INTEGER PRIMARY |
| 87531 | ** KEY column, then output variable *ppIdx is set to NULL. Otherwise, *ppIdx |
| 87532 | ** is set to point to the unique index. |
| 87533 | ** |
| @@ -87559,11 +87578,11 @@ | |
| 87559 | ** |
| 87560 | ** then non-zero is returned, and a "foreign key mismatch" error loaded |
| 87561 | ** into pParse. If an OOM error occurs, non-zero is returned and the |
| 87562 | ** pParse->db->mallocFailed flag is set. |
| 87563 | */ |
| 87564 | static int locateFkeyIndex( |
| 87565 | Parse *pParse, /* Parse context to store any error in */ |
| 87566 | Table *pParent, /* Parent table of FK constraint pFKey */ |
| 87567 | FKey *pFKey, /* Foreign key to find index for */ |
| 87568 | Index **ppIdx, /* OUT: Unique index on parent table */ |
| 87569 | int **paiCol /* OUT: Map of index columns in pFKey */ |
| @@ -87656,11 +87675,13 @@ | |
| 87656 | } |
| 87657 | } |
| 87658 | |
| 87659 | if( !pIdx ){ |
| 87660 | if( !pParse->disableTriggers ){ |
| 87661 | sqlite3ErrorMsg(pParse, "foreign key mismatch"); |
| 87662 | } |
| 87663 | sqlite3DbFree(pParse->db, aiCol); |
| 87664 | return 1; |
| 87665 | } |
| 87666 | |
| @@ -88117,11 +88138,11 @@ | |
| 88117 | if( pParse->disableTriggers ){ |
| 88118 | pTo = sqlite3FindTable(db, pFKey->zTo, zDb); |
| 88119 | }else{ |
| 88120 | pTo = sqlite3LocateTable(pParse, 0, pFKey->zTo, zDb); |
| 88121 | } |
| 88122 | if( !pTo || locateFkeyIndex(pParse, pTo, pFKey, &pIdx, &aiFree) ){ |
| 88123 | assert( isIgnoreErrors==0 || (regOld!=0 && regNew==0) ); |
| 88124 | if( !isIgnoreErrors || db->mallocFailed ) return; |
| 88125 | if( pTo==0 ){ |
| 88126 | /* If isIgnoreErrors is true, then a table is being dropped. In this |
| 88127 | ** case SQLite runs a "DELETE FROM xxx" on the table being dropped |
| @@ -88197,11 +88218,11 @@ | |
| 88197 | /* Inserting a single row into a parent table cannot cause an immediate |
| 88198 | ** foreign key violation. So do nothing in this case. */ |
| 88199 | continue; |
| 88200 | } |
| 88201 | |
| 88202 | if( locateFkeyIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ){ |
| 88203 | if( !isIgnoreErrors || db->mallocFailed ) return; |
| 88204 | continue; |
| 88205 | } |
| 88206 | assert( aiCol || pFKey->nCol==1 ); |
| 88207 | |
| @@ -88252,11 +88273,11 @@ | |
| 88252 | for(p=pTab->pFKey; p; p=p->pNextFrom){ |
| 88253 | for(i=0; i<p->nCol; i++) mask |= COLUMN_MASK(p->aCol[i].iFrom); |
| 88254 | } |
| 88255 | for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){ |
| 88256 | Index *pIdx = 0; |
| 88257 | locateFkeyIndex(pParse, pTab, p, &pIdx, 0); |
| 88258 | if( pIdx ){ |
| 88259 | for(i=0; i<pIdx->nColumn; i++) mask |= COLUMN_MASK(pIdx->aiColumn[i]); |
| 88260 | } |
| 88261 | } |
| 88262 | } |
| @@ -88378,11 +88399,11 @@ | |
| 88378 | ExprList *pList = 0; /* Changes list if ON UPDATE CASCADE */ |
| 88379 | Select *pSelect = 0; /* If RESTRICT, "SELECT RAISE(...)" */ |
| 88380 | int i; /* Iterator variable */ |
| 88381 | Expr *pWhen = 0; /* WHEN clause for the trigger */ |
| 88382 | |
| 88383 | if( locateFkeyIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ) return 0; |
| 88384 | assert( aiCol || pFKey->nCol==1 ); |
| 88385 | |
| 88386 | for(i=0; i<pFKey->nCol; i++){ |
| 88387 | Token tOld = { "old", 3 }; /* Literal "old" token */ |
| 88388 | Token tNew = { "new", 3 }; /* Literal "new" token */ |
| @@ -92884,10 +92905,124 @@ | |
| 92884 | } |
| 92885 | } |
| 92886 | }else |
| 92887 | #endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */ |
| 92888 | |
| 92889 | #ifndef NDEBUG |
| 92890 | if( sqlite3StrICmp(zLeft, "parser_trace")==0 ){ |
| 92891 | if( zRight ){ |
| 92892 | if( sqlite3GetBoolean(zRight, 0) ){ |
| 92893 | sqlite3ParserTrace(stderr, "parser: "); |
| @@ -94340,11 +94475,11 @@ | |
| 94340 | SrcList *pSrc, /* the FROM clause -- which tables to scan */ |
| 94341 | Expr *pWhere, /* the WHERE clause */ |
| 94342 | ExprList *pGroupBy, /* the GROUP BY clause */ |
| 94343 | Expr *pHaving, /* the HAVING clause */ |
| 94344 | ExprList *pOrderBy, /* the ORDER BY clause */ |
| 94345 | int isDistinct, /* true if the DISTINCT keyword is present */ |
| 94346 | Expr *pLimit, /* LIMIT value. NULL means not used */ |
| 94347 | Expr *pOffset /* OFFSET value. NULL means no offset */ |
| 94348 | ){ |
| 94349 | Select *pNew; |
| 94350 | Select standin; |
| @@ -94364,11 +94499,11 @@ | |
| 94364 | pNew->pSrc = pSrc; |
| 94365 | pNew->pWhere = pWhere; |
| 94366 | pNew->pGroupBy = pGroupBy; |
| 94367 | pNew->pHaving = pHaving; |
| 94368 | pNew->pOrderBy = pOrderBy; |
| 94369 | pNew->selFlags = isDistinct ? SF_Distinct : 0; |
| 94370 | pNew->op = TK_SELECT; |
| 94371 | pNew->pLimit = pLimit; |
| 94372 | pNew->pOffset = pOffset; |
| 94373 | assert( pOffset==0 || pLimit!=0 ); |
| 94374 | pNew->addrOpenEphm[0] = -1; |
| @@ -102869,11 +103004,11 @@ | |
| 102869 | sqlite3DbFree(db, pOld); |
| 102870 | } |
| 102871 | pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]); |
| 102872 | } |
| 102873 | pTerm = &pWC->a[idx = pWC->nTerm++]; |
| 102874 | pTerm->pExpr = p; |
| 102875 | pTerm->wtFlags = wtFlags; |
| 102876 | pTerm->pWC = pWC; |
| 102877 | pTerm->iParent = -1; |
| 102878 | return idx; |
| 102879 | } |
| @@ -103654,11 +103789,12 @@ | |
| 103654 | if( db->mallocFailed ){ |
| 103655 | return; |
| 103656 | } |
| 103657 | pTerm = &pWC->a[idxTerm]; |
| 103658 | pMaskSet = pWC->pMaskSet; |
| 103659 | pExpr = sqlite3ExprSkipCollate(pTerm->pExpr); |
| 103660 | prereqLeft = exprTableUsage(pMaskSet, pExpr->pLeft); |
| 103661 | op = pExpr->op; |
| 103662 | if( op==TK_IN ){ |
| 103663 | assert( pExpr->pRight==0 ); |
| 103664 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| @@ -108237,10 +108373,11 @@ | |
| 108237 | Expr* yy122; |
| 108238 | Select* yy159; |
| 108239 | IdList* yy180; |
| 108240 | struct {int value; int mask;} yy207; |
| 108241 | u8 yy258; |
| 108242 | struct LikeOp yy318; |
| 108243 | TriggerStep* yy327; |
| 108244 | ExprSpan yy342; |
| 108245 | SrcList* yy347; |
| 108246 | int yy392; |
| @@ -110187,22 +110324,19 @@ | |
| 110187 | case 82: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==82); |
| 110188 | case 84: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==84); |
| 110189 | case 86: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==86); |
| 110190 | case 98: /* defer_subclause_opt ::= */ yytestcase(yyruleno==98); |
| 110191 | case 109: /* ifexists ::= */ yytestcase(yyruleno==109); |
| 110192 | case 120: /* distinct ::= ALL */ yytestcase(yyruleno==120); |
| 110193 | case 121: /* distinct ::= */ yytestcase(yyruleno==121); |
| 110194 | case 221: /* between_op ::= BETWEEN */ yytestcase(yyruleno==221); |
| 110195 | case 224: /* in_op ::= IN */ yytestcase(yyruleno==224); |
| 110196 | {yygotominor.yy392 = 0;} |
| 110197 | break; |
| 110198 | case 29: /* ifnotexists ::= IF NOT EXISTS */ |
| 110199 | case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30); |
| 110200 | case 70: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==70); |
| 110201 | case 85: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==85); |
| 110202 | case 108: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==108); |
| 110203 | case 119: /* distinct ::= DISTINCT */ yytestcase(yyruleno==119); |
| 110204 | case 222: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==222); |
| 110205 | case 225: /* in_op ::= NOT IN */ yytestcase(yyruleno==225); |
| 110206 | {yygotominor.yy392 = 1;} |
| 110207 | break; |
| 110208 | case 32: /* create_table_args ::= LP columnlist conslist_opt RP */ |
| @@ -110438,12 +110572,19 @@ | |
| 110438 | case 116: /* multiselect_op ::= UNION ALL */ |
| 110439 | {yygotominor.yy392 = TK_ALL;} |
| 110440 | break; |
| 110441 | case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 110442 | { |
| 110443 | yygotominor.yy159 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy347,yymsp[-4].minor.yy122,yymsp[-3].minor.yy442,yymsp[-2].minor.yy122,yymsp[-1].minor.yy442,yymsp[-7].minor.yy392,yymsp[0].minor.yy64.pLimit,yymsp[0].minor.yy64.pOffset); |
| 110444 | } |
| 110445 | break; |
| 110446 | case 122: /* sclp ::= selcollist COMMA */ |
| 110447 | case 246: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==246); |
| 110448 | {yygotominor.yy442 = yymsp[-1].minor.yy442;} |
| 110449 | break; |
| @@ -110509,14 +110650,24 @@ | |
| 110509 | break; |
| 110510 | case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 110511 | { |
| 110512 | if( yymsp[-6].minor.yy347==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy122==0 && yymsp[0].minor.yy180==0 ){ |
| 110513 | yygotominor.yy347 = yymsp[-4].minor.yy347; |
| 110514 | }else{ |
| 110515 | Select *pSubquery; |
| 110516 | sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy347); |
| 110517 | pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy347,0,0,0,0,0,0,0); |
| 110518 | yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy122,yymsp[0].minor.yy180); |
| 110519 | } |
| 110520 | } |
| 110521 | break; |
| 110522 | case 137: /* dbnm ::= */ |
| @@ -110745,11 +110896,11 @@ | |
| 110745 | if( yymsp[-1].minor.yy442 && yymsp[-1].minor.yy442->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){ |
| 110746 | sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0); |
| 110747 | } |
| 110748 | yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0); |
| 110749 | spanSet(&yygotominor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 110750 | if( yymsp[-2].minor.yy392 && yygotominor.yy342.pExpr ){ |
| 110751 | yygotominor.yy342.pExpr->flags |= EP_Distinct; |
| 110752 | } |
| 110753 | } |
| 110754 | break; |
| 110755 | case 197: /* expr ::= ID LP STAR RP */ |
| 110756 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -673,11 +673,11 @@ | |
| 673 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 674 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 675 | */ |
| 676 | #define SQLITE_VERSION "3.7.16" |
| 677 | #define SQLITE_VERSION_NUMBER 3007016 |
| 678 | #define SQLITE_SOURCE_ID "2012-12-21 16:15:35 ff6857b6ed6a46671006b75157d8cf853a816ef9" |
| 679 | |
| 680 | /* |
| 681 | ** CAPI3REF: Run-Time Library Version Numbers |
| 682 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 683 | ** |
| @@ -11171,10 +11171,11 @@ | |
| 11171 | #define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */ |
| 11172 | #define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */ |
| 11173 | #define SF_UseSorter 0x0040 /* Sort using a sorter */ |
| 11174 | #define SF_Values 0x0080 /* Synthesized from VALUES clause */ |
| 11175 | #define SF_Materialize 0x0100 /* Force materialization of views */ |
| 11176 | #define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */ |
| 11177 | |
| 11178 | |
| 11179 | /* |
| 11180 | ** The results of a select can be distributed in several ways. The |
| 11181 | ** "SRT" prefix means "SELECT Result Type". |
| @@ -11883,11 +11884,11 @@ | |
| 11884 | SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, |
| 11885 | Token*, int, int); |
| 11886 | SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int); |
| 11887 | SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*); |
| 11888 | SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, |
| 11889 | Expr*,ExprList*,u16,Expr*,Expr*); |
| 11890 | SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*); |
| 11891 | SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*); |
| 11892 | SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int); |
| 11893 | SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); |
| 11894 | #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) |
| @@ -12278,12 +12279,14 @@ | |
| 12279 | #define sqlite3FkOldmask(a,b) 0 |
| 12280 | #define sqlite3FkRequired(a,b,c,d) 0 |
| 12281 | #endif |
| 12282 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 12283 | SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*); |
| 12284 | SQLITE_PRIVATE int sqlite3FkLocateIndex(Parse*,Table*,FKey*,Index**,int**); |
| 12285 | #else |
| 12286 | #define sqlite3FkDelete(a,b) |
| 12287 | #define sqlite3FkLocateIndex(a,b,c,d,e) |
| 12288 | #endif |
| 12289 | |
| 12290 | |
| 12291 | /* |
| 12292 | ** Available fault injectors. Should be numbered beginning with 0. |
| @@ -56869,11 +56872,16 @@ | |
| 56872 | /* |
| 56873 | ** Parameter zSrcData points to a buffer containing the data for |
| 56874 | ** page iSrcPg from the source database. Copy this data into the |
| 56875 | ** destination database. |
| 56876 | */ |
| 56877 | static int backupOnePage( |
| 56878 | sqlite3_backup *p, /* Backup handle */ |
| 56879 | Pgno iSrcPg, /* Source database page to backup */ |
| 56880 | const u8 *zSrcData, /* Source database page data */ |
| 56881 | int bUpdate /* True for an update, false otherwise */ |
| 56882 | ){ |
| 56883 | Pager * const pDestPager = sqlite3BtreePager(p->pDest); |
| 56884 | const int nSrcPgsz = sqlite3BtreeGetPageSize(p->pSrc); |
| 56885 | int nDestPgsz = sqlite3BtreeGetPageSize(p->pDest); |
| 56886 | const int nCopy = MIN(nSrcPgsz, nDestPgsz); |
| 56887 | const i64 iEnd = (i64)iSrcPg*(i64)nSrcPgsz; |
| @@ -56942,10 +56950,13 @@ | |
| 56950 | ** cached parse of the page). MemPage.isInit is marked |
| 56951 | ** "MUST BE FIRST" for this purpose. |
| 56952 | */ |
| 56953 | memcpy(zOut, zIn, nCopy); |
| 56954 | ((u8 *)sqlite3PagerGetExtra(pDestPg))[0] = 0; |
| 56955 | if( iOff==0 && bUpdate==0 ){ |
| 56956 | sqlite3Put4byte(&zOut[28], sqlite3BtreeLastPage(p->pSrc)); |
| 56957 | } |
| 56958 | } |
| 56959 | sqlite3PagerUnref(pDestPg); |
| 56960 | } |
| 56961 | |
| 56962 | return rc; |
| @@ -57048,11 +57059,11 @@ | |
| 57059 | const Pgno iSrcPg = p->iNext; /* Source page number */ |
| 57060 | if( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) ){ |
| 57061 | DbPage *pSrcPg; /* Source page object */ |
| 57062 | rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg); |
| 57063 | if( rc==SQLITE_OK ){ |
| 57064 | rc = backupOnePage(p, iSrcPg, sqlite3PagerGetData(pSrcPg), 0); |
| 57065 | sqlite3PagerUnref(pSrcPg); |
| 57066 | } |
| 57067 | } |
| 57068 | p->iNext++; |
| 57069 | } |
| @@ -57296,11 +57307,11 @@ | |
| 57307 | ** the new data into the backup. |
| 57308 | */ |
| 57309 | int rc; |
| 57310 | assert( p->pDestDb ); |
| 57311 | sqlite3_mutex_enter(p->pDestDb->mutex); |
| 57312 | rc = backupOnePage(p, iPage, aData, 1); |
| 57313 | sqlite3_mutex_leave(p->pDestDb->mutex); |
| 57314 | assert( rc!=SQLITE_BUSY && rc!=SQLITE_LOCKED ); |
| 57315 | if( rc!=SQLITE_OK ){ |
| 57316 | p->rc = rc; |
| 57317 | } |
| @@ -71890,10 +71901,18 @@ | |
| 71901 | p->pReal = pReal; |
| 71902 | if( p->iSize>0 ){ |
| 71903 | assert(p->iSize<=p->nBuf); |
| 71904 | rc = sqlite3OsWrite(p->pReal, p->zBuf, p->iSize, 0); |
| 71905 | } |
| 71906 | if( rc!=SQLITE_OK ){ |
| 71907 | /* If an error occurred while writing to the file, close it before |
| 71908 | ** returning. This way, SQLite uses the in-memory journal data to |
| 71909 | ** roll back changes made to the internal page-cache before this |
| 71910 | ** function was called. */ |
| 71911 | sqlite3OsClose(pReal); |
| 71912 | p->pReal = 0; |
| 71913 | } |
| 71914 | } |
| 71915 | } |
| 71916 | return rc; |
| 71917 | } |
| 71918 | |
| @@ -73519,27 +73538,10 @@ | |
| 73538 | if( sqlite3ResolveExprNames(&sNC, p->pLimit) || |
| 73539 | sqlite3ResolveExprNames(&sNC, p->pOffset) ){ |
| 73540 | return WRC_Abort; |
| 73541 | } |
| 73542 | |
| 73543 | /* Recursively resolve names in all subqueries |
| 73544 | */ |
| 73545 | for(i=0; i<p->pSrc->nSrc; i++){ |
| 73546 | struct SrcList_item *pItem = &p->pSrc->a[i]; |
| 73547 | if( pItem->pSelect ){ |
| @@ -73562,10 +73564,27 @@ | |
| 73564 | for(pNC=pOuterNC; pNC; pNC=pNC->pNext) nRef -= pNC->nRef; |
| 73565 | assert( pItem->isCorrelated==0 && nRef<=0 ); |
| 73566 | pItem->isCorrelated = (nRef!=0); |
| 73567 | } |
| 73568 | } |
| 73569 | |
| 73570 | /* Set up the local name-context to pass to sqlite3ResolveExprNames() to |
| 73571 | ** resolve the result-set expression list. |
| 73572 | */ |
| 73573 | sNC.ncFlags = NC_AllowAgg; |
| 73574 | sNC.pSrcList = p->pSrc; |
| 73575 | sNC.pNext = pOuterNC; |
| 73576 | |
| 73577 | /* Resolve names in the result set. */ |
| 73578 | pEList = p->pEList; |
| 73579 | assert( pEList!=0 ); |
| 73580 | for(i=0; i<pEList->nExpr; i++){ |
| 73581 | Expr *pX = pEList->a[i].pExpr; |
| 73582 | if( sqlite3ResolveExprNames(&sNC, pX) ){ |
| 73583 | return WRC_Abort; |
| 73584 | } |
| 73585 | } |
| 73586 | |
| 73587 | /* If there are no aggregate functions in the result-set, and no GROUP BY |
| 73588 | ** expression, do not allow aggregates in any of the other expressions. |
| 73589 | */ |
| 73590 | assert( (p->selFlags & SF_Aggregate)==0 ); |
| @@ -87523,11 +87542,11 @@ | |
| 87542 | |
| 87543 | /* |
| 87544 | ** A foreign key constraint requires that the key columns in the parent |
| 87545 | ** table are collectively subject to a UNIQUE or PRIMARY KEY constraint. |
| 87546 | ** Given that pParent is the parent table for foreign key constraint pFKey, |
| 87547 | ** search the schema for a unique index on the parent key columns. |
| 87548 | ** |
| 87549 | ** If successful, zero is returned. If the parent key is an INTEGER PRIMARY |
| 87550 | ** KEY column, then output variable *ppIdx is set to NULL. Otherwise, *ppIdx |
| 87551 | ** is set to point to the unique index. |
| 87552 | ** |
| @@ -87559,11 +87578,11 @@ | |
| 87578 | ** |
| 87579 | ** then non-zero is returned, and a "foreign key mismatch" error loaded |
| 87580 | ** into pParse. If an OOM error occurs, non-zero is returned and the |
| 87581 | ** pParse->db->mallocFailed flag is set. |
| 87582 | */ |
| 87583 | SQLITE_PRIVATE int sqlite3FkLocateIndex( |
| 87584 | Parse *pParse, /* Parse context to store any error in */ |
| 87585 | Table *pParent, /* Parent table of FK constraint pFKey */ |
| 87586 | FKey *pFKey, /* Foreign key to find index for */ |
| 87587 | Index **ppIdx, /* OUT: Unique index on parent table */ |
| 87588 | int **paiCol /* OUT: Map of index columns in pFKey */ |
| @@ -87656,11 +87675,13 @@ | |
| 87675 | } |
| 87676 | } |
| 87677 | |
| 87678 | if( !pIdx ){ |
| 87679 | if( !pParse->disableTriggers ){ |
| 87680 | sqlite3ErrorMsg(pParse, |
| 87681 | "foreign key mismatch - \"%w\" referencing \"%w\"", |
| 87682 | pFKey->pFrom->zName, pFKey->zTo); |
| 87683 | } |
| 87684 | sqlite3DbFree(pParse->db, aiCol); |
| 87685 | return 1; |
| 87686 | } |
| 87687 | |
| @@ -88117,11 +88138,11 @@ | |
| 88138 | if( pParse->disableTriggers ){ |
| 88139 | pTo = sqlite3FindTable(db, pFKey->zTo, zDb); |
| 88140 | }else{ |
| 88141 | pTo = sqlite3LocateTable(pParse, 0, pFKey->zTo, zDb); |
| 88142 | } |
| 88143 | if( !pTo || sqlite3FkLocateIndex(pParse, pTo, pFKey, &pIdx, &aiFree) ){ |
| 88144 | assert( isIgnoreErrors==0 || (regOld!=0 && regNew==0) ); |
| 88145 | if( !isIgnoreErrors || db->mallocFailed ) return; |
| 88146 | if( pTo==0 ){ |
| 88147 | /* If isIgnoreErrors is true, then a table is being dropped. In this |
| 88148 | ** case SQLite runs a "DELETE FROM xxx" on the table being dropped |
| @@ -88197,11 +88218,11 @@ | |
| 88218 | /* Inserting a single row into a parent table cannot cause an immediate |
| 88219 | ** foreign key violation. So do nothing in this case. */ |
| 88220 | continue; |
| 88221 | } |
| 88222 | |
| 88223 | if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ){ |
| 88224 | if( !isIgnoreErrors || db->mallocFailed ) return; |
| 88225 | continue; |
| 88226 | } |
| 88227 | assert( aiCol || pFKey->nCol==1 ); |
| 88228 | |
| @@ -88252,11 +88273,11 @@ | |
| 88273 | for(p=pTab->pFKey; p; p=p->pNextFrom){ |
| 88274 | for(i=0; i<p->nCol; i++) mask |= COLUMN_MASK(p->aCol[i].iFrom); |
| 88275 | } |
| 88276 | for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){ |
| 88277 | Index *pIdx = 0; |
| 88278 | sqlite3FkLocateIndex(pParse, pTab, p, &pIdx, 0); |
| 88279 | if( pIdx ){ |
| 88280 | for(i=0; i<pIdx->nColumn; i++) mask |= COLUMN_MASK(pIdx->aiColumn[i]); |
| 88281 | } |
| 88282 | } |
| 88283 | } |
| @@ -88378,11 +88399,11 @@ | |
| 88399 | ExprList *pList = 0; /* Changes list if ON UPDATE CASCADE */ |
| 88400 | Select *pSelect = 0; /* If RESTRICT, "SELECT RAISE(...)" */ |
| 88401 | int i; /* Iterator variable */ |
| 88402 | Expr *pWhen = 0; /* WHEN clause for the trigger */ |
| 88403 | |
| 88404 | if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ) return 0; |
| 88405 | assert( aiCol || pFKey->nCol==1 ); |
| 88406 | |
| 88407 | for(i=0; i<pFKey->nCol; i++){ |
| 88408 | Token tOld = { "old", 3 }; /* Literal "old" token */ |
| 88409 | Token tNew = { "new", 3 }; /* Literal "new" token */ |
| @@ -92884,10 +92905,124 @@ | |
| 92905 | } |
| 92906 | } |
| 92907 | }else |
| 92908 | #endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */ |
| 92909 | |
| 92910 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 92911 | if( sqlite3StrICmp(zLeft, "foreign_key_check")==0 ){ |
| 92912 | FKey *pFK; /* A foreign key constraint */ |
| 92913 | Table *pTab; /* Child table contain "REFERENCES" keyword */ |
| 92914 | Table *pParent; /* Parent table that child points to */ |
| 92915 | Index *pIdx; /* Index in the parent table */ |
| 92916 | int i; /* Loop counter: Foreign key number for pTab */ |
| 92917 | int j; /* Loop counter: Field of the foreign key */ |
| 92918 | HashElem *k; /* Loop counter: Next table in schema */ |
| 92919 | int x; /* result variable */ |
| 92920 | int regResult; /* 3 registers to hold a result row */ |
| 92921 | int regKey; /* Register to hold key for checking the FK */ |
| 92922 | int regRow; /* Registers to hold a row from pTab */ |
| 92923 | int addrTop; /* Top of a loop checking foreign keys */ |
| 92924 | int addrOk; /* Jump here if the key is OK */ |
| 92925 | int *aiCols; /* child to parent column mapping */ |
| 92926 | |
| 92927 | if( sqlite3ReadSchema(pParse) ) goto pragma_out; |
| 92928 | regResult = pParse->nMem+1; |
| 92929 | pParse->nMem += 4; |
| 92930 | regKey = ++pParse->nMem; |
| 92931 | regRow = ++pParse->nMem; |
| 92932 | v = sqlite3GetVdbe(pParse); |
| 92933 | sqlite3VdbeSetNumCols(v, 4); |
| 92934 | sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "table", SQLITE_STATIC); |
| 92935 | sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "rowid", SQLITE_STATIC); |
| 92936 | sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "parent", SQLITE_STATIC); |
| 92937 | sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "fkid", SQLITE_STATIC); |
| 92938 | sqlite3CodeVerifySchema(pParse, iDb); |
| 92939 | k = sqliteHashFirst(&db->aDb[iDb].pSchema->tblHash); |
| 92940 | while( k ){ |
| 92941 | if( zRight ){ |
| 92942 | pTab = sqlite3LocateTable(pParse, 0, zRight, zDb); |
| 92943 | k = 0; |
| 92944 | }else{ |
| 92945 | pTab = (Table*)sqliteHashData(k); |
| 92946 | k = sqliteHashNext(k); |
| 92947 | } |
| 92948 | if( pTab==0 || pTab->pFKey==0 ) continue; |
| 92949 | sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName); |
| 92950 | if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow; |
| 92951 | sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead); |
| 92952 | sqlite3VdbeAddOp4(v, OP_String8, 0, regResult, 0, pTab->zName, |
| 92953 | P4_TRANSIENT); |
| 92954 | for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){ |
| 92955 | pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb); |
| 92956 | if( pParent==0 ) break; |
| 92957 | pIdx = 0; |
| 92958 | sqlite3TableLock(pParse, iDb, pParent->tnum, 0, pParent->zName); |
| 92959 | x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0); |
| 92960 | if( x==0 ){ |
| 92961 | if( pIdx==0 ){ |
| 92962 | sqlite3OpenTable(pParse, i, iDb, pParent, OP_OpenRead); |
| 92963 | }else{ |
| 92964 | KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx); |
| 92965 | sqlite3VdbeAddOp3(v, OP_OpenRead, i, pIdx->tnum, iDb); |
| 92966 | sqlite3VdbeChangeP4(v, -1, (char*)pKey, P4_KEYINFO_HANDOFF); |
| 92967 | } |
| 92968 | }else{ |
| 92969 | k = 0; |
| 92970 | break; |
| 92971 | } |
| 92972 | } |
| 92973 | if( pFK ) break; |
| 92974 | if( pParse->nTab<i ) pParse->nTab = i; |
| 92975 | addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0); |
| 92976 | for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){ |
| 92977 | pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb); |
| 92978 | assert( pParent!=0 ); |
| 92979 | pIdx = 0; |
| 92980 | aiCols = 0; |
| 92981 | x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols); |
| 92982 | assert( x==0 ); |
| 92983 | addrOk = sqlite3VdbeMakeLabel(v); |
| 92984 | if( pIdx==0 ){ |
| 92985 | int iKey = pFK->aCol[0].iFrom; |
| 92986 | assert( iKey>=0 && iKey<pTab->nCol ); |
| 92987 | if( iKey!=pTab->iPKey ){ |
| 92988 | sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow); |
| 92989 | sqlite3ColumnDefault(v, pTab, iKey, regRow); |
| 92990 | sqlite3VdbeAddOp2(v, OP_IsNull, regRow, addrOk); |
| 92991 | sqlite3VdbeAddOp2(v, OP_MustBeInt, regRow, |
| 92992 | sqlite3VdbeCurrentAddr(v)+3); |
| 92993 | }else{ |
| 92994 | sqlite3VdbeAddOp2(v, OP_Rowid, 0, regRow); |
| 92995 | } |
| 92996 | sqlite3VdbeAddOp3(v, OP_NotExists, i, 0, regRow); |
| 92997 | sqlite3VdbeAddOp2(v, OP_Goto, 0, addrOk); |
| 92998 | sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2); |
| 92999 | }else{ |
| 93000 | for(j=0; j<pFK->nCol; j++){ |
| 93001 | sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, |
| 93002 | aiCols ? aiCols[j] : pFK->aCol[0].iFrom, regRow+j); |
| 93003 | sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk); |
| 93004 | } |
| 93005 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey); |
| 93006 | sqlite3VdbeChangeP4(v, -1, |
| 93007 | sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT); |
| 93008 | sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0); |
| 93009 | } |
| 93010 | sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1); |
| 93011 | sqlite3VdbeAddOp4(v, OP_String8, 0, regResult+2, 0, |
| 93012 | pFK->zTo, P4_TRANSIENT); |
| 93013 | sqlite3VdbeAddOp2(v, OP_Integer, i-1, regResult+3); |
| 93014 | sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 4); |
| 93015 | sqlite3VdbeResolveLabel(v, addrOk); |
| 93016 | sqlite3DbFree(db, aiCols); |
| 93017 | } |
| 93018 | sqlite3VdbeAddOp2(v, OP_Next, 0, addrTop+1); |
| 93019 | sqlite3VdbeJumpHere(v, addrTop); |
| 93020 | } |
| 93021 | }else |
| 93022 | #endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */ |
| 93023 | |
| 93024 | #ifndef NDEBUG |
| 93025 | if( sqlite3StrICmp(zLeft, "parser_trace")==0 ){ |
| 93026 | if( zRight ){ |
| 93027 | if( sqlite3GetBoolean(zRight, 0) ){ |
| 93028 | sqlite3ParserTrace(stderr, "parser: "); |
| @@ -94340,11 +94475,11 @@ | |
| 94475 | SrcList *pSrc, /* the FROM clause -- which tables to scan */ |
| 94476 | Expr *pWhere, /* the WHERE clause */ |
| 94477 | ExprList *pGroupBy, /* the GROUP BY clause */ |
| 94478 | Expr *pHaving, /* the HAVING clause */ |
| 94479 | ExprList *pOrderBy, /* the ORDER BY clause */ |
| 94480 | u16 selFlags, /* Flag parameters, such as SF_Distinct */ |
| 94481 | Expr *pLimit, /* LIMIT value. NULL means not used */ |
| 94482 | Expr *pOffset /* OFFSET value. NULL means no offset */ |
| 94483 | ){ |
| 94484 | Select *pNew; |
| 94485 | Select standin; |
| @@ -94364,11 +94499,11 @@ | |
| 94499 | pNew->pSrc = pSrc; |
| 94500 | pNew->pWhere = pWhere; |
| 94501 | pNew->pGroupBy = pGroupBy; |
| 94502 | pNew->pHaving = pHaving; |
| 94503 | pNew->pOrderBy = pOrderBy; |
| 94504 | pNew->selFlags = selFlags; |
| 94505 | pNew->op = TK_SELECT; |
| 94506 | pNew->pLimit = pLimit; |
| 94507 | pNew->pOffset = pOffset; |
| 94508 | assert( pOffset==0 || pLimit!=0 ); |
| 94509 | pNew->addrOpenEphm[0] = -1; |
| @@ -102869,11 +103004,11 @@ | |
| 103004 | sqlite3DbFree(db, pOld); |
| 103005 | } |
| 103006 | pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]); |
| 103007 | } |
| 103008 | pTerm = &pWC->a[idx = pWC->nTerm++]; |
| 103009 | pTerm->pExpr = sqlite3ExprSkipCollate(p); |
| 103010 | pTerm->wtFlags = wtFlags; |
| 103011 | pTerm->pWC = pWC; |
| 103012 | pTerm->iParent = -1; |
| 103013 | return idx; |
| 103014 | } |
| @@ -103654,11 +103789,12 @@ | |
| 103789 | if( db->mallocFailed ){ |
| 103790 | return; |
| 103791 | } |
| 103792 | pTerm = &pWC->a[idxTerm]; |
| 103793 | pMaskSet = pWC->pMaskSet; |
| 103794 | pExpr = pTerm->pExpr; |
| 103795 | assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE ); |
| 103796 | prereqLeft = exprTableUsage(pMaskSet, pExpr->pLeft); |
| 103797 | op = pExpr->op; |
| 103798 | if( op==TK_IN ){ |
| 103799 | assert( pExpr->pRight==0 ); |
| 103800 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| @@ -108237,10 +108373,11 @@ | |
| 108373 | Expr* yy122; |
| 108374 | Select* yy159; |
| 108375 | IdList* yy180; |
| 108376 | struct {int value; int mask;} yy207; |
| 108377 | u8 yy258; |
| 108378 | u16 yy305; |
| 108379 | struct LikeOp yy318; |
| 108380 | TriggerStep* yy327; |
| 108381 | ExprSpan yy342; |
| 108382 | SrcList* yy347; |
| 108383 | int yy392; |
| @@ -110187,22 +110324,19 @@ | |
| 110324 | case 82: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==82); |
| 110325 | case 84: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==84); |
| 110326 | case 86: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==86); |
| 110327 | case 98: /* defer_subclause_opt ::= */ yytestcase(yyruleno==98); |
| 110328 | case 109: /* ifexists ::= */ yytestcase(yyruleno==109); |
| 110329 | case 221: /* between_op ::= BETWEEN */ yytestcase(yyruleno==221); |
| 110330 | case 224: /* in_op ::= IN */ yytestcase(yyruleno==224); |
| 110331 | {yygotominor.yy392 = 0;} |
| 110332 | break; |
| 110333 | case 29: /* ifnotexists ::= IF NOT EXISTS */ |
| 110334 | case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30); |
| 110335 | case 70: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==70); |
| 110336 | case 85: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==85); |
| 110337 | case 108: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==108); |
| 110338 | case 222: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==222); |
| 110339 | case 225: /* in_op ::= NOT IN */ yytestcase(yyruleno==225); |
| 110340 | {yygotominor.yy392 = 1;} |
| 110341 | break; |
| 110342 | case 32: /* create_table_args ::= LP columnlist conslist_opt RP */ |
| @@ -110438,12 +110572,19 @@ | |
| 110572 | case 116: /* multiselect_op ::= UNION ALL */ |
| 110573 | {yygotominor.yy392 = TK_ALL;} |
| 110574 | break; |
| 110575 | case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 110576 | { |
| 110577 | yygotominor.yy159 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy347,yymsp[-4].minor.yy122,yymsp[-3].minor.yy442,yymsp[-2].minor.yy122,yymsp[-1].minor.yy442,yymsp[-7].minor.yy305,yymsp[0].minor.yy64.pLimit,yymsp[0].minor.yy64.pOffset); |
| 110578 | } |
| 110579 | break; |
| 110580 | case 119: /* distinct ::= DISTINCT */ |
| 110581 | {yygotominor.yy305 = SF_Distinct;} |
| 110582 | break; |
| 110583 | case 120: /* distinct ::= ALL */ |
| 110584 | case 121: /* distinct ::= */ yytestcase(yyruleno==121); |
| 110585 | {yygotominor.yy305 = 0;} |
| 110586 | break; |
| 110587 | case 122: /* sclp ::= selcollist COMMA */ |
| 110588 | case 246: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==246); |
| 110589 | {yygotominor.yy442 = yymsp[-1].minor.yy442;} |
| 110590 | break; |
| @@ -110509,14 +110650,24 @@ | |
| 110650 | break; |
| 110651 | case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 110652 | { |
| 110653 | if( yymsp[-6].minor.yy347==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy122==0 && yymsp[0].minor.yy180==0 ){ |
| 110654 | yygotominor.yy347 = yymsp[-4].minor.yy347; |
| 110655 | }else if( yymsp[-4].minor.yy347->nSrc==1 ){ |
| 110656 | yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180); |
| 110657 | if( yygotominor.yy347 ){ |
| 110658 | struct SrcList_item *pNew = &yygotominor.yy347->a[yygotominor.yy347->nSrc-1]; |
| 110659 | struct SrcList_item *pOld = yymsp[-4].minor.yy347->a; |
| 110660 | pNew->zName = pOld->zName; |
| 110661 | pNew->zDatabase = pOld->zDatabase; |
| 110662 | pOld->zName = pOld->zDatabase = 0; |
| 110663 | } |
| 110664 | sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy347); |
| 110665 | }else{ |
| 110666 | Select *pSubquery; |
| 110667 | sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy347); |
| 110668 | pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy347,0,0,0,0,SF_NestedFrom,0,0); |
| 110669 | yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy122,yymsp[0].minor.yy180); |
| 110670 | } |
| 110671 | } |
| 110672 | break; |
| 110673 | case 137: /* dbnm ::= */ |
| @@ -110745,11 +110896,11 @@ | |
| 110896 | if( yymsp[-1].minor.yy442 && yymsp[-1].minor.yy442->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){ |
| 110897 | sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0); |
| 110898 | } |
| 110899 | yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0); |
| 110900 | spanSet(&yygotominor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 110901 | if( yymsp[-2].minor.yy305 && yygotominor.yy342.pExpr ){ |
| 110902 | yygotominor.yy342.pExpr->flags |= EP_Distinct; |
| 110903 | } |
| 110904 | } |
| 110905 | break; |
| 110906 | case 197: /* expr ::= ID LP STAR RP */ |
| 110907 |
+1
-1
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -107,11 +107,11 @@ | ||
| 107 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | 109 | */ |
| 110 | 110 | #define SQLITE_VERSION "3.7.16" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3007016 |
| 112 | -#define SQLITE_SOURCE_ID "2012-12-14 17:54:38 3d65c70343196b8f69c5293e7703839846fade85" | |
| 112 | +#define SQLITE_SOURCE_ID "2012-12-21 16:15:35 ff6857b6ed6a46671006b75157d8cf853a816ef9" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| 118 | 118 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.16" |
| 111 | #define SQLITE_VERSION_NUMBER 3007016 |
| 112 | #define SQLITE_SOURCE_ID "2012-12-14 17:54:38 3d65c70343196b8f69c5293e7703839846fade85" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.16" |
| 111 | #define SQLITE_VERSION_NUMBER 3007016 |
| 112 | #define SQLITE_SOURCE_ID "2012-12-21 16:15:35 ff6857b6ed6a46671006b75157d8cf853a816ef9" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |