1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 06:08:38 -04:00

Update SQLite to 3.37.2

This commit is contained in:
Kenichi Ishigaki 2022-01-07 05:48:22 +09:00
parent 1bfcf7c38e
commit 30a08cebd1
3 changed files with 86 additions and 42 deletions

View file

@ -1073,7 +1073,7 @@ are limited by the typeless nature of the SQLite database.
=head1 SQLITE VERSION =head1 SQLITE VERSION
DBD::SQLite is usually compiled with a bundled SQLite library DBD::SQLite is usually compiled with a bundled SQLite library
(SQLite version S<3.37.0> as of this release) for consistency. (SQLite version S<3.37.2> as of this release) for consistency.
However, a different version of SQLite may sometimes be used for However, a different version of SQLite may sometimes be used for
some reasons like security, or some new experimental features. some reasons like security, or some new experimental features.

120
sqlite3.c
View file

@ -1,6 +1,6 @@
/****************************************************************************** /******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite ** This file is an amalgamation of many separate C source files from SQLite
** version 3.37.0. By combining all the individual C code files into this ** version 3.37.2. By combining all the individual C code files into this
** single large file, the entire code can be compiled as a single translation ** single large file, the entire code can be compiled as a single translation
** unit. This allows many compilers to do optimizations that would not be ** unit. This allows many compilers to do optimizations that would not be
** possible if the files were compiled separately. Performance improvements ** possible if the files were compiled separately. Performance improvements
@ -452,9 +452,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()]. ** [sqlite_version()] and [sqlite_source_id()].
*/ */
#define SQLITE_VERSION "3.37.0" #define SQLITE_VERSION "3.37.2"
#define SQLITE_VERSION_NUMBER 3037000 #define SQLITE_VERSION_NUMBER 3037002
#define SQLITE_SOURCE_ID "2021-11-27 14:13:22 bd41822c7424d393a30e92ff6cb254d25c26769889c1499a18a0b9339f5d6c8a" #define SQLITE_SOURCE_ID "2022-01-06 13:25:41 872ba256cbf61d9290b571c0e6d82a20c224ca3ad82971edc46b29818d5d17a0"
/* /*
** CAPI3REF: Run-Time Library Version Numbers ** CAPI3REF: Run-Time Library Version Numbers
@ -18503,6 +18503,8 @@ struct Parse {
AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */ AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
Parse *pToplevel; /* Parse structure for main program (or NULL) */ Parse *pToplevel; /* Parse structure for main program (or NULL) */
Table *pTriggerTab; /* Table triggers are being coded for */ Table *pTriggerTab; /* Table triggers are being coded for */
TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
ParseCleanup *pCleanup; /* List of cleanup operations to run after parse */
union { union {
int addrCrTab; /* Address of OP_CreateBtree on CREATE TABLE */ int addrCrTab; /* Address of OP_CreateBtree on CREATE TABLE */
Returning *pReturning; /* The RETURNING clause */ Returning *pReturning; /* The RETURNING clause */
@ -18557,9 +18559,7 @@ struct Parse {
Token sArg; /* Complete text of a module argument */ Token sArg; /* Complete text of a module argument */
Table **apVtabLock; /* Pointer to virtual tables needing locking */ Table **apVtabLock; /* Pointer to virtual tables needing locking */
#endif #endif
TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
With *pWith; /* Current WITH clause, or NULL */ With *pWith; /* Current WITH clause, or NULL */
ParseCleanup *pCleanup; /* List of cleanup operations to run after parse */
#ifndef SQLITE_OMIT_ALTERTABLE #ifndef SQLITE_OMIT_ALTERTABLE
RenameToken *pRename; /* Tokens subject to renaming by ALTER TABLE */ RenameToken *pRename; /* Tokens subject to renaming by ALTER TABLE */
#endif #endif
@ -20093,6 +20093,7 @@ SQLITE_PRIVATE void sqlite3FkActions(Parse*, Table*, ExprList*, int, int*, int
SQLITE_PRIVATE int sqlite3FkRequired(Parse*, Table*, int*, int); SQLITE_PRIVATE int sqlite3FkRequired(Parse*, Table*, int*, int);
SQLITE_PRIVATE u32 sqlite3FkOldmask(Parse*, Table*); SQLITE_PRIVATE u32 sqlite3FkOldmask(Parse*, Table*);
SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *); SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
SQLITE_PRIVATE void sqlite3FkClearTriggerCache(sqlite3*,int);
#else #else
#define sqlite3FkActions(a,b,c,d,e,f) #define sqlite3FkActions(a,b,c,d,e,f)
#define sqlite3FkCheck(a,b,c,d,e,f) #define sqlite3FkCheck(a,b,c,d,e,f)
@ -20100,6 +20101,7 @@ SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
#define sqlite3FkOldmask(a,b) 0 #define sqlite3FkOldmask(a,b) 0
#define sqlite3FkRequired(a,b,c,d) 0 #define sqlite3FkRequired(a,b,c,d) 0
#define sqlite3FkReferences(a) 0 #define sqlite3FkReferences(a) 0
#define sqlite3FkClearTriggerCache(a,b)
#endif #endif
#ifndef SQLITE_OMIT_FOREIGN_KEY #ifndef SQLITE_OMIT_FOREIGN_KEY
SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*); SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*);
@ -56574,7 +56576,7 @@ static int pager_wait_on_lock(Pager *pPager, int locktype){
#if defined(SQLITE_DEBUG) #if defined(SQLITE_DEBUG)
static void assertTruncateConstraintCb(PgHdr *pPg){ static void assertTruncateConstraintCb(PgHdr *pPg){
assert( pPg->flags&PGHDR_DIRTY ); assert( pPg->flags&PGHDR_DIRTY );
assert( !subjRequiresPage(pPg) || pPg->pgno<=pPg->pPager->dbSize ); assert( pPg->pgno<=pPg->pPager->dbSize || !subjRequiresPage(pPg) );
} }
static void assertTruncateConstraint(Pager *pPager){ static void assertTruncateConstraint(Pager *pPager){
sqlite3PcacheIterateDirty(pPager->pPCache, assertTruncateConstraintCb); sqlite3PcacheIterateDirty(pPager->pPCache, assertTruncateConstraintCb);
@ -57915,7 +57917,7 @@ SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager){
** may mean that the pager was in the error-state when this ** may mean that the pager was in the error-state when this
** function was called and the journal file does not exist. ** function was called and the journal file does not exist.
*/ */
if( !isOpen(pPager->jfd) ){ if( !isOpen(pPager->jfd) && pPager->journalMode!=PAGER_JOURNALMODE_OFF ){
sqlite3_vfs * const pVfs = pPager->pVfs; sqlite3_vfs * const pVfs = pPager->pVfs;
int bExists; /* True if journal file exists */ int bExists; /* True if journal file exists */
rc = sqlite3OsAccess( rc = sqlite3OsAccess(
@ -66818,7 +66820,7 @@ static void btreeParseCellPtr(
pInfo->nPayload = nPayload; pInfo->nPayload = nPayload;
pInfo->pPayload = pIter; pInfo->pPayload = pIter;
testcase( nPayload==pPage->maxLocal ); testcase( nPayload==pPage->maxLocal );
testcase( nPayload==pPage->maxLocal+1 ); testcase( nPayload==(u32)pPage->maxLocal+1 );
if( nPayload<=pPage->maxLocal ){ if( nPayload<=pPage->maxLocal ){
/* This is the (easy) common case where the entire payload fits /* This is the (easy) common case where the entire payload fits
** on the local page. No overflow is required. ** on the local page. No overflow is required.
@ -66855,7 +66857,7 @@ static void btreeParseCellPtrIndex(
pInfo->nPayload = nPayload; pInfo->nPayload = nPayload;
pInfo->pPayload = pIter; pInfo->pPayload = pIter;
testcase( nPayload==pPage->maxLocal ); testcase( nPayload==pPage->maxLocal );
testcase( nPayload==pPage->maxLocal+1 ); testcase( nPayload==(u32)pPage->maxLocal+1 );
if( nPayload<=pPage->maxLocal ){ if( nPayload<=pPage->maxLocal ){
/* This is the (easy) common case where the entire payload fits /* This is the (easy) common case where the entire payload fits
** on the local page. No overflow is required. ** on the local page. No overflow is required.
@ -66918,7 +66920,7 @@ static u16 cellSizePtr(MemPage *pPage, u8 *pCell){
while( (*pIter++)&0x80 && pIter<pEnd ); while( (*pIter++)&0x80 && pIter<pEnd );
} }
testcase( nSize==pPage->maxLocal ); testcase( nSize==pPage->maxLocal );
testcase( nSize==pPage->maxLocal+1 ); testcase( nSize==(u32)pPage->maxLocal+1 );
if( nSize<=pPage->maxLocal ){ if( nSize<=pPage->maxLocal ){
nSize += (u32)(pIter - pCell); nSize += (u32)(pIter - pCell);
if( nSize<4 ) nSize = 4; if( nSize<4 ) nSize = 4;
@ -66926,7 +66928,7 @@ static u16 cellSizePtr(MemPage *pPage, u8 *pCell){
int minLocal = pPage->minLocal; int minLocal = pPage->minLocal;
nSize = minLocal + (nSize - minLocal) % (pPage->pBt->usableSize - 4); nSize = minLocal + (nSize - minLocal) % (pPage->pBt->usableSize - 4);
testcase( nSize==pPage->maxLocal ); testcase( nSize==pPage->maxLocal );
testcase( nSize==pPage->maxLocal+1 ); testcase( nSize==(u32)pPage->maxLocal+1 );
if( nSize>pPage->maxLocal ){ if( nSize>pPage->maxLocal ){
nSize = minLocal; nSize = minLocal;
} }
@ -69817,7 +69819,7 @@ static void btreeSetNPage(BtShared *pBt, MemPage *pPage1){
int nPage = get4byte(&pPage1->aData[28]); int nPage = get4byte(&pPage1->aData[28]);
testcase( nPage==0 ); testcase( nPage==0 );
if( nPage==0 ) sqlite3PagerPagecount(pBt->pPager, &nPage); if( nPage==0 ) sqlite3PagerPagecount(pBt->pPager, &nPage);
testcase( pBt->nPage!=nPage ); testcase( pBt->nPage!=(u32)nPage );
pBt->nPage = nPage; pBt->nPage = nPage;
} }
@ -72382,16 +72384,18 @@ static void dropCell(MemPage *pPage, int idx, int sz, int *pRC){
int hdr; /* Beginning of the header. 0 most pages. 100 page 1 */ int hdr; /* Beginning of the header. 0 most pages. 100 page 1 */
if( *pRC ) return; if( *pRC ) return;
assert( idx>=0 && idx<pPage->nCell ); assert( idx>=0 );
assert( idx<pPage->nCell );
assert( CORRUPT_DB || sz==cellSize(pPage, idx) ); assert( CORRUPT_DB || sz==cellSize(pPage, idx) );
assert( sqlite3PagerIswriteable(pPage->pDbPage) ); assert( sqlite3PagerIswriteable(pPage->pDbPage) );
assert( sqlite3_mutex_held(pPage->pBt->mutex) ); assert( sqlite3_mutex_held(pPage->pBt->mutex) );
assert( pPage->nFree>=0 ); assert( pPage->nFree>=0 );
data = pPage->aData; data = pPage->aData;
ptr = &pPage->aCellIdx[2*idx]; ptr = &pPage->aCellIdx[2*idx];
assert( pPage->pBt->usableSize > (int)(ptr-data) );
pc = get2byte(ptr); pc = get2byte(ptr);
hdr = pPage->hdrOffset; hdr = pPage->hdrOffset;
testcase( pc==get2byte(&data[hdr+5]) ); testcase( pc==(u32)get2byte(&data[hdr+5]) );
testcase( pc+sz==pPage->pBt->usableSize ); testcase( pc+sz==pPage->pBt->usableSize );
if( pc+sz > pPage->pBt->usableSize ){ if( pc+sz > pPage->pBt->usableSize ){
*pRC = SQLITE_CORRUPT_BKPT; *pRC = SQLITE_CORRUPT_BKPT;
@ -72683,7 +72687,7 @@ static int rebuildPage(
assert( i<iEnd ); assert( i<iEnd );
j = get2byte(&aData[hdr+5]); j = get2byte(&aData[hdr+5]);
if( NEVER(j>(u32)usableSize) ){ j = 0; } if( j>(u32)usableSize ){ j = 0; }
memcpy(&pTmp[j], &aData[j], usableSize - j); memcpy(&pTmp[j], &aData[j], usableSize - j);
for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){} for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
@ -72914,7 +72918,7 @@ static int editPage(
pData = &aData[get2byteNotZero(&aData[hdr+5])]; pData = &aData[get2byteNotZero(&aData[hdr+5])];
if( pData<pBegin ) goto editpage_fail; if( pData<pBegin ) goto editpage_fail;
if( NEVER(pData>pPg->aDataEnd) ) goto editpage_fail; if( pData>pPg->aDataEnd ) goto editpage_fail;
/* Add cells to the start of the page */ /* Add cells to the start of the page */
if( iNew<iOld ){ if( iNew<iOld ){
@ -74817,7 +74821,12 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
iCellIdx = pCur->ix; iCellIdx = pCur->ix;
pPage = pCur->pPage; pPage = pCur->pPage;
pCell = findCell(pPage, iCellIdx); pCell = findCell(pPage, iCellIdx);
if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ) return SQLITE_CORRUPT; if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ){
return SQLITE_CORRUPT_BKPT;
}
if( pPage->nCell<=iCellIdx ){
return SQLITE_CORRUPT_BKPT;
}
/* If the bPreserve flag is set to true, then the cursor position must /* If the bPreserve flag is set to true, then the cursor position must
** be preserved following this delete operation. If the current delete ** be preserved following this delete operation. If the current delete
@ -84101,7 +84110,7 @@ SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 *rowid){
/* The index entry must begin with a header size */ /* The index entry must begin with a header size */
getVarint32NR((u8*)m.z, szHdr); getVarint32NR((u8*)m.z, szHdr);
testcase( szHdr==3 ); testcase( szHdr==3 );
testcase( szHdr==m.n ); testcase( szHdr==(u32)m.n );
testcase( szHdr>0x7fffffff ); testcase( szHdr>0x7fffffff );
assert( m.n>=0 ); assert( m.n>=0 );
if( unlikely(szHdr<3 || szHdr>(unsigned)m.n) ){ if( unlikely(szHdr<3 || szHdr>(unsigned)m.n) ){
@ -90511,6 +90520,7 @@ case OP_SetCookie: {
/* When the schema cookie changes, record the new cookie internally */ /* When the schema cookie changes, record the new cookie internally */
pDb->pSchema->schema_cookie = pOp->p3 - pOp->p5; pDb->pSchema->schema_cookie = pOp->p3 - pOp->p5;
db->mDbFlags |= DBFLAG_SchemaChange; db->mDbFlags |= DBFLAG_SchemaChange;
sqlite3FkClearTriggerCache(db, pOp->p1);
}else if( pOp->p2==BTREE_FILE_FORMAT ){ }else if( pOp->p2==BTREE_FILE_FORMAT ){
/* Record changes in the file format */ /* Record changes in the file format */
pDb->pSchema->file_format = pOp->p3; pDb->pSchema->file_format = pOp->p3;
@ -99143,7 +99153,7 @@ static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){
p->pFirst = 0; p->pFirst = 0;
}else{ }else{
i64 iOff = p->nChunkSize; i64 iOff = p->nChunkSize;
for(pIter=p->pFirst; ALWAYS(pIter) && iOff<=size; pIter=pIter->pNext){ for(pIter=p->pFirst; ALWAYS(pIter) && iOff<size; pIter=pIter->pNext){
iOff += p->nChunkSize; iOff += p->nChunkSize;
} }
if( ALWAYS(pIter) ){ if( ALWAYS(pIter) ){
@ -104085,7 +104095,7 @@ SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){
return ExprHasProperty(p, EP_CanBeNull) || return ExprHasProperty(p, EP_CanBeNull) ||
p->y.pTab==0 || /* Reference to column of index on expression */ p->y.pTab==0 || /* Reference to column of index on expression */
(p->iColumn>=0 (p->iColumn>=0
&& ALWAYS(p->y.pTab->aCol!=0) /* Defense against OOM problems */ && p->y.pTab->aCol!=0 /* Possible due to prior error */
&& p->y.pTab->aCol[p->iColumn].notNull==0); && p->y.pTab->aCol[p->iColumn].notNull==0);
default: default:
return 1; return 1;
@ -123234,6 +123244,25 @@ static void fkTriggerDelete(sqlite3 *dbMem, Trigger *p){
} }
} }
/*
** Clear the apTrigger[] cache of CASCADE triggers for all foreign keys
** in a particular database. This needs to happen when the schema
** changes.
*/
SQLITE_PRIVATE void sqlite3FkClearTriggerCache(sqlite3 *db, int iDb){
HashElem *k;
Hash *pHash = &db->aDb[iDb].pSchema->tblHash;
for(k=sqliteHashFirst(pHash); k; k=sqliteHashNext(k)){
Table *pTab = sqliteHashData(k);
FKey *pFKey;
if( !IsOrdinaryTable(pTab) ) continue;
for(pFKey=pTab->u.tab.pFKey; pFKey; pFKey=pFKey->pNextFrom){
fkTriggerDelete(db, pFKey->apTrigger[0]); pFKey->apTrigger[0] = 0;
fkTriggerDelete(db, pFKey->apTrigger[1]); pFKey->apTrigger[1] = 0;
}
}
}
/* /*
** This function is called to generate code that runs when table pTab is ** This function is called to generate code that runs when table pTab is
** being dropped from the database. The SrcList passed as the second argument ** being dropped from the database. The SrcList passed as the second argument
@ -124034,7 +124063,7 @@ SQLITE_PRIVATE void sqlite3OpenTable(
}else{ }else{
Index *pPk = sqlite3PrimaryKeyIndex(pTab); Index *pPk = sqlite3PrimaryKeyIndex(pTab);
assert( pPk!=0 ); assert( pPk!=0 );
assert( pPk->tnum==pTab->tnum ); assert( pPk->tnum==pTab->tnum || CORRUPT_DB );
sqlite3VdbeAddOp3(v, opcode, iCur, pPk->tnum, iDb); sqlite3VdbeAddOp3(v, opcode, iCur, pPk->tnum, iDb);
sqlite3VdbeSetP4KeyInfo(pParse, pPk); sqlite3VdbeSetP4KeyInfo(pParse, pPk);
VdbeComment((v, "%s", pTab->zName)); VdbeComment((v, "%s", pTab->zName));
@ -126000,6 +126029,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
if( onError==OE_Replace /* IPK rule is REPLACE */ if( onError==OE_Replace /* IPK rule is REPLACE */
&& onError!=overrideError /* Rules for other constraints are different */ && onError!=overrideError /* Rules for other constraints are different */
&& pTab->pIndex /* There exist other constraints */ && pTab->pIndex /* There exist other constraints */
&& !upsertIpkDelay /* IPK check already deferred by UPSERT */
){ ){
ipkTop = sqlite3VdbeAddOp0(v, OP_Goto)+1; ipkTop = sqlite3VdbeAddOp0(v, OP_Goto)+1;
VdbeComment((v, "defer IPK REPLACE until last")); VdbeComment((v, "defer IPK REPLACE until last"));
@ -126408,6 +126438,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
if( ipkTop ){ if( ipkTop ){
sqlite3VdbeGoto(v, ipkTop); sqlite3VdbeGoto(v, ipkTop);
VdbeComment((v, "Do IPK REPLACE")); VdbeComment((v, "Do IPK REPLACE"));
assert( ipkBottom>0 );
sqlite3VdbeJumpHere(v, ipkBottom); sqlite3VdbeJumpHere(v, ipkBottom);
} }
@ -126538,7 +126569,6 @@ SQLITE_PRIVATE void sqlite3CompleteInsertion(
} }
pik_flags = (useSeekResult ? OPFLAG_USESEEKRESULT : 0); pik_flags = (useSeekResult ? OPFLAG_USESEEKRESULT : 0);
if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){ if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
assert( pParse->nested==0 );
pik_flags |= OPFLAG_NCHANGE; pik_flags |= OPFLAG_NCHANGE;
pik_flags |= (update_flags & OPFLAG_SAVEPOSITION); pik_flags |= (update_flags & OPFLAG_SAVEPOSITION);
if( update_flags==0 ){ if( update_flags==0 ){
@ -132944,7 +132974,7 @@ static int sqlite3Prepare(
sParse.checkSchema = 0; sParse.checkSchema = 0;
} }
if( sParse.rc!=SQLITE_OK && sParse.rc!=SQLITE_DONE ){ if( sParse.rc!=SQLITE_OK && sParse.rc!=SQLITE_DONE ){
if( sParse.checkSchema ){ if( sParse.checkSchema && db->init.busy==0 ){
schemaIsValid(&sParse); schemaIsValid(&sParse);
} }
if( sParse.pVdbe ){ if( sParse.pVdbe ){
@ -133005,6 +133035,7 @@ static int sqlite3LockAndPrepare(
** reset is considered a permanent error. */ ** reset is considered a permanent error. */
rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail); rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
assert( rc==SQLITE_OK || *ppStmt==0 ); assert( rc==SQLITE_OK || *ppStmt==0 );
if( rc==SQLITE_OK || db->mallocFailed ) break;
}while( rc==SQLITE_ERROR_RETRY }while( rc==SQLITE_ERROR_RETRY
|| (rc==SQLITE_SCHEMA && (sqlite3ResetOneSchema(db,-1), cnt++)==0) ); || (rc==SQLITE_SCHEMA && (sqlite3ResetOneSchema(db,-1), cnt++)==0) );
sqlite3BtreeLeaveAll(db); sqlite3BtreeLeaveAll(db);
@ -141886,7 +141917,7 @@ static void codeReturningTrigger(
} }
sqlite3ExprListDelete(db, sSelect.pEList); sqlite3ExprListDelete(db, sSelect.pEList);
pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab); pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab);
if( pNew ){ if( !db->mallocFailed ){
NameContext sNC; NameContext sNC;
memset(&sNC, 0, sizeof(sNC)); memset(&sNC, 0, sizeof(sNC));
if( pReturning->nRetCol==0 ){ if( pReturning->nRetCol==0 ){
@ -141898,7 +141929,9 @@ static void codeReturningTrigger(
sNC.ncFlags = NC_UBaseReg; sNC.ncFlags = NC_UBaseReg;
pParse->eTriggerOp = pTrigger->op; pParse->eTriggerOp = pTrigger->op;
pParse->pTriggerTab = pTab; pParse->pTriggerTab = pTab;
if( sqlite3ResolveExprListNames(&sNC, pNew)==SQLITE_OK ){ if( sqlite3ResolveExprListNames(&sNC, pNew)==SQLITE_OK
&& !db->mallocFailed
){
int i; int i;
int nCol = pNew->nExpr; int nCol = pNew->nExpr;
int reg = pParse->nMem+1; int reg = pParse->nMem+1;
@ -141906,16 +141939,17 @@ static void codeReturningTrigger(
pReturning->iRetReg = reg; pReturning->iRetReg = reg;
for(i=0; i<nCol; i++){ for(i=0; i<nCol; i++){
Expr *pCol = pNew->a[i].pExpr; Expr *pCol = pNew->a[i].pExpr;
assert( pCol!=0 ); /* Due to !db->mallocFailed ~9 lines above */
sqlite3ExprCodeFactorable(pParse, pCol, reg+i); sqlite3ExprCodeFactorable(pParse, pCol, reg+i);
} }
sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, i, reg+i); sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, i, reg+i);
sqlite3VdbeAddOp2(v, OP_NewRowid, pReturning->iRetCur, reg+i+1); sqlite3VdbeAddOp2(v, OP_NewRowid, pReturning->iRetCur, reg+i+1);
sqlite3VdbeAddOp3(v, OP_Insert, pReturning->iRetCur, reg+i, reg+i+1); sqlite3VdbeAddOp3(v, OP_Insert, pReturning->iRetCur, reg+i, reg+i+1);
} }
sqlite3ExprListDelete(db, pNew);
pParse->eTriggerOp = 0;
pParse->pTriggerTab = 0;
} }
sqlite3ExprListDelete(db, pNew);
pParse->eTriggerOp = 0;
pParse->pTriggerTab = 0;
} }
@ -169411,6 +169445,8 @@ SQLITE_API int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
if( newLimit>=0 ){ /* IMP: R-52476-28732 */ if( newLimit>=0 ){ /* IMP: R-52476-28732 */
if( newLimit>aHardLimit[limitId] ){ if( newLimit>aHardLimit[limitId] ){
newLimit = aHardLimit[limitId]; /* IMP: R-51463-25634 */ newLimit = aHardLimit[limitId]; /* IMP: R-51463-25634 */
}else if( newLimit<1 && limitId==SQLITE_LIMIT_LENGTH ){
newLimit = 1;
} }
db->aLimit[limitId] = newLimit; db->aLimit[limitId] = newLimit;
} }
@ -170814,12 +170850,16 @@ SQLITE_API int sqlite3_test_control(int op, ...){
*/ */
case SQLITE_TESTCTRL_IMPOSTER: { case SQLITE_TESTCTRL_IMPOSTER: {
sqlite3 *db = va_arg(ap, sqlite3*); sqlite3 *db = va_arg(ap, sqlite3*);
int iDb;
sqlite3_mutex_enter(db->mutex); sqlite3_mutex_enter(db->mutex);
db->init.iDb = sqlite3FindDbName(db, va_arg(ap,const char*)); iDb = sqlite3FindDbName(db, va_arg(ap,const char*));
db->init.busy = db->init.imposterTable = va_arg(ap,int); if( iDb>=0 ){
db->init.newTnum = va_arg(ap,int); db->init.iDb = iDb;
if( db->init.busy==0 && db->init.newTnum>0 ){ db->init.busy = db->init.imposterTable = va_arg(ap,int);
sqlite3ResetAllSchemasOfConnection(db); db->init.newTnum = va_arg(ap,int);
if( db->init.busy==0 && db->init.newTnum>0 ){
sqlite3ResetAllSchemasOfConnection(db);
}
} }
sqlite3_mutex_leave(db->mutex); sqlite3_mutex_leave(db->mutex);
break; break;
@ -177073,7 +177113,7 @@ SQLITE_PRIVATE void sqlite3Fts3DoclistPrev(
assert( nDoclist>0 ); assert( nDoclist>0 );
assert( *pbEof==0 ); assert( *pbEof==0 );
assert( p || *piDocid==0 ); assert_fts3_nc( p || *piDocid==0 );
assert( !p || (p>aDoclist && p<&aDoclist[nDoclist]) ); assert( !p || (p>aDoclist && p<&aDoclist[nDoclist]) );
if( p==0 ){ if( p==0 ){
@ -224759,8 +224799,12 @@ static void fts5SegIterReverseNewPage(Fts5Index *p, Fts5SegIter *pIter){
int iRowidOff; int iRowidOff;
iRowidOff = fts5LeafFirstRowidOff(pNew); iRowidOff = fts5LeafFirstRowidOff(pNew);
if( iRowidOff ){ if( iRowidOff ){
pIter->pLeaf = pNew; if( iRowidOff>=pNew->szLeaf ){
pIter->iLeafOffset = iRowidOff; p->rc = FTS5_CORRUPT;
}else{
pIter->pLeaf = pNew;
pIter->iLeafOffset = iRowidOff;
}
} }
} }
@ -232489,7 +232533,7 @@ static void fts5SourceIdFunc(
){ ){
assert( nArg==0 ); assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused); UNUSED_PARAM2(nArg, apUnused);
sqlite3_result_text(pCtx, "fts5: 2021-11-27 14:13:22 bd41822c7424d393a30e92ff6cb254d25c26769889c1499a18a0b9339f5d6c8a", -1, SQLITE_TRANSIENT); sqlite3_result_text(pCtx, "fts5: 2022-01-06 13:25:41 872ba256cbf61d9290b571c0e6d82a20c224ca3ad82971edc46b29818d5d17a0", -1, SQLITE_TRANSIENT);
} }
/* /*

View file

@ -146,9 +146,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()]. ** [sqlite_version()] and [sqlite_source_id()].
*/ */
#define SQLITE_VERSION "3.37.0" #define SQLITE_VERSION "3.37.2"
#define SQLITE_VERSION_NUMBER 3037000 #define SQLITE_VERSION_NUMBER 3037002
#define SQLITE_SOURCE_ID "2021-11-27 14:13:22 bd41822c7424d393a30e92ff6cb254d25c26769889c1499a18a0b9339f5d6c8a" #define SQLITE_SOURCE_ID "2022-01-06 13:25:41 872ba256cbf61d9290b571c0e6d82a20c224ca3ad82971edc46b29818d5d17a0"
/* /*
** CAPI3REF: Run-Time Library Version Numbers ** CAPI3REF: Run-Time Library Version Numbers