sqlite-amalgamation-3450100.zip
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4819 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
7f661d9af9
commit
2d1b6a09e9
208
deps/sqlite/sqlite3.c
vendored
208
deps/sqlite/sqlite3.c
vendored
@ -1,6 +1,6 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
** This file is an amalgamation of many separate C source files from SQLite
|
** This file is an amalgamation of many separate C source files from SQLite
|
||||||
** version 3.45.0. By combining all the individual C code files into this
|
** version 3.45.1. By combining all the individual C code files into this
|
||||||
** single large file, the entire code can be compiled as a single translation
|
** single large file, the entire code can be compiled as a single translation
|
||||||
** unit. This allows many compilers to do optimizations that would not be
|
** unit. This allows many compilers to do optimizations that would not be
|
||||||
** possible if the files were compiled separately. Performance improvements
|
** possible if the files were compiled separately. Performance improvements
|
||||||
@ -18,7 +18,7 @@
|
|||||||
** separate file. This file contains only code for the core SQLite library.
|
** separate file. This file contains only code for the core SQLite library.
|
||||||
**
|
**
|
||||||
** The content in this amalgamation comes from Fossil check-in
|
** The content in this amalgamation comes from Fossil check-in
|
||||||
** 1066602b2b1976fe58b5150777cced894af1.
|
** e876e51a0ed5c5b3126f52e532044363a014.
|
||||||
*/
|
*/
|
||||||
#define SQLITE_CORE 1
|
#define SQLITE_CORE 1
|
||||||
#define SQLITE_AMALGAMATION 1
|
#define SQLITE_AMALGAMATION 1
|
||||||
@ -459,9 +459,9 @@ extern "C" {
|
|||||||
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
|
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
|
||||||
** [sqlite_version()] and [sqlite_source_id()].
|
** [sqlite_version()] and [sqlite_source_id()].
|
||||||
*/
|
*/
|
||||||
#define SQLITE_VERSION "3.45.0"
|
#define SQLITE_VERSION "3.45.1"
|
||||||
#define SQLITE_VERSION_NUMBER 3045000
|
#define SQLITE_VERSION_NUMBER 3045001
|
||||||
#define SQLITE_SOURCE_ID "2024-01-15 17:01:13 1066602b2b1976fe58b5150777cced894af17c803e068f5918390d6915b46e1d"
|
#define SQLITE_SOURCE_ID "2024-01-30 16:01:20 e876e51a0ed5c5b3126f52e532044363a014bc594cfefa87ffb5b82257cc467a"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** CAPI3REF: Run-Time Library Version Numbers
|
** CAPI3REF: Run-Time Library Version Numbers
|
||||||
@ -43408,11 +43408,16 @@ static int unixFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
|
|||||||
|
|
||||||
#if SQLITE_MAX_MMAP_SIZE>0
|
#if SQLITE_MAX_MMAP_SIZE>0
|
||||||
if( pFd->mmapSizeMax>0 ){
|
if( pFd->mmapSizeMax>0 ){
|
||||||
|
/* Ensure that there is always at least a 256 byte buffer of addressable
|
||||||
|
** memory following the returned page. If the database is corrupt,
|
||||||
|
** SQLite may overread the page slightly (in practice only a few bytes,
|
||||||
|
** but 256 is safe, round, number). */
|
||||||
|
const int nEofBuffer = 256;
|
||||||
if( pFd->pMapRegion==0 ){
|
if( pFd->pMapRegion==0 ){
|
||||||
int rc = unixMapfile(pFd, -1);
|
int rc = unixMapfile(pFd, -1);
|
||||||
if( rc!=SQLITE_OK ) return rc;
|
if( rc!=SQLITE_OK ) return rc;
|
||||||
}
|
}
|
||||||
if( pFd->mmapSize >= iOff+nAmt ){
|
if( pFd->mmapSize >= (iOff+nAmt+nEofBuffer) ){
|
||||||
*pp = &((u8 *)pFd->pMapRegion)[iOff];
|
*pp = &((u8 *)pFd->pMapRegion)[iOff];
|
||||||
pFd->nFetchOut++;
|
pFd->nFetchOut++;
|
||||||
}
|
}
|
||||||
@ -50765,6 +50770,11 @@ static int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
|
|||||||
|
|
||||||
#if SQLITE_MAX_MMAP_SIZE>0
|
#if SQLITE_MAX_MMAP_SIZE>0
|
||||||
if( pFd->mmapSizeMax>0 ){
|
if( pFd->mmapSizeMax>0 ){
|
||||||
|
/* Ensure that there is always at least a 256 byte buffer of addressable
|
||||||
|
** memory following the returned page. If the database is corrupt,
|
||||||
|
** SQLite may overread the page slightly (in practice only a few bytes,
|
||||||
|
** but 256 is safe, round, number). */
|
||||||
|
const int nEofBuffer = 256;
|
||||||
if( pFd->pMapRegion==0 ){
|
if( pFd->pMapRegion==0 ){
|
||||||
int rc = winMapfile(pFd, -1);
|
int rc = winMapfile(pFd, -1);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
@ -50773,7 +50783,7 @@ static int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( pFd->mmapSize >= iOff+nAmt ){
|
if( pFd->mmapSize >= (iOff+nAmt+nEofBuffer) ){
|
||||||
assert( pFd->pMapRegion!=0 );
|
assert( pFd->pMapRegion!=0 );
|
||||||
*pp = &((u8 *)pFd->pMapRegion)[iOff];
|
*pp = &((u8 *)pFd->pMapRegion)[iOff];
|
||||||
pFd->nFetchOut++;
|
pFd->nFetchOut++;
|
||||||
@ -76402,7 +76412,10 @@ static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur){
|
|||||||
}
|
}
|
||||||
|
|
||||||
pPage = pCur->pPage;
|
pPage = pCur->pPage;
|
||||||
assert( pPage->isInit );
|
if( sqlite3FaultSim(412) ) pPage->isInit = 0;
|
||||||
|
if( !pPage->isInit ){
|
||||||
|
return SQLITE_CORRUPT_BKPT;
|
||||||
|
}
|
||||||
if( !pPage->leaf ){
|
if( !pPage->leaf ){
|
||||||
int idx = pCur->ix;
|
int idx = pCur->ix;
|
||||||
rc = moveToChild(pCur, get4byte(findCell(pPage, idx)));
|
rc = moveToChild(pCur, get4byte(findCell(pPage, idx)));
|
||||||
@ -166812,7 +166825,10 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
|
|||||||
|
|
||||||
/* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */
|
/* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */
|
||||||
testcase( pOrderBy && pOrderBy->nExpr==BMS-1 );
|
testcase( pOrderBy && pOrderBy->nExpr==BMS-1 );
|
||||||
if( pOrderBy && pOrderBy->nExpr>=BMS ) pOrderBy = 0;
|
if( pOrderBy && pOrderBy->nExpr>=BMS ){
|
||||||
|
pOrderBy = 0;
|
||||||
|
wctrlFlags &= ~WHERE_WANT_DISTINCT;
|
||||||
|
}
|
||||||
|
|
||||||
/* The number of tables in the FROM clause is limited by the number of
|
/* The number of tables in the FROM clause is limited by the number of
|
||||||
** bits in a Bitmask
|
** bits in a Bitmask
|
||||||
@ -184749,6 +184765,8 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeIsdiacritic(int);
|
|||||||
|
|
||||||
SQLITE_PRIVATE int sqlite3Fts3ExprIterate(Fts3Expr*, int (*x)(Fts3Expr*,int,void*), void*);
|
SQLITE_PRIVATE int sqlite3Fts3ExprIterate(Fts3Expr*, int (*x)(Fts3Expr*,int,void*), void*);
|
||||||
|
|
||||||
|
SQLITE_PRIVATE int sqlite3Fts3IntegrityCheck(Fts3Table *p, int *pbOk);
|
||||||
|
|
||||||
#endif /* !SQLITE_CORE || SQLITE_ENABLE_FTS3 */
|
#endif /* !SQLITE_CORE || SQLITE_ENABLE_FTS3 */
|
||||||
#endif /* _FTSINT_H */
|
#endif /* _FTSINT_H */
|
||||||
|
|
||||||
@ -188471,7 +188489,7 @@ static int fts3ShadowName(const char *zName){
|
|||||||
** Implementation of the xIntegrity() method on the FTS3/FTS4 virtual
|
** Implementation of the xIntegrity() method on the FTS3/FTS4 virtual
|
||||||
** table.
|
** table.
|
||||||
*/
|
*/
|
||||||
static int fts3Integrity(
|
static int fts3IntegrityMethod(
|
||||||
sqlite3_vtab *pVtab, /* The virtual table to be checked */
|
sqlite3_vtab *pVtab, /* The virtual table to be checked */
|
||||||
const char *zSchema, /* Name of schema in which pVtab lives */
|
const char *zSchema, /* Name of schema in which pVtab lives */
|
||||||
const char *zTabname, /* Name of the pVTab table */
|
const char *zTabname, /* Name of the pVTab table */
|
||||||
@ -188479,30 +188497,21 @@ static int fts3Integrity(
|
|||||||
char **pzErr /* Write error message here */
|
char **pzErr /* Write error message here */
|
||||||
){
|
){
|
||||||
Fts3Table *p = (Fts3Table*)pVtab;
|
Fts3Table *p = (Fts3Table*)pVtab;
|
||||||
char *zSql;
|
|
||||||
int rc;
|
int rc;
|
||||||
char *zErr = 0;
|
int bOk = 0;
|
||||||
|
|
||||||
assert( pzErr!=0 );
|
|
||||||
assert( *pzErr==0 );
|
|
||||||
UNUSED_PARAMETER(isQuick);
|
UNUSED_PARAMETER(isQuick);
|
||||||
zSql = sqlite3_mprintf(
|
rc = sqlite3Fts3IntegrityCheck(p, &bOk);
|
||||||
"INSERT INTO \"%w\".\"%w\"(\"%w\") VALUES('integrity-check');",
|
assert( rc!=SQLITE_CORRUPT_VTAB || bOk==0 );
|
||||||
zSchema, zTabname, zTabname);
|
if( rc!=SQLITE_OK && rc!=SQLITE_CORRUPT_VTAB ){
|
||||||
if( zSql==0 ){
|
|
||||||
return SQLITE_NOMEM;
|
|
||||||
}
|
|
||||||
rc = sqlite3_exec(p->db, zSql, 0, 0, &zErr);
|
|
||||||
sqlite3_free(zSql);
|
|
||||||
if( (rc&0xff)==SQLITE_CORRUPT ){
|
|
||||||
*pzErr = sqlite3_mprintf("malformed inverted index for FTS%d table %s.%s",
|
|
||||||
p->bFts4 ? 4 : 3, zSchema, zTabname);
|
|
||||||
}else if( rc!=SQLITE_OK ){
|
|
||||||
*pzErr = sqlite3_mprintf("unable to validate the inverted index for"
|
*pzErr = sqlite3_mprintf("unable to validate the inverted index for"
|
||||||
" FTS%d table %s.%s: %s",
|
" FTS%d table %s.%s: %s",
|
||||||
p->bFts4 ? 4 : 3, zSchema, zTabname, zErr);
|
p->bFts4 ? 4 : 3, zSchema, zTabname, sqlite3_errstr(rc));
|
||||||
|
}else if( bOk==0 ){
|
||||||
|
*pzErr = sqlite3_mprintf("malformed inverted index for FTS%d table %s.%s",
|
||||||
|
p->bFts4 ? 4 : 3, zSchema, zTabname);
|
||||||
}
|
}
|
||||||
sqlite3_free(zErr);
|
sqlite3Fts3SegmentsClose(p);
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188533,7 +188542,7 @@ static const sqlite3_module fts3Module = {
|
|||||||
/* xRelease */ fts3ReleaseMethod,
|
/* xRelease */ fts3ReleaseMethod,
|
||||||
/* xRollbackTo */ fts3RollbackToMethod,
|
/* xRollbackTo */ fts3RollbackToMethod,
|
||||||
/* xShadowName */ fts3ShadowName,
|
/* xShadowName */ fts3ShadowName,
|
||||||
/* xIntegrity */ fts3Integrity,
|
/* xIntegrity */ fts3IntegrityMethod,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -200087,7 +200096,7 @@ static u64 fts3ChecksumIndex(
|
|||||||
** If an error occurs (e.g. an OOM or IO error), return an SQLite error
|
** If an error occurs (e.g. an OOM or IO error), return an SQLite error
|
||||||
** code. The final value of *pbOk is undefined in this case.
|
** code. The final value of *pbOk is undefined in this case.
|
||||||
*/
|
*/
|
||||||
static int fts3IntegrityCheck(Fts3Table *p, int *pbOk){
|
SQLITE_PRIVATE int sqlite3Fts3IntegrityCheck(Fts3Table *p, int *pbOk){
|
||||||
int rc = SQLITE_OK; /* Return code */
|
int rc = SQLITE_OK; /* Return code */
|
||||||
u64 cksum1 = 0; /* Checksum based on FTS index contents */
|
u64 cksum1 = 0; /* Checksum based on FTS index contents */
|
||||||
u64 cksum2 = 0; /* Checksum based on %_content contents */
|
u64 cksum2 = 0; /* Checksum based on %_content contents */
|
||||||
@ -200165,7 +200174,7 @@ static int fts3IntegrityCheck(Fts3Table *p, int *pbOk){
|
|||||||
sqlite3_finalize(pStmt);
|
sqlite3_finalize(pStmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
*pbOk = (cksum1==cksum2);
|
*pbOk = (rc==SQLITE_OK && cksum1==cksum2);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200205,7 +200214,7 @@ static int fts3DoIntegrityCheck(
|
|||||||
){
|
){
|
||||||
int rc;
|
int rc;
|
||||||
int bOk = 0;
|
int bOk = 0;
|
||||||
rc = fts3IntegrityCheck(p, &bOk);
|
rc = sqlite3Fts3IntegrityCheck(p, &bOk);
|
||||||
if( rc==SQLITE_OK && bOk==0 ) rc = FTS_CORRUPT_VTAB;
|
if( rc==SQLITE_OK && bOk==0 ) rc = FTS_CORRUPT_VTAB;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -203758,6 +203767,16 @@ static void jsonAppendChar(JsonString *p, char c){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove a single character from the end of the string
|
||||||
|
*/
|
||||||
|
static void jsonStringTrimOneChar(JsonString *p){
|
||||||
|
if( p->eErr==0 ){
|
||||||
|
assert( p->nUsed>0 );
|
||||||
|
p->nUsed--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Make sure there is a zero terminator on p->zBuf[]
|
/* Make sure there is a zero terminator on p->zBuf[]
|
||||||
**
|
**
|
||||||
** Return true on success. Return false if an OOM prevents this
|
** Return true on success. Return false if an OOM prevents this
|
||||||
@ -203765,7 +203784,7 @@ static void jsonAppendChar(JsonString *p, char c){
|
|||||||
*/
|
*/
|
||||||
static int jsonStringTerminate(JsonString *p){
|
static int jsonStringTerminate(JsonString *p){
|
||||||
jsonAppendChar(p, 0);
|
jsonAppendChar(p, 0);
|
||||||
p->nUsed--;
|
jsonStringTrimOneChar(p);
|
||||||
return p->eErr==0;
|
return p->eErr==0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205231,8 +205250,8 @@ static u32 jsonbPayloadSize(const JsonParse *pParse, u32 i, u32 *pSz){
|
|||||||
(pParse->aBlob[i+7]<<8) + pParse->aBlob[i+8];
|
(pParse->aBlob[i+7]<<8) + pParse->aBlob[i+8];
|
||||||
n = 9;
|
n = 9;
|
||||||
}
|
}
|
||||||
if( i+sz+n > pParse->nBlob
|
if( (i64)i+sz+n > pParse->nBlob
|
||||||
&& i+sz+n > pParse->nBlob-pParse->delta
|
&& (i64)i+sz+n > pParse->nBlob-pParse->delta
|
||||||
){
|
){
|
||||||
sz = 0;
|
sz = 0;
|
||||||
n = 0;
|
n = 0;
|
||||||
@ -205282,6 +205301,7 @@ static u32 jsonTranslateBlobToText(
|
|||||||
}
|
}
|
||||||
case JSONB_INT:
|
case JSONB_INT:
|
||||||
case JSONB_FLOAT: {
|
case JSONB_FLOAT: {
|
||||||
|
if( sz==0 ) goto malformed_jsonb;
|
||||||
jsonAppendRaw(pOut, (const char*)&pParse->aBlob[i+n], sz);
|
jsonAppendRaw(pOut, (const char*)&pParse->aBlob[i+n], sz);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -205290,6 +205310,7 @@ static u32 jsonTranslateBlobToText(
|
|||||||
sqlite3_uint64 u = 0;
|
sqlite3_uint64 u = 0;
|
||||||
const char *zIn = (const char*)&pParse->aBlob[i+n];
|
const char *zIn = (const char*)&pParse->aBlob[i+n];
|
||||||
int bOverflow = 0;
|
int bOverflow = 0;
|
||||||
|
if( sz==0 ) goto malformed_jsonb;
|
||||||
if( zIn[0]=='-' ){
|
if( zIn[0]=='-' ){
|
||||||
jsonAppendChar(pOut, '-');
|
jsonAppendChar(pOut, '-');
|
||||||
k++;
|
k++;
|
||||||
@ -205312,6 +205333,7 @@ static u32 jsonTranslateBlobToText(
|
|||||||
case JSONB_FLOAT5: { /* Float literal missing digits beside "." */
|
case JSONB_FLOAT5: { /* Float literal missing digits beside "." */
|
||||||
u32 k = 0;
|
u32 k = 0;
|
||||||
const char *zIn = (const char*)&pParse->aBlob[i+n];
|
const char *zIn = (const char*)&pParse->aBlob[i+n];
|
||||||
|
if( sz==0 ) goto malformed_jsonb;
|
||||||
if( zIn[0]=='-' ){
|
if( zIn[0]=='-' ){
|
||||||
jsonAppendChar(pOut, '-');
|
jsonAppendChar(pOut, '-');
|
||||||
k++;
|
k++;
|
||||||
@ -205425,11 +205447,12 @@ static u32 jsonTranslateBlobToText(
|
|||||||
jsonAppendChar(pOut, '[');
|
jsonAppendChar(pOut, '[');
|
||||||
j = i+n;
|
j = i+n;
|
||||||
iEnd = j+sz;
|
iEnd = j+sz;
|
||||||
while( j<iEnd ){
|
while( j<iEnd && pOut->eErr==0 ){
|
||||||
j = jsonTranslateBlobToText(pParse, j, pOut);
|
j = jsonTranslateBlobToText(pParse, j, pOut);
|
||||||
jsonAppendChar(pOut, ',');
|
jsonAppendChar(pOut, ',');
|
||||||
}
|
}
|
||||||
if( sz>0 ) pOut->nUsed--;
|
if( j>iEnd ) pOut->eErr |= JSTRING_MALFORMED;
|
||||||
|
if( sz>0 ) jsonStringTrimOneChar(pOut);
|
||||||
jsonAppendChar(pOut, ']');
|
jsonAppendChar(pOut, ']');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -205438,17 +205461,18 @@ static u32 jsonTranslateBlobToText(
|
|||||||
jsonAppendChar(pOut, '{');
|
jsonAppendChar(pOut, '{');
|
||||||
j = i+n;
|
j = i+n;
|
||||||
iEnd = j+sz;
|
iEnd = j+sz;
|
||||||
while( j<iEnd ){
|
while( j<iEnd && pOut->eErr==0 ){
|
||||||
j = jsonTranslateBlobToText(pParse, j, pOut);
|
j = jsonTranslateBlobToText(pParse, j, pOut);
|
||||||
jsonAppendChar(pOut, (x++ & 1) ? ',' : ':');
|
jsonAppendChar(pOut, (x++ & 1) ? ',' : ':');
|
||||||
}
|
}
|
||||||
if( x & 1 ) pOut->eErr |= JSTRING_MALFORMED;
|
if( (x & 1)!=0 || j>iEnd ) pOut->eErr |= JSTRING_MALFORMED;
|
||||||
if( sz>0 ) pOut->nUsed--;
|
if( sz>0 ) jsonStringTrimOneChar(pOut);
|
||||||
jsonAppendChar(pOut, '}');
|
jsonAppendChar(pOut, '}');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
malformed_jsonb:
|
||||||
pOut->eErr |= JSTRING_MALFORMED;
|
pOut->eErr |= JSTRING_MALFORMED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -206375,6 +206399,38 @@ jsonInsertIntoBlob_patherror:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** If pArg is a blob that seems like a JSONB blob, then initialize
|
||||||
|
** p to point to that JSONB and return TRUE. If pArg does not seem like
|
||||||
|
** a JSONB blob, then return FALSE;
|
||||||
|
**
|
||||||
|
** This routine is only called if it is already known that pArg is a
|
||||||
|
** blob. The only open question is whether or not the blob appears
|
||||||
|
** to be a JSONB blob.
|
||||||
|
*/
|
||||||
|
static int jsonArgIsJsonb(sqlite3_value *pArg, JsonParse *p){
|
||||||
|
u32 n, sz = 0;
|
||||||
|
p->aBlob = (u8*)sqlite3_value_blob(pArg);
|
||||||
|
p->nBlob = (u32)sqlite3_value_bytes(pArg);
|
||||||
|
if( p->nBlob==0 ){
|
||||||
|
p->aBlob = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if( NEVER(p->aBlob==0) ){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if( (p->aBlob[0] & 0x0f)<=JSONB_OBJECT
|
||||||
|
&& (n = jsonbPayloadSize(p, 0, &sz))>0
|
||||||
|
&& sz+n==p->nBlob
|
||||||
|
&& ((p->aBlob[0] & 0x0f)>JSONB_FALSE || sz==0)
|
||||||
|
){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
p->aBlob = 0;
|
||||||
|
p->nBlob = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Generate a JsonParse object, containing valid JSONB in aBlob and nBlob,
|
** Generate a JsonParse object, containing valid JSONB in aBlob and nBlob,
|
||||||
** from the SQL function argument pArg. Return a pointer to the new
|
** from the SQL function argument pArg. Return a pointer to the new
|
||||||
@ -206431,30 +206487,25 @@ rebuild_from_cache:
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
if( eType==SQLITE_BLOB ){
|
if( eType==SQLITE_BLOB ){
|
||||||
u32 n, sz = 0;
|
if( jsonArgIsJsonb(pArg,p) ){
|
||||||
p->aBlob = (u8*)sqlite3_value_blob(pArg);
|
|
||||||
p->nBlob = (u32)sqlite3_value_bytes(pArg);
|
|
||||||
if( p->nBlob==0 ){
|
|
||||||
goto json_pfa_malformed;
|
|
||||||
}
|
|
||||||
if( NEVER(p->aBlob==0) ){
|
|
||||||
goto json_pfa_oom;
|
|
||||||
}
|
|
||||||
if( (p->aBlob[0] & 0x0f)>JSONB_OBJECT ){
|
|
||||||
goto json_pfa_malformed;
|
|
||||||
}
|
|
||||||
n = jsonbPayloadSize(p, 0, &sz);
|
|
||||||
if( n==0
|
|
||||||
|| sz+n!=p->nBlob
|
|
||||||
|| ((p->aBlob[0] & 0x0f)<=JSONB_FALSE && sz>0)
|
|
||||||
){
|
|
||||||
goto json_pfa_malformed;
|
|
||||||
}
|
|
||||||
if( (flgs & JSON_EDITABLE)!=0 && jsonBlobMakeEditable(p, 0)==0 ){
|
if( (flgs & JSON_EDITABLE)!=0 && jsonBlobMakeEditable(p, 0)==0 ){
|
||||||
goto json_pfa_oom;
|
goto json_pfa_oom;
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
/* If the blob is not valid JSONB, fall through into trying to cast
|
||||||
|
** the blob into text which is then interpreted as JSON. (tag-20240123-a)
|
||||||
|
**
|
||||||
|
** This goes against all historical documentation about how the SQLite
|
||||||
|
** JSON functions were suppose to work. From the beginning, blob was
|
||||||
|
** reserved for expansion and a blob value should have raised an error.
|
||||||
|
** But it did not, due to a bug. And many applications came to depend
|
||||||
|
** upon this buggy behavior, espeically when using the CLI and reading
|
||||||
|
** JSON text using readfile(), which returns a blob. For this reason
|
||||||
|
** we will continue to support the bug moving forward.
|
||||||
|
** See for example https://sqlite.org/forum/forumpost/012136abd5292b8d
|
||||||
|
*/
|
||||||
|
}
|
||||||
p->zJson = (char*)sqlite3_value_text(pArg);
|
p->zJson = (char*)sqlite3_value_text(pArg);
|
||||||
p->nJson = sqlite3_value_bytes(pArg);
|
p->nJson = sqlite3_value_bytes(pArg);
|
||||||
if( p->nJson==0 ) goto json_pfa_malformed;
|
if( p->nJson==0 ) goto json_pfa_malformed;
|
||||||
@ -207429,12 +207480,12 @@ static void jsonValidFunc(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case SQLITE_BLOB: {
|
case SQLITE_BLOB: {
|
||||||
if( (flags & 0x0c)!=0 && jsonFuncArgMightBeBinary(argv[0]) ){
|
if( jsonFuncArgMightBeBinary(argv[0]) ){
|
||||||
if( flags & 0x04 ){
|
if( flags & 0x04 ){
|
||||||
/* Superficial checking only - accomplished by the
|
/* Superficial checking only - accomplished by the
|
||||||
** jsonFuncArgMightBeBinary() call above. */
|
** jsonFuncArgMightBeBinary() call above. */
|
||||||
res = 1;
|
res = 1;
|
||||||
}else{
|
}else if( flags & 0x08 ){
|
||||||
/* Strict checking. Check by translating BLOB->TEXT->BLOB. If
|
/* Strict checking. Check by translating BLOB->TEXT->BLOB. If
|
||||||
** no errors occur, call that a "strict check". */
|
** no errors occur, call that a "strict check". */
|
||||||
JsonParse px;
|
JsonParse px;
|
||||||
@ -207445,9 +207496,12 @@ static void jsonValidFunc(
|
|||||||
iErr = jsonbValidityCheck(&px, 0, px.nBlob, 1);
|
iErr = jsonbValidityCheck(&px, 0, px.nBlob, 1);
|
||||||
res = iErr==0;
|
res = iErr==0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/* Fall through into interpreting the input as text. See note
|
||||||
|
** above at tag-20240123-a. */
|
||||||
|
/* no break */ deliberate_fall_through
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
JsonParse px;
|
JsonParse px;
|
||||||
if( (flags & 0x3)==0 ) break;
|
if( (flags & 0x3)==0 ) break;
|
||||||
@ -207571,7 +207625,7 @@ static void jsonArrayCompute(sqlite3_context *ctx, int isFinal){
|
|||||||
if( isFinal ){
|
if( isFinal ){
|
||||||
if( !pStr->bStatic ) sqlite3RCStrUnref(pStr->zBuf);
|
if( !pStr->bStatic ) sqlite3RCStrUnref(pStr->zBuf);
|
||||||
}else{
|
}else{
|
||||||
pStr->nUsed--;
|
jsonStringTrimOneChar(pStr);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}else if( isFinal ){
|
}else if( isFinal ){
|
||||||
@ -207581,7 +207635,7 @@ static void jsonArrayCompute(sqlite3_context *ctx, int isFinal){
|
|||||||
pStr->bStatic = 1;
|
pStr->bStatic = 1;
|
||||||
}else{
|
}else{
|
||||||
sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT);
|
sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT);
|
||||||
pStr->nUsed--;
|
jsonStringTrimOneChar(pStr);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
sqlite3_result_text(ctx, "[]", 2, SQLITE_STATIC);
|
sqlite3_result_text(ctx, "[]", 2, SQLITE_STATIC);
|
||||||
@ -207691,7 +207745,7 @@ static void jsonObjectCompute(sqlite3_context *ctx, int isFinal){
|
|||||||
if( isFinal ){
|
if( isFinal ){
|
||||||
if( !pStr->bStatic ) sqlite3RCStrUnref(pStr->zBuf);
|
if( !pStr->bStatic ) sqlite3RCStrUnref(pStr->zBuf);
|
||||||
}else{
|
}else{
|
||||||
pStr->nUsed--;
|
jsonStringTrimOneChar(pStr);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}else if( isFinal ){
|
}else if( isFinal ){
|
||||||
@ -207701,7 +207755,7 @@ static void jsonObjectCompute(sqlite3_context *ctx, int isFinal){
|
|||||||
pStr->bStatic = 1;
|
pStr->bStatic = 1;
|
||||||
}else{
|
}else{
|
||||||
sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT);
|
sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT);
|
||||||
pStr->nUsed--;
|
jsonStringTrimOneChar(pStr);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
sqlite3_result_text(ctx, "{}", 2, SQLITE_STATIC);
|
sqlite3_result_text(ctx, "{}", 2, SQLITE_STATIC);
|
||||||
@ -208182,13 +208236,9 @@ static int jsonEachFilter(
|
|||||||
memset(&p->sParse, 0, sizeof(p->sParse));
|
memset(&p->sParse, 0, sizeof(p->sParse));
|
||||||
p->sParse.nJPRef = 1;
|
p->sParse.nJPRef = 1;
|
||||||
p->sParse.db = p->db;
|
p->sParse.db = p->db;
|
||||||
if( sqlite3_value_type(argv[0])==SQLITE_BLOB ){
|
|
||||||
if( jsonFuncArgMightBeBinary(argv[0]) ){
|
if( jsonFuncArgMightBeBinary(argv[0]) ){
|
||||||
p->sParse.nBlob = sqlite3_value_bytes(argv[0]);
|
p->sParse.nBlob = sqlite3_value_bytes(argv[0]);
|
||||||
p->sParse.aBlob = (u8*)sqlite3_value_blob(argv[0]);
|
p->sParse.aBlob = (u8*)sqlite3_value_blob(argv[0]);
|
||||||
}else{
|
|
||||||
goto json_each_malformed_input;
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
p->sParse.zJson = (char*)sqlite3_value_text(argv[0]);
|
p->sParse.zJson = (char*)sqlite3_value_text(argv[0]);
|
||||||
p->sParse.nJson = sqlite3_value_bytes(argv[0]);
|
p->sParse.nJson = sqlite3_value_bytes(argv[0]);
|
||||||
@ -250497,7 +250547,7 @@ static void fts5SourceIdFunc(
|
|||||||
){
|
){
|
||||||
assert( nArg==0 );
|
assert( nArg==0 );
|
||||||
UNUSED_PARAM2(nArg, apUnused);
|
UNUSED_PARAM2(nArg, apUnused);
|
||||||
sqlite3_result_text(pCtx, "fts5: 2024-01-15 17:01:13 1066602b2b1976fe58b5150777cced894af17c803e068f5918390d6915b46e1d", -1, SQLITE_TRANSIENT);
|
sqlite3_result_text(pCtx, "fts5: 2024-01-30 16:01:20 e876e51a0ed5c5b3126f52e532044363a014bc594cfefa87ffb5b82257cc467a", -1, SQLITE_TRANSIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -250528,27 +250578,21 @@ static int fts5IntegrityMethod(
|
|||||||
char **pzErr /* Write error message here */
|
char **pzErr /* Write error message here */
|
||||||
){
|
){
|
||||||
Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
|
Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
|
||||||
Fts5Config *pConfig = pTab->p.pConfig;
|
|
||||||
char *zSql;
|
|
||||||
char *zErr = 0;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
assert( pzErr!=0 && *pzErr==0 );
|
assert( pzErr!=0 && *pzErr==0 );
|
||||||
UNUSED_PARAM(isQuick);
|
UNUSED_PARAM(isQuick);
|
||||||
zSql = sqlite3_mprintf(
|
rc = sqlite3Fts5StorageIntegrity(pTab->pStorage, 0);
|
||||||
"INSERT INTO \"%w\".\"%w\"(\"%w\") VALUES('integrity-check');",
|
|
||||||
zSchema, zTabname, pConfig->zName);
|
|
||||||
if( zSql==0 ) return SQLITE_NOMEM;
|
|
||||||
rc = sqlite3_exec(pConfig->db, zSql, 0, 0, &zErr);
|
|
||||||
sqlite3_free(zSql);
|
|
||||||
if( (rc&0xff)==SQLITE_CORRUPT ){
|
if( (rc&0xff)==SQLITE_CORRUPT ){
|
||||||
*pzErr = sqlite3_mprintf("malformed inverted index for FTS5 table %s.%s",
|
*pzErr = sqlite3_mprintf("malformed inverted index for FTS5 table %s.%s",
|
||||||
zSchema, zTabname);
|
zSchema, zTabname);
|
||||||
}else if( rc!=SQLITE_OK ){
|
}else if( rc!=SQLITE_OK ){
|
||||||
*pzErr = sqlite3_mprintf("unable to validate the inverted index for"
|
*pzErr = sqlite3_mprintf("unable to validate the inverted index for"
|
||||||
" FTS5 table %s.%s: %s",
|
" FTS5 table %s.%s: %s",
|
||||||
zSchema, zTabname, zErr);
|
zSchema, zTabname, sqlite3_errstr(rc));
|
||||||
}
|
}
|
||||||
sqlite3_free(zErr);
|
sqlite3Fts5IndexCloseReader(pTab->p.pIndex);
|
||||||
|
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
deps/sqlite/sqlite3.h
vendored
6
deps/sqlite/sqlite3.h
vendored
@ -146,9 +146,9 @@ extern "C" {
|
|||||||
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
|
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
|
||||||
** [sqlite_version()] and [sqlite_source_id()].
|
** [sqlite_version()] and [sqlite_source_id()].
|
||||||
*/
|
*/
|
||||||
#define SQLITE_VERSION "3.45.0"
|
#define SQLITE_VERSION "3.45.1"
|
||||||
#define SQLITE_VERSION_NUMBER 3045000
|
#define SQLITE_VERSION_NUMBER 3045001
|
||||||
#define SQLITE_SOURCE_ID "2024-01-15 17:01:13 1066602b2b1976fe58b5150777cced894af17c803e068f5918390d6915b46e1d"
|
#define SQLITE_SOURCE_ID "2024-01-30 16:01:20 e876e51a0ed5c5b3126f52e532044363a014bc594cfefa87ffb5b82257cc467a"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** CAPI3REF: Run-Time Library Version Numbers
|
** CAPI3REF: Run-Time Library Version Numbers
|
||||||
|
Loading…
Reference in New Issue
Block a user