Fossil SCM

Update the built-in SQLite to the latest trunk version which includes all of the patches associated with version 3.38.1 plus additional performance enhancements.

drh 2022-03-12 14:20 trunk
Commit b731e1f65bae4b46802664b5fc680c299ea342ac1ae1cd6572bb57d1763c42c5
+6 -1
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -8870,10 +8870,14 @@
88708870
0, /* xSync */
88718871
zipfileCommit, /* xCommit */
88728872
zipfileRollback, /* xRollback */
88738873
zipfileFindFunction, /* xFindMethod */
88748874
0, /* xRename */
8875
+ 0, /* xSavepoint */
8876
+ 0, /* xRelease */
8877
+ 0, /* xRollback */
8878
+ 0 /* xShadowName */
88758879
};
88768880
88778881
int rc = sqlite3_create_module(db, "zipfile" , &zipfileModule, 0);
88788882
if( rc==SQLITE_OK ) rc = sqlite3_overload_function(db, "zipfile_cds", -1);
88798883
if( rc==SQLITE_OK ){
@@ -19919,10 +19923,11 @@
1991919923
ImportCtx sCtx; /* Reader context */
1992019924
char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */
1992119925
int eVerbose = 0; /* Larger for more console output */
1992219926
int nSkip = 0; /* Initial lines to skip */
1992319927
int useOutputMode = 1; /* Use output mode to determine separators */
19928
+ char *zCreate = 0; /* CREATE TABLE statement text */
1992419929
1992519930
failIfSafeMode(p, "cannot run .import in safe mode");
1992619931
memset(&sCtx, 0, sizeof(sCtx));
1992719932
sCtx.z = sqlite3_malloc64(120);
1992819933
if( sCtx.z==0 ){
@@ -20070,14 +20075,14 @@
2007020075
}
2007120076
nByte = strlen30(zSql);
2007220077
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
2007320078
import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */
2007420079
if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){
20075
- char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zFullTabName);
2007620080
sqlite3 *dbCols = 0;
2007720081
char *zRenames = 0;
2007820082
char *zColDefs;
20083
+ zCreate = sqlite3_mprintf("CREATE TABLE %s", zFullTabName);
2007920084
while( xRead(&sCtx) ){
2008020085
zAutoColumn(sCtx.z, &dbCols, 0);
2008120086
if( sCtx.cTerm!=sCtx.cColSep ) break;
2008220087
}
2008320088
zColDefs = zAutoColumn(0, &dbCols, &zRenames);
2008420089
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -8870,10 +8870,14 @@
8870 0, /* xSync */
8871 zipfileCommit, /* xCommit */
8872 zipfileRollback, /* xRollback */
8873 zipfileFindFunction, /* xFindMethod */
8874 0, /* xRename */
 
 
 
 
8875 };
8876
8877 int rc = sqlite3_create_module(db, "zipfile" , &zipfileModule, 0);
8878 if( rc==SQLITE_OK ) rc = sqlite3_overload_function(db, "zipfile_cds", -1);
8879 if( rc==SQLITE_OK ){
@@ -19919,10 +19923,11 @@
19919 ImportCtx sCtx; /* Reader context */
19920 char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */
19921 int eVerbose = 0; /* Larger for more console output */
19922 int nSkip = 0; /* Initial lines to skip */
19923 int useOutputMode = 1; /* Use output mode to determine separators */
 
19924
19925 failIfSafeMode(p, "cannot run .import in safe mode");
19926 memset(&sCtx, 0, sizeof(sCtx));
19927 sCtx.z = sqlite3_malloc64(120);
19928 if( sCtx.z==0 ){
@@ -20070,14 +20075,14 @@
20070 }
20071 nByte = strlen30(zSql);
20072 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
20073 import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */
20074 if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){
20075 char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zFullTabName);
20076 sqlite3 *dbCols = 0;
20077 char *zRenames = 0;
20078 char *zColDefs;
 
20079 while( xRead(&sCtx) ){
20080 zAutoColumn(sCtx.z, &dbCols, 0);
20081 if( sCtx.cTerm!=sCtx.cColSep ) break;
20082 }
20083 zColDefs = zAutoColumn(0, &dbCols, &zRenames);
20084
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -8870,10 +8870,14 @@
8870 0, /* xSync */
8871 zipfileCommit, /* xCommit */
8872 zipfileRollback, /* xRollback */
8873 zipfileFindFunction, /* xFindMethod */
8874 0, /* xRename */
8875 0, /* xSavepoint */
8876 0, /* xRelease */
8877 0, /* xRollback */
8878 0 /* xShadowName */
8879 };
8880
8881 int rc = sqlite3_create_module(db, "zipfile" , &zipfileModule, 0);
8882 if( rc==SQLITE_OK ) rc = sqlite3_overload_function(db, "zipfile_cds", -1);
8883 if( rc==SQLITE_OK ){
@@ -19919,10 +19923,11 @@
19923 ImportCtx sCtx; /* Reader context */
19924 char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */
19925 int eVerbose = 0; /* Larger for more console output */
19926 int nSkip = 0; /* Initial lines to skip */
19927 int useOutputMode = 1; /* Use output mode to determine separators */
19928 char *zCreate = 0; /* CREATE TABLE statement text */
19929
19930 failIfSafeMode(p, "cannot run .import in safe mode");
19931 memset(&sCtx, 0, sizeof(sCtx));
19932 sCtx.z = sqlite3_malloc64(120);
19933 if( sCtx.z==0 ){
@@ -20070,14 +20075,14 @@
20075 }
20076 nByte = strlen30(zSql);
20077 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
20078 import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */
20079 if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){
 
20080 sqlite3 *dbCols = 0;
20081 char *zRenames = 0;
20082 char *zColDefs;
20083 zCreate = sqlite3_mprintf("CREATE TABLE %s", zFullTabName);
20084 while( xRead(&sCtx) ){
20085 zAutoColumn(sCtx.z, &dbCols, 0);
20086 if( sCtx.cTerm!=sCtx.cColSep ) break;
20087 }
20088 zColDefs = zAutoColumn(0, &dbCols, &zRenames);
20089
+104 -52
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -452,11 +452,11 @@
452452
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453453
** [sqlite_version()] and [sqlite_source_id()].
454454
*/
455455
#define SQLITE_VERSION "3.39.0"
456456
#define SQLITE_VERSION_NUMBER 3039000
457
-#define SQLITE_SOURCE_ID "2022-03-07 18:32:08 ae464a18d74bf44fc95bc335e75e6a57dc974f6d6a3d603133594039fb589af2"
457
+#define SQLITE_SOURCE_ID "2022-03-11 15:42:05 0606e8e93edb5de4d154f377dbf91f15295d25ca9013c0f1612ae6d63a0139ea"
458458
459459
/*
460460
** CAPI3REF: Run-Time Library Version Numbers
461461
** KEYWORDS: sqlite3_version sqlite3_sourceid
462462
**
@@ -5282,10 +5282,14 @@
52825282
** bytes in the string, not the number of characters.
52835283
**
52845284
** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
52855285
** even empty strings, are always zero-terminated. ^The return
52865286
** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
5287
+**
5288
+** ^Strings returned by sqlite3_column_text16() always have the endianness
5289
+** which is native to the platform, regardless of the text encoding set
5290
+** for the database.
52875291
**
52885292
** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
52895293
** [unprotected sqlite3_value] object. In a multithreaded environment,
52905294
** an unprotected sqlite3_value object may only be used safely with
52915295
** [sqlite3_bind_value()] and [sqlite3_result_value()].
@@ -5296,11 +5300,11 @@
52965300
** Hence, the sqlite3_column_value() interface
52975301
** is normally only useful within the implementation of
52985302
** [application-defined SQL functions] or [virtual tables], not within
52995303
** top-level application code.
53005304
**
5301
-** The these routines may attempt to convert the datatype of the result.
5305
+** These routines may attempt to convert the datatype of the result.
53025306
** ^For example, if the internal representation is FLOAT and a text result
53035307
** is requested, [sqlite3_snprintf()] is used internally to perform the
53045308
** conversion automatically. ^(The following table details the conversions
53055309
** that are applied:
53065310
**
@@ -5321,11 +5325,11 @@
53215325
** <tr><td> TEXT <td> INTEGER <td> [CAST] to INTEGER
53225326
** <tr><td> TEXT <td> FLOAT <td> [CAST] to REAL
53235327
** <tr><td> TEXT <td> BLOB <td> No change
53245328
** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
53255329
** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
5326
-** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
5330
+** <tr><td> BLOB <td> TEXT <td> [CAST] to TEXT, ensure zero terminator
53275331
** </table>
53285332
** </blockquote>)^
53295333
**
53305334
** Note that when type conversions occur, pointers returned by prior
53315335
** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
@@ -14515,11 +14519,11 @@
1451514519
** one parameter that destructors normally want. So we have to introduce
1451614520
** this magic value that the code knows to handle differently. Any
1451714521
** pointer will work here as long as it is distinct from SQLITE_STATIC
1451814522
** and SQLITE_TRANSIENT.
1451914523
*/
14520
-#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3OomFault)
14524
+#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3OomClear)
1452114525
1452214526
/*
1452314527
** When SQLITE_OMIT_WSD is defined, it means that the target platform does
1452414528
** not support Writable Static Data (WSD) such as global and static variables.
1452514529
** All variables must either be on the stack or dynamically allocated from
@@ -19406,11 +19410,11 @@
1940619410
Expr *pStart; /* Expression for "<expr> PRECEDING" */
1940719411
Expr *pEnd; /* Expression for "<expr> FOLLOWING" */
1940819412
Window **ppThis; /* Pointer to this object in Select.pWin list */
1940919413
Window *pNextWin; /* Next window function belonging to this SELECT */
1941019414
Expr *pFilter; /* The FILTER expression */
19411
- FuncDef *pFunc; /* The function */
19415
+ FuncDef *pWFunc; /* The function */
1941219416
int iEphCsr; /* Partition buffer or Peer buffer */
1941319417
int regAccum; /* Accumulator */
1941419418
int regResult; /* Interim result */
1941519419
int csrApp; /* Function cursor (used by min/max) */
1941619420
int regApp; /* Function register (also used by min/max) */
@@ -20366,11 +20370,16 @@
2036620370
SQLITE_PRIVATE void sqlite3VtabArgExtend(Parse*, Token*);
2036720371
SQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);
2036820372
SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);
2036920373
SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
2037020374
SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);
20375
+
2037120376
SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
20377
+#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
20378
+ && !defined(SQLITE_OMIT_VIRTUALTABLE)
20379
+SQLITE_PRIVATE void sqlite3VtabWriteAll(sqlite3_index_info*);
20380
+#endif
2037220381
SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
2037320382
SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
2037420383
SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
2037520384
SQLITE_PRIVATE void sqlite3ParseObjectInit(Parse*,sqlite3*);
2037620385
SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse*);
@@ -21886,10 +21895,13 @@
2188621895
0, /* bLocaltimeFault */
2188721896
0, /* xAltLocaltime */
2188821897
0x7ffffffe, /* iOnceResetThreshold */
2188921898
SQLITE_DEFAULT_SORTERREF_SIZE, /* szSorterRef */
2189021899
0, /* iPrngSeed */
21900
+#ifdef SQLITE_DEBUG
21901
+ {0,0,0,0,0,0} /* aTune */
21902
+#endif
2189121903
};
2189221904
2189321905
/*
2189421906
** Hash table for global functions - functions common to all
2189521907
** database connections. After initialization, this table is
@@ -30870,11 +30882,11 @@
3087030882
memset(p, 0, sizeof(*p));
3087130883
}else{
3087230884
p->iLevel++;
3087330885
}
3087430886
assert( moreToFollow==0 || moreToFollow==1 );
30875
- if( p->iLevel<sizeof(p->bLine) ) p->bLine[p->iLevel] = moreToFollow;
30887
+ if( p->iLevel<(int)sizeof(p->bLine) ) p->bLine[p->iLevel] = moreToFollow;
3087630888
return p;
3087730889
}
3087830890
3087930891
/*
3088030892
** Finished with one layer of the tree
@@ -30894,11 +30906,11 @@
3089430906
int i;
3089530907
StrAccum acc;
3089630908
char zBuf[500];
3089730909
sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
3089830910
if( p ){
30899
- for(i=0; i<p->iLevel && i<sizeof(p->bLine)-1; i++){
30911
+ for(i=0; i<p->iLevel && i<(int)sizeof(p->bLine)-1; i++){
3090030912
sqlite3_str_append(&acc, p->bLine[i] ? "| " : " ", 4);
3090130913
}
3090230914
sqlite3_str_append(&acc, p->bLine[i] ? "|-- " : "'-- ", 4);
3090330915
}
3090430916
if( zFormat!=0 ){
@@ -31224,11 +31236,11 @@
3122431236
** Generate a human-readable explanation for a Window Function object
3122531237
*/
3122631238
SQLITE_PRIVATE void sqlite3TreeViewWinFunc(TreeView *pView, const Window *pWin, u8 more){
3122731239
pView = sqlite3TreeViewPush(pView, more);
3122831240
sqlite3TreeViewLine(pView, "WINFUNC %s(%d)",
31229
- pWin->pFunc->zName, pWin->pFunc->nArg);
31241
+ pWin->pWFunc->zName, pWin->pWFunc->nArg);
3123031242
sqlite3TreeViewWindow(pView, pWin, 0);
3123131243
sqlite3TreeViewPop(pView);
3123231244
}
3123331245
#endif /* SQLITE_OMIT_WINDOWFUNC */
3123431246
@@ -40820,24 +40832,27 @@
4082040832
** "<path to db>-journalNN"
4082140833
** "<path to db>-walNN"
4082240834
**
4082340835
** where NN is a decimal number. The NN naming schemes are
4082440836
** used by the test_multiplex.c module.
40837
+ **
40838
+ ** In normal operation, the journal file name will always contain
40839
+ ** a '-' character. However in 8+3 filename mode, or if a corrupt
40840
+ ** rollback journal specifies a super-journal with a goofy name, then
40841
+ ** the '-' might be missing or the '-' might be the first character in
40842
+ ** the filename. In that case, just return SQLITE_OK with *pMode==0.
4082540843
*/
4082640844
nDb = sqlite3Strlen30(zPath) - 1;
40827
- while( zPath[nDb]!='-' ){
40828
- /* In normal operation, the journal file name will always contain
40829
- ** a '-' character. However in 8+3 filename mode, or if a corrupt
40830
- ** rollback journal specifies a super-journal with a goofy name, then
40831
- ** the '-' might be missing. */
40832
- if( nDb==0 || zPath[nDb]=='.' ) return SQLITE_OK;
40845
+ while( nDb>0 && zPath[nDb]!='.' ){
40846
+ if( zPath[nDb]=='-' ){
40847
+ memcpy(zDb, zPath, nDb);
40848
+ zDb[nDb] = '\0';
40849
+ rc = getFileMode(zDb, pMode, pUid, pGid);
40850
+ break;
40851
+ }
4083340852
nDb--;
4083440853
}
40835
- memcpy(zDb, zPath, nDb);
40836
- zDb[nDb] = '\0';
40837
-
40838
- rc = getFileMode(zDb, pMode, pUid, pGid);
4083940854
}else if( flags & SQLITE_OPEN_DELETEONCLOSE ){
4084040855
*pMode = 0600;
4084140856
}else if( flags & SQLITE_OPEN_URI ){
4084240857
/* If this is a main database file and the file was opened using a URI
4084340858
** filename, check for the "modeof" parameter. If present, interpret
@@ -65443,11 +65458,11 @@
6544365458
u8 *apOvfl[4]; /* Pointers to the body of overflow cells */
6544465459
BtShared *pBt; /* Pointer to BtShared that this page is part of */
6544565460
u8 *aData; /* Pointer to disk image of the page data */
6544665461
u8 *aDataEnd; /* One byte past the end of the entire page - not just
6544765462
** the usable space, the entire page. Used to prevent
65448
- ** corruption-induced of buffer overflow. */
65463
+ ** corruption-induced buffer overflow. */
6544965464
u8 *aCellIdx; /* The cell index area */
6545065465
u8 *aDataOfst; /* Same as aData for leaves. aData+4 for interior */
6545165466
DbPage *pDbPage; /* Pager page handle */
6545265467
u16 (*xCellSize)(MemPage*,u8*); /* cellSizePtr method */
6545365468
void (*xParseCell)(MemPage*,u8*,CellInfo*); /* btreeParseCell method */
@@ -66389,11 +66404,11 @@
6638966404
if( isIndex ){
6639066405
HashElem *p;
6639166406
int bSeen = 0;
6639266407
for(p=sqliteHashFirst(&pSchema->idxHash); p; p=sqliteHashNext(p)){
6639366408
Index *pIdx = (Index *)sqliteHashData(p);
66394
- if( pIdx->tnum==(int)iRoot ){
66409
+ if( pIdx->tnum==iRoot ){
6639566410
if( bSeen ){
6639666411
/* Two or more indexes share the same root page. There must
6639766412
** be imposter tables. So just return true. The assert is not
6639866413
** useful in that case. */
6639966414
return 1;
@@ -72005,20 +72020,23 @@
7200572020
&& cursorOnLastPage(pCur)
7200672021
){
7200772022
int c;
7200872023
if( pCur->ix==pCur->pPage->nCell-1
7200972024
&& (c = indexCellCompare(pCur, pCur->ix, pIdxKey, xRecordCompare))<=0
72025
+ && pIdxKey->errCode==SQLITE_OK
7201072026
){
7201172027
*pRes = c;
7201272028
return SQLITE_OK; /* Cursor already pointing at the correct spot */
7201372029
}
7201472030
if( pCur->iPage>0
72015
- && (c = indexCellCompare(pCur, 0, pIdxKey, xRecordCompare))<=0
72031
+ && indexCellCompare(pCur, 0, pIdxKey, xRecordCompare)<=0
72032
+ && pIdxKey->errCode==SQLITE_OK
7201672033
){
7201772034
pCur->curFlags &= ~BTCF_ValidOvfl;
7201872035
goto bypass_moveto_root; /* Start search on the current page */
7201972036
}
72037
+ pIdxKey->errCode = SQLITE_OK;
7202072038
}
7202172039
7202272040
rc = moveToRoot(pCur);
7202372041
if( rc ){
7202472042
if( rc==SQLITE_EMPTY ){
@@ -80155,11 +80173,11 @@
8015580173
if( nNew > p->db->aLimit[SQLITE_LIMIT_VDBE_OP] ){
8015680174
sqlite3OomFault(p->db);
8015780175
return SQLITE_NOMEM;
8015880176
}
8015980177
80160
- assert( nOp<=(1024/sizeof(Op)) );
80178
+ assert( nOp<=(int)(1024/sizeof(Op)) );
8016180179
assert( nNew>=(v->nOpAlloc+nOp) );
8016280180
pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op));
8016380181
if( pNew ){
8016480182
p->szOpAlloc = sqlite3DbMallocSize(p->db, pNew);
8016580183
v->nOpAlloc = p->szOpAlloc/sizeof(Op);
@@ -110148,23 +110166,25 @@
110148110166
const char *zSql, /* SQL to parse */
110149110167
int bTemp /* True if SQL is from temp schema */
110150110168
){
110151110169
int rc;
110152110170
110153
- db->init.iDb = bTemp ? 1 : sqlite3FindDbName(db, zDb);
110154
-
110155
- /* Parse the SQL statement passed as the first argument. If no error
110156
- ** occurs and the parse does not result in a new table, index or
110157
- ** trigger object, the database must be corrupt. */
110158110171
sqlite3ParseObjectInit(p, db);
110172
+ if( zSql==0 ){
110173
+ return SQLITE_NOMEM;
110174
+ }
110175
+ if( sqlite3StrNICmp(zSql,"CREATE ",7)!=0 ){
110176
+ return SQLITE_CORRUPT_BKPT;
110177
+ }
110178
+ db->init.iDb = bTemp ? 1 : sqlite3FindDbName(db, zDb);
110159110179
p->eParseMode = PARSE_MODE_RENAME;
110160110180
p->db = db;
110161110181
p->nQueryLoop = 1;
110162
- rc = zSql ? sqlite3RunParser(p, zSql) : SQLITE_NOMEM;
110182
+ rc = sqlite3RunParser(p, zSql);
110163110183
if( db->mallocFailed ) rc = SQLITE_NOMEM;
110164110184
if( rc==SQLITE_OK
110165
- && p->pNewTable==0 && p->pNewIndex==0 && p->pNewTrigger==0
110185
+ && NEVER(p->pNewTable==0 && p->pNewIndex==0 && p->pNewTrigger==0)
110166110186
){
110167110187
rc = SQLITE_CORRUPT_BKPT;
110168110188
}
110169110189
110170110190
#ifdef SQLITE_DEBUG
@@ -116909,10 +116929,15 @@
116909116929
int regRec; /* A record to be insert into the new table */
116910116930
int regRowid; /* Rowid of the next row to insert */
116911116931
int addrInsLoop; /* Top of the loop for inserting rows */
116912116932
Table *pSelTab; /* A table that describes the SELECT results */
116913116933
116934
+ if( IN_SPECIAL_PARSE ){
116935
+ pParse->rc = SQLITE_ERROR;
116936
+ pParse->nErr++;
116937
+ return;
116938
+ }
116914116939
regYield = ++pParse->nMem;
116915116940
regRec = ++pParse->nMem;
116916116941
regRowid = ++pParse->nMem;
116917116942
assert(pParse->nTab==1);
116918116943
sqlite3MayAbort(pParse);
@@ -127394,11 +127419,11 @@
127394127419
}
127395127420
}
127396127421
if( isUpdate ){
127397127422
/* If currently processing the PRIMARY KEY of a WITHOUT ROWID
127398127423
** table, only conflict if the new PRIMARY KEY values are actually
127399
- ** different from the old.
127424
+ ** different from the old. See TH3 withoutrowid04.test.
127400127425
**
127401127426
** For a UNIQUE index, only conflict if the PRIMARY KEY values
127402127427
** of the matched index row are different from the original PRIMARY
127403127428
** KEY values of this row before the update. */
127404127429
int addrJump = sqlite3VdbeCurrentAddr(v)+pPk->nKeyCol;
@@ -155956,11 +155981,10 @@
155956155981
}
155957155982
155958155983
return rc;
155959155984
}
155960155985
155961
-
155962155986
/*
155963155987
** Return true if ORDER BY clause may be handled as DISTINCT.
155964155988
*/
155965155989
SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info *pIdxInfo){
155966155990
HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
@@ -155967,10 +155991,26 @@
155967155991
assert( pHidden->eDistinct==0
155968155992
|| pHidden->eDistinct==1
155969155993
|| pHidden->eDistinct==2 );
155970155994
return pHidden->eDistinct;
155971155995
}
155996
+
155997
+#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
155998
+ && !defined(SQLITE_OMIT_VIRTUALTABLE)
155999
+/*
156000
+** Cause the prepared statement that is associated with a call to
156001
+** xBestIndex to open write transactions on all attached schemas.
156002
+** This is used by the (built-in) sqlite_dbpage virtual table.
156003
+*/
156004
+SQLITE_PRIVATE void sqlite3VtabWriteAll(sqlite3_index_info *pIdxInfo){
156005
+ HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
156006
+ Parse *pParse = pHidden->pParse;
156007
+ int nDb = pParse->db->nDb;
156008
+ int i;
156009
+ for(i=0; i<nDb; i++) sqlite3BeginWriteOperation(pParse, 0, i);
156010
+}
156011
+#endif
155972156012
155973156013
/*
155974156014
** Add all WhereLoop objects for a table of the join identified by
155975156015
** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table.
155976156016
**
@@ -158327,10 +158367,14 @@
158327158367
assert( pIdx->pTable==pTab );
158328158368
if( !HasRowid(pTab) ){
158329158369
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
158330158370
x = pPk->aiColumn[x];
158331158371
assert( x>=0 );
158372
+#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
158373
+ }else if( pOp->opcode==OP_Offset ){
158374
+ /* Do not need to translate the column number */
158375
+#endif
158332158376
}else{
158333158377
testcase( x!=sqlite3StorageColumnToTable(pTab,x) );
158334158378
x = sqlite3StorageColumnToTable(pTab,x);
158335158379
}
158336158380
x = sqlite3TableColumnToIndex(pIdx, x);
@@ -159093,11 +159137,11 @@
159093159137
break;
159094159138
}
159095159139
}
159096159140
}
159097159141
}
159098
- pWin->pFunc = pFunc;
159142
+ pWin->pWFunc = pFunc;
159099159143
}
159100159144
159101159145
/*
159102159146
** Context object passed through sqlite3WalkExprList() to
159103159147
** selectWindowRewriteExprCb() by selectWindowRewriteEList().
@@ -159326,11 +159370,15 @@
159326159370
** are invoked in the correct order as described under "SELECT REWRITING"
159327159371
** at the top of this file.
159328159372
*/
159329159373
SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
159330159374
int rc = SQLITE_OK;
159331
- if( p->pWin && p->pPrior==0 && ALWAYS((p->selFlags & SF_WinRewrite)==0) ){
159375
+ if( p->pWin
159376
+ && p->pPrior==0
159377
+ && ALWAYS((p->selFlags & SF_WinRewrite)==0)
159378
+ && ALWAYS(!IN_RENAME_OBJECT)
159379
+ ){
159332159380
Vdbe *v = sqlite3GetVdbe(pParse);
159333159381
sqlite3 *db = pParse->db;
159334159382
Select *pSub = 0; /* The subquery */
159335159383
SrcList *pSrc = p->pSrc;
159336159384
Expr *pWhere = p->pWhere;
@@ -159401,12 +159449,13 @@
159401159449
** window function - one for the accumulator, another for interim
159402159450
** results. */
159403159451
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
159404159452
ExprList *pArgs;
159405159453
assert( ExprUseXList(pWin->pOwner) );
159454
+ assert( pWin->pWFunc!=0 );
159406159455
pArgs = pWin->pOwner->x.pList;
159407
- if( pWin->pFunc->funcFlags & SQLITE_FUNC_SUBTYPE ){
159456
+ if( pWin->pWFunc->funcFlags & SQLITE_FUNC_SUBTYPE ){
159408159457
selectWindowRewriteEList(pParse, pMWin, pSrc, pArgs, pTab, &pSublist);
159409159458
pWin->iArgCol = (pSublist ? pSublist->nExpr : 0);
159410159459
pWin->bExprArgs = 1;
159411159460
}else{
159412159461
pWin->iArgCol = (pSublist ? pSublist->nExpr : 0);
@@ -159784,11 +159833,11 @@
159784159833
sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->csrApp, pMWin->iEphCsr);
159785159834
return;
159786159835
}
159787159836
159788159837
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
159789
- FuncDef *p = pWin->pFunc;
159838
+ FuncDef *p = pWin->pWFunc;
159790159839
if( (p->funcFlags & SQLITE_FUNC_MINMAX) && pWin->eStart!=TK_UNBOUNDED ){
159791159840
/* The inline versions of min() and max() require a single ephemeral
159792159841
** table and 3 registers. The registers are used as follows:
159793159842
**
159794159843
** regApp+0: slot to copy min()/max() argument to for MakeRecord
@@ -159801,11 +159850,11 @@
159801159850
pList = pWin->pOwner->x.pList;
159802159851
pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pList, 0, 0);
159803159852
pWin->csrApp = pParse->nTab++;
159804159853
pWin->regApp = pParse->nMem+1;
159805159854
pParse->nMem += 3;
159806
- if( pKeyInfo && pWin->pFunc->zName[1]=='i' ){
159855
+ if( pKeyInfo && pWin->pWFunc->zName[1]=='i' ){
159807159856
assert( pKeyInfo->aSortFlags[0]==0 );
159808159857
pKeyInfo->aSortFlags[0] = KEYINFO_ORDER_DESC;
159809159858
}
159810159859
sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pWin->csrApp, 2);
159811159860
sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO);
@@ -160024,11 +160073,11 @@
160024160073
){
160025160074
Parse *pParse = p->pParse;
160026160075
Vdbe *v = sqlite3GetVdbe(pParse);
160027160076
Window *pWin;
160028160077
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
160029
- FuncDef *pFunc = pWin->pFunc;
160078
+ FuncDef *pFunc = pWin->pWFunc;
160030160079
int regArg;
160031160080
int nArg = pWin->bExprArgs ? 0 : windowArgCount(pWin);
160032160081
int i;
160033160082
160034160083
assert( bInverse==0 || pWin->eStart!=TK_UNBOUNDED );
@@ -160138,11 +160187,11 @@
160138160187
Vdbe *v = sqlite3GetVdbe(pParse);
160139160188
Window *pWin;
160140160189
160141160190
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
160142160191
if( pMWin->regStartRowid==0
160143
- && (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX)
160192
+ && (pWin->pWFunc->funcFlags & SQLITE_FUNC_MINMAX)
160144160193
&& (pWin->eStart!=TK_UNBOUNDED)
160145160194
){
160146160195
sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
160147160196
sqlite3VdbeAddOp1(v, OP_Last, pWin->csrApp);
160148160197
VdbeCoverage(v);
@@ -160152,16 +160201,16 @@
160152160201
assert( pMWin->regStartRowid==0 );
160153160202
}else{
160154160203
int nArg = windowArgCount(pWin);
160155160204
if( bFin ){
160156160205
sqlite3VdbeAddOp2(v, OP_AggFinal, pWin->regAccum, nArg);
160157
- sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
160206
+ sqlite3VdbeAppendP4(v, pWin->pWFunc, P4_FUNCDEF);
160158160207
sqlite3VdbeAddOp2(v, OP_Copy, pWin->regAccum, pWin->regResult);
160159160208
sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
160160160209
}else{
160161160210
sqlite3VdbeAddOp3(v, OP_AggValue,pWin->regAccum,nArg,pWin->regResult);
160162
- sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
160211
+ sqlite3VdbeAppendP4(v, pWin->pWFunc, P4_FUNCDEF);
160163160212
}
160164160213
}
160165160214
}
160166160215
}
160167160216
@@ -160286,11 +160335,11 @@
160286160335
}else{
160287160336
Parse *pParse = p->pParse;
160288160337
Window *pWin;
160289160338
160290160339
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
160291
- FuncDef *pFunc = pWin->pFunc;
160340
+ FuncDef *pFunc = pWin->pWFunc;
160292160341
assert( ExprUseXList(pWin->pOwner) );
160293160342
if( pFunc->zName==nth_valueName
160294160343
|| pFunc->zName==first_valueName
160295160344
){
160296160345
int csr = pWin->csrApp;
@@ -160358,11 +160407,11 @@
160358160407
Vdbe *v = sqlite3GetVdbe(pParse);
160359160408
int regArg;
160360160409
int nArg = 0;
160361160410
Window *pWin;
160362160411
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
160363
- FuncDef *pFunc = pWin->pFunc;
160412
+ FuncDef *pFunc = pWin->pWFunc;
160364160413
assert( pWin->regAccum );
160365160414
sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
160366160415
nArg = MAX(nArg, windowArgCount(pWin));
160367160416
if( pMWin->regStartRowid==0 ){
160368160417
if( pFunc->zName==nth_valueName || pFunc->zName==first_valueName ){
@@ -160388,11 +160437,11 @@
160388160437
*/
160389160438
static int windowCacheFrame(Window *pMWin){
160390160439
Window *pWin;
160391160440
if( pMWin->regStartRowid ) return 1;
160392160441
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
160393
- FuncDef *pFunc = pWin->pFunc;
160442
+ FuncDef *pFunc = pWin->pWFunc;
160394160443
if( (pFunc->zName==nth_valueName)
160395160444
|| (pFunc->zName==first_valueName)
160396160445
|| (pFunc->zName==leadName)
160397160446
|| (pFunc->zName==lagName)
160398160447
){
@@ -160746,11 +160795,11 @@
160746160795
pNew = sqlite3DbMallocZero(db, sizeof(Window));
160747160796
if( pNew ){
160748160797
pNew->zName = sqlite3DbStrDup(db, p->zName);
160749160798
pNew->zBase = sqlite3DbStrDup(db, p->zBase);
160750160799
pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);
160751
- pNew->pFunc = p->pFunc;
160800
+ pNew->pWFunc = p->pWFunc;
160752160801
pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);
160753160802
pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);
160754160803
pNew->eFrmType = p->eFrmType;
160755160804
pNew->eEnd = p->eEnd;
160756160805
pNew->eStart = p->eStart;
@@ -172983,14 +173032,16 @@
172983173032
** Test access for the LogEst conversion routines.
172984173033
*/
172985173034
case SQLITE_TESTCTRL_LOGEST: {
172986173035
double rIn = va_arg(ap, double);
172987173036
LogEst rLogEst = sqlite3LogEstFromDouble(rIn);
172988
- u64 iInt = sqlite3LogEstToInt(rLogEst);
172989
- va_arg(ap, int*)[0] = rLogEst;
172990
- va_arg(ap, u64*)[0] = iInt;
172991
- va_arg(ap, int*)[0] = sqlite3LogEst(iInt);
173037
+ int *pI1 = va_arg(ap,int*);
173038
+ u64 *pU64 = va_arg(ap,u64*);
173039
+ int *pI2 = va_arg(ap,int*);
173040
+ *pI1 = rLogEst;
173041
+ *pU64 = sqlite3LogEstToInt(rLogEst);
173042
+ *pI2 = sqlite3LogEst(*pU64);
172992173043
break;
172993173044
}
172994173045
172995173046
172996173047
#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_WSD)
@@ -194917,11 +194968,11 @@
194917194968
u32 iRoot;
194918194969
JsonNode *pTarget;
194919194970
if( pPatch->eType!=JSON_OBJECT ){
194920194971
return pPatch;
194921194972
}
194922
- assert( iTarget>=0 && iTarget<pParse->nNode );
194973
+ assert( iTarget<pParse->nNode );
194923194974
pTarget = &pParse->aNode[iTarget];
194924194975
assert( (pPatch->jnFlags & JNODE_APPEND)==0 );
194925194976
if( pTarget->eType!=JSON_OBJECT ){
194926194977
jsonRemoveAllNulls(pPatch);
194927194978
return pPatch;
@@ -210212,10 +210263,11 @@
210212210263
&& pIdxInfo->aOrderBy[0].iColumn<=0
210213210264
&& pIdxInfo->aOrderBy[0].desc==0
210214210265
){
210215210266
pIdxInfo->orderByConsumed = 1;
210216210267
}
210268
+ sqlite3VtabWriteAll(pIdxInfo);
210217210269
return SQLITE_OK;
210218210270
}
210219210271
210220210272
/*
210221210273
** Open a new dbpagevfs cursor.
@@ -210389,11 +210441,11 @@
210389210441
if( iDb<0 ){
210390210442
zErr = "no such schema";
210391210443
goto update_fail;
210392210444
}
210393210445
pBt = pTab->db->aDb[iDb].pBt;
210394
- if( pgno<1 || pBt==0 || pgno>(int)sqlite3BtreeLastPage(pBt) ){
210446
+ if( pgno<1 || pBt==0 || pgno>sqlite3BtreeLastPage(pBt) ){
210395210447
zErr = "bad page number";
210396210448
goto update_fail;
210397210449
}
210398210450
szPage = sqlite3BtreeGetPageSize(pBt);
210399210451
if( sqlite3_value_type(argv[3])!=SQLITE_BLOB
@@ -232566,11 +232618,11 @@
232566232618
int rc;
232567232619
232568232620
rc = sqlite3_step(pSorter->pStmt);
232569232621
if( rc==SQLITE_DONE ){
232570232622
rc = SQLITE_OK;
232571
- CsrFlagSet(pCsr, FTS5CSR_EOF);
232623
+ CsrFlagSet(pCsr, FTS5CSR_EOF|FTS5CSR_REQUIRE_CONTENT);
232572232624
}else if( rc==SQLITE_ROW ){
232573232625
const u8 *a;
232574232626
const u8 *aBlob;
232575232627
int nBlob;
232576232628
int i;
@@ -234555,11 +234607,11 @@
234555234607
int nArg, /* Number of args */
234556234608
sqlite3_value **apUnused /* Function arguments */
234557234609
){
234558234610
assert( nArg==0 );
234559234611
UNUSED_PARAM2(nArg, apUnused);
234560
- sqlite3_result_text(pCtx, "fts5: 2022-03-07 18:32:08 ae464a18d74bf44fc95bc335e75e6a57dc974f6d6a3d603133594039fb589af2", -1, SQLITE_TRANSIENT);
234612
+ sqlite3_result_text(pCtx, "fts5: 2022-03-11 15:42:05 0606e8e93edb5de4d154f377dbf91f15295d25ca9013c0f1612ae6d63a0139ea", -1, SQLITE_TRANSIENT);
234561234613
}
234562234614
234563234615
/*
234564234616
** Return true if zName is the extension on one of the shadow tables used
234565234617
** by this module.
234566234618
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -452,11 +452,11 @@
452 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453 ** [sqlite_version()] and [sqlite_source_id()].
454 */
455 #define SQLITE_VERSION "3.39.0"
456 #define SQLITE_VERSION_NUMBER 3039000
457 #define SQLITE_SOURCE_ID "2022-03-07 18:32:08 ae464a18d74bf44fc95bc335e75e6a57dc974f6d6a3d603133594039fb589af2"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -5282,10 +5282,14 @@
5282 ** bytes in the string, not the number of characters.
5283 **
5284 ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
5285 ** even empty strings, are always zero-terminated. ^The return
5286 ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
 
 
 
 
5287 **
5288 ** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
5289 ** [unprotected sqlite3_value] object. In a multithreaded environment,
5290 ** an unprotected sqlite3_value object may only be used safely with
5291 ** [sqlite3_bind_value()] and [sqlite3_result_value()].
@@ -5296,11 +5300,11 @@
5296 ** Hence, the sqlite3_column_value() interface
5297 ** is normally only useful within the implementation of
5298 ** [application-defined SQL functions] or [virtual tables], not within
5299 ** top-level application code.
5300 **
5301 ** The these routines may attempt to convert the datatype of the result.
5302 ** ^For example, if the internal representation is FLOAT and a text result
5303 ** is requested, [sqlite3_snprintf()] is used internally to perform the
5304 ** conversion automatically. ^(The following table details the conversions
5305 ** that are applied:
5306 **
@@ -5321,11 +5325,11 @@
5321 ** <tr><td> TEXT <td> INTEGER <td> [CAST] to INTEGER
5322 ** <tr><td> TEXT <td> FLOAT <td> [CAST] to REAL
5323 ** <tr><td> TEXT <td> BLOB <td> No change
5324 ** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
5325 ** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
5326 ** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
5327 ** </table>
5328 ** </blockquote>)^
5329 **
5330 ** Note that when type conversions occur, pointers returned by prior
5331 ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
@@ -14515,11 +14519,11 @@
14515 ** one parameter that destructors normally want. So we have to introduce
14516 ** this magic value that the code knows to handle differently. Any
14517 ** pointer will work here as long as it is distinct from SQLITE_STATIC
14518 ** and SQLITE_TRANSIENT.
14519 */
14520 #define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3OomFault)
14521
14522 /*
14523 ** When SQLITE_OMIT_WSD is defined, it means that the target platform does
14524 ** not support Writable Static Data (WSD) such as global and static variables.
14525 ** All variables must either be on the stack or dynamically allocated from
@@ -19406,11 +19410,11 @@
19406 Expr *pStart; /* Expression for "<expr> PRECEDING" */
19407 Expr *pEnd; /* Expression for "<expr> FOLLOWING" */
19408 Window **ppThis; /* Pointer to this object in Select.pWin list */
19409 Window *pNextWin; /* Next window function belonging to this SELECT */
19410 Expr *pFilter; /* The FILTER expression */
19411 FuncDef *pFunc; /* The function */
19412 int iEphCsr; /* Partition buffer or Peer buffer */
19413 int regAccum; /* Accumulator */
19414 int regResult; /* Interim result */
19415 int csrApp; /* Function cursor (used by min/max) */
19416 int regApp; /* Function register (also used by min/max) */
@@ -20366,11 +20370,16 @@
20366 SQLITE_PRIVATE void sqlite3VtabArgExtend(Parse*, Token*);
20367 SQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);
20368 SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);
20369 SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
20370 SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);
 
20371 SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
 
 
 
 
20372 SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
20373 SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
20374 SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
20375 SQLITE_PRIVATE void sqlite3ParseObjectInit(Parse*,sqlite3*);
20376 SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse*);
@@ -21886,10 +21895,13 @@
21886 0, /* bLocaltimeFault */
21887 0, /* xAltLocaltime */
21888 0x7ffffffe, /* iOnceResetThreshold */
21889 SQLITE_DEFAULT_SORTERREF_SIZE, /* szSorterRef */
21890 0, /* iPrngSeed */
 
 
 
21891 };
21892
21893 /*
21894 ** Hash table for global functions - functions common to all
21895 ** database connections. After initialization, this table is
@@ -30870,11 +30882,11 @@
30870 memset(p, 0, sizeof(*p));
30871 }else{
30872 p->iLevel++;
30873 }
30874 assert( moreToFollow==0 || moreToFollow==1 );
30875 if( p->iLevel<sizeof(p->bLine) ) p->bLine[p->iLevel] = moreToFollow;
30876 return p;
30877 }
30878
30879 /*
30880 ** Finished with one layer of the tree
@@ -30894,11 +30906,11 @@
30894 int i;
30895 StrAccum acc;
30896 char zBuf[500];
30897 sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
30898 if( p ){
30899 for(i=0; i<p->iLevel && i<sizeof(p->bLine)-1; i++){
30900 sqlite3_str_append(&acc, p->bLine[i] ? "| " : " ", 4);
30901 }
30902 sqlite3_str_append(&acc, p->bLine[i] ? "|-- " : "'-- ", 4);
30903 }
30904 if( zFormat!=0 ){
@@ -31224,11 +31236,11 @@
31224 ** Generate a human-readable explanation for a Window Function object
31225 */
31226 SQLITE_PRIVATE void sqlite3TreeViewWinFunc(TreeView *pView, const Window *pWin, u8 more){
31227 pView = sqlite3TreeViewPush(pView, more);
31228 sqlite3TreeViewLine(pView, "WINFUNC %s(%d)",
31229 pWin->pFunc->zName, pWin->pFunc->nArg);
31230 sqlite3TreeViewWindow(pView, pWin, 0);
31231 sqlite3TreeViewPop(pView);
31232 }
31233 #endif /* SQLITE_OMIT_WINDOWFUNC */
31234
@@ -40820,24 +40832,27 @@
40820 ** "<path to db>-journalNN"
40821 ** "<path to db>-walNN"
40822 **
40823 ** where NN is a decimal number. The NN naming schemes are
40824 ** used by the test_multiplex.c module.
 
 
 
 
 
 
40825 */
40826 nDb = sqlite3Strlen30(zPath) - 1;
40827 while( zPath[nDb]!='-' ){
40828 /* In normal operation, the journal file name will always contain
40829 ** a '-' character. However in 8+3 filename mode, or if a corrupt
40830 ** rollback journal specifies a super-journal with a goofy name, then
40831 ** the '-' might be missing. */
40832 if( nDb==0 || zPath[nDb]=='.' ) return SQLITE_OK;
 
40833 nDb--;
40834 }
40835 memcpy(zDb, zPath, nDb);
40836 zDb[nDb] = '\0';
40837
40838 rc = getFileMode(zDb, pMode, pUid, pGid);
40839 }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){
40840 *pMode = 0600;
40841 }else if( flags & SQLITE_OPEN_URI ){
40842 /* If this is a main database file and the file was opened using a URI
40843 ** filename, check for the "modeof" parameter. If present, interpret
@@ -65443,11 +65458,11 @@
65443 u8 *apOvfl[4]; /* Pointers to the body of overflow cells */
65444 BtShared *pBt; /* Pointer to BtShared that this page is part of */
65445 u8 *aData; /* Pointer to disk image of the page data */
65446 u8 *aDataEnd; /* One byte past the end of the entire page - not just
65447 ** the usable space, the entire page. Used to prevent
65448 ** corruption-induced of buffer overflow. */
65449 u8 *aCellIdx; /* The cell index area */
65450 u8 *aDataOfst; /* Same as aData for leaves. aData+4 for interior */
65451 DbPage *pDbPage; /* Pager page handle */
65452 u16 (*xCellSize)(MemPage*,u8*); /* cellSizePtr method */
65453 void (*xParseCell)(MemPage*,u8*,CellInfo*); /* btreeParseCell method */
@@ -66389,11 +66404,11 @@
66389 if( isIndex ){
66390 HashElem *p;
66391 int bSeen = 0;
66392 for(p=sqliteHashFirst(&pSchema->idxHash); p; p=sqliteHashNext(p)){
66393 Index *pIdx = (Index *)sqliteHashData(p);
66394 if( pIdx->tnum==(int)iRoot ){
66395 if( bSeen ){
66396 /* Two or more indexes share the same root page. There must
66397 ** be imposter tables. So just return true. The assert is not
66398 ** useful in that case. */
66399 return 1;
@@ -72005,20 +72020,23 @@
72005 && cursorOnLastPage(pCur)
72006 ){
72007 int c;
72008 if( pCur->ix==pCur->pPage->nCell-1
72009 && (c = indexCellCompare(pCur, pCur->ix, pIdxKey, xRecordCompare))<=0
 
72010 ){
72011 *pRes = c;
72012 return SQLITE_OK; /* Cursor already pointing at the correct spot */
72013 }
72014 if( pCur->iPage>0
72015 && (c = indexCellCompare(pCur, 0, pIdxKey, xRecordCompare))<=0
 
72016 ){
72017 pCur->curFlags &= ~BTCF_ValidOvfl;
72018 goto bypass_moveto_root; /* Start search on the current page */
72019 }
 
72020 }
72021
72022 rc = moveToRoot(pCur);
72023 if( rc ){
72024 if( rc==SQLITE_EMPTY ){
@@ -80155,11 +80173,11 @@
80155 if( nNew > p->db->aLimit[SQLITE_LIMIT_VDBE_OP] ){
80156 sqlite3OomFault(p->db);
80157 return SQLITE_NOMEM;
80158 }
80159
80160 assert( nOp<=(1024/sizeof(Op)) );
80161 assert( nNew>=(v->nOpAlloc+nOp) );
80162 pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op));
80163 if( pNew ){
80164 p->szOpAlloc = sqlite3DbMallocSize(p->db, pNew);
80165 v->nOpAlloc = p->szOpAlloc/sizeof(Op);
@@ -110148,23 +110166,25 @@
110148 const char *zSql, /* SQL to parse */
110149 int bTemp /* True if SQL is from temp schema */
110150 ){
110151 int rc;
110152
110153 db->init.iDb = bTemp ? 1 : sqlite3FindDbName(db, zDb);
110154
110155 /* Parse the SQL statement passed as the first argument. If no error
110156 ** occurs and the parse does not result in a new table, index or
110157 ** trigger object, the database must be corrupt. */
110158 sqlite3ParseObjectInit(p, db);
 
 
 
 
 
 
 
110159 p->eParseMode = PARSE_MODE_RENAME;
110160 p->db = db;
110161 p->nQueryLoop = 1;
110162 rc = zSql ? sqlite3RunParser(p, zSql) : SQLITE_NOMEM;
110163 if( db->mallocFailed ) rc = SQLITE_NOMEM;
110164 if( rc==SQLITE_OK
110165 && p->pNewTable==0 && p->pNewIndex==0 && p->pNewTrigger==0
110166 ){
110167 rc = SQLITE_CORRUPT_BKPT;
110168 }
110169
110170 #ifdef SQLITE_DEBUG
@@ -116909,10 +116929,15 @@
116909 int regRec; /* A record to be insert into the new table */
116910 int regRowid; /* Rowid of the next row to insert */
116911 int addrInsLoop; /* Top of the loop for inserting rows */
116912 Table *pSelTab; /* A table that describes the SELECT results */
116913
 
 
 
 
 
116914 regYield = ++pParse->nMem;
116915 regRec = ++pParse->nMem;
116916 regRowid = ++pParse->nMem;
116917 assert(pParse->nTab==1);
116918 sqlite3MayAbort(pParse);
@@ -127394,11 +127419,11 @@
127394 }
127395 }
127396 if( isUpdate ){
127397 /* If currently processing the PRIMARY KEY of a WITHOUT ROWID
127398 ** table, only conflict if the new PRIMARY KEY values are actually
127399 ** different from the old.
127400 **
127401 ** For a UNIQUE index, only conflict if the PRIMARY KEY values
127402 ** of the matched index row are different from the original PRIMARY
127403 ** KEY values of this row before the update. */
127404 int addrJump = sqlite3VdbeCurrentAddr(v)+pPk->nKeyCol;
@@ -155956,11 +155981,10 @@
155956 }
155957
155958 return rc;
155959 }
155960
155961
155962 /*
155963 ** Return true if ORDER BY clause may be handled as DISTINCT.
155964 */
155965 SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info *pIdxInfo){
155966 HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
@@ -155967,10 +155991,26 @@
155967 assert( pHidden->eDistinct==0
155968 || pHidden->eDistinct==1
155969 || pHidden->eDistinct==2 );
155970 return pHidden->eDistinct;
155971 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155972
155973 /*
155974 ** Add all WhereLoop objects for a table of the join identified by
155975 ** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table.
155976 **
@@ -158327,10 +158367,14 @@
158327 assert( pIdx->pTable==pTab );
158328 if( !HasRowid(pTab) ){
158329 Index *pPk = sqlite3PrimaryKeyIndex(pTab);
158330 x = pPk->aiColumn[x];
158331 assert( x>=0 );
 
 
 
 
158332 }else{
158333 testcase( x!=sqlite3StorageColumnToTable(pTab,x) );
158334 x = sqlite3StorageColumnToTable(pTab,x);
158335 }
158336 x = sqlite3TableColumnToIndex(pIdx, x);
@@ -159093,11 +159137,11 @@
159093 break;
159094 }
159095 }
159096 }
159097 }
159098 pWin->pFunc = pFunc;
159099 }
159100
159101 /*
159102 ** Context object passed through sqlite3WalkExprList() to
159103 ** selectWindowRewriteExprCb() by selectWindowRewriteEList().
@@ -159326,11 +159370,15 @@
159326 ** are invoked in the correct order as described under "SELECT REWRITING"
159327 ** at the top of this file.
159328 */
159329 SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
159330 int rc = SQLITE_OK;
159331 if( p->pWin && p->pPrior==0 && ALWAYS((p->selFlags & SF_WinRewrite)==0) ){
 
 
 
 
159332 Vdbe *v = sqlite3GetVdbe(pParse);
159333 sqlite3 *db = pParse->db;
159334 Select *pSub = 0; /* The subquery */
159335 SrcList *pSrc = p->pSrc;
159336 Expr *pWhere = p->pWhere;
@@ -159401,12 +159449,13 @@
159401 ** window function - one for the accumulator, another for interim
159402 ** results. */
159403 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
159404 ExprList *pArgs;
159405 assert( ExprUseXList(pWin->pOwner) );
 
159406 pArgs = pWin->pOwner->x.pList;
159407 if( pWin->pFunc->funcFlags & SQLITE_FUNC_SUBTYPE ){
159408 selectWindowRewriteEList(pParse, pMWin, pSrc, pArgs, pTab, &pSublist);
159409 pWin->iArgCol = (pSublist ? pSublist->nExpr : 0);
159410 pWin->bExprArgs = 1;
159411 }else{
159412 pWin->iArgCol = (pSublist ? pSublist->nExpr : 0);
@@ -159784,11 +159833,11 @@
159784 sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->csrApp, pMWin->iEphCsr);
159785 return;
159786 }
159787
159788 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
159789 FuncDef *p = pWin->pFunc;
159790 if( (p->funcFlags & SQLITE_FUNC_MINMAX) && pWin->eStart!=TK_UNBOUNDED ){
159791 /* The inline versions of min() and max() require a single ephemeral
159792 ** table and 3 registers. The registers are used as follows:
159793 **
159794 ** regApp+0: slot to copy min()/max() argument to for MakeRecord
@@ -159801,11 +159850,11 @@
159801 pList = pWin->pOwner->x.pList;
159802 pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pList, 0, 0);
159803 pWin->csrApp = pParse->nTab++;
159804 pWin->regApp = pParse->nMem+1;
159805 pParse->nMem += 3;
159806 if( pKeyInfo && pWin->pFunc->zName[1]=='i' ){
159807 assert( pKeyInfo->aSortFlags[0]==0 );
159808 pKeyInfo->aSortFlags[0] = KEYINFO_ORDER_DESC;
159809 }
159810 sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pWin->csrApp, 2);
159811 sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO);
@@ -160024,11 +160073,11 @@
160024 ){
160025 Parse *pParse = p->pParse;
160026 Vdbe *v = sqlite3GetVdbe(pParse);
160027 Window *pWin;
160028 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
160029 FuncDef *pFunc = pWin->pFunc;
160030 int regArg;
160031 int nArg = pWin->bExprArgs ? 0 : windowArgCount(pWin);
160032 int i;
160033
160034 assert( bInverse==0 || pWin->eStart!=TK_UNBOUNDED );
@@ -160138,11 +160187,11 @@
160138 Vdbe *v = sqlite3GetVdbe(pParse);
160139 Window *pWin;
160140
160141 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
160142 if( pMWin->regStartRowid==0
160143 && (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX)
160144 && (pWin->eStart!=TK_UNBOUNDED)
160145 ){
160146 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
160147 sqlite3VdbeAddOp1(v, OP_Last, pWin->csrApp);
160148 VdbeCoverage(v);
@@ -160152,16 +160201,16 @@
160152 assert( pMWin->regStartRowid==0 );
160153 }else{
160154 int nArg = windowArgCount(pWin);
160155 if( bFin ){
160156 sqlite3VdbeAddOp2(v, OP_AggFinal, pWin->regAccum, nArg);
160157 sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
160158 sqlite3VdbeAddOp2(v, OP_Copy, pWin->regAccum, pWin->regResult);
160159 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
160160 }else{
160161 sqlite3VdbeAddOp3(v, OP_AggValue,pWin->regAccum,nArg,pWin->regResult);
160162 sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
160163 }
160164 }
160165 }
160166 }
160167
@@ -160286,11 +160335,11 @@
160286 }else{
160287 Parse *pParse = p->pParse;
160288 Window *pWin;
160289
160290 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
160291 FuncDef *pFunc = pWin->pFunc;
160292 assert( ExprUseXList(pWin->pOwner) );
160293 if( pFunc->zName==nth_valueName
160294 || pFunc->zName==first_valueName
160295 ){
160296 int csr = pWin->csrApp;
@@ -160358,11 +160407,11 @@
160358 Vdbe *v = sqlite3GetVdbe(pParse);
160359 int regArg;
160360 int nArg = 0;
160361 Window *pWin;
160362 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
160363 FuncDef *pFunc = pWin->pFunc;
160364 assert( pWin->regAccum );
160365 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
160366 nArg = MAX(nArg, windowArgCount(pWin));
160367 if( pMWin->regStartRowid==0 ){
160368 if( pFunc->zName==nth_valueName || pFunc->zName==first_valueName ){
@@ -160388,11 +160437,11 @@
160388 */
160389 static int windowCacheFrame(Window *pMWin){
160390 Window *pWin;
160391 if( pMWin->regStartRowid ) return 1;
160392 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
160393 FuncDef *pFunc = pWin->pFunc;
160394 if( (pFunc->zName==nth_valueName)
160395 || (pFunc->zName==first_valueName)
160396 || (pFunc->zName==leadName)
160397 || (pFunc->zName==lagName)
160398 ){
@@ -160746,11 +160795,11 @@
160746 pNew = sqlite3DbMallocZero(db, sizeof(Window));
160747 if( pNew ){
160748 pNew->zName = sqlite3DbStrDup(db, p->zName);
160749 pNew->zBase = sqlite3DbStrDup(db, p->zBase);
160750 pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);
160751 pNew->pFunc = p->pFunc;
160752 pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);
160753 pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);
160754 pNew->eFrmType = p->eFrmType;
160755 pNew->eEnd = p->eEnd;
160756 pNew->eStart = p->eStart;
@@ -172983,14 +173032,16 @@
172983 ** Test access for the LogEst conversion routines.
172984 */
172985 case SQLITE_TESTCTRL_LOGEST: {
172986 double rIn = va_arg(ap, double);
172987 LogEst rLogEst = sqlite3LogEstFromDouble(rIn);
172988 u64 iInt = sqlite3LogEstToInt(rLogEst);
172989 va_arg(ap, int*)[0] = rLogEst;
172990 va_arg(ap, u64*)[0] = iInt;
172991 va_arg(ap, int*)[0] = sqlite3LogEst(iInt);
 
 
172992 break;
172993 }
172994
172995
172996 #if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_WSD)
@@ -194917,11 +194968,11 @@
194917 u32 iRoot;
194918 JsonNode *pTarget;
194919 if( pPatch->eType!=JSON_OBJECT ){
194920 return pPatch;
194921 }
194922 assert( iTarget>=0 && iTarget<pParse->nNode );
194923 pTarget = &pParse->aNode[iTarget];
194924 assert( (pPatch->jnFlags & JNODE_APPEND)==0 );
194925 if( pTarget->eType!=JSON_OBJECT ){
194926 jsonRemoveAllNulls(pPatch);
194927 return pPatch;
@@ -210212,10 +210263,11 @@
210212 && pIdxInfo->aOrderBy[0].iColumn<=0
210213 && pIdxInfo->aOrderBy[0].desc==0
210214 ){
210215 pIdxInfo->orderByConsumed = 1;
210216 }
 
210217 return SQLITE_OK;
210218 }
210219
210220 /*
210221 ** Open a new dbpagevfs cursor.
@@ -210389,11 +210441,11 @@
210389 if( iDb<0 ){
210390 zErr = "no such schema";
210391 goto update_fail;
210392 }
210393 pBt = pTab->db->aDb[iDb].pBt;
210394 if( pgno<1 || pBt==0 || pgno>(int)sqlite3BtreeLastPage(pBt) ){
210395 zErr = "bad page number";
210396 goto update_fail;
210397 }
210398 szPage = sqlite3BtreeGetPageSize(pBt);
210399 if( sqlite3_value_type(argv[3])!=SQLITE_BLOB
@@ -232566,11 +232618,11 @@
232566 int rc;
232567
232568 rc = sqlite3_step(pSorter->pStmt);
232569 if( rc==SQLITE_DONE ){
232570 rc = SQLITE_OK;
232571 CsrFlagSet(pCsr, FTS5CSR_EOF);
232572 }else if( rc==SQLITE_ROW ){
232573 const u8 *a;
232574 const u8 *aBlob;
232575 int nBlob;
232576 int i;
@@ -234555,11 +234607,11 @@
234555 int nArg, /* Number of args */
234556 sqlite3_value **apUnused /* Function arguments */
234557 ){
234558 assert( nArg==0 );
234559 UNUSED_PARAM2(nArg, apUnused);
234560 sqlite3_result_text(pCtx, "fts5: 2022-03-07 18:32:08 ae464a18d74bf44fc95bc335e75e6a57dc974f6d6a3d603133594039fb589af2", -1, SQLITE_TRANSIENT);
234561 }
234562
234563 /*
234564 ** Return true if zName is the extension on one of the shadow tables used
234565 ** by this module.
234566
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -452,11 +452,11 @@
452 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453 ** [sqlite_version()] and [sqlite_source_id()].
454 */
455 #define SQLITE_VERSION "3.39.0"
456 #define SQLITE_VERSION_NUMBER 3039000
457 #define SQLITE_SOURCE_ID "2022-03-11 15:42:05 0606e8e93edb5de4d154f377dbf91f15295d25ca9013c0f1612ae6d63a0139ea"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -5282,10 +5282,14 @@
5282 ** bytes in the string, not the number of characters.
5283 **
5284 ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
5285 ** even empty strings, are always zero-terminated. ^The return
5286 ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
5287 **
5288 ** ^Strings returned by sqlite3_column_text16() always have the endianness
5289 ** which is native to the platform, regardless of the text encoding set
5290 ** for the database.
5291 **
5292 ** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
5293 ** [unprotected sqlite3_value] object. In a multithreaded environment,
5294 ** an unprotected sqlite3_value object may only be used safely with
5295 ** [sqlite3_bind_value()] and [sqlite3_result_value()].
@@ -5296,11 +5300,11 @@
5300 ** Hence, the sqlite3_column_value() interface
5301 ** is normally only useful within the implementation of
5302 ** [application-defined SQL functions] or [virtual tables], not within
5303 ** top-level application code.
5304 **
5305 ** These routines may attempt to convert the datatype of the result.
5306 ** ^For example, if the internal representation is FLOAT and a text result
5307 ** is requested, [sqlite3_snprintf()] is used internally to perform the
5308 ** conversion automatically. ^(The following table details the conversions
5309 ** that are applied:
5310 **
@@ -5321,11 +5325,11 @@
5325 ** <tr><td> TEXT <td> INTEGER <td> [CAST] to INTEGER
5326 ** <tr><td> TEXT <td> FLOAT <td> [CAST] to REAL
5327 ** <tr><td> TEXT <td> BLOB <td> No change
5328 ** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
5329 ** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
5330 ** <tr><td> BLOB <td> TEXT <td> [CAST] to TEXT, ensure zero terminator
5331 ** </table>
5332 ** </blockquote>)^
5333 **
5334 ** Note that when type conversions occur, pointers returned by prior
5335 ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
@@ -14515,11 +14519,11 @@
14519 ** one parameter that destructors normally want. So we have to introduce
14520 ** this magic value that the code knows to handle differently. Any
14521 ** pointer will work here as long as it is distinct from SQLITE_STATIC
14522 ** and SQLITE_TRANSIENT.
14523 */
14524 #define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3OomClear)
14525
14526 /*
14527 ** When SQLITE_OMIT_WSD is defined, it means that the target platform does
14528 ** not support Writable Static Data (WSD) such as global and static variables.
14529 ** All variables must either be on the stack or dynamically allocated from
@@ -19406,11 +19410,11 @@
19410 Expr *pStart; /* Expression for "<expr> PRECEDING" */
19411 Expr *pEnd; /* Expression for "<expr> FOLLOWING" */
19412 Window **ppThis; /* Pointer to this object in Select.pWin list */
19413 Window *pNextWin; /* Next window function belonging to this SELECT */
19414 Expr *pFilter; /* The FILTER expression */
19415 FuncDef *pWFunc; /* The function */
19416 int iEphCsr; /* Partition buffer or Peer buffer */
19417 int regAccum; /* Accumulator */
19418 int regResult; /* Interim result */
19419 int csrApp; /* Function cursor (used by min/max) */
19420 int regApp; /* Function register (also used by min/max) */
@@ -20366,11 +20370,16 @@
20370 SQLITE_PRIVATE void sqlite3VtabArgExtend(Parse*, Token*);
20371 SQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);
20372 SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);
20373 SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
20374 SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);
20375
20376 SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
20377 #if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
20378 && !defined(SQLITE_OMIT_VIRTUALTABLE)
20379 SQLITE_PRIVATE void sqlite3VtabWriteAll(sqlite3_index_info*);
20380 #endif
20381 SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
20382 SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
20383 SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
20384 SQLITE_PRIVATE void sqlite3ParseObjectInit(Parse*,sqlite3*);
20385 SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse*);
@@ -21886,10 +21895,13 @@
21895 0, /* bLocaltimeFault */
21896 0, /* xAltLocaltime */
21897 0x7ffffffe, /* iOnceResetThreshold */
21898 SQLITE_DEFAULT_SORTERREF_SIZE, /* szSorterRef */
21899 0, /* iPrngSeed */
21900 #ifdef SQLITE_DEBUG
21901 {0,0,0,0,0,0} /* aTune */
21902 #endif
21903 };
21904
21905 /*
21906 ** Hash table for global functions - functions common to all
21907 ** database connections. After initialization, this table is
@@ -30870,11 +30882,11 @@
30882 memset(p, 0, sizeof(*p));
30883 }else{
30884 p->iLevel++;
30885 }
30886 assert( moreToFollow==0 || moreToFollow==1 );
30887 if( p->iLevel<(int)sizeof(p->bLine) ) p->bLine[p->iLevel] = moreToFollow;
30888 return p;
30889 }
30890
30891 /*
30892 ** Finished with one layer of the tree
@@ -30894,11 +30906,11 @@
30906 int i;
30907 StrAccum acc;
30908 char zBuf[500];
30909 sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
30910 if( p ){
30911 for(i=0; i<p->iLevel && i<(int)sizeof(p->bLine)-1; i++){
30912 sqlite3_str_append(&acc, p->bLine[i] ? "| " : " ", 4);
30913 }
30914 sqlite3_str_append(&acc, p->bLine[i] ? "|-- " : "'-- ", 4);
30915 }
30916 if( zFormat!=0 ){
@@ -31224,11 +31236,11 @@
31236 ** Generate a human-readable explanation for a Window Function object
31237 */
31238 SQLITE_PRIVATE void sqlite3TreeViewWinFunc(TreeView *pView, const Window *pWin, u8 more){
31239 pView = sqlite3TreeViewPush(pView, more);
31240 sqlite3TreeViewLine(pView, "WINFUNC %s(%d)",
31241 pWin->pWFunc->zName, pWin->pWFunc->nArg);
31242 sqlite3TreeViewWindow(pView, pWin, 0);
31243 sqlite3TreeViewPop(pView);
31244 }
31245 #endif /* SQLITE_OMIT_WINDOWFUNC */
31246
@@ -40820,24 +40832,27 @@
40832 ** "<path to db>-journalNN"
40833 ** "<path to db>-walNN"
40834 **
40835 ** where NN is a decimal number. The NN naming schemes are
40836 ** used by the test_multiplex.c module.
40837 **
40838 ** In normal operation, the journal file name will always contain
40839 ** a '-' character. However in 8+3 filename mode, or if a corrupt
40840 ** rollback journal specifies a super-journal with a goofy name, then
40841 ** the '-' might be missing or the '-' might be the first character in
40842 ** the filename. In that case, just return SQLITE_OK with *pMode==0.
40843 */
40844 nDb = sqlite3Strlen30(zPath) - 1;
40845 while( nDb>0 && zPath[nDb]!='.' ){
40846 if( zPath[nDb]=='-' ){
40847 memcpy(zDb, zPath, nDb);
40848 zDb[nDb] = '\0';
40849 rc = getFileMode(zDb, pMode, pUid, pGid);
40850 break;
40851 }
40852 nDb--;
40853 }
 
 
 
 
40854 }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){
40855 *pMode = 0600;
40856 }else if( flags & SQLITE_OPEN_URI ){
40857 /* If this is a main database file and the file was opened using a URI
40858 ** filename, check for the "modeof" parameter. If present, interpret
@@ -65443,11 +65458,11 @@
65458 u8 *apOvfl[4]; /* Pointers to the body of overflow cells */
65459 BtShared *pBt; /* Pointer to BtShared that this page is part of */
65460 u8 *aData; /* Pointer to disk image of the page data */
65461 u8 *aDataEnd; /* One byte past the end of the entire page - not just
65462 ** the usable space, the entire page. Used to prevent
65463 ** corruption-induced buffer overflow. */
65464 u8 *aCellIdx; /* The cell index area */
65465 u8 *aDataOfst; /* Same as aData for leaves. aData+4 for interior */
65466 DbPage *pDbPage; /* Pager page handle */
65467 u16 (*xCellSize)(MemPage*,u8*); /* cellSizePtr method */
65468 void (*xParseCell)(MemPage*,u8*,CellInfo*); /* btreeParseCell method */
@@ -66389,11 +66404,11 @@
66404 if( isIndex ){
66405 HashElem *p;
66406 int bSeen = 0;
66407 for(p=sqliteHashFirst(&pSchema->idxHash); p; p=sqliteHashNext(p)){
66408 Index *pIdx = (Index *)sqliteHashData(p);
66409 if( pIdx->tnum==iRoot ){
66410 if( bSeen ){
66411 /* Two or more indexes share the same root page. There must
66412 ** be imposter tables. So just return true. The assert is not
66413 ** useful in that case. */
66414 return 1;
@@ -72005,20 +72020,23 @@
72020 && cursorOnLastPage(pCur)
72021 ){
72022 int c;
72023 if( pCur->ix==pCur->pPage->nCell-1
72024 && (c = indexCellCompare(pCur, pCur->ix, pIdxKey, xRecordCompare))<=0
72025 && pIdxKey->errCode==SQLITE_OK
72026 ){
72027 *pRes = c;
72028 return SQLITE_OK; /* Cursor already pointing at the correct spot */
72029 }
72030 if( pCur->iPage>0
72031 && indexCellCompare(pCur, 0, pIdxKey, xRecordCompare)<=0
72032 && pIdxKey->errCode==SQLITE_OK
72033 ){
72034 pCur->curFlags &= ~BTCF_ValidOvfl;
72035 goto bypass_moveto_root; /* Start search on the current page */
72036 }
72037 pIdxKey->errCode = SQLITE_OK;
72038 }
72039
72040 rc = moveToRoot(pCur);
72041 if( rc ){
72042 if( rc==SQLITE_EMPTY ){
@@ -80155,11 +80173,11 @@
80173 if( nNew > p->db->aLimit[SQLITE_LIMIT_VDBE_OP] ){
80174 sqlite3OomFault(p->db);
80175 return SQLITE_NOMEM;
80176 }
80177
80178 assert( nOp<=(int)(1024/sizeof(Op)) );
80179 assert( nNew>=(v->nOpAlloc+nOp) );
80180 pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op));
80181 if( pNew ){
80182 p->szOpAlloc = sqlite3DbMallocSize(p->db, pNew);
80183 v->nOpAlloc = p->szOpAlloc/sizeof(Op);
@@ -110148,23 +110166,25 @@
110166 const char *zSql, /* SQL to parse */
110167 int bTemp /* True if SQL is from temp schema */
110168 ){
110169 int rc;
110170
 
 
 
 
 
110171 sqlite3ParseObjectInit(p, db);
110172 if( zSql==0 ){
110173 return SQLITE_NOMEM;
110174 }
110175 if( sqlite3StrNICmp(zSql,"CREATE ",7)!=0 ){
110176 return SQLITE_CORRUPT_BKPT;
110177 }
110178 db->init.iDb = bTemp ? 1 : sqlite3FindDbName(db, zDb);
110179 p->eParseMode = PARSE_MODE_RENAME;
110180 p->db = db;
110181 p->nQueryLoop = 1;
110182 rc = sqlite3RunParser(p, zSql);
110183 if( db->mallocFailed ) rc = SQLITE_NOMEM;
110184 if( rc==SQLITE_OK
110185 && NEVER(p->pNewTable==0 && p->pNewIndex==0 && p->pNewTrigger==0)
110186 ){
110187 rc = SQLITE_CORRUPT_BKPT;
110188 }
110189
110190 #ifdef SQLITE_DEBUG
@@ -116909,10 +116929,15 @@
116929 int regRec; /* A record to be insert into the new table */
116930 int regRowid; /* Rowid of the next row to insert */
116931 int addrInsLoop; /* Top of the loop for inserting rows */
116932 Table *pSelTab; /* A table that describes the SELECT results */
116933
116934 if( IN_SPECIAL_PARSE ){
116935 pParse->rc = SQLITE_ERROR;
116936 pParse->nErr++;
116937 return;
116938 }
116939 regYield = ++pParse->nMem;
116940 regRec = ++pParse->nMem;
116941 regRowid = ++pParse->nMem;
116942 assert(pParse->nTab==1);
116943 sqlite3MayAbort(pParse);
@@ -127394,11 +127419,11 @@
127419 }
127420 }
127421 if( isUpdate ){
127422 /* If currently processing the PRIMARY KEY of a WITHOUT ROWID
127423 ** table, only conflict if the new PRIMARY KEY values are actually
127424 ** different from the old. See TH3 withoutrowid04.test.
127425 **
127426 ** For a UNIQUE index, only conflict if the PRIMARY KEY values
127427 ** of the matched index row are different from the original PRIMARY
127428 ** KEY values of this row before the update. */
127429 int addrJump = sqlite3VdbeCurrentAddr(v)+pPk->nKeyCol;
@@ -155956,11 +155981,10 @@
155981 }
155982
155983 return rc;
155984 }
155985
 
155986 /*
155987 ** Return true if ORDER BY clause may be handled as DISTINCT.
155988 */
155989 SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info *pIdxInfo){
155990 HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
@@ -155967,10 +155991,26 @@
155991 assert( pHidden->eDistinct==0
155992 || pHidden->eDistinct==1
155993 || pHidden->eDistinct==2 );
155994 return pHidden->eDistinct;
155995 }
155996
155997 #if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
155998 && !defined(SQLITE_OMIT_VIRTUALTABLE)
155999 /*
156000 ** Cause the prepared statement that is associated with a call to
156001 ** xBestIndex to open write transactions on all attached schemas.
156002 ** This is used by the (built-in) sqlite_dbpage virtual table.
156003 */
156004 SQLITE_PRIVATE void sqlite3VtabWriteAll(sqlite3_index_info *pIdxInfo){
156005 HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
156006 Parse *pParse = pHidden->pParse;
156007 int nDb = pParse->db->nDb;
156008 int i;
156009 for(i=0; i<nDb; i++) sqlite3BeginWriteOperation(pParse, 0, i);
156010 }
156011 #endif
156012
156013 /*
156014 ** Add all WhereLoop objects for a table of the join identified by
156015 ** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table.
156016 **
@@ -158327,10 +158367,14 @@
158367 assert( pIdx->pTable==pTab );
158368 if( !HasRowid(pTab) ){
158369 Index *pPk = sqlite3PrimaryKeyIndex(pTab);
158370 x = pPk->aiColumn[x];
158371 assert( x>=0 );
158372 #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
158373 }else if( pOp->opcode==OP_Offset ){
158374 /* Do not need to translate the column number */
158375 #endif
158376 }else{
158377 testcase( x!=sqlite3StorageColumnToTable(pTab,x) );
158378 x = sqlite3StorageColumnToTable(pTab,x);
158379 }
158380 x = sqlite3TableColumnToIndex(pIdx, x);
@@ -159093,11 +159137,11 @@
159137 break;
159138 }
159139 }
159140 }
159141 }
159142 pWin->pWFunc = pFunc;
159143 }
159144
159145 /*
159146 ** Context object passed through sqlite3WalkExprList() to
159147 ** selectWindowRewriteExprCb() by selectWindowRewriteEList().
@@ -159326,11 +159370,15 @@
159370 ** are invoked in the correct order as described under "SELECT REWRITING"
159371 ** at the top of this file.
159372 */
159373 SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
159374 int rc = SQLITE_OK;
159375 if( p->pWin
159376 && p->pPrior==0
159377 && ALWAYS((p->selFlags & SF_WinRewrite)==0)
159378 && ALWAYS(!IN_RENAME_OBJECT)
159379 ){
159380 Vdbe *v = sqlite3GetVdbe(pParse);
159381 sqlite3 *db = pParse->db;
159382 Select *pSub = 0; /* The subquery */
159383 SrcList *pSrc = p->pSrc;
159384 Expr *pWhere = p->pWhere;
@@ -159401,12 +159449,13 @@
159449 ** window function - one for the accumulator, another for interim
159450 ** results. */
159451 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
159452 ExprList *pArgs;
159453 assert( ExprUseXList(pWin->pOwner) );
159454 assert( pWin->pWFunc!=0 );
159455 pArgs = pWin->pOwner->x.pList;
159456 if( pWin->pWFunc->funcFlags & SQLITE_FUNC_SUBTYPE ){
159457 selectWindowRewriteEList(pParse, pMWin, pSrc, pArgs, pTab, &pSublist);
159458 pWin->iArgCol = (pSublist ? pSublist->nExpr : 0);
159459 pWin->bExprArgs = 1;
159460 }else{
159461 pWin->iArgCol = (pSublist ? pSublist->nExpr : 0);
@@ -159784,11 +159833,11 @@
159833 sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->csrApp, pMWin->iEphCsr);
159834 return;
159835 }
159836
159837 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
159838 FuncDef *p = pWin->pWFunc;
159839 if( (p->funcFlags & SQLITE_FUNC_MINMAX) && pWin->eStart!=TK_UNBOUNDED ){
159840 /* The inline versions of min() and max() require a single ephemeral
159841 ** table and 3 registers. The registers are used as follows:
159842 **
159843 ** regApp+0: slot to copy min()/max() argument to for MakeRecord
@@ -159801,11 +159850,11 @@
159850 pList = pWin->pOwner->x.pList;
159851 pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pList, 0, 0);
159852 pWin->csrApp = pParse->nTab++;
159853 pWin->regApp = pParse->nMem+1;
159854 pParse->nMem += 3;
159855 if( pKeyInfo && pWin->pWFunc->zName[1]=='i' ){
159856 assert( pKeyInfo->aSortFlags[0]==0 );
159857 pKeyInfo->aSortFlags[0] = KEYINFO_ORDER_DESC;
159858 }
159859 sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pWin->csrApp, 2);
159860 sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO);
@@ -160024,11 +160073,11 @@
160073 ){
160074 Parse *pParse = p->pParse;
160075 Vdbe *v = sqlite3GetVdbe(pParse);
160076 Window *pWin;
160077 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
160078 FuncDef *pFunc = pWin->pWFunc;
160079 int regArg;
160080 int nArg = pWin->bExprArgs ? 0 : windowArgCount(pWin);
160081 int i;
160082
160083 assert( bInverse==0 || pWin->eStart!=TK_UNBOUNDED );
@@ -160138,11 +160187,11 @@
160187 Vdbe *v = sqlite3GetVdbe(pParse);
160188 Window *pWin;
160189
160190 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
160191 if( pMWin->regStartRowid==0
160192 && (pWin->pWFunc->funcFlags & SQLITE_FUNC_MINMAX)
160193 && (pWin->eStart!=TK_UNBOUNDED)
160194 ){
160195 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
160196 sqlite3VdbeAddOp1(v, OP_Last, pWin->csrApp);
160197 VdbeCoverage(v);
@@ -160152,16 +160201,16 @@
160201 assert( pMWin->regStartRowid==0 );
160202 }else{
160203 int nArg = windowArgCount(pWin);
160204 if( bFin ){
160205 sqlite3VdbeAddOp2(v, OP_AggFinal, pWin->regAccum, nArg);
160206 sqlite3VdbeAppendP4(v, pWin->pWFunc, P4_FUNCDEF);
160207 sqlite3VdbeAddOp2(v, OP_Copy, pWin->regAccum, pWin->regResult);
160208 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
160209 }else{
160210 sqlite3VdbeAddOp3(v, OP_AggValue,pWin->regAccum,nArg,pWin->regResult);
160211 sqlite3VdbeAppendP4(v, pWin->pWFunc, P4_FUNCDEF);
160212 }
160213 }
160214 }
160215 }
160216
@@ -160286,11 +160335,11 @@
160335 }else{
160336 Parse *pParse = p->pParse;
160337 Window *pWin;
160338
160339 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
160340 FuncDef *pFunc = pWin->pWFunc;
160341 assert( ExprUseXList(pWin->pOwner) );
160342 if( pFunc->zName==nth_valueName
160343 || pFunc->zName==first_valueName
160344 ){
160345 int csr = pWin->csrApp;
@@ -160358,11 +160407,11 @@
160407 Vdbe *v = sqlite3GetVdbe(pParse);
160408 int regArg;
160409 int nArg = 0;
160410 Window *pWin;
160411 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
160412 FuncDef *pFunc = pWin->pWFunc;
160413 assert( pWin->regAccum );
160414 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
160415 nArg = MAX(nArg, windowArgCount(pWin));
160416 if( pMWin->regStartRowid==0 ){
160417 if( pFunc->zName==nth_valueName || pFunc->zName==first_valueName ){
@@ -160388,11 +160437,11 @@
160437 */
160438 static int windowCacheFrame(Window *pMWin){
160439 Window *pWin;
160440 if( pMWin->regStartRowid ) return 1;
160441 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
160442 FuncDef *pFunc = pWin->pWFunc;
160443 if( (pFunc->zName==nth_valueName)
160444 || (pFunc->zName==first_valueName)
160445 || (pFunc->zName==leadName)
160446 || (pFunc->zName==lagName)
160447 ){
@@ -160746,11 +160795,11 @@
160795 pNew = sqlite3DbMallocZero(db, sizeof(Window));
160796 if( pNew ){
160797 pNew->zName = sqlite3DbStrDup(db, p->zName);
160798 pNew->zBase = sqlite3DbStrDup(db, p->zBase);
160799 pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);
160800 pNew->pWFunc = p->pWFunc;
160801 pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);
160802 pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);
160803 pNew->eFrmType = p->eFrmType;
160804 pNew->eEnd = p->eEnd;
160805 pNew->eStart = p->eStart;
@@ -172983,14 +173032,16 @@
173032 ** Test access for the LogEst conversion routines.
173033 */
173034 case SQLITE_TESTCTRL_LOGEST: {
173035 double rIn = va_arg(ap, double);
173036 LogEst rLogEst = sqlite3LogEstFromDouble(rIn);
173037 int *pI1 = va_arg(ap,int*);
173038 u64 *pU64 = va_arg(ap,u64*);
173039 int *pI2 = va_arg(ap,int*);
173040 *pI1 = rLogEst;
173041 *pU64 = sqlite3LogEstToInt(rLogEst);
173042 *pI2 = sqlite3LogEst(*pU64);
173043 break;
173044 }
173045
173046
173047 #if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_WSD)
@@ -194917,11 +194968,11 @@
194968 u32 iRoot;
194969 JsonNode *pTarget;
194970 if( pPatch->eType!=JSON_OBJECT ){
194971 return pPatch;
194972 }
194973 assert( iTarget<pParse->nNode );
194974 pTarget = &pParse->aNode[iTarget];
194975 assert( (pPatch->jnFlags & JNODE_APPEND)==0 );
194976 if( pTarget->eType!=JSON_OBJECT ){
194977 jsonRemoveAllNulls(pPatch);
194978 return pPatch;
@@ -210212,10 +210263,11 @@
210263 && pIdxInfo->aOrderBy[0].iColumn<=0
210264 && pIdxInfo->aOrderBy[0].desc==0
210265 ){
210266 pIdxInfo->orderByConsumed = 1;
210267 }
210268 sqlite3VtabWriteAll(pIdxInfo);
210269 return SQLITE_OK;
210270 }
210271
210272 /*
210273 ** Open a new dbpagevfs cursor.
@@ -210389,11 +210441,11 @@
210441 if( iDb<0 ){
210442 zErr = "no such schema";
210443 goto update_fail;
210444 }
210445 pBt = pTab->db->aDb[iDb].pBt;
210446 if( pgno<1 || pBt==0 || pgno>sqlite3BtreeLastPage(pBt) ){
210447 zErr = "bad page number";
210448 goto update_fail;
210449 }
210450 szPage = sqlite3BtreeGetPageSize(pBt);
210451 if( sqlite3_value_type(argv[3])!=SQLITE_BLOB
@@ -232566,11 +232618,11 @@
232618 int rc;
232619
232620 rc = sqlite3_step(pSorter->pStmt);
232621 if( rc==SQLITE_DONE ){
232622 rc = SQLITE_OK;
232623 CsrFlagSet(pCsr, FTS5CSR_EOF|FTS5CSR_REQUIRE_CONTENT);
232624 }else if( rc==SQLITE_ROW ){
232625 const u8 *a;
232626 const u8 *aBlob;
232627 int nBlob;
232628 int i;
@@ -234555,11 +234607,11 @@
234607 int nArg, /* Number of args */
234608 sqlite3_value **apUnused /* Function arguments */
234609 ){
234610 assert( nArg==0 );
234611 UNUSED_PARAM2(nArg, apUnused);
234612 sqlite3_result_text(pCtx, "fts5: 2022-03-11 15:42:05 0606e8e93edb5de4d154f377dbf91f15295d25ca9013c0f1612ae6d63a0139ea", -1, SQLITE_TRANSIENT);
234613 }
234614
234615 /*
234616 ** Return true if zName is the extension on one of the shadow tables used
234617 ** by this module.
234618
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.39.0"
150150
#define SQLITE_VERSION_NUMBER 3039000
151
-#define SQLITE_SOURCE_ID "2022-03-07 18:32:08 ae464a18d74bf44fc95bc335e75e6a57dc974f6d6a3d603133594039fb589af2"
151
+#define SQLITE_SOURCE_ID "2022-03-11 15:42:05 0606e8e93edb5de4d154f377dbf91f15295d25ca9013c0f1612ae6d63a0139ea"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
@@ -4976,10 +4976,14 @@
49764976
** bytes in the string, not the number of characters.
49774977
**
49784978
** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
49794979
** even empty strings, are always zero-terminated. ^The return
49804980
** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
4981
+**
4982
+** ^Strings returned by sqlite3_column_text16() always have the endianness
4983
+** which is native to the platform, regardless of the text encoding set
4984
+** for the database.
49814985
**
49824986
** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
49834987
** [unprotected sqlite3_value] object. In a multithreaded environment,
49844988
** an unprotected sqlite3_value object may only be used safely with
49854989
** [sqlite3_bind_value()] and [sqlite3_result_value()].
@@ -4990,11 +4994,11 @@
49904994
** Hence, the sqlite3_column_value() interface
49914995
** is normally only useful within the implementation of
49924996
** [application-defined SQL functions] or [virtual tables], not within
49934997
** top-level application code.
49944998
**
4995
-** The these routines may attempt to convert the datatype of the result.
4999
+** These routines may attempt to convert the datatype of the result.
49965000
** ^For example, if the internal representation is FLOAT and a text result
49975001
** is requested, [sqlite3_snprintf()] is used internally to perform the
49985002
** conversion automatically. ^(The following table details the conversions
49995003
** that are applied:
50005004
**
@@ -5015,11 +5019,11 @@
50155019
** <tr><td> TEXT <td> INTEGER <td> [CAST] to INTEGER
50165020
** <tr><td> TEXT <td> FLOAT <td> [CAST] to REAL
50175021
** <tr><td> TEXT <td> BLOB <td> No change
50185022
** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
50195023
** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
5020
-** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
5024
+** <tr><td> BLOB <td> TEXT <td> [CAST] to TEXT, ensure zero terminator
50215025
** </table>
50225026
** </blockquote>)^
50235027
**
50245028
** Note that when type conversions occur, pointers returned by prior
50255029
** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
50265030
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.39.0"
150 #define SQLITE_VERSION_NUMBER 3039000
151 #define SQLITE_SOURCE_ID "2022-03-07 18:32:08 ae464a18d74bf44fc95bc335e75e6a57dc974f6d6a3d603133594039fb589af2"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -4976,10 +4976,14 @@
4976 ** bytes in the string, not the number of characters.
4977 **
4978 ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
4979 ** even empty strings, are always zero-terminated. ^The return
4980 ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
 
 
 
 
4981 **
4982 ** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
4983 ** [unprotected sqlite3_value] object. In a multithreaded environment,
4984 ** an unprotected sqlite3_value object may only be used safely with
4985 ** [sqlite3_bind_value()] and [sqlite3_result_value()].
@@ -4990,11 +4994,11 @@
4990 ** Hence, the sqlite3_column_value() interface
4991 ** is normally only useful within the implementation of
4992 ** [application-defined SQL functions] or [virtual tables], not within
4993 ** top-level application code.
4994 **
4995 ** The these routines may attempt to convert the datatype of the result.
4996 ** ^For example, if the internal representation is FLOAT and a text result
4997 ** is requested, [sqlite3_snprintf()] is used internally to perform the
4998 ** conversion automatically. ^(The following table details the conversions
4999 ** that are applied:
5000 **
@@ -5015,11 +5019,11 @@
5015 ** <tr><td> TEXT <td> INTEGER <td> [CAST] to INTEGER
5016 ** <tr><td> TEXT <td> FLOAT <td> [CAST] to REAL
5017 ** <tr><td> TEXT <td> BLOB <td> No change
5018 ** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
5019 ** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
5020 ** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
5021 ** </table>
5022 ** </blockquote>)^
5023 **
5024 ** Note that when type conversions occur, pointers returned by prior
5025 ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
5026
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.39.0"
150 #define SQLITE_VERSION_NUMBER 3039000
151 #define SQLITE_SOURCE_ID "2022-03-11 15:42:05 0606e8e93edb5de4d154f377dbf91f15295d25ca9013c0f1612ae6d63a0139ea"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -4976,10 +4976,14 @@
4976 ** bytes in the string, not the number of characters.
4977 **
4978 ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
4979 ** even empty strings, are always zero-terminated. ^The return
4980 ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
4981 **
4982 ** ^Strings returned by sqlite3_column_text16() always have the endianness
4983 ** which is native to the platform, regardless of the text encoding set
4984 ** for the database.
4985 **
4986 ** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
4987 ** [unprotected sqlite3_value] object. In a multithreaded environment,
4988 ** an unprotected sqlite3_value object may only be used safely with
4989 ** [sqlite3_bind_value()] and [sqlite3_result_value()].
@@ -4990,11 +4994,11 @@
4994 ** Hence, the sqlite3_column_value() interface
4995 ** is normally only useful within the implementation of
4996 ** [application-defined SQL functions] or [virtual tables], not within
4997 ** top-level application code.
4998 **
4999 ** These routines may attempt to convert the datatype of the result.
5000 ** ^For example, if the internal representation is FLOAT and a text result
5001 ** is requested, [sqlite3_snprintf()] is used internally to perform the
5002 ** conversion automatically. ^(The following table details the conversions
5003 ** that are applied:
5004 **
@@ -5015,11 +5019,11 @@
5019 ** <tr><td> TEXT <td> INTEGER <td> [CAST] to INTEGER
5020 ** <tr><td> TEXT <td> FLOAT <td> [CAST] to REAL
5021 ** <tr><td> TEXT <td> BLOB <td> No change
5022 ** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
5023 ** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
5024 ** <tr><td> BLOB <td> TEXT <td> [CAST] to TEXT, ensure zero terminator
5025 ** </table>
5026 ** </blockquote>)^
5027 **
5028 ** Note that when type conversions occur, pointers returned by prior
5029 ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
5030

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button