OLD | NEW |
1 # 2010 September 18 | 1 # 2010 September 18 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 1a "INSERT INTO a2 VALUES(1, 2, 3)" {} | 150 1a "INSERT INTO a2 VALUES(1, 2, 3)" {} |
151 1b "SELECT count(*) FROM a2" {1} | 151 1b "SELECT count(*) FROM a2" {1} |
152 | 152 |
153 2a "INSERT INTO a2(a, b) VALUES(1, 2)" {} | 153 2a "INSERT INTO a2(a, b) VALUES(1, 2)" {} |
154 2b "SELECT count(*) FROM a2" {2} | 154 2b "SELECT count(*) FROM a2" {2} |
155 | 155 |
156 3a "INSERT INTO a2(a) VALUES(3),(4)" {} | 156 3a "INSERT INTO a2(a) VALUES(3),(4)" {} |
157 3b "SELECT count(*) FROM a2" {4} | 157 3b "SELECT count(*) FROM a2" {4} |
158 } | 158 } |
159 | 159 |
160 # EVIDENCE-OF: R-53616-44976 If no column-list is specified then the | 160 # EVIDENCE-OF: R-19218-01018 If the column-name list after table-name is |
161 # number of values inserted into each row must be the same as the number | 161 # omitted then the number of values inserted into each row must be the |
162 # of columns in the table. | 162 # same as the number of columns in the table. |
163 # | 163 # |
164 # A test in the block above verifies that if the VALUES list has the | 164 # A test in the block above verifies that if the VALUES list has the |
165 # correct number of columns (for table a2, 3 columns) works. So these | 165 # correct number of columns (for table a2, 3 columns) works. So these |
166 # tests just show that other values cause an error. | 166 # tests just show that other values cause an error. |
167 # | 167 # |
168 do_insert_tests e_insert-1.2 -error { | 168 do_insert_tests e_insert-1.2 -error { |
169 table %s has %d columns but %d values were supplied | 169 table %s has %d columns but %d values were supplied |
170 } { | 170 } { |
171 1 "INSERT INTO a2 VALUES(1)" {a2 3 1} | 171 1 "INSERT INTO a2 VALUES(1)" {a2 3 1} |
172 2 "INSERT INTO a2 VALUES(1,2)" {a2 3 2} | 172 2 "INSERT INTO a2 VALUES(1,2)" {a2 3 2} |
(...skipping 11 matching lines...) Expand all Loading... |
184 1a "INSERT INTO a2 VALUES(1, 2, 3)" {} | 184 1a "INSERT INTO a2 VALUES(1, 2, 3)" {} |
185 1b "SELECT * FROM a2 WHERE oid=last_insert_rowid()" {1 2 3} | 185 1b "SELECT * FROM a2 WHERE oid=last_insert_rowid()" {1 2 3} |
186 | 186 |
187 2a "INSERT INTO a2 VALUES('abc', NULL, 3*3+1)" {} | 187 2a "INSERT INTO a2 VALUES('abc', NULL, 3*3+1)" {} |
188 2b "SELECT * FROM a2 WHERE oid=last_insert_rowid()" {abc {} 10} | 188 2b "SELECT * FROM a2 WHERE oid=last_insert_rowid()" {abc {} 10} |
189 | 189 |
190 3a "INSERT INTO a2 VALUES((SELECT count(*) FROM a2), 'x', 'y')" {} | 190 3a "INSERT INTO a2 VALUES((SELECT count(*) FROM a2), 'x', 'y')" {} |
191 3b "SELECT * FROM a2 WHERE oid=last_insert_rowid()" {2 x y} | 191 3b "SELECT * FROM a2 WHERE oid=last_insert_rowid()" {2 x y} |
192 } | 192 } |
193 | 193 |
194 # EVIDENCE-OF: R-09234-17933 If a column-list is specified, then the | 194 # EVIDENCE-OF: R-21115-58321 If a column-name list is specified, then |
195 # number of values in each term of the VALUE list must match the number | 195 # the number of values in each term of the VALUE list must match the |
196 # of specified columns. | 196 # number of specified columns. |
197 # | 197 # |
198 do_insert_tests e_insert-1.4 -error { | 198 do_insert_tests e_insert-1.4 -error { |
199 %d values for %d columns | 199 %d values for %d columns |
200 } { | 200 } { |
201 1 "INSERT INTO a2(a, b, c) VALUES(1)" {1 3} | 201 1 "INSERT INTO a2(a, b, c) VALUES(1)" {1 3} |
202 2 "INSERT INTO a2(a, b, c) VALUES(1,2)" {2 3} | 202 2 "INSERT INTO a2(a, b, c) VALUES(1,2)" {2 3} |
203 3 "INSERT INTO a2(a, b, c) VALUES(1,2,3,4)" {4 3} | 203 3 "INSERT INTO a2(a, b, c) VALUES(1,2,3,4)" {4 3} |
204 4 "INSERT INTO a2(a, b, c) VALUES(1,2,3,4,5)" {5 3} | 204 4 "INSERT INTO a2(a, b, c) VALUES(1,2,3,4,5)" {5 3} |
205 | 205 |
206 5 "INSERT INTO a2(c, a) VALUES(1)" {1 2} | 206 5 "INSERT INTO a2(c, a) VALUES(1)" {1 2} |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 4.1 "INSERT INTO a2 DEFAULT VALUES" {} | 341 4.1 "INSERT INTO a2 DEFAULT VALUES" {} |
342 4.2 "SELECT * FROM a2" {{} {} xyz {} {} xyz} | 342 4.2 "SELECT * FROM a2" {{} {} xyz {} {} xyz} |
343 | 343 |
344 5.1 "INSERT INTO a1 DEFAULT VALUES" {} | 344 5.1 "INSERT INTO a1 DEFAULT VALUES" {} |
345 5.2 "SELECT * FROM a1" {{} {}} | 345 5.2 "SELECT * FROM a1" {{} {}} |
346 | 346 |
347 6.1 "INSERT INTO a1 DEFAULT VALUES" {} | 347 6.1 "INSERT INTO a1 DEFAULT VALUES" {} |
348 6.2 "SELECT * FROM a1" {{} {} {} {}} | 348 6.2 "SELECT * FROM a1" {{} {} {} {}} |
349 } | 349 } |
350 | 350 |
351 # EVIDENCE-OF: R-46928-50290 The optional conflict-clause allows the | 351 # EVIDENCE-OF: R-03235-45250 The "REPLACE" and "INSERT OR action" forms |
352 # specification of an alternative constraint conflict resolution | 352 # specify an alternative constraint conflict resolution algorithm to use |
353 # algorithm to use during this one INSERT command. | 353 # during this one INSERT command. |
354 # | 354 # |
355 # EVIDENCE-OF: R-23110-47146 the parser allows the use of the single | 355 # EVIDENCE-OF: R-23110-47146 the parser allows the use of the single |
356 # keyword REPLACE as an alias for "INSERT OR REPLACE". | 356 # keyword REPLACE as an alias for "INSERT OR REPLACE". |
357 # | 357 # |
358 # The two requirements above are tested by e_select-4.1.* and | 358 # The two requirements above are tested by e_select-4.1.* and |
359 # e_select-4.2.*, respectively. | 359 # e_select-4.2.*, respectively. |
360 # | 360 # |
361 # EVIDENCE-OF: R-03421-22330 The REPLACE command is an alias for the | 361 # EVIDENCE-OF: R-03421-22330 The REPLACE command is an alias for the |
362 # "INSERT OR REPLACE" variant of the INSERT command. | 362 # "INSERT OR REPLACE" variant of the INSERT command. |
363 # | 363 # |
(...skipping 23 matching lines...) Expand all Loading... |
387 | 387 |
388 2.1 "INSERT INTO a4 VALUES(2,'f')" | 388 2.1 "INSERT INTO a4 VALUES(2,'f')" |
389 {UNIQUE constraint failed: a4.c} 1 {1 a 3 a 2 b 4 e} | 389 {UNIQUE constraint failed: a4.c} 1 {1 a 3 a 2 b 4 e} |
390 2.2 "REPLACE INTO a4 VALUES(2, 'f')" {} 1 {1 a 3 a 4 e 2 f} | 390 2.2 "REPLACE INTO a4 VALUES(2, 'f')" {} 1 {1 a 3 a 4 e 2 f} |
391 } { | 391 } { |
392 do_catchsql_test e_insert-4.1.$tn.1 $sql [list [expr {$error!=""}] $error] | 392 do_catchsql_test e_insert-4.1.$tn.1 $sql [list [expr {$error!=""}] $error] |
393 do_execsql_test e_insert-4.1.$tn.2 {SELECT * FROM a4} [list {*}$data] | 393 do_execsql_test e_insert-4.1.$tn.2 {SELECT * FROM a4} [list {*}$data] |
394 do_test e_insert-4.1.$tn.3 {sqlite3_get_autocommit db} $ac | 394 do_test e_insert-4.1.$tn.3 {sqlite3_get_autocommit db} $ac |
395 } | 395 } |
396 | 396 |
397 # EVIDENCE-OF: R-64196-02418 The optional "database-name." prefix on the | 397 # EVIDENCE-OF: R-59829-49719 The optional "schema-name." prefix on the |
398 # table-name is support for top-level INSERT statements only. | 398 # table-name is supported for top-level INSERT statements only. |
399 # | 399 # |
400 # EVIDENCE-OF: R-05731-00924 The table name must be unqualified for | 400 # EVIDENCE-OF: R-05731-00924 The table name must be unqualified for |
401 # INSERT statements that occur within CREATE TRIGGER statements. | 401 # INSERT statements that occur within CREATE TRIGGER statements. |
402 # | 402 # |
403 set err {1 {qualified table names are not allowed on INSERT, UPDATE, and DELETE
statements within triggers}} | 403 set err {1 {qualified table names are not allowed on INSERT, UPDATE, and DELETE
statements within triggers}} |
404 | 404 |
405 do_catchsql_test e_insert-5.1.1 { | 405 do_catchsql_test e_insert-5.1.1 { |
406 CREATE TRIGGER AFTER UPDATE ON a1 BEGIN | 406 CREATE TRIGGER AFTER UPDATE ON a1 BEGIN |
407 INSERT INTO main.a4 VALUES(new.a, new.b); | 407 INSERT INTO main.a4 VALUES(new.a, new.b); |
408 END; | 408 END; |
(...skipping 12 matching lines...) Expand all Loading... |
421 do_catchsql_test e_insert-5.2.1 { | 421 do_catchsql_test e_insert-5.2.1 { |
422 CREATE TRIGGER AFTER UPDATE ON a1 BEGIN | 422 CREATE TRIGGER AFTER UPDATE ON a1 BEGIN |
423 INSERT INTO a4 DEFAULT VALUES; | 423 INSERT INTO a4 DEFAULT VALUES; |
424 END; | 424 END; |
425 } {1 {near "DEFAULT": syntax error}} | 425 } {1 {near "DEFAULT": syntax error}} |
426 | 426 |
427 | 427 |
428 delete_all_data | 428 delete_all_data |
429 | 429 |
430 finish_test | 430 finish_test |
OLD | NEW |