From: dan Date: Tue, 16 Nov 2021 13:36:50 +0000 (+0000) Subject: Fix a problem causing an OOM within an ALTER TABLE ADD COLUMN command that adds a... X-Git-Tag: version-3.37.0~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=488b55856e794bd2f267781474cbaade9e523700;p=thirdparty%2Fsqlite.git Fix a problem causing an OOM within an ALTER TABLE ADD COLUMN command that adds a column with a CHECK constraint to go unreported. FossilOrigin-Name: a33f5e93ecb7d84291f6fecc7b60f0c555034aa47e24584c63c78d8a94710d82 --- diff --git a/manifest b/manifest index c941b84118..d42e91c2b4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Strengthen\sthe\ssticky-CORRUPT\sidea\sof\scheck-in\s[3feb0f1c3840904d]\sby\nautomatically\schanging\sthe\sfirst\sCOMMIT\safter\san\sSQLITE_CORRUPT\serror\sinto\na\sROLLBACK. -D 2021-11-15T19:10:13.878 +C Fix\sa\sproblem\scausing\san\sOOM\swithin\san\sALTER\sTABLE\sADD\sCOLUMN\scommand\sthat\sadds\sa\scolumn\swith\sa\sCHECK\sconstraint\sto\sgo\sunreported. +D 2021-11-16T13:36:50.684 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -555,7 +555,7 @@ F src/shell.c.in f8854bcb0d14707d661732698d5210d7f01694000c46e8014b323ad18f575be F src/sqlite.h.in 5cd209ac7dc4180f0e19292846f40440b8488015849ca0110c70b906b57d68f0 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8ff2fd2c166150b2e48639f5e506fb44e29f1a3f65031710b9e89d1c126ac839 -F src/sqliteInt.h c36cdf01fcd624f9988305158e89bf1d7246b3a05f0fe578bc7dd2507e53e59d +F src/sqliteInt.h 42c8f4c05ddbe8214d439aa80d98914d1883104f8f518820ce2e9e4e183c31fb F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a31657 F src/status.c 4b8bc2a6905163a38b739854a35b826c737333fab5b1f8e03fa7eb9a4799c4c1 F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1 @@ -614,7 +614,7 @@ F src/test_windirent.h 90dfbe95442c9762357fe128dc7ae3dc199d006de93eb33ba3972e0a9 F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394ba3f F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c -F src/tokenize.c bae853ad129d1129c063de8630a3e99e306283bc40146f359b1bb91be2c08f1e +F src/tokenize.c 865911afa00fed589cd03b25c140ca88544842aaef7b81f7d41ed769a7a54120 F src/treeview.c 9dfdb7ff7f6645d0a6458dbdf4ffac041c071c4533a6db8bb6e502b979ac67bc F src/trigger.c 2ef56f0b7b75349a5557d0604b475126329c2e1a02432e7d49c4c710613e8254 F src/update.c 69c4c10bc6873a80c0a77cb578f9fc60ee90003d03f9530bc3370fa24615772d @@ -659,6 +659,7 @@ F test/altercol.test b11fa1b131e80ab5b6ecfb3b725fb0419c14ca6efba5adb57aeabfc9baa F test/altercorrupt.test 2e1d705342cf9d7de884518ddbb053fd52d7e60d2b8869b7b63b2fda68435c12 F test/alterdropcol.test a653a3945f964d26845ec0cd0a8e74189f46de3119a984c5bc45457da392612e F test/alterdropcol2.test 527fce683b200d620f560f666c44ae33e22728e990a10a48a543280dfd4b4d41 +F test/alterfault.test 2a19a9b8d4e42e2915ea82598341f089c2c16bb55b3f474572c9176eba0b9bc1 F test/alterlegacy.test f38c6d06cda39e1f7b955bbce57f2e3ef5b7cb566d3d1234502093e228c15811 F test/altermalloc.test 167a47de41b5c638f5f5c6efb59784002b196fff70f98d9b4ed3cd74a3fb80c9 F test/altermalloc2.test ca3ebc01670d9313953a2b7628d8cc00dc5ea9988f229b3cbbbe1cca506dae45 @@ -1932,7 +1933,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9e1ecf438cb01d3d76950bcce1b3e4df29bedbb8176c8cede27e66f8e53e2098 -R 8502cb577f96122347daa35ce5c6ba62 -U drh -Z 8ae9bdb2af913bcacdf4433e1e237b15 +P bd66ab8a1bc3c43a57c7caff5f54545b0feb0177f1f51492f30d308c123c43ba +R 8e910d7ef9b9683ef8c5339395ac64ec +U dan +Z ce8501e7bda0295d8dc505431c6919db diff --git a/manifest.uuid b/manifest.uuid index 82ba03b8c8..2f4df70c92 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bd66ab8a1bc3c43a57c7caff5f54545b0feb0177f1f51492f30d308c123c43ba \ No newline at end of file +a33f5e93ecb7d84291f6fecc7b60f0c555034aa47e24584c63c78d8a94710d82 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index cece2360e8..09bccc92fe 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3555,7 +3555,6 @@ struct Parse { AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */ Parse *pToplevel; /* Parse structure for main program (or NULL) */ Table *pTriggerTab; /* Table triggers are being coded for */ - Parse *pParentParse; /* Parent parser if this parser is nested */ union { int addrCrTab; /* Address of OP_CreateBtree on CREATE TABLE */ Returning *pReturning; /* The RETURNING clause */ diff --git a/src/tokenize.c b/src/tokenize.c index 5d250e6f6a..e128d16148 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -573,6 +573,7 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ int lastTokenParsed = -1; /* type of the previous token */ sqlite3 *db = pParse->db; /* The database connection */ int mxSqlLen; /* Max length of an SQL string */ + Parse *pParentParse = 0; /* Outer parse context, if any */ #ifdef sqlite3Parser_ENGINEALWAYSONSTACK yyParser sEngine; /* Space to hold the Lemon-generated Parser object */ #endif @@ -608,7 +609,7 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ assert( pParse->pNewTrigger==0 ); assert( pParse->nVar==0 ); assert( pParse->pVList==0 ); - pParse->pParentParse = db->pParse; + pParentParse = db->pParse; db->pParse = pParse; while( 1 ){ n = sqlite3GetToken((u8*)zSql, &tokenType); @@ -723,8 +724,7 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ sqlite3DeleteTrigger(db, pParse->pNewTrigger); } sqlite3DbFree(db, pParse->pVList); - db->pParse = pParse->pParentParse; - pParse->pParentParse = 0; + db->pParse = pParentParse; assert( nErr==0 || pParse->rc!=SQLITE_OK ); return nErr; } diff --git a/test/alterfault.test b/test/alterfault.test new file mode 100644 index 0000000000..a2a9677c9e --- /dev/null +++ b/test/alterfault.test @@ -0,0 +1,35 @@ +# 2021 November 16 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix alterfault + +do_execsql_test 1.0 { + CREATE TABLE t1(a); +} +faultsim_save_and_close + +do_faultsim_test 1.1 -faults oom* -prep { + faultsim_restore_and_reopen +} -body { + execsql { + ALTER TABLE t1 ADD COLUMN b CHECK (a!=1) + } +} -test { + faultsim_test_result {0 {}} +} + + + +finish_test