/ Check-in [dd4962aa34]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Rename the sqlite_compile_option_*() SQL functions to sqlite_compileoption_*() for consistency with the C/C++ interface.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: dd4962aa34c4dd118d2cb15465384636eacc64d5
User & Date: drh 2010-02-26 16:37:48
Context
2010-03-02
23:34
When TEMP files are in memory, also put the massive TEMP file used by the VACUUM command in memory. check-in: 9daf4e7d07 user: drh tags: trunk
2010-02-26
16:37
Rename the sqlite_compile_option_*() SQL functions to sqlite_compileoption_*() for consistency with the C/C++ interface. check-in: dd4962aa34 user: drh tags: trunk
15:39
Remove the compile_option pragma (retaining compile_options - with an "s"). Updates to documentation. check-in: 733778df99 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/func.c.

1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
    {2,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"ifnull",0},
    FUNCTION(random,             0, 0, 0, randomFunc       ),
    FUNCTION(randomblob,         1, 0, 0, randomBlob       ),
    FUNCTION(nullif,             2, 0, 1, nullifFunc       ),
    FUNCTION(sqlite_version,     0, 0, 0, versionFunc      ),
    FUNCTION(sqlite_source_id,   0, 0, 0, sourceidFunc     ),
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
    FUNCTION(sqlite_compile_option_used,1, 0, 0, compileoptionusedFunc  ),
    FUNCTION(sqlite_compile_option_get, 1, 0, 0, compileoptiongetFunc  ),
#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
    FUNCTION(quote,              1, 0, 0, quoteFunc        ),
    FUNCTION(last_insert_rowid,  0, 0, 0, last_insert_rowid),
    FUNCTION(changes,            0, 0, 0, changes          ),
    FUNCTION(total_changes,      0, 0, 0, total_changes    ),
    FUNCTION(replace,            3, 0, 0, replaceFunc      ),
    FUNCTION(zeroblob,           1, 0, 0, zeroblobFunc     ),







|
|







1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
    {2,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"ifnull",0},
    FUNCTION(random,             0, 0, 0, randomFunc       ),
    FUNCTION(randomblob,         1, 0, 0, randomBlob       ),
    FUNCTION(nullif,             2, 0, 1, nullifFunc       ),
    FUNCTION(sqlite_version,     0, 0, 0, versionFunc      ),
    FUNCTION(sqlite_source_id,   0, 0, 0, sourceidFunc     ),
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
    FUNCTION(sqlite_compileoption_used,1, 0, 0, compileoptionusedFunc  ),
    FUNCTION(sqlite_compileoption_get, 1, 0, 0, compileoptiongetFunc  ),
#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
    FUNCTION(quote,              1, 0, 0, quoteFunc        ),
    FUNCTION(last_insert_rowid,  0, 0, 0, last_insert_rowid),
    FUNCTION(changes,            0, 0, 0, changes          ),
    FUNCTION(total_changes,      0, 0, 0, total_changes    ),
    FUNCTION(replace,            3, 0, 0, replaceFunc      ),
    FUNCTION(zeroblob,           1, 0, 0, zeroblobFunc     ),

Changes to test/ctime.test.

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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
...
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
do_test ctime-1.2.2 {
  set ans [ catchsql {
    PRAGMA compile_options;
  } ]
  list [ lindex $ans 0 ] [ expr { [lsort [lindex $ans 1]]==[lindex $ans 1] } ]
} {0 1}

do_test ctime-1.3.1 {
  catchsql {
    PRAGMA compile_option();
  }
} {1 {near ")": syntax error}}
do_test ctime-1.3.2 {
  catchsql {
    PRAGMA compile_option(NULL);
  }
} {1 {near "NULL": syntax error}}
do_test ctime-1.3.3 {
  catchsql {
    PRAGMA compile_option foo;
  }
} {1 {near "foo": syntax error}}
do_test ctime-1.3.4 {
  catchsql {
    PRAGMA compile_option 'foo';
  }
} {1 {near "'foo'": syntax error}}

# SQLITE_THREADSAFE should pretty much always be defined
# one way or the other, and it must have a value of 0 or 1.
do_test ctime-1.4.1 {
  catchsql {
    PRAGMA compile_option('SQLITE_THREADSAFE');
  }
} {0 1}
do_test ctime-1.4.2 {
  catchsql {
    PRAGMA compile_option('THREADSAFE');
  }
} {0 1}
do_test ctime-1.4.3 {
  catchsql {
    PRAGMA compile_option("THREADSAFE");
  }
} {0 1}
do_test ctime-1.4.4 {
  catchsql {
    PRAGMA compile_option='THREADSAFE';
  }
} {0 1}
do_test ctime-1.4.5 {
  catchsql {
    PRAGMA compile_option="THREADSAFE";
  }
} {0 1}

do_test ctime-1.5 {
  set ans1 [ catchsql {
    PRAGMA compile_option('THREADSAFE=0');
  } ]
  set ans2 [ catchsql {
    PRAGMA compile_option('THREADSAFE=1');
  } ]
  lsort [ list $ans1 $ans2 ]
} {{0 0} {0 1}}

do_test ctime-1.6 {
  execsql {
    PRAGMA compile_option('THREADSAFE=');
  }
} {0}

do_test ctime-1.7.1 {
  execsql {
    PRAGMA compile_option('SQLITE_OMIT_COMPILEOPTION_DIAGS');
  }
} {0}
do_test ctime-1.7.2 {
  execsql {
    PRAGMA compile_option('OMIT_COMPILEOPTION_DIAGS');
  }
} {0}

#####################
# ctime-2.*: Test function support.

do_test ctime-2.1.1 {
  catchsql {
    SELECT sqlite_compile_option_used();
  }
} {1 {wrong number of arguments to function sqlite_compile_option_used()}}
do_test ctime-2.1.2 {
  catchsql {
    SELECT sqlite_compile_option_used(NULL);
  }
} {0 {{}}}
do_test ctime-2.1.3 {
  catchsql {
    SELECT sqlite_compile_option_used("");
  }
} {0 0}
do_test ctime-2.1.4 {
  catchsql {
    SELECT sqlite_compile_option_used('');
  }
} {0 0}
do_test ctime-2.1.5 {
  catchsql {
    SELECT sqlite_compile_option_used(foo);
  }
} {1 {no such column: foo}}
do_test ctime-2.1.6 {
  catchsql {
    SELECT sqlite_compile_option_used('THREADSAFE', 0);
  }
} {1 {wrong number of arguments to function sqlite_compile_option_used()}}
do_test ctime-2.1.7 {
  catchsql {
    SELECT sqlite_compile_option_used(0);
  }
} {0 0}
do_test ctime-2.1.8 {
  catchsql {
    SELECT sqlite_compile_option_used('0');
  }
} {0 0}
do_test ctime-2.1.9 {
  catchsql {
    SELECT sqlite_compile_option_used(1.0);
  }
} {0 0}

do_test ctime-2.2.1 {
  catchsql {
    SELECT sqlite_compile_option_get();
  }
} {1 {wrong number of arguments to function sqlite_compile_option_get()}}
do_test ctime-2.2.2 {
  catchsql {
    SELECT sqlite_compile_option_get(0, 0);
  }
} {1 {wrong number of arguments to function sqlite_compile_option_get()}}

# This assumes there is at least 1 compile time option
# (see SQLITE_THREADSAFE above).
do_test ctime-2.3 {
  catchsql {
    SELECT sqlite_compile_option_used(sqlite_compile_option_get(0));
  }
} {0 1}

# This assumes there is at least 1 compile time option
# (see SQLITE_THREADSAFE above).
do_test ctime-2.4 {
  set ans [ catchsql {
    SELECT sqlite_compile_option_get(0);
  } ]
  list [lindex $ans 0]
} {0}

# Get the list of defines using the pragma,
# then try querying each one with the functions.
set ans [ catchsql {
................................................................................
} ]
set opts [ lindex $ans 1 ]
set tc 1
foreach opt $opts {
  do_test ctime-2.5.$tc {
    set N [ expr {$tc-1} ]
    set ans1 [ catchsql {
      SELECT sqlite_compile_option_get($N);
    } ]
    set ans2 [ catchsql {
      SELECT sqlite_compile_option_used($opt);
    } ]
    list [ lindex $ans1 0 ] [ expr { [lindex $ans1 1]==$opt } ] \
         [ expr { $ans2 } ]
  } {0 1 {0 1}}
  incr tc 1
}
# test 1 past array bounds
do_test ctime-2.5.$tc {
  set N [ expr {$tc-1} ]
  set ans [ catchsql {
    SELECT sqlite_compile_option_get($N);
  } ]
} {0 {{}}}
incr tc 1
# test 1 before array bounds (N=-1)
do_test ctime-2.5.$tc {
  set N -1
  set ans [ catchsql {
    SELECT sqlite_compile_option_get($N);
  } ]
} {0 {{}}}


finish_test







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




|




|




|
<
<
<
<
<
<
<
<
<
<





|


|






|





|




|








|

|


|




|




|




|




|

|


|




|




|





|

|


|

|





|







|







 







|


|










|







|





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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
...
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
do_test ctime-1.2.2 {
  set ans [ catchsql {
    PRAGMA compile_options;
  } ]
  list [ lindex $ans 0 ] [ expr { [lsort [lindex $ans 1]]==[lindex $ans 1] } ]
} {0 1}






















# SQLITE_THREADSAFE should pretty much always be defined
# one way or the other, and it must have a value of 0 or 1.
do_test ctime-1.4.1 {
  catchsql {
    SELECT sqlite_compileoption_used('SQLITE_THREADSAFE');
  }
} {0 1}
do_test ctime-1.4.2 {
  catchsql {
    SELECT sqlite_compileoption_used('THREADSAFE');
  }
} {0 1}
do_test ctime-1.4.3 {
  catchsql {
    SELECT sqlite_compileoption_used("THREADSAFE");










  }
} {0 1}

do_test ctime-1.5 {
  set ans1 [ catchsql {
    SELECT sqlite_compileoption_used('THREADSAFE=0');
  } ]
  set ans2 [ catchsql {
    SELECT sqlite_compileoption_used('THREADSAFE=1');
  } ]
  lsort [ list $ans1 $ans2 ]
} {{0 0} {0 1}}

do_test ctime-1.6 {
  execsql {
    SELECT sqlite_compileoption_used('THREADSAFE=');
  }
} {0}

do_test ctime-1.7.1 {
  execsql {
    SELECT sqlite_compileoption_used('SQLITE_OMIT_COMPILEOPTION_DIAGS');
  }
} {0}
do_test ctime-1.7.2 {
  execsql {
    SELECT sqlite_compileoption_used('OMIT_COMPILEOPTION_DIAGS');
  }
} {0}

#####################
# ctime-2.*: Test function support.

do_test ctime-2.1.1 {
  catchsql {
    SELECT sqlite_compileoption_used();
  }
} {1 {wrong number of arguments to function sqlite_compileoption_used()}}
do_test ctime-2.1.2 {
  catchsql {
    SELECT sqlite_compileoption_used(NULL);
  }
} {0 {{}}}
do_test ctime-2.1.3 {
  catchsql {
    SELECT sqlite_compileoption_used("");
  }
} {0 0}
do_test ctime-2.1.4 {
  catchsql {
    SELECT sqlite_compileoption_used('');
  }
} {0 0}
do_test ctime-2.1.5 {
  catchsql {
    SELECT sqlite_compileoption_used(foo);
  }
} {1 {no such column: foo}}
do_test ctime-2.1.6 {
  catchsql {
    SELECT sqlite_compileoption_used('THREADSAFE', 0);
  }
} {1 {wrong number of arguments to function sqlite_compileoption_used()}}
do_test ctime-2.1.7 {
  catchsql {
    SELECT sqlite_compileoption_used(0);
  }
} {0 0}
do_test ctime-2.1.8 {
  catchsql {
    SELECT sqlite_compileoption_used('0');
  }
} {0 0}
do_test ctime-2.1.9 {
  catchsql {
    SELECT sqlite_compileoption_used(1.0);
  }
} {0 0}

do_test ctime-2.2.1 {
  catchsql {
    SELECT sqlite_compileoption_get();
  }
} {1 {wrong number of arguments to function sqlite_compileoption_get()}}
do_test ctime-2.2.2 {
  catchsql {
    SELECT sqlite_compileoption_get(0, 0);
  }
} {1 {wrong number of arguments to function sqlite_compileoption_get()}}

# This assumes there is at least 1 compile time option
# (see SQLITE_THREADSAFE above).
do_test ctime-2.3 {
  catchsql {
    SELECT sqlite_compileoption_used(sqlite_compileoption_get(0));
  }
} {0 1}

# This assumes there is at least 1 compile time option
# (see SQLITE_THREADSAFE above).
do_test ctime-2.4 {
  set ans [ catchsql {
    SELECT sqlite_compileoption_get(0);
  } ]
  list [lindex $ans 0]
} {0}

# Get the list of defines using the pragma,
# then try querying each one with the functions.
set ans [ catchsql {
................................................................................
} ]
set opts [ lindex $ans 1 ]
set tc 1
foreach opt $opts {
  do_test ctime-2.5.$tc {
    set N [ expr {$tc-1} ]
    set ans1 [ catchsql {
      SELECT sqlite_compileoption_get($N);
    } ]
    set ans2 [ catchsql {
      SELECT sqlite_compileoption_used($opt);
    } ]
    list [ lindex $ans1 0 ] [ expr { [lindex $ans1 1]==$opt } ] \
         [ expr { $ans2 } ]
  } {0 1 {0 1}}
  incr tc 1
}
# test 1 past array bounds
do_test ctime-2.5.$tc {
  set N [ expr {$tc-1} ]
  set ans [ catchsql {
    SELECT sqlite_compileoption_get($N);
  } ]
} {0 {{}}}
incr tc 1
# test 1 before array bounds (N=-1)
do_test ctime-2.5.$tc {
  set N -1
  set ans [ catchsql {
    SELECT sqlite_compileoption_get($N);
  } ]
} {0 {{}}}


finish_test