Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Run some more legacy tests. Fix some issues with converting between text and numeric values. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
d6d0e21ad2770739d086a759f6a81331 |
User & Date: | dan 2013-06-27 20:23:03.483 |
Context
2013-06-29
| ||
18:46 | Run further legacy tests. Fixes for bugs brought to light by the same. check-in: cb7a8b464e user: dan tags: trunk | |
2013-06-27
| ||
20:23 | Run some more legacy tests. Fix some issues with converting between text and numeric values. check-in: d6d0e21ad2 user: dan tags: trunk | |
17:40 | Run some more legacy test cases. check-in: 731841907a user: dan tags: trunk | |
Changes
Changes to src/math.c.
︙ | ︙ | |||
348 349 350 351 352 353 354 | nIn -= 1; } } /* If the IGNORE_WHITESPACE flag is set, ignore any leading whitespace. */ i = 0; if( flags & SQLITE4_IGNORE_WHITESPACE ){ | | | 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | nIn -= 1; } } /* If the IGNORE_WHITESPACE flag is set, ignore any leading whitespace. */ i = 0; if( flags & SQLITE4_IGNORE_WHITESPACE ){ while( i<nIn && sqlite4Isspace(zIn[i]) ) i+=incr; } if( nIn<=i ) return error_value; /* Check for a leading '+' or '-' symbol. */ if( zIn[i]=='-' ){ r.sign = 1; i += incr; |
︙ | ︙ | |||
632 633 634 635 636 637 638 | memcpy(z, "NaN", 4); }else{ memcpy(z, "inf", 4); } return (z - zOut)+3; } if( x.m==0 ){ | > > > | > | 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | memcpy(z, "NaN", 4); }else{ memcpy(z, "inf", 4); } return (z - zOut)+3; } if( x.m==0 ){ if( bReal ){ memcpy(z, "0.0", 4); }else{ memcpy(z, "0", 2); } return 1+(z-zOut); } zNum = renderInt(x.m, zBuf, sizeof(zBuf)); n = &zBuf[sizeof(zBuf)-1] - zNum; if( x.e>=0 && x.e+n<=25 ){ /* Integer values with up to 25 digits */ memcpy(z, zNum, n+1); |
︙ | ︙ |
Changes to src/vdbemem.c.
︙ | ︙ | |||
331 332 333 334 335 336 337 | */ int sqlite4VdbeMemIntegerify(Mem *pMem){ assert( pMem->db==0 || sqlite4_mutex_held(pMem->db->mutex) ); assert( (pMem->flags & MEM_RowSet)==0 ); assert( EIGHT_BYTE_ALIGNMENT(pMem) ); if( (pMem->flags & MEM_Int)==0 ){ | > | > > > > > | > | 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | */ int sqlite4VdbeMemIntegerify(Mem *pMem){ assert( pMem->db==0 || sqlite4_mutex_held(pMem->db->mutex) ); assert( (pMem->flags & MEM_RowSet)==0 ); assert( EIGHT_BYTE_ALIGNMENT(pMem) ); if( (pMem->flags & MEM_Int)==0 ){ if( pMem->flags & (MEM_Real|MEM_Null) ){ pMem->u.num = sqlite4_num_from_int64(sqlite4VdbeIntValue(pMem)); }else{ unsigned int flags = pMem->enc | SQLITE4_INTEGER_ONLY|SQLITE4_PREFIX_ONLY|SQLITE4_IGNORE_WHITESPACE; pMem->u.num = sqlite4_num_from_text(pMem->z, pMem->n, flags, 0); } MemSetTypeFlag(pMem, MEM_Int); } return SQLITE4_OK; } /* ** Convert pMem so that it has types MEM_Real or MEM_Int or both. ** Invalidate any prior representations. ** ** Every effort is made to force the conversion, even if the input ** is a string that does not look completely like a number. Convert ** as much of the string as we can and ignore the rest. */ int sqlite4VdbeMemNumerify(Mem *pMem){ if( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))==0 ){ int bReal = 0; int flags = (pMem->enc | SQLITE4_PREFIX_ONLY | SQLITE4_IGNORE_WHITESPACE); assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 ); assert( pMem->db==0 || sqlite4_mutex_held(pMem->db->mutex) ); pMem->u.num = sqlite4_num_from_text(pMem->z, pMem->n, flags, 0); sqlite4_num_to_int64(pMem->u.num, &bReal); MemSetTypeFlag(pMem, (bReal ? MEM_Real : MEM_Int)); } assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))!=0 ); pMem->flags &= ~(MEM_Str|MEM_Blob); return SQLITE4_OK; } |
︙ | ︙ |
Changes to test/e_createtable.test.
︙ | ︙ | |||
361 362 363 364 365 366 367 | do_createtable_tests 1.1.1 -error { object name reserved for internal use: %s } { 1 "CREATE TABLE sqlite_abc(a, b, c)" sqlite_abc 2 "CREATE TABLE temp.sqlite_helloworld(x)" sqlite_helloworld 3 {CREATE TABLE auxa."sqlite__"(x, y)} sqlite__ 4 {CREATE TABLE auxb."sqlite_"(z)} sqlite_ | | | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | do_createtable_tests 1.1.1 -error { object name reserved for internal use: %s } { 1 "CREATE TABLE sqlite_abc(a, b, c)" sqlite_abc 2 "CREATE TABLE temp.sqlite_helloworld(x)" sqlite_helloworld 3 {CREATE TABLE auxa."sqlite__"(x, y)} sqlite__ 4 {CREATE TABLE auxb."sqlite_"(z)} sqlite_ 5 {CREATE TABLE "SQLITE_TBL"(z)} SQLITE_TBL } do_createtable_tests 1.1.2 { 1 "CREATE TABLE sqlit_abc(a, b, c)" {} 2 "CREATE TABLE temp.sqlitehelloworld(x)" {} 3 {CREATE TABLE auxa."sqlite"(x, y)} {} 4 {CREATE TABLE auxb."sqlite-"(z)} {} 5 {CREATE TABLE "SQLITE-TBL"(z)} {} |
︙ | ︙ | |||
612 613 614 615 616 617 618 | # # table_column_decltypes TBL # The argument must be a table name. Return a list of column declared # types, from left to right, for the table. # proc sci {select cmd} { set res [list] | | | 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 | # # table_column_decltypes TBL # The argument must be a table name. Return a list of column declared # types, from left to right, for the table. # proc sci {select cmd} { set res [list] set STMT [sqlite4_prepare db $select -1 dummy] for {set i 0} {$i < [sqlite4_column_count $STMT]} {incr i} { lappend res [$cmd $STMT $i] } sqlite4_finalize $STMT set res } proc tci {tbl cmd} { sci "SELECT * FROM $tbl" $cmd } |
︙ | ︙ | |||
917 918 919 920 921 922 923 | set sqlite_current_time 1000000000 do_createtable_tests 3.5 -query { SELECT quote(a), quote(b), quote(c), quote(d), quote(e), quote(f), quote(g), quote(h), quote(i), quote(j), quote(k) FROM t4 ORDER BY rowid DESC LIMIT 1; } { 1 "INSERT INTO t4 DEFAULT VALUES" { | | | | 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 | set sqlite_current_time 1000000000 do_createtable_tests 3.5 -query { SELECT quote(a), quote(b), quote(c), quote(d), quote(e), quote(f), quote(g), quote(h), quote(i), quote(j), quote(k) FROM t4 ORDER BY rowid DESC LIMIT 1; } { 1 "INSERT INTO t4 DEFAULT VALUES" { NULL {'string constant'} x'424c4f42' 1 -1 3.14 -3.14 'acd' '01:46:40' '2001-09-09' {'2001-09-09 01:46:40'} } 2 "INSERT INTO t4(a, b, c) VALUES(1, 2, 3)" { 1 2 3 1 -1 3.14 -3.14 'acd' '01:46:40' '2001-09-09' {'2001-09-09 01:46:40'} } 3 "INSERT INTO t4(k, j, i) VALUES(1, 2, 3)" { NULL {'string constant'} x'424c4f42' 1 -1 3.14 -3.14 'acd' 3 2 1 } 4 "INSERT INTO t4(a,b,c,d,e,f,g,h,i,j,k) VALUES(1,2,3,4,5,6,7,8,9,10,11)" { 1 2 3 4 5 6 7 8 9 10 11 } } |
︙ | ︙ | |||
950 951 952 953 954 955 956 | d DEFAULT -45678.6, e DEFAULT 394507 ); } {} do_execsql_test e_createtable-3.6.2 { INSERT INTO t5 DEFAULT VALUES; SELECT quote(a), quote(b), quote(c), quote(d), quote(e) FROM t5; | | | 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 | d DEFAULT -45678.6, e DEFAULT 394507 ); } {} do_execsql_test e_createtable-3.6.2 { INSERT INTO t5 DEFAULT VALUES; SELECT quote(a), quote(b), quote(c), quote(d), quote(e) FROM t5; } {NULL {'text value'} x'424c4f42' -45678.6 394507} # EVIDENCE-OF: R-60616-50251 If the default value of a column is an # expression in parentheses, then the expression is evaluated once for # each row inserted and the results used in the new row. # # Test case 3.6.4 demonstrates that the expression is evaluated # separately for each row if the INSERT is an "INSERT INTO ... SELECT ..." |
︙ | ︙ | |||
1085 1086 1087 1088 1089 1090 1091 | # default compile time value. # sqlite4_limit db SQLITE4_LIMIT_COLUMN [expr $::SQLITE4_MAX_COLUMN+2] do_catchsql_test e_createtable-3.11.3 [subst { CREATE TABLE t11([columns [expr $::SQLITE4_MAX_COLUMN+1]]); }] {1 {too many columns on t11}} | | | 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 | # default compile time value. # sqlite4_limit db SQLITE4_LIMIT_COLUMN [expr $::SQLITE4_MAX_COLUMN+2] do_catchsql_test e_createtable-3.11.3 [subst { CREATE TABLE t11([columns [expr $::SQLITE4_MAX_COLUMN+1]]); }] {1 {too many columns on t11}} sqlite4_limit db SQLITE4_LIMIT_LENGTH 90013 do_execsql_test e_createtable-3.11.4 { CREATE TABLE t12(a, b, c); INSERT INTO t12 VALUES(randomblob(30000),randomblob(30000),randomblob(30000)); } {} do_catchsql_test e_createtable-3.11.5 { INSERT INTO t12 VALUES(randomblob(30001),randomblob(30000),randomblob(30000)); } {1 {string or blob too big}} |
︙ | ︙ | |||
1181 1182 1183 1184 1185 1186 1187 | CREATE TABLE t2(x, y, PRIMARY KEY(x, y)); INSERT INTO t2 VALUES(0, 'zero'); INSERT INTO t2 VALUES(45.5, 'one'); INSERT INTO t2 VALUES('brambles', 'two'); INSERT INTO t2 VALUES(X'ABCDEF', 'three'); } {} | | | | | | | | | | | | | | | | | | | | < | | < | < < | < | | | | | | | | | | | | | | | < < < < < < < | | | | | | 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 | CREATE TABLE t2(x, y, PRIMARY KEY(x, y)); INSERT INTO t2 VALUES(0, 'zero'); INSERT INTO t2 VALUES(45.5, 'one'); INSERT INTO t2 VALUES('brambles', 'two'); INSERT INTO t2 VALUES(X'ABCDEF', 'three'); } {} do_createtable_tests 4.3.1 -error { PRIMARY KEY must be unique%s } { 1 "INSERT INTO t1 VALUES(0, 0)" {""} 2 "INSERT INTO t1 VALUES(45.5, 'abc')" {""} 3 "INSERT INTO t1 VALUES(0.0, 'abc')" {""} 4 "INSERT INTO t1 VALUES('brambles', 'abc')" {""} 5 "INSERT INTO t1 VALUES(X'ABCDEF', 'abc')" {""} 6 "INSERT INTO t2 VALUES(0, 'zero')" {""} 7 "INSERT INTO t2 VALUES(45.5, 'one')" {""} 8 "INSERT INTO t2 VALUES(0.0, 'zero')" {""} 9 "INSERT INTO t2 VALUES('brambles', 'two')" {""} 10 "INSERT INTO t2 VALUES(X'ABCDEF', 'three')" {""} } do_createtable_tests 4.3.2 { 1 "INSERT INTO t1 VALUES(-1, 0)" {} 2 "INSERT INTO t1 VALUES(45.2, 'abc')" {} 3 "INSERT INTO t1 VALUES(0.01, 'abc')" {} 4 "INSERT INTO t1 VALUES('bramble', 'abc')" {} 5 "INSERT INTO t1 VALUES(X'ABCDEE', 'abc')" {} 6 "INSERT INTO t2 VALUES(0, 0)" {} 7 "INSERT INTO t2 VALUES(45.5, 'abc')" {} 8 "INSERT INTO t2 VALUES(0.0, 'abc')" {} 9 "INSERT INTO t2 VALUES('brambles', 'abc')" {} 10 "INSERT INTO t2 VALUES(X'ABCDEF', 'abc')" {} } do_createtable_tests 4.3.3 -error { PRIMARY KEY must be unique%s } { 1 "UPDATE t1 SET x=0 WHERE y='two'" {""} 2 "UPDATE t1 SET x='brambles' WHERE y='three'" {""} 3 "UPDATE t1 SET x=45.5 WHERE y='zero'" {""} 4 "UPDATE t1 SET x=X'ABCDEF' WHERE y='one'" {""} 5 "UPDATE t1 SET x=0.0 WHERE y='three'" {""} 6 "UPDATE t2 SET x=0, y='zero' WHERE y='two'" {""} 7 "UPDATE t2 SET x='brambles', y='two' WHERE y='three'" {""} 8 "UPDATE t2 SET x=45.5, y='one' WHERE y='zero'" {""} 9 "UPDATE t2 SET x=X'ABCDEF', y='three' WHERE y='one'" {""} 10 "UPDATE t2 SET x=0.0, y='zero' WHERE y='three'" {""} } # src4 does not allow NULL values in primary key columns. # do_createtable_tests 4.4 -error { %s may not be NULL } { 1 "INSERT INTO t1 VALUES(NULL, 0)" {t1.x} 2 "INSERT INTO t1 VALUES(NULL, 0)" {t1.x} 3 "INSERT INTO t1 VALUES(NULL, 0)" {t1.x} 4 "INSERT INTO t2 VALUES(NULL, 'zero')" {t2.x} 5 "INSERT INTO t2 VALUES(NULL, 'one')" {t2.x} 6 "INSERT INTO t2 VALUES(NULL, 'two')" {t2.x} 7 "INSERT INTO t2 VALUES(NULL, 'three')" {t2.x} 8 "INSERT INTO t2 VALUES(0, NULL)" {t2.y} 9 "INSERT INTO t2 VALUES(45.5, NULL)" {t2.y} 10 "INSERT INTO t2 VALUES(0.0, NULL)" {t2.y} 11 "INSERT INTO t2 VALUES('brambles', NULL)" {t2.y} 12 "INSERT INTO t2 VALUES(X'ABCDEF', NULL)" {t2.y} 13 "INSERT INTO t2 VALUES(NULL, NULL)" {t2.x} 14 "INSERT INTO t2 VALUES(NULL, NULL)" {t2.x} } do_createtable_tests 4.5.1 { 1 "SELECT count(*) FROM t1 WHERE x IS NULL" 0 2 "SELECT count(*) FROM t2 WHERE x IS NULL" 0 3 "SELECT count(*) FROM t2 WHERE y IS NULL" 0 4 "SELECT count(*) FROM t2 WHERE x IS NULL AND y IS NULL" 0 } do_execsql_test 4.5.2 { CREATE TABLE t3(s, u INTEGER PRIMARY KEY, v); INSERT INTO t3 VALUES(1, NULL, 2); INSERT INTO t3 VALUES('x', NULL, 'y'); SELECT u FROM t3; } {1 2} do_catchsql_test 4.5.3 { INSERT INTO t3 VALUES(2, 5, 3); UPDATE t3 SET u = NULL WHERE s = 2; } {1 {t3.u may not be NULL}} # EVIDENCE-OF: R-00227-21080 A UNIQUE constraint is similar to a PRIMARY # KEY constraint, except that a single table may have any number of # UNIQUE constraints. # drop_all_tables do_createtable_tests 4.6 { |
︙ | ︙ | |||
1348 1349 1350 1351 1352 1353 1354 | # EVIDENCE-OF: R-26983-26377 INTEGER PRIMARY KEY columns aside, both # UNIQUE and PRIMARY KEY constraints are implemented by creating an # index in the database (in the same way as a "CREATE UNIQUE INDEX" # statement would). do_createtable_tests 4.9 -repair drop_all_tables -query { SELECT count(*) FROM sqlite_master WHERE type='index' } { | | | | | | | | 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 | # EVIDENCE-OF: R-26983-26377 INTEGER PRIMARY KEY columns aside, both # UNIQUE and PRIMARY KEY constraints are implemented by creating an # index in the database (in the same way as a "CREATE UNIQUE INDEX" # statement would). do_createtable_tests 4.9 -repair drop_all_tables -query { SELECT count(*) FROM sqlite_master WHERE type='index' } { 1 "CREATE TABLE t1(a TEXT PRIMARY KEY, b)" 0 2 "CREATE TABLE t1(a INTEGER PRIMARY KEY, b)" 0 3 "CREATE TABLE t1(a TEXT UNIQUE, b)" 1 4 "CREATE TABLE t1(a PRIMARY KEY, b TEXT UNIQUE)" 1 5 "CREATE TABLE t1(a PRIMARY KEY, b, c, UNIQUE(c, b))" 1 } # EVIDENCE-OF: R-02252-33116 Such an index is used like any other index # in the database to optimize queries. # do_execsql_test 4.10.0 { CREATE TABLE t1(a, b PRIMARY KEY); CREATE TABLE t2(a, b, c, UNIQUE(b, c)); } do_createtable_tests 4.10 { 1 "EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b = 5" {0 0 0 {SEARCH TABLE t1 USING PRIMARY KEY (b=?) (~1 rows)}} 2 "EXPLAIN QUERY PLAN SELECT * FROM t2 ORDER BY b, c" {0 0 0 {SCAN TABLE t2 USING INDEX sqlite_t2_unique1 (~1000000 rows)}} 3 "EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE b=10 AND c>10" {0 0 0 {SEARCH TABLE t2 USING INDEX sqlite_t2_unique1 (b=? AND c>?) (~2 rows)}} } # EVIDENCE-OF: R-45493-35653 A CHECK constraint may be attached to a # column definition or specified as a table constraint. In practice it # makes no difference. # # All the tests that deal with CHECK constraints below (4.11.* and |
︙ | ︙ | |||
1536 1537 1538 1539 1540 1541 1542 | INSERT INTO t3_ig SELECT * FROM t3_ab; INSERT INTO t3_fa SELECT * FROM t3_ab; INSERT INTO t3_re SELECT * FROM t3_ab; INSERT INTO t3_xx SELECT * FROM t3_ab; } foreach {tn tbl res ac data} { | | | | | | | | | | | | | | | | | | | | | | | | 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 | INSERT INTO t3_ig SELECT * FROM t3_ab; INSERT INTO t3_fa SELECT * FROM t3_ab; INSERT INTO t3_re SELECT * FROM t3_ab; INSERT INTO t3_xx SELECT * FROM t3_ab; } foreach {tn tbl res ac data} { 1 t1_ab {1 {PRIMARY KEY must be unique}} 0 {1 one 2 two 3 three} 2 t1_ro {1 {PRIMARY KEY must be unique}} 1 {1 one 2 two} 3 t1_fa {1 {PRIMARY KEY must be unique}} 0 {1 one 2 two 3 three 4 string} 4 t1_ig {0 {}} 0 {1 one 2 two 3 three 4 string 6 string} 5 t1_re {0 {}} 0 {1 one 2 two 3 string 4 string 6 string} 6 t1_xx {1 {PRIMARY KEY must be unique}} 0 {1 one 2 two 3 three} } { catchsql COMMIT do_execsql_test 4.15.$tn.1 "BEGIN; INSERT INTO $tbl VALUES(3, 'three')" do_catchsql_test 4.15.$tn.2 " INSERT INTO $tbl SELECT ((a%2)*a+3), 'string' FROM $tbl; " $res do_test e_createtable-4.15.$tn.3 { sqlite4_db_transaction_status db } [expr !$ac] do_execsql_test 4.15.$tn.4 "SELECT * FROM $tbl" $data } foreach {tn tbl res trans data} { 1 t2_ab {1 {t2_ab.b may not be NULL}} 1 {1 one 2 two 3 three} 2 t2_ro {1 {t2_ro.b may not be NULL}} 0 {1 one 2 two} 3 t2_fa {1 {t2_fa.b may not be NULL}} 1 {1 one 2 two 3 three 4 xx} 4 t2_ig {0 {}} 1 {1 one 2 two 3 three 4 xx 6 xx} 5 t2_re {1 {t2_re.b may not be NULL}} 1 {1 one 2 two 3 three} 6 t2_xx {1 {t2_xx.b may not be NULL}} 1 {1 one 2 two 3 three} } { catchsql COMMIT do_execsql_test 4.16.$tn.1 "BEGIN; INSERT INTO $tbl VALUES(3, 'three')" do_catchsql_test 4.16.$tn.2 " INSERT INTO $tbl SELECT a+3, CASE a WHEN 2 THEN NULL ELSE 'xx' END FROM $tbl " $res do_test e_createtable-4.16.$tn.3 { sqlite4_db_transaction_status db } $trans do_execsql_test 4.16.$tn.4 "SELECT * FROM $tbl" $data } foreach {tn tbl res trans data} { 1 t3_ab {1 {columns a, b are not unique}} 1 {1 one 2 two 3 three} 2 t3_ro {1 {columns a, b are not unique}} 0 {1 one 2 two} 3 t3_fa {1 {columns a, b are not unique}} 1 {1 one 2 two 3 three 4 three} 4 t3_ig {0 {}} 1 {1 one 2 two 3 three 4 three 6 three} 5 t3_re {0 {}} 1 {1 one 2 two 4 three 3 three 6 three} 6 t3_xx {1 {columns a, b are not unique}} 1 {1 one 2 two 3 three} } { catchsql COMMIT do_execsql_test 4.17.$tn.1 "BEGIN; INSERT INTO $tbl VALUES(3, 'three')" do_catchsql_test 4.17.$tn.2 " INSERT INTO $tbl SELECT ((a%2)*a+3), 'three' FROM $tbl " $res do_test e_createtable-4.17.$tn.3 { sqlite4_db_transaction_status db } $trans do_execsql_test 4.17.$tn.4 "SELECT * FROM $tbl" $data } catchsql COMMIT # EVIDENCE-OF: R-12645-39772 Or, if a constraint definition does not # include a conflict-clause or it is a CHECK constraint, the default # conflict resolution algorithm is ABORT. |
︙ | ︙ | |||
1609 1610 1611 1612 1613 1614 1615 | INSERT INTO t4 VALUES(1, 2); INSERT INTO t4 VALUES(3, 4); } do_execsql_test 4.18.2 { BEGIN; INSERT INTO t4 VALUES(5, 6) } do_catchsql_test 4.18.3 { INSERT INTO t4 SELECT a+4, b+4 FROM t4 } {1 {constraint failed}} | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | < < < < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 | INSERT INTO t4 VALUES(1, 2); INSERT INTO t4 VALUES(3, 4); } do_execsql_test 4.18.2 { BEGIN; INSERT INTO t4 VALUES(5, 6) } do_catchsql_test 4.18.3 { INSERT INTO t4 SELECT a+4, b+4 FROM t4 } {1 {constraint failed}} do_test e_createtable-4.18.4 { sqlite4_db_transaction_status db } 1 do_execsql_test 4.18.5 { SELECT * FROM t4 } {1 2 3 4 5 6} # EVIDENCE-OF: R-19114-56113 Different constraints within the same table # may have different default conflict resolution algorithms. # do_execsql_test 4.19.0 { CREATE TABLE t5(a NOT NULL ON CONFLICT IGNORE, b NOT NULL ON CONFLICT ABORT); } do_catchsql_test 4.19.1 { INSERT INTO t5 VALUES(NULL, 'not null') } {0 {}} do_execsql_test 4.19.2 { SELECT * FROM t5 } {} do_catchsql_test 4.19.3 { INSERT INTO t5 VALUES('not null', NULL) } \ {1 {t5.b may not be NULL}} do_execsql_test 4.19.4 { SELECT * FROM t5 } {} # EVIDENCE-OF: R-41444-49665 Other integer type names like "INT" or # "BIGINT" or "SHORT INTEGER" or "UNSIGNED INTEGER" causes the primary # key column to behave as an ordinary table column with integer affinity # and a unique index, not as an alias for the rowid. # do_execsql_test 5.4.1 { CREATE TABLE t6(pk INT primary key); CREATE TABLE t7(pk BIGINT primary key); CREATE TABLE t8(pk SHORT INTEGER primary key); CREATE TABLE t9(pk UNSIGNED INTEGER primary key); } do_execsql_test 5.4.3 { INSERT INTO t6 VALUES('2.0'); INSERT INTO t7 VALUES('2.0'); INSERT INTO t8 VALUES('2.0'); INSERT INTO t9 VALUES('2.0'); SELECT typeof(pk), pk FROM t6; SELECT typeof(pk), pk FROM t7; SELECT typeof(pk), pk FROM t8; SELECT typeof(pk), pk FROM t9; } {integer 2 integer 2 integer 2 integer 2} do_catchsql_test 5.4.4.1 { INSERT INTO t6 VALUES(2) } {1 {PRIMARY KEY must be unique}} do_catchsql_test 5.4.4.2 { INSERT INTO t7 VALUES(2) } {1 {PRIMARY KEY must be unique}} do_catchsql_test 5.4.4.3 { INSERT INTO t8 VALUES(2) } {1 {PRIMARY KEY must be unique}} do_catchsql_test 5.4.4.4 { INSERT INTO t9 VALUES(2) } {1 {PRIMARY KEY must be unique}} finish_test |
Changes to test/e_delete.test.
︙ | ︙ | |||
202 203 204 205 206 207 208 | # top-level statement (by searching first the TEMP database, then the # main database, then any other databases in the order they were # attached). # do_execsql_test e_delete-2.3.0 { DROP TRIGGER aux.tr1; DROP TRIGGER main.tr1; | | | | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | # top-level statement (by searching first the TEMP database, then the # main database, then any other databases in the order they were # attached). # do_execsql_test e_delete-2.3.0 { DROP TRIGGER aux.tr1; DROP TRIGGER main.tr1; DELETE FROM main.t8 WHERE rowid>1; DELETE FROM aux.t8 WHERE rowid>1; INSERT INTO aux.t9 VALUES(1, 2); INSERT INTO main.t7 VALUES(3, 4); } {} do_execsql_test e_delete-2.3.1 { SELECT count(*) FROM temp.t7 UNION ALL SELECT count(*) FROM main.t7 UNION ALL SELECT count(*) FROM aux.t7 UNION ALL SELECT count(*) FROM aux2.t7; |
︙ | ︙ |
Changes to test/e_expr.test.
︙ | ︙ | |||
40 41 42 43 44 45 46 | # ::oplist A list of all SQL operators supported by SQLite. # foreach {op opn} { || cat * mul / div % mod + add - sub << lshift >> rshift & bitand | bitor < less <= lesseq > more >= moreeq = eq1 == eq2 <> ne1 != ne2 IS is LIKE like | | | | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # ::oplist A list of all SQL operators supported by SQLite. # foreach {op opn} { || cat * mul / div % mod + add - sub << lshift >> rshift & bitand | bitor < less <= lesseq > more >= moreeq = eq1 == eq2 <> ne1 != ne2 IS is LIKE like GLOB glob AND and OR or REGEXP regexp {IS NOT} isnt } { set ::opname($op) $opn } set oplist [list] foreach {prec opl} { 1 || 2 {* / %} 3 {+ -} 4 {<< >> & |} 5 {< <= > >=} 6 {= == != <> IS {IS NOT} LIKE GLOB REGEXP} 7 AND 8 OR } { foreach op $opl { set ::opprec($op) $prec lappend oplist $op } |
︙ | ︙ | |||
194 195 196 197 198 199 200 | # the operand. # foreach {tn literal type} { 1 'helloworld' text 2 45 integer 3 45.2 real 4 45.0 real | | | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | # the operand. # foreach {tn literal type} { 1 'helloworld' text 2 45 integer 3 45.2 real 4 45.0 real 5 x'abcdef' blob 6 NULL null } { set sql " SELECT quote( + $literal ), typeof( + $literal) " do_execsql_test e_expr-3.$tn $sql [list $literal $type] } #------------------------------------------------------------------------- |
︙ | ︙ | |||
733 734 735 736 737 738 739 | 54 "EXPR1 LIKE EXPR2" 55 "EXPR1 LIKE EXPR2 ESCAPE EXPR" 56 "EXPR1 GLOB EXPR2" 57 "EXPR1 GLOB EXPR2 ESCAPE EXPR" 58 "EXPR1 REGEXP EXPR2" 59 "EXPR1 REGEXP EXPR2 ESCAPE EXPR" | < < | 733 734 735 736 737 738 739 740 741 742 743 744 745 746 | 54 "EXPR1 LIKE EXPR2" 55 "EXPR1 LIKE EXPR2 ESCAPE EXPR" 56 "EXPR1 GLOB EXPR2" 57 "EXPR1 GLOB EXPR2 ESCAPE EXPR" 58 "EXPR1 REGEXP EXPR2" 59 "EXPR1 REGEXP EXPR2 ESCAPE EXPR" 62 "EXPR1 NOT LIKE EXPR2" 63 "EXPR1 NOT LIKE EXPR2 ESCAPE EXPR" 64 "EXPR1 NOT GLOB EXPR2" 65 "EXPR1 NOT GLOB EXPR2 ESCAPE EXPR" 66 "EXPR1 NOT REGEXP EXPR2" 67 "EXPR1 NOT REGEXP EXPR2 ESCAPE EXPR" 68 "EXPR1 NOT MATCH EXPR2" |
︙ | ︙ | |||
1090 1091 1092 1093 1094 1095 1096 | do_execsql_test e_expr-18.2.1 { SELECT 'abc' REGEXP 'def' } 1 do_test e_expr-18.2.2 { set regexpargs } {def abc} set ::regexpargs [list] do_execsql_test e_expr-18.2.3 { SELECT 'X' NOT REGEXP 'Y' } 0 do_test e_expr-18.2.4 { set regexpargs } {Y X} sqlite4 db test.db | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | do_execsql_test e_expr-18.2.1 { SELECT 'abc' REGEXP 'def' } 1 do_test e_expr-18.2.2 { set regexpargs } {def abc} set ::regexpargs [list] do_execsql_test e_expr-18.2.3 { SELECT 'X' NOT REGEXP 'Y' } 0 do_test e_expr-18.2.4 { set regexpargs } {Y X} sqlite4 db test.db #------------------------------------------------------------------------- # Test cases for the testable statements related to the CASE expression. # # EVIDENCE-OF: R-15199-61389 There are two basic forms of the CASE # expression: those with a base expression and those without. # do_execsql_test e_expr-20.1 { |
︙ | ︙ | |||
1309 1310 1311 1312 1313 1314 1315 | SELECT CASE 'AbC' WHEN 'abc' THEN 'A' WHEN a THEN 'B' END FROM t1 } {B} do_execsql_test e_expr-23.1.4 { SELECT CASE a WHEN b THEN 'A' ELSE 'B' END FROM t1 } {B} do_execsql_test e_expr-23.1.5 { SELECT CASE b WHEN a THEN 'A' ELSE 'B' END FROM t1 | | | 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 | SELECT CASE 'AbC' WHEN 'abc' THEN 'A' WHEN a THEN 'B' END FROM t1 } {B} do_execsql_test e_expr-23.1.4 { SELECT CASE a WHEN b THEN 'A' ELSE 'B' END FROM t1 } {B} do_execsql_test e_expr-23.1.5 { SELECT CASE b WHEN a THEN 'A' ELSE 'B' END FROM t1 } {B} do_execsql_test e_expr-23.1.6 { SELECT CASE 55 WHEN '55' THEN 'A' ELSE 'B' END } {B} do_execsql_test e_expr-23.1.7 { SELECT CASE c WHEN '55' THEN 'A' ELSE 'B' END FROM t1 } {A} do_execsql_test e_expr-23.1.8 { |
︙ | ︙ | |||
1435 1436 1437 1438 1439 1440 1441 | do_expr_test e_expr-27.3.2 { CAST('def' AS shobblob_x) } blob def do_expr_test e_expr-27.3.3 { CAST('ghi' AS abbLOb10) } blob ghi # EVIDENCE-OF: R-22956-37754 Casting to a BLOB consists of first casting # the value to TEXT in the encoding of the database connection, then # interpreting the resulting byte sequence as a BLOB instead of as TEXT. # | | | | | | | | | | | 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 | do_expr_test e_expr-27.3.2 { CAST('def' AS shobblob_x) } blob def do_expr_test e_expr-27.3.3 { CAST('ghi' AS abbLOb10) } blob ghi # EVIDENCE-OF: R-22956-37754 Casting to a BLOB consists of first casting # the value to TEXT in the encoding of the database connection, then # interpreting the resulting byte sequence as a BLOB instead of as TEXT. # do_qexpr_test e_expr-27.4.1 { CAST('ghi' AS blob) } x'676869' do_qexpr_test e_expr-27.4.2 { CAST(456 AS blob) } x'343536' do_qexpr_test e_expr-27.4.3 { CAST(1.78 AS blob) } x'312e3738' rename db db2 sqlite4 db :memory: ifcapable {utf16} { db eval { PRAGMA encoding = 'utf-16le' } do_qexpr_test e_expr-27.4.4 { CAST('ghi' AS blob) } x'670068006900' do_qexpr_test e_expr-27.4.5 { CAST(456 AS blob) } x'340035003600' do_qexpr_test e_expr-27.4.6 { CAST(1.78 AS blob) } x'31002e0037003800' } db close sqlite4 db :memory: db eval { PRAGMA encoding = 'utf-16be' } ifcapable {utf16} { do_qexpr_test e_expr-27.4.7 { CAST('ghi' AS blob) } x'006700680069' do_qexpr_test e_expr-27.4.8 { CAST(456 AS blob) } x'003400350036' do_qexpr_test e_expr-27.4.9 { CAST(1.78 AS blob) } x'0031002e00370038' } db close rename db2 db # EVIDENCE-OF: R-04207-37981 To cast a BLOB value to TEXT, the sequence # of bytes that make up the BLOB is interpreted as text encoded using # the database encoding. |
︙ | ︙ | |||
1482 1483 1484 1485 1486 1487 1488 | # resulting TEXT uses the encoding of the database connection. # do_expr_test e_expr-28.2.1 { CAST (1 AS text) } text 1 do_expr_test e_expr-28.2.2 { CAST (45 AS text) } text 45 do_expr_test e_expr-28.2.3 { CAST (-45 AS text) } text -45 do_expr_test e_expr-28.2.4 { CAST (8.8 AS text) } text 8.8 do_expr_test e_expr-28.2.5 { CAST (2.3e+5 AS text) } text 230000.0 | | | | 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 | # resulting TEXT uses the encoding of the database connection. # do_expr_test e_expr-28.2.1 { CAST (1 AS text) } text 1 do_expr_test e_expr-28.2.2 { CAST (45 AS text) } text 45 do_expr_test e_expr-28.2.3 { CAST (-45 AS text) } text -45 do_expr_test e_expr-28.2.4 { CAST (8.8 AS text) } text 8.8 do_expr_test e_expr-28.2.5 { CAST (2.3e+5 AS text) } text 230000.0 do_expr_test e_expr-28.2.6 { CAST (-2.3e-5 AS text) } text -0.000023 do_expr_test e_expr-28.2.7 { CAST (0.0 AS text) } text 0.0 do_expr_test e_expr-28.2.8 { CAST (0 AS text) } text 0 # EVIDENCE-OF: R-26346-36443 When casting a BLOB value to a REAL, the # value is first converted to TEXT. # do_expr_test e_expr-29.1.1 { CAST (X'312E3233' AS REAL) } real 1.23 do_expr_test e_expr-29.1.2 { CAST (X'3233302E30' AS REAL) } real 230.0 do_expr_test e_expr-29.1.3 { CAST (X'2D392E3837' AS REAL) } real -9.87 |
︙ | ︙ | |||
1598 1599 1600 1601 1602 1603 1604 | do_expr_test e_expr-31.1.3 { CAST(-1.99999 AS INTEGER) } integer -1 do_expr_test e_expr-31.1.4 { CAST(-0.99999 AS INTEGER) } integer 0 # EVIDENCE-OF: R-49503-28105 If a REAL is too large to be represented as # an INTEGER then the result of the cast is the largest negative # integer: -9223372036854775808. # | | | | 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 | do_expr_test e_expr-31.1.3 { CAST(-1.99999 AS INTEGER) } integer -1 do_expr_test e_expr-31.1.4 { CAST(-0.99999 AS INTEGER) } integer 0 # EVIDENCE-OF: R-49503-28105 If a REAL is too large to be represented as # an INTEGER then the result of the cast is the largest negative # integer: -9223372036854775808. # do_expr_test e_expr-31.2.1 { CAST(2e+50 AS INT) } integer 9223372036854775807 do_expr_test e_expr-31.2.2 { CAST(-2e+50 AS INT) } integer -9223372036854775808 do_expr_test e_expr-31.2.3 { CAST(-9223372036854775809.0 AS INT) } integer -9223372036854775808 do_expr_test e_expr-31.2.4 { CAST(9223372036854775809.0 AS INT) } integer 9223372036854775807 # EVIDENCE-OF: R-09295-61337 Casting a TEXT or BLOB value into NUMERIC # first does a forced conversion into REAL but then further converts the # result into INTEGER if and only if the conversion from REAL to INTEGER # is lossless and reversible. # |
︙ | ︙ |
Changes to test/permutations.test.
︙ | ︙ | |||
169 170 171 172 173 174 175 | date.test default.test delete.test delete2.test delete3.test descidx1.test descidx2.test descidx3.test distinct.test distinctagg.test enc.test enc4.test exists.test | | > | < | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | date.test default.test delete.test delete2.test delete3.test descidx1.test descidx2.test descidx3.test distinct.test distinctagg.test enc.test enc4.test exists.test e_createtable.test e_delete.test e_droptrigger.test e_dropview.test e_expr.test e_resolve.test e_select2.test fkey1.test fkey2.test fkey3.test fkey4.test func.test func2.test func3.test fuzz2.test in.test in4.test index2.test index3.test index4.test insert.test insert2.test insert3.test insert5.test join.test join2.test join3.test join4.test join5.test join6.test |
︙ | ︙ |
Changes to test/simple.test.
︙ | ︙ | |||
1558 1559 1560 1561 1562 1563 1564 | do_execsql_test 80.2 { SELECT idx, count(*), sum(length(sample)) FROM t1 GROUP BY idx } {t1 2 4 t1i1 2 4 t1i2 2 4 t1i3 2 4} #------------------------------------------------------------------------- reset_db | | | | > > > > > > > > > > > > > > > | 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 | do_execsql_test 80.2 { SELECT idx, count(*), sum(length(sample)) FROM t1 GROUP BY idx } {t1 2 4 t1i1 2 4 t1i2 2 4 t1i3 2 4} #------------------------------------------------------------------------- reset_db do_test 81.1 { execsql { CREATE TABLE t1(a TEXT); INSERT INTO t1 VALUES(5.4e-08); SELECT a FROM t1; } } {5.4e-8} #------------------------------------------------------------------------- reset_db do_test 82.1 { execsql { CREATE TABLE t1(a TEXT) } execsql { SELECT * FROM sqlite_master } } {table t1 t1 2 {CREATE TABLE t1(a TEXT)}} do_test 82.2 { execsql { DROP TABLE t1 } execsql { CREATE TABLE t1(a TEXT) } execsql { SELECT * FROM sqlite_master } } {table t1 t1 2 {CREATE TABLE t1(a TEXT)}} #------------------------------------------------------------------------- reset_db do_test 83.1 { execsql { SELECT CAST('2.12e-01ABC' AS INT) } } {2} do_test 83.2 { execsql { SELECT CAST(' -2.12e-01ABC' AS INT) } } {-2} do_test 83.3 { execsql { SELECT CAST('45.0' AS NUMERIC) } } {45} do_test 83.4 { execsql { SELECT CAST(0.0 AS TEXT) } } {0.0} finish_test |