1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Fix a crash that can follow an OOM when "all tables" are registered with a session module.

FossilOrigin-Name: 183c236e991faaabdc768e52e926c52cf4a7abc9
This commit is contained in:
dan
2011-03-22 16:54:12 +00:00
parent ff4d0f41bb
commit 245b49b203
4 changed files with 40 additions and 10 deletions

View File

@ -34,7 +34,11 @@ db2 close
#-------------------------------------------------------------------------
# Test OOM error handling when collecting and applying a simple changeset.
#
do_faultsim_test pagerfault-1 -faults oom-* -prep {
# Test 1.1 attaches tables individually by name to the session object.
# Whereas test 1.2 passes NULL to sqlite3session_attach() to attach all
# tables.
#
do_faultsim_test pagerfault-1.1 -faults oom-* -prep {
catch {db2 close}
catch {db close}
faultsim_restore_and_reopen
@ -51,6 +55,32 @@ do_faultsim_test pagerfault-1 -faults oom-* -prep {
if {$testrc==0} { compare_db db db2 }
}
do_faultsim_test pagerfault-1.2 -faults oom-* -prep {
catch {db2 close}
catch {db close}
faultsim_restore_and_reopen
} -body {
sqlite3session S db main
S attach *
execsql {
INSERT INTO t1 VALUES(7, 8, 9);
UPDATE t1 SET c = 10 WHERE a = 1;
DELETE FROM t1 WHERE a = 4;
}
set ::changeset [S changeset]
set {} {}
} -test {
catch { S delete }
faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
faultsim_integrity_check
if {$testrc==0} {
proc xConflict {args} { return "OMIT" }
sqlite3 db2 test.db2
sqlite3changeset_apply db2 $::changeset xConflict
compare_db db db2
}
}
#-------------------------------------------------------------------------
# The following block of tests - pagerfault-2.* - are designed to check
# the handling of faults in the sqlite3changeset_apply() function.

View File

@ -781,7 +781,7 @@ static void xPreUpdate(
/* This branch is taken if table zName has not yet been attached to
** this session and the auto-attach flag is set. */
pSession->rc = sqlite3session_attach(pSession,zName);
if( pSession->rc ) continue;
if( pSession->rc ) break;
pTab = pSession->pTable;
assert( 0==sqlite3_strnicmp(pTab->zName, zName, nName+1) );
}

View File

@ -1,5 +1,5 @@
C If\sa\sNULL\spointer\sis\spassed\sto\ssqlite3session_attach()\sin\splace\sof\sa\stable\sname,\sattach\sall\sdatabase\stables\sto\sthe\ssession\sobject.
D 2011-03-22T15:21:04
C Fix\sa\scrash\sthat\scan\sfollow\san\sOOM\swhen\s"all\stables"\sare\sregistered\swith\sa\ssession\smodule.
D 2011-03-22T16:54:12
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -102,8 +102,8 @@ F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024
F ext/session/session1.test 1e8cda2cc8a60171dabc0fbec4124f9f7c943f23
F ext/session/session2.test f993ee243db15025a7d9b1dae903fe3f82f04229
F ext/session/session_common.tcl fb91560b6dbd086010df8b3a137a452f1ac21a28
F ext/session/sessionfault.test 2dcf303379d0c01d8320f3c7d0452e6a0dcebd48
F ext/session/sqlite3session.c c2cc2149e682af9d2ddaab09152ef578c8f97864
F ext/session/sessionfault.test 495f87fb9bd764ae90d4b40d0c33a76d86d9063e
F ext/session/sqlite3session.c ec0f440ae73229ae8ae307a31e631b9d71991cd4
F ext/session/sqlite3session.h 5055e21ca0cb6ddacd46b773a15d90bc0298b0a2
F ext/session/test_session.c d31fbf5902d0cff5e5495a5ce62efda77b596f2b
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
@ -923,7 +923,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 06048a68b351e3eb15a890cb54db8a1d4b345fbc
R aba670c08b10d639853d25c358b85571
P e9037e4e4ccaa5c633759c4d041b60b631b92c6c
R 93198cfc6613c93be1aa416f0de3d035
U dan
Z 48e2e8d1a1883a86d400f9c1e1c32110
Z ee6ba5845d31702e943c5fa7b7c9db34

View File

@ -1 +1 @@
e9037e4e4ccaa5c633759c4d041b60b631b92c6c
183c236e991faaabdc768e52e926c52cf4a7abc9