Improve coverage of session module a bit more.
FossilOrigin-Name: 4255a9f609c4fd43582a0874143eabe211199726
This commit is contained in:
parent
f51e5f6c99
commit
e5754eec26
@ -44,12 +44,24 @@ do_iterator_test 1.1 t1 {
|
|||||||
{DELETE t1 0 X. {t i t one} {}}
|
{DELETE t1 0 X. {t i t one} {}}
|
||||||
{INSERT t1 0 X. {} {t ii t two}}
|
{INSERT t1 0 X. {} {t ii t two}}
|
||||||
}
|
}
|
||||||
|
|
||||||
do_iterator_test 1.2 t1 {
|
do_iterator_test 1.2 t1 {
|
||||||
INSERT INTO t1 VALUES(1.5, 99.9)
|
INSERT INTO t1 VALUES(1.5, 99.9)
|
||||||
} {
|
} {
|
||||||
{INSERT t1 0 X. {} {f 1.5 f 99.9}}
|
{INSERT t1 0 X. {} {f 1.5 f 99.9}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_iterator_test 1.3 t1 {
|
||||||
|
UPDATE t1 SET b = 100.1 WHERE a = 1.5;
|
||||||
|
UPDATE t1 SET b = 99.9 WHERE a = 1.5;
|
||||||
|
} { }
|
||||||
|
|
||||||
|
do_iterator_test 1.4 t1 {
|
||||||
|
UPDATE t1 SET b = 100.1 WHERE a = 1.5;
|
||||||
|
} {
|
||||||
|
{UPDATE t1 0 X. {f 1.5 f 99.9} {{} {} f 100.1}}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Execute each of the following blocks of SQL on database [db1]. Collect
|
# Execute each of the following blocks of SQL on database [db1]. Collect
|
||||||
# changes using a session object. Apply the resulting changeset to
|
# changes using a session object. Apply the resulting changeset to
|
||||||
@ -520,6 +532,32 @@ do_test 9.3 {
|
|||||||
execsql { SELECT * FROM t1 } db2
|
execsql { SELECT * FROM t1 } db2
|
||||||
} {x 2}
|
} {x 2}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
test_reset
|
||||||
|
db function enable [list S enable]
|
||||||
|
|
||||||
|
do_common_sql {
|
||||||
|
CREATE TABLE t1(a PRIMARY KEY, b);
|
||||||
|
INSERT INTO t1 VALUES('x', 'X');
|
||||||
|
}
|
||||||
|
|
||||||
|
do_iterator_test 10.1 t1 {
|
||||||
|
INSERT INTO t1 VALUES('y', 'Y');
|
||||||
|
SELECT enable(0);
|
||||||
|
INSERT INTO t1 VALUES('z', 'Z');
|
||||||
|
SELECT enable(1);
|
||||||
|
} {
|
||||||
|
{INSERT t1 0 X. {} {t y t Y}}
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlite3session S db main
|
||||||
|
do_execsql_test 10.2 {
|
||||||
|
SELECT enable(0);
|
||||||
|
SELECT enable(-1);
|
||||||
|
SELECT enable(1);
|
||||||
|
SELECT enable(-1);
|
||||||
|
} {0 0 1 1}
|
||||||
|
S delete
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
@ -146,7 +146,7 @@ do_test 2.3 {
|
|||||||
execsql {
|
execsql {
|
||||||
INSERT INTO t2 VALUES(1, 2);
|
INSERT INTO t2 VALUES(1, 2);
|
||||||
DROP TABLE t2;
|
DROP TABLE t2;
|
||||||
CREATE TABLE t2(a PRIMARY KEY, b, c);
|
CREATE TABLE t2(a PRIMARY KEY, b);
|
||||||
}
|
}
|
||||||
list [catch { S changeset } msg] $msg
|
list [catch { S changeset } msg] $msg
|
||||||
} {1 SQLITE_SCHEMA}
|
} {1 SQLITE_SCHEMA}
|
||||||
|
@ -59,4 +59,9 @@ do_test 1.2 {
|
|||||||
list [catch { sqlite3changeset_invert $x } msg] $msg
|
list [catch { sqlite3changeset_invert $x } msg] $msg
|
||||||
} {1 SQLITE_CORRUPT}
|
} {1 SQLITE_CORRUPT}
|
||||||
|
|
||||||
|
do_test 1.3 {
|
||||||
|
set x [binary format "ca*" 0 [string range $changeset 1 end]]
|
||||||
|
list [catch { sqlite3changeset_apply db $x xConflict } msg] $msg
|
||||||
|
} {1 SQLITE_CORRUPT}
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
@ -45,7 +45,7 @@ do_faultsim_test 1.1 -faults oom-* -prep {
|
|||||||
sqlite3 db2 test.db2
|
sqlite3 db2 test.db2
|
||||||
} -body {
|
} -body {
|
||||||
do_then_apply_sql {
|
do_then_apply_sql {
|
||||||
INSERT INTO t1 VALUES(7, 8, 9);
|
INSERT INTO t1 VALUES('a string value', 8, 9);
|
||||||
UPDATE t1 SET c = 10 WHERE a = 1;
|
UPDATE t1 SET c = 10 WHERE a = 1;
|
||||||
DELETE FROM t1 WHERE a = 4;
|
DELETE FROM t1 WHERE a = 4;
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ do_faultsim_test 1.2 -faults oom-* -prep {
|
|||||||
sqlite3session S db main
|
sqlite3session S db main
|
||||||
S attach *
|
S attach *
|
||||||
execsql {
|
execsql {
|
||||||
INSERT INTO t1 VALUES(7, 8, 9);
|
INSERT INTO t1 VALUES('a string value', 8, 9);
|
||||||
UPDATE t1 SET c = 10 WHERE a = 1;
|
UPDATE t1 SET c = 10 WHERE a = 1;
|
||||||
DELETE FROM t1 WHERE a = 4;
|
DELETE FROM t1 WHERE a = 4;
|
||||||
}
|
}
|
||||||
|
@ -1181,10 +1181,10 @@ static void sessionAppendUpdate(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SQLITE_TEXT:
|
default: {
|
||||||
case SQLITE_BLOB: {
|
|
||||||
int nByte;
|
int nByte;
|
||||||
int nHdr = 1 + sessionVarintGet(&pCsr[1], &nByte);
|
int nHdr = 1 + sessionVarintGet(&pCsr[1], &nByte);
|
||||||
|
assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB );
|
||||||
nAdvance = nHdr + nByte;
|
nAdvance = nHdr + nByte;
|
||||||
if( eType==sqlite3_column_type(pStmt, i)
|
if( eType==sqlite3_column_type(pStmt, i)
|
||||||
&& nByte==sqlite3_column_bytes(pStmt, i)
|
&& nByte==sqlite3_column_bytes(pStmt, i)
|
||||||
@ -1260,19 +1260,18 @@ static int sessionSelectBind(
|
|||||||
sqlite3_stmt *pSelect,
|
sqlite3_stmt *pSelect,
|
||||||
int nCol,
|
int nCol,
|
||||||
u8 *abPK,
|
u8 *abPK,
|
||||||
u8 *aRecord,
|
SessionChange *pChange
|
||||||
int nRecord
|
|
||||||
){
|
){
|
||||||
int i;
|
int i;
|
||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
u8 *a = aRecord;
|
u8 *a = pChange->aRecord;
|
||||||
|
|
||||||
for(i=0; i<nCol && rc==SQLITE_OK; i++){
|
for(i=0; i<nCol && rc==SQLITE_OK; i++){
|
||||||
int eType = *a++;
|
int eType = *a++;
|
||||||
|
|
||||||
switch( eType ){
|
switch( eType ){
|
||||||
case SQLITE_NULL:
|
case SQLITE_NULL:
|
||||||
if( abPK[i] ) rc = sqlite3_bind_null(pSelect, i+1);
|
assert( abPK[i]==0 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SQLITE_INTEGER: {
|
case SQLITE_INTEGER: {
|
||||||
@ -1305,8 +1304,9 @@ static int sessionSelectBind(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SQLITE_BLOB: {
|
default: {
|
||||||
int n;
|
int n;
|
||||||
|
assert( eType==SQLITE_BLOB );
|
||||||
a += sessionVarintGet(a, &n);
|
a += sessionVarintGet(a, &n);
|
||||||
if( abPK[i] ){
|
if( abPK[i] ){
|
||||||
rc = sqlite3_bind_blob(pSelect, i+1, a, n, SQLITE_TRANSIENT);
|
rc = sqlite3_bind_blob(pSelect, i+1, a, n, SQLITE_TRANSIENT);
|
||||||
@ -1337,14 +1337,17 @@ int sqlite3session_changeset(
|
|||||||
SessionBuffer buf = {0,0,0}; /* Buffer in which to accumlate changeset */
|
SessionBuffer buf = {0,0,0}; /* Buffer in which to accumlate changeset */
|
||||||
int rc; /* Return code */
|
int rc; /* Return code */
|
||||||
|
|
||||||
sqlite3_mutex_enter(sqlite3_db_mutex(db));
|
|
||||||
|
|
||||||
/* Zero the output variables in case an error occurs. If this session
|
/* Zero the output variables in case an error occurs. If this session
|
||||||
** object is already in the error state (sqlite3_session.rc != SQLITE_OK),
|
** object is already in the error state (sqlite3_session.rc != SQLITE_OK),
|
||||||
** this call will be a no-op. */
|
** this call will be a no-op. */
|
||||||
*pnChangeset = 0;
|
*pnChangeset = 0;
|
||||||
*ppChangeset = 0;
|
*ppChangeset = 0;
|
||||||
rc = pSession->rc;
|
|
||||||
|
if( pSession->rc ) return pSession->rc;
|
||||||
|
rc = sqlite3_exec(pSession->db, "SAVEPOINT changeset", 0, 0, 0);
|
||||||
|
if( rc!=SQLITE_OK ) return rc;
|
||||||
|
|
||||||
|
sqlite3_mutex_enter(sqlite3_db_mutex(db));
|
||||||
|
|
||||||
for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){
|
for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){
|
||||||
if( pTab->nEntry ){
|
if( pTab->nEntry ){
|
||||||
@ -1375,17 +1378,12 @@ int sqlite3session_changeset(
|
|||||||
db, pSession->zDb, zName, nCol, azCol, abPK, &pSel);
|
db, pSession->zDb, zName, nCol, azCol, abPK, &pSel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( rc==SQLITE_OK && nCol!=sqlite3_column_count(pSel) ){
|
|
||||||
rc = SQLITE_SCHEMA;
|
|
||||||
}
|
|
||||||
|
|
||||||
nNoop = buf.nBuf;
|
nNoop = buf.nBuf;
|
||||||
for(i=0; i<pTab->nChange && rc==SQLITE_OK; i++){
|
for(i=0; i<pTab->nChange && rc==SQLITE_OK; i++){
|
||||||
SessionChange *p; /* Used to iterate through changes */
|
SessionChange *p; /* Used to iterate through changes */
|
||||||
|
|
||||||
for(p=pTab->apChange[i]; rc==SQLITE_OK && p; p=p->pNext){
|
for(p=pTab->apChange[i]; rc==SQLITE_OK && p; p=p->pNext){
|
||||||
rc = sessionSelectBind(pSel, nCol, abPK, p->aRecord, p->nRecord);
|
rc = sessionSelectBind(pSel, nCol, abPK, p);
|
||||||
if( rc==SQLITE_OK ){
|
|
||||||
if( sqlite3_step(pSel)==SQLITE_ROW ){
|
if( sqlite3_step(pSel)==SQLITE_ROW ){
|
||||||
int iCol;
|
int iCol;
|
||||||
if( p->bInsert ){
|
if( p->bInsert ){
|
||||||
@ -1408,7 +1406,6 @@ int sqlite3session_changeset(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
sqlite3_finalize(pSel);
|
sqlite3_finalize(pSel);
|
||||||
if( buf.nBuf==nNoop ){
|
if( buf.nBuf==nNoop ){
|
||||||
@ -1425,6 +1422,7 @@ int sqlite3session_changeset(
|
|||||||
sqlite3_free(buf.aBuf);
|
sqlite3_free(buf.aBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sqlite3_exec(db, "RELEASE changeset", 0, 0, 0);
|
||||||
sqlite3_mutex_leave(sqlite3_db_mutex(db));
|
sqlite3_mutex_leave(sqlite3_db_mutex(db));
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ static int test_session_cmd(
|
|||||||
|
|
||||||
case 3: { /* enable */
|
case 3: { /* enable */
|
||||||
int val;
|
int val;
|
||||||
if( Tcl_GetBooleanFromObj(interp, objv[2], &val) ) return TCL_ERROR;
|
if( Tcl_GetIntFromObj(interp, objv[2], &val) ) return TCL_ERROR;
|
||||||
val = sqlite3session_enable(pSession, val);
|
val = sqlite3session_enable(pSession, val);
|
||||||
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(val));
|
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(val));
|
||||||
break;
|
break;
|
||||||
@ -436,6 +436,7 @@ static int test_sqlite3session_foreach(
|
|||||||
|
|
||||||
while( SQLITE_ROW==sqlite3changeset_next(pIter) ){
|
while( SQLITE_ROW==sqlite3changeset_next(pIter) ){
|
||||||
int nCol; /* Number of columns in table */
|
int nCol; /* Number of columns in table */
|
||||||
|
int nCol2; /* Number of columns in table */
|
||||||
int op; /* SQLITE_INSERT, UPDATE or DELETE */
|
int op; /* SQLITE_INSERT, UPDATE or DELETE */
|
||||||
const char *zTab; /* Name of table change applies to */
|
const char *zTab; /* Name of table change applies to */
|
||||||
Tcl_Obj *pVar; /* Tcl value to set $VARNAME to */
|
Tcl_Obj *pVar; /* Tcl value to set $VARNAME to */
|
||||||
@ -460,7 +461,8 @@ static int test_sqlite3session_foreach(
|
|||||||
|
|
||||||
zPK = ckalloc(nCol+1);
|
zPK = ckalloc(nCol+1);
|
||||||
memset(zPK, 0, nCol+1);
|
memset(zPK, 0, nCol+1);
|
||||||
sqlite3changeset_pk(pIter, &abPK, 0);
|
sqlite3changeset_pk(pIter, &abPK, &nCol2);
|
||||||
|
assert( nCol==nCol2 );
|
||||||
for(i=0; i<nCol; i++){
|
for(i=0; i<nCol; i++){
|
||||||
zPK[i] = (abPK[i] ? 'X' : '.');
|
zPK[i] = (abPK[i] ? 'X' : '.');
|
||||||
}
|
}
|
||||||
|
22
manifest
22
manifest
@ -1,5 +1,5 @@
|
|||||||
C Improve\scoverage\sof\ssession\smodule\scode.
|
C Improve\scoverage\sof\ssession\smodule\sa\sbit\smore.
|
||||||
D 2011-03-25T10:52:02
|
D 2011-03-25T19:06:10
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f
|
F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@ -100,14 +100,14 @@ F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0
|
|||||||
F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de
|
F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de
|
||||||
F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024
|
F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024
|
||||||
F ext/session/session1.test b2da15b9d727d7f4e5fe95599b32b92d93b5a970
|
F ext/session/session1.test b2da15b9d727d7f4e5fe95599b32b92d93b5a970
|
||||||
F ext/session/session2.test f2f0bad3f27c9084f5f51444d017ede485cee009
|
F ext/session/session2.test e36222e1f48bc9b1d80eacd001994d307c107e73
|
||||||
F ext/session/session3.test 5b2e9d0b94af5d7770f89e020d83b838584ccc64
|
F ext/session/session3.test 919f7e2e07fa5a166a0ea5d8ac3fbe7f38f7e447
|
||||||
F ext/session/session4.test 3b39b468bf871f3b7825f64f9ce9f3849ff4b156
|
F ext/session/session4.test a37bc9d8891ea1f3e120056c978f66c925f040b9
|
||||||
F ext/session/session_common.tcl fb91560b6dbd086010df8b3a137a452f1ac21a28
|
F ext/session/session_common.tcl fb91560b6dbd086010df8b3a137a452f1ac21a28
|
||||||
F ext/session/sessionfault.test d7e6154a30e85622d0733b1a1e3c63e9b8b7004b
|
F ext/session/sessionfault.test 2544a2e2ecad56e3c07a32c09799871d243c114c
|
||||||
F ext/session/sqlite3session.c 8057ed55d25c4d487ec8b68a3ee1c2c25dd543da
|
F ext/session/sqlite3session.c 9be8ccee4248681700659b89a81ae5c6cb8afacc
|
||||||
F ext/session/sqlite3session.h f284bac51c12de0e0096fc986e61f5ae6b9e5be5
|
F ext/session/sqlite3session.h f284bac51c12de0e0096fc986e61f5ae6b9e5be5
|
||||||
F ext/session/test_session.c 5f186a9f45958620ebc0609099538eb7cabdfe84
|
F ext/session/test_session.c f8fdf5c110898b2bbc20c475fca879664c77fb5a
|
||||||
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
|
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
|
||||||
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
|
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
|
||||||
F main.mk ae0868e05c76eaa8a0ae3d6927a949b1c8e810d7
|
F main.mk ae0868e05c76eaa8a0ae3d6927a949b1c8e810d7
|
||||||
@ -925,7 +925,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
|||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||||
P 76d2d2ad3b2a5171393b7894f35f463ff284e53b
|
P 666123c8d07be87d477e67b1cebef2b0fba5b4bc
|
||||||
R b7843eac9e1de41d0b79cfdd795816c8
|
R 06396f39a2dba603f238d63a566a7e13
|
||||||
U dan
|
U dan
|
||||||
Z 4c90a35f73d811b840852d363dcb9fdc
|
Z 44bcd7637527a5a2be65b60012fc28ed
|
||||||
|
@ -1 +1 @@
|
|||||||
666123c8d07be87d477e67b1cebef2b0fba5b4bc
|
4255a9f609c4fd43582a0874143eabe211199726
|
Loading…
Reference in New Issue
Block a user