blob: 9a89b247de8d6bfb4f05884b9d69c8f3e7030443 [file] [log] [blame]
dan9e1ab1a2017-01-05 19:32:48 +00001# 2017 Jan 4
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# This file implements regression tests for SQLite library.
12#
13
14set testdir [file dirname $argv0]
15source $testdir/tester.tcl
16set testprefix pragma4
17
18proc do_pragma_ncol_test {tn sql nCol} {
19 set ::stmt 0
20 set ::stmt [sqlite3_prepare_v2 db $sql -1 dummy]
21 uplevel [list do_test $tn { sqlite3_column_count $::stmt } $nCol]
22 sqlite3_finalize $::stmt
23}
24
25# If there is no RHS argument, the following PRAGMA statements operate as
mistachkin817be732017-01-06 00:02:51 +000026# queries, returning a single row containing a single column.
dan9e1ab1a2017-01-05 19:32:48 +000027#
28# Or, if there is RHS argument, they return zero rows of zero columns.
29#
30foreach {tn sql} {
31 1 "PRAGMA application_id = 10"
32 2 "PRAGMA automatic_index = 1"
33 3 "PRAGMA auto_vacuum = 1"
34 4 "PRAGMA cache_size = -100"
35 5 "PRAGMA cache_spill = 1"
36 6 "PRAGMA cell_size_check = 1"
37 7 "PRAGMA checkpoint_fullfsync = 1"
38 8 "PRAGMA count_changes = 1"
39 9 "PRAGMA default_cache_size = 100"
40 10 "PRAGMA defer_foreign_keys = 1"
41 11 "PRAGMA empty_result_callbacks = 1"
42 12 "PRAGMA encoding = 'utf-8'"
43 13 "PRAGMA foreign_keys = 1"
44 14 "PRAGMA full_column_names = 1"
45 15 "PRAGMA fullfsync = 1"
46 16 "PRAGMA ignore_check_constraints = 1"
47 17 "PRAGMA legacy_file_format = 1"
48 18 "PRAGMA page_size = 511"
49 19 "PRAGMA page_size = 512"
50 20 "PRAGMA query_only = false"
51 21 "PRAGMA read_uncommitted = true"
52 22 "PRAGMA recursive_triggers = false"
53 23 "PRAGMA reverse_unordered_selects = false"
54 24 "PRAGMA schema_version = 211"
55 25 "PRAGMA short_column_names = 1"
56 26 "PRAGMA synchronous = full"
dan9e1ab1a2017-01-05 19:32:48 +000057 29 "PRAGMA temp_store = memory"
58 30 "PRAGMA user_version = 405"
59 31 "PRAGMA writable_schema = 1"
60} {
61 reset_db
62
63 # Without RHS:
64 do_pragma_ncol_test 1.$tn.1 [lindex [split $sql =] 0] 1
mistachkin817be732017-01-06 00:02:51 +000065
dan9e1ab1a2017-01-05 19:32:48 +000066 # With RHS:
67 do_pragma_ncol_test 1.$tn.2 $sql 0
68}
69
dane1ff3f52017-01-06 13:49:40 +000070# These pragmas should never return any values.
71#
72foreach {tn sql} {
73 1 "PRAGMA shrink_memory"
74 2 "PRAGMA shrink_memory = 10"
75 3 "PRAGMA case_sensitive_like = 0"
76 4 "PRAGMA case_sensitive_like = 1"
77 5 "PRAGMA case_sensitive_like"
78} {
79
80 do_pragma_ncol_test 1.$tn.1 $sql 0
81}
82
dan9e1ab1a2017-01-05 19:32:48 +000083
84finish_test