Follow-up to [68db1ff9c44fa9c3]: The number of registers needed by

PRAGMA foreign_key_check was increased too late for an assert() deep
down inside of sqlite3ExprCode().  So move the size increase a little
earlier.
[forum:/forumpost/79c9e4797d|Forum post 79c9e4797d].

FossilOrigin-Name: 7072404ad0267b8ee774b2804ea59ea28e29316521d76d76a701595e51d1be97
This commit is contained in:
drh 2021-07-07 16:48:24 +00:00
parent 2931a66ece
commit 4f16ff9d06
4 changed files with 16 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C Fix\sa\srecently\sintroduced\ssegfault\sthat\smight\soccur\sif\sa\ssub-select\swere\sused\sas\sa\sterm\son\sthe\sRHS\sof\san\sIN(...)\soperator\sfor\swhich\sthe\sLHS\sis\sa\srow-value.
D 2021-07-07T15:52:44.574
C Follow-up\sto\s[68db1ff9c44fa9c3]:\s\sThe\snumber\sof\sregisters\sneeded\sby\nPRAGMA\sforeign_key_check\swas\sincreased\stoo\slate\sfor\san\sassert()\sdeep\ndown\sinside\sof\ssqlite3ExprCode().\s\sSo\smove\sthe\ssize\sincrease\sa\slittle\nearlier.\n[forum:/forumpost/79c9e4797d|Forum\spost\s79c9e4797d].
D 2021-07-07T16:48:24.382
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -537,7 +537,7 @@ F src/parse.y 62388bd7323ce1b76b219de0a0974789224d98fc14cfccb08dd98524ccd693c3
F src/pcache.c 385ff064bca69789d199a98e2169445dc16e4291fa807babd61d4890c3b34177
F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586
F src/pcache1.c 388304fd2d91c39591080b5e0f3c62cfba87db20370e7e0554062bfb29740e9f
F src/pragma.c e74fbc64dcf4985bf11f8366ca3e37df1db1b211f42f25270b461c118411a512
F src/pragma.c 9fe75aa29e8706a2cf6b9c1600ac05a2efc55c44ce719b65aa45d10ff58acc9d
F src/pragma.h 8dc78ab7e9ec6ce3ded8332810a2066f1ef6267e2e03cd7356ee00276125c6cf
F src/prepare.c 0d53d20532aada295c1690792a125adbd6435f5ce703ff0adf1b9b3605238b67
F src/printf.c 78fabb49b9ac9a12dd1c89d744abdc9b67fd3205e62967e158f78b965a29ec4b
@ -899,7 +899,7 @@ F test/filter1.test 6c483ecf7886c8843a8612c021aa23f33c581f584151f251842b3a3592c9
F test/filter2.tcl 44e525497ce07382915f01bd29ffd0fa49dab3adb87253b5e5103ba8f93393e8
F test/filter2.test 485cf95d1f6d6ceee5632201ca52a71868599836f430cdee42e5f7f14666e30a
F test/filterfault.test c08fb491d698e8df6c122c98f7db1c65ffcfcad2c1ab0e07fa8a5be1b34eaa8b
F test/fkey1.test a0a38fc7f1b88497a355e2931115395fd43dc20cfb317e39c5bf4e11bedea199
F test/fkey1.test 03503639d266d565db90ee3b8fe211ba446624030ac4eb24895cec265e9631d0
F test/fkey2.test 1063d65e5923c054cfb8f0555a92a3ae0fa8c067275a33ee1715bd856cdb304c
F test/fkey3.test 76d475c80b84ee7a5d062e56ccb6ea68882e2b49
F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d
@ -1920,7 +1920,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 6b22f4e71dbc14c887ebbda67095b5faaa8079cac87cd4ab5a2ae90c71cd9633
R 2f5c851e73952219f058fe70670ea883
U dan
Z c96972b6a62814c17f8f6aa2467bed52
P f586c06a5d03943db32add4d3d058a5aa09c819870b29cd8b54cf69433a8cdb1
R 1e2ab0b571f6af295ffe5d3c314f1294
U drh
Z 9f0157c1df421495cc816917f7595608

View File

@ -1 +1 @@
f586c06a5d03943db32add4d3d058a5aa09c819870b29cd8b54cf69433a8cdb1
7072404ad0267b8ee774b2804ea59ea28e29316521d76d76a701595e51d1be97

View File

@ -1461,12 +1461,12 @@ void sqlite3Pragma(
** regRow..regRow+n. If any of the child key values are NULL, this
** row cannot cause an FK violation. Jump directly to addrOk in
** this case. */
if( regRow+pFK->nCol>pParse->nMem ) pParse->nMem = regRow+pFK->nCol;
for(j=0; j<pFK->nCol; j++){
int iCol = aiCols ? aiCols[j] : pFK->aCol[j].iFrom;
sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, iCol, regRow+j);
sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk); VdbeCoverage(v);
}
if( regRow+j>pParse->nMem ) pParse->nMem = regRow+j;
/* Generate code to query the parent index for a matching parent
** key. If a match is found, jump to addrOk. */

View File

@ -223,6 +223,7 @@ do_execsql_test 6.2 {
} {}
# 2021-07-03 https://sqlite.org/forum/forumpost/a6b0c05277
# 2021-07-07 https://sqlite.org/forum/forumpost/79c9e4797d
# Failure to allocate enough registers in the VDBE for a
# PRAGMA foreign_key_check when the foreign key has more
# columns than the table.
@ -234,6 +235,11 @@ do_execsql_test 7.1 {
INSERT INTO t1 VALUES(1,2,3);
PRAGMA foreign_key_check;
} {t1 1 t0 0}
do_execsql_test 7.2 {
DROP TABLE t1;
CREATE TABLE t1(a,b,c AS(1),d, FOREIGN KEY(c,d,b,a,b,d,b,c) REFERENCES t0);
PRAGMA foreign_key_check;
} {}
finish_test