| | @@ -452,11 +452,11 @@ |
| 452 | 452 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 453 | 453 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 454 | 454 | */ |
| 455 | 455 | #define SQLITE_VERSION "3.37.0" |
| 456 | 456 | #define SQLITE_VERSION_NUMBER 3037000 |
| 457 | | -#define SQLITE_SOURCE_ID "2021-11-15 19:10:13 bd66ab8a1bc3c43a57c7caff5f54545b0feb0177f1f51492f30d308c123c43ba" |
| 457 | +#define SQLITE_SOURCE_ID "2021-11-22 16:06:57 0f567b61072e214c40cae1441889f83622a975f429b41803dfbed687718731c8" |
| 458 | 458 | |
| 459 | 459 | /* |
| 460 | 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| 461 | 461 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 462 | 462 | ** |
| | @@ -18501,11 +18501,10 @@ |
| 18501 | 18501 | TableLock *aTableLock; /* Required table locks for shared-cache mode */ |
| 18502 | 18502 | #endif |
| 18503 | 18503 | AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */ |
| 18504 | 18504 | Parse *pToplevel; /* Parse structure for main program (or NULL) */ |
| 18505 | 18505 | Table *pTriggerTab; /* Table triggers are being coded for */ |
| 18506 | | - Parse *pParentParse; /* Parent parser if this parser is nested */ |
| 18507 | 18506 | union { |
| 18508 | 18507 | int addrCrTab; /* Address of OP_CreateBtree on CREATE TABLE */ |
| 18509 | 18508 | Returning *pReturning; /* The RETURNING clause */ |
| 18510 | 18509 | } u1; |
| 18511 | 18510 | u32 nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */ |
| | @@ -20059,11 +20058,11 @@ |
| 20059 | 20058 | #else |
| 20060 | 20059 | # define sqlite3CteNew(P,T,E,S) ((void*)0) |
| 20061 | 20060 | # define sqlite3CteDelete(D,C) |
| 20062 | 20061 | # define sqlite3CteWithAdd(P,W,C) ((void*)0) |
| 20063 | 20062 | # define sqlite3WithDelete(x,y) |
| 20064 | | -# define sqlite3WithPush(x,y,z) |
| 20063 | +# define sqlite3WithPush(x,y,z) ((void*)0) |
| 20065 | 20064 | #endif |
| 20066 | 20065 | #ifndef SQLITE_OMIT_UPSERT |
| 20067 | 20066 | SQLITE_PRIVATE Upsert *sqlite3UpsertNew(sqlite3*,ExprList*,Expr*,ExprList*,Expr*,Upsert*); |
| 20068 | 20067 | SQLITE_PRIVATE void sqlite3UpsertDelete(sqlite3*,Upsert*); |
| 20069 | 20068 | SQLITE_PRIVATE Upsert *sqlite3UpsertDup(sqlite3*,Upsert*); |
| | @@ -40030,40 +40029,50 @@ |
| 40030 | 40029 | OpenCounter(+1); |
| 40031 | 40030 | verifyDbFile(pNew); |
| 40032 | 40031 | } |
| 40033 | 40032 | return rc; |
| 40034 | 40033 | } |
| 40034 | + |
| 40035 | +/* |
| 40036 | +** Directories to consider for temp files. |
| 40037 | +*/ |
| 40038 | +static const char *azTempDirs[] = { |
| 40039 | + 0, |
| 40040 | + 0, |
| 40041 | + "/var/tmp", |
| 40042 | + "/usr/tmp", |
| 40043 | + "/tmp", |
| 40044 | + "." |
| 40045 | +}; |
| 40046 | + |
| 40047 | +/* |
| 40048 | +** Initialize first two members of azTempDirs[] array. |
| 40049 | +*/ |
| 40050 | +static void unixTempFileInit(void){ |
| 40051 | + azTempDirs[0] = getenv("SQLITE_TMPDIR"); |
| 40052 | + azTempDirs[1] = getenv("TMPDIR"); |
| 40053 | +} |
| 40035 | 40054 | |
| 40036 | 40055 | /* |
| 40037 | 40056 | ** Return the name of a directory in which to put temporary files. |
| 40038 | 40057 | ** If no suitable temporary file directory can be found, return NULL. |
| 40039 | 40058 | */ |
| 40040 | 40059 | static const char *unixTempFileDir(void){ |
| 40041 | | - static const char *azDirs[] = { |
| 40042 | | - 0, |
| 40043 | | - 0, |
| 40044 | | - "/var/tmp", |
| 40045 | | - "/usr/tmp", |
| 40046 | | - "/tmp", |
| 40047 | | - "." |
| 40048 | | - }; |
| 40049 | 40060 | unsigned int i = 0; |
| 40050 | 40061 | struct stat buf; |
| 40051 | 40062 | const char *zDir = sqlite3_temp_directory; |
| 40052 | 40063 | |
| 40053 | | - if( !azDirs[0] ) azDirs[0] = getenv("SQLITE_TMPDIR"); |
| 40054 | | - if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR"); |
| 40055 | 40064 | while(1){ |
| 40056 | 40065 | if( zDir!=0 |
| 40057 | 40066 | && osStat(zDir, &buf)==0 |
| 40058 | 40067 | && S_ISDIR(buf.st_mode) |
| 40059 | 40068 | && osAccess(zDir, 03)==0 |
| 40060 | 40069 | ){ |
| 40061 | 40070 | return zDir; |
| 40062 | 40071 | } |
| 40063 | | - if( i>=sizeof(azDirs)/sizeof(azDirs[0]) ) break; |
| 40064 | | - zDir = azDirs[i++]; |
| 40072 | + if( i>=sizeof(azTempDirs)/sizeof(azTempDirs[0]) ) break; |
| 40073 | + zDir = azTempDirs[i++]; |
| 40065 | 40074 | } |
| 40066 | 40075 | return 0; |
| 40067 | 40076 | } |
| 40068 | 40077 | |
| 40069 | 40078 | /* |
| | @@ -42330,10 +42339,13 @@ |
| 42330 | 42339 | ** READ-4 UNIX_SHM_BASE+7 127 |
| 42331 | 42340 | ** DMS UNIX_SHM_BASE+8 128 |
| 42332 | 42341 | */ |
| 42333 | 42342 | assert( UNIX_SHM_DMS==128 ); /* Byte offset of the deadman-switch */ |
| 42334 | 42343 | #endif |
| 42344 | + |
| 42345 | + /* Initialize temp file dir array. */ |
| 42346 | + unixTempFileInit(); |
| 42335 | 42347 | |
| 42336 | 42348 | return SQLITE_OK; |
| 42337 | 42349 | } |
| 42338 | 42350 | |
| 42339 | 42351 | /* |
| | @@ -107083,16 +107095,13 @@ |
| 107083 | 107095 | if( pB->op==TK_COLLATE && sqlite3ExprCompare(pParse, pA,pB->pLeft,iTab)<2 ){ |
| 107084 | 107096 | return 1; |
| 107085 | 107097 | } |
| 107086 | 107098 | return 2; |
| 107087 | 107099 | } |
| 107088 | | - if( pA->op!=TK_COLUMN |
| 107089 | | - && pA->op!=TK_AGG_COLUMN |
| 107090 | | - && ALWAYS(!ExprHasProperty(pA, EP_IntValue)) |
| 107091 | | - && pA->u.zToken |
| 107092 | | - ){ |
| 107093 | | - assert( !ExprHasProperty(pB, EP_IntValue) ); |
| 107100 | + assert( !ExprHasProperty(pA, EP_IntValue) ); |
| 107101 | + assert( !ExprHasProperty(pB, EP_IntValue) ); |
| 107102 | + if( pA->u.zToken ){ |
| 107094 | 107103 | if( pA->op==TK_FUNCTION || pA->op==TK_AGG_FUNCTION ){ |
| 107095 | 107104 | if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2; |
| 107096 | 107105 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 107097 | 107106 | assert( pA->op==pB->op ); |
| 107098 | 107107 | if( ExprHasProperty(pA,EP_WinFunc)!=ExprHasProperty(pB,EP_WinFunc) ){ |
| | @@ -107106,11 +107115,16 @@ |
| 107106 | 107115 | #endif |
| 107107 | 107116 | }else if( pA->op==TK_NULL ){ |
| 107108 | 107117 | return 0; |
| 107109 | 107118 | }else if( pA->op==TK_COLLATE ){ |
| 107110 | 107119 | if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2; |
| 107111 | | - }else if( ALWAYS(pB->u.zToken!=0) && strcmp(pA->u.zToken,pB->u.zToken)!=0 ){ |
| 107120 | + }else |
| 107121 | + if( pB->u.zToken!=0 |
| 107122 | + && pA->op!=TK_COLUMN |
| 107123 | + && pA->op!=TK_AGG_COLUMN |
| 107124 | + && strcmp(pA->u.zToken,pB->u.zToken)!=0 |
| 107125 | + ){ |
| 107112 | 107126 | return 2; |
| 107113 | 107127 | } |
| 107114 | 107128 | } |
| 107115 | 107129 | if( (pA->flags & (EP_Distinct|EP_Commuted)) |
| 107116 | 107130 | != (pB->flags & (EP_Distinct|EP_Commuted)) ) return 2; |
| | @@ -165855,10 +165869,11 @@ |
| 165855 | 165869 | int n = 0; /* Length of the next token token */ |
| 165856 | 165870 | int tokenType; /* type of the next token */ |
| 165857 | 165871 | int lastTokenParsed = -1; /* type of the previous token */ |
| 165858 | 165872 | sqlite3 *db = pParse->db; /* The database connection */ |
| 165859 | 165873 | int mxSqlLen; /* Max length of an SQL string */ |
| 165874 | + Parse *pParentParse = 0; /* Outer parse context, if any */ |
| 165860 | 165875 | #ifdef sqlite3Parser_ENGINEALWAYSONSTACK |
| 165861 | 165876 | yyParser sEngine; /* Space to hold the Lemon-generated Parser object */ |
| 165862 | 165877 | #endif |
| 165863 | 165878 | VVA_ONLY( u8 startedWithOom = db->mallocFailed ); |
| 165864 | 165879 | |
| | @@ -165890,11 +165905,11 @@ |
| 165890 | 165905 | #endif |
| 165891 | 165906 | assert( pParse->pNewTable==0 ); |
| 165892 | 165907 | assert( pParse->pNewTrigger==0 ); |
| 165893 | 165908 | assert( pParse->nVar==0 ); |
| 165894 | 165909 | assert( pParse->pVList==0 ); |
| 165895 | | - pParse->pParentParse = db->pParse; |
| 165910 | + pParentParse = db->pParse; |
| 165896 | 165911 | db->pParse = pParse; |
| 165897 | 165912 | while( 1 ){ |
| 165898 | 165913 | n = sqlite3GetToken((u8*)zSql, &tokenType); |
| 165899 | 165914 | mxSqlLen -= n; |
| 165900 | 165915 | if( mxSqlLen<0 ){ |
| | @@ -166005,12 +166020,11 @@ |
| 166005 | 166020 | } |
| 166006 | 166021 | if( !IN_RENAME_OBJECT ){ |
| 166007 | 166022 | sqlite3DeleteTrigger(db, pParse->pNewTrigger); |
| 166008 | 166023 | } |
| 166009 | 166024 | sqlite3DbFree(db, pParse->pVList); |
| 166010 | | - db->pParse = pParse->pParentParse; |
| 166011 | | - pParse->pParentParse = 0; |
| 166025 | + db->pParse = pParentParse; |
| 166012 | 166026 | assert( nErr==0 || pParse->rc!=SQLITE_OK ); |
| 166013 | 166027 | return nErr; |
| 166014 | 166028 | } |
| 166015 | 166029 | |
| 166016 | 166030 | |
| | @@ -178984,10 +178998,11 @@ |
| 178984 | 178998 | } |
| 178985 | 178999 | |
| 178986 | 179000 | if( fts3auxGrowStatArray(pCsr, 2) ) return SQLITE_NOMEM; |
| 178987 | 179001 | memset(pCsr->aStat, 0, sizeof(struct Fts3auxColstats) * pCsr->nStat); |
| 178988 | 179002 | iCol = 0; |
| 179003 | + rc = SQLITE_OK; |
| 178989 | 179004 | |
| 178990 | 179005 | while( i<nDoclist ){ |
| 178991 | 179006 | sqlite3_int64 v = 0; |
| 178992 | 179007 | |
| 178993 | 179008 | i += sqlite3Fts3GetVarint(&aDoclist[i], &v); |
| | @@ -179027,19 +179042,22 @@ |
| 179027 | 179042 | break; |
| 179028 | 179043 | |
| 179029 | 179044 | /* State 3. The integer just read is a column number. */ |
| 179030 | 179045 | default: assert( eState==3 ); |
| 179031 | 179046 | iCol = (int)v; |
| 179047 | + if( iCol<1 ){ |
| 179048 | + rc = SQLITE_CORRUPT_VTAB; |
| 179049 | + break; |
| 179050 | + } |
| 179032 | 179051 | if( fts3auxGrowStatArray(pCsr, iCol+2) ) return SQLITE_NOMEM; |
| 179033 | 179052 | pCsr->aStat[iCol+1].nDoc++; |
| 179034 | 179053 | eState = 2; |
| 179035 | 179054 | break; |
| 179036 | 179055 | } |
| 179037 | 179056 | } |
| 179038 | 179057 | |
| 179039 | 179058 | pCsr->iCol = 0; |
| 179040 | | - rc = SQLITE_OK; |
| 179041 | 179059 | }else{ |
| 179042 | 179060 | pCsr->isEof = 1; |
| 179043 | 179061 | } |
| 179044 | 179062 | return rc; |
| 179045 | 179063 | } |
| | @@ -195171,24 +195189,33 @@ |
| 195171 | 195189 | || p->op==RTREE_FALSE ); |
| 195172 | 195190 | assert( ((((char*)pCellData) - (char*)0)&3)==0 ); /* 4-byte aligned */ |
| 195173 | 195191 | switch( p->op ){ |
| 195174 | 195192 | case RTREE_TRUE: return; /* Always satisfied */ |
| 195175 | 195193 | case RTREE_FALSE: break; /* Never satisfied */ |
| 195176 | | - case RTREE_LE: |
| 195177 | | - case RTREE_LT: |
| 195178 | 195194 | case RTREE_EQ: |
| 195179 | 195195 | RTREE_DECODE_COORD(eInt, pCellData, val); |
| 195180 | 195196 | /* val now holds the lower bound of the coordinate pair */ |
| 195197 | + if( p->u.rValue>=val ){ |
| 195198 | + pCellData += 4; |
| 195199 | + RTREE_DECODE_COORD(eInt, pCellData, val); |
| 195200 | + /* val now holds the upper bound of the coordinate pair */ |
| 195201 | + if( p->u.rValue<=val ) return; |
| 195202 | + } |
| 195203 | + break; |
| 195204 | + case RTREE_LE: |
| 195205 | + case RTREE_LT: |
| 195206 | + RTREE_DECODE_COORD(eInt, pCellData, val); |
| 195207 | + /* val now holds the lower bound of the coordinate pair */ |
| 195181 | 195208 | if( p->u.rValue>=val ) return; |
| 195182 | | - if( p->op!=RTREE_EQ ) break; /* RTREE_LE and RTREE_LT end here */ |
| 195183 | | - /* Fall through for the RTREE_EQ case */ |
| 195209 | + break; |
| 195184 | 195210 | |
| 195185 | | - default: /* RTREE_GT or RTREE_GE, or fallthrough of RTREE_EQ */ |
| 195211 | + default: |
| 195186 | 195212 | pCellData += 4; |
| 195187 | 195213 | RTREE_DECODE_COORD(eInt, pCellData, val); |
| 195188 | 195214 | /* val now holds the upper bound of the coordinate pair */ |
| 195189 | 195215 | if( p->u.rValue<=val ) return; |
| 195216 | + break; |
| 195190 | 195217 | } |
| 195191 | 195218 | *peWithin = NOT_WITHIN; |
| 195192 | 195219 | } |
| 195193 | 195220 | |
| 195194 | 195221 | /* |
| | @@ -232459,11 +232486,11 @@ |
| 232459 | 232486 | int nArg, /* Number of args */ |
| 232460 | 232487 | sqlite3_value **apUnused /* Function arguments */ |
| 232461 | 232488 | ){ |
| 232462 | 232489 | assert( nArg==0 ); |
| 232463 | 232490 | UNUSED_PARAM2(nArg, apUnused); |
| 232464 | | - sqlite3_result_text(pCtx, "fts5: 2021-11-15 19:10:13 bd66ab8a1bc3c43a57c7caff5f54545b0feb0177f1f51492f30d308c123c43ba", -1, SQLITE_TRANSIENT); |
| 232491 | + sqlite3_result_text(pCtx, "fts5: 2021-11-22 16:06:57 0f567b61072e214c40cae1441889f83622a975f429b41803dfbed687718731c8", -1, SQLITE_TRANSIENT); |
| 232465 | 232492 | } |
| 232466 | 232493 | |
| 232467 | 232494 | /* |
| 232468 | 232495 | ** Return true if zName is the extension on one of the shadow tables used |
| 232469 | 232496 | ** by this module. |
| 232470 | 232497 | |