Skip to content

Commit ed8f995

Browse files
committed
Snapshot of upstream SQLite 3.32.3
1 parent c6a9d85 commit ed8f995

24 files changed

+741
-1959
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.32.2
1+
3.32.3

configure

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
22
# Guess values for system-dependent variables and create Makefiles.
3-
# Generated by GNU Autoconf 2.69 for sqlite 3.32.2.
3+
# Generated by GNU Autoconf 2.69 for sqlite 3.32.3.
44
#
55
#
66
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -726,8 +726,8 @@ MAKEFLAGS=
726726
# Identity of this package.
727727
PACKAGE_NAME='sqlite'
728728
PACKAGE_TARNAME='sqlite'
729-
PACKAGE_VERSION='3.32.2'
730-
PACKAGE_STRING='sqlite 3.32.2'
729+
PACKAGE_VERSION='3.32.3'
730+
PACKAGE_STRING='sqlite 3.32.3'
731731
PACKAGE_BUGREPORT=''
732732
PACKAGE_URL=''
733733

@@ -1467,7 +1467,7 @@ if test "$ac_init_help" = "long"; then
14671467
# Omit some internal or obsolete options to make the list less imposing.
14681468
# This message is too long to be a string in the A/UX 3.1 sh.
14691469
cat <<_ACEOF
1470-
\`configure' configures sqlite 3.32.2 to adapt to many kinds of systems.
1470+
\`configure' configures sqlite 3.32.3 to adapt to many kinds of systems.
14711471
14721472
Usage: $0 [OPTION]... [VAR=VALUE]...
14731473
@@ -1532,7 +1532,7 @@ fi
15321532

15331533
if test -n "$ac_init_help"; then
15341534
case $ac_init_help in
1535-
short | recursive ) echo "Configuration of sqlite 3.32.2:";;
1535+
short | recursive ) echo "Configuration of sqlite 3.32.3:";;
15361536
esac
15371537
cat <<\_ACEOF
15381538
@@ -1659,7 +1659,7 @@ fi
16591659
test -n "$ac_init_help" && exit $ac_status
16601660
if $ac_init_version; then
16611661
cat <<\_ACEOF
1662-
sqlite configure 3.32.2
1662+
sqlite configure 3.32.3
16631663
generated by GNU Autoconf 2.69
16641664
16651665
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2078,7 +2078,7 @@ cat >config.log <<_ACEOF
20782078
This file contains any messages produced by compilers while
20792079
running configure, to aid debugging if configure makes a mistake.
20802080
2081-
It was created by sqlite $as_me 3.32.2, which was
2081+
It was created by sqlite $as_me 3.32.3, which was
20822082
generated by GNU Autoconf 2.69. Invocation command line was
20832083
20842084
$ $0 $@
@@ -12243,7 +12243,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
1224312243
# report actual input values of CONFIG_FILES etc. instead of their
1224412244
# values after options handling.
1224512245
ac_log="
12246-
This file was extended by sqlite $as_me 3.32.2, which was
12246+
This file was extended by sqlite $as_me 3.32.3, which was
1224712247
generated by GNU Autoconf 2.69. Invocation command line was
1224812248
1224912249
CONFIG_FILES = $CONFIG_FILES
@@ -12309,7 +12309,7 @@ _ACEOF
1230912309
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
1231012310
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
1231112311
ac_cs_version="\\
12312-
sqlite config.status 3.32.2
12312+
sqlite config.status 3.32.3
1231312313
configured by $0, generated by GNU Autoconf 2.69,
1231412314
with options \\"\$ac_cs_config\\"
1231512315

ext/fts3/fts3.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,6 +2267,9 @@ static int fts3PoslistMerge(
22672267
*/
22682268
fts3GetDeltaVarint(&p1, &i1);
22692269
fts3GetDeltaVarint(&p2, &i2);
2270+
if( i1<2 || i2<2 ){
2271+
break;
2272+
}
22702273
do {
22712274
fts3PutDeltaVarint(&p, &iPrev, (i1<i2) ? i1 : i2);
22722275
iPrev -= 2;
@@ -2335,7 +2338,7 @@ static int fts3PoslistPhraseMerge(
23352338
/* Never set both isSaveLeft and isExact for the same invocation. */
23362339
assert( isSaveLeft==0 || isExact==0 );
23372340

2338-
assert( p!=0 && *p1!=0 && *p2!=0 );
2341+
assert_fts3_nc( p!=0 && *p1!=0 && *p2!=0 );
23392342
if( *p1==POS_COLUMN ){
23402343
p1++;
23412344
p1 += fts3GetVarint32(p1, &iCol1);
@@ -4520,7 +4523,7 @@ void sqlite3Fts3DoclistNext(
45204523

45214524
assert( nDoclist>0 );
45224525
assert( *pbEof==0 );
4523-
assert( p || *piDocid==0 );
4526+
assert_fts3_nc( p || *piDocid==0 );
45244527
assert( !p || (p>=aDoclist && p<=&aDoclist[nDoclist]) );
45254528

45264529
if( p==0 ){
@@ -5170,7 +5173,7 @@ static void fts3EvalInvalidatePoslist(Fts3Phrase *pPhrase){
51705173
**
51715174
** Parameter nNear is passed the NEAR distance of the expression (5 in
51725175
** the example above). When this function is called, *paPoslist points to
5173-
** the position list, and *pnToken is the number of phrase tokens in, the
5176+
** the position list, and *pnToken is the number of phrase tokens in the
51745177
** phrase on the other side of the NEAR operator to pPhrase. For example,
51755178
** if pPhrase refers to the "def ghi" phrase, then *paPoslist points to
51765179
** the position list associated with phrase "abc".

manifest

Lines changed: 22 additions & 1872 deletions
Large diffs are not rendered by default.

manifest.uuid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ec02243ea6ce33b090870ae55ab8aa2534b54d216d45c4aa2fdbb00e86861e8c
1+
7ebdfa80be8e8e73324b8d66b3460222eb74c7e9dfd655b48d6ca7e1933cc8fd

src/btree.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,18 @@ static int hasSharedCacheTableLock(
200200
** table. */
201201
if( isIndex ){
202202
HashElem *p;
203+
int bSeen = 0;
203204
for(p=sqliteHashFirst(&pSchema->idxHash); p; p=sqliteHashNext(p)){
204205
Index *pIdx = (Index *)sqliteHashData(p);
205206
if( pIdx->tnum==(int)iRoot ){
206-
if( iTab ){
207+
if( bSeen ){
207208
/* Two or more indexes share the same root page. There must
208209
** be imposter tables. So just return true. The assert is not
209210
** useful in that case. */
210211
return 1;
211212
}
212213
iTab = pIdx->pTable->tnum;
214+
bSeen = 1;
213215
}
214216
}
215217
}else{
@@ -1751,7 +1753,7 @@ static int freeSpace(MemPage *pPage, u16 iStart, u16 iSize){
17511753
nFrag = iFreeBlk - iEnd;
17521754
if( iEnd>iFreeBlk ) return SQLITE_CORRUPT_PAGE(pPage);
17531755
iEnd = iFreeBlk + get2byte(&data[iFreeBlk+2]);
1754-
if( NEVER(iEnd > pPage->pBt->usableSize) ){
1756+
if( iEnd > pPage->pBt->usableSize ){
17551757
return SQLITE_CORRUPT_PAGE(pPage);
17561758
}
17571759
iSize = iEnd - iStart;

src/build.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,21 @@ void sqlite3FinishCoding(Parse *pParse){
207207
*/
208208
sqlite3AutoincrementBegin(pParse);
209209

210-
/* Code constant expressions that where factored out of inner loops */
210+
/* Code constant expressions that where factored out of inner loops.
211+
**
212+
** The pConstExpr list might also contain expressions that we simply
213+
** want to keep around until the Parse object is deleted. Such
214+
** expressions have iConstExprReg==0. Do not generate code for
215+
** those expressions, of course.
216+
*/
211217
if( pParse->pConstExpr ){
212218
ExprList *pEL = pParse->pConstExpr;
213219
pParse->okConstFactor = 0;
214220
for(i=0; i<pEL->nExpr; i++){
215-
sqlite3ExprCode(pParse, pEL->a[i].pExpr, pEL->a[i].u.iConstExprReg);
221+
int iReg = pEL->a[i].u.iConstExprReg;
222+
if( iReg>0 ){
223+
sqlite3ExprCode(pParse, pEL->a[i].pExpr, iReg);
224+
}
216225
}
217226
}
218227

src/expr.c

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ char sqlite3ExprAffinity(const Expr *pExpr){
5252
op = pExpr->op;
5353
if( op==TK_SELECT ){
5454
assert( pExpr->flags&EP_xIsSelect );
55-
return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);
55+
if( ALWAYS(pExpr->x.pSelect)
56+
&& pExpr->x.pSelect->pEList
57+
&& ALWAYS(pExpr->x.pSelect->pEList->a[0].pExpr)
58+
){
59+
return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);
60+
}
5661
}
5762
if( op==TK_REGISTER ) op = pExpr->op2;
5863
#ifndef SQLITE_OMIT_CAST
@@ -2043,8 +2048,10 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
20432048
/* Fall through */
20442049
case TK_IF_NULL_ROW:
20452050
case TK_REGISTER:
2051+
case TK_DOT:
20462052
testcase( pExpr->op==TK_REGISTER );
20472053
testcase( pExpr->op==TK_IF_NULL_ROW );
2054+
testcase( pExpr->op==TK_DOT );
20482055
pWalker->eCode = 0;
20492056
return WRC_Abort;
20502057
case TK_VARIABLE:
@@ -5650,10 +5657,25 @@ int sqlite3ExprCoveredByIndex(
56505657
*/
56515658
struct SrcCount {
56525659
SrcList *pSrc; /* One particular FROM clause in a nested query */
5660+
int iSrcInner; /* Smallest cursor number in this context */
56535661
int nThis; /* Number of references to columns in pSrcList */
56545662
int nOther; /* Number of references to columns in other FROM clauses */
56555663
};
56565664

5665+
/*
5666+
** xSelect callback for sqlite3FunctionUsesThisSrc(). If this is the first
5667+
** SELECT with a FROM clause encountered during this iteration, set
5668+
** SrcCount.iSrcInner to the cursor number of the leftmost object in
5669+
** the FROM cause.
5670+
*/
5671+
static int selectSrcCount(Walker *pWalker, Select *pSel){
5672+
struct SrcCount *p = pWalker->u.pSrcCount;
5673+
if( p->iSrcInner==0x7FFFFFFF && ALWAYS(pSel->pSrc) && pSel->pSrc->nSrc ){
5674+
pWalker->u.pSrcCount->iSrcInner = pSel->pSrc->a[0].iCursor;
5675+
}
5676+
return WRC_Continue;
5677+
}
5678+
56575679
/*
56585680
** Count the number of references to columns.
56595681
*/
@@ -5674,7 +5696,7 @@ static int exprSrcCount(Walker *pWalker, Expr *pExpr){
56745696
}
56755697
if( i<nSrc ){
56765698
p->nThis++;
5677-
}else if( nSrc==0 || pExpr->iTable<pSrc->a[0].iCursor ){
5699+
}else if( pExpr->iTable<p->iSrcInner ){
56785700
/* In a well-formed parse tree (no name resolution errors),
56795701
** TK_COLUMN nodes with smaller Expr.iTable values are in an
56805702
** outer context. Those are the only ones to count as "other" */
@@ -5696,9 +5718,10 @@ int sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrcList){
56965718
assert( pExpr->op==TK_AGG_FUNCTION );
56975719
memset(&w, 0, sizeof(w));
56985720
w.xExprCallback = exprSrcCount;
5699-
w.xSelectCallback = sqlite3SelectWalkNoop;
5721+
w.xSelectCallback = selectSrcCount;
57005722
w.u.pSrcCount = &cnt;
57015723
cnt.pSrc = pSrcList;
5724+
cnt.iSrcInner = (pSrcList&&pSrcList->nSrc)?pSrcList->a[0].iCursor:0x7FFFFFFF;
57025725
cnt.nThis = 0;
57035726
cnt.nOther = 0;
57045727
sqlite3WalkExprList(&w, pExpr->x.pList);
@@ -5710,6 +5733,64 @@ int sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrcList){
57105733
return cnt.nThis>0 || cnt.nOther==0;
57115734
}
57125735

5736+
/*
5737+
** This is a Walker expression node callback.
5738+
**
5739+
** For Expr nodes that contain pAggInfo pointers, make sure the AggInfo
5740+
** object that is referenced does not refer directly to the Expr. If
5741+
** it does, make a copy. This is done because the pExpr argument is
5742+
** subject to change.
5743+
**
5744+
** The copy is stored on pParse->pConstExpr with a register number of 0.
5745+
** This will cause the expression to be deleted automatically when the
5746+
** Parse object is destroyed, but the zero register number means that it
5747+
** will not generate any code in the preamble.
5748+
*/
5749+
static int agginfoPersistExprCb(Walker *pWalker, Expr *pExpr){
5750+
if( ALWAYS(!ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced))
5751+
&& pExpr->pAggInfo!=0
5752+
){
5753+
AggInfo *pAggInfo = pExpr->pAggInfo;
5754+
int iAgg = pExpr->iAgg;
5755+
Parse *pParse = pWalker->pParse;
5756+
sqlite3 *db = pParse->db;
5757+
assert( pExpr->op==TK_AGG_COLUMN || pExpr->op==TK_AGG_FUNCTION );
5758+
if( pExpr->op==TK_AGG_COLUMN ){
5759+
assert( iAgg>=0 && iAgg<pAggInfo->nColumn );
5760+
if( pAggInfo->aCol[iAgg].pExpr==pExpr ){
5761+
pExpr = sqlite3ExprDup(db, pExpr, 0);
5762+
if( pExpr ){
5763+
pAggInfo->aCol[iAgg].pExpr = pExpr;
5764+
pParse->pConstExpr =
5765+
sqlite3ExprListAppend(pParse, pParse->pConstExpr, pExpr);
5766+
}
5767+
}
5768+
}else{
5769+
assert( iAgg>=0 && iAgg<pAggInfo->nFunc );
5770+
if( pAggInfo->aFunc[iAgg].pExpr==pExpr ){
5771+
pExpr = sqlite3ExprDup(db, pExpr, 0);
5772+
if( pExpr ){
5773+
pAggInfo->aFunc[iAgg].pExpr = pExpr;
5774+
pParse->pConstExpr =
5775+
sqlite3ExprListAppend(pParse, pParse->pConstExpr, pExpr);
5776+
}
5777+
}
5778+
}
5779+
}
5780+
return WRC_Continue;
5781+
}
5782+
5783+
/*
5784+
** Initialize a Walker object so that will persist AggInfo entries referenced
5785+
** by the tree that is walked.
5786+
*/
5787+
void sqlite3AggInfoPersistWalkerInit(Walker *pWalker, Parse *pParse){
5788+
memset(pWalker, 0, sizeof(*pWalker));
5789+
pWalker->pParse = pParse;
5790+
pWalker->xExprCallback = agginfoPersistExprCb;
5791+
pWalker->xSelectCallback = sqlite3SelectWalkNoop;
5792+
}
5793+
57135794
/*
57145795
** Add a new element to the pAggInfo->aCol[] array. Return the index of
57155796
** the new element. Return a negative number if malloc fails.
@@ -5740,7 +5821,7 @@ static int addAggInfoFunc(sqlite3 *db, AggInfo *pInfo){
57405821
&i
57415822
);
57425823
return i;
5743-
}
5824+
}
57445825

57455826
/*
57465827
** This is the xExprCallback for a tree walker. It is used to

src/prepare.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,26 @@ int sqlite3SchemaToIndex(sqlite3 *db, Schema *pSchema){
529529
return i;
530530
}
531531

532+
/*
533+
** Deallocate a single AggInfo object
534+
*/
535+
static void agginfoFree(sqlite3 *db, AggInfo *p){
536+
sqlite3DbFree(db, p->aCol);
537+
sqlite3DbFree(db, p->aFunc);
538+
sqlite3DbFree(db, p);
539+
}
540+
532541
/*
533542
** Free all memory allocations in the pParse object
534543
*/
535544
void sqlite3ParserReset(Parse *pParse){
536545
sqlite3 *db = pParse->db;
546+
AggInfo *pThis = pParse->pAggList;
547+
while( pThis ){
548+
AggInfo *pNext = pThis->pNext;
549+
agginfoFree(db, pThis);
550+
pThis = pNext;
551+
}
537552
sqlite3DbFree(db, pParse->aLabel);
538553
sqlite3ExprListDelete(db, pParse->pConstExpr);
539554
if( db ){

0 commit comments

Comments
 (0)