Add tests to ensure an INSERT/UPDATE/DELETE immediately after virtual table construction does not fail. (CVS 3270)

FossilOrigin-Name: 144d0eb13aed4507e93edec781b1819a068f4a70
This commit is contained in:
danielk1977 2006-06-19 03:05:10 +00:00
parent fdb83b2fa1
commit b3d24bf8ee
8 changed files with 97 additions and 24 deletions

View File

@ -1,5 +1,5 @@
C Add\sthe\sload_extension()\sSQL\sfunction.\s(CVS\s3269)
D 2006-06-17T14:12:48
C Add\stests\sto\sensure\san\sINSERT/UPDATE/DELETE\simmediately\safter\svirtual\stable\sconstruction\sdoes\snot\sfail.\s(CVS\s3270)
D 2006-06-19T03:05:10
F Makefile.in f839b470345d3cb4b0644068474623fe2464b5d3
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -40,13 +40,13 @@ F src/build.c 3eb63f61249fd0fcd7075456b522a1ceb5f912bd
F src/callback.c fd9bb39f7ff6b52bad8365617abc61c720640429
F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675
F src/date.c cd2bd5d1ebc6fa12d6312f69789ae5b0a2766f2e
F src/delete.c e6a324650fb9f6afe5757ec5c7d8dad62d9496b8
F src/delete.c 804384761144fe1a5035b99f4bd7d706976831bd
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
F src/expr.c 78b521337d628b1fd9d87b12dbbe771247aab585
F src/func.c a8a52723878b38ad275513b81260c29980332504
F src/hash.c 449f3d6620193aa557f5d86cbc5cc6b87702b185
F src/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564
F src/insert.c 5c1fddd7e4d05805e02e12bdced2a3841d2bd8dc
F src/insert.c 63f01d3f4e0ba7ed171934a24aece2191824faec
F src/legacy.c fa15d505dd4e45044177ee4d1c6aeaf8c836d390
F src/loadext.c 3a730b22dfb6ba2c261848c72fb96a5c3195defd
F src/main.c 7101314a365120465bf5e308caaf518b7776430c
@ -93,7 +93,7 @@ F src/test_server.c a6460daed0b92ecbc2531b6dc73717470e7a648c
F src/test_tclvar.c c52f67fbe06d32804af2ba9a2d7aadfc15f5910c
F src/tokenize.c 6ebcafa6622839968dda4418a7b6945f277a128f
F src/trigger.c 0fc40125820409a6274834a6e04ad804d96e2793
F src/update.c 23a71ccef6b26e8fddfc2e5b3d36f3e8d0fa868d
F src/update.c 686b13db8b28a129a2407aaffc8b7588d1104e0b
F src/utf.c ab81ac59084ff1c07d421eb1a0a84ec809603b44
F src/util.c ca6ee72772c0f5dc04d2e0ab1973fd3b6a9bf79d
F src/vacuum.c 5b37d0f436f8e1ffacd17934e44720b38d2247f9
@ -291,10 +291,11 @@ F test/vacuum.test 37f998b841cb335397c26d9bbc3457182af2565f
F test/vacuum2.test 5aea8c88a65cb29f7d175296e7c819c6158d838c
F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
F test/view.test 16e2774fe35e47a07ac4471b7f0bcc948b1aa6d5
F test/vtab1.test cb90ff6852a0dcb72965939df5da2bb1b3fcbcf9
F test/vtab2.test a0968c4e5e1b4197bd9a5a348bd4022196711a65
F test/vtab1.test 97d68ca03f18ed14ffec6420363a13b486fd66bb
F test/vtab2.test b8daa5d9989c3096a294bce0f614ff6f37db0f99
F test/vtab3.test b3ea5dfdc36ba23ba5136928b6c307c5125ababc
F test/vtab4.test 4b4293341443839ef6dc02f8d9e614702a6c67ff
F test/vtab5.test a76f85c2762b96b96ce7c82e496102533049d80b
F test/where.test ee7c9a6659b07e1ee61177f6e7ff71565ee2c9df
F test/where2.test a16476a5913e75cf65b38f2daa6157a6b7791394
F test/where3.test 3b5ad2c58069e12be2bd86bc5e211a82810521aa
@ -370,7 +371,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P 059b1f61406ca60fdbd3ec59c5b15fadc6552564
R 6e75aa9555d6b6ac99ebbabeb152a126
U drh
Z 6bcb5d58c602d9ee2f0ac3771c819d7b
P e08e2ddafe909ae6073ec56dfa3fdca23e36bf2e
R 4cf9e2b8592ece2ea2925c06bcdec672
U danielk1977
Z e0e66e994bedc3899b9799edc6b24f36

View File

@ -1 +1 @@
e08e2ddafe909ae6073ec56dfa3fdca23e36bf2e
144d0eb13aed4507e93edec781b1819a068f4a70

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** in order to generate code for DELETE FROM statements.
**
** $Id: delete.c,v 1.126 2006/06/16 16:08:55 danielk1977 Exp $
** $Id: delete.c,v 1.127 2006/06/19 03:05:10 danielk1977 Exp $
*/
#include "sqliteInt.h"
@ -155,7 +155,7 @@ void sqlite3DeleteFrom(
/* If pTab is really a view, make sure it has been initialized.
*/
if( isView && sqlite3ViewGetColumnNames(pParse, pTab) ){
if( sqlite3ViewGetColumnNames(pParse, pTab) ){
goto delete_from_cleanup;
}

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle INSERT statements in SQLite.
**
** $Id: insert.c,v 1.169 2006/06/16 16:08:55 danielk1977 Exp $
** $Id: insert.c,v 1.170 2006/06/19 03:05:10 danielk1977 Exp $
*/
#include "sqliteInt.h"
@ -272,8 +272,10 @@ void sqlite3Insert(
assert( pTab!=0 );
/* If pTab is really a view, make sure it has been initialized.
** ViewGetColumnNames() is a no-op if pTab is not a view (or virtual
** module table).
*/
if( isView && sqlite3ViewGetColumnNames(pParse, pTab) ){
if( sqlite3ViewGetColumnNames(pParse, pTab) ){
goto insert_cleanup;
}

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle UPDATE statements.
**
** $Id: update.c,v 1.130 2006/06/17 09:39:56 danielk1977 Exp $
** $Id: update.c,v 1.131 2006/06/19 03:05:10 danielk1977 Exp $
*/
#include "sqliteInt.h"
@ -141,10 +141,8 @@ void sqlite3Update(
if( sqlite3IsReadOnly(pParse, pTab, triggers_exist) ){
goto update_cleanup;
}
if( isView ){
if( sqlite3ViewGetColumnNames(pParse, pTab) ){
goto update_cleanup;
}
if( sqlite3ViewGetColumnNames(pParse, pTab) ){
goto update_cleanup;
}
aXRef = sqliteMallocRaw( sizeof(int) * pTab->nCol );
if( aXRef==0 ) goto update_cleanup;

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is creating and dropping virtual tables.
#
# $Id: vtab1.test,v 1.21 2006/06/17 11:30:33 danielk1977 Exp $
# $Id: vtab1.test,v 1.22 2006/06/19 03:05:10 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -32,6 +32,7 @@ ifcapable !vtab {
# vtab1-5.*: Test queries that include joins. This brings the
# sqlite3_index_info.estimatedCost variable into play.
# vtab1-6.*: Test UPDATE/INSERT/DELETE on vtables.
# vtab1-7.*: Test sqlite3_last_insert_rowid().
#
# This file uses the "echo" module (see src/test8.c). Refer to comments
# in that file for the special behaviour of the Tcl $echo_module variable.
@ -582,4 +583,5 @@ do_test vtab1.7-13 {
}
} {}
finish_test

View File

@ -10,7 +10,7 @@
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# $Id: vtab2.test,v 1.1 2006/06/17 11:30:33 danielk1977 Exp $
# $Id: vtab2.test,v 1.2 2006/06/19 03:05:10 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -36,6 +36,5 @@ do_test vtab2-1.1 {
main schema 6 dflt_value {} 0 {} 0 \
main schema 7 pk {} 0 {} 0 \
]
finish_test

71
test/vtab5.test Normal file
View File

@ -0,0 +1,71 @@
# 2006 June 10
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# $Id: vtab5.test,v 1.1 2006/06/19 03:05:10 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !vtab {
finish_test
return
}
# The following tests - vtab5-1.* - ensure that an INSERT, DELETE or UPDATE
# statement can be executed immediately after a CREATE or schema reload. The
# point here is testing that the parser always calls xConnect() before the
# schema of a virtual table is used.
register_echo_module [sqlite3_connection_pointer db]
do_test vtab5-1.1 {
execsql {
CREATE TABLE treal(a VARCHAR(16), b INTEGER, c FLOAT);
INSERT INTO treal VALUES('a', 'b', 'c');
CREATE VIRTUAL TABLE techo USING echo(treal);
}
} {}
do_test vtab5.1.2 {
execsql {
SELECT * FROM treal;
}
} {a b c}
do_test vtab5.1.3 {
db close
sqlite3 db test.db
register_echo_module [sqlite3_connection_pointer db]
execsql {
INSERT INTO techo VALUES('c', 'd', 'e');
SELECT * FROM techo;
}
} {a b c c d e}
do_test vtab5.1.4 {
db close
sqlite3 db test.db
register_echo_module [sqlite3_connection_pointer db]
execsql {
UPDATE techo SET a = 10;
SELECT * FROM techo;
}
} {10 b c 10 d e}
do_test vtab5.1.5 {
db close
sqlite3 db test.db
register_echo_module [sqlite3_connection_pointer db]
execsql {
DELETE FROM techo WHERE b > 'c';
SELECT * FROM techo;
}
} {10 b c}
finish_test