Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Change the hexadecimal digits generated by the hex() and quote() functions to lower-case. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
3025370e1f3513e1f8b33f83f7bf0e1c |
User & Date: | drh 2013-01-19 02:38:05.741 |
Context
2013-01-19
| ||
16:14 | Inserting NULL into a INTEGER PRIMARY KEY fills that key with the next available integer value. The sqlite4_last_insert_rowid() function now works for those cases. check-in: 697ee9faad user: drh tags: trunk | |
02:38 | Change the hexadecimal digits generated by the hex() and quote() functions to lower-case. check-in: 3025370e1f user: drh tags: trunk | |
02:16 | Fix for queries that use and inequality on ROWID in the WHERE clause. check-in: 32de931aa1 user: drh tags: trunk | |
Changes
Changes to src/func.c.
︙ | ︙ | |||
834 835 836 837 838 839 840 | } #endif /* SQLITE4_OMIT_COMPILEOPTION_DIAGS */ /* Array for converting from half-bytes (nybbles) into ASCII hex ** digits. */ static const char hexdigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', | | | 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 | } #endif /* SQLITE4_OMIT_COMPILEOPTION_DIAGS */ /* Array for converting from half-bytes (nybbles) into ASCII hex ** digits. */ static const char hexdigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; /* ** EXPERIMENTAL - This is not an official function. The interface may ** change. This function may disappear. Do not write code that depends ** on this function. ** |
︙ | ︙ | |||
871 872 873 874 875 876 877 | int i; for(i=0; i<nBlob; i++){ zText[(i*2)+2] = hexdigits[(zBlob[i]>>4)&0x0F]; zText[(i*2)+3] = hexdigits[(zBlob[i])&0x0F]; } zText[(nBlob*2)+2] = '\''; zText[(nBlob*2)+3] = '\0'; | | | 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 | int i; for(i=0; i<nBlob; i++){ zText[(i*2)+2] = hexdigits[(zBlob[i]>>4)&0x0F]; zText[(i*2)+3] = hexdigits[(zBlob[i])&0x0F]; } zText[(nBlob*2)+2] = '\''; zText[(nBlob*2)+3] = '\0'; zText[0] = 'x'; zText[1] = '\''; sqlite4_result_text(context, zText, -1, SQLITE4_TRANSIENT); sqlite4_free(sqlite4_context_env(context), zText); } break; } case SQLITE4_TEXT: { |
︙ | ︙ |
Changes to test/badutf.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file checks to make sure SQLite is able to gracefully # handle malformed UTF-8. # | < | | | | | | | | | | | | | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file checks to make sure SQLite is able to gracefully # handle malformed UTF-8. # set testdir [file dirname $argv0] source $testdir/tester.tcl do_test badutf-1.1 { db eval {PRAGMA encoding=UTF8} sqlite4_exec db {SELECT hex('%80') AS x} } {0 {x 80}} do_test badutf-1.2 { sqlite4_exec db {SELECT hex('%81') AS x} } {0 {x 81}} do_test badutf-1.3 { sqlite4_exec db {SELECT hex('%bf') AS x} } {0 {x bf}} do_test badutf-1.4 { sqlite4_exec db {SELECT hex('%c0') AS x} } {0 {x c0}} do_test badutf-1.5 { sqlite4_exec db {SELECT hex('%e0') AS x} } {0 {x e0}} do_test badutf-1.6 { sqlite4_exec db {SELECT hex('%f0') AS x} } {0 {x f0}} do_test badutf-1.7 { sqlite4_exec db {SELECT hex('%ff') AS x} } {0 {x ff}} sqlite4 db2 {} ifcapable utf16 { do_test badutf-1.10 { db2 eval {PRAGMA encoding=UTF16be} sqlite4_exec db2 {SELECT hex('%80') AS x} } {0 {x 0080}} do_test badutf-1.11 { sqlite4_exec db2 {SELECT hex('%81') AS x} } {0 {x 0081}} do_test badutf-1.12 { sqlite4_exec db2 {SELECT hex('%bf') AS x} } {0 {x 00bf}} do_test badutf-1.13 { sqlite4_exec db2 {SELECT hex('%c0') AS x} } {0 {x fffd}} do_test badutf-1.14 { sqlite4_exec db2 {SELECT hex('%c1') AS x} } {0 {x fffd}} do_test badutf-1.15 { sqlite4_exec db2 {SELECT hex('%c0%bf') AS x} } {0 {x fffd}} do_test badutf-1.16 { sqlite4_exec db2 {SELECT hex('%c1%bf') AS x} } {0 {x fffd}} do_test badutf-1.17 { sqlite4_exec db2 {SELECT hex('%c3%bf') AS x} } {0 {x 00ff}} do_test badutf-1.18 { sqlite4_exec db2 {SELECT hex('%e0') AS x} } {0 {x fffd}} do_test badutf-1.19 { sqlite4_exec db2 {SELECT hex('%f0') AS x} } {0 {x fffd}} do_test badutf-1.20 { sqlite4_exec db2 {SELECT hex('%ff') AS x} } {0 {x fffd}} } ifcapable bloblit { do_test badutf-2.1 { sqlite4_exec db {SELECT '%80'=CAST(x'80' AS text) AS x} } {0 {x 1}} |
︙ | ︙ | |||
115 116 117 118 119 120 121 | } {0 {x 6}} do_test badutf-3.9 { sqlite4_exec db {SELECT length('%80%80%80%80%80%f0%80%80%80%ff') AS x} } {0 {x 7}} do_test badutf-4.1 { sqlite4_exec db {SELECT hex(trim('%80%80%80%f0%80%80%80%ff','%80%ff')) AS x} | | | | | | | | | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | } {0 {x 6}} do_test badutf-3.9 { sqlite4_exec db {SELECT length('%80%80%80%80%80%f0%80%80%80%ff') AS x} } {0 {x 7}} do_test badutf-4.1 { sqlite4_exec db {SELECT hex(trim('%80%80%80%f0%80%80%80%ff','%80%ff')) AS x} } {0 {x f0}} do_test badutf-4.2 { sqlite4_exec db {SELECT hex(ltrim('%80%80%80%f0%80%80%80%ff','%80%ff')) AS x} } {0 {x f0808080ff}} do_test badutf-4.3 { sqlite4_exec db {SELECT hex(rtrim('%80%80%80%f0%80%80%80%ff','%80%ff')) AS x} } {0 {x 808080f0}} do_test badutf-4.4 { sqlite4_exec db {SELECT hex(trim('%80%80%80%f0%80%80%80%ff','%ff%80')) AS x} } {0 {x 808080f0808080ff}} do_test badutf-4.5 { sqlite4_exec db {SELECT hex(trim('%ff%80%80%f0%80%80%80%ff','%ff%80')) AS x} } {0 {x 80f0808080ff}} do_test badutf-4.6 { sqlite4_exec db {SELECT hex(trim('%ff%80%f0%80%80%80%ff','%ff%80')) AS x} } {0 {x f0808080ff}} do_test badutf-4.7 { sqlite4_exec db {SELECT hex(trim('%ff%80%f0%80%80%80%ff','%ff%80%80')) AS x} } {0 {x ff80f0808080ff}} db2 close finish_test |
Changes to test/bind.test.
︙ | ︙ | |||
299 300 301 302 303 304 305 | sqlite4_reset $VM execsql {SELECT * FROM t1} } {hello hello hello} set enc [db eval {PRAGMA encoding}] if {$enc=="UTF-8" || $enc==""} { do_test bind-6.5 { execsql {SELECT hex(a), hex(b), hex(c) FROM t1} | | | | | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | sqlite4_reset $VM execsql {SELECT * FROM t1} } {hello hello hello} set enc [db eval {PRAGMA encoding}] if {$enc=="UTF-8" || $enc==""} { do_test bind-6.5 { execsql {SELECT hex(a), hex(b), hex(c) FROM t1} } {68656c6c6f00746865726500 68656c6c6f007468657265 68656c6c6f} } elseif {$enc=="UTF-16le"} { do_test bind-6.5 { execsql {SELECT hex(a), hex(b), hex(c) FROM t1} } {680065006c006c006f000000740068006500720065000000 680065006c006c006f00000074006800650072006500 680065006c006c006f00} } elseif {$enc=="UTF-16be"} { do_test bind-6.5 { execsql {SELECT hex(a), hex(b), hex(c) FROM t1} } {00680065006c006c006f0000007400680065007200650000 00680065006c006c006f000000740068006500720065 00680065006c006c006f} } else { do_test bind-6.5 { set "Unknown database encoding: $::enc" } {} } do_test bind-6.6 { execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1} |
︙ | ︙ | |||
348 349 350 351 352 353 354 | sqlite_step $VM N VALUES COLNAMES sqlite4_reset $VM execsql {SELECT * FROM t1} } {hi hi hi} if {$enc=="UTF-8"} { do_test bind-7.4 { execsql {SELECT hex(a), hex(b), hex(c) FROM t1} | | | | | 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | sqlite_step $VM N VALUES COLNAMES sqlite4_reset $VM execsql {SELECT * FROM t1} } {hi hi hi} if {$enc=="UTF-8"} { do_test bind-7.4 { execsql {SELECT hex(a), hex(b), hex(c) FROM t1} } {68690079616c6c00 68690079616c6c 6869} } elseif {$enc=="UTF-16le"} { do_test bind-7.4 { execsql {SELECT hex(a), hex(b), hex(c) FROM t1} } {680069000000790061006c006c000000 680069000000790061006c006c00 68006900} } elseif {$enc=="UTF-16be"} { do_test bind-7.4 { execsql {SELECT hex(a), hex(b), hex(c) FROM t1} } {00680069000000790061006c006c0000 00680069000000790061006c006c 00680069} } do_test bind-7.5 { execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1} } {text text text} } do_test bind-7.99 { execsql {DELETE FROM t1;} |
︙ | ︙ | |||
622 623 624 625 626 627 628 | sqlite_bind $VM 1 not-used blob10 sqlite4_step $VM sqlite4_finalize $VM execsql { SELECT typeof(x), length(x), quote(x), length(cast(x AS BLOB)), quote(cast(x AS BLOB)) FROM t3 } | | | | 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 | sqlite_bind $VM 1 not-used blob10 sqlite4_step $VM sqlite4_finalize $VM execsql { SELECT typeof(x), length(x), quote(x), length(cast(x AS BLOB)), quote(cast(x AS BLOB)) FROM t3 } } {text 3 'abc' 10 x'6162630078797a007071'} do_test bind-12.2 { sqlite4_create_function $DB execsql { SELECT quote(cast(x_coalesce(x) AS blob)) FROM t3 } } {x'6162630078797a007071'} } # Test the operation of sqlite4_clear_bindings # do_test bind-13.1 { set VM [sqlite4_prepare $DB {SELECT ?,?,?} -1 TAIL] sqlite4_step $VM |
︙ | ︙ |
Changes to test/substr.test.
︙ | ︙ | |||
124 125 126 127 128 129 130 | subblob-test 3.12 61626364656667 200 100 {} # If these blobs were strings, then they would contain multi-byte # characters. But since they are blobs, the substr indices refer # to bytes. # subblob-test 4.1 61E188B462E28D8563E3919663 1 1 61 | | | | | | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | subblob-test 3.12 61626364656667 200 100 {} # If these blobs were strings, then they would contain multi-byte # characters. But since they are blobs, the substr indices refer # to bytes. # subblob-test 4.1 61E188B462E28D8563E3919663 1 1 61 subblob-test 4.2 61E188B462E28D8563E3919663 2 1 e1 subblob-test 4.3 61E188B462E28D8563E3919663 1 2 61e1 subblob-test 4.4 61E188B462E28D8563E3919663 -2 1 96 subblob-test 4.5 61E188B462E28D8563E3919663 -5 4 63e39196 subblob-test 4.6 61E188B462E28D8563E3919663 -100 98 61e188b462e28d8563e391 # Two-argument SUBSTR # proc substr-2-test {id string idx result} { db eval { DELETE FROM t1; INSERT INTO t1(t) VALUES($string) |
︙ | ︙ |
Changes to test/tkt-3fe897352e.test.
︙ | ︙ | |||
29 30 31 32 33 34 35 | sqlite4 db :memory: db eval { PRAGMA encoding=UTF8; CREATE TABLE t1(x); INSERT INTO t1 VALUES(hex_to_utf16be('D800')); SELECT hex(x) FROM t1; } | | | | | | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | sqlite4 db :memory: db eval { PRAGMA encoding=UTF8; CREATE TABLE t1(x); INSERT INTO t1 VALUES(hex_to_utf16be('D800')); SELECT hex(x) FROM t1; } } {eda080} do_test tkt-3fe89-1.2 { db eval { DELETE FROM t1; INSERT INTO t1 VALUES(hex_to_utf16le('00D8')); SELECT hex(x) FROM t1; } } {eda080} do_test tkt-3fe89-1.3 { db eval { DELETE FROM t1; INSERT INTO t1 VALUES(hex_to_utf16be('DFFF')); SELECT hex(x) FROM t1; } } {edbfbf} do_test tkt-3fe89-1.4 { db eval { DELETE FROM t1; INSERT INTO t1 VALUES(hex_to_utf16le('FFDF')); SELECT hex(x) FROM t1; } } {edbfbf} finish_test |