aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/sqlite3
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-03-17 20:49:45 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-03-17 20:49:45 +0300
commita69ff2522cb406dd22c19acedc40b68d482628f7 (patch)
tree2ffe917a60d6364d648c314323944fd780d3de85 /contrib/libs/sqlite3
parent9d42691833fa286dd17ed69b129158a5d0896245 (diff)
downloadydb-a69ff2522cb406dd22c19acedc40b68d482628f7.tar.gz
intermediate changes
ref:1abbc1a4aac58e9775b192a06be577ba688ea039
Diffstat (limited to 'contrib/libs/sqlite3')
-rw-r--r--contrib/libs/sqlite3/.yandex_meta/devtools.licenses.report286
-rw-r--r--contrib/libs/sqlite3/config.h4
-rw-r--r--contrib/libs/sqlite3/sqlite3.c216
-rw-r--r--contrib/libs/sqlite3/sqlite3.h16
4 files changed, 301 insertions, 221 deletions
diff --git a/contrib/libs/sqlite3/.yandex_meta/devtools.licenses.report b/contrib/libs/sqlite3/.yandex_meta/devtools.licenses.report
index 0ecab85ccd..7858920149 100644
--- a/contrib/libs/sqlite3/.yandex_meta/devtools.licenses.report
+++ b/contrib/libs/sqlite3/.yandex_meta/devtools.licenses.report
@@ -39,7 +39,7 @@ BELONGS ya.make
Match type : TEXT
Links : http://www.linfo.org/publicdomain.html, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/public-domain.LICENSE
Files with this license:
- sqlite3.c [173862:173862]
+ sqlite3.c [173937:173937]
SKIP LicenseRef-scancode-proprietary-license 8426a059ede424b00bf0246f20b5d31f
BELONGS ya.make
@@ -52,7 +52,7 @@ BELONGS ya.make
Match type : REFERENCE
Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/proprietary-license.LICENSE
Files with this license:
- sqlite3.c [65508:65508]
+ sqlite3.c [65523:65523]
KEEP blessing 85b808eb169d4456ed67e0cf819b320f
BELONGS ya.make
@@ -67,146 +67,146 @@ BELONGS ya.make
sqlite3.c [90:95]
sqlite3.c [140:145]
sqlite3.c [311:316]
- sqlite3.c [10695:10700]
- sqlite3.c [12537:12542]
- sqlite3.c [13128:13133]
- sqlite3.c [13726:13731]
- sqlite3.c [14673:14678]
- sqlite3.c [14920:14925]
- sqlite3.c [15337:15342]
- sqlite3.c [15973:15978]
- sqlite3.c [16168:16173]
- sqlite3.c [16196:16201]
- sqlite3.c [16452:16457]
- sqlite3.c [20612:20617]
- sqlite3.c [20655:20660]
- sqlite3.c [20817:20822]
- sqlite3.c [21599:21604]
- sqlite3.c [22006:22011]
- sqlite3.c [22024:22029]
- sqlite3.c [23057:23062]
- sqlite3.c [24417:24422]
- sqlite3.c [24864:24869]
- sqlite3.c [24954:24959]
- sqlite3.c [25016:25021]
- sqlite3.c [25310:25315]
- sqlite3.c [25841:25846]
- sqlite3.c [26531:26536]
- sqlite3.c [27110:27115]
- sqlite3.c [27474:27479]
- sqlite3.c [27693:27698]
- sqlite3.c [28090:28095]
- sqlite3.c [28116:28121]
- sqlite3.c [28584:28589]
- sqlite3.c [30807:30812]
- sqlite3.c [31627:31632]
- sqlite3.c [31769:31774]
- sqlite3.c [32046:32051]
- sqlite3.c [32584:32589]
- sqlite3.c [34302:34307]
- sqlite3.c [34778:34783]
- sqlite3.c [42910:42915]
- sqlite3.c [49067:49072]
- sqlite3.c [49948:49953]
- sqlite3.c [50362:50367]
- sqlite3.c [51250:51255]
- sqlite3.c [52537:52542]
- sqlite3.c [53042:53047]
- sqlite3.c [53066:53071]
- sqlite3.c [60934:60939]
- sqlite3.c [65092:65097]
- sqlite3.c [65111:65116]
- sqlite3.c [66136:66141]
- sqlite3.c [77053:77058]
- sqlite3.c [77826:77831]
- sqlite3.c [79771:79776]
- sqlite3.c [85033:85038]
- sqlite3.c [87174:87179]
- sqlite3.c [87369:87374]
- sqlite3.c [95965:95970]
- sqlite3.c [96484:96489]
- sqlite3.c [99253:99258]
- sqlite3.c [99680:99685]
- sqlite3.c [100121:100126]
- sqlite3.c [100381:100386]
- sqlite3.c [102440:102445]
- sqlite3.c [108793:108798]
- sqlite3.c [111054:111059]
- sqlite3.c [112987:112992]
- sqlite3.c [113588:113593]
- sqlite3.c [113859:113864]
- sqlite3.c [119498:119503]
- sqlite3.c [120038:120043]
- sqlite3.c [121023:121028]
- sqlite3.c [123409:123414]
- sqlite3.c [124888:124893]
- sqlite3.c [128020:128025]
- sqlite3.c [128164:128169]
- sqlite3.c [128184:128189]
- sqlite3.c [129736:129741]
- sqlite3.c [133122:133127]
- sqlite3.c [134179:134184]
- sqlite3.c [141731:141736]
- sqlite3.c [141931:141936]
- sqlite3.c [143362:143367]
- sqlite3.c [144702:144707]
- sqlite3.c [145020:145025]
- sqlite3.c [145429:145434]
- sqlite3.c [146775:146780]
- sqlite3.c [146797:146802]
- sqlite3.c [150106:150111]
- sqlite3.c [151946:151951]
- sqlite3.c [158120:158125]
- sqlite3.c [161225:161230]
- sqlite3.c [166635:166640]
- sqlite3.c [167976:167981]
- sqlite3.c [168269:168274]
- sqlite3.c [168290:168295]
- sqlite3.c [168323:168328]
- sqlite3.c [168360:168365]
- sqlite3.c [173189:173194]
- sqlite3.c [173524:173529]
- sqlite3.c [173816:173821]
- sqlite3.c [174028:174033]
- sqlite3.c [180580:180585]
- sqlite3.c [181139:181144]
- sqlite3.c [182435:182440]
- sqlite3.c [182821:182826]
- sqlite3.c [183486:183491]
- sqlite3.c [184009:184014]
- sqlite3.c [184246:184251]
- sqlite3.c [184707:184712]
- sqlite3.c [190519:190524]
- sqlite3.c [192273:192278]
- sqlite3.c [192673:192678]
- sqlite3.c [193059:193064]
- sqlite3.c [195737:195742]
- sqlite3.c [200141:200146]
- sqlite3.c [202140:202145]
- sqlite3.c [202697:202702]
- sqlite3.c [202962:202967]
- sqlite3.c [203053:203058]
- sqlite3.c [208920:208925]
- sqlite3.c [209823:209828]
- sqlite3.c [216060:216065]
- sqlite3.c [216636:216641]
- sqlite3.c [217512:217517]
- sqlite3.c [218989:218994]
- sqlite3.c [219704:219709]
- sqlite3.c [220113:220118]
- sqlite3.c [221079:221084]
- sqlite3.c [224148:224153]
- sqlite3.c [224709:224714]
- sqlite3.c [231529:231534]
- sqlite3.c [234456:234461]
- sqlite3.c [235625:235630]
- sqlite3.c [237041:237046]
- sqlite3.c [237820:237825]
- sqlite3.c [238165:238170]
- sqlite3.c [238963:238968]
+ sqlite3.c [10699:10704]
+ sqlite3.c [12541:12546]
+ sqlite3.c [13132:13137]
+ sqlite3.c [13730:13735]
+ sqlite3.c [14677:14682]
+ sqlite3.c [14924:14929]
+ sqlite3.c [15341:15346]
+ sqlite3.c [15977:15982]
+ sqlite3.c [16172:16177]
+ sqlite3.c [16200:16205]
+ sqlite3.c [16456:16461]
+ sqlite3.c [20621:20626]
+ sqlite3.c [20664:20669]
+ sqlite3.c [20826:20831]
+ sqlite3.c [21608:21613]
+ sqlite3.c [22015:22020]
+ sqlite3.c [22033:22038]
+ sqlite3.c [23066:23071]
+ sqlite3.c [24426:24431]
+ sqlite3.c [24873:24878]
+ sqlite3.c [24963:24968]
+ sqlite3.c [25025:25030]
+ sqlite3.c [25319:25324]
+ sqlite3.c [25850:25855]
+ sqlite3.c [26540:26545]
+ sqlite3.c [27119:27124]
+ sqlite3.c [27483:27488]
+ sqlite3.c [27702:27707]
+ sqlite3.c [28099:28104]
+ sqlite3.c [28125:28130]
+ sqlite3.c [28593:28598]
+ sqlite3.c [30816:30821]
+ sqlite3.c [31636:31641]
+ sqlite3.c [31778:31783]
+ sqlite3.c [32055:32060]
+ sqlite3.c [32593:32598]
+ sqlite3.c [34311:34316]
+ sqlite3.c [34787:34792]
+ sqlite3.c [42919:42924]
+ sqlite3.c [49076:49081]
+ sqlite3.c [49957:49962]
+ sqlite3.c [50371:50376]
+ sqlite3.c [51260:51265]
+ sqlite3.c [52547:52552]
+ sqlite3.c [53052:53057]
+ sqlite3.c [53076:53081]
+ sqlite3.c [60947:60952]
+ sqlite3.c [65105:65110]
+ sqlite3.c [65124:65129]
+ sqlite3.c [66151:66156]
+ sqlite3.c [77068:77073]
+ sqlite3.c [77841:77846]
+ sqlite3.c [79787:79792]
+ sqlite3.c [85049:85054]
+ sqlite3.c [87190:87195]
+ sqlite3.c [87385:87390]
+ sqlite3.c [95993:95998]
+ sqlite3.c [96512:96517]
+ sqlite3.c [99281:99286]
+ sqlite3.c [99708:99713]
+ sqlite3.c [100149:100154]
+ sqlite3.c [100409:100414]
+ sqlite3.c [102468:102473]
+ sqlite3.c [108821:108826]
+ sqlite3.c [111084:111089]
+ sqlite3.c [113017:113022]
+ sqlite3.c [113618:113623]
+ sqlite3.c [113889:113894]
+ sqlite3.c [119533:119538]
+ sqlite3.c [120073:120078]
+ sqlite3.c [121058:121063]
+ sqlite3.c [123444:123449]
+ sqlite3.c [124923:124928]
+ sqlite3.c [128054:128059]
+ sqlite3.c [128198:128203]
+ sqlite3.c [128218:128223]
+ sqlite3.c [129770:129775]
+ sqlite3.c [133156:133161]
+ sqlite3.c [134213:134218]
+ sqlite3.c [141765:141770]
+ sqlite3.c [141965:141970]
+ sqlite3.c [143397:143402]
+ sqlite3.c [144737:144742]
+ sqlite3.c [145055:145060]
+ sqlite3.c [145464:145469]
+ sqlite3.c [146810:146815]
+ sqlite3.c [146832:146837]
+ sqlite3.c [150154:150159]
+ sqlite3.c [151994:151999]
+ sqlite3.c [158190:158195]
+ sqlite3.c [161300:161305]
+ sqlite3.c [166710:166715]
+ sqlite3.c [168051:168056]
+ sqlite3.c [168344:168349]
+ sqlite3.c [168365:168370]
+ sqlite3.c [168398:168403]
+ sqlite3.c [168435:168440]
+ sqlite3.c [173264:173269]
+ sqlite3.c [173599:173604]
+ sqlite3.c [173891:173896]
+ sqlite3.c [174103:174108]
+ sqlite3.c [180655:180660]
+ sqlite3.c [181214:181219]
+ sqlite3.c [182510:182515]
+ sqlite3.c [182896:182901]
+ sqlite3.c [183561:183566]
+ sqlite3.c [184084:184089]
+ sqlite3.c [184321:184326]
+ sqlite3.c [184782:184787]
+ sqlite3.c [190594:190599]
+ sqlite3.c [192348:192353]
+ sqlite3.c [192748:192753]
+ sqlite3.c [193134:193139]
+ sqlite3.c [195812:195817]
+ sqlite3.c [200216:200221]
+ sqlite3.c [202215:202220]
+ sqlite3.c [202772:202777]
+ sqlite3.c [203037:203042]
+ sqlite3.c [203128:203133]
+ sqlite3.c [208995:209000]
+ sqlite3.c [209898:209903]
+ sqlite3.c [216136:216141]
+ sqlite3.c [216712:216717]
+ sqlite3.c [217588:217593]
+ sqlite3.c [219065:219070]
+ sqlite3.c [219780:219785]
+ sqlite3.c [220189:220194]
+ sqlite3.c [221155:221160]
+ sqlite3.c [224224:224229]
+ sqlite3.c [224785:224790]
+ sqlite3.c [231605:231610]
+ sqlite3.c [234532:234537]
+ sqlite3.c [235701:235706]
+ sqlite3.c [237117:237122]
+ sqlite3.c [237896:237901]
+ sqlite3.c [238241:238246]
+ sqlite3.c [239039:239044]
sqlite3.h [4:9]
- sqlite3.h [10388:10393]
- sqlite3.h [12230:12235]
+ sqlite3.h [10392:10397]
+ sqlite3.h [12234:12239]
sqlite3ext.h [4:9]
test_multiplex.c [4:9]
test_multiplex.h [4:9]
@@ -256,7 +256,7 @@ BELONGS ya.make
Match type : REFERENCE
Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/proprietary-license.LICENSE
Files with this license:
- sqlite3.c [120127:120127]
+ sqlite3.c [120162:120162]
KEEP Public-Domain f14cda0580418473b9b9cbd71db6f933
BELONGS ya.make
@@ -269,4 +269,4 @@ BELONGS ya.make
Match type : TEXT
Links : http://www.linfo.org/publicdomain.html, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/public-domain.LICENSE
Files with this license:
- sqlite3.c [29421:29422]
+ sqlite3.c [29430:29431]
diff --git a/contrib/libs/sqlite3/config.h b/contrib/libs/sqlite3/config.h
index 711879636a..ff679d6f17 100644
--- a/contrib/libs/sqlite3/config.h
+++ b/contrib/libs/sqlite3/config.h
@@ -114,13 +114,13 @@
#define PACKAGE_NAME "sqlite"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "sqlite 3.38.0"
+#define PACKAGE_STRING "sqlite 3.38.1"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "sqlite"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "3.38.0"
+#define PACKAGE_VERSION "3.38.1"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
diff --git a/contrib/libs/sqlite3/sqlite3.c b/contrib/libs/sqlite3/sqlite3.c
index 8d8a5b36fc..e8f8a37fd2 100644
--- a/contrib/libs/sqlite3/sqlite3.c
+++ b/contrib/libs/sqlite3/sqlite3.c
@@ -1,6 +1,6 @@
/******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite
-** version 3.38.0. By combining all the individual C code files into this
+** version 3.38.1. By combining all the individual C code files into this
** 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
** possible if the files were compiled separately. Performance improvements
@@ -453,9 +453,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
-#define SQLITE_VERSION "3.38.0"
-#define SQLITE_VERSION_NUMBER 3038000
-#define SQLITE_SOURCE_ID "2022-02-22 18:58:40 40fa792d359f84c3b9e9d6623743e1a59826274e221df1bde8f47086968aalt1"
+#define SQLITE_VERSION "3.38.1"
+#define SQLITE_VERSION_NUMBER 3038001
+#define SQLITE_SOURCE_ID "2022-03-12 13:37:29 38c210fdd258658321c85ec9c01a072fda3ada94540e3239d29b34dc547aalt1"
/*
** CAPI3REF: Run-Time Library Version Numbers
@@ -5286,6 +5286,10 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** even empty strings, are always zero-terminated. ^The return
** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
**
+** ^Strings returned by sqlite3_column_text16() always have the endianness
+** which is native to the platform, regardless of the text encoding set
+** for the database.
+**
** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
** [unprotected sqlite3_value] object. In a multithreaded environment,
** an unprotected sqlite3_value object may only be used safely with
@@ -5299,7 +5303,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** [application-defined SQL functions] or [virtual tables], not within
** top-level application code.
**
-** The these routines may attempt to convert the datatype of the result.
+** These routines may attempt to convert the datatype of the result.
** ^For example, if the internal representation is FLOAT and a text result
** is requested, [sqlite3_snprintf()] is used internally to perform the
** conversion automatically. ^(The following table details the conversions
@@ -5324,7 +5328,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** <tr><td> TEXT <td> BLOB <td> No change
** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
-** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
+** <tr><td> BLOB <td> TEXT <td> [CAST] to TEXT, ensure zero terminator
** </table>
** </blockquote>)^
**
@@ -10074,7 +10078,7 @@ SQLITE_API int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut);
** ^When xBestIndex returns, the sqlite3_value object returned by
** sqlite3_vtab_rhs_value() is automatically deallocated.
**
-** The "_rhs_" in the name of this routine is an appreviation for
+** The "_rhs_" in the name of this routine is an abbreviation for
** "Right-Hand Side".
*/
SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);
@@ -20365,7 +20369,12 @@ SQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);
SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);
SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);
+
SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
+#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
+ && !defined(SQLITE_OMIT_VIRTUALTABLE)
+SQLITE_PRIVATE void sqlite3VtabWriteAll(sqlite3_index_info*);
+#endif
SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
@@ -23655,7 +23664,7 @@ static int toLocaltime(
p->D = sLocal.tm_mday;
p->h = sLocal.tm_hour;
p->m = sLocal.tm_min;
- p->s = sLocal.tm_sec;
+ p->s = sLocal.tm_sec + (p->iJD%1000)*0.001;
p->validYMD = 1;
p->validHMS = 1;
p->validJD = 0;
@@ -50909,7 +50918,8 @@ SQLITE_PRIVATE void sqlite3PcacheDrop(PgHdr *p){
** make it so.
*/
SQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr *p){
- assert( p->nRef>0 );
+ assert( p->nRef>0 || p->pCache->bPurgeable==0 );
+ testcase( p->nRef==0 );
assert( sqlite3PcachePageSanity(p) );
if( p->flags & (PGHDR_CLEAN|PGHDR_DONT_WRITE) ){ /*OPTIMIZATION-IF-FALSE*/
p->flags &= ~PGHDR_DONT_WRITE;
@@ -56041,6 +56051,9 @@ static int pager_playback(Pager *pPager, int isHot){
goto end_playback;
}
pPager->dbSize = mxPg;
+ if( pPager->mxPgno<mxPg ){
+ pPager->mxPgno = mxPg;
+ }
}
/* Copy original pages out of the journal and back into the
@@ -65400,7 +65413,9 @@ struct MemPage {
u8 *apOvfl[4]; /* Pointers to the body of overflow cells */
BtShared *pBt; /* Pointer to BtShared that this page is part of */
u8 *aData; /* Pointer to disk image of the page data */
- u8 *aDataEnd; /* One byte past the end of usable data */
+ u8 *aDataEnd; /* One byte past the end of the entire page - not just
+ ** the usable space, the entire page. Used to prevent
+ ** corruption-induced of buffer overflow. */
u8 *aCellIdx; /* The cell index area */
u8 *aDataOfst; /* Same as aData for leaves. aData+4 for interior */
DbPage *pDbPage; /* Pager page handle */
@@ -68185,7 +68200,7 @@ static int btreeInitPage(MemPage *pPage){
pPage->nOverflow = 0;
pPage->cellOffset = pPage->hdrOffset + 8 + pPage->childPtrSize;
pPage->aCellIdx = data + pPage->childPtrSize + 8;
- pPage->aDataEnd = pPage->aData + pBt->usableSize;
+ pPage->aDataEnd = pPage->aData + pBt->pageSize;
pPage->aDataOfst = pPage->aData + pPage->childPtrSize;
/* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
** number of cells on the page. */
@@ -68220,7 +68235,7 @@ static void zeroPage(MemPage *pPage, int flags){
u8 hdr = pPage->hdrOffset;
u16 first;
- assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno );
+ assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno || CORRUPT_DB );
assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );
assert( sqlite3PagerGetData(pPage->pDbPage) == data );
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
@@ -68236,7 +68251,7 @@ static void zeroPage(MemPage *pPage, int flags){
pPage->nFree = (u16)(pBt->usableSize - first);
decodeFlags(pPage, flags);
pPage->cellOffset = first;
- pPage->aDataEnd = &data[pBt->usableSize];
+ pPage->aDataEnd = &data[pBt->pageSize];
pPage->aCellIdx = &data[first];
pPage->aDataOfst = &data[pPage->childPtrSize];
pPage->nOverflow = 0;
@@ -68362,7 +68377,7 @@ static int getAndInitPage(
goto getAndInitPage_error2;
}
}
- assert( (*ppPage)->pgno==pgno );
+ assert( (*ppPage)->pgno==pgno || CORRUPT_DB );
assert( (*ppPage)->aData==sqlite3PagerGetData(pDbPage) );
/* If obtaining a child page for a cursor, we must verify that the page is
@@ -71449,7 +71464,7 @@ static int moveToRoot(BtCursor *pCur){
pCur->curIntKey = pCur->pPage->intKey;
}
pRoot = pCur->pPage;
- assert( pRoot->pgno==pCur->pgnoRoot );
+ assert( pRoot->pgno==pCur->pgnoRoot || CORRUPT_DB );
/* If pCur->pKeyInfo is not NULL, then the caller that opened this cursor
** expected to open it on an index b-tree. Otherwise, if pKeyInfo is
@@ -75117,7 +75132,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
assert( pPage->intKey || pX->nKey>=0 || (flags & BTREE_PREFORMAT) );
assert( pPage->leaf || !pPage->intKey );
if( pPage->nFree<0 ){
- if( NEVER(pCur->eState>CURSOR_INVALID) ){
+ if( pCur->eState>CURSOR_INVALID ){
rc = SQLITE_CORRUPT_BKPT;
}else{
rc = btreeComputeFreeSpace(pPage);
@@ -78738,6 +78753,7 @@ SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(
void (*xDestructor)(void*)
){
assert( pMem->flags==MEM_Null );
+ vdbeMemClear(pMem);
pMem->u.zPType = zPType ? zPType : "";
pMem->z = pPtr;
pMem->flags = MEM_Null|MEM_Dyn|MEM_Subtype|MEM_Term;
@@ -89992,10 +90008,18 @@ case OP_Offset: { /* out3 */
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
pC = p->apCsr[pOp->p1];
pOut = &p->aMem[pOp->p3];
- if( NEVER(pC==0) || pC->eCurType!=CURTYPE_BTREE ){
+ if( pC==0 || pC->eCurType!=CURTYPE_BTREE ){
sqlite3VdbeMemSetNull(pOut);
}else{
- sqlite3VdbeMemSetInt64(pOut, sqlite3BtreeOffset(pC->uc.pCursor));
+ if( pC->deferredMoveto ){
+ rc = sqlite3VdbeFinishMoveto(pC);
+ if( rc ) goto abort_due_to_error;
+ }
+ if( sqlite3BtreeEof(pC->uc.pCursor) ){
+ sqlite3VdbeMemSetNull(pOut);
+ }else{
+ sqlite3VdbeMemSetInt64(pOut, sqlite3BtreeOffset(pC->uc.pCursor));
+ }
}
break;
}
@@ -93074,6 +93098,10 @@ case OP_Rowid: { /* out2 */
** Move the cursor P1 to a null row. Any OP_Column operations
** that occur while the cursor is on the null row will always
** write a NULL.
+**
+** Or, if P1 is a Pseudo-Cursor (a cursor opened using OP_OpenPseudo)
+** just reset the cache for that cursor. This causes the row of
+** content held by the pseudo-cursor to be reparsed.
*/
case OP_NullRow: {
VdbeCursor *pC;
@@ -109920,19 +109948,21 @@ static int renameParseSql(
){
int rc;
- db->init.iDb = bTemp ? 1 : sqlite3FindDbName(db, zDb);
-
- /* Parse the SQL statement passed as the first argument. If no error
- ** occurs and the parse does not result in a new table, index or
- ** trigger object, the database must be corrupt. */
sqlite3ParseObjectInit(p, db);
+ if( zSql==0 ){
+ return SQLITE_NOMEM;
+ }
+ if( sqlite3StrNICmp(zSql,"CREATE ",7)!=0 ){
+ return SQLITE_CORRUPT_BKPT;
+ }
+ db->init.iDb = bTemp ? 1 : sqlite3FindDbName(db, zDb);
p->eParseMode = PARSE_MODE_RENAME;
p->db = db;
p->nQueryLoop = 1;
- rc = zSql ? sqlite3RunParser(p, zSql) : SQLITE_NOMEM;
+ rc = sqlite3RunParser(p, zSql);
if( db->mallocFailed ) rc = SQLITE_NOMEM;
if( rc==SQLITE_OK
- && p->pNewTable==0 && p->pNewIndex==0 && p->pNewTrigger==0
+ && NEVER(p->pNewTable==0 && p->pNewIndex==0 && p->pNewTrigger==0)
){
rc = SQLITE_CORRUPT_BKPT;
}
@@ -116681,6 +116711,11 @@ SQLITE_PRIVATE void sqlite3EndTable(
int addrInsLoop; /* Top of the loop for inserting rows */
Table *pSelTab; /* A table that describes the SELECT results */
+ if( IN_SPECIAL_PARSE ){
+ pParse->rc = SQLITE_ERROR;
+ pParse->nErr++;
+ return;
+ }
regYield = ++pParse->nMem;
regRec = ++pParse->nMem;
regRowid = ++pParse->nMem;
@@ -123260,8 +123295,8 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){
INLINE_FUNC(likelihood, 2, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
INLINE_FUNC(likely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
- FUNCTION2(sqlite_offset, 1, 0, 0, noopFunc, SQLITE_FUNC_OFFSET|
- SQLITE_FUNC_TYPEOF),
+ {1, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|SQLITE_FUNC_OFFSET|SQLITE_FUNC_TYPEOF,
+ 0, 0, noopFunc, 0, 0, 0, "sqlite_offset", {0} },
#endif
FUNCTION(ltrim, 1, 1, 0, trimFunc ),
FUNCTION(ltrim, 2, 1, 0, trimFunc ),
@@ -125679,7 +125714,11 @@ SQLITE_PRIVATE void sqlite3Insert(
**
** This is the 2nd template.
*/
- if( pColumn==0 && xferOptimization(pParse, pTab, pSelect, onError, iDb) ){
+ if( pColumn==0
+ && pSelect!=0
+ && pTrigger==0
+ && xferOptimization(pParse, pTab, pSelect, onError, iDb)
+ ){
assert( !pTrigger );
assert( pList==0 );
goto insert_end;
@@ -127650,18 +127689,13 @@ static int xferOptimization(
int destHasUniqueIdx = 0; /* True if pDest has a UNIQUE index */
int regData, regRowid; /* Registers holding data and rowid */
- if( pSelect==0 ){
- return 0; /* Must be of the form INSERT INTO ... SELECT ... */
- }
+ assert( pSelect!=0 );
if( pParse->pWith || pSelect->pWith ){
/* Do not attempt to process this query if there are an WITH clauses
** attached to it. Proceeding may generate a false "no such table: xxx"
** error if pSelect reads from a CTE named "xxx". */
return 0;
}
- if( sqlite3TriggerList(pParse, pDest) ){
- return 0; /* tab1 must not have triggers */
- }
#ifndef SQLITE_OMIT_VIRTUALTABLE
if( IsVirtual(pDest) ){
return 0; /* tab1 must not be a virtual table */
@@ -142374,6 +142408,7 @@ static TriggerStep *triggerStepAllocate(
sqlite3 *db = pParse->db;
TriggerStep *pTriggerStep;
+ if( pParse->nErr ) return 0;
pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n + 1);
if( pTriggerStep ){
char *z = (char*)&pTriggerStep[1];
@@ -148187,6 +148222,7 @@ static int codeAllEqualityTerms(
VdbeCoverageIf(v, bRev!=0);
VdbeComment((v, "begin skip-scan on %s", pIdx->zName));
j = sqlite3VdbeAddOp0(v, OP_Goto);
+ assert( pLevel->addrSkip==0 );
pLevel->addrSkip = sqlite3VdbeAddOp4Int(v, (bRev?OP_SeekLT:OP_SeekGT),
iIdxCur, 0, regBase, nSkip);
VdbeCoverageIf(v, bRev==0);
@@ -148784,6 +148820,7 @@ static SQLITE_NOINLINE void filterPullDown(
WhereLevel *pLevel = &pWInfo->a[iLevel];
WhereLoop *pLoop = pLevel->pWLoop;
if( pLevel->regFilter==0 ) continue;
+ if( pLevel->pWLoop->nSkip ) continue;
/* ,--- Because sqlite3ConstructBloomFilter() has will not have set
** vvvvv--' pLevel->regFilter if this were true. */
if( NEVER(pLoop->prereq & notReady) ) continue;
@@ -148918,7 +148955,6 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
int iReg; /* P3 Value for OP_VFilter */
int addrNotFound;
int nConstraint = pLoop->nLTerm;
- int iIn; /* Counter for IN constraints */
iReg = sqlite3GetTempRange(pParse, nConstraint+2);
addrNotFound = pLevel->addrBrk;
@@ -148964,50 +149000,54 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
pLevel->op = pWInfo->eOnePass ? OP_Noop : OP_VNext;
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 );
- if( pLoop->wsFlags & WHERE_IN_ABLE ){
- iIn = pLevel->u.in.nIn;
- }else{
- iIn = 0;
- }
- for(j=nConstraint-1; j>=0; j--){
- int bIn; /* True to generate byte code to loop over RHS IN values */
+
+ for(j=0; j<nConstraint; j++){
pTerm = pLoop->aLTerm[j];
+ if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){
+ disableTerm(pLevel, pTerm);
+ continue;
+ }
if( (pTerm->eOperator & WO_IN)!=0
&& (SMASKBIT32(j) & pLoop->u.vtab.mHandleIn)==0
+ && !db->mallocFailed
){
- bIn = 1;
- }else{
- bIn = 0;
- }
- if( bIn ) iIn--;
- if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){
- disableTerm(pLevel, pTerm);
- }else if( bIn && sqlite3ExprVectorSize(pTerm->pExpr->pLeft)==1 ){
Expr *pCompare; /* The comparison operator */
Expr *pRight; /* RHS of the comparison */
VdbeOp *pOp; /* Opcode to access the value of the IN constraint */
+ int iIn; /* IN loop corresponding to the j-th constraint */
/* Reload the constraint value into reg[iReg+j+2]. The same value
** was loaded into the same register prior to the OP_VFilter, but
** the xFilter implementation might have changed the datatype or
- ** encoding of the value in the register, so it *must* be reloaded. */
- assert( pLevel->u.in.aInLoop!=0 || db->mallocFailed );
- if( !db->mallocFailed ){
- assert( iIn>=0 && iIn<pLevel->u.in.nIn );
+ ** encoding of the value in the register, so it *must* be reloaded.
+ */
+ for(iIn=0; ALWAYS(iIn<pLevel->u.in.nIn); iIn++){
pOp = sqlite3VdbeGetOp(v, pLevel->u.in.aInLoop[iIn].addrInTop);
- assert( pOp->opcode==OP_Column || pOp->opcode==OP_Rowid );
- assert( pOp->opcode!=OP_Column || pOp->p3==iReg+j+2 );
- assert( pOp->opcode!=OP_Rowid || pOp->p2==iReg+j+2 );
- testcase( pOp->opcode==OP_Rowid );
- sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);
+ if( (pOp->opcode==OP_Column && pOp->p3==iReg+j+2)
+ || (pOp->opcode==OP_Rowid && pOp->p2==iReg+j+2)
+ ){
+ testcase( pOp->opcode==OP_Rowid );
+ sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);
+ break;
+ }
}
/* Generate code that will continue to the next row if
- ** the IN constraint is not satisfied */
+ ** the IN constraint is not satisfied
+ */
pCompare = sqlite3PExpr(pParse, TK_EQ, 0, 0);
- assert( pCompare!=0 || db->mallocFailed );
- if( pCompare ){
- pCompare->pLeft = pTerm->pExpr->pLeft;
+ if( !db->mallocFailed ){
+ int iFld = pTerm->u.x.iField;
+ Expr *pLeft = pTerm->pExpr->pLeft;
+ assert( pLeft!=0 );
+ if( iFld>0 ){
+ assert( pLeft->op==TK_VECTOR );
+ assert( ExprUseXList(pLeft) );
+ assert( iFld<=pLeft->x.pList->nExpr );
+ pCompare->pLeft = pLeft->x.pList->a[iFld-1].pExpr;
+ }else{
+ pCompare->pLeft = pLeft;
+ }
pCompare->pRight = pRight = sqlite3Expr(db, TK_REGISTER, 0);
if( pRight ){
pRight->iTable = iReg+j+2;
@@ -149016,11 +149056,11 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
);
}
pCompare->pLeft = 0;
- sqlite3ExprDelete(db, pCompare);
}
+ sqlite3ExprDelete(db, pCompare);
}
}
- assert( iIn==0 || db->mallocFailed );
+
/* These registers need to be preserved in case there is an IN operator
** loop. So we could deallocate the registers here (and potentially
** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0. But it seems
@@ -149730,6 +149770,14 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
** the initialization of the right-hand operand of the vector comparison
** might not occur, or might occur only in an OR branch that is not
** taken. dbsqlfuzz 80a9fade844b4fb43564efc972bcb2c68270f5d1.
+ **
+ ** 2022-03-03: Do not push down expressions that involve subqueries.
+ ** The subquery might get coded as a subroutine. Any table-references
+ ** in the subquery might be resolved to index-references for the index on
+ ** the OR branch in which the subroutine is coded. But if the subroutine
+ ** is invoked from a different OR branch that uses a different index, such
+ ** index-references will not work. tag-20220303a
+ ** https://sqlite.org/forum/forumpost/36937b197273d403
*/
if( pWC->nTerm>1 ){
int iTerm;
@@ -149743,7 +149791,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
continue;
}
if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
- testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO );
+ if( ExprHasProperty(pExpr, EP_Subquery) ) continue; /* tag-20220303a */
pExpr = sqlite3ExprDup(db, pExpr, 0);
pAndExpr = sqlite3ExprAnd(pParse, pAndExpr, pExpr);
}
@@ -153020,7 +153068,10 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter(
pLoop->wsFlags &= ~WHERE_BLOOMFILTER;
if( OptimizationDisabled(pParse->db, SQLITE_BloomPulldown) ) break;
while( ++iLevel < pWInfo->nLevel ){
+ const SrcItem *pTabItem;
pLevel = &pWInfo->a[iLevel];
+ pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
+ if( pTabItem->fg.jointype & JT_LEFT ) continue;
pLoop = pLevel->pWLoop;
if( NEVER(pLoop==0) ) continue;
if( pLoop->prereq & notReady ) continue;
@@ -155703,7 +155754,6 @@ SQLITE_API int sqlite3_vtab_rhs_value(
return rc;
}
-
/*
** Return true if ORDER BY clause may be handled as DISTINCT.
*/
@@ -155715,6 +155765,22 @@ SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info *pIdxInfo){
return pHidden->eDistinct;
}
+#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
+ && !defined(SQLITE_OMIT_VIRTUALTABLE)
+/*
+** Cause the prepared statement that is associated with a call to
+** xBestIndex to open write transactions on all attached schemas.
+** This is used by the (built-in) sqlite_dbpage virtual table.
+*/
+SQLITE_PRIVATE void sqlite3VtabWriteAll(sqlite3_index_info *pIdxInfo){
+ HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
+ Parse *pParse = pHidden->pParse;
+ int nDb = pParse->db->nDb;
+ int i;
+ for(i=0; i<nDb; i++) sqlite3BeginWriteOperation(pParse, 0, i);
+}
+#endif
+
/*
** Add all WhereLoop objects for a table of the join identified by
** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table.
@@ -158074,6 +158140,10 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
x = pPk->aiColumn[x];
assert( x>=0 );
+#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
+ }else if( pOp->opcode==OP_Offset ){
+ /* Do not need to translate the column number */
+#endif
}else{
testcase( x!=sqlite3StorageColumnToTable(pTab,x) );
x = sqlite3StorageColumnToTable(pTab,x);
@@ -159073,7 +159143,11 @@ static int disallowAggregatesInOrderByCb(Walker *pWalker, Expr *pExpr){
*/
SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
int rc = SQLITE_OK;
- if( p->pWin && p->pPrior==0 && ALWAYS((p->selFlags & SF_WinRewrite)==0) ){
+ if( p->pWin
+ && p->pPrior==0
+ && ALWAYS((p->selFlags & SF_WinRewrite)==0)
+ && ALWAYS(!IN_RENAME_OBJECT)
+ ){
Vdbe *v = sqlite3GetVdbe(pParse);
sqlite3 *db = pParse->db;
Select *pSub = 0; /* The subquery */
@@ -159148,6 +159222,7 @@ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
ExprList *pArgs;
assert( ExprUseXList(pWin->pOwner) );
+ assert( pWin->pFunc!=0 );
pArgs = pWin->pOwner->x.pList;
if( pWin->pFunc->funcFlags & SQLITE_FUNC_SUBTYPE ){
selectWindowRewriteEList(pParse, pMWin, pSrc, pArgs, pTab, &pSublist);
@@ -209975,6 +210050,7 @@ static int dbpageBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
){
pIdxInfo->orderByConsumed = 1;
}
+ sqlite3VtabWriteAll(pIdxInfo);
return SQLITE_OK;
}
@@ -232329,7 +232405,7 @@ static int fts5SorterNext(Fts5Cursor *pCsr){
rc = sqlite3_step(pSorter->pStmt);
if( rc==SQLITE_DONE ){
rc = SQLITE_OK;
- CsrFlagSet(pCsr, FTS5CSR_EOF);
+ CsrFlagSet(pCsr, FTS5CSR_EOF|FTS5CSR_REQUIRE_CONTENT);
}else if( rc==SQLITE_ROW ){
const u8 *a;
const u8 *aBlob;
@@ -234318,7 +234394,7 @@ static void fts5SourceIdFunc(
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
- sqlite3_result_text(pCtx, "fts5: 2022-02-22 18:58:40 40fa792d359f84c3b9e9d6623743e1a59826274e221df1bde8f47086968a1bab", -1, SQLITE_TRANSIENT);
+ sqlite3_result_text(pCtx, "fts5: 2022-03-12 13:37:29 38c210fdd258658321c85ec9c01a072fda3ada94540e3239d29b34dc547a8cbc", -1, SQLITE_TRANSIENT);
}
/*
diff --git a/contrib/libs/sqlite3/sqlite3.h b/contrib/libs/sqlite3/sqlite3.h
index b01c9aa9b6..4f731b7af2 100644
--- a/contrib/libs/sqlite3/sqlite3.h
+++ b/contrib/libs/sqlite3/sqlite3.h
@@ -146,9 +146,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
-#define SQLITE_VERSION "3.38.0"
-#define SQLITE_VERSION_NUMBER 3038000
-#define SQLITE_SOURCE_ID "2022-02-22 18:58:40 40fa792d359f84c3b9e9d6623743e1a59826274e221df1bde8f47086968aalt1"
+#define SQLITE_VERSION "3.38.1"
+#define SQLITE_VERSION_NUMBER 3038001
+#define SQLITE_SOURCE_ID "2022-03-12 13:37:29 38c210fdd258658321c85ec9c01a072fda3ada94540e3239d29b34dc547aalt1"
/*
** CAPI3REF: Run-Time Library Version Numbers
@@ -4979,6 +4979,10 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** even empty strings, are always zero-terminated. ^The return
** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
**
+** ^Strings returned by sqlite3_column_text16() always have the endianness
+** which is native to the platform, regardless of the text encoding set
+** for the database.
+**
** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
** [unprotected sqlite3_value] object. In a multithreaded environment,
** an unprotected sqlite3_value object may only be used safely with
@@ -4992,7 +4996,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** [application-defined SQL functions] or [virtual tables], not within
** top-level application code.
**
-** The these routines may attempt to convert the datatype of the result.
+** These routines may attempt to convert the datatype of the result.
** ^For example, if the internal representation is FLOAT and a text result
** is requested, [sqlite3_snprintf()] is used internally to perform the
** conversion automatically. ^(The following table details the conversions
@@ -5017,7 +5021,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** <tr><td> TEXT <td> BLOB <td> No change
** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
-** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
+** <tr><td> BLOB <td> TEXT <td> [CAST] to TEXT, ensure zero terminator
** </table>
** </blockquote>)^
**
@@ -9767,7 +9771,7 @@ SQLITE_API int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut);
** ^When xBestIndex returns, the sqlite3_value object returned by
** sqlite3_vtab_rhs_value() is automatically deallocated.
**
-** The "_rhs_" in the name of this routine is an appreviation for
+** The "_rhs_" in the name of this routine is an abbreviation for
** "Right-Hand Side".
*/
SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);