Fix error handling in sqlite3session_diff() when it is invoked for table

"sqlite_stat1".

FossilOrigin-Name: 874285e477dd9bd164e25ddb08b6b80daaa8cfd111b4180ecce59b1ce26f77a5
This commit is contained in:
dan
2018-01-12 19:20:15 +00:00
parent 84ebe2b303
commit 5871318407
5 changed files with 57 additions and 18 deletions
+33
View File
@@ -221,5 +221,38 @@ do_test 4.2.2 {
} {1 {SQLITE_SCHEMA - table schemas do not match}}
S delete
do_test 4.3.1 {
sqlite3session S db main
S attach t4
execsql { CREATE TABLE t4(i PRIMARY KEY, b) }
list [catch { S diff ixua t4 } msg] $msg
} {1 {SQLITE_SCHEMA - table schemas do not match}}
S delete
do_catchsql_test 4.3.2 {
SELECT * FROM ixua.t4;
} {1 {no such table: ixua.t4}}
do_test 4.4.1 {
sqlite3session S db main
S attach sqlite_stat1
execsql { ANALYZE }
execsql { DROP TABLE ixua.sqlite_stat1 }
list [catch { S diff ixua sqlite_stat1 } msg] $msg
} {1 {SQLITE_SCHEMA - table schemas do not match}}
S delete
do_catchsql_test 4.4.2 {
SELECT * FROM ixua.sqlite_stat1;
} {1 {no such table: ixua.sqlite_stat1}}
do_test 4.5.1 {
sqlite3session S db main
S attach t8
list [catch { S diff ixua t8 } msg] $msg
} {0 {}}
S delete
do_catchsql_test 4.5.2 {
SELECT * FROM ixua.i8;
} {1 {no such table: ixua.i8}}
finish_test
+1 -1
View File
@@ -119,7 +119,7 @@ do_execsql_test -db db2 2.4 {
} {
}
do_execsql_test -db db2 2.4 { SELECT count(*) FROM t1 } 32
do_execsql_test -db db2 2.5 { SELECT count(*) FROM t1 } 32
finish_test
+13 -7
View File
@@ -941,12 +941,19 @@ static int sessionTableInfo(
nThis = sqlite3Strlen30(zThis);
if( nThis==12 && 0==sqlite3_stricmp("sqlite_stat1", zThis) ){
/* For sqlite_stat1, pretend that (tbl,idx) is the PRIMARY KEY. */
zPragma = sqlite3_mprintf(
"SELECT 0, 'tbl', '', 0, '', 1 UNION ALL "
"SELECT 1, 'idx', '', 0, '', 2 UNION ALL "
"SELECT 2, 'stat', '', 0, '', 0"
);
rc = sqlite3_table_column_metadata(db, zDb, zThis, 0, 0, 0, 0, 0, 0);
if( rc==SQLITE_OK ){
/* For sqlite_stat1, pretend that (tbl,idx) is the PRIMARY KEY. */
zPragma = sqlite3_mprintf(
"SELECT 0, 'tbl', '', 0, '', 1 UNION ALL "
"SELECT 1, 'idx', '', 0, '', 2 UNION ALL "
"SELECT 2, 'stat', '', 0, '', 0"
);
}else if( rc==SQLITE_ERROR ){
zPragma = sqlite3_mprintf("");
}else{
return rc;
}
}else{
zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis);
}
@@ -1506,7 +1513,6 @@ int sqlite3session_diff(
if( abPK[i] ) bHasPk = 1;
}
}
}
sqlite3_free((char*)azCol);
if( bMismatch ){