A prepared statement that aborts due to SQLITE_SCHEMA should not invalidate

cursors in other prepared statements that are already running.
See [forum:/forumpost/cae4367d9b|forum post cae4367d9b] for the original
trouble report.

FossilOrigin-Name: 857d0f5e16ba69ac9e5ee581befca2f7ed933edfe6e36396b10dae7979b44a57
This commit is contained in:
drh 2023-04-06 13:35:42 +00:00
parent 5482afd6cf
commit ebec9c475e
4 changed files with 36 additions and 8 deletions

View File

@ -154,4 +154,30 @@ do_execsql_test 3.2 {
}
# 2023-04-06 https://sqlite.org/forum/forumpost/cae4367d9b
#
# This is not a test of FTS5, but rather a test of the of what happens to
# prepared statements that encounter SQLITE_SCHEMA while other prepared
# statements are running. The original problem POC used FTS5, and so
# is seems reasonable to put the test here.
#
# The vdbeaux24.test module in TH3 also tests this same behavior but
# without requiring FTS5 or an other extension.
#
reset_db
db null NULL
do_execsql_test 4.0 {
CREATE TABLE t5(a PRIMARY KEY);
INSERT INTO t5 VALUES(0);
CREATE VIRTUAL TABLE t6 USING fts5(0);
DELETE FROM t6;
CREATE TABLE t7(x);
WITH cte(a) AS (
SELECT a FROM t5
WHERE ((0,0) IN (SELECT 0, LAG(0) OVER (PARTITION BY 0) FROM t6), 0)
< (a,0)
)
SELECT max(a) FROM cte;
} NULL
finish_test

View File

@ -1,5 +1,5 @@
C In\sthe\sCLI,\sduring\serror\sprocessing\swhile\slooking\sfor\sa\sword\sboundary,\navoid\sbeing\sdeceived\sby\smalformed\sinput\sthat\shas\sa\svery\slong\ssequence\nof\s0x80\scharacters.\n[forum:/forumpost/ab93a23ba1|forum\spost\sab93a23ba1].
D 2023-04-06T01:05:52.467
C A\sprepared\sstatement\sthat\saborts\sdue\sto\sSQLITE_SCHEMA\sshould\snot\sinvalidate\ncursors\sin\sother\sprepared\sstatements\sthat\sare\salready\srunning.\nSee\s[forum:/forumpost/cae4367d9b|forum\spost\scae4367d9b]\sfor\sthe\soriginal\ntrouble\sreport.
D 2023-04-06T13:35:42.258
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -115,7 +115,7 @@ F ext/fts5/test/fts5ag.test 7816f25a0707578f08145ab539fc0ca025f8951e788b28a6a18a
F ext/fts5/test/fts5ah.test 2f047dfe89dc8611fa53e3d8bfc453b79cff037aa423c8d171e91e645745aa2c
F ext/fts5/test/fts5ai.test bc97e4758cc93e06bf851d61c98fdf4e8b8f8315ee28a84fb15f916360856414
F ext/fts5/test/fts5aj.test 745020852d85f5dd49d11cb7ad11d3cc6dafc4fe6d6d24bc0875ac8f43ee4149
F ext/fts5/test/fts5ak.test fc3595f8e6873bb86d70c9bd4b67d0413ce577bd4793c39a2b60a7b8825b60a6
F ext/fts5/test/fts5ak.test f459a64c9d38698af72a7c657ab6349bca96150241dd69fcce752634b2742d41
F ext/fts5/test/fts5al.test 00c4c1c6a1366b73aa48ce2068c634520867c3cf7f5d1676ebbb775ee1f35734
F ext/fts5/test/fts5alter.test 5565f7e4605512b69171ac18ca84398603f9f6456dbe377beeca97e83cc242cd
F ext/fts5/test/fts5auto.test 78989e6527ce69c9eddbef7392fea5c10b0010cd2b2ae68eec7bc869c471e691
@ -699,7 +699,7 @@ F src/vdbe.c a6c52ba65e8ceb574fe0eda62af84e6c50c176ffc5f310c613425f7ab2b1484b
F src/vdbe.h 73b904a6b3bb27f308c6cc287a5751ebc7f1f89456be0ed068a12b92844c6e8c
F src/vdbeInt.h a4147a4ddf613cb1bcb555ace9e9e74a9c099d65facd88155f191b1fb4d74cfb
F src/vdbeapi.c 1a95162e26d5eda3b7b46fbe4fcbc33eb7f801529d66fc2e14c52094a5523339
F src/vdbeaux.c 2ec444e0be19d2cf671e2f3ae331965f5d9e24625525cc947048ab61625e1a37
F src/vdbeaux.c 0379f2529aa16ab82fefddb1163c3138d6552ede80962b599ae711bbf5777608
F src/vdbeblob.c 5e61ce31aca17db8fb60395407457a8c1c7fb471dde405e0cd675974611dcfcd
F src/vdbemem.c db0458d11a51f6cfad2333a41e36a3795be0b2f316d070df5d33543a9ac884ac
F src/vdbesort.c 43756031ca7430f7aec3ef904824a7883c4ede783e51f280d99b9b65c0796e35
@ -2052,8 +2052,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 46db2e42a5f9b18da9661ccedca68cb70257ea5c58b33b401db2a5e030c1346a
R 3627c9efb7548c46bc3a47ca70e854b9
P 82609d5a2d4eba741d48ea265f4e749578964961903c072c7b222ffe2aefaa3c
R 34575d0f1bbe64bf65b9c8db61b744d0
U drh
Z 9baf3dd4e699627dd6a76c9e074307b5
Z 0b0e55febdd72c86a8dbd43eaed96ed2
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
82609d5a2d4eba741d48ea265f4e749578964961903c072c7b222ffe2aefaa3c
857d0f5e16ba69ac9e5ee581befca2f7ed933edfe6e36396b10dae7979b44a57

View File

@ -3326,6 +3326,8 @@ int sqlite3VdbeHalt(Vdbe *p){
db->flags &= ~(u64)SQLITE_DeferFKs;
sqlite3CommitInternalChanges(db);
}
}else if( p->rc==SQLITE_SCHEMA && db->nVdbeActive>1 ){
p->nChange = 0;
}else{
sqlite3RollbackAll(db, SQLITE_OK);
p->nChange = 0;