| ︙ | | |
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
-
+
|
** the text of this file. Search for "Begin file sqlite3.h" to find the start
** of the embedded sqlite3.h header file.) Additional code files may be needed
** if you want a wrapper to interface SQLite with your choice of programming
** language. The code for the "sqlite3" command-line shell is also in a
** separate file. This file contains only code for the core SQLite library.
**
** The content in this amalgamation comes from Fossil check-in
** 6eb2939a6093c0796910645172d80c530555 with changes in files:
** e7dcf25efae364b7cdf9eb8265803c816c8b with changes in files:
**
**
*/
#ifndef SQLITE_AMALGAMATION
#define SQLITE_CORE 1
#define SQLITE_AMALGAMATION 1
#ifndef SQLITE_PRIVATE
|
| ︙ | | |
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
|
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
|
-
+
|
**
** See also: [sqlite3_libversion()],
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION "3.50.0"
#define SQLITE_VERSION_NUMBER 3050000
#define SQLITE_SOURCE_ID "2025-05-06 17:56:32 6eb2939a6093c0796910645172d80c53055559dd57c012f1dc815d89fbf84447"
#define SQLITE_SOURCE_ID "2025-05-14 16:40:05 e7dcf25efae364b7cdf9eb8265803c816c8b8557e4a7684da428badc6ffb3875"
/*
** CAPI3REF: Run-Time Library Version Numbers
** KEYWORDS: sqlite3_version sqlite3_sourceid
**
** These interfaces provide the same information as the [SQLITE_VERSION],
** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
|
| ︙ | | |
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
|
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
|
-
+
|
/*
** CAPI3REF: Flags for sqlite3changeset_start_v2
**
** The following flags may passed via the 4th parameter to
** [sqlite3changeset_start_v2] and [sqlite3changeset_start_v2_strm]:
**
** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>
** <dt>SQLITE_CHANGESETSTART_INVERT <dd>
** Invert the changeset while iterating through it. This is equivalent to
** inverting a changeset using sqlite3changeset_invert() before applying it.
** It is an error to specify this flag with a patchset.
*/
#define SQLITE_CHANGESETSTART_INVERT 0x0002
|
| ︙ | | |
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
19173
|
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
|
-
|
unsigned idxType:2; /* 0:Normal 1:UNIQUE, 2:PRIMARY KEY, 3:IPK */
unsigned bUnordered:1; /* Use this index for == or IN queries only */
unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */
unsigned isResized:1; /* True if resizeIndexObject() has been called */
unsigned isCovering:1; /* True if this is a covering index */
unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */
unsigned bLowQual:1; /* sqlite_stat1 says this is a low-quality index */
unsigned bNoQuery:1; /* Do not use this index to optimize queries */
unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */
unsigned bIdxRowid:1; /* One or more of the index keys is the ROWID */
unsigned bHasVCol:1; /* Index references one or more VIRTUAL columns */
unsigned bHasExpr:1; /* Index contains an expression, either a literal
** expression, or a reference to a VIRTUAL column */
#ifdef SQLITE_ENABLE_STAT4
|
| ︙ | | |
22423
22424
22425
22426
22427
22428
22429
22430
22431
22432
22433
22434
22435
22436
|
22422
22423
22424
22425
22426
22427
22428
22429
22430
22431
22432
22433
22434
22435
22436
22437
22438
|
+
+
+
|
"ATOMIC_INTRINSICS=" CTIMEOPT_VAL(SQLITE_ATOMIC_INTRINSICS),
#endif
#ifdef SQLITE_BITMASK_TYPE
"BITMASK_TYPE=" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE),
#endif
#ifdef SQLITE_BUG_COMPATIBLE_20160819
"BUG_COMPATIBLE_20160819",
#endif
#ifdef SQLITE_BUG_COMPATIBLE_20250510
"BUG_COMPATIBLE_20250510",
#endif
#ifdef SQLITE_CASE_SENSITIVE_LIKE
"CASE_SENSITIVE_LIKE",
#endif
#ifdef SQLITE_CHECK_PAGES
"CHECK_PAGES",
#endif
|
| ︙ | | |
109305
109306
109307
109308
109309
109310
109311
109312
109313
109314
109315
109316
109317
109318
109319
109320
109321
109322
109323
109324
109325
109326
109327
109328
109329
109330
109331
109332
109333
109334
109335
109336
109337
109338
109339
109340
|
109307
109308
109309
109310
109311
109312
109313
109314
109315
109316
109317
109318
109319
109320
109321
109322
109323
109324
109325
109326
109327
109328
109329
109330
109331
109332
109333
109334
109335
109336
109337
109338
109339
109340
109341
109342
|
-
+
-
+
|
}
if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){
/* Clearly non-deterministic functions like random(), but also
** date/time functions that use 'now', and other functions like
** sqlite_version() that might change over time cannot be used
** in an index or generated column. Curiously, they can be used
** in a CHECK constraint. SQLServer, MySQL, and PostgreSQL all
** all this. */
** allow this. */
sqlite3ResolveNotValid(pParse, pNC, "non-deterministic functions",
NC_IdxExpr|NC_PartIdx|NC_GenCol, 0, pExpr);
}else{
assert( (NC_SelfRef & 0xff)==NC_SelfRef ); /* Must fit in 8 bits */
pExpr->op2 = pNC->ncFlags & NC_SelfRef;
if( pNC->ncFlags & NC_FromDDL ) ExprSetProperty(pExpr, EP_FromDDL);
}
if( (pDef->funcFlags & SQLITE_FUNC_INTERNAL)!=0
&& pParse->nested==0
&& (pParse->db->mDbFlags & DBFLAG_InternalFunc)==0
){
/* Internal-use-only functions are disallowed unless the
** SQL is being compiled using sqlite3NestedParse() or
** the SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test-control has be
** used to activate internal functions for testing purposes */
no_such_func = 1;
pDef = 0;
}else
if( (pDef->funcFlags & (SQLITE_FUNC_DIRECT|SQLITE_FUNC_UNSAFE))!=0
&& !IN_RENAME_OBJECT
){
if( pNC->ncFlags & NC_FromDDL ) ExprSetProperty(pExpr, EP_FromDDL);
sqlite3ExprFunctionUsable(pParse, pExpr, pDef);
}
}
if( 0==IN_RENAME_OBJECT ){
#ifndef SQLITE_OMIT_WINDOWFUNC
assert( is_agg==0 || (pDef->funcFlags & SQLITE_FUNC_MINMAX)
|
| ︙ | | |
121702
121703
121704
121705
121706
121707
121708
121709
121710
121711
121712
121713
121714
121715
121716
121717
121718
121719
121720
121721
121722
121723
121724
121725
|
121704
121705
121706
121707
121708
121709
121710
121711
121712
121713
121714
121715
121716
121717
|
-
-
-
-
-
-
-
-
-
-
|
else if( sqlite3_strglob("costmult=[0-9]*",z)==0 ){
pIndex->pTable->costMult = sqlite3LogEst(sqlite3Atoi(z+9));
}
#endif
while( z[0]!=0 && z[0]!=' ' ) z++;
while( z[0]==' ' ) z++;
}
/* Set the bLowQual flag if the peak number of rows obtained
** from a full equality match is so large that a full table scan
** seems likely to be faster than using the index.
*/
if( aLog[0] > 66 /* Index has more than 100 rows */
&& aLog[0] <= aLog[nOut-1] /* And only a single value seen */
){
pIndex->bLowQual = 1;
}
}
}
/*
** This callback is invoked once for each index when reading the
** sqlite_stat1 table.
**
|
| ︙ | | |
167639
167640
167641
167642
167643
167644
167645
167646
167647
167648
167649
167650
167651
167652
167653
167654
167655
167656
167657
|
167631
167632
167633
167634
167635
167636
167637
167638
167639
167640
167641
167642
167643
167644
167645
167646
|
-
-
+
+
-
-
-
|
assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 );
if( pNew->wsFlags & WHERE_BTM_LIMIT ){
opMask = WO_LT|WO_LE;
}else{
assert( pNew->u.btree.nBtm==0 );
opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
}
if( pProbe->bUnordered || pProbe->bLowQual ){
if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
if( pProbe->bUnordered ){
opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
if( pProbe->bLowQual && pSrc->fg.isIndexedBy==0 ){
opMask &= ~(WO_EQ|WO_IN|WO_IS);
}
}
assert( pNew->u.btree.nEq<pProbe->nColumn );
assert( pNew->u.btree.nEq<pProbe->nKeyCol
|| pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY );
saved_nEq = pNew->u.btree.nEq;
|
| ︙ | | |
168580
168581
168582
168583
168584
168585
168586
168587
168588
168589
168590
168591
168592
168593
168594
|
168569
168570
168571
168572
168573
168574
168575
168576
168577
168578
168579
168580
168581
168582
168583
|
-
+
|
" according to whereIsCoveringIndex()\n", pProbe->zName));
}
}
}else if( m==0
&& (HasRowid(pTab) || pWInfo->pSelect!=0 || sqlite3FaultSim(700))
){
WHERETRACE(0x200,
("-> %s a covering index according to bitmasks\n",
("-> %s is a covering index according to bitmasks\n",
pProbe->zName, m==0 ? "is" : "is not"));
pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED;
}
}
/* Full scan via index */
if( b
|
| ︙ | | |
209592
209593
209594
209595
209596
209597
209598
209599
209600
209601
209602
209603
209604
209605
209606
|
209581
209582
209583
209584
209585
209586
209587
209588
209589
209590
209591
209592
209593
209594
209595
209596
209597
209598
209599
209600
|
-
+
+
+
+
+
+
|
break;
}else if( c=='\\' ){
c = z[++j];
if( c=='"' || c=='\\' || c=='/' || c=='b' || c=='f'
|| c=='n' || c=='r' || c=='t'
|| (c=='u' && jsonIs4Hex(&z[j+1])) ){
if( opcode==JSONB_TEXT ) opcode = JSONB_TEXTJ;
}else if( c=='\'' || c=='0' || c=='v' || c=='\n'
}else if( c=='\'' || c=='v' || c=='\n'
#ifdef SQLITE_BUG_COMPATIBLE_20250510
|| (c=='0') /* Legacy bug compatible */
#else
|| (c=='0' && !sqlite3Isdigit(z[j+1])) /* Correct implementation */
#endif
|| (0xe2==(u8)c && 0x80==(u8)z[j+1]
&& (0xa8==(u8)z[j+2] || 0xa9==(u8)z[j+2]))
|| (c=='x' && jsonIs2Hex(&z[j+1])) ){
opcode = JSONB_TEXT5;
pParse->hasNonstd = 1;
}else if( c=='\r' ){
if( z[j+1]=='\n' ) j++;
|
| ︙ | | |
209979
209980
209981
209982
209983
209984
209985
209986
209987
209988
209989
209990
209991
209992
209993
|
209973
209974
209975
209976
209977
209978
209979
209980
209981
209982
209983
209984
209985
209986
209987
|
-
+
|
|| pParse->aBlob[i+2]!=0
|| pParse->aBlob[i+3]!=0
|| pParse->aBlob[i+4]!=0
){
*pSz = 0;
return 0;
}
sz = (pParse->aBlob[i+5]<<24) + (pParse->aBlob[i+6]<<16) +
sz = ((u32)pParse->aBlob[i+5]<<24) + (pParse->aBlob[i+6]<<16) +
(pParse->aBlob[i+7]<<8) + pParse->aBlob[i+8];
n = 9;
}
if( (i64)i+sz+n > pParse->nBlob
&& (i64)i+sz+n > pParse->nBlob-pParse->delta
){
*pSz = 0;
|
| ︙ | | |
210560
210561
210562
210563
210564
210565
210566
210567
210568
210569
210570
210571
210572
210573
210574
|
210554
210555
210556
210557
210558
210559
210560
210561
210562
210563
210564
210565
210566
210567
210568
210569
210570
210571
210572
210573
210574
210575
210576
210577
210578
210579
210580
210581
210582
|
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
}
case 'b': { *piOut = '\b'; return 2; }
case 'f': { *piOut = '\f'; return 2; }
case 'n': { *piOut = '\n'; return 2; }
case 'r': { *piOut = '\r'; return 2; }
case 't': { *piOut = '\t'; return 2; }
case 'v': { *piOut = '\v'; return 2; }
case '0': { *piOut = 0; return 2; }
case '0': {
/* JSON5 requires that the \0 escape not be followed by a digit.
** But SQLite did not enforce this restriction in versions 3.42.0
** through 3.49.2. That was a bug. But some applications might have
** come to depend on that bug. Use the SQLITE_BUG_COMPATIBLE_20250510
** option to restore the old buggy behavior. */
#ifdef SQLITE_BUG_COMPATIBLE_20250510
/* Legacy bug-compatible behavior */
*piOut = 0;
#else
/* Correct behavior */
*piOut = (n>2 && sqlite3Isdigit(z[2])) ? JSON_INVALID_CHAR : 0;
#endif
return 2;
}
case '\'':
case '"':
case '/':
case '\\':{ *piOut = z[1]; return 2; }
case 'x': {
if( n<4 ){
*piOut = JSON_INVALID_CHAR;
|
| ︙ | | |
257265
257266
257267
257268
257269
257270
257271
257272
257273
257274
257275
257276
257277
257278
257279
|
257273
257274
257275
257276
257277
257278
257279
257280
257281
257282
257283
257284
257285
257286
257287
|
-
+
|
static void fts5SourceIdFunc(
sqlite3_context *pCtx, /* Function call context */
int nArg, /* Number of args */
sqlite3_value **apUnused /* Function arguments */
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
sqlite3_result_text(pCtx, "fts5: 2025-05-06 17:56:32 6eb2939a6093c0796910645172d80c53055559dd57c012f1dc815d89fbf84447", -1, SQLITE_TRANSIENT);
sqlite3_result_text(pCtx, "fts5: 2025-05-14 16:40:05 e7dcf25efae364b7cdf9eb8265803c816c8b8557e4a7684da428badc6ffb3875", -1, SQLITE_TRANSIENT);
}
/*
** Implementation of fts5_locale(LOCALE, TEXT) function.
**
** If parameter LOCALE is NULL, or a zero-length string, then a copy of
** TEXT is returned. Otherwise, both LOCALE and TEXT are interpreted as
|
| ︙ | | |