summaryrefslogtreecommitdiff
path: root/dev-db/sqlite/files/sqlite-3.32.3-backports_3.patch
diff options
context:
space:
mode:
Diffstat (limited to 'dev-db/sqlite/files/sqlite-3.32.3-backports_3.patch')
-rw-r--r--dev-db/sqlite/files/sqlite-3.32.3-backports_3.patch220
1 files changed, 220 insertions, 0 deletions
diff --git a/dev-db/sqlite/files/sqlite-3.32.3-backports_3.patch b/dev-db/sqlite/files/sqlite-3.32.3-backports_3.patch
new file mode 100644
index 000000000000..07cb5d4a3960
--- /dev/null
+++ b/dev-db/sqlite/files/sqlite-3.32.3-backports_3.patch
@@ -0,0 +1,220 @@
+https://sqlite.org/src/info/14eed318aa9e6e16
+https://sqlite.org/src/info/9679c0c61131f0e9
+https://sqlite.org/src/info/28515bbbae4fbc26
+https://sqlite.org/src/info/892e9191dc8f8056
+https://sqlite.org/src/info/270ac1a0f232d755
+
+--- /ext/fts3/fts3.c
++++ /ext/fts3/fts3.c
+@@ -5831,7 +5831,8 @@
+ fts3EvalRestart(pCsr, pRoot, &rc);
+ do {
+ fts3EvalNextRow(pCsr, pRoot, &rc);
+- assert( pRoot->bEof==0 );
++ assert_fts3_nc( pRoot->bEof==0 );
++ if( pRoot->bEof ) rc = FTS_CORRUPT_VTAB;
+ }while( pRoot->iDocid!=iDocid && rc==SQLITE_OK );
+ }
+ }
+--- /ext/misc/appendvfs.c
++++ /ext/misc/appendvfs.c
+@@ -439,7 +439,7 @@
+ p = (ApndFile*)pFile;
+ memset(p, 0, sizeof(*p));
+ pSubFile = ORIGFILE(pFile);
+- p->base.pMethods = &apnd_io_methods;
++ pFile->pMethods = &apnd_io_methods;
+ rc = pSubVfs->xOpen(pSubVfs, zName, pSubFile, flags, pOutFlags);
+ if( rc ) goto apnd_open_done;
+ rc = pSubFile->pMethods->xFileSize(pSubFile, &sz);
+--- /ext/misc/cksumvfs.c
++++ /ext/misc/cksumvfs.c
+@@ -634,7 +634,7 @@
+ p = (CksmFile*)pFile;
+ memset(p, 0, sizeof(*p));
+ pSubFile = ORIGFILE(pFile);
+- p->base.pMethods = &cksm_io_methods;
++ pFile->pMethods = &cksm_io_methods;
+ rc = pSubVfs->xOpen(pSubVfs, zName, pSubFile, flags, pOutFlags);
+ if( rc ) goto cksm_open_done;
+ if( flags & SQLITE_OPEN_WAL ){
+--- /src/date.c
++++ /src/date.c
+@@ -1112,8 +1112,8 @@
+ case 'm': sqlite3_snprintf(3, &z[j],"%02d",x.M); j+=2; break;
+ case 'M': sqlite3_snprintf(3, &z[j],"%02d",x.m); j+=2; break;
+ case 's': {
+- sqlite3_snprintf(30,&z[j],"%lld",
+- (i64)(x.iJD/1000 - 21086676*(i64)10000));
++ i64 iS = (i64)(x.iJD/1000 - 21086676*(i64)10000);
++ sqlite3Int64ToText(iS, &z[j]);
+ j += sqlite3Strlen30(&z[j]);
+ break;
+ }
+--- /src/memdb.c
++++ /src/memdb.c
+@@ -339,7 +339,7 @@
+ p->mFlags = SQLITE_DESERIALIZE_RESIZEABLE | SQLITE_DESERIALIZE_FREEONCLOSE;
+ assert( pOutFlags!=0 ); /* True because flags==SQLITE_OPEN_MAIN_DB */
+ *pOutFlags = flags | SQLITE_OPEN_MEMORY;
+- p->base.pMethods = &memdb_io_methods;
++ pFile->pMethods = &memdb_io_methods;
+ p->szMax = sqlite3GlobalConfig.mxMemdbSize;
+ return SQLITE_OK;
+ }
+--- /src/memjournal.c
++++ /src/memjournal.c
+@@ -366,7 +366,7 @@
+ assert( MEMJOURNAL_DFLT_FILECHUNKSIZE==fileChunkSize(p->nChunkSize) );
+ }
+
+- p->pMethod = (const sqlite3_io_methods*)&MemJournalMethods;
++ pJfd->pMethods = (const sqlite3_io_methods*)&MemJournalMethods;
+ p->nSpill = nSpill;
+ p->flags = flags;
+ p->zJournal = zName;
+@@ -392,7 +392,7 @@
+ int sqlite3JournalCreate(sqlite3_file *pJfd){
+ int rc = SQLITE_OK;
+ MemJournal *p = (MemJournal*)pJfd;
+- if( p->pMethod==&MemJournalMethods && (
++ if( pJfd->pMethods==&MemJournalMethods && (
+ #ifdef SQLITE_ENABLE_ATOMIC_WRITE
+ p->nSpill>0
+ #else
+--- /src/os_unix.c
++++ /src/os_unix.c
+@@ -5689,7 +5689,7 @@
+ if( rc!=SQLITE_OK ){
+ if( h>=0 ) robust_close(pNew, h, __LINE__);
+ }else{
+- pNew->pMethod = pLockingStyle;
++ pId->pMethods = pLockingStyle;
+ OpenCounter(+1);
+ verifyDbFile(pNew);
+ }
+--- /src/os_win.c
++++ /src/os_win.c
+@@ -5266,7 +5266,7 @@
+ }
+
+ sqlite3_free(zTmpname);
+- pFile->pMethod = pAppData ? pAppData->pMethod : &winIoMethod;
++ id->pMethods = pAppData ? pAppData->pMethod : &winIoMethod;
+ pFile->pVfs = pVfs;
+ pFile->h = h;
+ if( isReadonly ){
+--- /src/sqliteInt.h
++++ /src/sqliteInt.h
+@@ -4437,6 +4437,7 @@
+ int sqlite3FixExprList(DbFixer*, ExprList*);
+ int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
+ int sqlite3RealSameAsInt(double,sqlite3_int64);
++void sqlite3Int64ToText(i64,char*);
+ int sqlite3AtoF(const char *z, double*, int, u8);
+ int sqlite3GetInt32(const char *, int*);
+ int sqlite3Atoi(const char*);
+--- /src/test_multiplex.c
++++ /src/test_multiplex.c
+@@ -591,9 +591,9 @@
+
+ if( rc==SQLITE_OK ){
+ if( pSubOpen->pMethods->iVersion==1 ){
+- pMultiplexOpen->base.pMethods = &gMultiplex.sIoMethodsV1;
++ pConn->pMethods = &gMultiplex.sIoMethodsV1;
+ }else{
+- pMultiplexOpen->base.pMethods = &gMultiplex.sIoMethodsV2;
++ pConn->pMethods = &gMultiplex.sIoMethodsV2;
+ }
+ }else{
+ multiplexFreeComponents(pGroup);
+--- /src/util.c
++++ /src/util.c
+@@ -596,6 +596,30 @@
+ #endif
+
+ /*
++** Render an signed 64-bit integer as text. Store the result in zOut[].
++**
++** The caller must ensure that zOut[] is at least 21 bytes in size.
++*/
++void sqlite3Int64ToText(i64 v, char *zOut){
++ int i;
++ u64 x;
++ char zTemp[22];
++ if( v<0 ){
++ x = (v==SMALLEST_INT64) ? ((u64)1)<<63 : -v;
++ }else{
++ x = v;
++ }
++ i = sizeof(zTemp)-2;
++ zTemp[sizeof(zTemp)-1] = 0;
++ do{
++ zTemp[i--] = (x%10) + '0';
++ x = x/10;
++ }while( x );
++ if( v<0 ) zTemp[i--] = '-';
++ memcpy(zOut, &zTemp[i+1], sizeof(zTemp)-1-i);
++}
++
++/*
+ ** Compare the 19-character string zNum against the text representation
+ ** value 2^63: 9223372036854775808. Return negative, zero, or positive
+ ** if zNum is less than, equal to, or greater than the string.
+--- /src/vdbemem.c
++++ /src/vdbemem.c
+@@ -104,16 +104,25 @@
+ static void vdbeMemRenderNum(int sz, char *zBuf, Mem *p){
+ StrAccum acc;
+ assert( p->flags & (MEM_Int|MEM_Real|MEM_IntReal) );
+- sqlite3StrAccumInit(&acc, 0, zBuf, sz, 0);
++ assert( sz>22 );
+ if( p->flags & MEM_Int ){
+- sqlite3_str_appendf(&acc, "%lld", p->u.i);
+- }else if( p->flags & MEM_IntReal ){
+- sqlite3_str_appendf(&acc, "%!.15g", (double)p->u.i);
++#if GCC_VERSION>=7000000
++ /* Work-around for GCC bug
++ ** https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96270 */
++ i64 x;
++ assert( (p->flags&MEM_Int)*2==sizeof(x) );
++ memcpy(&x, (char*)&p->u, (p->flags&MEM_Int)*2);
++ sqlite3Int64ToText(x, zBuf);
++#else
++ sqlite3Int64ToText(p->u.i, zBuf);
++#endif
+ }else{
+- sqlite3_str_appendf(&acc, "%!.15g", p->u.r);
++ sqlite3StrAccumInit(&acc, 0, zBuf, sz, 0);
++ sqlite3_str_appendf(&acc, "%!.15g",
++ (p->flags & MEM_IntReal)!=0 ? (double)p->u.i : p->u.r);
++ assert( acc.zText==zBuf && acc.mxAlloc<=0 );
++ zBuf[acc.nChar] = 0; /* Fast version of sqlite3StrAccumFinish(&acc) */
+ }
+- assert( acc.zText==zBuf && acc.mxAlloc<=0 );
+- zBuf[acc.nChar] = 0; /* Fast version of sqlite3StrAccumFinish(&acc) */
+ }
+
+ #ifdef SQLITE_DEBUG
+--- /test/fts3corrupt4.test
++++ /test/fts3corrupt4.test
+@@ -6282,4 +6282,19 @@
+
+ set sqlite_fts3_enable_parentheses $saved
+
++#-------------------------------------------------------------------------
++reset_db
++do_execsql_test 47.1 {
++ CREATE VIRTUAL TABLE t1 USING fts3(a,b,c);
++}
++do_execsql_test 47.2 {
++ INSERT INTO t1_segdir VALUES(0,0,0,0,0,X'000130120106000106000106001f030001030001030000083230313630363039090107000107000107000001340901050001050001050000013509010400010400010400010730303030303030091c0400010400010400000662696e6172793c0301020200030102020003010202000301020200030102020003010202000301020200030102020003010202000301020200030102020003010202000008636f6d70696c657209010200010200010200000664627374617409070300010300010300010465627567090402000102000102000006656e61626c653f07020001020001020001020001020001020001020001020001020001020001020001020001010001020001020001020001020001020001020001020001020001087874656e73696f6e091f0400010400010400000466747334090a0300010300010300030135090d03000103000103000003676363090103000103000103000106656f706f6c790910030001030001030000056a736f6e310913030001030001030000046c6f6164091f030001030001030000036d6178091c02000102000102000105656d6f7279091c03000103000103000304737973350916030001030001030000066e6f636173653c02010202000301020200030102020003010202000301020200030102020003010202000301020200030102020003010202000301020200030102020000046f6d6974091f020001020001020000057274726565091903000103000103000302696d3c01010202000301020200030102020003010202000301020200030102020003010202000301a202000301020200030102020003010202000301020200000a746872656164736166650922020001020001020000047674616209070400010400010400000178b401010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200010101020001010102000101010200');
++ INSERT INTO t1_segdir VALUES(0,1,0,0,0,X'0001300425061b000008323031363036303903250700000134032505000001350325040001073030303030303003251a000008636f6d70696c657203250200000664627374617403250a00010465627567032508000006656e61626c650925090504040404040001087874656e73696f6e03251d0000046674733403250d0003013503250f000003676363032503000106656f706f6c790325110000056a736f6e310325130000046c6f616403251c0000036d6178032518000105656d6f7279032519000304737973350325150000046f6d697403251b000005727472656503251700000a7468726561647361666503251e0000047674616333250b00');
++}
++
++do_catchsql_test 47.3 {
++ SELECT matchinfo(t1) FROM t1 WHERE t1 MATCH '"json1 enable"';
++} {1 {database disk image is malformed}}
++
++
+ finish_test