]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add further tests to e_insert.test.
authordan <dan@noemail.net>
Mon, 20 Sep 2010 14:05:51 +0000 (14:05 +0000)
committerdan <dan@noemail.net>
Mon, 20 Sep 2010 14:05:51 +0000 (14:05 +0000)
FossilOrigin-Name: eb3d0d8bb78aa7132f842480bc88621b1573f19c

manifest
manifest.uuid
test/e_insert.test

index 4c5973cb7cb150f9b98965f732395ca9a926ceac..5403a1e3c413d349a3dfb99a1abd200559740071 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sa\stest\scase\sto\sverify\sthat\sbug\s[313723c356]\shas\sbeen\sfixed.
-D 2010-09-20T08:47:01
+C Add\sfurther\stests\sto\se_insert.test.
+D 2010-09-20T14:05:52
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in c599a15d268b1db2aeadea19df2adc3bf2eb6bee
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -350,7 +350,7 @@ F test/distinctagg.test 1a6ef9c87a58669438fc771450d7a72577417376
 F test/e_expr.test 164e87c1d7b40ceb47c57c3bffa384c81d009aa7
 F test/e_fkey.test 6721a741c6499b3ab7e5385923233343c8f1ad05
 F test/e_fts3.test 75bb0aee26384ef586165e21018a17f7cd843469
-F test/e_insert.test 066926c10eeffbde3890a84d5f8b63dbbb2b6aa9
+F test/e_insert.test 9c72d3c255310ab8c64cd825a8a384fb7eb69109
 F test/e_select.test 64b9cc44f8df454f45bc8df032e12032c8bf8670
 F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea
 F test/enc2.test 6d91a5286f59add0cfcbb2d0da913b76f2242398
@@ -860,7 +860,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P e14ef0e8b4a27dbd58338214242eb3928404b176
-R c7291b56f5740f90d8dcf09aabde4142
+P 4ea134a84c264b55cdb6f6f8e740b252278ce792
+R 1dd2a51aedf94ac559de0c255b3913ec
 U dan
-Z bea42f9bac10fe0c0c7da75967ce3ee2
+Z 0a43987fd63a2fd5993e6c4cc09d002d
index 9e4117b115206a6a580c355a967cc0f256aaba93..2e2bad97f21334759ddf547413e781f2520d582b 100644 (file)
@@ -1 +1 @@
-4ea134a84c264b55cdb6f6f8e740b252278ce792
\ No newline at end of file
+eb3d0d8bb78aa7132f842480bc88621b1573f19c
\ No newline at end of file
index ece745d15fa11b079a0bb15eedbbb92f045152c8..c0cc8ab56233305d784b47dbbc778a71012db45a 100644 (file)
@@ -25,12 +25,17 @@ source $testdir/tester.tcl
 #
 #   e_insert-3.*: Test statements of the form "INSERT ... DEFAULT VALUES".
 #
+#   e_insert-4.*: Test statements regarding the conflict clause.
+#
+#   e_insert-5.*: Test that the qualified table name and "DEFAULT VALUES"
+#                 syntaxes do not work in trigger bodies.
+#
 
 do_execsql_test e_insert-0.0 {
   CREATE TABLE a1(a, b);
   CREATE TABLE a2(a, b, c DEFAULT 'xyz');
-
   CREATE TABLE a3(x DEFAULT 1.0, y DEFAULT 'string', z);
+  CREATE TABLE a4(c UNIQUE, d);
 } {}
 
 proc delete_all_data {} {
@@ -201,7 +206,33 @@ do_insert_tests e_insert-1.5 {
     2b   "SELECT * FROM a2"                          {{} b c  a b xyz}
 }
 
+# EVIDENCE-OF: R-52173-30215 A new entry is inserted into the table for
+# each row of data returned by executing the SELECT statement.
+#
 delete_all_data
+do_insert_tests e_insert-2.1 {
+    0    "SELECT count(*) FROM a1"            {0}
+
+    1a   "SELECT count(*) FROM (SELECT 1, 2)" {1}
+    1b   "INSERT INTO a1 SELECT 1, 2"         {}
+    1c   "SELECT count(*) FROM a1"            {1}
+
+    2a   "SELECT count(*) FROM (SELECT b, a FROM a1)"           {1}
+    2b   "INSERT INTO a1 SELECT b, a FROM a1"                   {}
+    2c   "SELECT count(*) FROM a1"                              {2}
+
+    3a   "SELECT count(*) FROM (SELECT b, a FROM a1)"           {2}
+    3b   "INSERT INTO a1 SELECT b, a FROM a1"                   {}
+    3c   "SELECT count(*) FROM a1"                              {4}
+
+    4a   "SELECT count(*) FROM (SELECT b, a FROM a1)"           {4}
+    4b   "INSERT INTO a1 SELECT b, a FROM a1"                   {}
+    4c   "SELECT count(*) FROM a1"                              {8}
+
+    4a   "SELECT count(*) FROM (SELECT min(b), min(a) FROM a1)" {1}
+    4b   "INSERT INTO a1 SELECT min(b), min(a) FROM a1"         {}
+    4c   "SELECT count(*) FROM a1"                              {9}
+}
 
 
 # EVIDENCE-OF: R-63614-47421 If a column-list is specified, the number
@@ -238,6 +269,27 @@ do_insert_tests e_insert-2.3 -error {
     5    "INSERT INTO a1 SELECT a2.a FROM a2,a1"            {a1 2 1}
 }
 
+# EVIDENCE-OF: R-31074-37730 Any SELECT statement, including compound
+# SELECTs and SELECT statements with ORDER BY and/or LIMIT clauses, may
+# be used in an INSERT statement of this form.
+#
+delete_all_data
+do_execsql_test e_insert-2.3.0 {
+  INSERT INTO a1 VALUES('x', 'y');
+} {}
+do_insert_tests e_insert-2.3 {
+  1  "INSERT INTO a1 SELECT a,b FROM a1 UNION SELECT b,a FROM a1 ORDER BY 1" {}
+  2  "INSERT INTO a1(b, a) SELECT * FROM a1 LIMIT 1"                         {}
+  3  "INSERT INTO a1 SELECT 'a'||a, 'b'||b FROM a1 LIMIT 2 OFFSET 1"         {}
+  4  "INSERT INTO a1 SELECT * FROM a1 ORDER BY b, a"                         {}
+  S  "SELECT * FROM a1" {
+      x y 
+      x y y x
+      y x
+      ax by ay bx 
+      ay bx ax by y x y x x y x y
+  }
+}
 
 # EVIDENCE-OF: R-25149-22012 The INSERT ... DEFAULT VALUES statement
 # inserts a single new row into the named table.
@@ -275,6 +327,74 @@ do_insert_tests e_insert-3.2 {
     6.2    "SELECT * FROM a1"                  {{} {} {} {}}
 }
 
+# EVIDENCE-OF: R-46928-50290 The optional conflict-clause allows the
+# specification of an alternative constraint conflict resolution
+# algorithm to use during this one INSERT command.
+#
+# EVIDENCE-OF: R-23110-47146 the parser allows the use of the single
+# keyword REPLACE as an alias for "INSERT OR REPLACE".
+#
+#    The two requirements above are tested by e_select-4.1.* and
+#    e_select-4.2.*, respectively.
+#
+do_execsql_test e_insert-4.1.0 {
+  INSERT INTO a4 VALUES(1, 'a');
+  INSERT INTO a4 VALUES(2, 'a');
+  INSERT INTO a4 VALUES(3, 'a');
+} {}
+foreach {tn sql error ac data } {
+  1.1  "INSERT INTO a4 VALUES(2,'b')"  {column c is not unique}  1 {1 a 2 a 3 a}
+  1.2  "INSERT OR REPLACE INTO a4 VALUES(2, 'b')"            {}  1 {1 a 3 a 2 b}
+  1.3  "INSERT OR IGNORE INTO a4 VALUES(3, 'c')"             {}  1 {1 a 3 a 2 b}
+  1.4  "BEGIN" {} 0 {1 a 3 a 2 b}
+  1.5  "INSERT INTO a4 VALUES(1, 'd')" {column c is not unique}  0 {1 a 3 a 2 b}
+  1.6  "INSERT OR ABORT INTO a4 VALUES(1, 'd')" 
+        {column c is not unique}  0 {1 a 3 a 2 b}
+  1.7  "INSERT OR ROLLBACK INTO a4 VALUES(1, 'd')" 
+        {column c is not unique}  1 {1 a 3 a 2 b}
+  1.8  "INSERT INTO a4 SELECT 4, 'e' UNION ALL SELECT 3, 'e'"
+        {column c is not unique}  1 {1 a 3 a 2 b}
+  1.9  "INSERT OR FAIL INTO a4 SELECT 4, 'e' UNION ALL SELECT 3, 'e'"
+        {column c is not unique}  1 {1 a 3 a 2 b 4 e}
+
+  2.1  "INSERT INTO a4 VALUES(2,'f')"  
+        {column c is not unique}  1 {1 a 3 a 2 b 4 e}
+  2.2  "REPLACE INTO a4 VALUES(2, 'f')" {}  1 {1 a 3 a 4 e 2 f}
+} {
+  do_catchsql_test e_insert-4.1.$tn.1 $sql [list [expr {$error!=""}] $error]
+  do_execsql_test  e_insert-4.1.$tn.2 {SELECT * FROM a4} [list {*}$data]
+  do_test          e_insert-4.1.$tn.3 {sqlite3_get_autocommit db} $ac
+}
+
+# EVIDENCE-OF: R-64196-02418 The optional "database-name." prefix on the
+# table-name is support for top-level INSERT statements only.
+#
+# EVIDENCE-OF: R-05731-00924 The table name must be unqualified for
+# INSERT statements that occur within CREATE TRIGGER statements.
+#
+set err {1 {qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers}}
+
+do_catchsql_test e_insert-5.1.1 {
+  CREATE TRIGGER AFTER UPDATE ON a1 BEGIN
+    INSERT INTO main.a4 VALUES(new.a, new.b);
+  END;
+} $err
+do_catchsql_test e_insert-5.1.2 {
+  CREATE TEMP TABLE IF NOT EXISTS tmptable(a, b);
+  CREATE TRIGGER AFTER DELETE ON a3 BEGIN
+    INSERT INTO temp.tmptable VALUES(1, 2);
+  END;
+} $err
+
+# EVIDENCE-OF: R-15888-36326 Similarly, the "DEFAULT VALUES" form of the
+# INSERT statement is supported for top-level INSERT statements only and
+# not for INSERT statements within triggers.
+#
+do_catchsql_test e_insert-5.2.1 {
+  CREATE TRIGGER AFTER UPDATE ON a1 BEGIN
+    INSERT INTO a4 DEFAULT VALUES;
+  END;
+} {1 {near "DEFAULT": syntax error}}
 
 
 delete_all_data