|
|
@ -317,7 +317,7 @@ STQLITE_API int sqlite3_exec(
|
|
|
|
** primary result code as a prefix. Primary result codes contain a single
|
|
|
|
** primary result code as a prefix. Primary result codes contain a single
|
|
|
|
** "_" character. Extended result codes contain two or more "_" characters.
|
|
|
|
** "_" character. Extended result codes contain two or more "_" characters.
|
|
|
|
** The numeric value of an extended result code can be converted to its
|
|
|
|
** The numeric value of an extended result code can be converted to its
|
|
|
|
** corresponding primary result code by tqmasking off the lower 8 bytes.
|
|
|
|
** corresponding primary result code by masking off the lower 8 bytes.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** The STQLITE_OK result code will never be extended. It will always
|
|
|
|
** The STQLITE_OK result code will never be extended. It will always
|
|
|
|
** be exactly zero.
|
|
|
|
** be exactly zero.
|
|
|
@ -1532,7 +1532,7 @@ int sqlite3_data_count(sqlite3_stmt *pStmt);
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** Note that when type conversions occur, pointers returned by prior
|
|
|
|
** Note that when type conversions occur, pointers returned by prior
|
|
|
|
** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
|
|
|
|
** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
|
|
|
|
** sqlite3_column_text16() may be tqinvalidated.
|
|
|
|
** sqlite3_column_text16() may be invalidated.
|
|
|
|
** Type conversions and pointer invalidations might occur
|
|
|
|
** Type conversions and pointer invalidations might occur
|
|
|
|
** in the following cases:
|
|
|
|
** in the following cases:
|
|
|
|
**
|
|
|
|
**
|
|
|
@ -1554,7 +1554,7 @@ int sqlite3_data_count(sqlite3_stmt *pStmt);
|
|
|
|
** not tqinvalidate a prior pointer, though of course the content of the buffer
|
|
|
|
** not tqinvalidate a prior pointer, though of course the content of the buffer
|
|
|
|
** that the prior pointer points to will have been modified. Other kinds
|
|
|
|
** that the prior pointer points to will have been modified. Other kinds
|
|
|
|
** of conversion are done in place when it is possible, but sometime it is
|
|
|
|
** of conversion are done in place when it is possible, but sometime it is
|
|
|
|
** not possible and in those cases prior pointers are tqinvalidated.
|
|
|
|
** not possible and in those cases prior pointers are invalidated.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** The safest and easiest to remember policy is to invoke these routines
|
|
|
|
** The safest and easiest to remember policy is to invoke these routines
|
|
|
|
** in one of the following ways:
|
|
|
|
** in one of the following ways:
|
|
|
@ -1757,7 +1757,7 @@ int sqlite3_global_recover(void);
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** Please pay particular attention to the fact that the pointer that
|
|
|
|
** Please pay particular attention to the fact that the pointer that
|
|
|
|
** is returned from [sqlite3_value_blob()], [sqlite3_value_text()], or
|
|
|
|
** is returned from [sqlite3_value_blob()], [sqlite3_value_text()], or
|
|
|
|
** [sqlite3_value_text16()] can be tqinvalidated by a subsequent call to
|
|
|
|
** [sqlite3_value_text16()] can be invalidated by a subsequent call to
|
|
|
|
** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite_value_text()],
|
|
|
|
** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite_value_text()],
|
|
|
|
** or [sqlite3_value_text16()].
|
|
|
|
** or [sqlite3_value_text16()].
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -18824,7 +18824,7 @@ static void pagerUnlockAndRollback(Pager *p){
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
** Clear the in-memory cache. This routine
|
|
|
|
** Clear the in-memory cache. This routine
|
|
|
|
** sets the state of the pager back to what it was when it was first
|
|
|
|
** sets the state of the pager back to what it was when it was first
|
|
|
|
** opened. Any outstanding pages are tqinvalidated and subsequent attempts
|
|
|
|
** opened. Any outstanding pages are invalidated and subsequent attempts
|
|
|
|
** to access those pages will likely result in a coredump.
|
|
|
|
** to access those pages will likely result in a coredump.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static void pager_reset(Pager *pPager){
|
|
|
|
static void pager_reset(Pager *pPager){
|
|
|
@ -20061,7 +20061,7 @@ STQLITE_PRIVATE int sqlite3PagerTruncate(Pager *pPager, Pgno nPage){
|
|
|
|
** Shutdown the page cache. Free all memory and close all files.
|
|
|
|
** Shutdown the page cache. Free all memory and close all files.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** If a transaction was in progress when this routine is called, that
|
|
|
|
** If a transaction was in progress when this routine is called, that
|
|
|
|
** transaction is rolled back. All outstanding pages are tqinvalidated
|
|
|
|
** transaction is rolled back. All outstanding pages are invalidated
|
|
|
|
** and their memory is freed. Any attempt to use a page associated
|
|
|
|
** and their memory is freed. Any attempt to use a page associated
|
|
|
|
** with this page cache after this function returns will likely
|
|
|
|
** with this page cache after this function returns will likely
|
|
|
|
** result in a coredump.
|
|
|
|
** result in a coredump.
|
|
|
@ -23114,7 +23114,7 @@ static void releasePage(MemPage *pPage); /* Forward reference */
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
** Invalidate the overflow page-list cache for cursor pCur, if any.
|
|
|
|
** Invalidate the overflow page-list cache for cursor pCur, if any.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static void tqinvalidateOverflowCache(BtCursor *pCur){
|
|
|
|
static void invalidateOverflowCache(BtCursor *pCur){
|
|
|
|
sqliteFree(pCur->aOverflow);
|
|
|
|
sqliteFree(pCur->aOverflow);
|
|
|
|
pCur->aOverflow = 0;
|
|
|
|
pCur->aOverflow = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -23123,15 +23123,15 @@ static void tqinvalidateOverflowCache(BtCursor *pCur){
|
|
|
|
** Invalidate the overflow page-list cache for all cursors opened
|
|
|
|
** Invalidate the overflow page-list cache for all cursors opened
|
|
|
|
** on the shared btree structure pBt.
|
|
|
|
** on the shared btree structure pBt.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static void tqinvalidateAllOverflowCache(BtShared *pBt){
|
|
|
|
static void invalidateAllOverflowCache(BtShared *pBt){
|
|
|
|
BtCursor *p;
|
|
|
|
BtCursor *p;
|
|
|
|
for(p=pBt->pCursor; p; p=p->pNext){
|
|
|
|
for(p=pBt->pCursor; p; p=p->pNext){
|
|
|
|
tqinvalidateOverflowCache(p);
|
|
|
|
invalidateOverflowCache(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
#define tqinvalidateOverflowCache(x)
|
|
|
|
#define invalidateOverflowCache(x)
|
|
|
|
#define tqinvalidateAllOverflowCache(x)
|
|
|
|
#define invalidateAllOverflowCache(x)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -23173,7 +23173,7 @@ static int saveCursorPosition(BtCursor *pCur){
|
|
|
|
pCur->eState = CURSOR_RETQUIRESEEK;
|
|
|
|
pCur->eState = CURSOR_RETQUIRESEEK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tqinvalidateOverflowCache(pCur);
|
|
|
|
invalidateOverflowCache(pCur);
|
|
|
|
return rc;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -24872,7 +24872,7 @@ STQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *p){
|
|
|
|
if( !pBt->autoVacuum ){
|
|
|
|
if( !pBt->autoVacuum ){
|
|
|
|
return STQLITE_DONE;
|
|
|
|
return STQLITE_DONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tqinvalidateAllOverflowCache(pBt);
|
|
|
|
invalidateAllOverflowCache(pBt);
|
|
|
|
return incrVacuumStep(pBt, 0);
|
|
|
|
return incrVacuumStep(pBt, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -24892,7 +24892,7 @@ static int autoVacuumCommit(BtShared *pBt, Pgno *pnTrunc){
|
|
|
|
int nRef = sqlite3PagerRefcount(pPager);
|
|
|
|
int nRef = sqlite3PagerRefcount(pPager);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
tqinvalidateAllOverflowCache(pBt);
|
|
|
|
invalidateAllOverflowCache(pBt);
|
|
|
|
assert(pBt->autoVacuum);
|
|
|
|
assert(pBt->autoVacuum);
|
|
|
|
if( !pBt->incrVacuum ){
|
|
|
|
if( !pBt->incrVacuum ){
|
|
|
|
Pgno nFin = 0;
|
|
|
|
Pgno nFin = 0;
|
|
|
@ -25199,7 +25199,7 @@ STQLITE_PRIVATE int sqlite3BtreeCommitStmt(Btree *p){
|
|
|
|
** Rollback the active statement subtransaction. If no subtransaction
|
|
|
|
** Rollback the active statement subtransaction. If no subtransaction
|
|
|
|
** is active this routine is a no-op.
|
|
|
|
** is active this routine is a no-op.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** All cursors will be tqinvalidated by this operation. Any attempt
|
|
|
|
** All cursors will be invalidated by this operation. Any attempt
|
|
|
|
** to use a cursor that was open at the beginning of this operation
|
|
|
|
** to use a cursor that was open at the beginning of this operation
|
|
|
|
** will result in an error.
|
|
|
|
** will result in an error.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -25355,7 +25355,7 @@ STQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor *pCur){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
releasePage(pCur->pPage);
|
|
|
|
releasePage(pCur->pPage);
|
|
|
|
unlockBtreeIfUnused(pBt);
|
|
|
|
unlockBtreeIfUnused(pBt);
|
|
|
|
tqinvalidateOverflowCache(pCur);
|
|
|
|
invalidateOverflowCache(pCur);
|
|
|
|
sqliteFree(pCur);
|
|
|
|
sqliteFree(pCur);
|
|
|
|
return STQLITE_OK;
|
|
|
|
return STQLITE_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -25609,7 +25609,7 @@ static int copyPayload(
|
|
|
|
** cache to make seeking to the supplied offset more efficient.
|
|
|
|
** cache to make seeking to the supplied offset more efficient.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** Once an overflow page-list cache has been allocated, it may be
|
|
|
|
** Once an overflow page-list cache has been allocated, it may be
|
|
|
|
** tqinvalidated if some other cursor writes to the same table, or if
|
|
|
|
** invalidated if some other cursor writes to the same table, or if
|
|
|
|
** the cursor is moved to a different row. Additionally, in auto-vacuum
|
|
|
|
** the cursor is moved to a different row. Additionally, in auto-vacuum
|
|
|
|
** mode, the following events may tqinvalidate an overflow page-list cache.
|
|
|
|
** mode, the following events may tqinvalidate an overflow page-list cache.
|
|
|
|
**
|
|
|
|
**
|
|
|
@ -27133,9 +27133,9 @@ static int balance_quick(MemPage *pPage, MemPage *pParent){
|
|
|
|
int szCell;
|
|
|
|
int szCell;
|
|
|
|
CellInfo info;
|
|
|
|
CellInfo info;
|
|
|
|
BtShared *pBt = pPage->pBt;
|
|
|
|
BtShared *pBt = pPage->pBt;
|
|
|
|
int tqparentIdx = pParent->nCell; /* pParent new divider cell index */
|
|
|
|
int parentIdx = pParent->nCell; /* pParent new divider cell index */
|
|
|
|
int tqparentSize; /* Size of new divider cell */
|
|
|
|
int parentSize; /* Size of new divider cell */
|
|
|
|
u8 tqparentCell[64]; /* Space for the new divider cell */
|
|
|
|
u8 parentCell[64]; /* Space for the new divider cell */
|
|
|
|
|
|
|
|
|
|
|
|
/* Allocate a new page. Insert the overflow cell from pPage
|
|
|
|
/* Allocate a new page. Insert the overflow cell from pPage
|
|
|
|
** into it. Then remove the overflow cell from pPage.
|
|
|
|
** into it. Then remove the overflow cell from pPage.
|
|
|
@ -27161,16 +27161,16 @@ static int balance_quick(MemPage *pPage, MemPage *pParent){
|
|
|
|
assert( pPage->nCell>0 );
|
|
|
|
assert( pPage->nCell>0 );
|
|
|
|
pCell = findCell(pPage, pPage->nCell-1);
|
|
|
|
pCell = findCell(pPage, pPage->nCell-1);
|
|
|
|
sqlite3BtreeParseCellPtr(pPage, pCell, &info);
|
|
|
|
sqlite3BtreeParseCellPtr(pPage, pCell, &info);
|
|
|
|
rc = fillInCell(pParent, tqparentCell, 0, info.nKey, 0, 0, 0, &tqparentSize);
|
|
|
|
rc = fillInCell(pParent, parentCell, 0, info.nKey, 0, 0, 0, &parentSize);
|
|
|
|
if( rc!=STQLITE_OK ){
|
|
|
|
if( rc!=STQLITE_OK ){
|
|
|
|
return rc;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert( tqparentSize<64 );
|
|
|
|
assert( parentSize<64 );
|
|
|
|
rc = insertCell(pParent, tqparentIdx, tqparentCell, tqparentSize, 0, 4);
|
|
|
|
rc = insertCell(pParent, parentIdx, parentCell, parentSize, 0, 4);
|
|
|
|
if( rc!=STQLITE_OK ){
|
|
|
|
if( rc!=STQLITE_OK ){
|
|
|
|
return rc;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
put4byte(findOverflowCell(pParent,tqparentIdx), pPage->pgno);
|
|
|
|
put4byte(findOverflowCell(pParent,parentIdx), pPage->pgno);
|
|
|
|
put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew);
|
|
|
|
put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew);
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef STQLITE_OMIT_AUTOVACUUM
|
|
|
|
#ifndef STQLITE_OMIT_AUTOVACUUM
|
|
|
@ -28249,7 +28249,7 @@ STQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree *p, int *piTable, int flags){
|
|
|
|
** out to be an overflow page, delete all overflow page-map caches
|
|
|
|
** out to be an overflow page, delete all overflow page-map caches
|
|
|
|
** held by open cursors.
|
|
|
|
** held by open cursors.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
tqinvalidateAllOverflowCache(pBt);
|
|
|
|
invalidateAllOverflowCache(pBt);
|
|
|
|
|
|
|
|
|
|
|
|
/* Read the value of meta[3] from the database to determine where the
|
|
|
|
/* Read the value of meta[3] from the database to determine where the
|
|
|
|
** root page of the new table should go. meta[3] is the largest root-page
|
|
|
|
** root page of the new table should go. meta[3] is the largest root-page
|
|
|
@ -29591,7 +29591,7 @@ STQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){
|
|
|
|
** are converted using sqlite3_snprintf(). Converting a BLOB to a string
|
|
|
|
** are converted using sqlite3_snprintf(). Converting a BLOB to a string
|
|
|
|
** is a no-op.
|
|
|
|
** is a no-op.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** Existing representations MEM_Int and MEM_Real are *not* tqinvalidated.
|
|
|
|
** Existing representations MEM_Int and MEM_Real are *not* invalidated.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** A MEM_Null value will never be passed to this function. This function is
|
|
|
|
** A MEM_Null value will never be passed to this function. This function is
|
|
|
|
** used for converting values to text for returning to the user (i.e. via
|
|
|
|
** used for converting values to text for returning to the user (i.e. via
|
|
|
@ -30630,13 +30630,13 @@ static int opcodeNoPush(u8 op){
|
|
|
|
** NOPUSH_MASK_0 corresponds to opcodes 0 to 15. NOPUSH_MASK_1 tqcontains
|
|
|
|
** NOPUSH_MASK_0 corresponds to opcodes 0 to 15. NOPUSH_MASK_1 tqcontains
|
|
|
|
** one bit for opcodes 16 to 31, and so on.
|
|
|
|
** one bit for opcodes 16 to 31, and so on.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** 16-bit bittqmasks (rather than 32-bit) are specified in opcodes.h
|
|
|
|
** 16-bit bitmasks (rather than 32-bit) are specified in opcodes.h
|
|
|
|
** because the file is generated by an awk program. Awk manipulates
|
|
|
|
** because the file is generated by an awk program. Awk manipulates
|
|
|
|
** all numbers as floating-point and we don't want to risk a rounding
|
|
|
|
** all numbers as floating-point and we don't want to risk a rounding
|
|
|
|
** error if someone builds with an awk that uses (for example) 32-bit
|
|
|
|
** error if someone builds with an awk that uses (for example) 32-bit
|
|
|
|
** IEEE floats.
|
|
|
|
** IEEE floats.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static const u32 tqmasks[5] = {
|
|
|
|
static const u32 masks[5] = {
|
|
|
|
NOPUSH_MASK_0 + (((unsigned)NOPUSH_MASK_1)<<16),
|
|
|
|
NOPUSH_MASK_0 + (((unsigned)NOPUSH_MASK_1)<<16),
|
|
|
|
NOPUSH_MASK_2 + (((unsigned)NOPUSH_MASK_3)<<16),
|
|
|
|
NOPUSH_MASK_2 + (((unsigned)NOPUSH_MASK_3)<<16),
|
|
|
|
NOPUSH_MASK_4 + (((unsigned)NOPUSH_MASK_5)<<16),
|
|
|
|
NOPUSH_MASK_4 + (((unsigned)NOPUSH_MASK_5)<<16),
|
|
|
@ -30644,7 +30644,7 @@ static int opcodeNoPush(u8 op){
|
|
|
|
NOPUSH_MASK_8 + (((unsigned)NOPUSH_MASK_9)<<16)
|
|
|
|
NOPUSH_MASK_8 + (((unsigned)NOPUSH_MASK_9)<<16)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
assert( op<32*5 );
|
|
|
|
assert( op<32*5 );
|
|
|
|
return (tqmasks[op>>5] & (1<<(op&0x1F)));
|
|
|
|
return (masks[op>>5] & (1<<(op&0x1F)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
#ifndef NDEBUG
|
|
|
@ -36150,7 +36150,7 @@ case OP_VerifyCookie: { /* no-push */
|
|
|
|
** prepared queries. If such a query is out-of-date, we do not want to
|
|
|
|
** prepared queries. If such a query is out-of-date, we do not want to
|
|
|
|
** discard the database schema, as the user code implementing the
|
|
|
|
** discard the database schema, as the user code implementing the
|
|
|
|
** v-table would have to be ready for the sqlite3_vtab structure itself
|
|
|
|
** v-table would have to be ready for the sqlite3_vtab structure itself
|
|
|
|
** to be tqinvalidated whenever sqlite3_step() is called from within
|
|
|
|
** to be invalidated whenever sqlite3_step() is called from within
|
|
|
|
** a v-table method.
|
|
|
|
** a v-table method.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if( db->aDb[pOp->p1].pSchema->schema_cookie!=iMeta ){
|
|
|
|
if( db->aDb[pOp->p1].pSchema->schema_cookie!=iMeta ){
|
|
|
@ -39004,7 +39004,7 @@ static int blobReadWrite(
|
|
|
|
sqlite3 *db;
|
|
|
|
sqlite3 *db;
|
|
|
|
|
|
|
|
|
|
|
|
/* If there is no statement handle, then the blob-handle has
|
|
|
|
/* If there is no statement handle, then the blob-handle has
|
|
|
|
** already been tqinvalidated. Return STQLITE_ABORT in this case.
|
|
|
|
** already been invalidated. Return STQLITE_ABORT in this case.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if( !v ) return STQLITE_ABORT;
|
|
|
|
if( !v ) return STQLITE_ABORT;
|
|
|
|
|
|
|
|
|
|
|
@ -41690,7 +41690,7 @@ static void renameTableFunc(
|
|
|
|
|
|
|
|
|
|
|
|
/* The principle used to locate the table name in the CREATE TABLE
|
|
|
|
/* The principle used to locate the table name in the CREATE TABLE
|
|
|
|
** statement is that the table name is the first token that is immediatedly
|
|
|
|
** statement is that the table name is the first token that is immediatedly
|
|
|
|
** followed by a left tqparenthesis - TK_LP - or "USING" TK_USING.
|
|
|
|
** followed by a left parenthesis - TK_LP - or "USING" TK_USING.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if( zSql ){
|
|
|
|
if( zSql ){
|
|
|
|
do {
|
|
|
|
do {
|
|
|
@ -51963,7 +51963,7 @@ static int getTempStore(const char *z){
|
|
|
|
** Invalidate temp storage, either when the temp storage is changed
|
|
|
|
** Invalidate temp storage, either when the temp storage is changed
|
|
|
|
** from default, or when 'file' and the temp_store_directory has changed
|
|
|
|
** from default, or when 'file' and the temp_store_directory has changed
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static int tqinvalidateTempStorage(Parse *pParse){
|
|
|
|
static int invalidateTempStorage(Parse *pParse){
|
|
|
|
sqlite3 *db = pParse->db;
|
|
|
|
sqlite3 *db = pParse->db;
|
|
|
|
if( db->aDb[1].pBt!=0 ){
|
|
|
|
if( db->aDb[1].pBt!=0 ){
|
|
|
|
if( !db->autoCommit ){
|
|
|
|
if( !db->autoCommit ){
|
|
|
@ -51989,7 +51989,7 @@ static int changeTempStorage(Parse *pParse, const char *zStorageType){
|
|
|
|
int ts = getTempStore(zStorageType);
|
|
|
|
int ts = getTempStore(zStorageType);
|
|
|
|
sqlite3 *db = pParse->db;
|
|
|
|
sqlite3 *db = pParse->db;
|
|
|
|
if( db->temp_store==ts ) return STQLITE_OK;
|
|
|
|
if( db->temp_store==ts ) return STQLITE_OK;
|
|
|
|
if( tqinvalidateTempStorage( pParse ) != STQLITE_OK ){
|
|
|
|
if( invalidateTempStorage( pParse ) != STQLITE_OK ){
|
|
|
|
return STQLITE_ERROR;
|
|
|
|
return STQLITE_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
db->temp_store = ts;
|
|
|
|
db->temp_store = ts;
|
|
|
@ -52393,7 +52393,7 @@ STQLITE_PRIVATE void sqlite3Pragma(
|
|
|
|
** Return or set the local value of the temp_store_directory flag. Changing
|
|
|
|
** Return or set the local value of the temp_store_directory flag. Changing
|
|
|
|
** the value sets a specific directory to be used for temporary files.
|
|
|
|
** the value sets a specific directory to be used for temporary files.
|
|
|
|
** Setting to a null string reverts to the default temporary directory search.
|
|
|
|
** Setting to a null string reverts to the default temporary directory search.
|
|
|
|
** If temporary directory is changed, then tqinvalidateTempStorage.
|
|
|
|
** If temporary directory is changed, then invalidateTempStorage.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if( sqlite3StrICmp(zLeft, "temp_store_directory")==0 ){
|
|
|
|
if( sqlite3StrICmp(zLeft, "temp_store_directory")==0 ){
|
|
|
@ -52414,7 +52414,7 @@ STQLITE_PRIVATE void sqlite3Pragma(
|
|
|
|
|| (TEMP_STORE==1 && db->temp_store<=1)
|
|
|
|
|| (TEMP_STORE==1 && db->temp_store<=1)
|
|
|
|
|| (TEMP_STORE==2 && db->temp_store==1)
|
|
|
|
|| (TEMP_STORE==2 && db->temp_store==1)
|
|
|
|
){
|
|
|
|
){
|
|
|
|
tqinvalidateTempStorage(pParse);
|
|
|
|
invalidateTempStorage(pParse);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sqliteFree(sqlite3_temp_directory);
|
|
|
|
sqliteFree(sqlite3_temp_directory);
|
|
|
|
if( zRight[0] ){
|
|
|
|
if( zRight[0] ){
|
|
|
@ -56578,7 +56578,7 @@ static void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){
|
|
|
|
** This routine does NOT free the Select structure passed in. The
|
|
|
|
** This routine does NOT free the Select structure passed in. The
|
|
|
|
** calling function needs to do that.
|
|
|
|
** calling function needs to do that.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** The pParent, tqparentTab, and *pParentAgg fields are filled in if this
|
|
|
|
** The pParent, parentTab, and *pParentAgg fields are filled in if this
|
|
|
|
** SELECT is a subquery. This routine may try to combine this SELECT
|
|
|
|
** SELECT is a subquery. This routine may try to combine this SELECT
|
|
|
|
** with its tqparent to form a single flat query. In so doing, it might
|
|
|
|
** with its tqparent to form a single flat query. In so doing, it might
|
|
|
|
** change the tqparent query from a non-aggregate to an aggregate query.
|
|
|
|
** change the tqparent query from a non-aggregate to an aggregate query.
|
|
|
@ -56596,7 +56596,7 @@ static void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){
|
|
|
|
** pParent will be NULL. During the processing of the outer query, this
|
|
|
|
** pParent will be NULL. During the processing of the outer query, this
|
|
|
|
** routine is called recursively to handle the subquery. For the recursive
|
|
|
|
** routine is called recursively to handle the subquery. For the recursive
|
|
|
|
** call, pParent will point to the outer query. Because the subquery is
|
|
|
|
** call, pParent will point to the outer query. Because the subquery is
|
|
|
|
** the second element in a three-way join, the tqparentTab parameter will
|
|
|
|
** the second element in a three-way join, the parentTab parameter will
|
|
|
|
** be 1 (the 2nd value of a 0-indexed array.)
|
|
|
|
** be 1 (the 2nd value of a 0-indexed array.)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
STQLITE_PRIVATE int sqlite3Select(
|
|
|
|
STQLITE_PRIVATE int sqlite3Select(
|
|
|
@ -56605,7 +56605,7 @@ STQLITE_PRIVATE int sqlite3Select(
|
|
|
|
int eDest, /* How to dispose of the results */
|
|
|
|
int eDest, /* How to dispose of the results */
|
|
|
|
int iParm, /* A parameter used by the eDest disposal method */
|
|
|
|
int iParm, /* A parameter used by the eDest disposal method */
|
|
|
|
Select *pParent, /* Another SELECT for which this is a sub-query */
|
|
|
|
Select *pParent, /* Another SELECT for which this is a sub-query */
|
|
|
|
int tqparentTab, /* Index in pParent->pSrc of this query */
|
|
|
|
int parentTab, /* Index in pParent->pSrc of this query */
|
|
|
|
int *pParentAgg, /* True if pParent uses aggregate functions */
|
|
|
|
int *pParentAgg, /* True if pParent uses aggregate functions */
|
|
|
|
char *aff /* If eDest is SRT_Union, the affinity string */
|
|
|
|
char *aff /* If eDest is SRT_Union, the affinity string */
|
|
|
|
){
|
|
|
|
){
|
|
|
@ -56755,7 +56755,7 @@ STQLITE_PRIVATE int sqlite3Select(
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#ifndef STQLITE_OMIT_VIEW
|
|
|
|
#ifndef STQLITE_OMIT_VIEW
|
|
|
|
if( pParent && pParentAgg &&
|
|
|
|
if( pParent && pParentAgg &&
|
|
|
|
flattenSubquery(pParent, tqparentTab, *pParentAgg, isAgg) ){
|
|
|
|
flattenSubquery(pParent, parentTab, *pParentAgg, isAgg) ){
|
|
|
|
if( isAgg ) *pParentAgg = 1;
|
|
|
|
if( isAgg ) *pParentAgg = 1;
|
|
|
|
goto select_end;
|
|
|
|
goto select_end;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -57104,9 +57104,9 @@ STQLITE_PRIVATE int sqlite3Select(
|
|
|
|
** the temporary table.
|
|
|
|
** the temporary table.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if( pParent ){
|
|
|
|
if( pParent ){
|
|
|
|
assert( pParent->pSrc->nSrc>tqparentTab );
|
|
|
|
assert( pParent->pSrc->nSrc>parentTab );
|
|
|
|
assert( pParent->pSrc->a[tqparentTab].pSelect==p );
|
|
|
|
assert( pParent->pSrc->a[parentTab].pSelect==p );
|
|
|
|
pParent->pSrc->a[tqparentTab].isPopulated = 1;
|
|
|
|
pParent->pSrc->a[parentTab].isPopulated = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
@ -60040,7 +60040,7 @@ struct WhereTerm {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
struct WhereClause {
|
|
|
|
struct WhereClause {
|
|
|
|
Parse *pParse; /* The parser context */
|
|
|
|
Parse *pParse; /* The parser context */
|
|
|
|
ExprMaskSet *pMaskSet; /* Mapping of table indices to bittqmasks */
|
|
|
|
ExprMaskSet *pMaskSet; /* Mapping of table indices to bitmasks */
|
|
|
|
int nTerm; /* Number of terms */
|
|
|
|
int nTerm; /* Number of terms */
|
|
|
|
int nSlot; /* Number of entries in a[] */
|
|
|
|
int nSlot; /* Number of entries in a[] */
|
|
|
|
WhereTerm *a; /* Each a[] describes a term of the WHERE cluase */
|
|
|
|
WhereTerm *a; /* Each a[] describes a term of the WHERE cluase */
|
|
|
@ -60049,13 +60049,13 @@ struct WhereClause {
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
** An instance of the following structure keeps track of a mapping
|
|
|
|
** An instance of the following structure keeps track of a mapping
|
|
|
|
** between VDBE cursor numbers and bits of the bittqmasks in WhereTerm.
|
|
|
|
** between VDBE cursor numbers and bits of the bitmasks in WhereTerm.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** The VDBE cursor numbers are small integers contained in
|
|
|
|
** The VDBE cursor numbers are small integers contained in
|
|
|
|
** SrcList_item.iCursor and Expr.iTable fields. For any given WHERE
|
|
|
|
** SrcList_item.iCursor and Expr.iTable fields. For any given WHERE
|
|
|
|
** clause, the cursor numbers might not begin with 0 and they might
|
|
|
|
** clause, the cursor numbers might not begin with 0 and they might
|
|
|
|
** contain gaps in the numbering sequence. But we want to make maximum
|
|
|
|
** contain gaps in the numbering sequence. But we want to make maximum
|
|
|
|
** use of the bits in our bittqmasks. This structure provides a mapping
|
|
|
|
** use of the bits in our bitmasks. This structure provides a mapping
|
|
|
|
** from the sparse cursor numbers into consecutive integers beginning
|
|
|
|
** from the sparse cursor numbers into consecutive integers beginning
|
|
|
|
** with 0.
|
|
|
|
** with 0.
|
|
|
|
**
|
|
|
|
**
|
|
|
@ -60080,7 +60080,7 @@ struct ExprMaskSet {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
** Bittqmasks for the operators that indices are able to exploit. An
|
|
|
|
** Bitmasks for the operators that indices are able to exploit. An
|
|
|
|
** OR-ed combination of these values can be used when searching for
|
|
|
|
** OR-ed combination of these values can be used when searching for
|
|
|
|
** terms in the where clause.
|
|
|
|
** terms in the where clause.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -60123,7 +60123,7 @@ struct ExprMaskSet {
|
|
|
|
static void whereClauseInit(
|
|
|
|
static void whereClauseInit(
|
|
|
|
WhereClause *pWC, /* The WhereClause to be initialized */
|
|
|
|
WhereClause *pWC, /* The WhereClause to be initialized */
|
|
|
|
Parse *pParse, /* The parsing context */
|
|
|
|
Parse *pParse, /* The parsing context */
|
|
|
|
ExprMaskSet *pMaskSet /* Mapping from table indices to bittqmasks */
|
|
|
|
ExprMaskSet *pMaskSet /* Mapping from table indices to bitmasks */
|
|
|
|
){
|
|
|
|
){
|
|
|
|
pWC->pParse = pParse;
|
|
|
|
pWC->pParse = pParse;
|
|
|
|
pWC->pMaskSet = pMaskSet;
|
|
|
|
pWC->pMaskSet = pMaskSet;
|
|
|
@ -60259,7 +60259,7 @@ static void createMask(ExprMaskSet *pMaskSet, int iCursor){
|
|
|
|
** sets their opcodes to TK_COLUMN and their Expr.iTable fields to
|
|
|
|
** sets their opcodes to TK_COLUMN and their Expr.iTable fields to
|
|
|
|
** the VDBE cursor number of the table. This routine just has to
|
|
|
|
** the VDBE cursor number of the table. This routine just has to
|
|
|
|
** translate the cursor numbers into bittqmask values and OR all
|
|
|
|
** translate the cursor numbers into bittqmask values and OR all
|
|
|
|
** the bittqmasks together.
|
|
|
|
** the bitmasks together.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static Bittqmask exprListTableUsage(ExprMaskSet*, ExprList*);
|
|
|
|
static Bittqmask exprListTableUsage(ExprMaskSet*, ExprList*);
|
|
|
|
static Bittqmask exprSelectTableUsage(ExprMaskSet*, Select*);
|
|
|
|
static Bittqmask exprSelectTableUsage(ExprMaskSet*, Select*);
|
|
|
@ -61889,7 +61889,7 @@ STQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
|
|
|
|
int brk, cont = 0; /* Addresses used during code generation */
|
|
|
|
int brk, cont = 0; /* Addresses used during code generation */
|
|
|
|
Bittqmask notReady; /* Cursors that are not yet positioned */
|
|
|
|
Bittqmask notReady; /* Cursors that are not yet positioned */
|
|
|
|
WhereTerm *pTerm; /* A single term in the WHERE clause */
|
|
|
|
WhereTerm *pTerm; /* A single term in the WHERE clause */
|
|
|
|
ExprMaskSet tqmaskSet; /* The expression tqmask set */
|
|
|
|
ExprMaskSet maskSet; /* The expression tqmask set */
|
|
|
|
WhereClause wc; /* The WHERE clause is divided into these terms */
|
|
|
|
WhereClause wc; /* The WHERE clause is divided into these terms */
|
|
|
|
struct SrcList_item *pTabItem; /* A single entry from pTabList */
|
|
|
|
struct SrcList_item *pTabItem; /* A single entry from pTabList */
|
|
|
|
WhereLevel *pLevel; /* A single level in the pWInfo list */
|
|
|
|
WhereLevel *pLevel; /* A single level in the pWInfo list */
|
|
|
@ -61907,8 +61907,8 @@ STQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
|
|
|
|
/* Split the WHERE clause into separate subexpressions where each
|
|
|
|
/* Split the WHERE clause into separate subexpressions where each
|
|
|
|
** subexpression is separated by an AND operator.
|
|
|
|
** subexpression is separated by an AND operator.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
initMaskSet(&tqmaskSet);
|
|
|
|
initMaskSet(&maskSet);
|
|
|
|
whereClauseInit(&wc, pParse, &tqmaskSet);
|
|
|
|
whereClauseInit(&wc, pParse, &maskSet);
|
|
|
|
whereSplit(&wc, pWhere, TK_AND);
|
|
|
|
whereSplit(&wc, pWhere, TK_AND);
|
|
|
|
|
|
|
|
|
|
|
|
/* Allocate and initialize the WhereInfo structure that will become the
|
|
|
|
/* Allocate and initialize the WhereInfo structure that will become the
|
|
|
@ -61937,7 +61937,7 @@ STQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
|
|
|
|
** and work forward so that the added virtual terms are never processed.
|
|
|
|
** and work forward so that the added virtual terms are never processed.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
for(i=0; i<pTabList->nSrc; i++){
|
|
|
|
for(i=0; i<pTabList->nSrc; i++){
|
|
|
|
createMask(&tqmaskSet, pTabList->a[i].iCursor);
|
|
|
|
createMask(&maskSet, pTabList->a[i].iCursor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exprAnalyzeAll(pTabList, &wc);
|
|
|
|
exprAnalyzeAll(pTabList, &wc);
|
|
|
|
if( sqlite3MallocFailed() ){
|
|
|
|
if( sqlite3MallocFailed() ){
|
|
|
@ -61984,7 +61984,7 @@ STQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
|
|
|
|
|
|
|
|
|
|
|
|
doNotReorder = (pTabItem->jointype & (JT_LEFT|JT_CROSS))!=0;
|
|
|
|
doNotReorder = (pTabItem->jointype & (JT_LEFT|JT_CROSS))!=0;
|
|
|
|
if( once && doNotReorder ) break;
|
|
|
|
if( once && doNotReorder ) break;
|
|
|
|
m = getMask(&tqmaskSet, pTabItem->iCursor);
|
|
|
|
m = getMask(&maskSet, pTabItem->iCursor);
|
|
|
|
if( (m & notReady)==0 ){
|
|
|
|
if( (m & notReady)==0 ){
|
|
|
|
if( j==iFrom ) iFrom++;
|
|
|
|
if( j==iFrom ) iFrom++;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
@ -62046,7 +62046,7 @@ STQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
pLevel->iIdxCur = -1;
|
|
|
|
pLevel->iIdxCur = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
notReady &= ~getMask(&tqmaskSet, pTabList->a[bestJ].iCursor);
|
|
|
|
notReady &= ~getMask(&maskSet, pTabList->a[bestJ].iCursor);
|
|
|
|
pLevel->iFrom = bestJ;
|
|
|
|
pLevel->iFrom = bestJ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
WHERETRACE(("*** Optimizer Finished ***\n"));
|
|
|
|
WHERETRACE(("*** Optimizer Finished ***\n"));
|
|
|
@ -62494,7 +62494,7 @@ STQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
|
|
|
|
pLevel->p1 = iCur;
|
|
|
|
pLevel->p1 = iCur;
|
|
|
|
pLevel->p2 = 1 + sqlite3VdbeAddOp(v, OP_Rewind, iCur, brk);
|
|
|
|
pLevel->p2 = 1 + sqlite3VdbeAddOp(v, OP_Rewind, iCur, brk);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
notReady &= ~getMask(&tqmaskSet, iCur);
|
|
|
|
notReady &= ~getMask(&maskSet, iCur);
|
|
|
|
|
|
|
|
|
|
|
|
/* Insert code to test every subexpression that can be completely
|
|
|
|
/* Insert code to test every subexpression that can be completely
|
|
|
|
** computed using the current set of tables.
|
|
|
|
** computed using the current set of tables.
|
|
|
@ -67305,7 +67305,7 @@ static int createCollation(
|
|
|
|
|
|
|
|
|
|
|
|
/* If collation sequence pColl was created directly by a call to
|
|
|
|
/* If collation sequence pColl was created directly by a call to
|
|
|
|
** sqlite3_create_collation, and not generated by synthCollSeq(),
|
|
|
|
** sqlite3_create_collation, and not generated by synthCollSeq(),
|
|
|
|
** then any copies made by synthCollSeq() need to be tqinvalidated.
|
|
|
|
** then any copies made by synthCollSeq() need to be invalidated.
|
|
|
|
** Also, collation destructor - CollSeq.xDel() - function may need
|
|
|
|
** Also, collation destructor - CollSeq.xDel() - function may need
|
|
|
|
** to be called.
|
|
|
|
** to be called.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|