aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/altertab2.test22
-rw-r--r--test/bestindexC.test22
-rw-r--r--test/colname.test2
-rw-r--r--test/trigger1.test13
-rw-r--r--test/vtabL.test11
5 files changed, 64 insertions, 6 deletions
diff --git a/test/altertab2.test b/test/altertab2.test
index def9e5668..576dc4967 100644
--- a/test/altertab2.test
+++ b/test/altertab2.test
@@ -360,4 +360,26 @@ do_catchsql_test 8.6 {
SELECT sql FROM sqlite_master WHERE name='i0';
} {1 {error in index i0: second argument to likelihood() must be a constant between 0.0 and 1.0}}
+
+reset_db
+
+do_execsql_test 9.0 {
+ CREATE TABLE t1(a,b,c,d);
+ CREATE TABLE t2(a,b,c,d,x);
+
+ CREATE TRIGGER AFTER INSERT ON t2 BEGIN
+
+ SELECT group_conct(
+ 123 ORDER BY (
+ SELECT 1 FROM ( VALUES(a, 'b'), ('c') )
+ ))
+ FROM t1;
+
+ END;
+}
+
+do_catchsql_test 9.1 {
+ ALTER TABLE t2 RENAME TO newname;
+} {1 {error in trigger AFTER: all VALUES must have the same number of terms}}
+
finish_test
diff --git a/test/bestindexC.test b/test/bestindexC.test
index 708e56f77..c6ddf3061 100644
--- a/test/bestindexC.test
+++ b/test/bestindexC.test
@@ -177,9 +177,7 @@ unset ::do_not_use_offset
reset_db
proc vtab_command {lVal method args} {
switch -- $method {
- xConnect {
- error "not happy!"
- }
+ xConnect { error "not happy!" }
}
return {}
@@ -193,5 +191,23 @@ do_test 4.1 {
sqlite3_errcode db
} SQLITE_ERROR
+proc vtab_command {lVal method args} {
+ switch -- $method {
+ xConnect {
+ return $lVal
+ }
+ }
+ return {}
+}
+
+do_catchsql_test 4.2 {
+ CREATE VIRTUAL TABLE y1 USING tcl(vtab_command "PRAGMA page_size=1024");
+} {1 {declare_vtab: syntax error}}
+do_catchsql_test 4.3 {
+ CREATE VIRTUAL TABLE y1 USING tcl(vtab_command "CREATE TABLE x1(");
+} {1 {declare_vtab: incomplete input}}
+do_catchsql_test 4.4 {
+ CREATE VIRTUAL TABLE y1 USING tcl(vtab_command "CREATE TABLE x1(insert)");
+} {1 {declare_vtab: near "insert": syntax error}}
finish_test
diff --git a/test/colname.test b/test/colname.test
index 5fa0b601f..24fb51acf 100644
--- a/test/colname.test
+++ b/test/colname.test
@@ -424,7 +424,7 @@ do_catchsql_test colname-9.400 {
#
do_catchsql_test colname-9.410 {
CREATE TABLE t5 AS SELECT RAISE(abort,a);
-} {1 {RAISE() may only be used within a trigger-program}}
+} {1 {no such column: a}}
# Make sure the quotation marks get removed from the column names
# when constructing a new table from an aggregate SELECT.
diff --git a/test/trigger1.test b/test/trigger1.test
index 6de121fa9..afeb7ddcc 100644
--- a/test/trigger1.test
+++ b/test/trigger1.test
@@ -838,4 +838,17 @@ do_catchsql_test trigger1-23.1 {
END;
} {1 {near "#1": syntax error}}
+# 2024-05-08 Allow arbitrary expressions as the 2nd argument to RAISE().
+#
+do_catchsql_test trigger1-24.1 {
+ CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
+ SELECT raise(abort,format('attempt to insert %d where is not a power of 2',new.a))
+ WHERE (new.a & (new.a-1))!=0;
+ END;
+ INSERT INTO t1 VALUES(0),(1),(2),(4),(8),(65536);
+} {0 {}}
+do_catchsql_test trigger1-24.2 {
+ INSERT INTO t1 VALUES(9876);
+} {1 {attempt to insert 9876 where is not a power of 2}}
+
finish_test
diff --git a/test/vtabL.test b/test/vtabL.test
index 0834655ff..45528edcb 100644
--- a/test/vtabL.test
+++ b/test/vtabL.test
@@ -31,7 +31,6 @@ proc vtab_command {method args} {
return {}
}
-breakpoint
foreach {tn cts} {
1 {SELECT 123}
2 {SELECT 123, 456}
@@ -41,13 +40,21 @@ foreach {tn cts} {
6 {DROP TABLE nosuchtable}
7 {DROP TABLE x1}
8 {DROP TABLE t1}
+} {
+ set ::create_table_sql $cts
+ do_catchsql_test 1.$tn {
+ CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);
+ } {1 {declare_vtab: syntax error}}
+}
+
+foreach {tn cts} {
9 {CREATE TABLE xyz AS SELECT * FROM sqlite_schema}
10 {CREATE TABLE xyz AS SELECT 1 AS 'col'}
} {
set ::create_table_sql $cts
do_catchsql_test 1.$tn {
CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);
- } {1 {vtable constructor failed: x1}}
+ } {1 {declare_vtab: SQL logic error}}
}
foreach {tn cts} {