| OLD | NEW |
| 1 # 2002 May 24 | 1 # 2002 May 24 |
| 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 14 matching lines...) Expand all Loading... |
| 25 return | 25 return |
| 26 } | 26 } |
| 27 | 27 |
| 28 # The rough organisation of tests in this file is: | 28 # The rough organisation of tests in this file is: |
| 29 # | 29 # |
| 30 # enc2.1.*: Simple tests with a UTF-8 db. | 30 # enc2.1.*: Simple tests with a UTF-8 db. |
| 31 # enc2.2.*: Simple tests with a UTF-16LE db. | 31 # enc2.2.*: Simple tests with a UTF-16LE db. |
| 32 # enc2.3.*: Simple tests with a UTF-16BE db. | 32 # enc2.3.*: Simple tests with a UTF-16BE db. |
| 33 # enc2.4.*: Test that attached databases must have the same text encoding | 33 # enc2.4.*: Test that attached databases must have the same text encoding |
| 34 # as the main database. | 34 # as the main database. |
| 35 # enc2.5.*: Test the behaviour of the library when a collation sequence is | 35 # enc2.5.*: Test the behavior of the library when a collation sequence is |
| 36 # not available for the most desirable text encoding. | 36 # not available for the most desirable text encoding. |
| 37 # enc2.6.*: Similar test for user functions. | 37 # enc2.6.*: Similar test for user functions. |
| 38 # enc2.7.*: Test that the VerifyCookie opcode protects against assuming the | 38 # enc2.7.*: Test that the VerifyCookie opcode protects against assuming the |
| 39 # wrong text encoding for the database. | 39 # wrong text encoding for the database. |
| 40 # enc2.8.*: Test sqlite3_complete16() | 40 # enc2.8.*: Test sqlite3_complete16() |
| 41 # | 41 # |
| 42 | 42 |
| 43 db close | 43 db close |
| 44 | 44 |
| 45 # Return the UTF-8 representation of the supplied UTF-16 string $str. | 45 # Return the UTF-8 representation of the supplied UTF-16 string $str. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 } $enc | 135 } $enc |
| 136 | 136 |
| 137 } | 137 } |
| 138 | 138 |
| 139 # The three unicode encodings understood by SQLite. | 139 # The three unicode encodings understood by SQLite. |
| 140 set encodings [list UTF-8 UTF-16le UTF-16be] | 140 set encodings [list UTF-8 UTF-16le UTF-16be] |
| 141 | 141 |
| 142 set sqlite_os_trace 0 | 142 set sqlite_os_trace 0 |
| 143 set i 1 | 143 set i 1 |
| 144 foreach enc $encodings { | 144 foreach enc $encodings { |
| 145 file delete -force test.db | 145 forcedelete test.db |
| 146 sqlite3 db test.db | 146 sqlite3 db test.db |
| 147 db eval "PRAGMA encoding = \"$enc\"" | 147 db eval "PRAGMA encoding = \"$enc\"" |
| 148 execsql $dbcontents | 148 execsql $dbcontents |
| 149 do_test enc2-$i.0.1 { | 149 do_test enc2-$i.0.1 { |
| 150 db eval {PRAGMA encoding} | 150 db eval {PRAGMA encoding} |
| 151 } $enc | 151 } $enc |
| 152 do_test enc2-$i.0.2 { | 152 do_test enc2-$i.0.2 { |
| 153 db eval {PRAGMA encoding=UTF8} | 153 db eval {PRAGMA encoding=UTF8} |
| 154 db eval {PRAGMA encoding} | 154 db eval {PRAGMA encoding} |
| 155 } $enc | 155 } $enc |
| 156 do_test enc2-$i.0.3 { | 156 do_test enc2-$i.0.3 { |
| 157 db eval {PRAGMA encoding=UTF16le} | 157 db eval {PRAGMA encoding=UTF16le} |
| 158 db eval {PRAGMA encoding} | 158 db eval {PRAGMA encoding} |
| 159 } $enc | 159 } $enc |
| 160 do_test enc2-$i.0.4 { | 160 do_test enc2-$i.0.4 { |
| 161 db eval {PRAGMA encoding=UTF16be} | 161 db eval {PRAGMA encoding=UTF16be} |
| 162 db eval {PRAGMA encoding} | 162 db eval {PRAGMA encoding} |
| 163 } $enc | 163 } $enc |
| 164 | 164 |
| 165 db close | 165 db close |
| 166 run_test_script enc2-$i $enc | 166 run_test_script enc2-$i $enc |
| 167 db close | 167 db close |
| 168 incr i | 168 incr i |
| 169 } | 169 } |
| 170 | 170 |
| 171 # Test that it is an error to try to attach a database with a different | 171 # Test that it is an error to try to attach a database with a different |
| 172 # encoding to the main database. | 172 # encoding to the main database. |
| 173 ifcapable attach { | 173 ifcapable attach { |
| 174 do_test enc2-4.1 { | 174 do_test enc2-4.1 { |
| 175 file delete -force test.db | 175 forcedelete test.db |
| 176 sqlite3 db test.db | 176 sqlite3 db test.db |
| 177 db eval "PRAGMA encoding = 'UTF-8'" | 177 db eval "PRAGMA encoding = 'UTF-8'" |
| 178 db eval "CREATE TABLE abc(a, b, c);" | 178 db eval "CREATE TABLE abc(a, b, c);" |
| 179 } {} | 179 } {} |
| 180 do_test enc2-4.2 { | 180 do_test enc2-4.2 { |
| 181 file delete -force test2.db | 181 forcedelete test2.db |
| 182 sqlite3 db2 test2.db | 182 sqlite3 db2 test2.db |
| 183 db2 eval "PRAGMA encoding = 'UTF-16'" | 183 db2 eval "PRAGMA encoding = 'UTF-16'" |
| 184 db2 eval "CREATE TABLE abc(a, b, c);" | 184 db2 eval "CREATE TABLE abc(a, b, c);" |
| 185 } {} | 185 } {} |
| 186 do_test enc2-4.3 { | 186 do_test enc2-4.3 { |
| 187 catchsql { | 187 catchsql { |
| 188 ATTACH 'test2.db' as aux; | 188 ATTACH 'test2.db' as aux; |
| 189 } | 189 } |
| 190 } {1 {attached databases must use the same text encoding as main database}} | 190 } {1 {attached databases must use the same text encoding as main database}} |
| 191 db2 close | 191 db2 close |
| 192 db close | 192 db close |
| 193 } | 193 } |
| 194 | 194 |
| 195 # The following tests - enc2-5.* - test that SQLite selects the correct | 195 # The following tests - enc2-5.* - test that SQLite selects the correct |
| 196 # collation sequence when more than one is available. | 196 # collation sequence when more than one is available. |
| 197 | 197 |
| 198 set ::values [list one two three four five] | 198 set ::values [list one two three four five] |
| 199 set ::test_collate_enc INVALID | 199 set ::test_collate_enc INVALID |
| 200 proc test_collate {enc lhs rhs} { | 200 proc test_collate {enc lhs rhs} { |
| 201 set ::test_collate_enc $enc | 201 set ::test_collate_enc $enc |
| 202 set l [lsearch -exact $::values $lhs] | 202 set l [lsearch -exact $::values $lhs] |
| 203 set r [lsearch -exact $::values $rhs] | 203 set r [lsearch -exact $::values $rhs] |
| 204 set res [expr $l - $r] | 204 set res [expr $l - $r] |
| 205 # puts "enc=$enc lhs=$lhs/$l rhs=$rhs/$r res=$res" | 205 # puts "enc=$enc lhs=$lhs/$l rhs=$rhs/$r res=$res" |
| 206 return $res | 206 return $res |
| 207 } | 207 } |
| 208 | 208 |
| 209 file delete -force test.db | 209 forcedelete test.db |
| 210 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] | 210 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] |
| 211 do_test enc2-5.0 { | 211 do_test enc2-5.0 { |
| 212 execsql { | 212 execsql { |
| 213 CREATE TABLE t5(a); | 213 CREATE TABLE t5(a); |
| 214 INSERT INTO t5 VALUES('one'); | 214 INSERT INTO t5 VALUES('one'); |
| 215 INSERT INTO t5 VALUES('two'); | 215 INSERT INTO t5 VALUES('two'); |
| 216 INSERT INTO t5 VALUES('five'); | 216 INSERT INTO t5 VALUES('five'); |
| 217 INSERT INTO t5 VALUES('three'); | 217 INSERT INTO t5 VALUES('three'); |
| 218 INSERT INTO t5 VALUES('four'); | 218 INSERT INTO t5 VALUES('four'); |
| 219 } | 219 } |
| 220 } {} | 220 } {} |
| 221 do_test enc2-5.1 { | 221 do_test enc2-5.1 { |
| 222 add_test_collate $DB 1 1 1 | 222 add_test_collate $DB 1 1 1 |
| 223 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate;}] | 223 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate;}] |
| 224 lappend res $::test_collate_enc | 224 lappend res $::test_collate_enc |
| 225 } {one two three four five UTF-8} | 225 } {one two three four five UTF-8} |
| 226 do_test enc2-5.2 { | 226 do_test enc2-5.2 { |
| 227 add_test_collate $DB 0 1 0 | 227 add_test_collate $DB 0 1 0 |
| 228 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}] | 228 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}] |
| 229 lappend res $::test_collate_enc | 229 lappend res $::test_collate_enc |
| 230 } {one two three four five UTF-16LE} | 230 } {one two three four five UTF-16LE} |
| 231 do_test enc2-5.3 { | 231 do_test enc2-5.3 { |
| 232 add_test_collate $DB 0 0 1 | 232 add_test_collate $DB 0 0 1 |
| 233 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}] | 233 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}] |
| 234 lappend res $::test_collate_enc | 234 lappend res $::test_collate_enc |
| 235 } {one two three four five UTF-16BE} | 235 } {one two three four five UTF-16BE} |
| 236 | 236 |
| 237 db close | 237 db close |
| 238 file delete -force test.db | 238 forcedelete test.db |
| 239 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] | 239 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] |
| 240 execsql {pragma encoding = 'UTF-16LE'} | 240 execsql {pragma encoding = 'UTF-16LE'} |
| 241 do_test enc2-5.4 { | 241 do_test enc2-5.4 { |
| 242 execsql { | 242 execsql { |
| 243 CREATE TABLE t5(a); | 243 CREATE TABLE t5(a); |
| 244 INSERT INTO t5 VALUES('one'); | 244 INSERT INTO t5 VALUES('one'); |
| 245 INSERT INTO t5 VALUES('two'); | 245 INSERT INTO t5 VALUES('two'); |
| 246 INSERT INTO t5 VALUES('five'); | 246 INSERT INTO t5 VALUES('five'); |
| 247 INSERT INTO t5 VALUES('three'); | 247 INSERT INTO t5 VALUES('three'); |
| 248 INSERT INTO t5 VALUES('four'); | 248 INSERT INTO t5 VALUES('four'); |
| 249 } | 249 } |
| 250 } {} | 250 } {} |
| 251 do_test enc2-5.5 { | 251 do_test enc2-5.5 { |
| 252 add_test_collate $DB 1 1 1 | 252 add_test_collate $DB 1 1 1 |
| 253 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}] | 253 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}] |
| 254 lappend res $::test_collate_enc | 254 lappend res $::test_collate_enc |
| 255 } {one two three four five UTF-16LE} | 255 } {one two three four five UTF-16LE} |
| 256 do_test enc2-5.6 { | 256 do_test enc2-5.6 { |
| 257 add_test_collate $DB 1 0 1 | 257 add_test_collate $DB 1 0 1 |
| 258 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}] | 258 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}] |
| 259 lappend res $::test_collate_enc | 259 lappend res $::test_collate_enc |
| 260 } {one two three four five UTF-16BE} | 260 } {one two three four five UTF-16BE} |
| 261 do_test enc2-5.7 { | 261 do_test enc2-5.7 { |
| 262 add_test_collate $DB 1 0 0 | 262 add_test_collate $DB 1 0 0 |
| 263 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}] | 263 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}] |
| 264 lappend res $::test_collate_enc | 264 lappend res $::test_collate_enc |
| 265 } {one two three four five UTF-8} | 265 } {one two three four five UTF-8} |
| 266 | 266 |
| 267 db close | 267 db close |
| 268 file delete -force test.db | 268 forcedelete test.db |
| 269 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] | 269 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] |
| 270 execsql {pragma encoding = 'UTF-16BE'} | 270 execsql {pragma encoding = 'UTF-16BE'} |
| 271 do_test enc2-5.8 { | 271 do_test enc2-5.8 { |
| 272 execsql { | 272 execsql { |
| 273 CREATE TABLE t5(a); | 273 CREATE TABLE t5(a); |
| 274 INSERT INTO t5 VALUES('one'); | 274 INSERT INTO t5 VALUES('one'); |
| 275 INSERT INTO t5 VALUES('two'); | 275 INSERT INTO t5 VALUES('two'); |
| 276 INSERT INTO t5 VALUES('five'); | 276 INSERT INTO t5 VALUES('five'); |
| 277 INSERT INTO t5 VALUES('three'); | 277 INSERT INTO t5 VALUES('three'); |
| 278 INSERT INTO t5 VALUES('four'); | 278 INSERT INTO t5 VALUES('four'); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 304 do_test enc2-5.13 { | 304 do_test enc2-5.13 { |
| 305 add_test_collate_needed $DB | 305 add_test_collate_needed $DB |
| 306 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate; }] | 306 set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate; }] |
| 307 lappend res $::test_collate_enc | 307 lappend res $::test_collate_enc |
| 308 } {one two three four five UTF-16BE} | 308 } {one two three four five UTF-16BE} |
| 309 do_test enc2-5.14 { | 309 do_test enc2-5.14 { |
| 310 set ::sqlite_last_needed_collation | 310 set ::sqlite_last_needed_collation |
| 311 } test_collate | 311 } test_collate |
| 312 | 312 |
| 313 db close | 313 db close |
| 314 file delete -force test.db | 314 forcedelete test.db |
| 315 | 315 |
| 316 do_test enc2-5.15 { | 316 do_test enc2-5.15 { |
| 317 sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db] | 317 sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db] |
| 318 add_test_collate_needed $::DB | 318 add_test_collate_needed $::DB |
| 319 set ::sqlite_last_needed_collation | 319 set ::sqlite_last_needed_collation |
| 320 } {} | 320 } {} |
| 321 do_test enc2-5.16 { | 321 do_test enc2-5.16 { |
| 322 execsql {CREATE TABLE t1(a varchar collate test_collate);} | 322 execsql {CREATE TABLE t1(a varchar collate test_collate);} |
| 323 } {} | 323 } {} |
| 324 do_test enc2-5.17 { | 324 do_test enc2-5.17 { |
| 325 set ::sqlite_last_needed_collation | 325 set ::sqlite_last_needed_collation |
| 326 } {test_collate} | 326 } {test_collate} |
| 327 | 327 |
| 328 # The following tests - enc2-6.* - test that SQLite selects the correct | 328 # The following tests - enc2-6.* - test that SQLite selects the correct |
| 329 # user function when more than one is available. | 329 # user function when more than one is available. |
| 330 | 330 |
| 331 proc test_function {enc arg} { | 331 proc test_function {enc arg} { |
| 332 return "$enc $arg" | 332 return "$enc $arg" |
| 333 } | 333 } |
| 334 | 334 |
| 335 db close | 335 db close |
| 336 file delete -force test.db | 336 forcedelete test.db |
| 337 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] | 337 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] |
| 338 execsql {pragma encoding = 'UTF-8'} | 338 execsql {pragma encoding = 'UTF-8'} |
| 339 do_test enc2-6.0 { | 339 do_test enc2-6.0 { |
| 340 execsql { | 340 execsql { |
| 341 CREATE TABLE t5(a); | 341 CREATE TABLE t5(a); |
| 342 INSERT INTO t5 VALUES('one'); | 342 INSERT INTO t5 VALUES('one'); |
| 343 } | 343 } |
| 344 } {} | 344 } {} |
| 345 do_test enc2-6.1 { | 345 do_test enc2-6.1 { |
| 346 add_test_function $DB 1 1 1 | 346 add_test_function $DB 1 1 1 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 359 db close | 359 db close |
| 360 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] | 360 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] |
| 361 do_test enc2-6.3 { | 361 do_test enc2-6.3 { |
| 362 add_test_function $DB 0 0 1 | 362 add_test_function $DB 0 0 1 |
| 363 execsql { | 363 execsql { |
| 364 SELECT test_function('sqlite') | 364 SELECT test_function('sqlite') |
| 365 } | 365 } |
| 366 } {{UTF-16BE sqlite}} | 366 } {{UTF-16BE sqlite}} |
| 367 | 367 |
| 368 db close | 368 db close |
| 369 file delete -force test.db | 369 forcedelete test.db |
| 370 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] | 370 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] |
| 371 execsql {pragma encoding = 'UTF-16LE'} | 371 execsql {pragma encoding = 'UTF-16LE'} |
| 372 do_test enc2-6.3 { | 372 do_test enc2-6.3 { |
| 373 execsql { | 373 execsql { |
| 374 CREATE TABLE t5(a); | 374 CREATE TABLE t5(a); |
| 375 INSERT INTO t5 VALUES('sqlite'); | 375 INSERT INTO t5 VALUES('sqlite'); |
| 376 } | 376 } |
| 377 } {} | 377 } {} |
| 378 do_test enc2-6.4 { | 378 do_test enc2-6.4 { |
| 379 add_test_function $DB 1 1 1 | 379 add_test_function $DB 1 1 1 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 392 db close | 392 db close |
| 393 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] | 393 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] |
| 394 do_test enc2-6.6 { | 394 do_test enc2-6.6 { |
| 395 add_test_function $DB 0 0 1 | 395 add_test_function $DB 0 0 1 |
| 396 execsql { | 396 execsql { |
| 397 SELECT test_function('sqlite') | 397 SELECT test_function('sqlite') |
| 398 } | 398 } |
| 399 } {{UTF-16BE sqlite}} | 399 } {{UTF-16BE sqlite}} |
| 400 | 400 |
| 401 db close | 401 db close |
| 402 file delete -force test.db | 402 forcedelete test.db |
| 403 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] | 403 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] |
| 404 execsql {pragma encoding = 'UTF-16BE'} | 404 execsql {pragma encoding = 'UTF-16BE'} |
| 405 do_test enc2-6.7 { | 405 do_test enc2-6.7 { |
| 406 execsql { | 406 execsql { |
| 407 CREATE TABLE t5(a); | 407 CREATE TABLE t5(a); |
| 408 INSERT INTO t5 VALUES('sqlite'); | 408 INSERT INTO t5 VALUES('sqlite'); |
| 409 } | 409 } |
| 410 } {} | 410 } {} |
| 411 do_test enc2-6.8 { | 411 do_test enc2-6.8 { |
| 412 add_test_function $DB 1 1 1 | 412 add_test_function $DB 1 1 1 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 426 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] | 426 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] |
| 427 do_test enc2-6.10 { | 427 do_test enc2-6.10 { |
| 428 add_test_function $DB 0 0 1 | 428 add_test_function $DB 0 0 1 |
| 429 execsql { | 429 execsql { |
| 430 SELECT test_function('sqlite') | 430 SELECT test_function('sqlite') |
| 431 } | 431 } |
| 432 } {{UTF-16BE sqlite}} | 432 } {{UTF-16BE sqlite}} |
| 433 | 433 |
| 434 | 434 |
| 435 db close | 435 db close |
| 436 file delete -force test.db | 436 forcedelete test.db |
| 437 | 437 |
| 438 # The following tests - enc2-7.* - function as follows: | 438 # The following tests - enc2-7.* - function as follows: |
| 439 # | 439 # |
| 440 # 1: Open an empty database file assuming UTF-16 encoding. | 440 # 1: Open an empty database file assuming UTF-16 encoding. |
| 441 # 2: Open the same database with a different handle assuming UTF-8. Create | 441 # 2: Open the same database with a different handle assuming UTF-8. Create |
| 442 # a table using this handle. | 442 # a table using this handle. |
| 443 # 3: Read the sqlite_master table from the first handle. | 443 # 3: Read the sqlite_master table from the first handle. |
| 444 # 4: Ensure the first handle recognises the database encoding is UTF-8. | 444 # 4: Ensure the first handle recognises the database encoding is UTF-8. |
| 445 # | 445 # |
| 446 do_test enc2-7.1 { | 446 do_test enc2-7.1 { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 do_test enc2-8.1 { | 486 do_test enc2-8.1 { |
| 487 sqlite3_complete16 [utf16 "SELECT * FROM t1;"] | 487 sqlite3_complete16 [utf16 "SELECT * FROM t1;"] |
| 488 } {1} | 488 } {1} |
| 489 do_test enc2-8.2 { | 489 do_test enc2-8.2 { |
| 490 sqlite3_complete16 [utf16 "SELECT * FROM"] | 490 sqlite3_complete16 [utf16 "SELECT * FROM"] |
| 491 } {0} | 491 } {0} |
| 492 } | 492 } |
| 493 | 493 |
| 494 # Test that the encoding of an empty database may still be set after the | 494 # Test that the encoding of an empty database may still be set after the |
| 495 # (empty) schema has been initialized. | 495 # (empty) schema has been initialized. |
| 496 file delete -force test.db | 496 forcedelete test.db |
| 497 do_test enc2-9.1 { | 497 do_test enc2-9.1 { |
| 498 sqlite3 db test.db | 498 sqlite3 db test.db |
| 499 execsql { | 499 execsql { |
| 500 PRAGMA encoding = 'UTF-8'; | 500 PRAGMA encoding = 'UTF-8'; |
| 501 PRAGMA encoding; | 501 PRAGMA encoding; |
| 502 } | 502 } |
| 503 } {UTF-8} | 503 } {UTF-8} |
| 504 do_test enc2-9.2 { | 504 do_test enc2-9.2 { |
| 505 sqlite3 db test.db | 505 sqlite3 db test.db |
| 506 execsql { | 506 execsql { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 530 PRAGMA encoding = 'UTF-8'; | 530 PRAGMA encoding = 'UTF-8'; |
| 531 PRAGMA encoding; | 531 PRAGMA encoding; |
| 532 } | 532 } |
| 533 } {UTF-16le} | 533 } {UTF-16le} |
| 534 | 534 |
| 535 # Ticket #1987. | 535 # Ticket #1987. |
| 536 # Disallow encoding changes once the encoding has been set. | 536 # Disallow encoding changes once the encoding has been set. |
| 537 # | 537 # |
| 538 do_test enc2-10.1 { | 538 do_test enc2-10.1 { |
| 539 db close | 539 db close |
| 540 file delete -force test.db test.db-journal | 540 forcedelete test.db test.db-journal |
| 541 sqlite3 db test.db | 541 sqlite3 db test.db |
| 542 db eval { | 542 db eval { |
| 543 PRAGMA encoding=UTF16; | 543 PRAGMA encoding=UTF16; |
| 544 CREATE TABLE t1(a); | 544 CREATE TABLE t1(a); |
| 545 PRAGMA encoding=UTF8; | 545 PRAGMA encoding=UTF8; |
| 546 CREATE TABLE t2(b); | 546 CREATE TABLE t2(b); |
| 547 } | 547 } |
| 548 db close | 548 db close |
| 549 sqlite3 db test.db | 549 sqlite3 db test.db |
| 550 db eval { | 550 db eval { |
| 551 SELECT name FROM sqlite_master | 551 SELECT name FROM sqlite_master |
| 552 } | 552 } |
| 553 } {t1 t2} | 553 } {t1 t2} |
| 554 | 554 |
| 555 finish_test | 555 finish_test |
| OLD | NEW |