blob: 52feb7b50ffcbf9b44a831a6161c66333bddf979 [file] [log] [blame]
dan5c35e902016-10-26 12:15:41 +00001# 2016 October 26
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
6# May you do good and not evil.
7# May you find forgiveness for yourself and forgive others.
8# May you share freely, never taking more than you give.
9#
10#***********************************************************************
11#
12# Tests for SQLITE_ENABLE_URI_00_ERROR builds.
13
14set testdir [file dirname $argv0]
15source $testdir/tester.tcl
16
17ifcapable !uri_00_error {
18 finish_test
19 return
20}
21
22set testprefix uri2
23db close
24sqlite3_shutdown
25sqlite3_config_uri 1
26
27foreach {tn uri} {
28 1 file:test.db%00trailing
29 2 file:test.db?%00trailing=1
30 3 file:test.db?trailing=1%00
31 4 file:test.db?trailing=1&abc%00def
32 5 file:test.db?trailing=1&abc%00def
33} {
34 do_test 1.$tn.1 {
35 set rc [catch { sqlite3 db $uri } msg]
36 list $rc $msg
37 } {1 {unexpected %00 in uri}}
38
39 do_test 1.$tn.2 {
dan635f83c2016-10-26 13:44:07 +000040 set DB2 [sqlite3_open $uri]
41 sqlite3_errcode $DB2
42 } {SQLITE_ERROR}
43
44 catch { sqlite3_close $DB2 }
45
46 do_test 1.$tn.2 {
dan5c35e902016-10-26 12:15:41 +000047 sqlite3 db ""
48 catchsql { ATTACH $uri AS aux }
49 } {1 {unexpected %00 in uri}}
50
dan635f83c2016-10-26 13:44:07 +000051 do_test 1.$tn.3 {
52 sqlite3_errcode db
53 } {SQLITE_ERROR}
54
dan5c35e902016-10-26 12:15:41 +000055 catch { db close }
56}
57
58reset_db
59do_test 2.0 {
60 expr {[lsearch [execsql {PRAGMA compile_options}] ENABLE_URI_00_ERROR] >= 0}
61} 1
62
63finish_test