diff options
Diffstat (limited to '')
| -rw-r--r-- | c/sqlite3.c | 271 | ||||
| -rw-r--r-- | c/sqlite3.h | 6 |
2 files changed, 185 insertions, 92 deletions
diff --git a/c/sqlite3.c b/c/sqlite3.c index 54f8277..df53e43 100644 --- a/c/sqlite3.c +++ b/c/sqlite3.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /****************************************************************************** | 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.35.2. By combining all the individual C code files into this | 3 | ** version 3.35.5. By combining all the individual C code files into this |
| 4 | ** single large file, the entire code can be compiled as a single translation | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | ** unit. This allows many compilers to do optimizations that would not be | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements | 6 | ** possible if the files were compiled separately. Performance improvements |
| @@ -1186,9 +1186,9 @@ extern "C" { | |||
| 1186 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], | 1186 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1187 | ** [sqlite_version()] and [sqlite_source_id()]. | 1187 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1188 | */ | 1188 | */ |
| 1189 | #define SQLITE_VERSION "3.35.2" | 1189 | #define SQLITE_VERSION "3.35.5" |
| 1190 | #define SQLITE_VERSION_NUMBER 3035002 | 1190 | #define SQLITE_VERSION_NUMBER 3035005 |
| 1191 | #define SQLITE_SOURCE_ID "2021-03-17 19:07:21 ea80f3002f4120f5dcee76e8779dfdc88e1e096c5cdd06904c20fd26d50c3827" | 1191 | #define SQLITE_SOURCE_ID "2021-04-19 18:32:05 1b256d97b553a9611efca188a3d995a2fff712759044ba480f9a0c9e98fae886" |
| 1192 | 1192 | ||
| 1193 | /* | 1193 | /* |
| 1194 | ** CAPI3REF: Run-Time Library Version Numbers | 1194 | ** CAPI3REF: Run-Time Library Version Numbers |
| @@ -19764,6 +19764,7 @@ SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*, int); | |||
| 19764 | SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,Expr*,FuncDef*); | 19764 | SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,Expr*,FuncDef*); |
| 19765 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); | 19765 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); |
| 19766 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); | 19766 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); |
| 19767 | SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse*, Expr*); | ||
| 19767 | SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*); | 19768 | SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*); |
| 19768 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); | 19769 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); |
| 19769 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*); | 19770 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*); |
| @@ -21071,6 +21072,7 @@ struct VdbeCursor { | |||
| 21071 | Bool isEphemeral:1; /* True for an ephemeral table */ | 21072 | Bool isEphemeral:1; /* True for an ephemeral table */ |
| 21072 | Bool useRandomRowid:1; /* Generate new record numbers semi-randomly */ | 21073 | Bool useRandomRowid:1; /* Generate new record numbers semi-randomly */ |
| 21073 | Bool isOrdered:1; /* True if the table is not BTREE_UNORDERED */ | 21074 | Bool isOrdered:1; /* True if the table is not BTREE_UNORDERED */ |
| 21075 | Bool hasBeenDuped:1; /* This cursor was source or target of OP_OpenDup */ | ||
| 21074 | u16 seekHit; /* See the OP_SeekHit and OP_IfNoHope opcodes */ | 21076 | u16 seekHit; /* See the OP_SeekHit and OP_IfNoHope opcodes */ |
| 21075 | Btree *pBtx; /* Separate file holding temporary table */ | 21077 | Btree *pBtx; /* Separate file holding temporary table */ |
| 21076 | i64 seqCount; /* Sequence counter */ | 21078 | i64 seqCount; /* Sequence counter */ |
| @@ -40220,7 +40222,8 @@ static int unixBackupDir(const char *z, int *pJ){ | |||
| 40220 | int j = *pJ; | 40222 | int j = *pJ; |
| 40221 | int i; | 40223 | int i; |
| 40222 | if( j<=0 ) return 0; | 40224 | if( j<=0 ) return 0; |
| 40223 | for(i=j-1; ALWAYS(i>0) && z[i-1]!='/'; i--){} | 40225 | for(i=j-1; i>0 && z[i-1]!='/'; i--){} |
| 40226 | if( i==0 ) return 0; | ||
| 40224 | if( z[i]=='.' && i==j-2 && z[i+1]=='.' ) return 0; | 40227 | if( z[i]=='.' && i==j-2 && z[i+1]=='.' ) return 0; |
| 40225 | *pJ = i-1; | 40228 | *pJ = i-1; |
| 40226 | return 1; | 40229 | return 1; |
| @@ -64277,7 +64280,7 @@ struct Btree { | |||
| 64277 | u8 hasIncrblobCur; /* True if there are one or more Incrblob cursors */ | 64280 | u8 hasIncrblobCur; /* True if there are one or more Incrblob cursors */ |
| 64278 | int wantToLock; /* Number of nested calls to sqlite3BtreeEnter() */ | 64281 | int wantToLock; /* Number of nested calls to sqlite3BtreeEnter() */ |
| 64279 | int nBackup; /* Number of backup operations reading this btree */ | 64282 | int nBackup; /* Number of backup operations reading this btree */ |
| 64280 | u32 iDataVersion; /* Combines with pBt->pPager->iDataVersion */ | 64283 | u32 iBDataVersion; /* Combines with pBt->pPager->iDataVersion */ |
| 64281 | Btree *pNext; /* List of other sharable Btrees from the same db */ | 64284 | Btree *pNext; /* List of other sharable Btrees from the same db */ |
| 64282 | Btree *pPrev; /* Back pointer of the same list */ | 64285 | Btree *pPrev; /* Back pointer of the same list */ |
| 64283 | #ifdef SQLITE_DEBUG | 64286 | #ifdef SQLITE_DEBUG |
| @@ -67690,19 +67693,23 @@ static void freeTempSpace(BtShared *pBt){ | |||
| 67690 | */ | 67693 | */ |
| 67691 | SQLITE_PRIVATE int sqlite3BtreeClose(Btree *p){ | 67694 | SQLITE_PRIVATE int sqlite3BtreeClose(Btree *p){ |
| 67692 | BtShared *pBt = p->pBt; | 67695 | BtShared *pBt = p->pBt; |
| 67693 | BtCursor *pCur; | ||
| 67694 | 67696 | ||
| 67695 | /* Close all cursors opened via this handle. */ | 67697 | /* Close all cursors opened via this handle. */ |
| 67696 | assert( sqlite3_mutex_held(p->db->mutex) ); | 67698 | assert( sqlite3_mutex_held(p->db->mutex) ); |
| 67697 | sqlite3BtreeEnter(p); | 67699 | sqlite3BtreeEnter(p); |
| 67698 | pCur = pBt->pCursor; | 67700 | |
| 67699 | while( pCur ){ | 67701 | /* Verify that no other cursors have this Btree open */ |
| 67700 | BtCursor *pTmp = pCur; | 67702 | #ifdef SQLITE_DEBUG |
| 67701 | pCur = pCur->pNext; | 67703 | { |
| 67702 | if( pTmp->pBtree==p ){ | 67704 | BtCursor *pCur = pBt->pCursor; |
| 67703 | sqlite3BtreeCloseCursor(pTmp); | 67705 | while( pCur ){ |
| 67706 | BtCursor *pTmp = pCur; | ||
| 67707 | pCur = pCur->pNext; | ||
| 67708 | assert( pTmp->pBtree!=p ); | ||
| 67709 | |||
| 67704 | } | 67710 | } |
| 67705 | } | 67711 | } |
| 67712 | #endif | ||
| 67706 | 67713 | ||
| 67707 | /* Rollback any active transaction and free the handle structure. | 67714 | /* Rollback any active transaction and free the handle structure. |
| 67708 | ** The call to sqlite3BtreeRollback() drops any table-locks held by | 67715 | ** The call to sqlite3BtreeRollback() drops any table-locks held by |
| @@ -69084,7 +69091,7 @@ SQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree *p, int bCleanup){ | |||
| 69084 | sqlite3BtreeLeave(p); | 69091 | sqlite3BtreeLeave(p); |
| 69085 | return rc; | 69092 | return rc; |
| 69086 | } | 69093 | } |
| 69087 | p->iDataVersion--; /* Compensate for pPager->iDataVersion++; */ | 69094 | p->iBDataVersion--; /* Compensate for pPager->iDataVersion++; */ |
| 69088 | pBt->inTransaction = TRANS_READ; | 69095 | pBt->inTransaction = TRANS_READ; |
| 69089 | btreeClearHasContent(pBt); | 69096 | btreeClearHasContent(pBt); |
| 69090 | } | 69097 | } |
| @@ -69494,7 +69501,14 @@ SQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor *pCur){ | |||
| 69494 | unlockBtreeIfUnused(pBt); | 69501 | unlockBtreeIfUnused(pBt); |
| 69495 | sqlite3_free(pCur->aOverflow); | 69502 | sqlite3_free(pCur->aOverflow); |
| 69496 | sqlite3_free(pCur->pKey); | 69503 | sqlite3_free(pCur->pKey); |
| 69497 | sqlite3BtreeLeave(pBtree); | 69504 | if( (pBt->openFlags & BTREE_SINGLE) && pBt->pCursor==0 ){ |
| 69505 | /* Since the BtShared is not sharable, there is no need to | ||
| 69506 | ** worry about the missing sqlite3BtreeLeave() call here. */ | ||
| 69507 | assert( pBtree->sharable==0 ); | ||
| 69508 | sqlite3BtreeClose(pBtree); | ||
| 69509 | }else{ | ||
| 69510 | sqlite3BtreeLeave(pBtree); | ||
| 69511 | } | ||
| 69498 | pCur->pBtree = 0; | 69512 | pCur->pBtree = 0; |
| 69499 | } | 69513 | } |
| 69500 | return SQLITE_OK; | 69514 | return SQLITE_OK; |
| @@ -74607,7 +74621,7 @@ SQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *p, int idx, u32 *pMeta){ | |||
| 74607 | assert( idx>=0 && idx<=15 ); | 74621 | assert( idx>=0 && idx<=15 ); |
| 74608 | 74622 | ||
| 74609 | if( idx==BTREE_DATA_VERSION ){ | 74623 | if( idx==BTREE_DATA_VERSION ){ |
| 74610 | *pMeta = sqlite3PagerDataVersion(pBt->pPager) + p->iDataVersion; | 74624 | *pMeta = sqlite3PagerDataVersion(pBt->pPager) + p->iBDataVersion; |
| 74611 | }else{ | 74625 | }else{ |
| 74612 | *pMeta = get4byte(&pBt->pPage1->aData[36 + idx*4]); | 74626 | *pMeta = get4byte(&pBt->pPage1->aData[36 + idx*4]); |
| 74613 | } | 74627 | } |
| @@ -80835,20 +80849,15 @@ SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){ | |||
| 80835 | return; | 80849 | return; |
| 80836 | } | 80850 | } |
| 80837 | assert( pCx->pBtx==0 || pCx->eCurType==CURTYPE_BTREE ); | 80851 | assert( pCx->pBtx==0 || pCx->eCurType==CURTYPE_BTREE ); |
| 80852 | assert( pCx->pBtx==0 || pCx->isEphemeral ); | ||
| 80838 | switch( pCx->eCurType ){ | 80853 | switch( pCx->eCurType ){ |
| 80839 | case CURTYPE_SORTER: { | 80854 | case CURTYPE_SORTER: { |
| 80840 | sqlite3VdbeSorterClose(p->db, pCx); | 80855 | sqlite3VdbeSorterClose(p->db, pCx); |
| 80841 | break; | 80856 | break; |
| 80842 | } | 80857 | } |
| 80843 | case CURTYPE_BTREE: { | 80858 | case CURTYPE_BTREE: { |
| 80844 | if( pCx->isEphemeral ){ | 80859 | assert( pCx->uc.pCursor!=0 ); |
| 80845 | if( pCx->pBtx ) sqlite3BtreeClose(pCx->pBtx); | 80860 | sqlite3BtreeCloseCursor(pCx->uc.pCursor); |
| 80846 | /* The pCx->pCursor will be close automatically, if it exists, by | ||
| 80847 | ** the call above. */ | ||
| 80848 | }else{ | ||
| 80849 | assert( pCx->uc.pCursor!=0 ); | ||
| 80850 | sqlite3BtreeCloseCursor(pCx->uc.pCursor); | ||
| 80851 | } | ||
| 80852 | break; | 80861 | break; |
| 80853 | } | 80862 | } |
| 80854 | #ifndef SQLITE_OMIT_VIRTUALTABLE | 80863 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| @@ -81932,6 +81941,7 @@ SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor **pp, u32 *piCol){ | |||
| 81932 | assert( p->eCurType==CURTYPE_BTREE || p->eCurType==CURTYPE_PSEUDO ); | 81941 | assert( p->eCurType==CURTYPE_BTREE || p->eCurType==CURTYPE_PSEUDO ); |
| 81933 | if( p->deferredMoveto ){ | 81942 | if( p->deferredMoveto ){ |
| 81934 | u32 iMap; | 81943 | u32 iMap; |
| 81944 | assert( !p->isEphemeral ); | ||
| 81935 | if( p->aAltMap && (iMap = p->aAltMap[1+*piCol])>0 && !p->nullRow ){ | 81945 | if( p->aAltMap && (iMap = p->aAltMap[1+*piCol])>0 && !p->nullRow ){ |
| 81936 | *pp = p->pAltCursor; | 81946 | *pp = p->pAltCursor; |
| 81937 | *piCol = iMap - 1; | 81947 | *piCol = iMap - 1; |
| @@ -86140,11 +86150,6 @@ static VdbeCursor *allocateCursor( | |||
| 86140 | 86150 | ||
| 86141 | assert( iCur>=0 && iCur<p->nCursor ); | 86151 | assert( iCur>=0 && iCur<p->nCursor ); |
| 86142 | if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/ | 86152 | if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/ |
| 86143 | /* Before calling sqlite3VdbeFreeCursor(), ensure the isEphemeral flag | ||
| 86144 | ** is clear. Otherwise, if this is an ephemeral cursor created by | ||
| 86145 | ** OP_OpenDup, the cursor will not be closed and will still be part | ||
| 86146 | ** of a BtShared.pCursor list. */ | ||
| 86147 | if( p->apCsr[iCur]->pBtx==0 ) p->apCsr[iCur]->isEphemeral = 0; | ||
| 86148 | sqlite3VdbeFreeCursor(p, p->apCsr[iCur]); | 86153 | sqlite3VdbeFreeCursor(p, p->apCsr[iCur]); |
| 86149 | p->apCsr[iCur] = 0; | 86154 | p->apCsr[iCur] = 0; |
| 86150 | } | 86155 | } |
| @@ -89830,7 +89835,7 @@ case OP_OpenDup: { | |||
| 89830 | 89835 | ||
| 89831 | pOrig = p->apCsr[pOp->p2]; | 89836 | pOrig = p->apCsr[pOp->p2]; |
| 89832 | assert( pOrig ); | 89837 | assert( pOrig ); |
| 89833 | assert( pOrig->pBtx!=0 ); /* Only ephemeral cursors can be duplicated */ | 89838 | assert( pOrig->isEphemeral ); /* Only ephemeral cursors can be duplicated */ |
| 89834 | 89839 | ||
| 89835 | pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE); | 89840 | pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE); |
| 89836 | if( pCx==0 ) goto no_mem; | 89841 | if( pCx==0 ) goto no_mem; |
| @@ -89840,7 +89845,10 @@ case OP_OpenDup: { | |||
| 89840 | pCx->isTable = pOrig->isTable; | 89845 | pCx->isTable = pOrig->isTable; |
| 89841 | pCx->pgnoRoot = pOrig->pgnoRoot; | 89846 | pCx->pgnoRoot = pOrig->pgnoRoot; |
| 89842 | pCx->isOrdered = pOrig->isOrdered; | 89847 | pCx->isOrdered = pOrig->isOrdered; |
| 89843 | rc = sqlite3BtreeCursor(pOrig->pBtx, pCx->pgnoRoot, BTREE_WRCSR, | 89848 | pCx->pBtx = pOrig->pBtx; |
| 89849 | pCx->hasBeenDuped = 1; | ||
| 89850 | pOrig->hasBeenDuped = 1; | ||
| 89851 | rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR, | ||
| 89844 | pCx->pKeyInfo, pCx->uc.pCursor); | 89852 | pCx->pKeyInfo, pCx->uc.pCursor); |
| 89845 | /* The sqlite3BtreeCursor() routine can only fail for the first cursor | 89853 | /* The sqlite3BtreeCursor() routine can only fail for the first cursor |
| 89846 | ** opened for a database. Since there is already an open cursor when this | 89854 | ** opened for a database. Since there is already an open cursor when this |
| @@ -89906,9 +89914,10 @@ case OP_OpenEphemeral: { | |||
| 89906 | aMem[pOp->p3].z = ""; | 89914 | aMem[pOp->p3].z = ""; |
| 89907 | } | 89915 | } |
| 89908 | pCx = p->apCsr[pOp->p1]; | 89916 | pCx = p->apCsr[pOp->p1]; |
| 89909 | if( pCx && ALWAYS(pCx->pBtx) ){ | 89917 | if( pCx && !pCx->hasBeenDuped ){ |
| 89910 | /* If the ephermeral table is already open, erase all existing content | 89918 | /* If the ephermeral table is already open and has no duplicates from |
| 89911 | ** so that the table is empty again, rather than creating a new table. */ | 89919 | ** OP_OpenDup, then erase all existing content so that the table is |
| 89920 | ** empty again, rather than creating a new table. */ | ||
| 89912 | assert( pCx->isEphemeral ); | 89921 | assert( pCx->isEphemeral ); |
| 89913 | pCx->seqCount = 0; | 89922 | pCx->seqCount = 0; |
| 89914 | pCx->cacheStatus = CACHE_STALE; | 89923 | pCx->cacheStatus = CACHE_STALE; |
| @@ -89922,33 +89931,36 @@ case OP_OpenEphemeral: { | |||
| 89922 | vfsFlags); | 89931 | vfsFlags); |
| 89923 | if( rc==SQLITE_OK ){ | 89932 | if( rc==SQLITE_OK ){ |
| 89924 | rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1, 0); | 89933 | rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1, 0); |
| 89925 | } | 89934 | if( rc==SQLITE_OK ){ |
| 89926 | if( rc==SQLITE_OK ){ | 89935 | /* If a transient index is required, create it by calling |
| 89927 | /* If a transient index is required, create it by calling | 89936 | ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before |
| 89928 | ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before | 89937 | ** opening it. If a transient table is required, just use the |
| 89929 | ** opening it. If a transient table is required, just use the | 89938 | ** automatically created table with root-page 1 (an BLOB_INTKEY table). |
| 89930 | ** automatically created table with root-page 1 (an BLOB_INTKEY table). | 89939 | */ |
| 89931 | */ | 89940 | if( (pCx->pKeyInfo = pKeyInfo = pOp->p4.pKeyInfo)!=0 ){ |
| 89932 | if( (pCx->pKeyInfo = pKeyInfo = pOp->p4.pKeyInfo)!=0 ){ | 89941 | assert( pOp->p4type==P4_KEYINFO ); |
| 89933 | assert( pOp->p4type==P4_KEYINFO ); | 89942 | rc = sqlite3BtreeCreateTable(pCx->pBtx, &pCx->pgnoRoot, |
| 89934 | rc = sqlite3BtreeCreateTable(pCx->pBtx, &pCx->pgnoRoot, | 89943 | BTREE_BLOBKEY | pOp->p5); |
| 89935 | BTREE_BLOBKEY | pOp->p5); | 89944 | if( rc==SQLITE_OK ){ |
| 89936 | if( rc==SQLITE_OK ){ | 89945 | assert( pCx->pgnoRoot==SCHEMA_ROOT+1 ); |
| 89937 | assert( pCx->pgnoRoot==SCHEMA_ROOT+1 ); | 89946 | assert( pKeyInfo->db==db ); |
| 89938 | assert( pKeyInfo->db==db ); | 89947 | assert( pKeyInfo->enc==ENC(db) ); |
| 89939 | assert( pKeyInfo->enc==ENC(db) ); | 89948 | rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR, |
| 89940 | rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR, | 89949 | pKeyInfo, pCx->uc.pCursor); |
| 89941 | pKeyInfo, pCx->uc.pCursor); | 89950 | } |
| 89951 | pCx->isTable = 0; | ||
| 89952 | }else{ | ||
| 89953 | pCx->pgnoRoot = SCHEMA_ROOT; | ||
| 89954 | rc = sqlite3BtreeCursor(pCx->pBtx, SCHEMA_ROOT, BTREE_WRCSR, | ||
| 89955 | 0, pCx->uc.pCursor); | ||
| 89956 | pCx->isTable = 1; | ||
| 89942 | } | 89957 | } |
| 89943 | pCx->isTable = 0; | 89958 | } |
| 89944 | }else{ | 89959 | pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED); |
| 89945 | pCx->pgnoRoot = SCHEMA_ROOT; | 89960 | if( rc ){ |
| 89946 | rc = sqlite3BtreeCursor(pCx->pBtx, SCHEMA_ROOT, BTREE_WRCSR, | 89961 | sqlite3BtreeClose(pCx->pBtx); |
| 89947 | 0, pCx->uc.pCursor); | ||
| 89948 | pCx->isTable = 1; | ||
| 89949 | } | 89962 | } |
| 89950 | } | 89963 | } |
| 89951 | pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED); | ||
| 89952 | } | 89964 | } |
| 89953 | if( rc ) goto abort_due_to_error; | 89965 | if( rc ) goto abort_due_to_error; |
| 89954 | pCx->nullRow = 1; | 89966 | pCx->nullRow = 1; |
| @@ -90382,13 +90394,13 @@ seek_not_found: | |||
| 90382 | ** | 90394 | ** |
| 90383 | ** There are three possible outcomes from this opcode:<ol> | 90395 | ** There are three possible outcomes from this opcode:<ol> |
| 90384 | ** | 90396 | ** |
| 90385 | ** <li> If after This.P1 steps, the cursor is still point to a place that | 90397 | ** <li> If after This.P1 steps, the cursor is still pointing to a place that |
| 90386 | ** is earlier in the btree than the target row, | 90398 | ** is earlier in the btree than the target row, then fall through |
| 90387 | ** then fall through into the subsquence OP_SeekGE opcode. | 90399 | ** into the subsquence OP_SeekGE opcode. |
| 90388 | ** | 90400 | ** |
| 90389 | ** <li> If the cursor is successfully moved to the target row by 0 or more | 90401 | ** <li> If the cursor is successfully moved to the target row by 0 or more |
| 90390 | ** sqlite3BtreeNext() calls, then jump to This.P2, which will land just | 90402 | ** sqlite3BtreeNext() calls, then jump to This.P2, which will land just |
| 90391 | ** past the OP_IdxGT opcode that follows the OP_SeekGE. | 90403 | ** past the OP_IdxGT or OP_IdxGE opcode that follows the OP_SeekGE. |
| 90392 | ** | 90404 | ** |
| 90393 | ** <li> If the cursor ends up past the target row (indicating the the target | 90405 | ** <li> If the cursor ends up past the target row (indicating the the target |
| 90394 | ** row does not exist in the btree) then jump to SeekOP.P2. | 90406 | ** row does not exist in the btree) then jump to SeekOP.P2. |
| @@ -90405,7 +90417,8 @@ case OP_SeekScan: { | |||
| 90405 | /* pOp->p2 points to the first instruction past the OP_IdxGT that | 90417 | /* pOp->p2 points to the first instruction past the OP_IdxGT that |
| 90406 | ** follows the OP_SeekGE. */ | 90418 | ** follows the OP_SeekGE. */ |
| 90407 | assert( pOp->p2>=(int)(pOp-aOp)+2 ); | 90419 | assert( pOp->p2>=(int)(pOp-aOp)+2 ); |
| 90408 | assert( aOp[pOp->p2-1].opcode==OP_IdxGT ); | 90420 | assert( aOp[pOp->p2-1].opcode==OP_IdxGT || aOp[pOp->p2-1].opcode==OP_IdxGE ); |
| 90421 | testcase( aOp[pOp->p2-1].opcode==OP_IdxGE ); | ||
| 90409 | assert( pOp[1].p1==aOp[pOp->p2-1].p1 ); | 90422 | assert( pOp[1].p1==aOp[pOp->p2-1].p1 ); |
| 90410 | assert( pOp[1].p2==aOp[pOp->p2-1].p2 ); | 90423 | assert( pOp[1].p2==aOp[pOp->p2-1].p2 ); |
| 90411 | assert( pOp[1].p3==aOp[pOp->p2-1].p3 ); | 90424 | assert( pOp[1].p3==aOp[pOp->p2-1].p3 ); |
| @@ -91940,6 +91953,8 @@ case OP_IdxRowid: { /* out2 */ | |||
| 91940 | pTabCur->deferredMoveto = 1; | 91953 | pTabCur->deferredMoveto = 1; |
| 91941 | assert( pOp->p4type==P4_INTARRAY || pOp->p4.ai==0 ); | 91954 | assert( pOp->p4type==P4_INTARRAY || pOp->p4.ai==0 ); |
| 91942 | pTabCur->aAltMap = pOp->p4.ai; | 91955 | pTabCur->aAltMap = pOp->p4.ai; |
| 91956 | assert( !pC->isEphemeral ); | ||
| 91957 | assert( !pTabCur->isEphemeral ); | ||
| 91943 | pTabCur->pAltCursor = pC; | 91958 | pTabCur->pAltCursor = pC; |
| 91944 | }else{ | 91959 | }else{ |
| 91945 | pOut = out2Prerelease(p, pOp); | 91960 | pOut = out2Prerelease(p, pOp); |
| @@ -98988,15 +99003,19 @@ static int lookupName( | |||
| 98988 | if( pParse->pTriggerTab!=0 ){ | 99003 | if( pParse->pTriggerTab!=0 ){ |
| 98989 | int op = pParse->eTriggerOp; | 99004 | int op = pParse->eTriggerOp; |
| 98990 | assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT ); | 99005 | assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT ); |
| 98991 | if( op!=TK_DELETE && zTab && sqlite3StrICmp("new",zTab) == 0 ){ | 99006 | if( pParse->bReturning ){ |
| 99007 | if( (pNC->ncFlags & NC_UBaseReg)!=0 | ||
| 99008 | && (zTab==0 || sqlite3StrICmp(zTab,pParse->pTriggerTab->zName)==0) | ||
| 99009 | ){ | ||
| 99010 | pExpr->iTable = op!=TK_DELETE; | ||
| 99011 | pTab = pParse->pTriggerTab; | ||
| 99012 | } | ||
| 99013 | }else if( op!=TK_DELETE && zTab && sqlite3StrICmp("new",zTab) == 0 ){ | ||
| 98992 | pExpr->iTable = 1; | 99014 | pExpr->iTable = 1; |
| 98993 | pTab = pParse->pTriggerTab; | 99015 | pTab = pParse->pTriggerTab; |
| 98994 | }else if( op!=TK_INSERT && zTab && sqlite3StrICmp("old",zTab)==0 ){ | 99016 | }else if( op!=TK_INSERT && zTab && sqlite3StrICmp("old",zTab)==0 ){ |
| 98995 | pExpr->iTable = 0; | 99017 | pExpr->iTable = 0; |
| 98996 | pTab = pParse->pTriggerTab; | 99018 | pTab = pParse->pTriggerTab; |
| 98997 | }else if( pParse->bReturning && (pNC->ncFlags & NC_UBaseReg)!=0 ){ | ||
| 98998 | pExpr->iTable = op!=TK_DELETE; | ||
| 98999 | pTab = pParse->pTriggerTab; | ||
| 99000 | } | 99019 | } |
| 99001 | } | 99020 | } |
| 99002 | #endif /* SQLITE_OMIT_TRIGGER */ | 99021 | #endif /* SQLITE_OMIT_TRIGGER */ |
| @@ -101591,8 +101610,8 @@ SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse *pParse, Expr *pLeft, Expr *pRight){ | |||
| 101591 | }else if( (ExprAlwaysFalse(pLeft) || ExprAlwaysFalse(pRight)) | 101610 | }else if( (ExprAlwaysFalse(pLeft) || ExprAlwaysFalse(pRight)) |
| 101592 | && !IN_RENAME_OBJECT | 101611 | && !IN_RENAME_OBJECT |
| 101593 | ){ | 101612 | ){ |
| 101594 | sqlite3ExprDelete(db, pLeft); | 101613 | sqlite3ExprDeferredDelete(pParse, pLeft); |
| 101595 | sqlite3ExprDelete(db, pRight); | 101614 | sqlite3ExprDeferredDelete(pParse, pRight); |
| 101596 | return sqlite3Expr(db, TK_INTEGER, "0"); | 101615 | return sqlite3Expr(db, TK_INTEGER, "0"); |
| 101597 | }else{ | 101616 | }else{ |
| 101598 | return sqlite3PExpr(pParse, TK_AND, pLeft, pRight); | 101617 | return sqlite3PExpr(pParse, TK_AND, pLeft, pRight); |
| @@ -101789,6 +101808,22 @@ SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3 *db, Expr *p){ | |||
| 101789 | if( p ) sqlite3ExprDeleteNN(db, p); | 101808 | if( p ) sqlite3ExprDeleteNN(db, p); |
| 101790 | } | 101809 | } |
| 101791 | 101810 | ||
| 101811 | |||
| 101812 | /* | ||
| 101813 | ** Arrange to cause pExpr to be deleted when the pParse is deleted. | ||
| 101814 | ** This is similar to sqlite3ExprDelete() except that the delete is | ||
| 101815 | ** deferred untilthe pParse is deleted. | ||
| 101816 | ** | ||
| 101817 | ** The pExpr might be deleted immediately on an OOM error. | ||
| 101818 | ** | ||
| 101819 | ** The deferred delete is (currently) implemented by adding the | ||
| 101820 | ** pExpr to the pParse->pConstExpr list with a register number of 0. | ||
| 101821 | */ | ||
| 101822 | SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse *pParse, Expr *pExpr){ | ||
| 101823 | pParse->pConstExpr = | ||
| 101824 | sqlite3ExprListAppend(pParse, pParse->pConstExpr, pExpr); | ||
| 101825 | } | ||
| 101826 | |||
| 101792 | /* Invoke sqlite3RenameExprUnmap() and sqlite3ExprDelete() on the | 101827 | /* Invoke sqlite3RenameExprUnmap() and sqlite3ExprDelete() on the |
| 101793 | ** expression. | 101828 | ** expression. |
| 101794 | */ | 101829 | */ |
| @@ -106414,8 +106449,7 @@ static int agginfoPersistExprCb(Walker *pWalker, Expr *pExpr){ | |||
| 106414 | pExpr = sqlite3ExprDup(db, pExpr, 0); | 106449 | pExpr = sqlite3ExprDup(db, pExpr, 0); |
| 106415 | if( pExpr ){ | 106450 | if( pExpr ){ |
| 106416 | pAggInfo->aCol[iAgg].pCExpr = pExpr; | 106451 | pAggInfo->aCol[iAgg].pCExpr = pExpr; |
| 106417 | pParse->pConstExpr = | 106452 | sqlite3ExprDeferredDelete(pParse, pExpr); |
| 106418 | sqlite3ExprListAppend(pParse, pParse->pConstExpr, pExpr); | ||
| 106419 | } | 106453 | } |
| 106420 | } | 106454 | } |
| 106421 | }else{ | 106455 | }else{ |
| @@ -106424,8 +106458,7 @@ static int agginfoPersistExprCb(Walker *pWalker, Expr *pExpr){ | |||
| 106424 | pExpr = sqlite3ExprDup(db, pExpr, 0); | 106458 | pExpr = sqlite3ExprDup(db, pExpr, 0); |
| 106425 | if( pExpr ){ | 106459 | if( pExpr ){ |
| 106426 | pAggInfo->aFunc[iAgg].pFExpr = pExpr; | 106460 | pAggInfo->aFunc[iAgg].pFExpr = pExpr; |
| 106427 | pParse->pConstExpr = | 106461 | sqlite3ExprDeferredDelete(pParse, pExpr); |
| 106428 | sqlite3ExprListAppend(pParse, pParse->pConstExpr, pExpr); | ||
| 106429 | } | 106462 | } |
| 106430 | } | 106463 | } |
| 106431 | } | 106464 | } |
| @@ -108668,33 +108701,44 @@ SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, Token * | |||
| 108668 | sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenWrite); | 108701 | sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenWrite); |
| 108669 | addr = sqlite3VdbeAddOp1(v, OP_Rewind, iCur); VdbeCoverage(v); | 108702 | addr = sqlite3VdbeAddOp1(v, OP_Rewind, iCur); VdbeCoverage(v); |
| 108670 | reg = ++pParse->nMem; | 108703 | reg = ++pParse->nMem; |
| 108671 | pParse->nMem += pTab->nCol; | ||
| 108672 | if( HasRowid(pTab) ){ | 108704 | if( HasRowid(pTab) ){ |
| 108673 | sqlite3VdbeAddOp2(v, OP_Rowid, iCur, reg); | 108705 | sqlite3VdbeAddOp2(v, OP_Rowid, iCur, reg); |
| 108706 | pParse->nMem += pTab->nCol; | ||
| 108674 | }else{ | 108707 | }else{ |
| 108675 | pPk = sqlite3PrimaryKeyIndex(pTab); | 108708 | pPk = sqlite3PrimaryKeyIndex(pTab); |
| 108709 | pParse->nMem += pPk->nColumn; | ||
| 108710 | for(i=0; i<pPk->nKeyCol; i++){ | ||
| 108711 | sqlite3VdbeAddOp3(v, OP_Column, iCur, i, reg+i+1); | ||
| 108712 | } | ||
| 108713 | nField = pPk->nKeyCol; | ||
| 108676 | } | 108714 | } |
| 108715 | regRec = ++pParse->nMem; | ||
| 108677 | for(i=0; i<pTab->nCol; i++){ | 108716 | for(i=0; i<pTab->nCol; i++){ |
| 108678 | if( i!=iCol && (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ){ | 108717 | if( i!=iCol && (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ){ |
| 108679 | int regOut; | 108718 | int regOut; |
| 108680 | if( pPk ){ | 108719 | if( pPk ){ |
| 108681 | int iPos = sqlite3TableColumnToIndex(pPk, i); | 108720 | int iPos = sqlite3TableColumnToIndex(pPk, i); |
| 108682 | int iColPos = sqlite3TableColumnToIndex(pPk, iCol); | 108721 | int iColPos = sqlite3TableColumnToIndex(pPk, iCol); |
| 108722 | if( iPos<pPk->nKeyCol ) continue; | ||
| 108683 | regOut = reg+1+iPos-(iPos>iColPos); | 108723 | regOut = reg+1+iPos-(iPos>iColPos); |
| 108684 | }else{ | 108724 | }else{ |
| 108685 | regOut = reg+1+nField; | 108725 | regOut = reg+1+nField; |
| 108686 | } | 108726 | } |
| 108687 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, i, regOut); | 108727 | if( i==pTab->iPKey ){ |
| 108728 | sqlite3VdbeAddOp2(v, OP_Null, 0, regOut); | ||
| 108729 | }else{ | ||
| 108730 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, i, regOut); | ||
| 108731 | } | ||
| 108688 | nField++; | 108732 | nField++; |
| 108689 | } | 108733 | } |
| 108690 | } | 108734 | } |
| 108691 | regRec = reg + pTab->nCol; | ||
| 108692 | sqlite3VdbeAddOp3(v, OP_MakeRecord, reg+1, nField, regRec); | 108735 | sqlite3VdbeAddOp3(v, OP_MakeRecord, reg+1, nField, regRec); |
| 108693 | if( pPk ){ | 108736 | if( pPk ){ |
| 108694 | sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iCur, regRec, reg+1, pPk->nKeyCol); | 108737 | sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iCur, regRec, reg+1, pPk->nKeyCol); |
| 108695 | }else{ | 108738 | }else{ |
| 108696 | sqlite3VdbeAddOp3(v, OP_Insert, iCur, regRec, reg); | 108739 | sqlite3VdbeAddOp3(v, OP_Insert, iCur, regRec, reg); |
| 108697 | } | 108740 | } |
| 108741 | sqlite3VdbeChangeP5(v, OPFLAG_SAVEPOSITION); | ||
| 108698 | 108742 | ||
| 108699 | sqlite3VdbeAddOp2(v, OP_Next, iCur, addr+1); VdbeCoverage(v); | 108743 | sqlite3VdbeAddOp2(v, OP_Next, iCur, addr+1); VdbeCoverage(v); |
| 108700 | sqlite3VdbeJumpHere(v, addr); | 108744 | sqlite3VdbeJumpHere(v, addr); |
| @@ -115684,7 +115728,11 @@ SQLITE_PRIVATE void sqlite3CreateIndex( | |||
| 115684 | /* Clean up before exiting */ | 115728 | /* Clean up before exiting */ |
| 115685 | exit_create_index: | 115729 | exit_create_index: |
| 115686 | if( pIndex ) sqlite3FreeIndex(db, pIndex); | 115730 | if( pIndex ) sqlite3FreeIndex(db, pIndex); |
| 115687 | if( pTab ){ /* Ensure all REPLACE indexes are at the end of the list */ | 115731 | if( pTab ){ |
| 115732 | /* Ensure all REPLACE indexes on pTab are at the end of the pIndex list. | ||
| 115733 | ** The list was already ordered when this routine was entered, so at this | ||
| 115734 | ** point at most a single index (the newly added index) will be out of | ||
| 115735 | ** order. So we have to reorder at most one index. */ | ||
| 115688 | Index **ppFrom = &pTab->pIndex; | 115736 | Index **ppFrom = &pTab->pIndex; |
| 115689 | Index *pThis; | 115737 | Index *pThis; |
| 115690 | for(ppFrom=&pTab->pIndex; (pThis = *ppFrom)!=0; ppFrom=&pThis->pNext){ | 115738 | for(ppFrom=&pTab->pIndex; (pThis = *ppFrom)!=0; ppFrom=&pThis->pNext){ |
| @@ -115698,6 +115746,16 @@ exit_create_index: | |||
| 115698 | } | 115746 | } |
| 115699 | break; | 115747 | break; |
| 115700 | } | 115748 | } |
| 115749 | #ifdef SQLITE_DEBUG | ||
| 115750 | /* Verify that all REPLACE indexes really are now at the end | ||
| 115751 | ** of the index list. In other words, no other index type ever | ||
| 115752 | ** comes after a REPLACE index on the list. */ | ||
| 115753 | for(pThis = pTab->pIndex; pThis; pThis=pThis->pNext){ | ||
| 115754 | assert( pThis->onError!=OE_Replace | ||
| 115755 | || pThis->pNext==0 | ||
| 115756 | || pThis->pNext->onError==OE_Replace ); | ||
| 115757 | } | ||
| 115758 | #endif | ||
| 115701 | } | 115759 | } |
| 115702 | sqlite3ExprDelete(db, pPIWhere); | 115760 | sqlite3ExprDelete(db, pPIWhere); |
| 115703 | sqlite3ExprListDelete(db, pList); | 115761 | sqlite3ExprListDelete(db, pList); |
| @@ -123114,7 +123172,9 @@ SQLITE_PRIVATE void sqlite3Insert( | |||
| 123114 | pNx->iDataCur = iDataCur; | 123172 | pNx->iDataCur = iDataCur; |
| 123115 | pNx->iIdxCur = iIdxCur; | 123173 | pNx->iIdxCur = iIdxCur; |
| 123116 | if( pNx->pUpsertTarget ){ | 123174 | if( pNx->pUpsertTarget ){ |
| 123117 | sqlite3UpsertAnalyzeTarget(pParse, pTabList, pNx); | 123175 | if( sqlite3UpsertAnalyzeTarget(pParse, pTabList, pNx) ){ |
| 123176 | goto insert_cleanup; | ||
| 123177 | } | ||
| 123118 | } | 123178 | } |
| 123119 | pNx = pNx->pNextUpsert; | 123179 | pNx = pNx->pNextUpsert; |
| 123120 | }while( pNx!=0 ); | 123180 | }while( pNx!=0 ); |
| @@ -124536,7 +124596,7 @@ static void codeWithoutRowidPreupdate( | |||
| 124536 | Vdbe *v = pParse->pVdbe; | 124596 | Vdbe *v = pParse->pVdbe; |
| 124537 | int r = sqlite3GetTempReg(pParse); | 124597 | int r = sqlite3GetTempReg(pParse); |
| 124538 | assert( !HasRowid(pTab) ); | 124598 | assert( !HasRowid(pTab) ); |
| 124539 | assert( 0==(pParse->db->mDbFlags & DBFLAG_Vacuum) ); | 124599 | assert( 0==(pParse->db->mDbFlags & DBFLAG_Vacuum) || CORRUPT_DB ); |
| 124540 | sqlite3VdbeAddOp2(v, OP_Integer, 0, r); | 124600 | sqlite3VdbeAddOp2(v, OP_Integer, 0, r); |
| 124541 | sqlite3VdbeAddOp4(v, OP_Insert, iCur, regData, r, (char*)pTab, P4_TABLE); | 124601 | sqlite3VdbeAddOp4(v, OP_Insert, iCur, regData, r, (char*)pTab, P4_TABLE); |
| 124542 | sqlite3VdbeChangeP5(v, OPFLAG_ISNOOP); | 124602 | sqlite3VdbeChangeP5(v, OPFLAG_ISNOOP); |
| @@ -133084,7 +133144,7 @@ SQLITE_PRIVATE int sqlite3ColumnsFromExprList( | |||
| 133084 | nCol = pEList->nExpr; | 133144 | nCol = pEList->nExpr; |
| 133085 | aCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol); | 133145 | aCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol); |
| 133086 | testcase( aCol==0 ); | 133146 | testcase( aCol==0 ); |
| 133087 | if( nCol>32767 ) nCol = 32767; | 133147 | if( NEVER(nCol>32767) ) nCol = 32767; |
| 133088 | }else{ | 133148 | }else{ |
| 133089 | nCol = 0; | 133149 | nCol = 0; |
| 133090 | aCol = 0; | 133150 | aCol = 0; |
| @@ -136158,16 +136218,24 @@ static int resolveFromTermToCte( | |||
| 136158 | pSavedWith = pParse->pWith; | 136218 | pSavedWith = pParse->pWith; |
| 136159 | pParse->pWith = pWith; | 136219 | pParse->pWith = pWith; |
| 136160 | if( pSel->selFlags & SF_Recursive ){ | 136220 | if( pSel->selFlags & SF_Recursive ){ |
| 136221 | int rc; | ||
| 136161 | assert( pRecTerm!=0 ); | 136222 | assert( pRecTerm!=0 ); |
| 136162 | assert( (pRecTerm->selFlags & SF_Recursive)==0 ); | 136223 | assert( (pRecTerm->selFlags & SF_Recursive)==0 ); |
| 136163 | assert( pRecTerm->pNext!=0 ); | 136224 | assert( pRecTerm->pNext!=0 ); |
| 136164 | assert( (pRecTerm->pNext->selFlags & SF_Recursive)!=0 ); | 136225 | assert( (pRecTerm->pNext->selFlags & SF_Recursive)!=0 ); |
| 136165 | assert( pRecTerm->pWith==0 ); | 136226 | assert( pRecTerm->pWith==0 ); |
| 136166 | pRecTerm->pWith = pSel->pWith; | 136227 | pRecTerm->pWith = pSel->pWith; |
| 136167 | sqlite3WalkSelect(pWalker, pRecTerm); | 136228 | rc = sqlite3WalkSelect(pWalker, pRecTerm); |
| 136168 | pRecTerm->pWith = 0; | 136229 | pRecTerm->pWith = 0; |
| 136230 | if( rc ){ | ||
| 136231 | pParse->pWith = pSavedWith; | ||
| 136232 | return 2; | ||
| 136233 | } | ||
| 136169 | }else{ | 136234 | }else{ |
| 136170 | sqlite3WalkSelect(pWalker, pSel); | 136235 | if( sqlite3WalkSelect(pWalker, pSel) ){ |
| 136236 | pParse->pWith = pSavedWith; | ||
| 136237 | return 2; | ||
| 136238 | } | ||
| 136171 | } | 136239 | } |
| 136172 | pParse->pWith = pWith; | 136240 | pParse->pWith = pWith; |
| 136173 | 136241 | ||
| @@ -137476,7 +137544,9 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 137476 | sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor); | 137544 | sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor); |
| 137477 | pSub->nSelectRow = pPrior->pSelect->nSelectRow; | 137545 | pSub->nSelectRow = pPrior->pSelect->nSelectRow; |
| 137478 | }else{ | 137546 | }else{ |
| 137479 | /* Generate a subroutine that will materialize the view. */ | 137547 | /* Materalize the view. If the view is not correlated, generate a |
| 137548 | ** subroutine to do the materialization so that subsequent uses of | ||
| 137549 | ** the same view can reuse the materialization. */ | ||
| 137480 | int topAddr; | 137550 | int topAddr; |
| 137481 | int onceAddr = 0; | 137551 | int onceAddr = 0; |
| 137482 | int retAddr; | 137552 | int retAddr; |
| @@ -137503,7 +137573,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 137503 | VdbeComment((v, "end %s", pItem->pTab->zName)); | 137573 | VdbeComment((v, "end %s", pItem->pTab->zName)); |
| 137504 | sqlite3VdbeChangeP1(v, topAddr, retAddr); | 137574 | sqlite3VdbeChangeP1(v, topAddr, retAddr); |
| 137505 | sqlite3ClearTempRegCache(pParse); | 137575 | sqlite3ClearTempRegCache(pParse); |
| 137506 | if( pItem->fg.isCte ){ | 137576 | if( pItem->fg.isCte && pItem->fg.isCorrelated==0 ){ |
| 137507 | CteUse *pCteUse = pItem->u2.pCteUse; | 137577 | CteUse *pCteUse = pItem->u2.pCteUse; |
| 137508 | pCteUse->addrM9e = pItem->addrFillSub; | 137578 | pCteUse->addrM9e = pItem->addrFillSub; |
| 137509 | pCteUse->regRtn = pItem->regReturn; | 137579 | pCteUse->regRtn = pItem->regReturn; |
| @@ -139275,6 +139345,25 @@ SQLITE_PRIVATE SrcList *sqlite3TriggerStepSrc( | |||
| 139275 | return pSrc; | 139345 | return pSrc; |
| 139276 | } | 139346 | } |
| 139277 | 139347 | ||
| 139348 | /* | ||
| 139349 | ** Return true if the pExpr term from the RETURNING clause argument | ||
| 139350 | ** list is of the form "*". Raise an error if the terms if of the | ||
| 139351 | ** form "table.*". | ||
| 139352 | */ | ||
| 139353 | static int isAsteriskTerm( | ||
| 139354 | Parse *pParse, /* Parsing context */ | ||
| 139355 | Expr *pTerm /* A term in the RETURNING clause */ | ||
| 139356 | ){ | ||
| 139357 | assert( pTerm!=0 ); | ||
| 139358 | if( pTerm->op==TK_ASTERISK ) return 1; | ||
| 139359 | if( pTerm->op!=TK_DOT ) return 0; | ||
| 139360 | assert( pTerm->pRight!=0 ); | ||
| 139361 | assert( pTerm->pLeft!=0 ); | ||
| 139362 | if( pTerm->pRight->op!=TK_ASTERISK ) return 0; | ||
| 139363 | sqlite3ErrorMsg(pParse, "RETURNING may not use \"TABLE.*\" wildcards"); | ||
| 139364 | return 1; | ||
| 139365 | } | ||
| 139366 | |||
| 139278 | /* The input list pList is the list of result set terms from a RETURNING | 139367 | /* The input list pList is the list of result set terms from a RETURNING |
| 139279 | ** clause. The table that we are returning from is pTab. | 139368 | ** clause. The table that we are returning from is pTab. |
| 139280 | ** | 139369 | ** |
| @@ -139292,7 +139381,8 @@ static ExprList *sqlite3ExpandReturning( | |||
| 139292 | 139381 | ||
| 139293 | for(i=0; i<pList->nExpr; i++){ | 139382 | for(i=0; i<pList->nExpr; i++){ |
| 139294 | Expr *pOldExpr = pList->a[i].pExpr; | 139383 | Expr *pOldExpr = pList->a[i].pExpr; |
| 139295 | if( ALWAYS(pOldExpr!=0) && pOldExpr->op==TK_ASTERISK ){ | 139384 | if( NEVER(pOldExpr==0) ) continue; |
| 139385 | if( isAsteriskTerm(pParse, pOldExpr) ){ | ||
| 139296 | int jj; | 139386 | int jj; |
| 139297 | for(jj=0; jj<pTab->nCol; jj++){ | 139387 | for(jj=0; jj<pTab->nCol; jj++){ |
| 139298 | Expr *pNewExpr; | 139388 | Expr *pNewExpr; |
| @@ -146825,6 +146915,7 @@ static void whereCombineDisjuncts( | |||
| 146825 | int op; /* Operator for the combined expression */ | 146915 | int op; /* Operator for the combined expression */ |
| 146826 | int idxNew; /* Index in pWC of the next virtual term */ | 146916 | int idxNew; /* Index in pWC of the next virtual term */ |
| 146827 | 146917 | ||
| 146918 | if( (pOne->wtFlags | pTwo->wtFlags) & TERM_VNULL ) return; | ||
| 146828 | if( (pOne->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return; | 146919 | if( (pOne->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return; |
| 146829 | if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return; | 146920 | if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return; |
| 146830 | if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp | 146921 | if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp |
| @@ -147530,6 +147621,7 @@ static void exprAnalyzeExists( | |||
| 147530 | #endif | 147621 | #endif |
| 147531 | if( pSel->pPrior ) return; | 147622 | if( pSel->pPrior ) return; |
| 147532 | if( pSel->pWhere==0 ) return; | 147623 | if( pSel->pWhere==0 ) return; |
| 147624 | if( pSel->pLimit ) return; | ||
| 147533 | if( 0==exprAnalyzeExistsFindEq(pSel, 0, 0) ) return; | 147625 | if( 0==exprAnalyzeExistsFindEq(pSel, 0, 0) ) return; |
| 147534 | 147626 | ||
| 147535 | pDup = sqlite3ExprDup(db, pExpr, 0); | 147627 | pDup = sqlite3ExprDup(db, pExpr, 0); |
| @@ -155314,6 +155406,7 @@ static void windowCheckValue(Parse *pParse, int reg, int eCond){ | |||
| 155314 | VdbeCoverageIf(v, eCond==2); | 155406 | VdbeCoverageIf(v, eCond==2); |
| 155315 | } | 155407 | } |
| 155316 | sqlite3VdbeAddOp3(v, aOp[eCond], regZero, sqlite3VdbeCurrentAddr(v)+2, reg); | 155408 | sqlite3VdbeAddOp3(v, aOp[eCond], regZero, sqlite3VdbeCurrentAddr(v)+2, reg); |
| 155409 | sqlite3VdbeChangeP5(v, SQLITE_AFF_NUMERIC); | ||
| 155317 | VdbeCoverageNeverNullIf(v, eCond==0); /* NULL case captured by */ | 155410 | VdbeCoverageNeverNullIf(v, eCond==0); /* NULL case captured by */ |
| 155318 | VdbeCoverageNeverNullIf(v, eCond==1); /* the OP_MustBeInt */ | 155411 | VdbeCoverageNeverNullIf(v, eCond==1); /* the OP_MustBeInt */ |
| 155319 | VdbeCoverageNeverNullIf(v, eCond==2); | 155412 | VdbeCoverageNeverNullIf(v, eCond==2); |
| @@ -162308,7 +162401,7 @@ static const unsigned char aiClass[] = { | |||
| 162308 | #ifdef SQLITE_EBCDIC | 162401 | #ifdef SQLITE_EBCDIC |
| 162309 | /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */ | 162402 | /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */ |
| 162310 | /* 0x */ 29, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 7, 7, 28, 28, | 162403 | /* 0x */ 29, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 7, 7, 28, 28, |
| 162311 | /* 1x */ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, | 162404 | /* 1x */ 28, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, |
| 162312 | /* 2x */ 28, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, | 162405 | /* 2x */ 28, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, |
| 162313 | /* 3x */ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, | 162406 | /* 3x */ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, |
| 162314 | /* 4x */ 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 26, 12, 17, 20, 10, | 162407 | /* 4x */ 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 26, 12, 17, 20, 10, |
| @@ -229213,7 +229306,7 @@ static void fts5SourceIdFunc( | |||
| 229213 | ){ | 229306 | ){ |
| 229214 | assert( nArg==0 ); | 229307 | assert( nArg==0 ); |
| 229215 | UNUSED_PARAM2(nArg, apUnused); | 229308 | UNUSED_PARAM2(nArg, apUnused); |
| 229216 | sqlite3_result_text(pCtx, "fts5: 2021-03-17 19:07:21 ea80f3002f4120f5dcee76e8779dfdc88e1e096c5cdd06904c20fd26d50c3827", -1, SQLITE_TRANSIENT); | 229309 | sqlite3_result_text(pCtx, "fts5: 2021-04-19 18:32:05 1b256d97b553a9611efca188a3d995a2fff712759044ba480f9a0c9e98fae886", -1, SQLITE_TRANSIENT); |
| 229217 | } | 229310 | } |
| 229218 | 229311 | ||
| 229219 | /* | 229312 | /* |
| @@ -234139,9 +234232,9 @@ SQLITE_API int sqlite3_stmt_init( | |||
| 234139 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ | 234232 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 234140 | 234233 | ||
| 234141 | /************** End of stmt.c ************************************************/ | 234234 | /************** End of stmt.c ************************************************/ |
| 234142 | #if __LINE__!=234142 | 234235 | #if __LINE__!=234235 |
| 234143 | #undef SQLITE_SOURCE_ID | 234236 | #undef SQLITE_SOURCE_ID |
| 234144 | #define SQLITE_SOURCE_ID "2021-03-17 19:07:21 ea80f3002f4120f5dcee76e8779dfdc88e1e096c5cdd06904c20fd26d50calt2" | 234237 | #define SQLITE_SOURCE_ID "2021-04-19 18:32:05 1b256d97b553a9611efca188a3d995a2fff712759044ba480f9a0c9e98faalt2" |
| 234145 | #endif | 234238 | #endif |
| 234146 | /* Return the source-id for this library */ | 234239 | /* Return the source-id for this library */ |
| 234147 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } | 234240 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
diff --git a/c/sqlite3.h b/c/sqlite3.h index f636b29..19ee767 100644 --- a/c/sqlite3.h +++ b/c/sqlite3.h | |||
| @@ -123,9 +123,9 @@ extern "C" { | |||
| 123 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], | 123 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 124 | ** [sqlite_version()] and [sqlite_source_id()]. | 124 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 125 | */ | 125 | */ |
| 126 | #define SQLITE_VERSION "3.35.2" | 126 | #define SQLITE_VERSION "3.35.5" |
| 127 | #define SQLITE_VERSION_NUMBER 3035002 | 127 | #define SQLITE_VERSION_NUMBER 3035005 |
| 128 | #define SQLITE_SOURCE_ID "2021-03-17 19:07:21 ea80f3002f4120f5dcee76e8779dfdc88e1e096c5cdd06904c20fd26d50c3827" | 128 | #define SQLITE_SOURCE_ID "2021-04-19 18:32:05 1b256d97b553a9611efca188a3d995a2fff712759044ba480f9a0c9e98fae886" |
| 129 | 129 | ||
| 130 | /* | 130 | /* |
| 131 | ** CAPI3REF: Run-Time Library Version Numbers | 131 | ** CAPI3REF: Run-Time Library Version Numbers |