Updates the sqlite version in the agent (#13233)
New version sqlite Enabling also #define SQLITE_UDL_CAPABLE_PARSER 1 #define SQLITE_ENABLE_UPDATE_DELETE_LIMIT 1 #define SQLITE_OMIT_LOAD_EXTENSION 1 #define SQLITE_ENABLE_DBSTAT_VTAB 1
Stelios Fragkakis committed
Jun 28, 2022 at 19:16 UTC
920a2ae7f593c63238f4ee911e58f441bff56433
2 files changed
+12377
-7982
database/sqlite/sqlite3.c
+11880
-7938
@@ -1,6 +1,6 @@
1
/******************************************************************************
2
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.36.0. By combining all the individual C code files into this
3
+** version 3.38.5. By combining all the individual C code files into this
4
** single large file, the entire code can be compiled as a single translation
5
** unit. This allows many compilers to do optimizations that would not be
6
** possible if the files were compiled separately. Performance improvements
@@ -24,795 +24,10 @@
24
# define SQLITE_PRIVATE static
25
#endif
26
#define SQLITE_UDL_CAPABLE_PARSER 1
27
-/************** Begin file ctime.c *******************************************/
28
-/*
29
-** 2010 February 23
30
-**
31
-** The author disclaims copyright to this source code. In place of
32
-** a legal notice, here is a blessing:
33
-**
34
-** May you do good and not evil.
35
-** May you find forgiveness for yourself and forgive others.
36
-** May you share freely, never taking more than you give.
37
-**
38
-*************************************************************************
39
-**
40
-** This file implements routines used to report what compile-time options
41
-** SQLite was built with.
42
-*/
27
#define SQLITE_ENABLE_UPDATE_DELETE_LIMIT 1
28
#define SQLITE_OMIT_LOAD_EXTENSION 1
29
#define SQLITE_ENABLE_DBSTAT_VTAB 1
46
-#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS /* IMP: R-16824-07538 */
47
-
48
-/*
49
-** Include the configuration header output by 'configure' if we're using the
50
-** autoconf-based build
51
-*/
52
-#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
53
-#include "config.h"
54
-#define SQLITECONFIG_H 1
55
-#endif
56
-
57
-/* These macros are provided to "stringify" the value of the define
58
-** for those options in which the value is meaningful. */
59
-#define CTIMEOPT_VAL_(opt) #opt
60
-#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
61
-
62
-/* Like CTIMEOPT_VAL, but especially for SQLITE_DEFAULT_LOOKASIDE. This
63
-** option requires a separate macro because legal values contain a single
64
-** comma. e.g. (-DSQLITE_DEFAULT_LOOKASIDE="100,100") */
65
-#define CTIMEOPT_VAL2_(opt1,opt2) #opt1 "," #opt2
66
-#define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt)
30
68
-/*
69
-** An array of names of all compile-time options. This array should
70
-** be sorted A-Z.
71
-**
72
-** This array looks large, but in a typical installation actually uses
73
-** only a handful of compile-time options, so most times this array is usually
74
-** rather short and uses little memory space.
75
-*/
76
-static const char * const sqlite3azCompileOpt[] = {
77
-
78
-/*
79
-** BEGIN CODE GENERATED BY tool/mkctime.tcl
80
-*/
81
-#if SQLITE_32BIT_ROWID
82
- "32BIT_ROWID",
83
-#endif
84
-#if SQLITE_4_BYTE_ALIGNED_MALLOC
85
- "4_BYTE_ALIGNED_MALLOC",
86
-#endif
87
-#if SQLITE_64BIT_STATS
88
- "64BIT_STATS",
89
-#endif
90
-#ifdef SQLITE_ALLOW_COVERING_INDEX_SCAN
91
-# if SQLITE_ALLOW_COVERING_INDEX_SCAN != 1
92
- "ALLOW_COVERING_INDEX_SCAN=" CTIMEOPT_VAL(SQLITE_ALLOW_COVERING_INDEX_SCAN),
93
-# endif
94
-#endif
95
-#if SQLITE_ALLOW_URI_AUTHORITY
96
- "ALLOW_URI_AUTHORITY",
97
-#endif
98
-#ifdef SQLITE_BITMASK_TYPE
99
- "BITMASK_TYPE=" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE),
100
-#endif
101
-#if SQLITE_BUG_COMPATIBLE_20160819
102
- "BUG_COMPATIBLE_20160819",
103
-#endif
104
-#if SQLITE_CASE_SENSITIVE_LIKE
105
- "CASE_SENSITIVE_LIKE",
106
-#endif
107
-#if SQLITE_CHECK_PAGES
108
- "CHECK_PAGES",
109
-#endif
110
-#if defined(__clang__) && defined(__clang_major__)
111
- "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "."
112
- CTIMEOPT_VAL(__clang_minor__) "."
113
- CTIMEOPT_VAL(__clang_patchlevel__),
114
-#elif defined(_MSC_VER)
115
- "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER),
116
-#elif defined(__GNUC__) && defined(__VERSION__)
117
- "COMPILER=gcc-" __VERSION__,
118
-#endif
119
-#if SQLITE_COVERAGE_TEST
120
- "COVERAGE_TEST",
121
-#endif
122
-#if SQLITE_DEBUG
123
- "DEBUG",
124
-#endif
125
-#if SQLITE_DEFAULT_AUTOMATIC_INDEX
126
- "DEFAULT_AUTOMATIC_INDEX",
127
-#endif
128
-#if SQLITE_DEFAULT_AUTOVACUUM
129
- "DEFAULT_AUTOVACUUM",
130
-#endif
131
-#ifdef SQLITE_DEFAULT_CACHE_SIZE
132
- "DEFAULT_CACHE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_CACHE_SIZE),
133
-#endif
134
-#if SQLITE_DEFAULT_CKPTFULLFSYNC
135
- "DEFAULT_CKPTFULLFSYNC",
136
-#endif
137
-#ifdef SQLITE_DEFAULT_FILE_FORMAT
138
- "DEFAULT_FILE_FORMAT=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_FORMAT),
139
-#endif
140
-#ifdef SQLITE_DEFAULT_FILE_PERMISSIONS
141
- "DEFAULT_FILE_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_PERMISSIONS),
142
-#endif
143
-#if SQLITE_DEFAULT_FOREIGN_KEYS
144
- "DEFAULT_FOREIGN_KEYS",
145
-#endif
146
-#ifdef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
147
- "DEFAULT_JOURNAL_SIZE_LIMIT=" CTIMEOPT_VAL(SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT),
148
-#endif
149
-#ifdef SQLITE_DEFAULT_LOCKING_MODE
150
- "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
151
-#endif
152
-#ifdef SQLITE_DEFAULT_LOOKASIDE
153
- "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE),
154
-#endif
155
-#ifdef SQLITE_DEFAULT_MEMSTATUS
156
-# if SQLITE_DEFAULT_MEMSTATUS != 1
157
- "DEFAULT_MEMSTATUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_MEMSTATUS),
158
-# endif
159
-#endif
160
-#ifdef SQLITE_DEFAULT_MMAP_SIZE
161
- "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
162
-#endif
163
-#ifdef SQLITE_DEFAULT_PAGE_SIZE
164
- "DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_PAGE_SIZE),
165
-#endif
166
-#ifdef SQLITE_DEFAULT_PCACHE_INITSZ
167
- "DEFAULT_PCACHE_INITSZ=" CTIMEOPT_VAL(SQLITE_DEFAULT_PCACHE_INITSZ),
168
-#endif
169
-#ifdef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS
170
- "DEFAULT_PROXYDIR_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_PROXYDIR_PERMISSIONS),
171
-#endif
172
-#if SQLITE_DEFAULT_RECURSIVE_TRIGGERS
173
- "DEFAULT_RECURSIVE_TRIGGERS",
174
-#endif
175
-#ifdef SQLITE_DEFAULT_ROWEST
176
- "DEFAULT_ROWEST=" CTIMEOPT_VAL(SQLITE_DEFAULT_ROWEST),
177
-#endif
178
-#ifdef SQLITE_DEFAULT_SECTOR_SIZE
179
- "DEFAULT_SECTOR_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_SECTOR_SIZE),
180
-#endif
181
-#ifdef SQLITE_DEFAULT_SYNCHRONOUS
182
- "DEFAULT_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS),
183
-#endif
184
-#ifdef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
185
- "DEFAULT_WAL_AUTOCHECKPOINT=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_AUTOCHECKPOINT),
186
-#endif
187
-#ifdef SQLITE_DEFAULT_WAL_SYNCHRONOUS
188
- "DEFAULT_WAL_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS),
189
-#endif
190
-#ifdef SQLITE_DEFAULT_WORKER_THREADS
191
- "DEFAULT_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WORKER_THREADS),
192
-#endif
193
-#if SQLITE_DIRECT_OVERFLOW_READ
194
- "DIRECT_OVERFLOW_READ",
195
-#endif
196
-#if SQLITE_DISABLE_DIRSYNC
197
- "DISABLE_DIRSYNC",
198
-#endif
199
-#if SQLITE_DISABLE_FTS3_UNICODE
200
- "DISABLE_FTS3_UNICODE",
201
-#endif
202
-#if SQLITE_DISABLE_FTS4_DEFERRED
203
- "DISABLE_FTS4_DEFERRED",
204
-#endif
205
-#if SQLITE_DISABLE_INTRINSIC
206
- "DISABLE_INTRINSIC",
207
-#endif
208
-#if SQLITE_DISABLE_LFS
209
- "DISABLE_LFS",
210
-#endif
211
-#if SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
212
- "DISABLE_PAGECACHE_OVERFLOW_STATS",
213
-#endif
214
-#if SQLITE_DISABLE_SKIPAHEAD_DISTINCT
215
- "DISABLE_SKIPAHEAD_DISTINCT",
216
-#endif
217
-#ifdef SQLITE_ENABLE_8_3_NAMES
218
- "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),
219
-#endif
220
-#if SQLITE_ENABLE_API_ARMOR
221
- "ENABLE_API_ARMOR",
222
-#endif
223
-#if SQLITE_ENABLE_ATOMIC_WRITE
224
- "ENABLE_ATOMIC_WRITE",
225
-#endif
226
-#if SQLITE_ENABLE_BATCH_ATOMIC_WRITE
227
- "ENABLE_BATCH_ATOMIC_WRITE",
228
-#endif
229
-#if SQLITE_ENABLE_BYTECODE_VTAB
230
- "ENABLE_BYTECODE_VTAB",
231
-#endif
232
-#ifdef SQLITE_ENABLE_CEROD
233
- "ENABLE_CEROD=" CTIMEOPT_VAL(SQLITE_ENABLE_CEROD),
234
-#endif
235
-#if SQLITE_ENABLE_COLUMN_METADATA
236
- "ENABLE_COLUMN_METADATA",
237
-#endif
238
-#if SQLITE_ENABLE_COLUMN_USED_MASK
239
- "ENABLE_COLUMN_USED_MASK",
240
-#endif
241
-#if SQLITE_ENABLE_COSTMULT
242
- "ENABLE_COSTMULT",
243
-#endif
244
-#if SQLITE_ENABLE_CURSOR_HINTS
245
- "ENABLE_CURSOR_HINTS",
246
-#endif
247
-#if SQLITE_ENABLE_DBPAGE_VTAB
248
- "ENABLE_DBPAGE_VTAB",
249
-#endif
250
-#if SQLITE_ENABLE_DBSTAT_VTAB
251
- "ENABLE_DBSTAT_VTAB",
252
-#endif
253
-#if SQLITE_ENABLE_EXPENSIVE_ASSERT
254
- "ENABLE_EXPENSIVE_ASSERT",
255
-#endif
256
-#if SQLITE_ENABLE_EXPLAIN_COMMENTS
257
- "ENABLE_EXPLAIN_COMMENTS",
258
-#endif
259
-#if SQLITE_ENABLE_FTS3
260
- "ENABLE_FTS3",
261
-#endif
262
-#if SQLITE_ENABLE_FTS3_PARENTHESIS
263
- "ENABLE_FTS3_PARENTHESIS",
264
-#endif
265
-#if SQLITE_ENABLE_FTS3_TOKENIZER
266
- "ENABLE_FTS3_TOKENIZER",
267
-#endif
268
-#if SQLITE_ENABLE_FTS4
269
- "ENABLE_FTS4",
270
-#endif
271
-#if SQLITE_ENABLE_FTS5
272
- "ENABLE_FTS5",
273
-#endif
274
-#if SQLITE_ENABLE_GEOPOLY
275
- "ENABLE_GEOPOLY",
276
-#endif
277
-#if SQLITE_ENABLE_HIDDEN_COLUMNS
278
- "ENABLE_HIDDEN_COLUMNS",
279
-#endif
280
-#if SQLITE_ENABLE_ICU
281
- "ENABLE_ICU",
282
-#endif
283
-#if SQLITE_ENABLE_IOTRACE
284
- "ENABLE_IOTRACE",
285
-#endif
286
-#if SQLITE_ENABLE_JSON1
287
- "ENABLE_JSON1",
288
-#endif
289
-#if SQLITE_ENABLE_LOAD_EXTENSION
290
- "ENABLE_LOAD_EXTENSION",
291
-#endif
292
-#ifdef SQLITE_ENABLE_LOCKING_STYLE
293
- "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
294
-#endif
295
-#if SQLITE_ENABLE_MATH_FUNCTIONS
296
- "ENABLE_MATH_FUNCTIONS",
297
-#endif
298
-#if SQLITE_ENABLE_MEMORY_MANAGEMENT
299
- "ENABLE_MEMORY_MANAGEMENT",
300
-#endif
301
-#if SQLITE_ENABLE_MEMSYS3
302
- "ENABLE_MEMSYS3",
303
-#endif
304
-#if SQLITE_ENABLE_MEMSYS5
305
- "ENABLE_MEMSYS5",
306
-#endif
307
-#if SQLITE_ENABLE_MULTIPLEX
308
- "ENABLE_MULTIPLEX",
309
-#endif
310
-#if SQLITE_ENABLE_NORMALIZE
311
- "ENABLE_NORMALIZE",
312
-#endif
313
-#if SQLITE_ENABLE_NULL_TRIM
314
- "ENABLE_NULL_TRIM",
315
-#endif
316
-#if SQLITE_ENABLE_OFFSET_SQL_FUNC
317
- "ENABLE_OFFSET_SQL_FUNC",
318
-#endif
319
-#if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
320
- "ENABLE_OVERSIZE_CELL_CHECK",
321
-#endif
322
-#if SQLITE_ENABLE_PREUPDATE_HOOK
323
- "ENABLE_PREUPDATE_HOOK",
324
-#endif
325
-#if SQLITE_ENABLE_QPSG
326
- "ENABLE_QPSG",
327
-#endif
328
-#if SQLITE_ENABLE_RBU
329
- "ENABLE_RBU",
330
-#endif
331
-#if SQLITE_ENABLE_RTREE
332
- "ENABLE_RTREE",
333
-#endif
334
-#if SQLITE_ENABLE_SELECTTRACE
335
- "ENABLE_SELECTTRACE",
336
-#endif
337
-#if SQLITE_ENABLE_SESSION
338
- "ENABLE_SESSION",
339
-#endif
340
-#if SQLITE_ENABLE_SNAPSHOT
341
- "ENABLE_SNAPSHOT",
342
-#endif
343
-#if SQLITE_ENABLE_SORTER_REFERENCES
344
- "ENABLE_SORTER_REFERENCES",
345
-#endif
346
-#if SQLITE_ENABLE_SQLLOG
347
- "ENABLE_SQLLOG",
348
-#endif
349
-#if SQLITE_ENABLE_STAT4
350
- "ENABLE_STAT4",
351
-#endif
352
-#if SQLITE_ENABLE_STMTVTAB
353
- "ENABLE_STMTVTAB",
354
-#endif
355
-#if SQLITE_ENABLE_STMT_SCANSTATUS
356
- "ENABLE_STMT_SCANSTATUS",
357
-#endif
358
-#if SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
359
- "ENABLE_UNKNOWN_SQL_FUNCTION",
360
-#endif
361
-#if SQLITE_ENABLE_UNLOCK_NOTIFY
362
- "ENABLE_UNLOCK_NOTIFY",
363
-#endif
364
-#if SQLITE_ENABLE_UPDATE_DELETE_LIMIT
365
- "ENABLE_UPDATE_DELETE_LIMIT",
366
-#endif
367
-#if SQLITE_ENABLE_URI_00_ERROR
368
- "ENABLE_URI_00_ERROR",
369
-#endif
370
-#if SQLITE_ENABLE_VFSTRACE
371
- "ENABLE_VFSTRACE",
372
-#endif
373
-#if SQLITE_ENABLE_WHERETRACE
374
- "ENABLE_WHERETRACE",
375
-#endif
376
-#if SQLITE_ENABLE_ZIPVFS
377
- "ENABLE_ZIPVFS",
378
-#endif
379
-#if SQLITE_EXPLAIN_ESTIMATED_ROWS
380
- "EXPLAIN_ESTIMATED_ROWS",
381
-#endif
382
-#if SQLITE_EXTRA_IFNULLROW
383
- "EXTRA_IFNULLROW",
384
-#endif
385
-#ifdef SQLITE_EXTRA_INIT
386
- "EXTRA_INIT=" CTIMEOPT_VAL(SQLITE_EXTRA_INIT),
387
-#endif
388
-#ifdef SQLITE_EXTRA_SHUTDOWN
389
- "EXTRA_SHUTDOWN=" CTIMEOPT_VAL(SQLITE_EXTRA_SHUTDOWN),
390
-#endif
391
-#ifdef SQLITE_FTS3_MAX_EXPR_DEPTH
392
- "FTS3_MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_FTS3_MAX_EXPR_DEPTH),
393
-#endif
394
-#if SQLITE_FTS5_ENABLE_TEST_MI
395
- "FTS5_ENABLE_TEST_MI",
396
-#endif
397
-#if SQLITE_FTS5_NO_WITHOUT_ROWID
398
- "FTS5_NO_WITHOUT_ROWID",
399
-#endif
400
-#if HAVE_ISNAN || SQLITE_HAVE_ISNAN
401
- "HAVE_ISNAN",
402
-#endif
403
-#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
404
-# if SQLITE_HOMEGROWN_RECURSIVE_MUTEX != 1
405
- "HOMEGROWN_RECURSIVE_MUTEX=" CTIMEOPT_VAL(SQLITE_HOMEGROWN_RECURSIVE_MUTEX),
406
-# endif
407
-#endif
408
-#if SQLITE_IGNORE_AFP_LOCK_ERRORS
409
- "IGNORE_AFP_LOCK_ERRORS",
410
-#endif
411
-#if SQLITE_IGNORE_FLOCK_LOCK_ERRORS
412
- "IGNORE_FLOCK_LOCK_ERRORS",
413
-#endif
414
-#if SQLITE_INLINE_MEMCPY
415
- "INLINE_MEMCPY",
416
-#endif
417
-#if SQLITE_INT64_TYPE
418
- "INT64_TYPE",
419
-#endif
420
-#ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX
421
- "INTEGRITY_CHECK_ERROR_MAX=" CTIMEOPT_VAL(SQLITE_INTEGRITY_CHECK_ERROR_MAX),
422
-#endif
423
-#if SQLITE_LIKE_DOESNT_MATCH_BLOBS
424
- "LIKE_DOESNT_MATCH_BLOBS",
425
-#endif
426
-#if SQLITE_LOCK_TRACE
427
- "LOCK_TRACE",
428
-#endif
429
-#if SQLITE_LOG_CACHE_SPILL
430
- "LOG_CACHE_SPILL",
431
-#endif
432
-#ifdef SQLITE_MALLOC_SOFT_LIMIT
433
- "MALLOC_SOFT_LIMIT=" CTIMEOPT_VAL(SQLITE_MALLOC_SOFT_LIMIT),
434
-#endif
435
-#ifdef SQLITE_MAX_ATTACHED
436
- "MAX_ATTACHED=" CTIMEOPT_VAL(SQLITE_MAX_ATTACHED),
437
-#endif
438
-#ifdef SQLITE_MAX_COLUMN
439
- "MAX_COLUMN=" CTIMEOPT_VAL(SQLITE_MAX_COLUMN),
440
-#endif
441
-#ifdef SQLITE_MAX_COMPOUND_SELECT
442
- "MAX_COMPOUND_SELECT=" CTIMEOPT_VAL(SQLITE_MAX_COMPOUND_SELECT),
443
-#endif
444
-#ifdef SQLITE_MAX_DEFAULT_PAGE_SIZE
445
- "MAX_DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_DEFAULT_PAGE_SIZE),
446
-#endif
447
-#ifdef SQLITE_MAX_EXPR_DEPTH
448
- "MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_EXPR_DEPTH),
449
-#endif
450
-#ifdef SQLITE_MAX_FUNCTION_ARG
451
- "MAX_FUNCTION_ARG=" CTIMEOPT_VAL(SQLITE_MAX_FUNCTION_ARG),
452
-#endif
453
-#ifdef SQLITE_MAX_LENGTH
454
- "MAX_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LENGTH),
455
-#endif
456
-#ifdef SQLITE_MAX_LIKE_PATTERN_LENGTH
457
- "MAX_LIKE_PATTERN_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LIKE_PATTERN_LENGTH),
458
-#endif
459
-#ifdef SQLITE_MAX_MEMORY
460
- "MAX_MEMORY=" CTIMEOPT_VAL(SQLITE_MAX_MEMORY),
461
-#endif
462
-#ifdef SQLITE_MAX_MMAP_SIZE
463
- "MAX_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE),
464
-#endif
465
-#ifdef SQLITE_MAX_MMAP_SIZE_
466
- "MAX_MMAP_SIZE_=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE_),
467
-#endif
468
-#ifdef SQLITE_MAX_PAGE_COUNT
469
- "MAX_PAGE_COUNT=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_COUNT),
470
-#endif
471
-#ifdef SQLITE_MAX_PAGE_SIZE
472
- "MAX_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_SIZE),
473
-#endif
474
-#ifdef SQLITE_MAX_SCHEMA_RETRY
475
- "MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),
476
-#endif
477
-#ifdef SQLITE_MAX_SQL_LENGTH
478
- "MAX_SQL_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_SQL_LENGTH),
479
-#endif
480
-#ifdef SQLITE_MAX_TRIGGER_DEPTH
481
- "MAX_TRIGGER_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_TRIGGER_DEPTH),
482
-#endif
483
-#ifdef SQLITE_MAX_VARIABLE_NUMBER
484
- "MAX_VARIABLE_NUMBER=" CTIMEOPT_VAL(SQLITE_MAX_VARIABLE_NUMBER),
485
-#endif
486
-#ifdef SQLITE_MAX_VDBE_OP
487
- "MAX_VDBE_OP=" CTIMEOPT_VAL(SQLITE_MAX_VDBE_OP),
488
-#endif
489
-#ifdef SQLITE_MAX_WORKER_THREADS
490
- "MAX_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_MAX_WORKER_THREADS),
491
-#endif
492
-#if SQLITE_MEMDEBUG
493
- "MEMDEBUG",
494
-#endif
495
-#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT
496
- "MIXED_ENDIAN_64BIT_FLOAT",
497
-#endif
498
-#if SQLITE_MMAP_READWRITE
499
- "MMAP_READWRITE",
500
-#endif
501
-#if SQLITE_MUTEX_NOOP
502
- "MUTEX_NOOP",
503
-#endif
504
-#if SQLITE_MUTEX_OMIT
505
- "MUTEX_OMIT",
506
-#endif
507
-#if SQLITE_MUTEX_PTHREADS
508
- "MUTEX_PTHREADS",
509
-#endif
510
-#if SQLITE_MUTEX_W32
511
- "MUTEX_W32",
512
-#endif
513
-#if SQLITE_NEED_ERR_NAME
514
- "NEED_ERR_NAME",
515
-#endif
516
-#if SQLITE_NOINLINE
517
- "NOINLINE",
518
-#endif
519
-#if SQLITE_NO_SYNC
520
- "NO_SYNC",
521
-#endif
522
-#if SQLITE_OMIT_ALTERTABLE
523
- "OMIT_ALTERTABLE",
524
-#endif
525
-#if SQLITE_OMIT_ANALYZE
526
- "OMIT_ANALYZE",
527
-#endif
528
-#if SQLITE_OMIT_ATTACH
529
- "OMIT_ATTACH",
530
-#endif
531
-#if SQLITE_OMIT_AUTHORIZATION
532
- "OMIT_AUTHORIZATION",
533
-#endif
534
-#if SQLITE_OMIT_AUTOINCREMENT
535
- "OMIT_AUTOINCREMENT",
536
-#endif
537
-#if SQLITE_OMIT_AUTOINIT
538
- "OMIT_AUTOINIT",
539
-#endif
540
-#if SQLITE_OMIT_AUTOMATIC_INDEX
541
- "OMIT_AUTOMATIC_INDEX",
542
-#endif
543
-#if SQLITE_OMIT_AUTORESET
544
- "OMIT_AUTORESET",
545
-#endif
546
-#if SQLITE_OMIT_AUTOVACUUM
547
- "OMIT_AUTOVACUUM",
548
-#endif
549
-#if SQLITE_OMIT_BETWEEN_OPTIMIZATION
550
- "OMIT_BETWEEN_OPTIMIZATION",
551
-#endif
552
-#if SQLITE_OMIT_BLOB_LITERAL
553
- "OMIT_BLOB_LITERAL",
554
-#endif
555
-#if SQLITE_OMIT_CAST
556
- "OMIT_CAST",
557
-#endif
558
-#if SQLITE_OMIT_CHECK
559
- "OMIT_CHECK",
560
-#endif
561
-#if SQLITE_OMIT_COMPLETE
562
- "OMIT_COMPLETE",
563
-#endif
564
-#if SQLITE_OMIT_COMPOUND_SELECT
565
- "OMIT_COMPOUND_SELECT",
566
-#endif
567
-#if SQLITE_OMIT_CONFLICT_CLAUSE
568
- "OMIT_CONFLICT_CLAUSE",
569
-#endif
570
-#if SQLITE_OMIT_CTE
571
- "OMIT_CTE",
572
-#endif
573
-#if defined(SQLITE_OMIT_DATETIME_FUNCS) || defined(SQLITE_OMIT_FLOATING_POINT)
574
- "OMIT_DATETIME_FUNCS",
575
-#endif
576
-#if SQLITE_OMIT_DECLTYPE
577
- "OMIT_DECLTYPE",
578
-#endif
579
-#if SQLITE_OMIT_DEPRECATED
580
- "OMIT_DEPRECATED",
581
-#endif
582
-#if SQLITE_OMIT_DESERIALIZE
583
- "OMIT_DESERIALIZE",
584
-#endif
585
-#if SQLITE_OMIT_DISKIO
586
- "OMIT_DISKIO",
587
-#endif
588
-#if SQLITE_OMIT_EXPLAIN
589
- "OMIT_EXPLAIN",
590
-#endif
591
-#if SQLITE_OMIT_FLAG_PRAGMAS
592
- "OMIT_FLAG_PRAGMAS",
593
-#endif
594
-#if SQLITE_OMIT_FLOATING_POINT
595
- "OMIT_FLOATING_POINT",
596
-#endif
597
-#if SQLITE_OMIT_FOREIGN_KEY
598
- "OMIT_FOREIGN_KEY",
599
-#endif
600
-#if SQLITE_OMIT_GET_TABLE
601
- "OMIT_GET_TABLE",
602
-#endif
603
-#if SQLITE_OMIT_HEX_INTEGER
604
- "OMIT_HEX_INTEGER",
605
-#endif
606
-#if SQLITE_OMIT_INCRBLOB
607
- "OMIT_INCRBLOB",
608
-#endif
609
-#if SQLITE_OMIT_INTEGRITY_CHECK
610
- "OMIT_INTEGRITY_CHECK",
611
-#endif
612
-#if SQLITE_OMIT_INTROSPECTION_PRAGMAS
613
- "OMIT_INTROSPECTION_PRAGMAS",
614
-#endif
615
-#if SQLITE_OMIT_LIKE_OPTIMIZATION
616
- "OMIT_LIKE_OPTIMIZATION",
617
-#endif
618
-#if SQLITE_OMIT_LOAD_EXTENSION
619
- "OMIT_LOAD_EXTENSION",
620
-#endif
621
-#if SQLITE_OMIT_LOCALTIME
622
- "OMIT_LOCALTIME",
623
-#endif
624
-#if SQLITE_OMIT_LOOKASIDE
625
- "OMIT_LOOKASIDE",
626
-#endif
627
-#if SQLITE_OMIT_MEMORYDB
628
- "OMIT_MEMORYDB",
629
-#endif
630
-#if SQLITE_OMIT_OR_OPTIMIZATION
631
- "OMIT_OR_OPTIMIZATION",
632
-#endif
633
-#if SQLITE_OMIT_PAGER_PRAGMAS
634
- "OMIT_PAGER_PRAGMAS",
635
-#endif
636
-#if SQLITE_OMIT_PARSER_TRACE
637
- "OMIT_PARSER_TRACE",
638
-#endif
639
-#if SQLITE_OMIT_POPEN
640
- "OMIT_POPEN",
641
-#endif
642
-#if SQLITE_OMIT_PRAGMA
643
- "OMIT_PRAGMA",
644
-#endif
645
-#if SQLITE_OMIT_PROGRESS_CALLBACK
646
- "OMIT_PROGRESS_CALLBACK",
647
-#endif
648
-#if SQLITE_OMIT_QUICKBALANCE
649
- "OMIT_QUICKBALANCE",
650
-#endif
651
-#if SQLITE_OMIT_REINDEX
652
- "OMIT_REINDEX",
653
-#endif
654
-#if SQLITE_OMIT_SCHEMA_PRAGMAS
655
- "OMIT_SCHEMA_PRAGMAS",
656
-#endif
657
-#if SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
658
- "OMIT_SCHEMA_VERSION_PRAGMAS",
659
-#endif
660
-#if SQLITE_OMIT_SHARED_CACHE
661
- "OMIT_SHARED_CACHE",
662
-#endif
663
-#if SQLITE_OMIT_SHUTDOWN_DIRECTORIES
664
- "OMIT_SHUTDOWN_DIRECTORIES",
665
-#endif
666
-#if SQLITE_OMIT_SUBQUERY
667
- "OMIT_SUBQUERY",
668
-#endif
669
-#if SQLITE_OMIT_TCL_VARIABLE
670
- "OMIT_TCL_VARIABLE",
671
-#endif
672
-#if SQLITE_OMIT_TEMPDB
673
- "OMIT_TEMPDB",
674
-#endif
675
-#if SQLITE_OMIT_TEST_CONTROL
676
- "OMIT_TEST_CONTROL",
677
-#endif
678
-#ifdef SQLITE_OMIT_TRACE
679
-# if SQLITE_OMIT_TRACE != 1
680
- "OMIT_TRACE=" CTIMEOPT_VAL(SQLITE_OMIT_TRACE),
681
-# endif
682
-#endif
683
-#if SQLITE_OMIT_TRIGGER
684
- "OMIT_TRIGGER",
685
-#endif
686
-#if SQLITE_OMIT_TRUNCATE_OPTIMIZATION
687
- "OMIT_TRUNCATE_OPTIMIZATION",
688
-#endif
689
-#if SQLITE_OMIT_UTF16
690
- "OMIT_UTF16",
691
-#endif
692
-#if SQLITE_OMIT_VACUUM
693
- "OMIT_VACUUM",
694
-#endif
695
-#if SQLITE_OMIT_VIEW
696
- "OMIT_VIEW",
697
-#endif
698
-#if SQLITE_OMIT_VIRTUALTABLE
699
- "OMIT_VIRTUALTABLE",
700
-#endif
701
-#if SQLITE_OMIT_WAL
702
- "OMIT_WAL",
703
-#endif
704
-#if SQLITE_OMIT_WSD
705
- "OMIT_WSD",
706
-#endif
707
-#if SQLITE_OMIT_XFER_OPT
708
- "OMIT_XFER_OPT",
709
-#endif
710
-#if SQLITE_PCACHE_SEPARATE_HEADER
711
- "PCACHE_SEPARATE_HEADER",
712
-#endif
713
-#if SQLITE_PERFORMANCE_TRACE
714
- "PERFORMANCE_TRACE",
715
-#endif
716
-#ifdef SQLITE_POWERSAFE_OVERWRITE
717
-# if SQLITE_POWERSAFE_OVERWRITE != 1
718
- "POWERSAFE_OVERWRITE=" CTIMEOPT_VAL(SQLITE_POWERSAFE_OVERWRITE),
719
-# endif
720
-#endif
721
-#if SQLITE_PREFER_PROXY_LOCKING
722
- "PREFER_PROXY_LOCKING",
723
-#endif
724
-#if SQLITE_PROXY_DEBUG
725
- "PROXY_DEBUG",
726
-#endif
727
-#if SQLITE_REVERSE_UNORDERED_SELECTS
728
- "REVERSE_UNORDERED_SELECTS",
729
-#endif
730
-#if SQLITE_RTREE_INT_ONLY
731
- "RTREE_INT_ONLY",
732
-#endif
733
-#if SQLITE_SECURE_DELETE
734
- "SECURE_DELETE",
735
-#endif
736
-#if SQLITE_SMALL_STACK
737
- "SMALL_STACK",
738
-#endif
739
-#ifdef SQLITE_SORTER_PMASZ
740
- "SORTER_PMASZ=" CTIMEOPT_VAL(SQLITE_SORTER_PMASZ),
741
-#endif
742
-#if SQLITE_SOUNDEX
743
- "SOUNDEX",
744
-#endif
745
-#ifdef SQLITE_STAT4_SAMPLES
746
- "STAT4_SAMPLES=" CTIMEOPT_VAL(SQLITE_STAT4_SAMPLES),
747
-#endif
748
-#ifdef SQLITE_STMTJRNL_SPILL
749
- "STMTJRNL_SPILL=" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL),
750
-#endif
751
-#if SQLITE_SUBSTR_COMPATIBILITY
752
- "SUBSTR_COMPATIBILITY",
753
-#endif
754
-#if (!defined(SQLITE_WIN32_MALLOC) \
755
- && !defined(SQLITE_ZERO_MALLOC) \
756
- && !defined(SQLITE_MEMDEBUG) \
757
- ) || defined(SQLITE_SYSTEM_MALLOC)
758
- "SYSTEM_MALLOC",
759
-#endif
760
-#if SQLITE_TCL
761
- "TCL",
762
-#endif
763
-#ifdef SQLITE_TEMP_STORE
764
- "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE),
765
-#endif
766
-#if SQLITE_TEST
767
- "TEST",
768
-#endif
769
-#if defined(SQLITE_THREADSAFE)
770
- "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
771
-#elif defined(THREADSAFE)
772
- "THREADSAFE=" CTIMEOPT_VAL(THREADSAFE),
773
-#else
774
- "THREADSAFE=1",
775
-#endif
776
-#if SQLITE_UNLINK_AFTER_CLOSE
777
- "UNLINK_AFTER_CLOSE",
778
-#endif
779
-#if SQLITE_UNTESTABLE
780
- "UNTESTABLE",
781
-#endif
782
-#if SQLITE_USER_AUTHENTICATION
783
- "USER_AUTHENTICATION",
784
-#endif
785
-#if SQLITE_USE_ALLOCA
786
- "USE_ALLOCA",
787
-#endif
788
-#if SQLITE_USE_FCNTL_TRACE
789
- "USE_FCNTL_TRACE",
790
-#endif
791
-#if SQLITE_USE_URI
792
- "USE_URI",
793
-#endif
794
-#if SQLITE_VDBE_COVERAGE
795
- "VDBE_COVERAGE",
796
-#endif
797
-#if SQLITE_WIN32_MALLOC
798
- "WIN32_MALLOC",
799
-#endif
800
-#if SQLITE_ZERO_MALLOC
801
- "ZERO_MALLOC",
802
-#endif
803
-/*
804
-** END CODE GENERATED BY tool/mkctime.tcl
805
-*/
806
-};
807
-
808
-SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){
809
- *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]);
810
- return (const char**)sqlite3azCompileOpt;
811
-}
812
-
813
-#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
814
-
815
-/************** End of ctime.c ***********************************************/
31
/************** Begin file sqliteInt.h ***************************************/
32
/*
33
** 2001 September 15
@@ -1078,6 +293,17 @@ SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){
293
# define _USE_32BIT_TIME_T
294
#endif
295
296
+/* Optionally #include a user-defined header, whereby compilation options
297
+** may be set prior to where they take effect, but after platform setup.
298
+** If SQLITE_CUSTOM_INCLUDE=? is defined, its value names the #include
299
+** file.
300
+*/
301
+#ifdef SQLITE_CUSTOM_INCLUDE
302
+# define INC_STRINGIFY_(f) #f
303
+# define INC_STRINGIFY(f) INC_STRINGIFY_(f)
304
+# include INC_STRINGIFY(SQLITE_CUSTOM_INCLUDE)
305
+#endif
306
+
307
/* The public SQLite interface. The _FILE_OFFSET_BITS macro must appear
308
** first in QNX. Also, the _USE_32BIT_TIME_T macro must appear first for
309
** MinGW.
@@ -1129,7 +355,30 @@ extern "C" {
355
356
357
/*
1132
-** Provide the ability to override linkage features of the interface.
358
+** Facilitate override of interface linkage and calling conventions.
359
+** Be aware that these macros may not be used within this particular
360
+** translation of the amalgamation and its associated header file.
361
+**
362
+** The SQLITE_EXTERN and SQLITE_API macros are used to instruct the
363
+** compiler that the target identifier should have external linkage.
364
+**
365
+** The SQLITE_CDECL macro is used to set the calling convention for
366
+** public functions that accept a variable number of arguments.
367
+**
368
+** The SQLITE_APICALL macro is used to set the calling convention for
369
+** public functions that accept a fixed number of arguments.
370
+**
371
+** The SQLITE_STDCALL macro is no longer used and is now deprecated.
372
+**
373
+** The SQLITE_CALLBACK macro is used to set the calling convention for
374
+** function pointers.
375
+**
376
+** The SQLITE_SYSAPI macro is used to set the calling convention for
377
+** functions provided by the operating system.
378
+**
379
+** Currently, the SQLITE_CDECL, SQLITE_APICALL, SQLITE_CALLBACK, and
380
+** SQLITE_SYSAPI macros are used only when building for environments
381
+** that require non-default calling conventions.
382
*/
383
#ifndef SQLITE_EXTERN
384
# define SQLITE_EXTERN extern
@@ -1209,9 +458,9 @@ extern "C" {
458
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
459
** [sqlite_version()] and [sqlite_source_id()].
460
*/
1212
-#define SQLITE_VERSION "3.36.0"
1213
-#define SQLITE_VERSION_NUMBER 3036000
1214
-#define SQLITE_SOURCE_ID "2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafa66e5"
461
+#define SQLITE_VERSION "3.38.5"
462
+#define SQLITE_VERSION_NUMBER 3038005
463
+#define SQLITE_SOURCE_ID "2022-05-06 15:25:27 78d9c993d404cdfaa7fdd2973fa1052e3da9f66215cff9c5540ebe55c407d9fe"
464
465
/*
466
** CAPI3REF: Run-Time Library Version Numbers
@@ -1623,12 +872,13 @@ SQLITE_API int sqlite3_exec(
872
#define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8))
873
#define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8))
874
#define SQLITE_CONSTRAINT_PINNED (SQLITE_CONSTRAINT |(11<<8))
875
+#define SQLITE_CONSTRAINT_DATATYPE (SQLITE_CONSTRAINT |(12<<8))
876
#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
877
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
878
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
879
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
880
#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
1631
-#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8))
881
+#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal use only */
882
883
/*
884
** CAPI3REF: Flags For File Open Operations
@@ -1636,6 +886,19 @@ SQLITE_API int sqlite3_exec(
886
** These bit values are intended for use in the
887
** 3rd parameter to the [sqlite3_open_v2()] interface and
888
** in the 4th parameter to the [sqlite3_vfs.xOpen] method.
889
+**
890
+** Only those flags marked as "Ok for sqlite3_open_v2()" may be
891
+** used as the third argument to the [sqlite3_open_v2()] interface.
892
+** The other flags have historically been ignored by sqlite3_open_v2(),
893
+** though future versions of SQLite might change so that an error is
894
+** raised if any of the disallowed bits are passed into sqlite3_open_v2().
895
+** Applications should not depend on the historical behavior.
896
+**
897
+** Note in particular that passing the SQLITE_OPEN_EXCLUSIVE flag into
898
+** [sqlite3_open_v2()] does *not* cause the underlying database file
899
+** to be opened using O_EXCL. Passing SQLITE_OPEN_EXCLUSIVE into
900
+** [sqlite3_open_v2()] has historically be a no-op and might become an
901
+** error in future versions of SQLite.
902
*/
903
#define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */
904
#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */
@@ -1658,6 +921,7 @@ SQLITE_API int sqlite3_exec(
921
#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
922
#define SQLITE_OPEN_WAL 0x00080000 /* VFS only */
923
#define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */
924
+#define SQLITE_OPEN_EXRESCODE 0x02000000 /* Extended result codes */
925
926
/* Reserved: 0x00F00000 */
927
/* Legacy compatibility: */
@@ -3550,11 +2814,14 @@ SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);
2814
** CAPI3REF: Count The Number Of Rows Modified
2815
** METHOD: sqlite3
2816
**
3553
-** ^This function returns the number of rows modified, inserted or
2817
+** ^These functions return the number of rows modified, inserted or
2818
** deleted by the most recently completed INSERT, UPDATE or DELETE
2819
** statement on the database connection specified by the only parameter.
3556
-** ^Executing any other type of SQL statement does not modify the value
3557
-** returned by this function.
2820
+** The two functions are identical except for the type of the return value
2821
+** and that if the number of rows modified by the most recent INSERT, UPDATE
2822
+** or DELETE is greater than the maximum value supported by type "int", then
2823
+** the return value of sqlite3_changes() is undefined. ^Executing any other
2824
+** type of SQL statement does not modify the value returned by these functions.
2825
**
2826
** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
2827
** considered - auxiliary changes caused by [CREATE TRIGGER | triggers],
@@ -3603,16 +2870,21 @@ SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);
2870
** </ul>
2871
*/
2872
SQLITE_API int sqlite3_changes(sqlite3*);
2873
+SQLITE_API sqlite3_int64 sqlite3_changes64(sqlite3*);
2874
2875
/*
2876
** CAPI3REF: Total Number Of Rows Modified
2877
** METHOD: sqlite3
2878
**
3611
-** ^This function returns the total number of rows inserted, modified or
2879
+** ^These functions return the total number of rows inserted, modified or
2880
** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
2881
** since the database connection was opened, including those executed as
3614
-** part of trigger programs. ^Executing any other type of SQL statement
3615
-** does not affect the value returned by sqlite3_total_changes().
2882
+** part of trigger programs. The two functions are identical except for the
2883
+** type of the return value and that if the number of rows modified by the
2884
+** connection exceeds the maximum value supported by type "int", then
2885
+** the return value of sqlite3_total_changes() is undefined. ^Executing
2886
+** any other type of SQL statement does not affect the value returned by
2887
+** sqlite3_total_changes().
2888
**
2889
** ^Changes made as part of [foreign key actions] are included in the
2890
** count, but those made as part of REPLACE constraint resolution are
@@ -3640,6 +2912,7 @@ SQLITE_API int sqlite3_changes(sqlite3*);
2912
** </ul>
2913
*/
2914
SQLITE_API int sqlite3_total_changes(sqlite3*);
2915
+SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3*);
2916
2917
/*
2918
** CAPI3REF: Interrupt A Long-Running Query
@@ -4469,6 +3742,14 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3742
** the default shared cache setting provided by
3743
** [sqlite3_enable_shared_cache()].)^
3744
**
3745
+** [[OPEN_EXRESCODE]] ^(<dt>[SQLITE_OPEN_EXRESCODE]</dt>
3746
+** <dd>The database connection comes up in "extended result code mode".
3747
+** In other words, the database behaves has if
3748
+** [sqlite3_extended_result_codes(db,1)] where called on the database
3749
+** connection as soon as the connection is created. In addition to setting
3750
+** the extended result code mode, this flag also causes [sqlite3_open_v2()]
3751
+** to return an extended result code.</dd>
3752
+**
3753
** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt>
3754
** <dd>The database filename is not allowed to be a symbolic link</dd>
3755
** </dl>)^
@@ -4476,7 +3757,15 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3757
** If the 3rd parameter to sqlite3_open_v2() is not one of the
3758
** required combinations shown above optionally combined with other
3759
** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]
4479
-** then the behavior is undefined.
3760
+** then the behavior is undefined. Historic versions of SQLite
3761
+** have silently ignored surplus bits in the flags parameter to
3762
+** sqlite3_open_v2(), however that behavior might not be carried through
3763
+** into future versions of SQLite and so applications should not rely
3764
+** upon it. Note in particular that the SQLITE_OPEN_EXCLUSIVE flag is a no-op
3765
+** for sqlite3_open_v2(). The SQLITE_OPEN_EXCLUSIVE does *not* cause
3766
+** the open to fail if the database already exists. The SQLITE_OPEN_EXCLUSIVE
3767
+** flag is intended for use by the [sqlite3_vfs|VFS interface] only, and not
3768
+** by sqlite3_open_v2().
3769
**
3770
** ^The fourth parameter to sqlite3_open_v2() is the name of the
3771
** [sqlite3_vfs] object that defines the operating system interface that
@@ -4847,13 +4136,14 @@ SQLITE_API void sqlite3_free_filename(char*);
4136
** sqlite3_extended_errcode() might change with each API call.
4137
** Except, there are some interfaces that are guaranteed to never
4138
** change the value of the error code. The error-code preserving
4850
-** interfaces are:
4139
+** interfaces include the following:
4140
**
4141
** <ul>
4142
** <li> sqlite3_errcode()
4143
** <li> sqlite3_extended_errcode()
4144
** <li> sqlite3_errmsg()
4145
** <li> sqlite3_errmsg16()
4146
+** <li> sqlite3_error_offset()
4147
** </ul>
4148
**
4149
** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
@@ -4868,6 +4158,13 @@ SQLITE_API void sqlite3_free_filename(char*);
4158
** ^(Memory to hold the error message string is managed internally
4159
** and must not be freed by the application)^.
4160
**
4161
+** ^If the most recent error references a specific token in the input
4162
+** SQL, the sqlite3_error_offset() interface returns the byte offset
4163
+** of the start of that token. ^The byte offset returned by
4164
+** sqlite3_error_offset() assumes that the input SQL is UTF8.
4165
+** ^If the most recent error does not reference a specific token in the input
4166
+** SQL, then the sqlite3_error_offset() function returns -1.
4167
+**
4168
** When the serialized [threading mode] is in use, it might be the
4169
** case that a second error occurs on a separate thread in between
4170
** the time of the first error and the call to these interfaces.
@@ -4887,6 +4184,7 @@ SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
4184
SQLITE_API const char *sqlite3_errmsg(sqlite3*);
4185
SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
4186
SQLITE_API const char *sqlite3_errstr(int);
4187
+SQLITE_API int sqlite3_error_offset(sqlite3 *db);
4188
4189
/*
4190
** CAPI3REF: Prepared Statement Object
@@ -5244,12 +4542,17 @@ SQLITE_API int sqlite3_prepare16_v3(
4542
** are managed by SQLite and are automatically freed when the prepared
4543
** statement is finalized.
4544
** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
5247
-** is obtained from [sqlite3_malloc()] and must be free by the application
4545
+** is obtained from [sqlite3_malloc()] and must be freed by the application
4546
** by passing it to [sqlite3_free()].
4547
+**
4548
+** ^The sqlite3_normalized_sql() interface is only available if
4549
+** the [SQLITE_ENABLE_NORMALIZE] compile-time option is defined.
4550
*/
4551
SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
4552
SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);
4553
+#ifdef SQLITE_ENABLE_NORMALIZE
4554
SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
4555
+#endif
4556
4557
/*
4558
** CAPI3REF: Determine If An SQL Statement Writes The Database
@@ -5293,6 +4596,10 @@ SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
4596
** be false. ^Similarly, a CREATE TABLE IF NOT EXISTS statement is a
4597
** read-only no-op if the table already exists, but
4598
** sqlite3_stmt_readonly() still returns false for such a statement.
4599
+**
4600
+** ^If prepared statement X is an [EXPLAIN] or [EXPLAIN QUERY PLAN]
4601
+** statement, then sqlite3_stmt_readonly(X) returns the same value as
4602
+** if the EXPLAIN or EXPLAIN QUERY PLAN prefix were omitted.
4603
*/
4604
SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
4605
@@ -5361,6 +4668,8 @@ SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
4668
**
4669
** ^The sqlite3_value objects that are passed as parameters into the
4670
** implementation of [application-defined SQL functions] are protected.
4671
+** ^The sqlite3_value objects returned by [sqlite3_vtab_rhs_value()]
4672
+** are protected.
4673
** ^The sqlite3_value object returned by
4674
** [sqlite3_column_value()] is unprotected.
4675
** Unprotected sqlite3_value objects may only be used as arguments
@@ -5982,6 +5291,10 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
5291
** even empty strings, are always zero-terminated. ^The return
5292
** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
5293
**
5294
+** ^Strings returned by sqlite3_column_text16() always have the endianness
5295
+** which is native to the platform, regardless of the text encoding set
5296
+** for the database.
5297
+**
5298
** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
5299
** [unprotected sqlite3_value] object. In a multithreaded environment,
5300
** an unprotected sqlite3_value object may only be used safely with
@@ -5995,7 +5308,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
5308
** [application-defined SQL functions] or [virtual tables], not within
5309
** top-level application code.
5310
**
5998
-** The these routines may attempt to convert the datatype of the result.
5311
+** These routines may attempt to convert the datatype of the result.
5312
** ^For example, if the internal representation is FLOAT and a text result
5313
** is requested, [sqlite3_snprintf()] is used internally to perform the
5314
** conversion automatically. ^(The following table details the conversions
@@ -6020,7 +5333,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
5333
** <tr><td> TEXT <td> BLOB <td> No change
5334
** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
5335
** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
6023
-** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
5336
+** <tr><td> BLOB <td> TEXT <td> [CAST] to TEXT, ensure zero terminator
5337
** </table>
5338
** </blockquote>)^
5339
**
@@ -7433,6 +6746,72 @@ SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
6746
SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
6747
SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
6748
6749
+/*
6750
+** CAPI3REF: Autovacuum Compaction Amount Callback
6751
+** METHOD: sqlite3
6752
+**
6753
+** ^The sqlite3_autovacuum_pages(D,C,P,X) interface registers a callback
6754
+** function C that is invoked prior to each autovacuum of the database
6755
+** file. ^The callback is passed a copy of the generic data pointer (P),
6756
+** the schema-name of the attached database that is being autovacuumed,
6757
+** the the size of the database file in pages, the number of free pages,
6758
+** and the number of bytes per page, respectively. The callback should
6759
+** return the number of free pages that should be removed by the
6760
+** autovacuum. ^If the callback returns zero, then no autovacuum happens.
6761
+** ^If the value returned is greater than or equal to the number of
6762
+** free pages, then a complete autovacuum happens.
6763
+**
6764
+** <p>^If there are multiple ATTACH-ed database files that are being
6765
+** modified as part of a transaction commit, then the autovacuum pages
6766
+** callback is invoked separately for each file.
6767
+**
6768
+** <p><b>The callback is not reentrant.</b> The callback function should
6769
+** not attempt to invoke any other SQLite interface. If it does, bad
6770
+** things may happen, including segmentation faults and corrupt database
6771
+** files. The callback function should be a simple function that
6772
+** does some arithmetic on its input parameters and returns a result.
6773
+**
6774
+** ^The X parameter to sqlite3_autovacuum_pages(D,C,P,X) is an optional
6775
+** destructor for the P parameter. ^If X is not NULL, then X(P) is
6776
+** invoked whenever the database connection closes or when the callback
6777
+** is overwritten by another invocation of sqlite3_autovacuum_pages().
6778
+**
6779
+** <p>^There is only one autovacuum pages callback per database connection.
6780
+** ^Each call to the sqlite3_autovacuum_pages() interface overrides all
6781
+** previous invocations for that database connection. ^If the callback
6782
+** argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer,
6783
+** then the autovacuum steps callback is cancelled. The return value
6784
+** from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might
6785
+** be some other error code if something goes wrong. The current
6786
+** implementation will only return SQLITE_OK or SQLITE_MISUSE, but other
6787
+** return codes might be added in future releases.
6788
+**
6789
+** <p>If no autovacuum pages callback is specified (the usual case) or
6790
+** a NULL pointer is provided for the callback,
6791
+** then the default behavior is to vacuum all free pages. So, in other
6792
+** words, the default behavior is the same as if the callback function
6793
+** were something like this:
6794
+**
6795
+** <blockquote><pre>
6796
+** unsigned int demonstration_autovac_pages_callback(
6797
+** void *pClientData,
6798
+** const char *zSchema,
6799
+** unsigned int nDbPage,
6800
+** unsigned int nFreePage,
6801
+** unsigned int nBytePerPage
6802
+** ){
6803
+** return nFreePage;
6804
+** }
6805
+** </pre></blockquote>
6806
+*/
6807
+SQLITE_API int sqlite3_autovacuum_pages(
6808
+ sqlite3 *db,
6809
+ unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int),
6810
+ void*,
6811
+ void(*)(void*)
6812
+);
6813
+
6814
+
6815
/*
6816
** CAPI3REF: Data Change Notification Callbacks
6817
** METHOD: sqlite3
@@ -8074,24 +7453,56 @@ struct sqlite3_index_info {
7453
**
7454
** These macros define the allowed values for the
7455
** [sqlite3_index_info].aConstraint[].op field. Each value represents
8077
-** an operator that is part of a constraint term in the wHERE clause of
7456
+** an operator that is part of a constraint term in the WHERE clause of
7457
** a query that uses a [virtual table].
8079
-*/
8080
-#define SQLITE_INDEX_CONSTRAINT_EQ 2
8081
-#define SQLITE_INDEX_CONSTRAINT_GT 4
8082
-#define SQLITE_INDEX_CONSTRAINT_LE 8
8083
-#define SQLITE_INDEX_CONSTRAINT_LT 16
8084
-#define SQLITE_INDEX_CONSTRAINT_GE 32
8085
-#define SQLITE_INDEX_CONSTRAINT_MATCH 64
8086
-#define SQLITE_INDEX_CONSTRAINT_LIKE 65
8087
-#define SQLITE_INDEX_CONSTRAINT_GLOB 66
8088
-#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
8089
-#define SQLITE_INDEX_CONSTRAINT_NE 68
8090
-#define SQLITE_INDEX_CONSTRAINT_ISNOT 69
8091
-#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
8092
-#define SQLITE_INDEX_CONSTRAINT_ISNULL 71
8093
-#define SQLITE_INDEX_CONSTRAINT_IS 72
8094
-#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
7458
+**
7459
+** ^The left-hand operand of the operator is given by the corresponding
7460
+** aConstraint[].iColumn field. ^An iColumn of -1 indicates the left-hand
7461
+** operand is the rowid.
7462
+** The SQLITE_INDEX_CONSTRAINT_LIMIT and SQLITE_INDEX_CONSTRAINT_OFFSET
7463
+** operators have no left-hand operand, and so for those operators the
7464
+** corresponding aConstraint[].iColumn is meaningless and should not be
7465
+** used.
7466
+**
7467
+** All operator values from SQLITE_INDEX_CONSTRAINT_FUNCTION through
7468
+** value 255 are reserved to represent functions that are overloaded
7469
+** by the [xFindFunction|xFindFunction method] of the virtual table
7470
+** implementation.
7471
+**
7472
+** The right-hand operands for each constraint might be accessible using
7473
+** the [sqlite3_vtab_rhs_value()] interface. Usually the right-hand
7474
+** operand is only available if it appears as a single constant literal
7475
+** in the input SQL. If the right-hand operand is another column or an
7476
+** expression (even a constant expression) or a parameter, then the
7477
+** sqlite3_vtab_rhs_value() probably will not be able to extract it.
7478
+** ^The SQLITE_INDEX_CONSTRAINT_ISNULL and
7479
+** SQLITE_INDEX_CONSTRAINT_ISNOTNULL operators have no right-hand operand
7480
+** and hence calls to sqlite3_vtab_rhs_value() for those operators will
7481
+** always return SQLITE_NOTFOUND.
7482
+**
7483
+** The collating sequence to be used for comparison can be found using
7484
+** the [sqlite3_vtab_collation()] interface. For most real-world virtual
7485
+** tables, the collating sequence of constraints does not matter (for example
7486
+** because the constraints are numeric) and so the sqlite3_vtab_collation()
7487
+** interface is no commonly needed.
7488
+*/
7489
+#define SQLITE_INDEX_CONSTRAINT_EQ 2
7490
+#define SQLITE_INDEX_CONSTRAINT_GT 4
7491
+#define SQLITE_INDEX_CONSTRAINT_LE 8
7492
+#define SQLITE_INDEX_CONSTRAINT_LT 16
7493
+#define SQLITE_INDEX_CONSTRAINT_GE 32
7494
+#define SQLITE_INDEX_CONSTRAINT_MATCH 64
7495
+#define SQLITE_INDEX_CONSTRAINT_LIKE 65
7496
+#define SQLITE_INDEX_CONSTRAINT_GLOB 66
7497
+#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
7498
+#define SQLITE_INDEX_CONSTRAINT_NE 68
7499
+#define SQLITE_INDEX_CONSTRAINT_ISNOT 69
7500
+#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
7501
+#define SQLITE_INDEX_CONSTRAINT_ISNULL 71
7502
+#define SQLITE_INDEX_CONSTRAINT_IS 72
7503
+#define SQLITE_INDEX_CONSTRAINT_LIMIT 73
7504
+#define SQLITE_INDEX_CONSTRAINT_OFFSET 74
7505
+#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
7506
7507
/*
7508
** CAPI3REF: Register A Virtual Table Implementation
@@ -8120,7 +7531,7 @@ struct sqlite3_index_info {
7531
** destructor.
7532
**
7533
** ^If the third parameter (the pointer to the sqlite3_module object) is
8123
-** NULL then no new module is create and any existing modules with the
7534
+** NULL then no new module is created and any existing modules with the
7535
** same name are dropped.
7536
**
7537
** See also: [sqlite3_drop_modules()]
@@ -8896,7 +8307,8 @@ SQLITE_API int sqlite3_test_control(int op, ...);
8307
#define SQLITE_TESTCTRL_SEEK_COUNT 30
8308
#define SQLITE_TESTCTRL_TRACEFLAGS 31
8309
#define SQLITE_TESTCTRL_TUNE 32
8899
-#define SQLITE_TESTCTRL_LAST 32 /* Largest TESTCTRL */
8310
+#define SQLITE_TESTCTRL_LOGEST 33
8311
+#define SQLITE_TESTCTRL_LAST 33 /* Largest TESTCTRL */
8312
8313
/*
8314
** CAPI3REF: SQL Keyword Checking
@@ -9419,6 +8831,16 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
8831
** The counter is incremented on the first [sqlite3_step()] call of each
8832
** cycle.
8833
**
8834
+** [[SQLITE_STMTSTATUS_FILTER_MISS]]
8835
+** [[SQLITE_STMTSTATUS_FILTER HIT]]
8836
+** <dt>SQLITE_STMTSTATUS_FILTER_HIT<br>
8837
+** SQLITE_STMTSTATUS_FILTER_MISS</dt>
8838
+** <dd>^SQLITE_STMTSTATUS_FILTER_HIT is the number of times that a join
8839
+** step was bypassed because a Bloom filter returned not-found. The
8840
+** corresponding SQLITE_STMTSTATUS_FILTER_MISS value is the number of
8841
+** times that the Bloom filter returned a find, and thus the join step
8842
+** had to be processed as normal.
8843
+**
8844
** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
8845
** <dd>^This is the approximate number of bytes of heap memory
8846
** used to store the prepared statement. ^This value is not actually
@@ -9433,6 +8855,8 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
8855
#define SQLITE_STMTSTATUS_VM_STEP 4
8856
#define SQLITE_STMTSTATUS_REPREPARE 5
8857
#define SQLITE_STMTSTATUS_RUN 6
8858
+#define SQLITE_STMTSTATUS_FILTER_MISS 7
8859
+#define SQLITE_STMTSTATUS_FILTER_HIT 8
8860
#define SQLITE_STMTSTATUS_MEMUSED 99
8861
8862
/*
@@ -10096,8 +9520,9 @@ SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
9520
**
9521
** A single database handle may have at most a single write-ahead log callback
9522
** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any
10099
-** previously registered write-ahead log callback. ^Note that the
10100
-** [sqlite3_wal_autocheckpoint()] interface and the
9523
+** previously registered write-ahead log callback. ^The return value is
9524
+** a copy of the third parameter from the previous call, if any, or 0.
9525
+** ^Note that the [sqlite3_wal_autocheckpoint()] interface and the
9526
** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
9527
** overwrite any prior [sqlite3_wal_hook()] settings.
9528
*/
@@ -10400,19 +9825,269 @@ SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);
9825
9826
/*
9827
** CAPI3REF: Determine The Collation For a Virtual Table Constraint
9828
+** METHOD: sqlite3_index_info
9829
**
9830
** This function may only be called from within a call to the [xBestIndex]
10405
-** method of a [virtual table].
9831
+** method of a [virtual table]. This function returns a pointer to a string
9832
+** that is the name of the appropriate collation sequence to use for text
9833
+** comparisons on the constraint identified by its arguments.
9834
+**
9835
+** The first argument must be the pointer to the [sqlite3_index_info] object
9836
+** that is the first parameter to the xBestIndex() method. The second argument
9837
+** must be an index into the aConstraint[] array belonging to the
9838
+** sqlite3_index_info structure passed to xBestIndex.
9839
+**
9840
+** Important:
9841
+** The first parameter must be the same pointer that is passed into the
9842
+** xBestMethod() method. The first parameter may not be a pointer to a
9843
+** different [sqlite3_index_info] object, even an exact copy.
9844
**
10407
-** The first argument must be the sqlite3_index_info object that is the
10408
-** first parameter to the xBestIndex() method. The second argument must be
10409
-** an index into the aConstraint[] array belonging to the sqlite3_index_info
10410
-** structure passed to xBestIndex. This function returns a pointer to a buffer
10411
-** containing the name of the collation sequence for the corresponding
10412
-** constraint.
9845
+** The return value is computed as follows:
9846
+**
9847
+** <ol>
9848
+** <li><p> If the constraint comes from a WHERE clause expression that contains
9849
+** a [COLLATE operator], then the name of the collation specified by
9850
+** that COLLATE operator is returned.
9851
+** <li><p> If there is no COLLATE operator, but the column that is the subject
9852
+** of the constraint specifies an alternative collating sequence via
9853
+** a [COLLATE clause] on the column definition within the CREATE TABLE
9854
+** statement that was passed into [sqlite3_declare_vtab()], then the
9855
+** name of that alternative collating sequence is returned.
9856
+** <li><p> Otherwise, "BINARY" is returned.
9857
+** </ol>
9858
*/
9859
SQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
9860
9861
+/*
9862
+** CAPI3REF: Determine if a virtual table query is DISTINCT
9863
+** METHOD: sqlite3_index_info
9864
+**
9865
+** This API may only be used from within an [xBestIndex|xBestIndex method]
9866
+** of a [virtual table] implementation. The result of calling this
9867
+** interface from outside of xBestIndex() is undefined and probably harmful.
9868
+**
9869
+** ^The sqlite3_vtab_distinct() interface returns an integer that is
9870
+** either 0, 1, or 2. The integer returned by sqlite3_vtab_distinct()
9871
+** gives the virtual table additional information about how the query
9872
+** planner wants the output to be ordered. As long as the virtual table
9873
+** can meet the ordering requirements of the query planner, it may set
9874
+** the "orderByConsumed" flag.
9875
+**
9876
+** <ol><li value="0"><p>
9877
+** ^If the sqlite3_vtab_distinct() interface returns 0, that means
9878
+** that the query planner needs the virtual table to return all rows in the
9879
+** sort order defined by the "nOrderBy" and "aOrderBy" fields of the
9880
+** [sqlite3_index_info] object. This is the default expectation. If the
9881
+** virtual table outputs all rows in sorted order, then it is always safe for
9882
+** the xBestIndex method to set the "orderByConsumed" flag, regardless of
9883
+** the return value from sqlite3_vtab_distinct().
9884
+** <li value="1"><p>
9885
+** ^(If the sqlite3_vtab_distinct() interface returns 1, that means
9886
+** that the query planner does not need the rows to be returned in sorted order
9887
+** as long as all rows with the same values in all columns identified by the
9888
+** "aOrderBy" field are adjacent.)^ This mode is used when the query planner
9889
+** is doing a GROUP BY.
9890
+** <li value="2"><p>
9891
+** ^(If the sqlite3_vtab_distinct() interface returns 2, that means
9892
+** that the query planner does not need the rows returned in any particular
9893
+** order, as long as rows with the same values in all "aOrderBy" columns
9894
+** are adjacent.)^ ^(Furthermore, only a single row for each particular
9895
+** combination of values in the columns identified by the "aOrderBy" field
9896
+** needs to be returned.)^ ^It is always ok for two or more rows with the same
9897
+** values in all "aOrderBy" columns to be returned, as long as all such rows
9898
+** are adjacent. ^The virtual table may, if it chooses, omit extra rows
9899
+** that have the same value for all columns identified by "aOrderBy".
9900
+** ^However omitting the extra rows is optional.
9901
+** This mode is used for a DISTINCT query.
9902
+** </ol>
9903
+**
9904
+** ^For the purposes of comparing virtual table output values to see if the
9905
+** values are same value for sorting purposes, two NULL values are considered
9906
+** to be the same. In other words, the comparison operator is "IS"
9907
+** (or "IS NOT DISTINCT FROM") and not "==".
9908
+**
9909
+** If a virtual table implementation is unable to meet the requirements
9910
+** specified above, then it must not set the "orderByConsumed" flag in the
9911
+** [sqlite3_index_info] object or an incorrect answer may result.
9912
+**
9913
+** ^A virtual table implementation is always free to return rows in any order
9914
+** it wants, as long as the "orderByConsumed" flag is not set. ^When the
9915
+** the "orderByConsumed" flag is unset, the query planner will add extra
9916
+** [bytecode] to ensure that the final results returned by the SQL query are
9917
+** ordered correctly. The use of the "orderByConsumed" flag and the
9918
+** sqlite3_vtab_distinct() interface is merely an optimization. ^Careful
9919
+** use of the sqlite3_vtab_distinct() interface and the "orderByConsumed"
9920
+** flag might help queries against a virtual table to run faster. Being
9921
+** overly aggressive and setting the "orderByConsumed" flag when it is not
9922
+** valid to do so, on the other hand, might cause SQLite to return incorrect
9923
+** results.
9924
+*/
9925
+SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info*);
9926
+
9927
+/*
9928
+** CAPI3REF: Identify and handle IN constraints in xBestIndex
9929
+**
9930
+** This interface may only be used from within an
9931
+** [xBestIndex|xBestIndex() method] of a [virtual table] implementation.
9932
+** The result of invoking this interface from any other context is
9933
+** undefined and probably harmful.
9934
+**
9935
+** ^(A constraint on a virtual table of the form
9936
+** "[IN operator|column IN (...)]" is
9937
+** communicated to the xBestIndex method as a
9938
+** [SQLITE_INDEX_CONSTRAINT_EQ] constraint.)^ If xBestIndex wants to use
9939
+** this constraint, it must set the corresponding
9940
+** aConstraintUsage[].argvIndex to a postive integer. ^(Then, under
9941
+** the usual mode of handling IN operators, SQLite generates [bytecode]
9942
+** that invokes the [xFilter|xFilter() method] once for each value
9943
+** on the right-hand side of the IN operator.)^ Thus the virtual table
9944
+** only sees a single value from the right-hand side of the IN operator
9945
+** at a time.
9946
+**
9947
+** In some cases, however, it would be advantageous for the virtual
9948
+** table to see all values on the right-hand of the IN operator all at
9949
+** once. The sqlite3_vtab_in() interfaces facilitates this in two ways:
9950
+**
9951
+** <ol>
9952
+** <li><p>
9953
+** ^A call to sqlite3_vtab_in(P,N,-1) will return true (non-zero)
9954
+** if and only if the [sqlite3_index_info|P->aConstraint][N] constraint
9955
+** is an [IN operator] that can be processed all at once. ^In other words,
9956
+** sqlite3_vtab_in() with -1 in the third argument is a mechanism
9957
+** by which the virtual table can ask SQLite if all-at-once processing
9958
+** of the IN operator is even possible.
9959
+**
9960
+** <li><p>
9961
+** ^A call to sqlite3_vtab_in(P,N,F) with F==1 or F==0 indicates
9962
+** to SQLite that the virtual table does or does not want to process
9963
+** the IN operator all-at-once, respectively. ^Thus when the third
9964
+** parameter (F) is non-negative, this interface is the mechanism by
9965
+** which the virtual table tells SQLite how it wants to process the
9966
+** IN operator.
9967
+** </ol>
9968
+**
9969
+** ^The sqlite3_vtab_in(P,N,F) interface can be invoked multiple times
9970
+** within the same xBestIndex method call. ^For any given P,N pair,
9971
+** the return value from sqlite3_vtab_in(P,N,F) will always be the same
9972
+** within the same xBestIndex call. ^If the interface returns true
9973
+** (non-zero), that means that the constraint is an IN operator
9974
+** that can be processed all-at-once. ^If the constraint is not an IN
9975
+** operator or cannot be processed all-at-once, then the interface returns
9976
+** false.
9977
+**
9978
+** ^(All-at-once processing of the IN operator is selected if both of the
9979
+** following conditions are met:
9980
+**
9981
+** <ol>
9982
+** <li><p> The P->aConstraintUsage[N].argvIndex value is set to a positive
9983
+** integer. This is how the virtual table tells SQLite that it wants to
9984
+** use the N-th constraint.
9985
+**
9986
+** <li><p> The last call to sqlite3_vtab_in(P,N,F) for which F was
9987
+** non-negative had F>=1.
9988
+** </ol>)^
9989
+**
9990
+** ^If either or both of the conditions above are false, then SQLite uses
9991
+** the traditional one-at-a-time processing strategy for the IN constraint.
9992
+** ^If both conditions are true, then the argvIndex-th parameter to the
9993
+** xFilter method will be an [sqlite3_value] that appears to be NULL,
9994
+** but which can be passed to [sqlite3_vtab_in_first()] and
9995
+** [sqlite3_vtab_in_next()] to find all values on the right-hand side
9996
+** of the IN constraint.
9997
+*/
9998
+SQLITE_API int sqlite3_vtab_in(sqlite3_index_info*, int iCons, int bHandle);
9999
+
10000
+/*
10001
+** CAPI3REF: Find all elements on the right-hand side of an IN constraint.
10002
+**
10003
+** These interfaces are only useful from within the
10004
+** [xFilter|xFilter() method] of a [virtual table] implementation.
10005
+** The result of invoking these interfaces from any other context
10006
+** is undefined and probably harmful.
10007
+**
10008
+** The X parameter in a call to sqlite3_vtab_in_first(X,P) or
10009
+** sqlite3_vtab_in_next(X,P) must be one of the parameters to the
10010
+** xFilter method which invokes these routines, and specifically
10011
+** a parameter that was previously selected for all-at-once IN constraint
10012
+** processing use the [sqlite3_vtab_in()] interface in the
10013
+** [xBestIndex|xBestIndex method]. ^(If the X parameter is not
10014
+** an xFilter argument that was selected for all-at-once IN constraint
10015
+** processing, then these routines return [SQLITE_MISUSE])^ or perhaps
10016
+** exhibit some other undefined or harmful behavior.
10017
+**
10018
+** ^(Use these routines to access all values on the right-hand side
10019
+** of the IN constraint using code like the following:
10020
+**
10021
+** <blockquote><pre>
10022
+** for(rc=sqlite3_vtab_in_first(pList, &pVal);
10023
+** rc==SQLITE_OK && pVal
10024
+** rc=sqlite3_vtab_in_next(pList, &pVal)
10025
+** ){
10026
+** // do something with pVal
10027
+** }
10028
+** if( rc!=SQLITE_OK ){
10029
+** // an error has occurred
10030
+** }
10031
+** </pre></blockquote>)^
10032
+**
10033
+** ^On success, the sqlite3_vtab_in_first(X,P) and sqlite3_vtab_in_next(X,P)
10034
+** routines return SQLITE_OK and set *P to point to the first or next value
10035
+** on the RHS of the IN constraint. ^If there are no more values on the
10036
+** right hand side of the IN constraint, then *P is set to NULL and these
10037
+** routines return [SQLITE_DONE]. ^The return value might be
10038
+** some other value, such as SQLITE_NOMEM, in the event of a malfunction.
10039
+**
10040
+** The *ppOut values returned by these routines are only valid until the
10041
+** next call to either of these routines or until the end of the xFilter
10042
+** method from which these routines were called. If the virtual table
10043
+** implementation needs to retain the *ppOut values for longer, it must make
10044
+** copies. The *ppOut values are [protected sqlite3_value|protected].
10045
+*/
10046
+SQLITE_API int sqlite3_vtab_in_first(sqlite3_value *pVal, sqlite3_value **ppOut);
10047
+SQLITE_API int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut);
10048
+
10049
+/*
10050
+** CAPI3REF: Constraint values in xBestIndex()
10051
+** METHOD: sqlite3_index_info
10052
+**
10053
+** This API may only be used from within the [xBestIndex|xBestIndex method]
10054
+** of a [virtual table] implementation. The result of calling this interface
10055
+** from outside of an xBestIndex method are undefined and probably harmful.
10056
+**
10057
+** ^When the sqlite3_vtab_rhs_value(P,J,V) interface is invoked from within
10058
+** the [xBestIndex] method of a [virtual table] implementation, with P being
10059
+** a copy of the [sqlite3_index_info] object pointer passed into xBestIndex and
10060
+** J being a 0-based index into P->aConstraint[], then this routine
10061
+** attempts to set *V to the value of the right-hand operand of
10062
+** that constraint if the right-hand operand is known. ^If the
10063
+** right-hand operand is not known, then *V is set to a NULL pointer.
10064
+** ^The sqlite3_vtab_rhs_value(P,J,V) interface returns SQLITE_OK if
10065
+** and only if *V is set to a value. ^The sqlite3_vtab_rhs_value(P,J,V)
10066
+** inteface returns SQLITE_NOTFOUND if the right-hand side of the J-th
10067
+** constraint is not available. ^The sqlite3_vtab_rhs_value() interface
10068
+** can return an result code other than SQLITE_OK or SQLITE_NOTFOUND if
10069
+** something goes wrong.
10070
+**
10071
+** The sqlite3_vtab_rhs_value() interface is usually only successful if
10072
+** the right-hand operand of a constraint is a literal value in the original
10073
+** SQL statement. If the right-hand operand is an expression or a reference
10074
+** to some other column or a [host parameter], then sqlite3_vtab_rhs_value()
10075
+** will probably return [SQLITE_NOTFOUND].
10076
+**
10077
+** ^(Some constraints, such as [SQLITE_INDEX_CONSTRAINT_ISNULL] and
10078
+** [SQLITE_INDEX_CONSTRAINT_ISNOTNULL], have no right-hand operand. For such
10079
+** constraints, sqlite3_vtab_rhs_value() always returns SQLITE_NOTFOUND.)^
10080
+**
10081
+** ^The [sqlite3_value] object returned in *V is a protected sqlite3_value
10082
+** and remains valid for the duration of the xBestIndex method call.
10083
+** ^When xBestIndex returns, the sqlite3_value object returned by
10084
+** sqlite3_vtab_rhs_value() is automatically deallocated.
10085
+**
10086
+** The "_rhs_" in the name of this routine is an abbreviation for
10087
+** "Right-Hand Side".
10088
+*/
10089
+SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);
10090
+
10091
/*
10092
** CAPI3REF: Conflict resolution modes
10093
** KEYWORDS: {conflict resolution mode}
@@ -10964,6 +10639,10 @@ SQLITE_API unsigned char *sqlite3_serialize(
10639
** database is currently in a read transaction or is involved in a backup
10640
** operation.
10641
**
10642
+** It is not possible to deserialized into the TEMP database. If the
10643
+** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the
10644
+** function returns SQLITE_ERROR.
10645
+**
10646
** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
10647
** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
10648
** [sqlite3_free()] is invoked on argument P prior to returning.
@@ -13446,7 +13125,7 @@ struct fts5_api {
13125
** autoconf-based build
13126
*/
13127
#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
13449
-/* #include "config.h" */
13128
+#include "config.h"
13129
#define SQLITECONFIG_H 1
13130
#endif
13131
@@ -13682,11 +13361,12 @@ struct fts5_api {
13361
#ifndef __has_extension
13362
# define __has_extension(x) 0 /* compatibility with non-clang compilers */
13363
#endif
13685
-#if GCC_VERSION>=4007000 || \
13686
- (__has_extension(c_atomic) && __has_extension(c_atomic_store_n))
13364
+#if GCC_VERSION>=4007000 || __has_extension(c_atomic)
13365
+# define SQLITE_ATOMIC_INTRINSICS 1
13366
# define AtomicLoad(PTR) __atomic_load_n((PTR),__ATOMIC_RELAXED)
13367
# define AtomicStore(PTR,VAL) __atomic_store_n((PTR),(VAL),__ATOMIC_RELAXED)
13368
#else
13369
+# define SQLITE_ATOMIC_INTRINSICS 0
13370
# define AtomicLoad(PTR) (*(PTR))
13371
# define AtomicStore(PTR,VAL) (*(PTR) = (VAL))
13372
#endif
@@ -13891,11 +13571,12 @@ struct fts5_api {
13571
** is significant and used at least once. On switch statements
13572
** where multiple cases go to the same block of code, testcase()
13573
** can insure that all cases are evaluated.
13894
-**
13574
*/
13896
-#ifdef SQLITE_COVERAGE_TEST
13897
-SQLITE_PRIVATE void sqlite3Coverage(int);
13898
-# define testcase(X) if( X ){ sqlite3Coverage(__LINE__); }
13575
+#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG)
13576
+# ifndef SQLITE_AMALGAMATION
13577
+ extern unsigned int sqlite3CoverageCounter;
13578
+# endif
13579
+# define testcase(X) if( X ){ sqlite3CoverageCounter += (unsigned)__LINE__; }
13580
#else
13581
# define testcase(X)
13582
#endif
@@ -13925,6 +13606,14 @@ SQLITE_PRIVATE void sqlite3Coverage(int);
13606
# define VVA_ONLY(X)
13607
#endif
13608
13609
+/*
13610
+** Disable ALWAYS() and NEVER() (make them pass-throughs) for coverage
13611
+** and mutation testing
13612
+*/
13613
+#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
13614
+# define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
13615
+#endif
13616
+
13617
/*
13618
** The ALWAYS and NEVER macros surround boolean expressions which
13619
** are intended to always be true or false, respectively. Such
@@ -13940,7 +13629,7 @@ SQLITE_PRIVATE void sqlite3Coverage(int);
13629
** be true and false so that the unreachable code they specify will
13630
** not be counted as untested code.
13631
*/
13943
-#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
13632
+#if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
13633
# define ALWAYS(X) (1)
13634
# define NEVER(X) (0)
13635
#elif !defined(NDEBUG)
@@ -13951,26 +13640,6 @@ SQLITE_PRIVATE void sqlite3Coverage(int);
13640
# define NEVER(X) (X)
13641
#endif
13642
13954
-/*
13955
-** The harmless(X) macro indicates that expression X is usually false
13956
-** but can be true without causing any problems, but we don't know of
13957
-** any way to cause X to be true.
13958
-**
13959
-** In debugging and testing builds, this macro will abort if X is ever
13960
-** true. In this way, developers are alerted to a possible test case
13961
-** that causes X to be true. If a harmless macro ever fails, that is
13962
-** an opportunity to change the macro into a testcase() and add a new
13963
-** test case to the test suite.
13964
-**
13965
-** For normal production builds, harmless(X) is a no-op, since it does
13966
-** not matter whether expression X is true or false.
13967
-*/
13968
-#ifdef SQLITE_DEBUG
13969
-# define harmless(X) assert(!(X));
13970
-#else
13971
-# define harmless(X)
13972
-#endif
13973
-
13643
/*
13644
** Some conditionals are optimizations only. In other words, if the
13645
** conditionals are replaced with a constant 1 (true) or 0 (false) then
@@ -14034,6 +13703,13 @@ SQLITE_PRIVATE void sqlite3Coverage(int);
13703
# undef SQLITE_ENABLE_EXPLAIN_COMMENTS
13704
#endif
13705
13706
+/*
13707
+** SQLITE_OMIT_VIRTUALTABLE implies SQLITE_OMIT_ALTERTABLE
13708
+*/
13709
+#if defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_ALTERTABLE)
13710
+# define SQLITE_OMIT_ALTERTABLE
13711
+#endif
13712
+
13713
/*
13714
** Return true (non-zero) if the input is an integer that is too large
13715
** to fit in 32-bits. This macro is used inside of various testcase()
@@ -14146,7 +13822,7 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*);
13822
/*
13823
** Number of entries in a hash table
13824
*/
14149
-/* #define sqliteHashCount(H) ((H)->count) // NOT USED */
13825
+#define sqliteHashCount(H) ((H)->count)
13826
13827
#endif /* SQLITE_HASH_H */
13828
@@ -14178,8 +13854,8 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*);
13854
#define TK_LP 22
13855
#define TK_RP 23
13856
#define TK_AS 24
14181
-#define TK_WITHOUT 25
14182
-#define TK_COMMA 26
13857
+#define TK_COMMA 25
13858
+#define TK_WITHOUT 26
13859
#define TK_ABORT 27
13860
#define TK_ACTION 28
13861
#define TK_AFTER 29
@@ -14265,78 +13941,79 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*);
13941
#define TK_SLASH 109
13942
#define TK_REM 110
13943
#define TK_CONCAT 111
14268
-#define TK_COLLATE 112
14269
-#define TK_BITNOT 113
14270
-#define TK_ON 114
14271
-#define TK_INDEXED 115
14272
-#define TK_STRING 116
14273
-#define TK_JOIN_KW 117
14274
-#define TK_CONSTRAINT 118
14275
-#define TK_DEFAULT 119
14276
-#define TK_NULL 120
14277
-#define TK_PRIMARY 121
14278
-#define TK_UNIQUE 122
14279
-#define TK_CHECK 123
14280
-#define TK_REFERENCES 124
14281
-#define TK_AUTOINCR 125
14282
-#define TK_INSERT 126
14283
-#define TK_DELETE 127
14284
-#define TK_UPDATE 128
14285
-#define TK_SET 129
14286
-#define TK_DEFERRABLE 130
14287
-#define TK_FOREIGN 131
14288
-#define TK_DROP 132
14289
-#define TK_UNION 133
14290
-#define TK_ALL 134
14291
-#define TK_EXCEPT 135
14292
-#define TK_INTERSECT 136
14293
-#define TK_SELECT 137
14294
-#define TK_VALUES 138
14295
-#define TK_DISTINCT 139
14296
-#define TK_DOT 140
14297
-#define TK_FROM 141
14298
-#define TK_JOIN 142
14299
-#define TK_USING 143
14300
-#define TK_ORDER 144
14301
-#define TK_GROUP 145
14302
-#define TK_HAVING 146
14303
-#define TK_LIMIT 147
14304
-#define TK_WHERE 148
14305
-#define TK_RETURNING 149
14306
-#define TK_INTO 150
14307
-#define TK_NOTHING 151
14308
-#define TK_FLOAT 152
14309
-#define TK_BLOB 153
14310
-#define TK_INTEGER 154
14311
-#define TK_VARIABLE 155
14312
-#define TK_CASE 156
14313
-#define TK_WHEN 157
14314
-#define TK_THEN 158
14315
-#define TK_ELSE 159
14316
-#define TK_INDEX 160
14317
-#define TK_ALTER 161
14318
-#define TK_ADD 162
14319
-#define TK_WINDOW 163
14320
-#define TK_OVER 164
14321
-#define TK_FILTER 165
14322
-#define TK_COLUMN 166
14323
-#define TK_AGG_FUNCTION 167
14324
-#define TK_AGG_COLUMN 168
14325
-#define TK_TRUEFALSE 169
14326
-#define TK_ISNOT 170
14327
-#define TK_FUNCTION 171
14328
-#define TK_UMINUS 172
14329
-#define TK_UPLUS 173
14330
-#define TK_TRUTH 174
14331
-#define TK_REGISTER 175
14332
-#define TK_VECTOR 176
14333
-#define TK_SELECT_COLUMN 177
14334
-#define TK_IF_NULL_ROW 178
14335
-#define TK_ASTERISK 179
14336
-#define TK_SPAN 180
14337
-#define TK_ERROR 181
14338
-#define TK_SPACE 182
14339
-#define TK_ILLEGAL 183
13944
+#define TK_PTR 112
13945
+#define TK_COLLATE 113
13946
+#define TK_BITNOT 114
13947
+#define TK_ON 115
13948
+#define TK_INDEXED 116
13949
+#define TK_STRING 117
13950
+#define TK_JOIN_KW 118
13951
+#define TK_CONSTRAINT 119
13952
+#define TK_DEFAULT 120
13953
+#define TK_NULL 121
13954
+#define TK_PRIMARY 122
13955
+#define TK_UNIQUE 123
13956
+#define TK_CHECK 124
13957
+#define TK_REFERENCES 125
13958
+#define TK_AUTOINCR 126
13959
+#define TK_INSERT 127
13960
+#define TK_DELETE 128
13961
+#define TK_UPDATE 129
13962
+#define TK_SET 130
13963
+#define TK_DEFERRABLE 131
13964
+#define TK_FOREIGN 132
13965
+#define TK_DROP 133
13966
+#define TK_UNION 134
13967
+#define TK_ALL 135
13968
+#define TK_EXCEPT 136
13969
+#define TK_INTERSECT 137
13970
+#define TK_SELECT 138
13971
+#define TK_VALUES 139
13972
+#define TK_DISTINCT 140
13973
+#define TK_DOT 141
13974
+#define TK_FROM 142
13975
+#define TK_JOIN 143
13976
+#define TK_USING 144
13977
+#define TK_ORDER 145
13978
+#define TK_GROUP 146
13979
+#define TK_HAVING 147
13980
+#define TK_LIMIT 148
13981
+#define TK_WHERE 149
13982
+#define TK_RETURNING 150
13983
+#define TK_INTO 151
13984
+#define TK_NOTHING 152
13985
+#define TK_FLOAT 153
13986
+#define TK_BLOB 154
13987
+#define TK_INTEGER 155
13988
+#define TK_VARIABLE 156
13989
+#define TK_CASE 157
13990
+#define TK_WHEN 158
13991
+#define TK_THEN 159
13992
+#define TK_ELSE 160
13993
+#define TK_INDEX 161
13994
+#define TK_ALTER 162
13995
+#define TK_ADD 163
13996
+#define TK_WINDOW 164
13997
+#define TK_OVER 165
13998
+#define TK_FILTER 166
13999
+#define TK_COLUMN 167
14000
+#define TK_AGG_FUNCTION 168
14001
+#define TK_AGG_COLUMN 169
14002
+#define TK_TRUEFALSE 170
14003
+#define TK_ISNOT 171
14004
+#define TK_FUNCTION 172
14005
+#define TK_UMINUS 173
14006
+#define TK_UPLUS 174
14007
+#define TK_TRUTH 175
14008
+#define TK_REGISTER 176
14009
+#define TK_VECTOR 177
14010
+#define TK_SELECT_COLUMN 178
14011
+#define TK_IF_NULL_ROW 179
14012
+#define TK_ASTERISK 180
14013
+#define TK_SPAN 181
14014
+#define TK_ERROR 182
14015
+#define TK_SPACE 183
14016
+#define TK_ILLEGAL 184
14017
14018
/************** End of parse.h ***********************************************/
14019
/************** Continuing where we left off in sqliteInt.h ******************/
@@ -14442,7 +14119,7 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*);
14119
** number of pages. A negative number N translations means that a buffer
14120
** of -1024*N bytes is allocated and used for as many pages as it will hold.
14121
**
14445
-** The default value of "20" was choosen to minimize the run-time of the
14122
+** The default value of "20" was chosen to minimize the run-time of the
14123
** speedtest1 test program with options: --shrink-memory --reprepare
14124
*/
14125
#ifndef SQLITE_DEFAULT_PCACHE_INITSZ
@@ -14604,6 +14281,7 @@ typedef INT16_TYPE LogEst;
14281
# define SQLITE_PTRSIZE __SIZEOF_POINTER__
14282
# elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \
14283
defined(_M_ARM) || defined(__arm__) || defined(__x86) || \
14284
+ (defined(__APPLE__) && defined(__POWERPC__)) || \
14285
(defined(__TOS_AIX__) && !defined(__64BIT__))
14286
# define SQLITE_PTRSIZE 4
14287
# else
@@ -14798,11 +14476,25 @@ struct BusyHandler {
14476
14477
/*
14478
** Name of table that holds the database schema.
14479
+**
14480
+** The PREFERRED names are used whereever possible. But LEGACY is also
14481
+** used for backwards compatibility.
14482
+**
14483
+** 1. Queries can use either the PREFERRED or the LEGACY names
14484
+** 2. The sqlite3_set_authorizer() callback uses the LEGACY name
14485
+** 3. The PRAGMA table_list statement uses the PREFERRED name
14486
+**
14487
+** The LEGACY names are stored in the internal symbol hash table
14488
+** in support of (2). Names are translated using sqlite3PreferredTableName()
14489
+** for (3). The sqlite3FindTable() function takes care of translating
14490
+** names for (1).
14491
+**
14492
+** Note that "sqlite_temp_schema" can also be called "temp.sqlite_schema".
14493
*/
14802
-#define DFLT_SCHEMA_TABLE "sqlite_master"
14803
-#define DFLT_TEMP_SCHEMA_TABLE "sqlite_temp_master"
14804
-#define ALT_SCHEMA_TABLE "sqlite_schema"
14805
-#define ALT_TEMP_SCHEMA_TABLE "sqlite_temp_schema"
14494
+#define LEGACY_SCHEMA_TABLE "sqlite_master"
14495
+#define LEGACY_TEMP_SCHEMA_TABLE "sqlite_temp_master"
14496
+#define PREFERRED_SCHEMA_TABLE "sqlite_schema"
14497
+#define PREFERRED_TEMP_SCHEMA_TABLE "sqlite_temp_schema"
14498
14499
14500
/*
@@ -14814,7 +14506,7 @@ struct BusyHandler {
14506
** The name of the schema table. The name is different for TEMP.
14507
*/
14508
#define SCHEMA_TABLE(x) \
14817
- ((!OMIT_TEMPDB)&&(x==1)?DFLT_TEMP_SCHEMA_TABLE:DFLT_SCHEMA_TABLE)
14509
+ ((!OMIT_TEMPDB)&&(x==1)?LEGACY_TEMP_SCHEMA_TABLE:LEGACY_SCHEMA_TABLE)
14510
14511
/*
14512
** A convenience macro that returns the number of elements in
@@ -14963,10 +14655,11 @@ typedef struct With With;
14655
/*
14656
** A bit in a Bitmask
14657
*/
14966
-#define MASKBIT(n) (((Bitmask)1)<<(n))
14967
-#define MASKBIT64(n) (((u64)1)<<(n))
14968
-#define MASKBIT32(n) (((unsigned int)1)<<(n))
14969
-#define ALLBITS ((Bitmask)-1)
14658
+#define MASKBIT(n) (((Bitmask)1)<<(n))
14659
+#define MASKBIT64(n) (((u64)1)<<(n))
14660
+#define MASKBIT32(n) (((unsigned int)1)<<(n))
14661
+#define SMASKBIT32(n) ((n)<=31?((unsigned int)1)<<(n):0)
14662
+#define ALLBITS ((Bitmask)-1)
14663
14664
/* A VList object records a mapping between parameters/variables/wildcards
14665
** in the SQL statement (such as $abc, @pqr, or :xyz) and the integer
@@ -15355,7 +15048,7 @@ SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *);
15048
#define BTREE_BLOBKEY 2 /* Table has keys only - no data */
15049
15050
SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree*, int, int*);
15358
-SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, int*);
15051
+SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, i64*);
15052
SQLITE_PRIVATE int sqlite3BtreeClearTableOfCursor(BtCursor*);
15053
SQLITE_PRIVATE int sqlite3BtreeTripAllCursors(Btree*, int, int);
15054
@@ -15479,13 +15172,17 @@ SQLITE_PRIVATE void sqlite3BtreeCursorHint(BtCursor*, int, ...);
15172
#endif
15173
15174
SQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor*);
15482
-SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(
15175
+SQLITE_PRIVATE int sqlite3BtreeTableMoveto(
15176
BtCursor*,
15484
- UnpackedRecord *pUnKey,
15177
i64 intKey,
15178
int bias,
15179
int *pRes
15180
);
15181
+SQLITE_PRIVATE int sqlite3BtreeIndexMoveto(
15182
+ BtCursor*,
15183
+ UnpackedRecord *pUnKey,
15184
+ int *pRes
15185
+);
15186
SQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor*);
15187
SQLITE_PRIVATE int sqlite3BtreeCursorRestore(BtCursor*, int*);
15188
SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*, u8 flags);
@@ -15836,35 +15533,35 @@ typedef struct VdbeOpList VdbeOpList;
15533
#define OP_If 18 /* jump */
15534
#define OP_Not 19 /* same as TK_NOT, synopsis: r[P2]= !r[P1] */
15535
#define OP_IfNot 20 /* jump */
15839
-#define OP_IfNullRow 21 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */
15840
-#define OP_SeekLT 22 /* jump, synopsis: key=r[P3@P4] */
15841
-#define OP_SeekLE 23 /* jump, synopsis: key=r[P3@P4] */
15842
-#define OP_SeekGE 24 /* jump, synopsis: key=r[P3@P4] */
15843
-#define OP_SeekGT 25 /* jump, synopsis: key=r[P3@P4] */
15844
-#define OP_IfNotOpen 26 /* jump, synopsis: if( !csr[P1] ) goto P2 */
15845
-#define OP_IfNoHope 27 /* jump, synopsis: key=r[P3@P4] */
15846
-#define OP_NoConflict 28 /* jump, synopsis: key=r[P3@P4] */
15847
-#define OP_NotFound 29 /* jump, synopsis: key=r[P3@P4] */
15848
-#define OP_Found 30 /* jump, synopsis: key=r[P3@P4] */
15849
-#define OP_SeekRowid 31 /* jump, synopsis: intkey=r[P3] */
15850
-#define OP_NotExists 32 /* jump, synopsis: intkey=r[P3] */
15851
-#define OP_Last 33 /* jump */
15852
-#define OP_IfSmaller 34 /* jump */
15853
-#define OP_SorterSort 35 /* jump */
15854
-#define OP_Sort 36 /* jump */
15855
-#define OP_Rewind 37 /* jump */
15856
-#define OP_IdxLE 38 /* jump, synopsis: key=r[P3@P4] */
15857
-#define OP_IdxGT 39 /* jump, synopsis: key=r[P3@P4] */
15858
-#define OP_IdxLT 40 /* jump, synopsis: key=r[P3@P4] */
15859
-#define OP_IdxGE 41 /* jump, synopsis: key=r[P3@P4] */
15860
-#define OP_RowSetRead 42 /* jump, synopsis: r[P3]=rowset(P1) */
15536
+#define OP_IsNullOrType 21 /* jump, synopsis: if typeof(r[P1]) IN (P3,5) goto P2 */
15537
+#define OP_IfNullRow 22 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */
15538
+#define OP_SeekLT 23 /* jump, synopsis: key=r[P3@P4] */
15539
+#define OP_SeekLE 24 /* jump, synopsis: key=r[P3@P4] */
15540
+#define OP_SeekGE 25 /* jump, synopsis: key=r[P3@P4] */
15541
+#define OP_SeekGT 26 /* jump, synopsis: key=r[P3@P4] */
15542
+#define OP_IfNotOpen 27 /* jump, synopsis: if( !csr[P1] ) goto P2 */
15543
+#define OP_IfNoHope 28 /* jump, synopsis: key=r[P3@P4] */
15544
+#define OP_NoConflict 29 /* jump, synopsis: key=r[P3@P4] */
15545
+#define OP_NotFound 30 /* jump, synopsis: key=r[P3@P4] */
15546
+#define OP_Found 31 /* jump, synopsis: key=r[P3@P4] */
15547
+#define OP_SeekRowid 32 /* jump, synopsis: intkey=r[P3] */
15548
+#define OP_NotExists 33 /* jump, synopsis: intkey=r[P3] */
15549
+#define OP_Last 34 /* jump */
15550
+#define OP_IfSmaller 35 /* jump */
15551
+#define OP_SorterSort 36 /* jump */
15552
+#define OP_Sort 37 /* jump */
15553
+#define OP_Rewind 38 /* jump */
15554
+#define OP_IdxLE 39 /* jump, synopsis: key=r[P3@P4] */
15555
+#define OP_IdxGT 40 /* jump, synopsis: key=r[P3@P4] */
15556
+#define OP_IdxLT 41 /* jump, synopsis: key=r[P3@P4] */
15557
+#define OP_IdxGE 42 /* jump, synopsis: key=r[P3@P4] */
15558
#define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
15559
#define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
15863
-#define OP_RowSetTest 45 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
15864
-#define OP_Program 46 /* jump */
15865
-#define OP_FkIfZero 47 /* jump, synopsis: if fkctr[P1]==0 goto P2 */
15866
-#define OP_IfPos 48 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
15867
-#define OP_IfNotZero 49 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
15560
+#define OP_RowSetRead 45 /* jump, synopsis: r[P3]=rowset(P1) */
15561
+#define OP_RowSetTest 46 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
15562
+#define OP_Program 47 /* jump */
15563
+#define OP_FkIfZero 48 /* jump, synopsis: if fkctr[P1]==0 goto P2 */
15564
+#define OP_IfPos 49 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
15565
#define OP_IsNull 50 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
15566
#define OP_NotNull 51 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
15567
#define OP_Ne 52 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */
@@ -15874,49 +15571,49 @@ typedef struct VdbeOpList VdbeOpList;
15571
#define OP_Lt 56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */
15572
#define OP_Ge 57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
15573
#define OP_ElseEq 58 /* jump, same as TK_ESCAPE */
15877
-#define OP_DecrJumpZero 59 /* jump, synopsis: if (--r[P1])==0 goto P2 */
15878
-#define OP_IncrVacuum 60 /* jump */
15879
-#define OP_VNext 61 /* jump */
15880
-#define OP_Init 62 /* jump, synopsis: Start at P2 */
15881
-#define OP_PureFunc 63 /* synopsis: r[P3]=func(r[P2@NP]) */
15882
-#define OP_Function 64 /* synopsis: r[P3]=func(r[P2@NP]) */
15883
-#define OP_Return 65
15884
-#define OP_EndCoroutine 66
15885
-#define OP_HaltIfNull 67 /* synopsis: if r[P3]=null halt */
15886
-#define OP_Halt 68
15887
-#define OP_Integer 69 /* synopsis: r[P2]=P1 */
15888
-#define OP_Int64 70 /* synopsis: r[P2]=P4 */
15889
-#define OP_String 71 /* synopsis: r[P2]='P4' (len=P1) */
15890
-#define OP_Null 72 /* synopsis: r[P2..P3]=NULL */
15891
-#define OP_SoftNull 73 /* synopsis: r[P1]=NULL */
15892
-#define OP_Blob 74 /* synopsis: r[P2]=P4 (len=P1) */
15893
-#define OP_Variable 75 /* synopsis: r[P2]=parameter(P1,P4) */
15894
-#define OP_Move 76 /* synopsis: r[P2@P3]=r[P1@P3] */
15895
-#define OP_Copy 77 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
15896
-#define OP_SCopy 78 /* synopsis: r[P2]=r[P1] */
15897
-#define OP_IntCopy 79 /* synopsis: r[P2]=r[P1] */
15898
-#define OP_ChngCntRow 80 /* synopsis: output=r[P1] */
15899
-#define OP_ResultRow 81 /* synopsis: output=r[P1@P2] */
15900
-#define OP_CollSeq 82
15901
-#define OP_AddImm 83 /* synopsis: r[P1]=r[P1]+P2 */
15902
-#define OP_RealAffinity 84
15903
-#define OP_Cast 85 /* synopsis: affinity(r[P1]) */
15904
-#define OP_Permutation 86
15905
-#define OP_Compare 87 /* synopsis: r[P1@P3] <-> r[P2@P3] */
15906
-#define OP_IsTrue 88 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
15907
-#define OP_ZeroOrNull 89 /* synopsis: r[P2] = 0 OR NULL */
15908
-#define OP_Offset 90 /* synopsis: r[P3] = sqlite_offset(P1) */
15909
-#define OP_Column 91 /* synopsis: r[P3]=PX */
15910
-#define OP_Affinity 92 /* synopsis: affinity(r[P1@P2]) */
15911
-#define OP_MakeRecord 93 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
15912
-#define OP_Count 94 /* synopsis: r[P2]=count() */
15913
-#define OP_ReadCookie 95
15914
-#define OP_SetCookie 96
15915
-#define OP_ReopenIdx 97 /* synopsis: root=P2 iDb=P3 */
15916
-#define OP_OpenRead 98 /* synopsis: root=P2 iDb=P3 */
15917
-#define OP_OpenWrite 99 /* synopsis: root=P2 iDb=P3 */
15918
-#define OP_OpenDup 100
15919
-#define OP_OpenAutoindex 101 /* synopsis: nColumn=P2 */
15574
+#define OP_IfNotZero 59 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
15575
+#define OP_DecrJumpZero 60 /* jump, synopsis: if (--r[P1])==0 goto P2 */
15576
+#define OP_IncrVacuum 61 /* jump */
15577
+#define OP_VNext 62 /* jump */
15578
+#define OP_Filter 63 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */
15579
+#define OP_Init 64 /* jump, synopsis: Start at P2 */
15580
+#define OP_PureFunc 65 /* synopsis: r[P3]=func(r[P2@NP]) */
15581
+#define OP_Function 66 /* synopsis: r[P3]=func(r[P2@NP]) */
15582
+#define OP_Return 67
15583
+#define OP_EndCoroutine 68
15584
+#define OP_HaltIfNull 69 /* synopsis: if r[P3]=null halt */
15585
+#define OP_Halt 70
15586
+#define OP_Integer 71 /* synopsis: r[P2]=P1 */
15587
+#define OP_Int64 72 /* synopsis: r[P2]=P4 */
15588
+#define OP_String 73 /* synopsis: r[P2]='P4' (len=P1) */
15589
+#define OP_Null 74 /* synopsis: r[P2..P3]=NULL */
15590
+#define OP_SoftNull 75 /* synopsis: r[P1]=NULL */
15591
+#define OP_Blob 76 /* synopsis: r[P2]=P4 (len=P1) */
15592
+#define OP_Variable 77 /* synopsis: r[P2]=parameter(P1,P4) */
15593
+#define OP_Move 78 /* synopsis: r[P2@P3]=r[P1@P3] */
15594
+#define OP_Copy 79 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
15595
+#define OP_SCopy 80 /* synopsis: r[P2]=r[P1] */
15596
+#define OP_IntCopy 81 /* synopsis: r[P2]=r[P1] */
15597
+#define OP_FkCheck 82
15598
+#define OP_ResultRow 83 /* synopsis: output=r[P1@P2] */
15599
+#define OP_CollSeq 84
15600
+#define OP_AddImm 85 /* synopsis: r[P1]=r[P1]+P2 */
15601
+#define OP_RealAffinity 86
15602
+#define OP_Cast 87 /* synopsis: affinity(r[P1]) */
15603
+#define OP_Permutation 88
15604
+#define OP_Compare 89 /* synopsis: r[P1@P3] <-> r[P2@P3] */
15605
+#define OP_IsTrue 90 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
15606
+#define OP_ZeroOrNull 91 /* synopsis: r[P2] = 0 OR NULL */
15607
+#define OP_Offset 92 /* synopsis: r[P3] = sqlite_offset(P1) */
15608
+#define OP_Column 93 /* synopsis: r[P3]=PX */
15609
+#define OP_TypeCheck 94 /* synopsis: typecheck(r[P1@P2]) */
15610
+#define OP_Affinity 95 /* synopsis: affinity(r[P1@P2]) */
15611
+#define OP_MakeRecord 96 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
15612
+#define OP_Count 97 /* synopsis: r[P2]=count() */
15613
+#define OP_ReadCookie 98
15614
+#define OP_SetCookie 99
15615
+#define OP_ReopenIdx 100 /* synopsis: root=P2 iDb=P3 */
15616
+#define OP_OpenRead 101 /* synopsis: root=P2 iDb=P3 */
15617
#define OP_BitAnd 102 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
15618
#define OP_BitOr 103 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
15619
#define OP_ShiftLeft 104 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
@@ -15927,74 +15624,79 @@ typedef struct VdbeOpList VdbeOpList;
15624
#define OP_Divide 109 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
15625
#define OP_Remainder 110 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
15626
#define OP_Concat 111 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
15930
-#define OP_OpenEphemeral 112 /* synopsis: nColumn=P2 */
15931
-#define OP_BitNot 113 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
15932
-#define OP_SorterOpen 114
15933
-#define OP_SequenceTest 115 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
15934
-#define OP_String8 116 /* same as TK_STRING, synopsis: r[P2]='P4' */
15935
-#define OP_OpenPseudo 117 /* synopsis: P3 columns in r[P2] */
15936
-#define OP_Close 118
15937
-#define OP_ColumnsUsed 119
15938
-#define OP_SeekScan 120 /* synopsis: Scan-ahead up to P1 rows */
15939
-#define OP_SeekHit 121 /* synopsis: set P2<=seekHit<=P3 */
15940
-#define OP_Sequence 122 /* synopsis: r[P2]=cursor[P1].ctr++ */
15941
-#define OP_NewRowid 123 /* synopsis: r[P2]=rowid */
15942
-#define OP_Insert 124 /* synopsis: intkey=r[P3] data=r[P2] */
15943
-#define OP_RowCell 125
15944
-#define OP_Delete 126
15945
-#define OP_ResetCount 127
15946
-#define OP_SorterCompare 128 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
15947
-#define OP_SorterData 129 /* synopsis: r[P2]=data */
15948
-#define OP_RowData 130 /* synopsis: r[P2]=data */
15949
-#define OP_Rowid 131 /* synopsis: r[P2]=rowid */
15950
-#define OP_NullRow 132
15951
-#define OP_SeekEnd 133
15952
-#define OP_IdxInsert 134 /* synopsis: key=r[P2] */
15953
-#define OP_SorterInsert 135 /* synopsis: key=r[P2] */
15954
-#define OP_IdxDelete 136 /* synopsis: key=r[P2@P3] */
15955
-#define OP_DeferredSeek 137 /* synopsis: Move P3 to P1.rowid if needed */
15956
-#define OP_IdxRowid 138 /* synopsis: r[P2]=rowid */
15957
-#define OP_FinishSeek 139
15958
-#define OP_Destroy 140
15959
-#define OP_Clear 141
15960
-#define OP_ResetSorter 142
15961
-#define OP_CreateBtree 143 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
15962
-#define OP_SqlExec 144
15963
-#define OP_ParseSchema 145
15964
-#define OP_LoadAnalysis 146
15965
-#define OP_DropTable 147
15966
-#define OP_DropIndex 148
15967
-#define OP_DropTrigger 149
15968
-#define OP_IntegrityCk 150
15969
-#define OP_RowSetAdd 151 /* synopsis: rowset(P1)=r[P2] */
15970
-#define OP_Real 152 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
15971
-#define OP_Param 153
15972
-#define OP_FkCounter 154 /* synopsis: fkctr[P1]+=P2 */
15973
-#define OP_MemMax 155 /* synopsis: r[P1]=max(r[P1],r[P2]) */
15974
-#define OP_OffsetLimit 156 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
15975
-#define OP_AggInverse 157 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
15976
-#define OP_AggStep 158 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15977
-#define OP_AggStep1 159 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15978
-#define OP_AggValue 160 /* synopsis: r[P3]=value N=P2 */
15979
-#define OP_AggFinal 161 /* synopsis: accum=r[P1] N=P2 */
15980
-#define OP_Expire 162
15981
-#define OP_CursorLock 163
15982
-#define OP_CursorUnlock 164
15983
-#define OP_TableLock 165 /* synopsis: iDb=P1 root=P2 write=P3 */
15984
-#define OP_VBegin 166
15985
-#define OP_VCreate 167
15986
-#define OP_VDestroy 168
15987
-#define OP_VOpen 169
15988
-#define OP_VColumn 170 /* synopsis: r[P3]=vcolumn(P2) */
15989
-#define OP_VRename 171
15990
-#define OP_Pagecount 172
15991
-#define OP_MaxPgcnt 173
15992
-#define OP_Trace 174
15993
-#define OP_CursorHint 175
15994
-#define OP_ReleaseReg 176 /* synopsis: release r[P1@P2] mask P3 */
15995
-#define OP_Noop 177
15996
-#define OP_Explain 178
15997
-#define OP_Abortable 179
15627
+#define OP_OpenWrite 112 /* synopsis: root=P2 iDb=P3 */
15628
+#define OP_OpenDup 113
15629
+#define OP_BitNot 114 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
15630
+#define OP_OpenAutoindex 115 /* synopsis: nColumn=P2 */
15631
+#define OP_OpenEphemeral 116 /* synopsis: nColumn=P2 */
15632
+#define OP_String8 117 /* same as TK_STRING, synopsis: r[P2]='P4' */
15633
+#define OP_SorterOpen 118
15634
+#define OP_SequenceTest 119 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
15635
+#define OP_OpenPseudo 120 /* synopsis: P3 columns in r[P2] */
15636
+#define OP_Close 121
15637
+#define OP_ColumnsUsed 122
15638
+#define OP_SeekScan 123 /* synopsis: Scan-ahead up to P1 rows */
15639
+#define OP_SeekHit 124 /* synopsis: set P2<=seekHit<=P3 */
15640
+#define OP_Sequence 125 /* synopsis: r[P2]=cursor[P1].ctr++ */
15641
+#define OP_NewRowid 126 /* synopsis: r[P2]=rowid */
15642
+#define OP_Insert 127 /* synopsis: intkey=r[P3] data=r[P2] */
15643
+#define OP_RowCell 128
15644
+#define OP_Delete 129
15645
+#define OP_ResetCount 130
15646
+#define OP_SorterCompare 131 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
15647
+#define OP_SorterData 132 /* synopsis: r[P2]=data */
15648
+#define OP_RowData 133 /* synopsis: r[P2]=data */
15649
+#define OP_Rowid 134 /* synopsis: r[P2]=rowid */
15650
+#define OP_NullRow 135
15651
+#define OP_SeekEnd 136
15652
+#define OP_IdxInsert 137 /* synopsis: key=r[P2] */
15653
+#define OP_SorterInsert 138 /* synopsis: key=r[P2] */
15654
+#define OP_IdxDelete 139 /* synopsis: key=r[P2@P3] */
15655
+#define OP_DeferredSeek 140 /* synopsis: Move P3 to P1.rowid if needed */
15656
+#define OP_IdxRowid 141 /* synopsis: r[P2]=rowid */
15657
+#define OP_FinishSeek 142
15658
+#define OP_Destroy 143
15659
+#define OP_Clear 144
15660
+#define OP_ResetSorter 145
15661
+#define OP_CreateBtree 146 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
15662
+#define OP_SqlExec 147
15663
+#define OP_ParseSchema 148
15664
+#define OP_LoadAnalysis 149
15665
+#define OP_DropTable 150
15666
+#define OP_DropIndex 151
15667
+#define OP_DropTrigger 152
15668
+#define OP_Real 153 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
15669
+#define OP_IntegrityCk 154
15670
+#define OP_RowSetAdd 155 /* synopsis: rowset(P1)=r[P2] */
15671
+#define OP_Param 156
15672
+#define OP_FkCounter 157 /* synopsis: fkctr[P1]+=P2 */
15673
+#define OP_MemMax 158 /* synopsis: r[P1]=max(r[P1],r[P2]) */
15674
+#define OP_OffsetLimit 159 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
15675
+#define OP_AggInverse 160 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
15676
+#define OP_AggStep 161 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15677
+#define OP_AggStep1 162 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15678
+#define OP_AggValue 163 /* synopsis: r[P3]=value N=P2 */
15679
+#define OP_AggFinal 164 /* synopsis: accum=r[P1] N=P2 */
15680
+#define OP_Expire 165
15681
+#define OP_CursorLock 166
15682
+#define OP_CursorUnlock 167
15683
+#define OP_TableLock 168 /* synopsis: iDb=P1 root=P2 write=P3 */
15684
+#define OP_VBegin 169
15685
+#define OP_VCreate 170
15686
+#define OP_VDestroy 171
15687
+#define OP_VOpen 172
15688
+#define OP_VInitIn 173 /* synopsis: r[P2]=ValueList(P1,P3) */
15689
+#define OP_VColumn 174 /* synopsis: r[P3]=vcolumn(P2) */
15690
+#define OP_VRename 175
15691
+#define OP_Pagecount 176
15692
+#define OP_MaxPgcnt 177
15693
+#define OP_FilterAdd 178 /* synopsis: filter(P1) += key(P3@P4) */
15694
+#define OP_Trace 179
15695
+#define OP_CursorHint 180
15696
+#define OP_ReleaseReg 181 /* synopsis: release r[P1@P2] mask P3 */
15697
+#define OP_Noop 182
15698
+#define OP_Explain 183
15699
+#define OP_Abortable 184
15700
15701
/* Properties such as "out2" or "jump" that are specified in
15702
** comments following the "case" for each opcode in the vdbe.c
@@ -16009,27 +15711,28 @@ typedef struct VdbeOpList VdbeOpList;
15711
#define OPFLG_INITIALIZER {\
15712
/* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x10,\
15713
/* 8 */ 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03,\
16012
-/* 16 */ 0x01, 0x01, 0x03, 0x12, 0x03, 0x01, 0x09, 0x09,\
16013
-/* 24 */ 0x09, 0x09, 0x01, 0x09, 0x09, 0x09, 0x09, 0x09,\
16014
-/* 32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
16015
-/* 40 */ 0x01, 0x01, 0x23, 0x26, 0x26, 0x0b, 0x01, 0x01,\
16016
-/* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
16017
-/* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x01, 0x01, 0x01, 0x00,\
16018
-/* 64 */ 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10,\
16019
-/* 72 */ 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10,\
16020
-/* 80 */ 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\
16021
-/* 88 */ 0x12, 0x1e, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10,\
16022
-/* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x26,\
15714
+/* 16 */ 0x01, 0x01, 0x03, 0x12, 0x03, 0x03, 0x01, 0x09,\
15715
+/* 24 */ 0x09, 0x09, 0x09, 0x01, 0x09, 0x09, 0x09, 0x09,\
15716
+/* 32 */ 0x09, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
15717
+/* 40 */ 0x01, 0x01, 0x01, 0x26, 0x26, 0x23, 0x0b, 0x01,\
15718
+/* 48 */ 0x01, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
15719
+/* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x01, 0x01, 0x01,\
15720
+/* 64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10,\
15721
+/* 72 */ 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00,\
15722
+/* 80 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02,\
15723
+/* 88 */ 0x00, 0x00, 0x12, 0x1e, 0x20, 0x00, 0x00, 0x00,\
15724
+/* 96 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x26, 0x26,\
15725
/* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
16024
-/* 112 */ 0x00, 0x12, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\
16025
-/* 120 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,\
16026
-/* 128 */ 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x04, 0x04,\
16027
-/* 136 */ 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10,\
16028
-/* 144 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,\
16029
-/* 152 */ 0x10, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00,\
15726
+/* 112 */ 0x00, 0x00, 0x12, 0x00, 0x00, 0x10, 0x00, 0x00,\
15727
+/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
15728
+/* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,\
15729
+/* 136 */ 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x00, 0x10,\
15730
+/* 144 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
15731
+/* 152 */ 0x00, 0x10, 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a,\
15732
/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
16031
-/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
16032
-/* 176 */ 0x00, 0x00, 0x00, 0x00,}
15733
+/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\
15734
+/* 176 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15735
+/* 184 */ 0x00,}
15736
15737
/* The resolve3P2Values() routine is able to run faster if it knows
15738
** the value of the largest JUMP opcode. The smaller the maximum
@@ -16037,7 +15740,7 @@ typedef struct VdbeOpList VdbeOpList;
15740
** generated this include file strives to group all JUMP opcodes
15741
** together near the beginning of the list.
15742
*/
16040
-#define SQLITE_MX_JUMP_OPCODE 62 /* Maximum JUMP opcode */
15743
+#define SQLITE_MX_JUMP_OPCODE 64 /* Maximum JUMP opcode */
15744
15745
/************** End of opcodes.h *********************************************/
15746
/************** Continuing where we left off in vdbe.h ***********************/
@@ -17098,6 +16801,7 @@ struct sqlite3 {
16801
u32 nSchemaLock; /* Do not reset the schema when non-zero */
16802
unsigned int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */
16803
int errCode; /* Most recent error code (SQLITE_*) */
16804
+ int errByteOffset; /* Byte offset of error in SQL statement */
16805
int errMask; /* & result codes with this before returning */
16806
int iSysErrno; /* Errno value from last system error */
16807
u32 dbOptFlags; /* Flags to enable/disable optimizations */
@@ -17114,10 +16818,10 @@ struct sqlite3 {
16818
u8 mTrace; /* zero or more SQLITE_TRACE flags */
16819
u8 noSharedCache; /* True if no shared-cache backends */
16820
u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */
16821
+ u8 eOpenState; /* Current condition of the connection */
16822
int nextPagesize; /* Pagesize after VACUUM if >0 */
17118
- u32 magic; /* Magic number for detect library misuse */
17119
- int nChange; /* Value returned by sqlite3_changes() */
17120
- int nTotalChange; /* Value returned by sqlite3_total_changes() */
16823
+ i64 nChange; /* Value returned by sqlite3_changes() */
16824
+ i64 nTotalChange; /* Value returned by sqlite3_total_changes() */
16825
int aLimit[SQLITE_N_LIMIT]; /* Limits */
16826
int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */
16827
struct sqlite3InitInfo { /* Information used during initialization */
@@ -17127,7 +16831,7 @@ struct sqlite3 {
16831
unsigned orphanTrigger : 1; /* Last statement is orphaned TEMP trigger */
16832
unsigned imposterTable : 1; /* Building an imposter table */
16833
unsigned reopenMemdb : 1; /* ATTACH is really a reopen using MemDB */
17130
- char **azInit; /* "type", "name", and "tbl_name" columns */
16834
+ const char **azInit; /* "type", "name", and "tbl_name" columns */
16835
} init;
16836
int nVdbeActive; /* Number of VDBEs currently running */
16837
int nVdbeRead; /* Number of active VDBEs that read or write */
@@ -17137,10 +16841,10 @@ struct sqlite3 {
16841
int nExtension; /* Number of loaded extensions */
16842
void **aExtension; /* Array of shared library handles */
16843
union {
17140
- void (*xLegacy)(void*,const char*); /* Legacy trace function */
17141
- int (*xV2)(u32,void*,void*,void*); /* V2 Trace function */
16844
+ void (*xLegacy)(void*,const char*); /* mTrace==SQLITE_TRACE_LEGACY */
16845
+ int (*xV2)(u32,void*,void*,void*); /* All other mTrace values */
16846
} trace;
17143
- void *pTraceArg; /* Argument to the trace function */
16847
+ void *pTraceArg; /* Argument to the trace function */
16848
#ifndef SQLITE_OMIT_DEPRECATED
16849
void (*xProfile)(void*,const char*,u64); /* Profiling function */
16850
void *pProfileArg; /* Argument to profile function */
@@ -17151,6 +16855,9 @@ struct sqlite3 {
16855
void (*xRollbackCallback)(void*); /* Invoked at every commit. */
16856
void *pUpdateArg;
16857
void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64);
16858
+ void *pAutovacPagesArg; /* Client argument to autovac_pages */
16859
+ void (*xAutovacDestr)(void*); /* Destructor for pAutovacPAgesArg */
16860
+ unsigned int (*xAutovacPages)(void*,const char*,u32,u32,u32);
16861
Parse *pParse; /* Current parse */
16862
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
16863
void *pPreUpdateArg; /* First argument to xPreUpdateCallback */
@@ -17280,6 +16987,7 @@ struct sqlite3 {
16987
#define SQLITE_CountRows HI(0x00001) /* Count rows changed by INSERT, */
16988
/* DELETE, or UPDATE and return */
16989
/* the count using a callback. */
16990
+#define SQLITE_CorruptRdOnly HI(0x00002) /* Prohibit writes due to error */
16991
16992
/* Flags used only if debugging */
16993
#ifdef SQLITE_DEBUG
@@ -17326,6 +17034,11 @@ struct sqlite3 {
17034
#define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */
17035
#define SQLITE_MinMaxOpt 0x00010000 /* The min/max optimization */
17036
#define SQLITE_SeekScan 0x00020000 /* The OP_SeekScan optimization */
17037
+#define SQLITE_OmitOrderBy 0x00040000 /* Omit pointless ORDER BY */
17038
+ /* TH3 expects this value ^^^^^^^^^^ to be 0x40000. Coordinate any change */
17039
+#define SQLITE_BloomFilter 0x00080000 /* Use a Bloom filter on searches */
17040
+#define SQLITE_BloomPulldown 0x00100000 /* Run Bloom filters early */
17041
+#define SQLITE_BalancedMerge 0x00200000 /* Balance multi-way merges */
17042
#define SQLITE_AllOpts 0xffffffff /* All optimizations */
17043
17044
/*
@@ -17340,17 +17053,16 @@ struct sqlite3 {
17053
*/
17054
#define ConstFactorOk(P) ((P)->okConstFactor)
17055
17343
-/*
17344
-** Possible values for the sqlite.magic field.
17345
-** The numbers are obtained at random and have no special meaning, other
17346
-** than being distinct from one another.
17056
+/* Possible values for the sqlite3.eOpenState field.
17057
+** The numbers are randomly selected such that a minimum of three bits must
17058
+** change to convert any number to another or to zero
17059
*/
17348
-#define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */
17349
-#define SQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */
17350
-#define SQLITE_MAGIC_SICK 0x4b771290 /* Error and awaiting close */
17351
-#define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */
17352
-#define SQLITE_MAGIC_ERROR 0xb5357930 /* An SQLITE_MISUSE error occurred */
17353
-#define SQLITE_MAGIC_ZOMBIE 0x64cffc7f /* Close with last statement close */
17060
+#define SQLITE_STATE_OPEN 0x76 /* Database is open */
17061
+#define SQLITE_STATE_CLOSED 0xce /* Database is closed */
17062
+#define SQLITE_STATE_SICK 0xba /* Error and awaiting close */
17063
+#define SQLITE_STATE_BUSY 0x6d /* Database currently in use */
17064
+#define SQLITE_STATE_ERROR 0xd5 /* An SQLITE_MISUSE error occurred */
17065
+#define SQLITE_STATE_ZOMBIE 0xa7 /* Close with last statement close */
17066
17067
/*
17068
** Each SQL function is defined by an instance of the following
@@ -17375,7 +17087,7 @@ struct FuncDef {
17087
union {
17088
FuncDef *pHash; /* Next with a different name but the same hash */
17089
FuncDestructor *pDestructor; /* Reference counted destructor function */
17378
- } u;
17090
+ } u; /* pHash if SQLITE_FUNC_BUILTIN, pDestructor otherwise */
17091
};
17092
17093
/*
@@ -17405,12 +17117,13 @@ struct FuncDestructor {
17117
** are assert() statements in the code to verify this.
17118
**
17119
** Value constraints (enforced via assert()):
17408
-** SQLITE_FUNC_MINMAX == NC_MinMaxAgg == SF_MinMaxAgg
17409
-** SQLITE_FUNC_LENGTH == OPFLAG_LENGTHARG
17410
-** SQLITE_FUNC_TYPEOF == OPFLAG_TYPEOFARG
17411
-** SQLITE_FUNC_CONSTANT == SQLITE_DETERMINISTIC from the API
17412
-** SQLITE_FUNC_DIRECT == SQLITE_DIRECTONLY from the API
17413
-** SQLITE_FUNC_UNSAFE == SQLITE_INNOCUOUS
17120
+** SQLITE_FUNC_MINMAX == NC_MinMaxAgg == SF_MinMaxAgg
17121
+** SQLITE_FUNC_ANYORDER == NC_OrderAgg == SF_OrderByReqd
17122
+** SQLITE_FUNC_LENGTH == OPFLAG_LENGTHARG
17123
+** SQLITE_FUNC_TYPEOF == OPFLAG_TYPEOFARG
17124
+** SQLITE_FUNC_CONSTANT == SQLITE_DETERMINISTIC from the API
17125
+** SQLITE_FUNC_DIRECT == SQLITE_DIRECTONLY from the API
17126
+** SQLITE_FUNC_UNSAFE == SQLITE_INNOCUOUS
17127
** SQLITE_FUNC_ENCMASK depends on SQLITE_UTF* macros in the API
17128
*/
17129
#define SQLITE_FUNC_ENCMASK 0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */
@@ -17435,6 +17148,8 @@ struct FuncDestructor {
17148
#define SQLITE_FUNC_SUBTYPE 0x00100000 /* Result likely to have sub-type */
17149
#define SQLITE_FUNC_UNSAFE 0x00200000 /* Function has side effects */
17150
#define SQLITE_FUNC_INLINE 0x00400000 /* Functions implemented in-line */
17151
+#define SQLITE_FUNC_BUILTIN 0x00800000 /* This is a built-in function */
17152
+#define SQLITE_FUNC_ANYORDER 0x08000000 /* count/min/max aggregate */
17153
17154
/* Identifier numbers for each in-line function */
17155
#define INLINEFUNC_coalesce 0
@@ -17497,7 +17212,7 @@ struct FuncDestructor {
17212
** are interpreted in the same way as the first 4 parameters to
17213
** FUNCTION().
17214
**
17500
-** WFUNCTION(zName, nArg, iArg, xStep, xFinal, xValue, xInverse)
17215
+** WAGGREGATE(zName, nArg, iArg, xStep, xFinal, xValue, xInverse)
17216
** Used to create an aggregate function definition implemented by
17217
** the C functions xStep and xFinal. The first four parameters
17218
** are interpreted in the same way as the first 4 parameters to
@@ -17512,44 +17227,55 @@ struct FuncDestructor {
17227
** parameter.
17228
*/
17229
#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
17515
- {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
17230
+ {nArg, SQLITE_FUNC_BUILTIN|\
17231
+ SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
17232
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
17233
#define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \
17518
- {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
17234
+ {nArg, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
17235
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
17236
#define SFUNCTION(zName, nArg, iArg, bNC, xFunc) \
17521
- {nArg, SQLITE_UTF8|SQLITE_DIRECTONLY|SQLITE_FUNC_UNSAFE, \
17237
+ {nArg, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|SQLITE_DIRECTONLY|SQLITE_FUNC_UNSAFE, \
17238
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
17239
#define MFUNCTION(zName, nArg, xPtr, xFunc) \
17524
- {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8, \
17240
+ {nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_CONSTANT|SQLITE_UTF8, \
17241
xPtr, 0, xFunc, 0, 0, 0, #zName, {0} }
17242
+#define JFUNCTION(zName, nArg, iArg, xFunc) \
17243
+ {nArg, SQLITE_FUNC_BUILTIN|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS|\
17244
+ SQLITE_FUNC_CONSTANT|SQLITE_UTF8, \
17245
+ SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
17246
#define INLINE_FUNC(zName, nArg, iArg, mFlags) \
17527
- {nArg, SQLITE_UTF8|SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \
17247
+ {nArg, SQLITE_FUNC_BUILTIN|\
17248
+ SQLITE_UTF8|SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \
17249
SQLITE_INT_TO_PTR(iArg), 0, noopFunc, 0, 0, 0, #zName, {0} }
17250
#define TEST_FUNC(zName, nArg, iArg, mFlags) \
17530
- {nArg, SQLITE_UTF8|SQLITE_FUNC_INTERNAL|SQLITE_FUNC_TEST| \
17251
+ {nArg, SQLITE_FUNC_BUILTIN|\
17252
+ SQLITE_UTF8|SQLITE_FUNC_INTERNAL|SQLITE_FUNC_TEST| \
17253
SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \
17254
SQLITE_INT_TO_PTR(iArg), 0, noopFunc, 0, 0, 0, #zName, {0} }
17255
#define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \
17534
- {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8, \
17256
+ {nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_SLOCHNG|SQLITE_UTF8, \
17257
0, 0, xFunc, 0, 0, 0, #zName, {0} }
17258
#define PURE_DATE(zName, nArg, iArg, bNC, xFunc) \
17537
- {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \
17259
+ {nArg, SQLITE_FUNC_BUILTIN|\
17260
+ SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \
17261
(void*)&sqlite3Config, 0, xFunc, 0, 0, 0, #zName, {0} }
17262
#define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \
17540
- {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\
17263
+ {nArg, SQLITE_FUNC_BUILTIN|\
17264
+ SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\
17265
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
17266
#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
17543
- {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
17267
+ {nArg, SQLITE_FUNC_BUILTIN|\
17268
+ SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
17269
pArg, 0, xFunc, 0, 0, 0, #zName, }
17270
#define LIKEFUNC(zName, nArg, arg, flags) \
17546
- {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \
17271
+ {nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \
17272
(void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} }
17273
#define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \
17549
- {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \
17274
+ {nArg, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \
17275
SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,xInverse,#zName, {0}}
17276
#define INTERNAL_FUNCTION(zName, nArg, xFunc) \
17552
- {nArg, SQLITE_FUNC_INTERNAL|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \
17277
+ {nArg, SQLITE_FUNC_BUILTIN|\
17278
+ SQLITE_FUNC_INTERNAL|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \
17279
0, 0, xFunc, 0, 0, 0, #zName, {0} }
17280
17281
@@ -17605,18 +17331,42 @@ struct Module {
17331
** or equal to the table column index. It is
17332
** equal if and only if there are no VIRTUAL
17333
** columns to the left.
17334
+**
17335
+** Notes on zCnName:
17336
+** The zCnName field stores the name of the column, the datatype of the
17337
+** column, and the collating sequence for the column, in that order, all in
17338
+** a single allocation. Each string is 0x00 terminated. The datatype
17339
+** is only included if the COLFLAG_HASTYPE bit of colFlags is set and the
17340
+** collating sequence name is only included if the COLFLAG_HASCOLL bit is
17341
+** set.
17342
*/
17343
struct Column {
17610
- char *zName; /* Name of this column, \000, then the type */
17611
- Expr *pDflt; /* Default value or GENERATED ALWAYS AS value */
17612
- char *zColl; /* Collating sequence. If NULL, use the default */
17613
- u8 notNull; /* An OE_ code for handling a NOT NULL constraint */
17614
- char affinity; /* One of the SQLITE_AFF_... values */
17615
- u8 szEst; /* Estimated size of value in this column. sizeof(INT)==1 */
17616
- u8 hName; /* Column name hash for faster lookup */
17617
- u16 colFlags; /* Boolean properties. See COLFLAG_ defines below */
17344
+ char *zCnName; /* Name of this column */
17345
+ unsigned notNull :4; /* An OE_ code for handling a NOT NULL constraint */
17346
+ unsigned eCType :4; /* One of the standard types */
17347
+ char affinity; /* One of the SQLITE_AFF_... values */
17348
+ u8 szEst; /* Est size of value in this column. sizeof(INT)==1 */
17349
+ u8 hName; /* Column name hash for faster lookup */
17350
+ u16 iDflt; /* 1-based index of DEFAULT. 0 means "none" */
17351
+ u16 colFlags; /* Boolean properties. See COLFLAG_ defines below */
17352
};
17353
17354
+/* Allowed values for Column.eCType.
17355
+**
17356
+** Values must match entries in the global constant arrays
17357
+** sqlite3StdTypeLen[] and sqlite3StdType[]. Each value is one more
17358
+** than the offset into these arrays for the corresponding name.
17359
+** Adjust the SQLITE_N_STDTYPE value if adding or removing entries.
17360
+*/
17361
+#define COLTYPE_CUSTOM 0 /* Type appended to zName */
17362
+#define COLTYPE_ANY 1
17363
+#define COLTYPE_BLOB 2
17364
+#define COLTYPE_INT 3
17365
+#define COLTYPE_INTEGER 4
17366
+#define COLTYPE_REAL 5
17367
+#define COLTYPE_TEXT 6
17368
+#define SQLITE_N_STDTYPE 6 /* Number of standard types */
17369
+
17370
/* Allowed values for Column.colFlags.
17371
**
17372
** Constraints:
@@ -17633,6 +17383,7 @@ struct Column {
17383
#define COLFLAG_STORED 0x0040 /* GENERATED ALWAYS AS ... STORED */
17384
#define COLFLAG_NOTAVAIL 0x0080 /* STORED column not yet calculated */
17385
#define COLFLAG_BUSY 0x0100 /* Blocks recursion on GENERATED columns */
17386
+#define COLFLAG_HASCOLL 0x0200 /* Has collating sequence name in zCnName */
17387
#define COLFLAG_GENERATED 0x0060 /* Combo: _STORED, _VIRTUAL */
17388
#define COLFLAG_NOINSERT 0x0062 /* Combo: _HIDDEN, _STORED, _VIRTUAL */
17389
@@ -17762,15 +17513,13 @@ struct VTable {
17513
#define SQLITE_VTABRISK_High 2
17514
17515
/*
17765
-** The schema for each SQL table and view is represented in memory
17766
-** by an instance of the following structure.
17516
+** The schema for each SQL table, virtual table, and view is represented
17517
+** in memory by an instance of the following structure.
17518
*/
17519
struct Table {
17520
char *zName; /* Name of the table or view */
17521
Column *aCol; /* Information about each column */
17522
Index *pIndex; /* List of SQL indexes on this table. */
17772
- Select *pSelect; /* NULL for tables. Points to definition if a view. */
17773
- FKey *pFKey; /* Linked list of all foreign keys in this table */
17523
char *zColAff; /* String defining the affinity of each column */
17524
ExprList *pCheck; /* All CHECK constraints */
17525
/* ... also used as column name list in a VIEW */
@@ -17786,15 +17535,24 @@ struct Table {
17535
LogEst costMult; /* Cost multiplier for using this table */
17536
#endif
17537
u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */
17789
-#ifndef SQLITE_OMIT_ALTERTABLE
17790
- int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
17791
-#endif
17792
-#ifndef SQLITE_OMIT_VIRTUALTABLE
17793
- int nModuleArg; /* Number of arguments to the module */
17794
- char **azModuleArg; /* 0: module 1: schema 2: vtab name 3...: args */
17795
- VTable *pVTable; /* List of VTable objects. */
17796
-#endif
17797
- Trigger *pTrigger; /* List of triggers stored in pSchema */
17538
+ u8 eTabType; /* 0: normal, 1: virtual, 2: view */
17539
+ union {
17540
+ struct { /* Used by ordinary tables: */
17541
+ int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
17542
+ FKey *pFKey; /* Linked list of all foreign keys in this table */
17543
+ ExprList *pDfltList; /* DEFAULT clauses on various columns.
17544
+ ** Or the AS clause for generated columns. */
17545
+ } tab;
17546
+ struct { /* Used by views: */
17547
+ Select *pSelect; /* View definition */
17548
+ } view;
17549
+ struct { /* Used by virtual tables only: */
17550
+ int nArg; /* Number of arguments to the module */
17551
+ char **azArg; /* 0: module 1: schema 2: vtab name 3...: args */
17552
+ VTable *p; /* List of VTable objects. */
17553
+ } vtab;
17554
+ } u;
17555
+ Trigger *pTrigger; /* List of triggers on this object */
17556
Schema *pSchema; /* Schema that contains this table */
17557
};
17558
@@ -17813,24 +17571,35 @@ struct Table {
17571
** TF_HasStored == COLFLAG_STORED
17572
** TF_HasHidden == COLFLAG_HIDDEN
17573
*/
17816
-#define TF_Readonly 0x0001 /* Read-only system table */
17817
-#define TF_HasHidden 0x0002 /* Has one or more hidden columns */
17818
-#define TF_HasPrimaryKey 0x0004 /* Table has a primary key */
17819
-#define TF_Autoincrement 0x0008 /* Integer primary key is autoincrement */
17820
-#define TF_HasStat1 0x0010 /* nRowLogEst set from sqlite_stat1 */
17821
-#define TF_HasVirtual 0x0020 /* Has one or more VIRTUAL columns */
17822
-#define TF_HasStored 0x0040 /* Has one or more STORED columns */
17823
-#define TF_HasGenerated 0x0060 /* Combo: HasVirtual + HasStored */
17824
-#define TF_WithoutRowid 0x0080 /* No rowid. PRIMARY KEY is the key */
17825
-#define TF_StatsUsed 0x0100 /* Query planner decisions affected by
17574
+#define TF_Readonly 0x00000001 /* Read-only system table */
17575
+#define TF_HasHidden 0x00000002 /* Has one or more hidden columns */
17576
+#define TF_HasPrimaryKey 0x00000004 /* Table has a primary key */
17577
+#define TF_Autoincrement 0x00000008 /* Integer primary key is autoincrement */
17578
+#define TF_HasStat1 0x00000010 /* nRowLogEst set from sqlite_stat1 */
17579
+#define TF_HasVirtual 0x00000020 /* Has one or more VIRTUAL columns */
17580
+#define TF_HasStored 0x00000040 /* Has one or more STORED columns */
17581
+#define TF_HasGenerated 0x00000060 /* Combo: HasVirtual + HasStored */
17582
+#define TF_WithoutRowid 0x00000080 /* No rowid. PRIMARY KEY is the key */
17583
+#define TF_StatsUsed 0x00000100 /* Query planner decisions affected by
17584
** Index.aiRowLogEst[] values */
17827
-#define TF_NoVisibleRowid 0x0200 /* No user-visible "rowid" column */
17828
-#define TF_OOOHidden 0x0400 /* Out-of-Order hidden columns */
17829
-#define TF_HasNotNull 0x0800 /* Contains NOT NULL constraints */
17830
-#define TF_Shadow 0x1000 /* True for a shadow table */
17831
-#define TF_HasStat4 0x2000 /* STAT4 info available for this table */
17832
-#define TF_Ephemeral 0x4000 /* An ephemeral table */
17833
-#define TF_Eponymous 0x8000 /* An eponymous virtual table */
17585
+#define TF_NoVisibleRowid 0x00000200 /* No user-visible "rowid" column */
17586
+#define TF_OOOHidden 0x00000400 /* Out-of-Order hidden columns */
17587
+#define TF_HasNotNull 0x00000800 /* Contains NOT NULL constraints */
17588
+#define TF_Shadow 0x00001000 /* True for a shadow table */
17589
+#define TF_HasStat4 0x00002000 /* STAT4 info available for this table */
17590
+#define TF_Ephemeral 0x00004000 /* An ephemeral table */
17591
+#define TF_Eponymous 0x00008000 /* An eponymous virtual table */
17592
+#define TF_Strict 0x00010000 /* STRICT mode */
17593
+
17594
+/*
17595
+** Allowed values for Table.eTabType
17596
+*/
17597
+#define TABTYP_NORM 0 /* Ordinary table */
17598
+#define TABTYP_VTAB 1 /* Virtual table */
17599
+#define TABTYP_VIEW 2 /* A view */
17600
+
17601
+#define IsView(X) ((X)->eTabType==TABTYP_VIEW)
17602
+#define IsOrdinaryTable(X) ((X)->eTabType==TABTYP_NORM)
17603
17604
/*
17605
** Test to see whether or not a table is a virtual table. This is
@@ -17838,9 +17607,9 @@ struct Table {
17607
** table support is omitted from the build.
17608
*/
17609
#ifndef SQLITE_OMIT_VIRTUALTABLE
17841
-# define IsVirtual(X) ((X)->nModuleArg)
17610
+# define IsVirtual(X) ((X)->eTabType==TABTYP_VTAB)
17611
# define ExprIsVtab(X) \
17843
- ((X)->op==TK_COLUMN && (X)->y.pTab!=0 && (X)->y.pTab->nModuleArg)
17612
+ ((X)->op==TK_COLUMN && (X)->y.pTab!=0 && (X)->y.pTab->eTabType==TABTYP_VTAB)
17613
#else
17614
# define IsVirtual(X) 0
17615
# define ExprIsVtab(X) 0
@@ -18229,10 +17998,10 @@ typedef int ynVar;
17998
** tree.
17999
**
18000
** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB,
18232
-** or TK_STRING), then Expr.token contains the text of the SQL literal. If
18233
-** the expression is a variable (TK_VARIABLE), then Expr.token contains the
18001
+** or TK_STRING), then Expr.u.zToken contains the text of the SQL literal. If
18002
+** the expression is a variable (TK_VARIABLE), then Expr.u.zToken contains the
18003
** variable name. Finally, if the expression is an SQL function (TK_FUNCTION),
18235
-** then Expr.token contains the name of the function.
18004
+** then Expr.u.zToken contains the name of the function.
18005
**
18006
** Expr.pRight and Expr.pLeft are the left and right subexpressions of a
18007
** binary operator. Either or both may be NULL.
@@ -18272,7 +18041,7 @@ typedef int ynVar;
18041
** help reduce memory requirements, sometimes an Expr object will be
18042
** truncated. And to reduce the number of memory allocations, sometimes
18043
** two or more Expr objects will be stored in a single memory allocation,
18275
-** together with Expr.zToken strings.
18044
+** together with Expr.u.zToken strings.
18045
**
18046
** If the EP_Reduced and EP_TokenOnly flags are set when
18047
** an Expr object is truncated. When EP_Reduced is set, then all
@@ -18328,7 +18097,10 @@ struct Expr {
18097
** TK_VARIABLE: variable number (always >= 1).
18098
** TK_SELECT_COLUMN: column of the result vector */
18099
i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
18331
- int iRightJoinTable; /* If EP_FromJoin, the right table of the join */
18100
+ union {
18101
+ int iRightJoinTable; /* If EP_FromJoin, the right table of the join */
18102
+ int iOfst; /* else: start of token from start of statement */
18103
+ } w;
18104
AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
18105
union {
18106
Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
@@ -18341,8 +18113,7 @@ struct Expr {
18113
} y;
18114
};
18115
18344
-/*
18345
-** The following are the meanings of bits in the Expr.flags field.
18116
+/* The following are the meanings of bits in the Expr.flags field.
18117
** Value restrictions:
18118
**
18119
** EP_Agg == NC_HasAgg == SF_HasAgg
@@ -18381,14 +18152,12 @@ struct Expr {
18152
#define EP_FromDDL 0x40000000 /* Originates from sqlite_schema */
18153
/* 0x80000000 // Available */
18154
18384
-/*
18385
-** The EP_Propagate mask is a set of properties that automatically propagate
18155
+/* The EP_Propagate mask is a set of properties that automatically propagate
18156
** upwards into parent nodes.
18157
*/
18158
#define EP_Propagate (EP_Collate|EP_Subquery|EP_HasFunc)
18159
18390
-/*
18391
-** These macros can be used to test, set, or clear bits in the
18160
+/* Macros can be used to test, set, or clear bits in the
18161
** Expr.flags field.
18162
*/
18163
#define ExprHasProperty(E,P) (((E)->flags&(P))!=0)
@@ -18398,6 +18167,16 @@ struct Expr {
18167
#define ExprAlwaysTrue(E) (((E)->flags&(EP_FromJoin|EP_IsTrue))==EP_IsTrue)
18168
#define ExprAlwaysFalse(E) (((E)->flags&(EP_FromJoin|EP_IsFalse))==EP_IsFalse)
18169
18170
+/* Macros used to ensure that the correct members of unions are accessed
18171
+** in Expr.
18172
+*/
18173
+#define ExprUseUToken(E) (((E)->flags&EP_IntValue)==0)
18174
+#define ExprUseUValue(E) (((E)->flags&EP_IntValue)!=0)
18175
+#define ExprUseXList(E) (((E)->flags&EP_xIsSelect)==0)
18176
+#define ExprUseXSelect(E) (((E)->flags&EP_xIsSelect)!=0)
18177
+#define ExprUseYTab(E) (((E)->flags&(EP_WinFunc|EP_Subrtn))==0)
18178
+#define ExprUseYWin(E) (((E)->flags&EP_WinFunc)!=0)
18179
+#define ExprUseYSub(E) (((E)->flags&EP_Subrtn)!=0)
18180
18181
/* Flags for use with Expr.vvaFlags
18182
*/
@@ -18480,11 +18259,12 @@ struct ExprList {
18259
unsigned bSorterRef :1; /* Defer evaluation until after sorting */
18260
unsigned bNulls: 1; /* True if explicit "NULLS FIRST/LAST" */
18261
union {
18483
- struct {
18262
+ struct { /* Used by any ExprList other than Parse.pConsExpr */
18263
u16 iOrderByCol; /* For ORDER BY, column number in result set */
18264
u16 iAlias; /* Index into Parse.aAlias[] for zName */
18265
} x;
18487
- int iConstExprReg; /* Register in which Expr value is cached */
18266
+ int iConstExprReg; /* Register in which Expr value is cached. Used only
18267
+ ** by Parse.pConstExpr */
18268
} u;
18269
} a[1]; /* One slot for each expression in the list */
18270
};
@@ -18522,6 +18302,13 @@ struct IdList {
18302
/*
18303
** The SrcItem object represents a single term in the FROM clause of a query.
18304
** The SrcList object is mostly an array of SrcItems.
18305
+**
18306
+** Union member validity:
18307
+**
18308
+** u1.zIndexedBy fg.isIndexedBy && !fg.isTabFunc
18309
+** u1.pFuncArg fg.isTabFunc && !fg.isIndexedBy
18310
+** u2.pIBIndex fg.isIndexedBy && !fg.isCte
18311
+** u2.pCteUse fg.isCte && !fg.isIndexedBy
18312
*/
18313
struct SrcItem {
18314
Schema *pSchema; /* Schema to which this item is fixed */
@@ -18670,31 +18457,33 @@ struct NameContext {
18457
** Allowed values for the NameContext, ncFlags field.
18458
**
18459
** Value constraints (all checked via assert()):
18673
-** NC_HasAgg == SF_HasAgg == EP_Agg
18674
-** NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX
18460
+** NC_HasAgg == SF_HasAgg == EP_Agg
18461
+** NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX
18462
+** NC_OrderAgg == SF_OrderByReqd == SQLITE_FUNC_ANYORDER
18463
** NC_HasWin == EP_Win
18464
**
18465
*/
18678
-#define NC_AllowAgg 0x00001 /* Aggregate functions are allowed here */
18679
-#define NC_PartIdx 0x00002 /* True if resolving a partial index WHERE */
18680
-#define NC_IsCheck 0x00004 /* True if resolving a CHECK constraint */
18681
-#define NC_GenCol 0x00008 /* True for a GENERATED ALWAYS AS clause */
18682
-#define NC_HasAgg 0x00010 /* One or more aggregate functions seen */
18683
-#define NC_IdxExpr 0x00020 /* True if resolving columns of CREATE INDEX */
18684
-#define NC_SelfRef 0x0002e /* Combo: PartIdx, isCheck, GenCol, and IdxExpr */
18685
-#define NC_VarSelect 0x00040 /* A correlated subquery has been seen */
18686
-#define NC_UEList 0x00080 /* True if uNC.pEList is used */
18687
-#define NC_UAggInfo 0x00100 /* True if uNC.pAggInfo is used */
18688
-#define NC_UUpsert 0x00200 /* True if uNC.pUpsert is used */
18689
-#define NC_UBaseReg 0x00400 /* True if uNC.iBaseReg is used */
18690
-#define NC_MinMaxAgg 0x01000 /* min/max aggregates seen. See note above */
18691
-#define NC_Complex 0x02000 /* True if a function or subquery seen */
18692
-#define NC_AllowWin 0x04000 /* Window functions are allowed here */
18693
-#define NC_HasWin 0x08000 /* One or more window functions seen */
18694
-#define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */
18695
-#define NC_InAggFunc 0x20000 /* True if analyzing arguments to an agg func */
18696
-#define NC_FromDDL 0x40000 /* SQL text comes from sqlite_schema */
18697
-#define NC_NoSelect 0x80000 /* Do not descend into sub-selects */
18466
+#define NC_AllowAgg 0x000001 /* Aggregate functions are allowed here */
18467
+#define NC_PartIdx 0x000002 /* True if resolving a partial index WHERE */
18468
+#define NC_IsCheck 0x000004 /* True if resolving a CHECK constraint */
18469
+#define NC_GenCol 0x000008 /* True for a GENERATED ALWAYS AS clause */
18470
+#define NC_HasAgg 0x000010 /* One or more aggregate functions seen */
18471
+#define NC_IdxExpr 0x000020 /* True if resolving columns of CREATE INDEX */
18472
+#define NC_SelfRef 0x00002e /* Combo: PartIdx, isCheck, GenCol, and IdxExpr */
18473
+#define NC_VarSelect 0x000040 /* A correlated subquery has been seen */
18474
+#define NC_UEList 0x000080 /* True if uNC.pEList is used */
18475
+#define NC_UAggInfo 0x000100 /* True if uNC.pAggInfo is used */
18476
+#define NC_UUpsert 0x000200 /* True if uNC.pUpsert is used */
18477
+#define NC_UBaseReg 0x000400 /* True if uNC.iBaseReg is used */
18478
+#define NC_MinMaxAgg 0x001000 /* min/max aggregates seen. See note above */
18479
+#define NC_Complex 0x002000 /* True if a function or subquery seen */
18480
+#define NC_AllowWin 0x004000 /* Window functions are allowed here */
18481
+#define NC_HasWin 0x008000 /* One or more window functions seen */
18482
+#define NC_IsDDL 0x010000 /* Resolving names in a CREATE statement */
18483
+#define NC_InAggFunc 0x020000 /* True if analyzing arguments to an agg func */
18484
+#define NC_FromDDL 0x040000 /* SQL text comes from sqlite_schema */
18485
+#define NC_NoSelect 0x080000 /* Do not descend into sub-selects */
18486
+#define NC_OrderAgg 0x8000000 /* Has an aggregate other than count/min/max */
18487
18488
/*
18489
** An instance of the following object describes a single ON CONFLICT
@@ -18777,9 +18566,10 @@ struct Select {
18566
** "Select Flag".
18567
**
18568
** Value constraints (all checked via assert())
18780
-** SF_HasAgg == NC_HasAgg
18781
-** SF_MinMaxAgg == NC_MinMaxAgg == SQLITE_FUNC_MINMAX
18782
-** SF_FixedLimit == WHERE_USE_LIMIT
18569
+** SF_HasAgg == NC_HasAgg
18570
+** SF_MinMaxAgg == NC_MinMaxAgg == SQLITE_FUNC_MINMAX
18571
+** SF_OrderByReqd == NC_OrderAgg == SQLITE_FUNC_ANYORDER
18572
+** SF_FixedLimit == WHERE_USE_LIMIT
18573
*/
18574
#define SF_Distinct 0x0000001 /* Output should be DISTINCT */
18575
#define SF_All 0x0000002 /* Includes the ALL keyword */
@@ -18804,10 +18594,11 @@ struct Select {
18594
#define SF_WinRewrite 0x0100000 /* Window function rewrite accomplished */
18595
#define SF_View 0x0200000 /* SELECT statement is a view */
18596
#define SF_NoopOrderBy 0x0400000 /* ORDER BY is ignored for this query */
18807
-#define SF_UpdateFrom 0x0800000 /* Statement is an UPDATE...FROM */
18597
+#define SF_UFSrcCheck 0x0800000 /* Check pSrc as required by UPDATE...FROM */
18598
#define SF_PushDown 0x1000000 /* SELECT has be modified by push-down opt */
18599
#define SF_MultiPart 0x2000000 /* Has multiple incompatible PARTITIONs */
18600
#define SF_CopyCte 0x4000000 /* SELECT statement is a copy of a CTE */
18601
+#define SF_OrderByReqd 0x8000000 /* The ORDER BY clause may not be omitted */
18602
18603
/*
18604
** The results of a SELECT can be distributed in several ways, as defined
@@ -19049,7 +18840,8 @@ struct Parse {
18840
AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
18841
Parse *pToplevel; /* Parse structure for main program (or NULL) */
18842
Table *pTriggerTab; /* Table triggers are being coded for */
19052
- Parse *pParentParse; /* Parent parser if this parser is nested */
18843
+ TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
18844
+ ParseCleanup *pCleanup; /* List of cleanup operations to run after parse */
18845
union {
18846
int addrCrTab; /* Address of OP_CreateBtree on CREATE TABLE */
18847
Returning *pReturning; /* The RETURNING clause */
@@ -19070,6 +18862,7 @@ struct Parse {
18862
**************************************************************************/
18863
18864
int aTempReg[8]; /* Holding area for temporary registers */
18865
+ Parse *pOuterParse; /* Outer Parse object when nested */
18866
Token sNameToken; /* Token with unqualified schema object name */
18867
18868
/************************************************************************
@@ -19104,14 +18897,14 @@ struct Parse {
18897
Token sArg; /* Complete text of a module argument */
18898
Table **apVtabLock; /* Pointer to virtual tables needing locking */
18899
#endif
19107
- TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
18900
With *pWith; /* Current WITH clause, or NULL */
19109
- ParseCleanup *pCleanup; /* List of cleanup operations to run after parse */
18901
#ifndef SQLITE_OMIT_ALTERTABLE
18902
RenameToken *pRename; /* Tokens subject to renaming by ALTER TABLE */
18903
#endif
18904
};
18905
18906
+/* Allowed values for Parse.eParseMode
18907
+*/
18908
#define PARSE_MODE_NORMAL 0
18909
#define PARSE_MODE_DECLARE_VTAB 1
18910
#define PARSE_MODE_RENAME 2
@@ -19120,7 +18913,8 @@ struct Parse {
18913
/*
18914
** Sizes and pointers of various parts of the Parse object.
18915
*/
19123
-#define PARSE_HDR_SZ offsetof(Parse,aTempReg) /* Recursive part w/o aColCache*/
18916
+#define PARSE_HDR(X) (((char*)(X))+offsetof(Parse,zErrMsg))
18917
+#define PARSE_HDR_SZ (offsetof(Parse,aTempReg)-offsetof(Parse,zErrMsg)) /* Recursive part w/o aColCache*/
18918
#define PARSE_RECURSE_SZ offsetof(Parse,sLastToken) /* Recursive part */
18919
#define PARSE_TAIL_SZ (sizeof(Parse)-PARSE_RECURSE_SZ) /* Non-recursive part */
18920
#define PARSE_TAIL(X) (((char*)(X))+PARSE_RECURSE_SZ) /* Pointer to tail */
@@ -19333,8 +19127,10 @@ typedef struct {
19127
/*
19128
** Allowed values for mInitFlags
19129
*/
19130
+#define INITFLAG_AlterMask 0x0003 /* Types of ALTER */
19131
#define INITFLAG_AlterRename 0x0001 /* Reparse after a RENAME */
19132
#define INITFLAG_AlterDrop 0x0002 /* Reparse after a DROP COLUMN */
19133
+#define INITFLAG_AlterAdd 0x0003 /* Reparse after an ADD COLUMN */
19134
19135
/* Tuning parameters are set using SQLITE_TESTCTRL_TUNE and are controlled
19136
** on debug-builds of the CLI using ".testctrl tune ID VALUE". Tuning
@@ -19413,6 +19209,7 @@ struct Sqlite3Config {
19209
int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */
19210
#endif
19211
int bLocaltimeFault; /* True to fail localtime() calls */
19212
+ int (*xAltLocaltime)(const void*,void*); /* Alternative localtime() routine */
19213
int iOnceResetThreshold; /* When to reset OP_Once counters */
19214
u32 szSorterRef; /* Min size in bytes to use sorter-refs */
19215
unsigned int iPrngSeed; /* Alternative fixed seed for the PRNG */
@@ -19455,8 +19252,8 @@ struct Walker {
19252
int n; /* A counter */
19253
int iCur; /* A cursor number */
19254
SrcList *pSrcList; /* FROM clause */
19458
- struct SrcCount *pSrcCount; /* Counting column references */
19255
struct CCurHint *pCCurHint; /* Used by codeCursorHint() */
19256
+ struct RefSrcList *pRefSrcList; /* sqlite3ReferencesSrcList() */
19257
int *aiCol; /* array of column indexes */
19258
struct IdxCover *pIdxCover; /* Check for index coverage */
19259
struct IdxExprTrans *pIdxTrans; /* Convert idxed expr to column */
@@ -19641,7 +19438,7 @@ SQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p);
19438
SQLITE_PRIVATE Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*, u8);
19439
SQLITE_PRIVATE void sqlite3WindowAttach(Parse*, Expr*, Window*);
19440
SQLITE_PRIVATE void sqlite3WindowLink(Select *pSel, Window *pWin);
19644
-SQLITE_PRIVATE int sqlite3WindowCompare(Parse*, Window*, Window*, int);
19441
+SQLITE_PRIVATE int sqlite3WindowCompare(const Parse*, const Window*, const Window*, int);
19442
SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Select*);
19443
SQLITE_PRIVATE void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int);
19444
SQLITE_PRIVATE int sqlite3WindowRewrite(Parse*, Select*);
@@ -19773,8 +19570,8 @@ SQLITE_PRIVATE void *sqlite3DbReallocOrFree(sqlite3 *, void *, u64);
19570
SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *, void *, u64);
19571
SQLITE_PRIVATE void sqlite3DbFree(sqlite3*, void*);
19572
SQLITE_PRIVATE void sqlite3DbFreeNN(sqlite3*, void*);
19776
-SQLITE_PRIVATE int sqlite3MallocSize(void*);
19777
-SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3*, void*);
19573
+SQLITE_PRIVATE int sqlite3MallocSize(const void*);
19574
+SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3*, const void*);
19575
SQLITE_PRIVATE void *sqlite3PageMalloc(int);
19576
SQLITE_PRIVATE void sqlite3PageFree(void*);
19577
SQLITE_PRIVATE void sqlite3MemSetDefault(void);
@@ -19890,9 +19687,10 @@ SQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...);
19687
SQLITE_PRIVATE int sqlite3ErrorToParser(sqlite3*,int);
19688
SQLITE_PRIVATE void sqlite3Dequote(char*);
19689
SQLITE_PRIVATE void sqlite3DequoteExpr(Expr*);
19690
+SQLITE_PRIVATE void sqlite3DequoteToken(Token*);
19691
SQLITE_PRIVATE void sqlite3TokenInit(Token*,char*);
19692
SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char*, int);
19895
-SQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*, char **);
19693
+SQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*);
19694
SQLITE_PRIVATE void sqlite3FinishCoding(Parse*);
19695
SQLITE_PRIVATE int sqlite3GetTempReg(Parse*);
19696
SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse*,int);
@@ -19909,16 +19707,17 @@ SQLITE_PRIVATE Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*);
19707
SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*);
19708
SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse*,Expr*, Expr*);
19709
SQLITE_PRIVATE Expr *sqlite3ExprSimplifiedAndOr(Expr*);
19912
-SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*, int);
19913
-SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,Expr*,FuncDef*);
19710
+SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, const Token*, int);
19711
+SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*);
19712
SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32);
19713
SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
19714
SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse*, Expr*);
19715
SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*);
19716
SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
19717
SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
19718
+SQLITE_PRIVATE Select *sqlite3ExprListToValues(Parse*, int, ExprList*);
19719
SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int,int);
19921
-SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
19720
+SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,const Token*,int);
19721
SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);
19722
SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);
19723
SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);
@@ -19934,6 +19733,10 @@ SQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3*);
19733
SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3*,int);
19734
SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*);
19735
SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*);
19736
+SQLITE_PRIVATE void sqlite3ColumnSetExpr(Parse*,Table*,Column*,Expr*);
19737
+SQLITE_PRIVATE Expr *sqlite3ColumnExpr(Table*,Column*);
19738
+SQLITE_PRIVATE void sqlite3ColumnSetColl(sqlite3*,Column*,const char*zColl);
19739
+SQLITE_PRIVATE const char *sqlite3ColumnColl(Column*);
19740
SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*);
19741
SQLITE_PRIVATE void sqlite3GenerateColumnNames(Parse *pParse, Select *pSelect);
19742
SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
@@ -19955,14 +19758,14 @@ SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table*, Column*);
19758
#else
19759
# define sqlite3ColumnPropertiesFromName(T,C) /* no-op */
19760
#endif
19958
-SQLITE_PRIVATE void sqlite3AddColumn(Parse*,Token*,Token*);
19761
+SQLITE_PRIVATE void sqlite3AddColumn(Parse*,Token,Token);
19762
SQLITE_PRIVATE void sqlite3AddNotNull(Parse*, int);
19763
SQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);
19764
SQLITE_PRIVATE void sqlite3AddCheckConstraint(Parse*, Expr*, const char*, const char*);
19765
SQLITE_PRIVATE void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*);
19766
SQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*);
19767
SQLITE_PRIVATE void sqlite3AddGenerated(Parse*,Expr*,Token*);
19965
-SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);
19768
+SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u32,Select*);
19769
SQLITE_PRIVATE void sqlite3AddReturning(Parse*,ExprList*);
19770
SQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*,
19771
sqlite3_vfs**,char**,char **);
@@ -20048,10 +19851,12 @@ SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
19851
#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
19852
SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
19853
#endif
19854
+SQLITE_PRIVATE void sqlite3CodeChangeCount(Vdbe*,int,const char*);
19855
SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*, ExprList*, Expr*);
19856
SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*,Expr*,int,ExprList*,Expr*,
19857
Upsert*);
20054
-SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
19858
+SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,
19859
+ ExprList*,Select*,u16,int);
19860
SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
19861
SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);
19862
SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*);
@@ -20072,7 +19877,7 @@ SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int
19877
SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);
19878
SQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int);
19879
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
20075
-SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(Parse*, Column*, int);
19880
+SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(Parse*, Table*, Column*, int);
19881
#endif
19882
SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int);
19883
SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
@@ -20091,23 +19896,24 @@ SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3*,const char*, const char*);
19896
#define LOCATE_VIEW 0x01
19897
#define LOCATE_NOERR 0x02
19898
SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,u32 flags,const char*, const char*);
19899
+SQLITE_PRIVATE const char *sqlite3PreferredTableName(const char*);
19900
SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,u32 flags,SrcItem *);
19901
SQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*);
19902
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
19903
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
19904
SQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*,Expr*);
19905
SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int, sqlite3_value*);
20100
-SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
20101
-SQLITE_PRIVATE int sqlite3ExprCompare(Parse*,Expr*, Expr*, int);
20102
-SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*, Expr*, int);
20103
-SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
20104
-SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse*,Expr*, Expr*, int);
19906
+SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, const Token*);
19907
+SQLITE_PRIVATE int sqlite3ExprCompare(const Parse*,const Expr*,const Expr*, int);
19908
+SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*,Expr*,int);
19909
+SQLITE_PRIVATE int sqlite3ExprListCompare(const ExprList*,const ExprList*, int);
19910
+SQLITE_PRIVATE int sqlite3ExprImpliesExpr(const Parse*,const Expr*,const Expr*, int);
19911
SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr*,int);
19912
SQLITE_PRIVATE void sqlite3AggInfoPersistWalkerInit(Walker*,Parse*);
19913
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
19914
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
19915
SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);
20110
-SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
19916
+SQLITE_PRIVATE int sqlite3ReferencesSrcList(Parse*, Expr*, SrcList*);
19917
SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
19918
#ifndef SQLITE_UNTESTABLE
19919
SQLITE_PRIVATE void sqlite3PrngSaveState(void);
@@ -20129,10 +19935,11 @@ SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*);
19935
SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*, u8);
19936
SQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*);
19937
SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr*,int);
19938
+SQLITE_PRIVATE int sqlite3ExprIsTableConstraint(Expr*,const SrcItem*);
19939
#ifdef SQLITE_ENABLE_CURSOR_HINTS
19940
SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr*);
19941
#endif
20135
-SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*);
19942
+SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr*, int*);
19943
SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*);
19944
SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
19945
SQLITE_PRIVATE int sqlite3IsRowid(const char*);
@@ -20157,17 +19964,22 @@ SQLITE_PRIVATE void sqlite3MayAbort(Parse*);
19964
SQLITE_PRIVATE void sqlite3HaltConstraint(Parse*, int, int, char*, i8, u8);
19965
SQLITE_PRIVATE void sqlite3UniqueConstraint(Parse*, int, Index*);
19966
SQLITE_PRIVATE void sqlite3RowidConstraint(Parse*, int, Table*);
20160
-SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int);
20161
-SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);
20162
-SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
20163
-SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);
20164
-SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int);
19967
+SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,const Expr*,int);
19968
+SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,const ExprList*,int);
19969
+SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,const SrcList*,int);
19970
+SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,const IdList*);
19971
+SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,const Select*,int);
19972
SQLITE_PRIVATE FuncDef *sqlite3FunctionSearch(int,const char*);
19973
SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(FuncDef*,int);
19974
SQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,u8,u8);
19975
+SQLITE_PRIVATE void sqlite3QuoteValue(StrAccum*,sqlite3_value*);
19976
SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void);
19977
SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);
19978
+SQLITE_PRIVATE void sqlite3RegisterJsonFunctions(void);
19979
SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);
19980
+#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_JSON)
19981
+SQLITE_PRIVATE int sqlite3JsonTableFunctions(sqlite3*);
19982
+#endif
19983
SQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3*);
19984
SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3*);
19985
SQLITE_PRIVATE void sqlite3ChangeCookie(Parse*, int);
@@ -20257,14 +20069,8 @@ SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte);
20069
SQLITE_PRIVATE u32 sqlite3Utf8Read(const u8**);
20070
SQLITE_PRIVATE LogEst sqlite3LogEst(u64);
20071
SQLITE_PRIVATE LogEst sqlite3LogEstAdd(LogEst,LogEst);
20260
-#ifndef SQLITE_OMIT_VIRTUALTABLE
20072
SQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double);
20262
-#endif
20263
-#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
20264
- defined(SQLITE_ENABLE_STAT4) || \
20265
- defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
20073
SQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst);
20267
-#endif
20074
SQLITE_PRIVATE VList *sqlite3VListAdd(sqlite3*,VList*,const char*,int,int);
20075
SQLITE_PRIVATE const char *sqlite3VListNumToName(VList*,int);
20076
SQLITE_PRIVATE int sqlite3VListNameToNum(VList*,const char*,int);
@@ -20299,7 +20105,7 @@ SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3*, Index*);
20105
SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe*, Table*, int);
20106
SQLITE_PRIVATE char sqlite3CompareAffinity(const Expr *pExpr, char aff2);
20107
SQLITE_PRIVATE int sqlite3IndexAffinityOk(const Expr *pExpr, char idx_affinity);
20302
-SQLITE_PRIVATE char sqlite3TableColumnAffinity(Table*,int);
20108
+SQLITE_PRIVATE char sqlite3TableColumnAffinity(const Table*,int);
20109
SQLITE_PRIVATE char sqlite3ExprAffinity(const Expr *pExpr);
20110
SQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*, int, u8);
20111
SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*);
@@ -20328,14 +20134,14 @@ SQLITE_PRIVATE void sqlite3SetTextEncoding(sqlite3 *db, u8);
20134
SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, const Expr *pExpr);
20135
SQLITE_PRIVATE CollSeq *sqlite3ExprNNCollSeq(Parse *pParse, const Expr *pExpr);
20136
SQLITE_PRIVATE int sqlite3ExprCollSeqMatch(Parse*,const Expr*,const Expr*);
20331
-SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);
20332
-SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);
20137
+SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(const Parse *pParse, Expr*, const Token*, int);
20138
+SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(const Parse*,Expr*,const char*);
20139
SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);
20140
SQLITE_PRIVATE Expr *sqlite3ExprSkipCollateAndLikely(Expr*);
20141
SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);
20142
SQLITE_PRIVATE int sqlite3WritableSchema(sqlite3*);
20143
SQLITE_PRIVATE int sqlite3CheckObjectName(Parse*, const char*,const char*,const char*);
20338
-SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int);
20144
+SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, i64);
20145
SQLITE_PRIVATE int sqlite3AddInt64(i64*,i64);
20146
SQLITE_PRIVATE int sqlite3SubInt64(i64*,i64);
20147
SQLITE_PRIVATE int sqlite3MulInt64(i64*,i64);
@@ -20360,11 +20166,15 @@ SQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *);
20166
#ifndef SQLITE_OMIT_UTF16
20167
SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8);
20168
#endif
20363
-SQLITE_PRIVATE int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **);
20169
+SQLITE_PRIVATE int sqlite3ValueFromExpr(sqlite3 *, const Expr *, u8, u8, sqlite3_value **);
20170
SQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
20171
#ifndef SQLITE_AMALGAMATION
20172
SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[];
20173
SQLITE_PRIVATE const char sqlite3StrBINARY[];
20174
+SQLITE_PRIVATE const unsigned char sqlite3StdTypeLen[];
20175
+SQLITE_PRIVATE const char sqlite3StdTypeAffinity[];
20176
+SQLITE_PRIVATE const char sqlite3StdTypeMap[];
20177
+SQLITE_PRIVATE const char *sqlite3StdType[];
20178
SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[];
20179
SQLITE_PRIVATE const unsigned char *sqlite3aLTb;
20180
SQLITE_PRIVATE const unsigned char *sqlite3aEQb;
@@ -20408,9 +20218,9 @@ SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const
20218
SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
20219
SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
20220
SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
20411
-SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse*, SrcList*, Token*);
20412
-SQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse*, void*, Token*);
20413
-SQLITE_PRIVATE void sqlite3RenameTokenRemap(Parse*, void *pTo, void *pFrom);
20221
+SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse*, SrcList*, const Token*);
20222
+SQLITE_PRIVATE const void *sqlite3RenameTokenMap(Parse*, const void*, const Token*);
20223
+SQLITE_PRIVATE void sqlite3RenameTokenRemap(Parse*, const void *pTo, const void *pFrom);
20224
SQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse*, Expr*);
20225
SQLITE_PRIVATE void sqlite3RenameExprlistUnmap(Parse*, ExprList*);
20226
SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
@@ -20447,15 +20257,20 @@ SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
20257
FuncDestructor *pDestructor
20258
);
20259
SQLITE_PRIVATE void sqlite3NoopDestructor(void*);
20450
-SQLITE_PRIVATE void sqlite3OomFault(sqlite3*);
20260
+SQLITE_PRIVATE void *sqlite3OomFault(sqlite3*);
20261
SQLITE_PRIVATE void sqlite3OomClear(sqlite3*);
20262
SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int);
20263
SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *);
20264
20265
SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);
20266
+SQLITE_PRIVATE int sqlite3StrAccumEnlarge(StrAccum*, int);
20267
SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*);
20268
+SQLITE_PRIVATE void sqlite3StrAccumSetError(StrAccum*, u8);
20269
+SQLITE_PRIVATE void sqlite3ResultStrAccum(sqlite3_context*,StrAccum*);
20270
SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int);
20271
SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);
20272
+SQLITE_PRIVATE void sqlite3RecordErrorByteOffset(sqlite3*,const char*);
20273
+SQLITE_PRIVATE void sqlite3RecordErrorOffsetOfExpr(sqlite3*,const Expr*);
20274
20275
SQLITE_PRIVATE void sqlite3BackupRestart(sqlite3_backup *);
20276
SQLITE_PRIVATE void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);
@@ -20506,7 +20321,7 @@ SQLITE_PRIVATE int sqlite3Utf8To8(unsigned char*);
20321
#endif
20322
20323
#ifdef SQLITE_OMIT_VIRTUALTABLE
20509
-# define sqlite3VtabClear(Y)
20324
+# define sqlite3VtabClear(D,T)
20325
# define sqlite3VtabSync(X,Y) SQLITE_OK
20326
# define sqlite3VtabRollback(X)
20327
# define sqlite3VtabCommit(X)
@@ -20543,9 +20358,11 @@ SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db);
20358
#ifndef SQLITE_OMIT_VIRTUALTABLE
20359
SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName);
20360
SQLITE_PRIVATE int sqlite3IsShadowTableOf(sqlite3*,Table*,const char*);
20361
+SQLITE_PRIVATE void sqlite3MarkAllShadowTablesOf(sqlite3*, Table*);
20362
#else
20363
# define sqlite3ShadowTableName(A,B) 0
20364
# define sqlite3IsShadowTableOf(A,B,C) 0
20365
+# define sqlite3MarkAllShadowTablesOf(A,B)
20366
#endif
20367
SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*);
20368
SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*);
@@ -20558,11 +20375,17 @@ SQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);
20375
SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);
20376
SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
20377
SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);
20378
+
20379
SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
20380
+#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
20381
+ && !defined(SQLITE_OMIT_VIRTUALTABLE)
20382
+SQLITE_PRIVATE void sqlite3VtabWriteAll(sqlite3_index_info*);
20383
+#endif
20384
SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
20385
SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
20386
SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
20565
-SQLITE_PRIVATE void sqlite3ParserReset(Parse*);
20387
+SQLITE_PRIVATE void sqlite3ParseObjectInit(Parse*,sqlite3*);
20388
+SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse*);
20389
SQLITE_PRIVATE void *sqlite3ParserAddCleanup(Parse*,void(*)(sqlite3*,void*),void*);
20390
#ifdef SQLITE_ENABLE_NORMALIZE
20391
SQLITE_PRIVATE char *sqlite3Normalize(Vdbe*, const char*);
@@ -20588,7 +20411,7 @@ SQLITE_PRIVATE With *sqlite3WithPush(Parse*, With*, u8);
20411
# define sqlite3CteDelete(D,C)
20412
# define sqlite3CteWithAdd(P,W,C) ((void*)0)
20413
# define sqlite3WithDelete(x,y)
20591
-# define sqlite3WithPush(x,y,z)
20414
+# define sqlite3WithPush(x,y,z) ((void*)0)
20415
#endif
20416
#ifndef SQLITE_OMIT_UPSERT
20417
SQLITE_PRIVATE Upsert *sqlite3UpsertNew(sqlite3*,ExprList*,Expr*,ExprList*,Expr*,Upsert*);
@@ -20621,6 +20444,7 @@ SQLITE_PRIVATE void sqlite3FkActions(Parse*, Table*, ExprList*, int, int*, int
20444
SQLITE_PRIVATE int sqlite3FkRequired(Parse*, Table*, int*, int);
20445
SQLITE_PRIVATE u32 sqlite3FkOldmask(Parse*, Table*);
20446
SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
20447
+SQLITE_PRIVATE void sqlite3FkClearTriggerCache(sqlite3*,int);
20448
#else
20449
#define sqlite3FkActions(a,b,c,d,e,f)
20450
#define sqlite3FkCheck(a,b,c,d,e,f)
@@ -20628,6 +20452,7 @@ SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
20452
#define sqlite3FkOldmask(a,b) 0
20453
#define sqlite3FkRequired(a,b,c,d) 0
20454
#define sqlite3FkReferences(a) 0
20455
+ #define sqlite3FkClearTriggerCache(a,b)
20456
#endif
20457
#ifndef SQLITE_OMIT_FOREIGN_KEY
20458
SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*);
@@ -20685,7 +20510,7 @@ SQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *);
20510
20511
SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p);
20512
#if SQLITE_MAX_EXPR_DEPTH>0
20688
-SQLITE_PRIVATE int sqlite3SelectExprHeight(Select *);
20513
+SQLITE_PRIVATE int sqlite3SelectExprHeight(const Select *);
20514
SQLITE_PRIVATE int sqlite3ExprCheckHeight(Parse*, int);
20515
#else
20516
#define sqlite3SelectExprHeight(x) 0
@@ -20756,8 +20581,8 @@ SQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...);
20581
*/
20582
#ifdef SQLITE_MEMDEBUG
20583
SQLITE_PRIVATE void sqlite3MemdebugSetType(void*,u8);
20759
-SQLITE_PRIVATE int sqlite3MemdebugHasType(void*,u8);
20760
-SQLITE_PRIVATE int sqlite3MemdebugNoType(void*,u8);
20584
+SQLITE_PRIVATE int sqlite3MemdebugHasType(const void*,u8);
20585
+SQLITE_PRIVATE int sqlite3MemdebugNoType(const void*,u8);
20586
#else
20587
# define sqlite3MemdebugSetType(X,Y) /* no-op */
20588
# define sqlite3MemdebugHasType(X,Y) 1
@@ -20782,10 +20607,10 @@ SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3*);
20607
SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3*);
20608
#endif
20609
20785
-SQLITE_PRIVATE int sqlite3ExprVectorSize(Expr *pExpr);
20786
-SQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr);
20610
+SQLITE_PRIVATE int sqlite3ExprVectorSize(const Expr *pExpr);
20611
+SQLITE_PRIVATE int sqlite3ExprIsVector(const Expr *pExpr);
20612
SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr*, int);
20788
-SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(Parse*,Expr*,int);
20613
+SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(Parse*,Expr*,int,int);
20614
SQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse*, Expr*);
20615
20616
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
@@ -20795,6 +20620,993 @@ SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt);
20620
#endif /* SQLITEINT_H */
20621
20622
/************** End of sqliteInt.h *******************************************/
20623
+/************** Begin file os_common.h ***************************************/
20624
+/*
20625
+** 2004 May 22
20626
+**
20627
+** The author disclaims copyright to this source code. In place of
20628
+** a legal notice, here is a blessing:
20629
+**
20630
+** May you do good and not evil.
20631
+** May you find forgiveness for yourself and forgive others.
20632
+** May you share freely, never taking more than you give.
20633
+**
20634
+******************************************************************************
20635
+**
20636
+** This file contains macros and a little bit of code that is common to
20637
+** all of the platform-specific files (os_*.c) and is #included into those
20638
+** files.
20639
+**
20640
+** This file should be #included by the os_*.c files only. It is not a
20641
+** general purpose header file.
20642
+*/
20643
+#ifndef _OS_COMMON_H_
20644
+#define _OS_COMMON_H_
20645
+
20646
+/*
20647
+** At least two bugs have slipped in because we changed the MEMORY_DEBUG
20648
+** macro to SQLITE_DEBUG and some older makefiles have not yet made the
20649
+** switch. The following code should catch this problem at compile-time.
20650
+*/
20651
+#ifdef MEMORY_DEBUG
20652
+# error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead."
20653
+#endif
20654
+
20655
+/*
20656
+** Macros for performance tracing. Normally turned off. Only works
20657
+** on i486 hardware.
20658
+*/
20659
+#ifdef SQLITE_PERFORMANCE_TRACE
20660
+
20661
+/*
20662
+** hwtime.h contains inline assembler code for implementing
20663
+** high-performance timing routines.
20664
+*/
20665
+/************** Include hwtime.h in the middle of os_common.h ****************/
20666
+/************** Begin file hwtime.h ******************************************/
20667
+/*
20668
+** 2008 May 27
20669
+**
20670
+** The author disclaims copyright to this source code. In place of
20671
+** a legal notice, here is a blessing:
20672
+**
20673
+** May you do good and not evil.
20674
+** May you find forgiveness for yourself and forgive others.
20675
+** May you share freely, never taking more than you give.
20676
+**
20677
+******************************************************************************
20678
+**
20679
+** This file contains inline asm code for retrieving "high-performance"
20680
+** counters for x86 and x86_64 class CPUs.
20681
+*/
20682
+#ifndef SQLITE_HWTIME_H
20683
+#define SQLITE_HWTIME_H
20684
+
20685
+/*
20686
+** The following routine only works on pentium-class (or newer) processors.
20687
+** It uses the RDTSC opcode to read the cycle count value out of the
20688
+** processor and returns that value. This can be used for high-res
20689
+** profiling.
20690
+*/
20691
+#if !defined(__STRICT_ANSI__) && \
20692
+ (defined(__GNUC__) || defined(_MSC_VER)) && \
20693
+ (defined(i386) || defined(__i386__) || defined(_M_IX86))
20694
+
20695
+ #if defined(__GNUC__)
20696
+
20697
+ __inline__ sqlite_uint64 sqlite3Hwtime(void){
20698
+ unsigned int lo, hi;
20699
+ __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
20700
+ return (sqlite_uint64)hi << 32 | lo;
20701
+ }
20702
+
20703
+ #elif defined(_MSC_VER)
20704
+
20705
+ __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){
20706
+ __asm {
20707
+ rdtsc
20708
+ ret ; return value at EDX:EAX
20709
+ }
20710
+ }
20711
+
20712
+ #endif
20713
+
20714
+#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__))
20715
+
20716
+ __inline__ sqlite_uint64 sqlite3Hwtime(void){
20717
+ unsigned long val;
20718
+ __asm__ __volatile__ ("rdtsc" : "=A" (val));
20719
+ return val;
20720
+ }
20721
+
20722
+#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__))
20723
+
20724
+ __inline__ sqlite_uint64 sqlite3Hwtime(void){
20725
+ unsigned long long retval;
20726
+ unsigned long junk;
20727
+ __asm__ __volatile__ ("\n\
20728
+ 1: mftbu %1\n\
20729
+ mftb %L0\n\
20730
+ mftbu %0\n\
20731
+ cmpw %0,%1\n\
20732
+ bne 1b"
20733
+ : "=r" (retval), "=r" (junk));
20734
+ return retval;
20735
+ }
20736
+
20737
+#else
20738
+
20739
+ /*
20740
+ ** asm() is needed for hardware timing support. Without asm(),
20741
+ ** disable the sqlite3Hwtime() routine.
20742
+ **
20743
+ ** sqlite3Hwtime() is only used for some obscure debugging
20744
+ ** and analysis configurations, not in any deliverable, so this
20745
+ ** should not be a great loss.
20746
+ */
20747
+SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
20748
+
20749
+#endif
20750
+
20751
+#endif /* !defined(SQLITE_HWTIME_H) */
20752
+
20753
+/************** End of hwtime.h **********************************************/
20754
+/************** Continuing where we left off in os_common.h ******************/
20755
+
20756
+static sqlite_uint64 g_start;
20757
+static sqlite_uint64 g_elapsed;
20758
+#define TIMER_START g_start=sqlite3Hwtime()
20759
+#define TIMER_END g_elapsed=sqlite3Hwtime()-g_start
20760
+#define TIMER_ELAPSED g_elapsed
20761
+#else
20762
+#define TIMER_START
20763
+#define TIMER_END
20764
+#define TIMER_ELAPSED ((sqlite_uint64)0)
20765
+#endif
20766
+
20767
+/*
20768
+** If we compile with the SQLITE_TEST macro set, then the following block
20769
+** of code will give us the ability to simulate a disk I/O error. This
20770
+** is used for testing the I/O recovery logic.
20771
+*/
20772
+#if defined(SQLITE_TEST)
20773
+SQLITE_API extern int sqlite3_io_error_hit;
20774
+SQLITE_API extern int sqlite3_io_error_hardhit;
20775
+SQLITE_API extern int sqlite3_io_error_pending;
20776
+SQLITE_API extern int sqlite3_io_error_persist;
20777
+SQLITE_API extern int sqlite3_io_error_benign;
20778
+SQLITE_API extern int sqlite3_diskfull_pending;
20779
+SQLITE_API extern int sqlite3_diskfull;
20780
+#define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)
20781
+#define SimulateIOError(CODE) \
20782
+ if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \
20783
+ || sqlite3_io_error_pending-- == 1 ) \
20784
+ { local_ioerr(); CODE; }
20785
+static void local_ioerr(){
20786
+ IOTRACE(("IOERR\n"));
20787
+ sqlite3_io_error_hit++;
20788
+ if( !sqlite3_io_error_benign ) sqlite3_io_error_hardhit++;
20789
+}
20790
+#define SimulateDiskfullError(CODE) \
20791
+ if( sqlite3_diskfull_pending ){ \
20792
+ if( sqlite3_diskfull_pending == 1 ){ \
20793
+ local_ioerr(); \
20794
+ sqlite3_diskfull = 1; \
20795
+ sqlite3_io_error_hit = 1; \
20796
+ CODE; \
20797
+ }else{ \
20798
+ sqlite3_diskfull_pending--; \
20799
+ } \
20800
+ }
20801
+#else
20802
+#define SimulateIOErrorBenign(X)
20803
+#define SimulateIOError(A)
20804
+#define SimulateDiskfullError(A)
20805
+#endif /* defined(SQLITE_TEST) */
20806
+
20807
+/*
20808
+** When testing, keep a count of the number of open files.
20809
+*/
20810
+#if defined(SQLITE_TEST)
20811
+SQLITE_API extern int sqlite3_open_file_count;
20812
+#define OpenCounter(X) sqlite3_open_file_count+=(X)
20813
+#else
20814
+#define OpenCounter(X)
20815
+#endif /* defined(SQLITE_TEST) */
20816
+
20817
+#endif /* !defined(_OS_COMMON_H_) */
20818
+
20819
+/************** End of os_common.h *******************************************/
20820
+/************** Begin file ctime.c *******************************************/
20821
+/* DO NOT EDIT!
20822
+** This file is automatically generated by the script in the canonical
20823
+** SQLite source tree at tool/mkctimec.tcl.
20824
+**
20825
+** To modify this header, edit any of the various lists in that script
20826
+** which specify categories of generated conditionals in this file.
20827
+*/
20828
+
20829
+/*
20830
+** 2010 February 23
20831
+**
20832
+** The author disclaims copyright to this source code. In place of
20833
+** a legal notice, here is a blessing:
20834
+**
20835
+** May you do good and not evil.
20836
+** May you find forgiveness for yourself and forgive others.
20837
+** May you share freely, never taking more than you give.
20838
+**
20839
+*************************************************************************
20840
+**
20841
+** This file implements routines used to report what compile-time options
20842
+** SQLite was built with.
20843
+*/
20844
+#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS /* IMP: R-16824-07538 */
20845
+
20846
+/*
20847
+** Include the configuration header output by 'configure' if we're using the
20848
+** autoconf-based build
20849
+*/
20850
+#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
20851
+/* #include "config.h" */
20852
+#define SQLITECONFIG_H 1
20853
+#endif
20854
+
20855
+/* These macros are provided to "stringify" the value of the define
20856
+** for those options in which the value is meaningful. */
20857
+#define CTIMEOPT_VAL_(opt) #opt
20858
+#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
20859
+
20860
+/* Like CTIMEOPT_VAL, but especially for SQLITE_DEFAULT_LOOKASIDE. This
20861
+** option requires a separate macro because legal values contain a single
20862
+** comma. e.g. (-DSQLITE_DEFAULT_LOOKASIDE="100,100") */
20863
+#define CTIMEOPT_VAL2_(opt1,opt2) #opt1 "," #opt2
20864
+#define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt)
20865
+/* #include "sqliteInt.h" */
20866
+
20867
+/*
20868
+** An array of names of all compile-time options. This array should
20869
+** be sorted A-Z.
20870
+**
20871
+** This array looks large, but in a typical installation actually uses
20872
+** only a handful of compile-time options, so most times this array is usually
20873
+** rather short and uses little memory space.
20874
+*/
20875
+static const char * const sqlite3azCompileOpt[] = {
20876
+
20877
+#ifdef SQLITE_32BIT_ROWID
20878
+ "32BIT_ROWID",
20879
+#endif
20880
+#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
20881
+ "4_BYTE_ALIGNED_MALLOC",
20882
+#endif
20883
+#ifdef SQLITE_64BIT_STATS
20884
+ "64BIT_STATS",
20885
+#endif
20886
+#ifdef SQLITE_ALLOW_COVERING_INDEX_SCAN
20887
+# if SQLITE_ALLOW_COVERING_INDEX_SCAN != 1
20888
+ "ALLOW_COVERING_INDEX_SCAN=" CTIMEOPT_VAL(SQLITE_ALLOW_COVERING_INDEX_SCAN),
20889
+# endif
20890
+#endif
20891
+#ifdef SQLITE_ALLOW_URI_AUTHORITY
20892
+ "ALLOW_URI_AUTHORITY",
20893
+#endif
20894
+#ifdef SQLITE_ATOMIC_INTRINSICS
20895
+ "ATOMIC_INTRINSICS=" CTIMEOPT_VAL(SQLITE_ATOMIC_INTRINSICS),
20896
+#endif
20897
+#ifdef SQLITE_BITMASK_TYPE
20898
+ "BITMASK_TYPE=" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE),
20899
+#endif
20900
+#ifdef SQLITE_BUG_COMPATIBLE_20160819
20901
+ "BUG_COMPATIBLE_20160819",
20902
+#endif
20903
+#ifdef SQLITE_CASE_SENSITIVE_LIKE
20904
+ "CASE_SENSITIVE_LIKE",
20905
+#endif
20906
+#ifdef SQLITE_CHECK_PAGES
20907
+ "CHECK_PAGES",
20908
+#endif
20909
+#if defined(__clang__) && defined(__clang_major__)
20910
+ "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "."
20911
+ CTIMEOPT_VAL(__clang_minor__) "."
20912
+ CTIMEOPT_VAL(__clang_patchlevel__),
20913
+#elif defined(_MSC_VER)
20914
+ "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER),
20915
+#elif defined(__GNUC__) && defined(__VERSION__)
20916
+ "COMPILER=gcc-" __VERSION__,
20917
+#endif
20918
+#ifdef SQLITE_COVERAGE_TEST
20919
+ "COVERAGE_TEST",
20920
+#endif
20921
+#ifdef SQLITE_DEBUG
20922
+ "DEBUG",
20923
+#endif
20924
+#ifdef SQLITE_DEFAULT_AUTOMATIC_INDEX
20925
+ "DEFAULT_AUTOMATIC_INDEX",
20926
+#endif
20927
+#ifdef SQLITE_DEFAULT_AUTOVACUUM
20928
+ "DEFAULT_AUTOVACUUM",
20929
+#endif
20930
+#ifdef SQLITE_DEFAULT_CACHE_SIZE
20931
+ "DEFAULT_CACHE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_CACHE_SIZE),
20932
+#endif
20933
+#ifdef SQLITE_DEFAULT_CKPTFULLFSYNC
20934
+ "DEFAULT_CKPTFULLFSYNC",
20935
+#endif
20936
+#ifdef SQLITE_DEFAULT_FILE_FORMAT
20937
+ "DEFAULT_FILE_FORMAT=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_FORMAT),
20938
+#endif
20939
+#ifdef SQLITE_DEFAULT_FILE_PERMISSIONS
20940
+ "DEFAULT_FILE_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_PERMISSIONS),
20941
+#endif
20942
+#ifdef SQLITE_DEFAULT_FOREIGN_KEYS
20943
+ "DEFAULT_FOREIGN_KEYS",
20944
+#endif
20945
+#ifdef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
20946
+ "DEFAULT_JOURNAL_SIZE_LIMIT=" CTIMEOPT_VAL(SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT),
20947
+#endif
20948
+#ifdef SQLITE_DEFAULT_LOCKING_MODE
20949
+ "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
20950
+#endif
20951
+#ifdef SQLITE_DEFAULT_LOOKASIDE
20952
+ "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE),
20953
+#endif
20954
+#ifdef SQLITE_DEFAULT_MEMSTATUS
20955
+# if SQLITE_DEFAULT_MEMSTATUS != 1
20956
+ "DEFAULT_MEMSTATUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_MEMSTATUS),
20957
+# endif
20958
+#endif
20959
+#ifdef SQLITE_DEFAULT_MMAP_SIZE
20960
+ "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
20961
+#endif
20962
+#ifdef SQLITE_DEFAULT_PAGE_SIZE
20963
+ "DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_PAGE_SIZE),
20964
+#endif
20965
+#ifdef SQLITE_DEFAULT_PCACHE_INITSZ
20966
+ "DEFAULT_PCACHE_INITSZ=" CTIMEOPT_VAL(SQLITE_DEFAULT_PCACHE_INITSZ),
20967
+#endif
20968
+#ifdef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS
20969
+ "DEFAULT_PROXYDIR_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_PROXYDIR_PERMISSIONS),
20970
+#endif
20971
+#ifdef SQLITE_DEFAULT_RECURSIVE_TRIGGERS
20972
+ "DEFAULT_RECURSIVE_TRIGGERS",
20973
+#endif
20974
+#ifdef SQLITE_DEFAULT_ROWEST
20975
+ "DEFAULT_ROWEST=" CTIMEOPT_VAL(SQLITE_DEFAULT_ROWEST),
20976
+#endif
20977
+#ifdef SQLITE_DEFAULT_SECTOR_SIZE
20978
+ "DEFAULT_SECTOR_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_SECTOR_SIZE),
20979
+#endif
20980
+#ifdef SQLITE_DEFAULT_SYNCHRONOUS
20981
+ "DEFAULT_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS),
20982
+#endif
20983
+#ifdef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
20984
+ "DEFAULT_WAL_AUTOCHECKPOINT=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_AUTOCHECKPOINT),
20985
+#endif
20986
+#ifdef SQLITE_DEFAULT_WAL_SYNCHRONOUS
20987
+ "DEFAULT_WAL_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS),
20988
+#endif
20989
+#ifdef SQLITE_DEFAULT_WORKER_THREADS
20990
+ "DEFAULT_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WORKER_THREADS),
20991
+#endif
20992
+#ifdef SQLITE_DIRECT_OVERFLOW_READ
20993
+ "DIRECT_OVERFLOW_READ",
20994
+#endif
20995
+#ifdef SQLITE_DISABLE_DIRSYNC
20996
+ "DISABLE_DIRSYNC",
20997
+#endif
20998
+#ifdef SQLITE_DISABLE_FTS3_UNICODE
20999
+ "DISABLE_FTS3_UNICODE",
21000
+#endif
21001
+#ifdef SQLITE_DISABLE_FTS4_DEFERRED
21002
+ "DISABLE_FTS4_DEFERRED",
21003
+#endif
21004
+#ifdef SQLITE_DISABLE_INTRINSIC
21005
+ "DISABLE_INTRINSIC",
21006
+#endif
21007
+#ifdef SQLITE_DISABLE_LFS
21008
+ "DISABLE_LFS",
21009
+#endif
21010
+#ifdef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
21011
+ "DISABLE_PAGECACHE_OVERFLOW_STATS",
21012
+#endif
21013
+#ifdef SQLITE_DISABLE_SKIPAHEAD_DISTINCT
21014
+ "DISABLE_SKIPAHEAD_DISTINCT",
21015
+#endif
21016
+#ifdef SQLITE_ENABLE_8_3_NAMES
21017
+ "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),
21018
+#endif
21019
+#ifdef SQLITE_ENABLE_API_ARMOR
21020
+ "ENABLE_API_ARMOR",
21021
+#endif
21022
+#ifdef SQLITE_ENABLE_ATOMIC_WRITE
21023
+ "ENABLE_ATOMIC_WRITE",
21024
+#endif
21025
+#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE
21026
+ "ENABLE_BATCH_ATOMIC_WRITE",
21027
+#endif
21028
+#ifdef SQLITE_ENABLE_BYTECODE_VTAB
21029
+ "ENABLE_BYTECODE_VTAB",
21030
+#endif
21031
+#ifdef SQLITE_ENABLE_CEROD
21032
+ "ENABLE_CEROD=" CTIMEOPT_VAL(SQLITE_ENABLE_CEROD),
21033
+#endif
21034
+#ifdef SQLITE_ENABLE_COLUMN_METADATA
21035
+ "ENABLE_COLUMN_METADATA",
21036
+#endif
21037
+#ifdef SQLITE_ENABLE_COLUMN_USED_MASK
21038
+ "ENABLE_COLUMN_USED_MASK",
21039
+#endif
21040
+#ifdef SQLITE_ENABLE_COSTMULT
21041
+ "ENABLE_COSTMULT",
21042
+#endif
21043
+#ifdef SQLITE_ENABLE_CURSOR_HINTS
21044
+ "ENABLE_CURSOR_HINTS",
21045
+#endif
21046
+#ifdef SQLITE_ENABLE_DBPAGE_VTAB
21047
+ "ENABLE_DBPAGE_VTAB",
21048
+#endif
21049
+#ifdef SQLITE_ENABLE_DBSTAT_VTAB
21050
+ "ENABLE_DBSTAT_VTAB",
21051
+#endif
21052
+#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
21053
+ "ENABLE_EXPENSIVE_ASSERT",
21054
+#endif
21055
+#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
21056
+ "ENABLE_EXPLAIN_COMMENTS",
21057
+#endif
21058
+#ifdef SQLITE_ENABLE_FTS3
21059
+ "ENABLE_FTS3",
21060
+#endif
21061
+#ifdef SQLITE_ENABLE_FTS3_PARENTHESIS
21062
+ "ENABLE_FTS3_PARENTHESIS",
21063
+#endif
21064
+#ifdef SQLITE_ENABLE_FTS3_TOKENIZER
21065
+ "ENABLE_FTS3_TOKENIZER",
21066
+#endif
21067
+#ifdef SQLITE_ENABLE_FTS4
21068
+ "ENABLE_FTS4",
21069
+#endif
21070
+#ifdef SQLITE_ENABLE_FTS5
21071
+ "ENABLE_FTS5",
21072
+#endif
21073
+#ifdef SQLITE_ENABLE_GEOPOLY
21074
+ "ENABLE_GEOPOLY",
21075
+#endif
21076
+#ifdef SQLITE_ENABLE_HIDDEN_COLUMNS
21077
+ "ENABLE_HIDDEN_COLUMNS",
21078
+#endif
21079
+#ifdef SQLITE_ENABLE_ICU
21080
+ "ENABLE_ICU",
21081
+#endif
21082
+#ifdef SQLITE_ENABLE_IOTRACE
21083
+ "ENABLE_IOTRACE",
21084
+#endif
21085
+#ifdef SQLITE_ENABLE_LOAD_EXTENSION
21086
+ "ENABLE_LOAD_EXTENSION",
21087
+#endif
21088
+#ifdef SQLITE_ENABLE_LOCKING_STYLE
21089
+ "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
21090
+#endif
21091
+#ifdef SQLITE_ENABLE_MATH_FUNCTIONS
21092
+ "ENABLE_MATH_FUNCTIONS",
21093
+#endif
21094
+#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
21095
+ "ENABLE_MEMORY_MANAGEMENT",
21096
+#endif
21097
+#ifdef SQLITE_ENABLE_MEMSYS3
21098
+ "ENABLE_MEMSYS3",
21099
+#endif
21100
+#ifdef SQLITE_ENABLE_MEMSYS5
21101
+ "ENABLE_MEMSYS5",
21102
+#endif
21103
+#ifdef SQLITE_ENABLE_MULTIPLEX
21104
+ "ENABLE_MULTIPLEX",
21105
+#endif
21106
+#ifdef SQLITE_ENABLE_NORMALIZE
21107
+ "ENABLE_NORMALIZE",
21108
+#endif
21109
+#ifdef SQLITE_ENABLE_NULL_TRIM
21110
+ "ENABLE_NULL_TRIM",
21111
+#endif
21112
+#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
21113
+ "ENABLE_OFFSET_SQL_FUNC",
21114
+#endif
21115
+#ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK
21116
+ "ENABLE_OVERSIZE_CELL_CHECK",
21117
+#endif
21118
+#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
21119
+ "ENABLE_PREUPDATE_HOOK",
21120
+#endif
21121
+#ifdef SQLITE_ENABLE_QPSG
21122
+ "ENABLE_QPSG",
21123
+#endif
21124
+#ifdef SQLITE_ENABLE_RBU
21125
+ "ENABLE_RBU",
21126
+#endif
21127
+#ifdef SQLITE_ENABLE_RTREE
21128
+ "ENABLE_RTREE",
21129
+#endif
21130
+#ifdef SQLITE_ENABLE_SELECTTRACE
21131
+ "ENABLE_SELECTTRACE",
21132
+#endif
21133
+#ifdef SQLITE_ENABLE_SESSION
21134
+ "ENABLE_SESSION",
21135
+#endif
21136
+#ifdef SQLITE_ENABLE_SNAPSHOT
21137
+ "ENABLE_SNAPSHOT",
21138
+#endif
21139
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
21140
+ "ENABLE_SORTER_REFERENCES",
21141
+#endif
21142
+#ifdef SQLITE_ENABLE_SQLLOG
21143
+ "ENABLE_SQLLOG",
21144
+#endif
21145
+#ifdef SQLITE_ENABLE_STAT4
21146
+ "ENABLE_STAT4",
21147
+#endif
21148
+#ifdef SQLITE_ENABLE_STMTVTAB
21149
+ "ENABLE_STMTVTAB",
21150
+#endif
21151
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
21152
+ "ENABLE_STMT_SCANSTATUS",
21153
+#endif
21154
+#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
21155
+ "ENABLE_UNKNOWN_SQL_FUNCTION",
21156
+#endif
21157
+#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
21158
+ "ENABLE_UNLOCK_NOTIFY",
21159
+#endif
21160
+#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
21161
+ "ENABLE_UPDATE_DELETE_LIMIT",
21162
+#endif
21163
+#ifdef SQLITE_ENABLE_URI_00_ERROR
21164
+ "ENABLE_URI_00_ERROR",
21165
+#endif
21166
+#ifdef SQLITE_ENABLE_VFSTRACE
21167
+ "ENABLE_VFSTRACE",
21168
+#endif
21169
+#ifdef SQLITE_ENABLE_WHERETRACE
21170
+ "ENABLE_WHERETRACE",
21171
+#endif
21172
+#ifdef SQLITE_ENABLE_ZIPVFS
21173
+ "ENABLE_ZIPVFS",
21174
+#endif
21175
+#ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS
21176
+ "EXPLAIN_ESTIMATED_ROWS",
21177
+#endif
21178
+#ifdef SQLITE_EXTRA_IFNULLROW
21179
+ "EXTRA_IFNULLROW",
21180
+#endif
21181
+#ifdef SQLITE_EXTRA_INIT
21182
+ "EXTRA_INIT=" CTIMEOPT_VAL(SQLITE_EXTRA_INIT),
21183
+#endif
21184
+#ifdef SQLITE_EXTRA_SHUTDOWN
21185
+ "EXTRA_SHUTDOWN=" CTIMEOPT_VAL(SQLITE_EXTRA_SHUTDOWN),
21186
+#endif
21187
+#ifdef SQLITE_FTS3_MAX_EXPR_DEPTH
21188
+ "FTS3_MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_FTS3_MAX_EXPR_DEPTH),
21189
+#endif
21190
+#ifdef SQLITE_FTS5_ENABLE_TEST_MI
21191
+ "FTS5_ENABLE_TEST_MI",
21192
+#endif
21193
+#ifdef SQLITE_FTS5_NO_WITHOUT_ROWID
21194
+ "FTS5_NO_WITHOUT_ROWID",
21195
+#endif
21196
+#if HAVE_ISNAN || SQLITE_HAVE_ISNAN
21197
+ "HAVE_ISNAN",
21198
+#endif
21199
+#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
21200
+# if SQLITE_HOMEGROWN_RECURSIVE_MUTEX != 1
21201
+ "HOMEGROWN_RECURSIVE_MUTEX=" CTIMEOPT_VAL(SQLITE_HOMEGROWN_RECURSIVE_MUTEX),
21202
+# endif
21203
+#endif
21204
+#ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS
21205
+ "IGNORE_AFP_LOCK_ERRORS",
21206
+#endif
21207
+#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS
21208
+ "IGNORE_FLOCK_LOCK_ERRORS",
21209
+#endif
21210
+#ifdef SQLITE_INLINE_MEMCPY
21211
+ "INLINE_MEMCPY",
21212
+#endif
21213
+#ifdef SQLITE_INT64_TYPE
21214
+ "INT64_TYPE",
21215
+#endif
21216
+#ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX
21217
+ "INTEGRITY_CHECK_ERROR_MAX=" CTIMEOPT_VAL(SQLITE_INTEGRITY_CHECK_ERROR_MAX),
21218
+#endif
21219
+#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS
21220
+ "LIKE_DOESNT_MATCH_BLOBS",
21221
+#endif
21222
+#ifdef SQLITE_LOCK_TRACE
21223
+ "LOCK_TRACE",
21224
+#endif
21225
+#ifdef SQLITE_LOG_CACHE_SPILL
21226
+ "LOG_CACHE_SPILL",
21227
+#endif
21228
+#ifdef SQLITE_MALLOC_SOFT_LIMIT
21229
+ "MALLOC_SOFT_LIMIT=" CTIMEOPT_VAL(SQLITE_MALLOC_SOFT_LIMIT),
21230
+#endif
21231
+#ifdef SQLITE_MAX_ATTACHED
21232
+ "MAX_ATTACHED=" CTIMEOPT_VAL(SQLITE_MAX_ATTACHED),
21233
+#endif
21234
+#ifdef SQLITE_MAX_COLUMN
21235
+ "MAX_COLUMN=" CTIMEOPT_VAL(SQLITE_MAX_COLUMN),
21236
+#endif
21237
+#ifdef SQLITE_MAX_COMPOUND_SELECT
21238
+ "MAX_COMPOUND_SELECT=" CTIMEOPT_VAL(SQLITE_MAX_COMPOUND_SELECT),
21239
+#endif
21240
+#ifdef SQLITE_MAX_DEFAULT_PAGE_SIZE
21241
+ "MAX_DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_DEFAULT_PAGE_SIZE),
21242
+#endif
21243
+#ifdef SQLITE_MAX_EXPR_DEPTH
21244
+ "MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_EXPR_DEPTH),
21245
+#endif
21246
+#ifdef SQLITE_MAX_FUNCTION_ARG
21247
+ "MAX_FUNCTION_ARG=" CTIMEOPT_VAL(SQLITE_MAX_FUNCTION_ARG),
21248
+#endif
21249
+#ifdef SQLITE_MAX_LENGTH
21250
+ "MAX_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LENGTH),
21251
+#endif
21252
+#ifdef SQLITE_MAX_LIKE_PATTERN_LENGTH
21253
+ "MAX_LIKE_PATTERN_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LIKE_PATTERN_LENGTH),
21254
+#endif
21255
+#ifdef SQLITE_MAX_MEMORY
21256
+ "MAX_MEMORY=" CTIMEOPT_VAL(SQLITE_MAX_MEMORY),
21257
+#endif
21258
+#ifdef SQLITE_MAX_MMAP_SIZE
21259
+ "MAX_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE),
21260
+#endif
21261
+#ifdef SQLITE_MAX_MMAP_SIZE_
21262
+ "MAX_MMAP_SIZE_=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE_),
21263
+#endif
21264
+#ifdef SQLITE_MAX_PAGE_COUNT
21265
+ "MAX_PAGE_COUNT=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_COUNT),
21266
+#endif
21267
+#ifdef SQLITE_MAX_PAGE_SIZE
21268
+ "MAX_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_SIZE),
21269
+#endif
21270
+#ifdef SQLITE_MAX_SCHEMA_RETRY
21271
+ "MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),
21272
+#endif
21273
+#ifdef SQLITE_MAX_SQL_LENGTH
21274
+ "MAX_SQL_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_SQL_LENGTH),
21275
+#endif
21276
+#ifdef SQLITE_MAX_TRIGGER_DEPTH
21277
+ "MAX_TRIGGER_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_TRIGGER_DEPTH),
21278
+#endif
21279
+#ifdef SQLITE_MAX_VARIABLE_NUMBER
21280
+ "MAX_VARIABLE_NUMBER=" CTIMEOPT_VAL(SQLITE_MAX_VARIABLE_NUMBER),
21281
+#endif
21282
+#ifdef SQLITE_MAX_VDBE_OP
21283
+ "MAX_VDBE_OP=" CTIMEOPT_VAL(SQLITE_MAX_VDBE_OP),
21284
+#endif
21285
+#ifdef SQLITE_MAX_WORKER_THREADS
21286
+ "MAX_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_MAX_WORKER_THREADS),
21287
+#endif
21288
+#ifdef SQLITE_MEMDEBUG
21289
+ "MEMDEBUG",
21290
+#endif
21291
+#ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT
21292
+ "MIXED_ENDIAN_64BIT_FLOAT",
21293
+#endif
21294
+#ifdef SQLITE_MMAP_READWRITE
21295
+ "MMAP_READWRITE",
21296
+#endif
21297
+#ifdef SQLITE_MUTEX_NOOP
21298
+ "MUTEX_NOOP",
21299
+#endif
21300
+#ifdef SQLITE_MUTEX_OMIT
21301
+ "MUTEX_OMIT",
21302
+#endif
21303
+#ifdef SQLITE_MUTEX_PTHREADS
21304
+ "MUTEX_PTHREADS",
21305
+#endif
21306
+#ifdef SQLITE_MUTEX_W32
21307
+ "MUTEX_W32",
21308
+#endif
21309
+#ifdef SQLITE_NEED_ERR_NAME
21310
+ "NEED_ERR_NAME",
21311
+#endif
21312
+#ifdef SQLITE_NO_SYNC
21313
+ "NO_SYNC",
21314
+#endif
21315
+#ifdef SQLITE_OMIT_ALTERTABLE
21316
+ "OMIT_ALTERTABLE",
21317
+#endif
21318
+#ifdef SQLITE_OMIT_ANALYZE
21319
+ "OMIT_ANALYZE",
21320
+#endif
21321
+#ifdef SQLITE_OMIT_ATTACH
21322
+ "OMIT_ATTACH",
21323
+#endif
21324
+#ifdef SQLITE_OMIT_AUTHORIZATION
21325
+ "OMIT_AUTHORIZATION",
21326
+#endif
21327
+#ifdef SQLITE_OMIT_AUTOINCREMENT
21328
+ "OMIT_AUTOINCREMENT",
21329
+#endif
21330
+#ifdef SQLITE_OMIT_AUTOINIT
21331
+ "OMIT_AUTOINIT",
21332
+#endif
21333
+#ifdef SQLITE_OMIT_AUTOMATIC_INDEX
21334
+ "OMIT_AUTOMATIC_INDEX",
21335
+#endif
21336
+#ifdef SQLITE_OMIT_AUTORESET
21337
+ "OMIT_AUTORESET",
21338
+#endif
21339
+#ifdef SQLITE_OMIT_AUTOVACUUM
21340
+ "OMIT_AUTOVACUUM",
21341
+#endif
21342
+#ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION
21343
+ "OMIT_BETWEEN_OPTIMIZATION",
21344
+#endif
21345
+#ifdef SQLITE_OMIT_BLOB_LITERAL
21346
+ "OMIT_BLOB_LITERAL",
21347
+#endif
21348
+#ifdef SQLITE_OMIT_CAST
21349
+ "OMIT_CAST",
21350
+#endif
21351
+#ifdef SQLITE_OMIT_CHECK
21352
+ "OMIT_CHECK",
21353
+#endif
21354
+#ifdef SQLITE_OMIT_COMPLETE
21355
+ "OMIT_COMPLETE",
21356
+#endif
21357
+#ifdef SQLITE_OMIT_COMPOUND_SELECT
21358
+ "OMIT_COMPOUND_SELECT",
21359
+#endif
21360
+#ifdef SQLITE_OMIT_CONFLICT_CLAUSE
21361
+ "OMIT_CONFLICT_CLAUSE",
21362
+#endif
21363
+#ifdef SQLITE_OMIT_CTE
21364
+ "OMIT_CTE",
21365
+#endif
21366
+#if defined(SQLITE_OMIT_DATETIME_FUNCS) || defined(SQLITE_OMIT_FLOATING_POINT)
21367
+ "OMIT_DATETIME_FUNCS",
21368
+#endif
21369
+#ifdef SQLITE_OMIT_DECLTYPE
21370
+ "OMIT_DECLTYPE",
21371
+#endif
21372
+#ifdef SQLITE_OMIT_DEPRECATED
21373
+ "OMIT_DEPRECATED",
21374
+#endif
21375
+#ifdef SQLITE_OMIT_DESERIALIZE
21376
+ "OMIT_DESERIALIZE",
21377
+#endif
21378
+#ifdef SQLITE_OMIT_DISKIO
21379
+ "OMIT_DISKIO",
21380
+#endif
21381
+#ifdef SQLITE_OMIT_EXPLAIN
21382
+ "OMIT_EXPLAIN",
21383
+#endif
21384
+#ifdef SQLITE_OMIT_FLAG_PRAGMAS
21385
+ "OMIT_FLAG_PRAGMAS",
21386
+#endif
21387
+#ifdef SQLITE_OMIT_FLOATING_POINT
21388
+ "OMIT_FLOATING_POINT",
21389
+#endif
21390
+#ifdef SQLITE_OMIT_FOREIGN_KEY
21391
+ "OMIT_FOREIGN_KEY",
21392
+#endif
21393
+#ifdef SQLITE_OMIT_GET_TABLE
21394
+ "OMIT_GET_TABLE",
21395
+#endif
21396
+#ifdef SQLITE_OMIT_HEX_INTEGER
21397
+ "OMIT_HEX_INTEGER",
21398
+#endif
21399
+#ifdef SQLITE_OMIT_INCRBLOB
21400
+ "OMIT_INCRBLOB",
21401
+#endif
21402
+#ifdef SQLITE_OMIT_INTEGRITY_CHECK
21403
+ "OMIT_INTEGRITY_CHECK",
21404
+#endif
21405
+#ifdef SQLITE_OMIT_INTROSPECTION_PRAGMAS
21406
+ "OMIT_INTROSPECTION_PRAGMAS",
21407
+#endif
21408
+#ifdef SQLITE_OMIT_JSON
21409
+ "OMIT_JSON",
21410
+#endif
21411
+#ifdef SQLITE_OMIT_LIKE_OPTIMIZATION
21412
+ "OMIT_LIKE_OPTIMIZATION",
21413
+#endif
21414
+#ifdef SQLITE_OMIT_LOAD_EXTENSION
21415
+ "OMIT_LOAD_EXTENSION",
21416
+#endif
21417
+#ifdef SQLITE_OMIT_LOCALTIME
21418
+ "OMIT_LOCALTIME",
21419
+#endif
21420
+#ifdef SQLITE_OMIT_LOOKASIDE
21421
+ "OMIT_LOOKASIDE",
21422
+#endif
21423
+#ifdef SQLITE_OMIT_MEMORYDB
21424
+ "OMIT_MEMORYDB",
21425
+#endif
21426
+#ifdef SQLITE_OMIT_OR_OPTIMIZATION
21427
+ "OMIT_OR_OPTIMIZATION",
21428
+#endif
21429
+#ifdef SQLITE_OMIT_PAGER_PRAGMAS
21430
+ "OMIT_PAGER_PRAGMAS",
21431
+#endif
21432
+#ifdef SQLITE_OMIT_PARSER_TRACE
21433
+ "OMIT_PARSER_TRACE",
21434
+#endif
21435
+#ifdef SQLITE_OMIT_POPEN
21436
+ "OMIT_POPEN",
21437
+#endif
21438
+#ifdef SQLITE_OMIT_PRAGMA
21439
+ "OMIT_PRAGMA",
21440
+#endif
21441
+#ifdef SQLITE_OMIT_PROGRESS_CALLBACK
21442
+ "OMIT_PROGRESS_CALLBACK",
21443
+#endif
21444
+#ifdef SQLITE_OMIT_QUICKBALANCE
21445
+ "OMIT_QUICKBALANCE",
21446
+#endif
21447
+#ifdef SQLITE_OMIT_REINDEX
21448
+ "OMIT_REINDEX",
21449
+#endif
21450
+#ifdef SQLITE_OMIT_SCHEMA_PRAGMAS
21451
+ "OMIT_SCHEMA_PRAGMAS",
21452
+#endif
21453
+#ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
21454
+ "OMIT_SCHEMA_VERSION_PRAGMAS",
21455
+#endif
21456
+#ifdef SQLITE_OMIT_SHARED_CACHE
21457
+ "OMIT_SHARED_CACHE",
21458
+#endif
21459
+#ifdef SQLITE_OMIT_SHUTDOWN_DIRECTORIES
21460
+ "OMIT_SHUTDOWN_DIRECTORIES",
21461
+#endif
21462
+#ifdef SQLITE_OMIT_SUBQUERY
21463
+ "OMIT_SUBQUERY",
21464
+#endif
21465
+#ifdef SQLITE_OMIT_TCL_VARIABLE
21466
+ "OMIT_TCL_VARIABLE",
21467
+#endif
21468
+#ifdef SQLITE_OMIT_TEMPDB
21469
+ "OMIT_TEMPDB",
21470
+#endif
21471
+#ifdef SQLITE_OMIT_TEST_CONTROL
21472
+ "OMIT_TEST_CONTROL",
21473
+#endif
21474
+#ifdef SQLITE_OMIT_TRACE
21475
+# if SQLITE_OMIT_TRACE != 1
21476
+ "OMIT_TRACE=" CTIMEOPT_VAL(SQLITE_OMIT_TRACE),
21477
+# endif
21478
+#endif
21479
+#ifdef SQLITE_OMIT_TRIGGER
21480
+ "OMIT_TRIGGER",
21481
+#endif
21482
+#ifdef SQLITE_OMIT_TRUNCATE_OPTIMIZATION
21483
+ "OMIT_TRUNCATE_OPTIMIZATION",
21484
+#endif
21485
+#ifdef SQLITE_OMIT_UTF16
21486
+ "OMIT_UTF16",
21487
+#endif
21488
+#ifdef SQLITE_OMIT_VACUUM
21489
+ "OMIT_VACUUM",
21490
+#endif
21491
+#ifdef SQLITE_OMIT_VIEW
21492
+ "OMIT_VIEW",
21493
+#endif
21494
+#ifdef SQLITE_OMIT_VIRTUALTABLE
21495
+ "OMIT_VIRTUALTABLE",
21496
+#endif
21497
+#ifdef SQLITE_OMIT_WAL
21498
+ "OMIT_WAL",
21499
+#endif
21500
+#ifdef SQLITE_OMIT_WSD
21501
+ "OMIT_WSD",
21502
+#endif
21503
+#ifdef SQLITE_OMIT_XFER_OPT
21504
+ "OMIT_XFER_OPT",
21505
+#endif
21506
+#ifdef SQLITE_PCACHE_SEPARATE_HEADER
21507
+ "PCACHE_SEPARATE_HEADER",
21508
+#endif
21509
+#ifdef SQLITE_PERFORMANCE_TRACE
21510
+ "PERFORMANCE_TRACE",
21511
+#endif
21512
+#ifdef SQLITE_POWERSAFE_OVERWRITE
21513
+# if SQLITE_POWERSAFE_OVERWRITE != 1
21514
+ "POWERSAFE_OVERWRITE=" CTIMEOPT_VAL(SQLITE_POWERSAFE_OVERWRITE),
21515
+# endif
21516
+#endif
21517
+#ifdef SQLITE_PREFER_PROXY_LOCKING
21518
+ "PREFER_PROXY_LOCKING",
21519
+#endif
21520
+#ifdef SQLITE_PROXY_DEBUG
21521
+ "PROXY_DEBUG",
21522
+#endif
21523
+#ifdef SQLITE_REVERSE_UNORDERED_SELECTS
21524
+ "REVERSE_UNORDERED_SELECTS",
21525
+#endif
21526
+#ifdef SQLITE_RTREE_INT_ONLY
21527
+ "RTREE_INT_ONLY",
21528
+#endif
21529
+#ifdef SQLITE_SECURE_DELETE
21530
+ "SECURE_DELETE",
21531
+#endif
21532
+#ifdef SQLITE_SMALL_STACK
21533
+ "SMALL_STACK",
21534
+#endif
21535
+#ifdef SQLITE_SORTER_PMASZ
21536
+ "SORTER_PMASZ=" CTIMEOPT_VAL(SQLITE_SORTER_PMASZ),
21537
+#endif
21538
+#ifdef SQLITE_SOUNDEX
21539
+ "SOUNDEX",
21540
+#endif
21541
+#ifdef SQLITE_STAT4_SAMPLES
21542
+ "STAT4_SAMPLES=" CTIMEOPT_VAL(SQLITE_STAT4_SAMPLES),
21543
+#endif
21544
+#ifdef SQLITE_STMTJRNL_SPILL
21545
+ "STMTJRNL_SPILL=" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL),
21546
+#endif
21547
+#ifdef SQLITE_SUBSTR_COMPATIBILITY
21548
+ "SUBSTR_COMPATIBILITY",
21549
+#endif
21550
+#if (!defined(SQLITE_WIN32_MALLOC) \
21551
+ && !defined(SQLITE_ZERO_MALLOC) \
21552
+ && !defined(SQLITE_MEMDEBUG) \
21553
+ ) || defined(SQLITE_SYSTEM_MALLOC)
21554
+ "SYSTEM_MALLOC",
21555
+#endif
21556
+#ifdef SQLITE_TCL
21557
+ "TCL",
21558
+#endif
21559
+#ifdef SQLITE_TEMP_STORE
21560
+ "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE),
21561
+#endif
21562
+#ifdef SQLITE_TEST
21563
+ "TEST",
21564
+#endif
21565
+#if defined(SQLITE_THREADSAFE)
21566
+ "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
21567
+#elif defined(THREADSAFE)
21568
+ "THREADSAFE=" CTIMEOPT_VAL(THREADSAFE),
21569
+#else
21570
+ "THREADSAFE=1",
21571
+#endif
21572
+#ifdef SQLITE_UNLINK_AFTER_CLOSE
21573
+ "UNLINK_AFTER_CLOSE",
21574
+#endif
21575
+#ifdef SQLITE_UNTESTABLE
21576
+ "UNTESTABLE",
21577
+#endif
21578
+#ifdef SQLITE_USER_AUTHENTICATION
21579
+ "USER_AUTHENTICATION",
21580
+#endif
21581
+#ifdef SQLITE_USE_ALLOCA
21582
+ "USE_ALLOCA",
21583
+#endif
21584
+#ifdef SQLITE_USE_FCNTL_TRACE
21585
+ "USE_FCNTL_TRACE",
21586
+#endif
21587
+#ifdef SQLITE_USE_URI
21588
+ "USE_URI",
21589
+#endif
21590
+#ifdef SQLITE_VDBE_COVERAGE
21591
+ "VDBE_COVERAGE",
21592
+#endif
21593
+#ifdef SQLITE_WIN32_MALLOC
21594
+ "WIN32_MALLOC",
21595
+#endif
21596
+#ifdef SQLITE_ZERO_MALLOC
21597
+ "ZERO_MALLOC",
21598
+#endif
21599
+
21600
+} ;
21601
+
21602
+SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){
21603
+ *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]);
21604
+ return (const char**)sqlite3azCompileOpt;
21605
+}
21606
+
21607
+#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
21608
+
21609
+/************** End of ctime.c ***********************************************/
21610
/************** Begin file global.c ******************************************/
21611
/*
21612
** 2008 June 13
@@ -21084,6 +21896,7 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = {
21896
0, /* xTestCallback */
21897
#endif
21898
0, /* bLocaltimeFault */
21899
+ 0, /* xAltLocaltime */
21900
0x7ffffffe, /* iOnceResetThreshold */
21901
SQLITE_DEFAULT_SORTERREF_SIZE, /* szSorterRef */
21902
0, /* iPrngSeed */
@@ -21096,6 +21909,18 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = {
21909
*/
21910
SQLITE_PRIVATE FuncDefHash sqlite3BuiltinFunctions;
21911
21912
+#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG)
21913
+/*
21914
+** Counter used for coverage testing. Does not come into play for
21915
+** release builds.
21916
+**
21917
+** Access to this global variable is not mutex protected. This might
21918
+** result in TSAN warnings. But as the variable does not exist in
21919
+** release builds, that should not be a concern.
21920
+*/
21921
+SQLITE_PRIVATE unsigned int sqlite3CoverageCounter;
21922
+#endif /* SQLITE_COVERAGE_TEST || SQLITE_DEBUG */
21923
+
21924
#ifdef VDBE_PROFILE
21925
/*
21926
** The following performance counter can be used in place of
@@ -21146,6 +21971,48 @@ SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER;
21971
*/
21972
SQLITE_PRIVATE const char sqlite3StrBINARY[] = "BINARY";
21973
21974
+/*
21975
+** Standard typenames. These names must match the COLTYPE_* definitions.
21976
+** Adjust the SQLITE_N_STDTYPE value if adding or removing entries.
21977
+**
21978
+** sqlite3StdType[] The actual names of the datatypes.
21979
+**
21980
+** sqlite3StdTypeLen[] The length (in bytes) of each entry
21981
+** in sqlite3StdType[].
21982
+**
21983
+** sqlite3StdTypeAffinity[] The affinity associated with each entry
21984
+** in sqlite3StdType[].
21985
+**
21986
+** sqlite3StdTypeMap[] The type value (as returned from
21987
+** sqlite3_column_type() or sqlite3_value_type())
21988
+** for each entry in sqlite3StdType[].
21989
+*/
21990
+SQLITE_PRIVATE const unsigned char sqlite3StdTypeLen[] = { 3, 4, 3, 7, 4, 4 };
21991
+SQLITE_PRIVATE const char sqlite3StdTypeAffinity[] = {
21992
+ SQLITE_AFF_NUMERIC,
21993
+ SQLITE_AFF_BLOB,
21994
+ SQLITE_AFF_INTEGER,
21995
+ SQLITE_AFF_INTEGER,
21996
+ SQLITE_AFF_REAL,
21997
+ SQLITE_AFF_TEXT
21998
+};
21999
+SQLITE_PRIVATE const char sqlite3StdTypeMap[] = {
22000
+ 0,
22001
+ SQLITE_BLOB,
22002
+ SQLITE_INTEGER,
22003
+ SQLITE_INTEGER,
22004
+ SQLITE_FLOAT,
22005
+ SQLITE_TEXT
22006
+};
22007
+SQLITE_PRIVATE const char *sqlite3StdType[] = {
22008
+ "ANY",
22009
+ "BLOB",
22010
+ "INT",
22011
+ "INTEGER",
22012
+ "REAL",
22013
+ "TEXT"
22014
+};
22015
+
22016
/************** End of global.c **********************************************/
22017
/************** Begin file status.c ******************************************/
22018
/*
@@ -21243,7 +22110,7 @@ typedef struct AuxData AuxData;
22110
typedef struct VdbeCursor VdbeCursor;
22111
struct VdbeCursor {
22112
u8 eCurType; /* One of the CURTYPE_* values above */
21246
- i8 iDb; /* Index of cursor database in db->aDb[] (or -1) */
22113
+ i8 iDb; /* Index of cursor database in db->aDb[] */
22114
u8 nullRow; /* True if pointing to a row with no data */
22115
u8 deferredMoveto; /* A call to sqlite3BtreeMoveto() is needed */
22116
u8 isTable; /* True for rowid tables. False for indexes */
@@ -21256,9 +22123,11 @@ struct VdbeCursor {
22123
Bool isOrdered:1; /* True if the table is not BTREE_UNORDERED */
22124
Bool hasBeenDuped:1; /* This cursor was source or target of OP_OpenDup */
22125
u16 seekHit; /* See the OP_SeekHit and OP_IfNoHope opcodes */
21259
- Btree *pBtx; /* Separate file holding temporary table */
22126
+ union { /* pBtx for isEphermeral. pAltMap otherwise */
22127
+ Btree *pBtx; /* Separate file holding temporary table */
22128
+ u32 *aAltMap; /* Mapping from table to index column numbers */
22129
+ } ub;
22130
i64 seqCount; /* Sequence counter */
21261
- u32 *aAltMap; /* Mapping from table to index column numbers */
22131
22132
/* Cached OP_Column parse information is only valid if cacheStatus matches
22133
** Vdbe.cacheCtr. Vdbe.cacheCtr will never take on the value of
@@ -21348,8 +22217,8 @@ struct VdbeFrame {
22217
int nMem; /* Number of entries in aMem */
22218
int nChildMem; /* Number of memory cells for child frame */
22219
int nChildCsr; /* Number of cursors for child frame */
21351
- int nChange; /* Statement changes (Vdbe.nChange) */
21352
- int nDbChange; /* Value of db->nChange */
22220
+ i64 nChange; /* Statement changes (Vdbe.nChange) */
22221
+ i64 nDbChange; /* Value of db->nChange */
22222
};
22223
22224
/* Magic number for sanity checking on VdbeFrame objects */
@@ -21556,7 +22425,7 @@ struct Vdbe {
22425
u32 cacheCtr; /* VdbeCursor row cache generation counter */
22426
int pc; /* The program counter */
22427
int rc; /* Value to return */
21559
- int nChange; /* Number of db changes made since last reset */
22428
+ i64 nChange; /* Number of db changes made since last reset */
22429
int iStatement; /* Statement number (or 0 if has no opened stmt) */
22430
i64 iCurrentTime; /* Value of julianday('now') for this statement */
22431
i64 nFkConstraint; /* Number of imm. FK constraints this VM */
@@ -21598,7 +22467,7 @@ struct Vdbe {
22467
bft bIsReader:1; /* True for statements that read */
22468
yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
22469
yDbMask lockMask; /* Subset of btreeMask that requires a lock */
21601
- u32 aCounter[7]; /* Counters used by sqlite3_stmt_status() */
22470
+ u32 aCounter[9]; /* Counters used by sqlite3_stmt_status() */
22471
char *zSql; /* Text of the SQL statement that generated this */
22472
#ifdef SQLITE_ENABLE_NORMALIZE
22473
char *zNormSql; /* Normalization of the associated SQL statement */
@@ -21648,6 +22517,24 @@ struct PreUpdate {
22517
Index *pPk; /* PK index if pTab is WITHOUT ROWID */
22518
};
22519
22520
+/*
22521
+** An instance of this object is used to pass an vector of values into
22522
+** OP_VFilter, the xFilter method of a virtual table. The vector is the
22523
+** set of values on the right-hand side of an IN constraint.
22524
+**
22525
+** The value as passed into xFilter is an sqlite3_value with a "pointer"
22526
+** type, such as is generated by sqlite3_result_pointer() and read by
22527
+** sqlite3_value_pointer. Such values have MEM_Term|MEM_Subtype|MEM_Null
22528
+** and a subtype of 'p'. The sqlite3_vtab_in_first() and _next() interfaces
22529
+** know how to use this object to step through all the values in the
22530
+** right operand of the IN constraint.
22531
+*/
22532
+typedef struct ValueList ValueList;
22533
+struct ValueList {
22534
+ BtCursor *pCsr; /* An ephemeral table holding all values */
22535
+ sqlite3_value *pOut; /* Register to hold each decoded output value */
22536
+};
22537
+
22538
/*
22539
** Function prototypes
22540
*/
@@ -21660,7 +22547,7 @@ SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor*);
22547
SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
22548
SQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8);
22549
SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);
21663
-SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
22550
+SQLITE_PRIVATE void sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
22551
SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(sqlite3*, AuxData**, int, int);
22552
22553
int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
@@ -21694,14 +22581,19 @@ SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double);
22581
SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*, const char*, void(*)(void*));
22582
SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16);
22583
SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*);
22584
+#ifndef SQLITE_OMIT_INCRBLOB
22585
SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int);
22586
+#else
22587
+SQLITE_PRIVATE int sqlite3VdbeMemSetZeroBlob(Mem*,int);
22588
+#endif
22589
#ifdef SQLITE_DEBUG
22590
SQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem*);
22591
#endif
22592
SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*);
22593
SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);
22594
SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8);
21704
-SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem*);
22595
+SQLITE_PRIVATE int sqlite3IntFloatCompare(i64,double);
22596
+SQLITE_PRIVATE i64 sqlite3VdbeIntValue(const Mem*);
22597
SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*);
22598
SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*);
22599
SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull);
@@ -22679,8 +23571,10 @@ static void clearYMD_HMS_TZ(DateTime *p){
23571
** is available. This routine returns 0 on success and
23572
** non-zero on any kind of error.
23573
**
22682
-** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this
22683
-** routine will always fail.
23574
+** If the sqlite3GlobalConfig.bLocaltimeFault variable is non-zero then this
23575
+** routine will always fail. If bLocaltimeFault is nonzero and
23576
+** sqlite3GlobalConfig.xAltLocaltime is not NULL, then xAltLocaltime() is
23577
+** invoked in place of the OS-defined localtime() function.
23578
**
23579
** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C
23580
** library function localtime_r() is used to assist in the calculation of
@@ -22696,14 +23590,30 @@ static int osLocaltime(time_t *t, struct tm *pTm){
23590
sqlite3_mutex_enter(mutex);
23591
pX = localtime(t);
23592
#ifndef SQLITE_UNTESTABLE
22699
- if( sqlite3GlobalConfig.bLocaltimeFault ) pX = 0;
23593
+ if( sqlite3GlobalConfig.bLocaltimeFault ){
23594
+ if( sqlite3GlobalConfig.xAltLocaltime!=0
23595
+ && 0==sqlite3GlobalConfig.xAltLocaltime((const void*)t,(void*)pTm)
23596
+ ){
23597
+ pX = pTm;
23598
+ }else{
23599
+ pX = 0;
23600
+ }
23601
+ }
23602
#endif
23603
if( pX ) *pTm = *pX;
23604
+#if SQLITE_THREADSAFE>0
23605
sqlite3_mutex_leave(mutex);
23606
+#endif
23607
rc = pX==0;
23608
#else
23609
#ifndef SQLITE_UNTESTABLE
22706
- if( sqlite3GlobalConfig.bLocaltimeFault ) return 1;
23610
+ if( sqlite3GlobalConfig.bLocaltimeFault ){
23611
+ if( sqlite3GlobalConfig.xAltLocaltime!=0 ){
23612
+ return sqlite3GlobalConfig.xAltLocaltime((const void*)t,(void*)pTm);
23613
+ }else{
23614
+ return 1;
23615
+ }
23616
+ }
23617
#endif
23618
#if HAVE_LOCALTIME_R
23619
rc = localtime_r(t, pTm)==0;
@@ -22718,67 +23628,56 @@ static int osLocaltime(time_t *t, struct tm *pTm){
23628
23629
#ifndef SQLITE_OMIT_LOCALTIME
23630
/*
22721
-** Compute the difference (in milliseconds) between localtime and UTC
22722
-** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs,
22723
-** return this value and set *pRc to SQLITE_OK.
22724
-**
22725
-** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value
22726
-** is undefined in this case.
23631
+** Assuming the input DateTime is UTC, move it to its localtime equivalent.
23632
*/
22728
-static sqlite3_int64 localtimeOffset(
22729
- DateTime *p, /* Date at which to calculate offset */
22730
- sqlite3_context *pCtx, /* Write error here if one occurs */
22731
- int *pRc /* OUT: Error code. SQLITE_OK or ERROR */
23633
+static int toLocaltime(
23634
+ DateTime *p, /* Date at which to calculate offset */
23635
+ sqlite3_context *pCtx /* Write error here if one occurs */
23636
){
22733
- DateTime x, y;
23637
time_t t;
23638
struct tm sLocal;
23639
+ int iYearDiff;
23640
23641
/* Initialize the contents of sLocal to avoid a compiler warning. */
23642
memset(&sLocal, 0, sizeof(sLocal));
23643
22740
- x = *p;
22741
- computeYMD_HMS(&x);
22742
- if( x.Y<1971 || x.Y>=2038 ){
23644
+ computeJD(p);
23645
+ if( p->iJD<2108667600*(i64)100000 /* 1970-01-01 */
23646
+ || p->iJD>2130141456*(i64)100000 /* 2038-01-18 */
23647
+ ){
23648
/* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only
23649
** works for years between 1970 and 2037. For dates outside this range,
23650
** SQLite attempts to map the year into an equivalent year within this
23651
** range, do the calculation, then map the year back.
23652
*/
22748
- x.Y = 2000;
22749
- x.M = 1;
22750
- x.D = 1;
22751
- x.h = 0;
22752
- x.m = 0;
22753
- x.s = 0.0;
22754
- } else {
22755
- int s = (int)(x.s + 0.5);
22756
- x.s = s;
23653
+ DateTime x = *p;
23654
+ computeYMD_HMS(&x);
23655
+ iYearDiff = (2000 + x.Y%4) - x.Y;
23656
+ x.Y += iYearDiff;
23657
+ x.validJD = 0;
23658
+ computeJD(&x);
23659
+ t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);
23660
+ }else{
23661
+ iYearDiff = 0;
23662
+ t = (time_t)(p->iJD/1000 - 21086676*(i64)10000);
23663
}
22758
- x.tz = 0;
22759
- x.validJD = 0;
22760
- computeJD(&x);
22761
- t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);
23664
if( osLocaltime(&t, &sLocal) ){
23665
sqlite3_result_error(pCtx, "local time unavailable", -1);
22764
- *pRc = SQLITE_ERROR;
22765
- return 0;
23666
+ return SQLITE_ERROR;
23667
}
22767
- y.Y = sLocal.tm_year + 1900;
22768
- y.M = sLocal.tm_mon + 1;
22769
- y.D = sLocal.tm_mday;
22770
- y.h = sLocal.tm_hour;
22771
- y.m = sLocal.tm_min;
22772
- y.s = sLocal.tm_sec;
22773
- y.validYMD = 1;
22774
- y.validHMS = 1;
22775
- y.validJD = 0;
22776
- y.rawS = 0;
22777
- y.validTZ = 0;
22778
- y.isError = 0;
22779
- computeJD(&y);
22780
- *pRc = SQLITE_OK;
22781
- return y.iJD - x.iJD;
23668
+ p->Y = sLocal.tm_year + 1900 - iYearDiff;
23669
+ p->M = sLocal.tm_mon + 1;
23670
+ p->D = sLocal.tm_mday;
23671
+ p->h = sLocal.tm_hour;
23672
+ p->m = sLocal.tm_min;
23673
+ p->s = sLocal.tm_sec + (p->iJD%1000)*0.001;
23674
+ p->validYMD = 1;
23675
+ p->validHMS = 1;
23676
+ p->validJD = 0;
23677
+ p->rawS = 0;
23678
+ p->validTZ = 0;
23679
+ p->isError = 0;
23680
+ return SQLITE_OK;
23681
}
23682
#endif /* SQLITE_OMIT_LOCALTIME */
23683
@@ -22791,18 +23690,17 @@ static sqlite3_int64 localtimeOffset(
23690
** of several units of time.
23691
*/
23692
static const struct {
22794
- u8 eType; /* Transformation type code */
22795
- u8 nName; /* Length of th name */
22796
- char *zName; /* Name of the transformation */
22797
- double rLimit; /* Maximum NNN value for this transform */
22798
- double rXform; /* Constant used for this transform */
23693
+ u8 nName; /* Length of the name */
23694
+ char zName[7]; /* Name of the transformation */
23695
+ float rLimit; /* Maximum NNN value for this transform */
23696
+ float rXform; /* Constant used for this transform */
23697
} aXformType[] = {
22800
- { 0, 6, "second", 464269060800.0, 1000.0 },
22801
- { 0, 6, "minute", 7737817680.0, 60000.0 },
22802
- { 0, 4, "hour", 128963628.0, 3600000.0 },
22803
- { 0, 3, "day", 5373485.0, 86400000.0 },
22804
- { 1, 5, "month", 176546.0, 2592000000.0 },
22805
- { 2, 4, "year", 14713.0, 31536000000.0 },
23698
+ { 6, "second", 4.6427e+14, 1.0 },
23699
+ { 6, "minute", 7.7379e+12, 60.0 },
23700
+ { 4, "hour", 1.2897e+11, 3600.0 },
23701
+ { 3, "day", 5373485.0, 86400.0 },
23702
+ { 5, "month", 176546.0, 2592000.0 },
23703
+ { 4, "year", 14713.0, 31536000.0 },
23704
};
23705
23706
/*
@@ -22833,11 +23731,55 @@ static int parseModifier(
23731
sqlite3_context *pCtx, /* Function context */
23732
const char *z, /* The text of the modifier */
23733
int n, /* Length of zMod in bytes */
22836
- DateTime *p /* The date/time value to be modified */
23734
+ DateTime *p, /* The date/time value to be modified */
23735
+ int idx /* Parameter index of the modifier */
23736
){
23737
int rc = 1;
23738
double r;
23739
switch(sqlite3UpperToLower[(u8)z[0]] ){
23740
+ case 'a': {
23741
+ /*
23742
+ ** auto
23743
+ **
23744
+ ** If rawS is available, then interpret as a julian day number, or
23745
+ ** a unix timestamp, depending on its magnitude.
23746
+ */
23747
+ if( sqlite3_stricmp(z, "auto")==0 ){
23748
+ if( idx>1 ) return 1; /* IMP: R-33611-57934 */
23749
+ if( !p->rawS || p->validJD ){
23750
+ rc = 0;
23751
+ p->rawS = 0;
23752
+ }else if( p->s>=-21086676*(i64)10000 /* -4713-11-24 12:00:00 */
23753
+ && p->s<=(25340230*(i64)10000)+799 /* 9999-12-31 23:59:59 */
23754
+ ){
23755
+ r = p->s*1000.0 + 210866760000000.0;
23756
+ clearYMD_HMS_TZ(p);
23757
+ p->iJD = (sqlite3_int64)(r + 0.5);
23758
+ p->validJD = 1;
23759
+ p->rawS = 0;
23760
+ rc = 0;
23761
+ }
23762
+ }
23763
+ break;
23764
+ }
23765
+ case 'j': {
23766
+ /*
23767
+ ** julianday
23768
+ **
23769
+ ** Always interpret the prior number as a julian-day value. If this
23770
+ ** is not the first modifier, or if the prior argument is not a numeric
23771
+ ** value in the allowed range of julian day numbers understood by
23772
+ ** SQLite (0..5373484.5) then the result will be NULL.
23773
+ */
23774
+ if( sqlite3_stricmp(z, "julianday")==0 ){
23775
+ if( idx>1 ) return 1; /* IMP: R-31176-64601 */
23776
+ if( p->validJD && p->rawS ){
23777
+ rc = 0;
23778
+ p->rawS = 0;
23779
+ }
23780
+ }
23781
+ break;
23782
+ }
23783
#ifndef SQLITE_OMIT_LOCALTIME
23784
case 'l': {
23785
/* localtime
@@ -22846,9 +23788,7 @@ static int parseModifier(
23788
** show local time.
23789
*/
23790
if( sqlite3_stricmp(z, "localtime")==0 && sqlite3NotPureFunc(pCtx) ){
22849
- computeJD(p);
22850
- p->iJD += localtimeOffset(p, pCtx, &rc);
22851
- clearYMD_HMS_TZ(p);
23791
+ rc = toLocaltime(p, pCtx);
23792
}
23793
break;
23794
}
@@ -22861,6 +23801,7 @@ static int parseModifier(
23801
** seconds since 1970. Convert to a real julian day number.
23802
*/
23803
if( sqlite3_stricmp(z, "unixepoch")==0 && p->rawS ){
23804
+ if( idx>1 ) return 1; /* IMP: R-49255-55373 */
23805
r = p->s*1000.0 + 210866760000000.0;
23806
if( r>=0.0 && r<464269060800000.0 ){
23807
clearYMD_HMS_TZ(p);
@@ -22873,18 +23814,31 @@ static int parseModifier(
23814
#ifndef SQLITE_OMIT_LOCALTIME
23815
else if( sqlite3_stricmp(z, "utc")==0 && sqlite3NotPureFunc(pCtx) ){
23816
if( p->tzSet==0 ){
22876
- sqlite3_int64 c1;
23817
+ i64 iOrigJD; /* Original localtime */
23818
+ i64 iGuess; /* Guess at the corresponding utc time */
23819
+ int cnt = 0; /* Safety to prevent infinite loop */
23820
+ int iErr; /* Guess is off by this much */
23821
+
23822
computeJD(p);
22878
- c1 = localtimeOffset(p, pCtx, &rc);
22879
- if( rc==SQLITE_OK ){
22880
- p->iJD -= c1;
22881
- clearYMD_HMS_TZ(p);
22882
- p->iJD += c1 - localtimeOffset(p, pCtx, &rc);
22883
- }
23823
+ iGuess = iOrigJD = p->iJD;
23824
+ iErr = 0;
23825
+ do{
23826
+ DateTime new;
23827
+ memset(&new, 0, sizeof(new));
23828
+ iGuess -= iErr;
23829
+ new.iJD = iGuess;
23830
+ new.validJD = 1;
23831
+ rc = toLocaltime(&new, pCtx);
23832
+ if( rc ) return rc;
23833
+ computeJD(&new);
23834
+ iErr = new.iJD - iOrigJD;
23835
+ }while( iErr && cnt++<3 );
23836
+ memset(p, 0, sizeof(*p));
23837
+ p->iJD = iGuess;
23838
+ p->validJD = 1;
23839
p->tzSet = 1;
22885
- }else{
22886
- rc = SQLITE_OK;
23840
}
23841
+ rc = SQLITE_OK;
23842
}
23843
#endif
23844
break;
@@ -23000,9 +23954,10 @@ static int parseModifier(
23954
&& sqlite3_strnicmp(aXformType[i].zName, z, n)==0
23955
&& r>-aXformType[i].rLimit && r<aXformType[i].rLimit
23956
){
23003
- switch( aXformType[i].eType ){
23004
- case 1: { /* Special processing to add months */
23957
+ switch( i ){
23958
+ case 4: { /* Special processing to add months */
23959
int x;
23960
+ assert( strcmp(aXformType[i].zName,"month")==0 );
23961
computeYMD_HMS(p);
23962
p->M += (int)r;
23963
x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;
@@ -23012,8 +23967,9 @@ static int parseModifier(
23967
r -= (int)r;
23968
break;
23969
}
23015
- case 2: { /* Special processing to add years */
23970
+ case 5: { /* Special processing to add years */
23971
int y = (int)r;
23972
+ assert( strcmp(aXformType[i].zName,"year")==0 );
23973
computeYMD_HMS(p);
23974
p->Y += y;
23975
p->validJD = 0;
@@ -23022,7 +23978,7 @@ static int parseModifier(
23978
}
23979
}
23980
computeJD(p);
23025
- p->iJD += (sqlite3_int64)(r*aXformType[i].rXform + rRounder);
23981
+ p->iJD += (sqlite3_int64)(r*1000.0*aXformType[i].rXform + rRounder);
23982
rc = 0;
23983
break;
23984
}
@@ -23072,7 +24028,7 @@ static int isDate(
24028
for(i=1; i<argc; i++){
24029
z = sqlite3_value_text(argv[i]);
24030
n = sqlite3_value_bytes(argv[i]);
23075
- if( z==0 || parseModifier(context, (char*)z, n, p) ) return 1;
24031
+ if( z==0 || parseModifier(context, (char*)z, n, p, i) ) return 1;
24032
}
24033
computeJD(p);
24034
if( p->isError || !validJulianDay(p->iJD) ) return 1;
@@ -23102,6 +24058,24 @@ static void juliandayFunc(
24058
}
24059
}
24060
24061
+/*
24062
+** unixepoch( TIMESTRING, MOD, MOD, ...)
24063
+**
24064
+** Return the number of seconds (including fractional seconds) since
24065
+** the unix epoch of 1970-01-01 00:00:00 GMT.
24066
+*/
24067
+static void unixepochFunc(
24068
+ sqlite3_context *context,
24069
+ int argc,
24070
+ sqlite3_value **argv
24071
+){
24072
+ DateTime x;
24073
+ if( isDate(context, argc, argv, &x)==0 ){
24074
+ computeJD(&x);
24075
+ sqlite3_result_int64(context, x.iJD/1000 - 21086676*(i64)10000);
24076
+ }
24077
+}
24078
+
24079
/*
24080
** datetime( TIMESTRING, MOD, MOD, ...)
24081
**
@@ -23114,11 +24088,38 @@ static void datetimeFunc(
24088
){
24089
DateTime x;
24090
if( isDate(context, argc, argv, &x)==0 ){
23117
- char zBuf[100];
24091
+ int Y, s;
24092
+ char zBuf[24];
24093
computeYMD_HMS(&x);
23119
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%04d-%02d-%02d %02d:%02d:%02d",
23120
- x.Y, x.M, x.D, x.h, x.m, (int)(x.s));
23121
- sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
24094
+ Y = x.Y;
24095
+ if( Y<0 ) Y = -Y;
24096
+ zBuf[1] = '0' + (Y/1000)%10;
24097
+ zBuf[2] = '0' + (Y/100)%10;
24098
+ zBuf[3] = '0' + (Y/10)%10;
24099
+ zBuf[4] = '0' + (Y)%10;
24100
+ zBuf[5] = '-';
24101
+ zBuf[6] = '0' + (x.M/10)%10;
24102
+ zBuf[7] = '0' + (x.M)%10;
24103
+ zBuf[8] = '-';
24104
+ zBuf[9] = '0' + (x.D/10)%10;
24105
+ zBuf[10] = '0' + (x.D)%10;
24106
+ zBuf[11] = ' ';
24107
+ zBuf[12] = '0' + (x.h/10)%10;
24108
+ zBuf[13] = '0' + (x.h)%10;
24109
+ zBuf[14] = ':';
24110
+ zBuf[15] = '0' + (x.m/10)%10;
24111
+ zBuf[16] = '0' + (x.m)%10;
24112
+ zBuf[17] = ':';
24113
+ s = (int)x.s;
24114
+ zBuf[18] = '0' + (s/10)%10;
24115
+ zBuf[19] = '0' + (s)%10;
24116
+ zBuf[20] = 0;
24117
+ if( x.Y<0 ){
24118
+ zBuf[0] = '-';
24119
+ sqlite3_result_text(context, zBuf, 20, SQLITE_TRANSIENT);
24120
+ }else{
24121
+ sqlite3_result_text(context, &zBuf[1], 19, SQLITE_TRANSIENT);
24122
+ }
24123
}
24124
}
24125
@@ -23134,10 +24135,20 @@ static void timeFunc(
24135
){
24136
DateTime x;
24137
if( isDate(context, argc, argv, &x)==0 ){
23137
- char zBuf[100];
24138
+ int s;
24139
+ char zBuf[16];
24140
computeHMS(&x);
23139
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%02d:%02d:%02d", x.h, x.m, (int)x.s);
23140
- sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
24141
+ zBuf[0] = '0' + (x.h/10)%10;
24142
+ zBuf[1] = '0' + (x.h)%10;
24143
+ zBuf[2] = ':';
24144
+ zBuf[3] = '0' + (x.m/10)%10;
24145
+ zBuf[4] = '0' + (x.m)%10;
24146
+ zBuf[5] = ':';
24147
+ s = (int)x.s;
24148
+ zBuf[6] = '0' + (s/10)%10;
24149
+ zBuf[7] = '0' + (s)%10;
24150
+ zBuf[8] = 0;
24151
+ sqlite3_result_text(context, zBuf, 8, SQLITE_TRANSIENT);
24152
}
24153
}
24154
@@ -23153,10 +24164,28 @@ static void dateFunc(
24164
){
24165
DateTime x;
24166
if( isDate(context, argc, argv, &x)==0 ){
23156
- char zBuf[100];
24167
+ int Y;
24168
+ char zBuf[16];
24169
computeYMD(&x);
23158
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%04d-%02d-%02d", x.Y, x.M, x.D);
23159
- sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
24170
+ Y = x.Y;
24171
+ if( Y<0 ) Y = -Y;
24172
+ zBuf[1] = '0' + (Y/1000)%10;
24173
+ zBuf[2] = '0' + (Y/100)%10;
24174
+ zBuf[3] = '0' + (Y/10)%10;
24175
+ zBuf[4] = '0' + (Y)%10;
24176
+ zBuf[5] = '-';
24177
+ zBuf[6] = '0' + (x.M/10)%10;
24178
+ zBuf[7] = '0' + (x.M)%10;
24179
+ zBuf[8] = '-';
24180
+ zBuf[9] = '0' + (x.D/10)%10;
24181
+ zBuf[10] = '0' + (x.D)%10;
24182
+ zBuf[11] = 0;
24183
+ if( x.Y<0 ){
24184
+ zBuf[0] = '-';
24185
+ sqlite3_result_text(context, zBuf, 11, SQLITE_TRANSIENT);
24186
+ }else{
24187
+ sqlite3_result_text(context, &zBuf[1], 10, SQLITE_TRANSIENT);
24188
+ }
24189
}
24190
}
24191
@@ -23185,131 +24214,100 @@ static void strftimeFunc(
24214
sqlite3_value **argv
24215
){
24216
DateTime x;
23188
- u64 n;
This file is too large to show in full.
database/sqlite/sqlite3.h
+497
-44
@@ -43,7 +43,30 @@ extern "C" {
43
44
45
/*
46
-** Provide the ability to override linkage features of the interface.
46
+** Facilitate override of interface linkage and calling conventions.
47
+** Be aware that these macros may not be used within this particular
48
+** translation of the amalgamation and its associated header file.
49
+**
50
+** The SQLITE_EXTERN and SQLITE_API macros are used to instruct the
51
+** compiler that the target identifier should have external linkage.
52
+**
53
+** The SQLITE_CDECL macro is used to set the calling convention for
54
+** public functions that accept a variable number of arguments.
55
+**
56
+** The SQLITE_APICALL macro is used to set the calling convention for
57
+** public functions that accept a fixed number of arguments.
58
+**
59
+** The SQLITE_STDCALL macro is no longer used and is now deprecated.
60
+**
61
+** The SQLITE_CALLBACK macro is used to set the calling convention for
62
+** function pointers.
63
+**
64
+** The SQLITE_SYSAPI macro is used to set the calling convention for
65
+** functions provided by the operating system.
66
+**
67
+** Currently, the SQLITE_CDECL, SQLITE_APICALL, SQLITE_CALLBACK, and
68
+** SQLITE_SYSAPI macros are used only when building for environments
69
+** that require non-default calling conventions.
70
*/
71
#ifndef SQLITE_EXTERN
72
# define SQLITE_EXTERN extern
@@ -123,9 +146,9 @@ extern "C" {
146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147
** [sqlite_version()] and [sqlite_source_id()].
148
*/
126
-#define SQLITE_VERSION "3.36.0"
127
-#define SQLITE_VERSION_NUMBER 3036000
128
-#define SQLITE_SOURCE_ID "2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafa66e5"
149
+#define SQLITE_VERSION "3.38.5"
150
+#define SQLITE_VERSION_NUMBER 3038005
151
+#define SQLITE_SOURCE_ID "2022-05-06 15:25:27 78d9c993d404cdfaa7fdd2973fa1052e3da9f66215cff9c5540ebe55c407d9fe"
152
153
/*
154
** CAPI3REF: Run-Time Library Version Numbers
@@ -537,12 +560,13 @@ SQLITE_API int sqlite3_exec(
560
#define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8))
561
#define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8))
562
#define SQLITE_CONSTRAINT_PINNED (SQLITE_CONSTRAINT |(11<<8))
563
+#define SQLITE_CONSTRAINT_DATATYPE (SQLITE_CONSTRAINT |(12<<8))
564
#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
565
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
566
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
567
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
568
#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
545
-#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8))
569
+#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal use only */
570
571
/*
572
** CAPI3REF: Flags For File Open Operations
@@ -550,6 +574,19 @@ SQLITE_API int sqlite3_exec(
574
** These bit values are intended for use in the
575
** 3rd parameter to the [sqlite3_open_v2()] interface and
576
** in the 4th parameter to the [sqlite3_vfs.xOpen] method.
577
+**
578
+** Only those flags marked as "Ok for sqlite3_open_v2()" may be
579
+** used as the third argument to the [sqlite3_open_v2()] interface.
580
+** The other flags have historically been ignored by sqlite3_open_v2(),
581
+** though future versions of SQLite might change so that an error is
582
+** raised if any of the disallowed bits are passed into sqlite3_open_v2().
583
+** Applications should not depend on the historical behavior.
584
+**
585
+** Note in particular that passing the SQLITE_OPEN_EXCLUSIVE flag into
586
+** [sqlite3_open_v2()] does *not* cause the underlying database file
587
+** to be opened using O_EXCL. Passing SQLITE_OPEN_EXCLUSIVE into
588
+** [sqlite3_open_v2()] has historically be a no-op and might become an
589
+** error in future versions of SQLite.
590
*/
591
#define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */
592
#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */
@@ -572,6 +609,7 @@ SQLITE_API int sqlite3_exec(
609
#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
610
#define SQLITE_OPEN_WAL 0x00080000 /* VFS only */
611
#define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */
612
+#define SQLITE_OPEN_EXRESCODE 0x02000000 /* Extended result codes */
613
614
/* Reserved: 0x00F00000 */
615
/* Legacy compatibility: */
@@ -2464,11 +2502,14 @@ SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);
2502
** CAPI3REF: Count The Number Of Rows Modified
2503
** METHOD: sqlite3
2504
**
2467
-** ^This function returns the number of rows modified, inserted or
2505
+** ^These functions return the number of rows modified, inserted or
2506
** deleted by the most recently completed INSERT, UPDATE or DELETE
2507
** statement on the database connection specified by the only parameter.
2470
-** ^Executing any other type of SQL statement does not modify the value
2471
-** returned by this function.
2508
+** The two functions are identical except for the type of the return value
2509
+** and that if the number of rows modified by the most recent INSERT, UPDATE
2510
+** or DELETE is greater than the maximum value supported by type "int", then
2511
+** the return value of sqlite3_changes() is undefined. ^Executing any other
2512
+** type of SQL statement does not modify the value returned by these functions.
2513
**
2514
** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
2515
** considered - auxiliary changes caused by [CREATE TRIGGER | triggers],
@@ -2517,16 +2558,21 @@ SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);
2558
** </ul>
2559
*/
2560
SQLITE_API int sqlite3_changes(sqlite3*);
2561
+SQLITE_API sqlite3_int64 sqlite3_changes64(sqlite3*);
2562
2563
/*
2564
** CAPI3REF: Total Number Of Rows Modified
2565
** METHOD: sqlite3
2566
**
2525
-** ^This function returns the total number of rows inserted, modified or
2567
+** ^These functions return the total number of rows inserted, modified or
2568
** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
2569
** since the database connection was opened, including those executed as
2528
-** part of trigger programs. ^Executing any other type of SQL statement
2529
-** does not affect the value returned by sqlite3_total_changes().
2570
+** part of trigger programs. The two functions are identical except for the
2571
+** type of the return value and that if the number of rows modified by the
2572
+** connection exceeds the maximum value supported by type "int", then
2573
+** the return value of sqlite3_total_changes() is undefined. ^Executing
2574
+** any other type of SQL statement does not affect the value returned by
2575
+** sqlite3_total_changes().
2576
**
2577
** ^Changes made as part of [foreign key actions] are included in the
2578
** count, but those made as part of REPLACE constraint resolution are
@@ -2554,6 +2600,7 @@ SQLITE_API int sqlite3_changes(sqlite3*);
2600
** </ul>
2601
*/
2602
SQLITE_API int sqlite3_total_changes(sqlite3*);
2603
+SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3*);
2604
2605
/*
2606
** CAPI3REF: Interrupt A Long-Running Query
@@ -3383,6 +3430,14 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3430
** the default shared cache setting provided by
3431
** [sqlite3_enable_shared_cache()].)^
3432
**
3433
+** [[OPEN_EXRESCODE]] ^(<dt>[SQLITE_OPEN_EXRESCODE]</dt>
3434
+** <dd>The database connection comes up in "extended result code mode".
3435
+** In other words, the database behaves has if
3436
+** [sqlite3_extended_result_codes(db,1)] where called on the database
3437
+** connection as soon as the connection is created. In addition to setting
3438
+** the extended result code mode, this flag also causes [sqlite3_open_v2()]
3439
+** to return an extended result code.</dd>
3440
+**
3441
** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt>
3442
** <dd>The database filename is not allowed to be a symbolic link</dd>
3443
** </dl>)^
@@ -3390,7 +3445,15 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3445
** If the 3rd parameter to sqlite3_open_v2() is not one of the
3446
** required combinations shown above optionally combined with other
3447
** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]
3393
-** then the behavior is undefined.
3448
+** then the behavior is undefined. Historic versions of SQLite
3449
+** have silently ignored surplus bits in the flags parameter to
3450
+** sqlite3_open_v2(), however that behavior might not be carried through
3451
+** into future versions of SQLite and so applications should not rely
3452
+** upon it. Note in particular that the SQLITE_OPEN_EXCLUSIVE flag is a no-op
3453
+** for sqlite3_open_v2(). The SQLITE_OPEN_EXCLUSIVE does *not* cause
3454
+** the open to fail if the database already exists. The SQLITE_OPEN_EXCLUSIVE
3455
+** flag is intended for use by the [sqlite3_vfs|VFS interface] only, and not
3456
+** by sqlite3_open_v2().
3457
**
3458
** ^The fourth parameter to sqlite3_open_v2() is the name of the
3459
** [sqlite3_vfs] object that defines the operating system interface that
@@ -3761,13 +3824,14 @@ SQLITE_API void sqlite3_free_filename(char*);
3824
** sqlite3_extended_errcode() might change with each API call.
3825
** Except, there are some interfaces that are guaranteed to never
3826
** change the value of the error code. The error-code preserving
3764
-** interfaces are:
3827
+** interfaces include the following:
3828
**
3829
** <ul>
3830
** <li> sqlite3_errcode()
3831
** <li> sqlite3_extended_errcode()
3832
** <li> sqlite3_errmsg()
3833
** <li> sqlite3_errmsg16()
3834
+** <li> sqlite3_error_offset()
3835
** </ul>
3836
**
3837
** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
@@ -3782,6 +3846,13 @@ SQLITE_API void sqlite3_free_filename(char*);
3846
** ^(Memory to hold the error message string is managed internally
3847
** and must not be freed by the application)^.
3848
**
3849
+** ^If the most recent error references a specific token in the input
3850
+** SQL, the sqlite3_error_offset() interface returns the byte offset
3851
+** of the start of that token. ^The byte offset returned by
3852
+** sqlite3_error_offset() assumes that the input SQL is UTF8.
3853
+** ^If the most recent error does not reference a specific token in the input
3854
+** SQL, then the sqlite3_error_offset() function returns -1.
3855
+**
3856
** When the serialized [threading mode] is in use, it might be the
3857
** case that a second error occurs on a separate thread in between
3858
** the time of the first error and the call to these interfaces.
@@ -3801,6 +3872,7 @@ SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
3872
SQLITE_API const char *sqlite3_errmsg(sqlite3*);
3873
SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
3874
SQLITE_API const char *sqlite3_errstr(int);
3875
+SQLITE_API int sqlite3_error_offset(sqlite3 *db);
3876
3877
/*
3878
** CAPI3REF: Prepared Statement Object
@@ -4158,12 +4230,17 @@ SQLITE_API int sqlite3_prepare16_v3(
4230
** are managed by SQLite and are automatically freed when the prepared
4231
** statement is finalized.
4232
** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
4161
-** is obtained from [sqlite3_malloc()] and must be free by the application
4233
+** is obtained from [sqlite3_malloc()] and must be freed by the application
4234
** by passing it to [sqlite3_free()].
4235
+**
4236
+** ^The sqlite3_normalized_sql() interface is only available if
4237
+** the [SQLITE_ENABLE_NORMALIZE] compile-time option is defined.
4238
*/
4239
SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
4240
SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);
4241
+#ifdef SQLITE_ENABLE_NORMALIZE
4242
SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
4243
+#endif
4244
4245
/*
4246
** CAPI3REF: Determine If An SQL Statement Writes The Database
@@ -4207,6 +4284,10 @@ SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
4284
** be false. ^Similarly, a CREATE TABLE IF NOT EXISTS statement is a
4285
** read-only no-op if the table already exists, but
4286
** sqlite3_stmt_readonly() still returns false for such a statement.
4287
+**
4288
+** ^If prepared statement X is an [EXPLAIN] or [EXPLAIN QUERY PLAN]
4289
+** statement, then sqlite3_stmt_readonly(X) returns the same value as
4290
+** if the EXPLAIN or EXPLAIN QUERY PLAN prefix were omitted.
4291
*/
4292
SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
4293
@@ -4275,6 +4356,8 @@ SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
4356
**
4357
** ^The sqlite3_value objects that are passed as parameters into the
4358
** implementation of [application-defined SQL functions] are protected.
4359
+** ^The sqlite3_value objects returned by [sqlite3_vtab_rhs_value()]
4360
+** are protected.
4361
** ^The sqlite3_value object returned by
4362
** [sqlite3_column_value()] is unprotected.
4363
** Unprotected sqlite3_value objects may only be used as arguments
@@ -4896,6 +4979,10 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
4979
** even empty strings, are always zero-terminated. ^The return
4980
** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
4981
**
4982
+** ^Strings returned by sqlite3_column_text16() always have the endianness
4983
+** which is native to the platform, regardless of the text encoding set
4984
+** for the database.
4985
+**
4986
** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
4987
** [unprotected sqlite3_value] object. In a multithreaded environment,
4988
** an unprotected sqlite3_value object may only be used safely with
@@ -4909,7 +4996,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
4996
** [application-defined SQL functions] or [virtual tables], not within
4997
** top-level application code.
4998
**
4912
-** The these routines may attempt to convert the datatype of the result.
4999
+** These routines may attempt to convert the datatype of the result.
5000
** ^For example, if the internal representation is FLOAT and a text result
5001
** is requested, [sqlite3_snprintf()] is used internally to perform the
5002
** conversion automatically. ^(The following table details the conversions
@@ -4934,7 +5021,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
5021
** <tr><td> TEXT <td> BLOB <td> No change
5022
** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
5023
** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
4937
-** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
5024
+** <tr><td> BLOB <td> TEXT <td> [CAST] to TEXT, ensure zero terminator
5025
** </table>
5026
** </blockquote>)^
5027
**
@@ -6347,6 +6434,72 @@ SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
6434
SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
6435
SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
6436
6437
+/*
6438
+** CAPI3REF: Autovacuum Compaction Amount Callback
6439
+** METHOD: sqlite3
6440
+**
6441
+** ^The sqlite3_autovacuum_pages(D,C,P,X) interface registers a callback
6442
+** function C that is invoked prior to each autovacuum of the database
6443
+** file. ^The callback is passed a copy of the generic data pointer (P),
6444
+** the schema-name of the attached database that is being autovacuumed,
6445
+** the the size of the database file in pages, the number of free pages,
6446
+** and the number of bytes per page, respectively. The callback should
6447
+** return the number of free pages that should be removed by the
6448
+** autovacuum. ^If the callback returns zero, then no autovacuum happens.
6449
+** ^If the value returned is greater than or equal to the number of
6450
+** free pages, then a complete autovacuum happens.
6451
+**
6452
+** <p>^If there are multiple ATTACH-ed database files that are being
6453
+** modified as part of a transaction commit, then the autovacuum pages
6454
+** callback is invoked separately for each file.
6455
+**
6456
+** <p><b>The callback is not reentrant.</b> The callback function should
6457
+** not attempt to invoke any other SQLite interface. If it does, bad
6458
+** things may happen, including segmentation faults and corrupt database
6459
+** files. The callback function should be a simple function that
6460
+** does some arithmetic on its input parameters and returns a result.
6461
+**
6462
+** ^The X parameter to sqlite3_autovacuum_pages(D,C,P,X) is an optional
6463
+** destructor for the P parameter. ^If X is not NULL, then X(P) is
6464
+** invoked whenever the database connection closes or when the callback
6465
+** is overwritten by another invocation of sqlite3_autovacuum_pages().
6466
+**
6467
+** <p>^There is only one autovacuum pages callback per database connection.
6468
+** ^Each call to the sqlite3_autovacuum_pages() interface overrides all
6469
+** previous invocations for that database connection. ^If the callback
6470
+** argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer,
6471
+** then the autovacuum steps callback is cancelled. The return value
6472
+** from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might
6473
+** be some other error code if something goes wrong. The current
6474
+** implementation will only return SQLITE_OK or SQLITE_MISUSE, but other
6475
+** return codes might be added in future releases.
6476
+**
6477
+** <p>If no autovacuum pages callback is specified (the usual case) or
6478
+** a NULL pointer is provided for the callback,
6479
+** then the default behavior is to vacuum all free pages. So, in other
6480
+** words, the default behavior is the same as if the callback function
6481
+** were something like this:
6482
+**
6483
+** <blockquote><pre>
6484
+** unsigned int demonstration_autovac_pages_callback(
6485
+** void *pClientData,
6486
+** const char *zSchema,
6487
+** unsigned int nDbPage,
6488
+** unsigned int nFreePage,
6489
+** unsigned int nBytePerPage
6490
+** ){
6491
+** return nFreePage;
6492
+** }
6493
+** </pre></blockquote>
6494
+*/
6495
+SQLITE_API int sqlite3_autovacuum_pages(
6496
+ sqlite3 *db,
6497
+ unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int),
6498
+ void*,
6499
+ void(*)(void*)
6500
+);
6501
+
6502
+
6503
/*
6504
** CAPI3REF: Data Change Notification Callbacks
6505
** METHOD: sqlite3
@@ -6988,24 +7141,56 @@ struct sqlite3_index_info {
7141
**
7142
** These macros define the allowed values for the
7143
** [sqlite3_index_info].aConstraint[].op field. Each value represents
6991
-** an operator that is part of a constraint term in the wHERE clause of
7144
+** an operator that is part of a constraint term in the WHERE clause of
7145
** a query that uses a [virtual table].
6993
-*/
6994
-#define SQLITE_INDEX_CONSTRAINT_EQ 2
6995
-#define SQLITE_INDEX_CONSTRAINT_GT 4
6996
-#define SQLITE_INDEX_CONSTRAINT_LE 8
6997
-#define SQLITE_INDEX_CONSTRAINT_LT 16
6998
-#define SQLITE_INDEX_CONSTRAINT_GE 32
6999
-#define SQLITE_INDEX_CONSTRAINT_MATCH 64
7000
-#define SQLITE_INDEX_CONSTRAINT_LIKE 65
7001
-#define SQLITE_INDEX_CONSTRAINT_GLOB 66
7002
-#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
7003
-#define SQLITE_INDEX_CONSTRAINT_NE 68
7004
-#define SQLITE_INDEX_CONSTRAINT_ISNOT 69
7005
-#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
7006
-#define SQLITE_INDEX_CONSTRAINT_ISNULL 71
7007
-#define SQLITE_INDEX_CONSTRAINT_IS 72
7008
-#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
7146
+**
7147
+** ^The left-hand operand of the operator is given by the corresponding
7148
+** aConstraint[].iColumn field. ^An iColumn of -1 indicates the left-hand
7149
+** operand is the rowid.
7150
+** The SQLITE_INDEX_CONSTRAINT_LIMIT and SQLITE_INDEX_CONSTRAINT_OFFSET
7151
+** operators have no left-hand operand, and so for those operators the
7152
+** corresponding aConstraint[].iColumn is meaningless and should not be
7153
+** used.
7154
+**
7155
+** All operator values from SQLITE_INDEX_CONSTRAINT_FUNCTION through
7156
+** value 255 are reserved to represent functions that are overloaded
7157
+** by the [xFindFunction|xFindFunction method] of the virtual table
7158
+** implementation.
7159
+**
7160
+** The right-hand operands for each constraint might be accessible using
7161
+** the [sqlite3_vtab_rhs_value()] interface. Usually the right-hand
7162
+** operand is only available if it appears as a single constant literal
7163
+** in the input SQL. If the right-hand operand is another column or an
7164
+** expression (even a constant expression) or a parameter, then the
7165
+** sqlite3_vtab_rhs_value() probably will not be able to extract it.
7166
+** ^The SQLITE_INDEX_CONSTRAINT_ISNULL and
7167
+** SQLITE_INDEX_CONSTRAINT_ISNOTNULL operators have no right-hand operand
7168
+** and hence calls to sqlite3_vtab_rhs_value() for those operators will
7169
+** always return SQLITE_NOTFOUND.
7170
+**
7171
+** The collating sequence to be used for comparison can be found using
7172
+** the [sqlite3_vtab_collation()] interface. For most real-world virtual
7173
+** tables, the collating sequence of constraints does not matter (for example
7174
+** because the constraints are numeric) and so the sqlite3_vtab_collation()
7175
+** interface is no commonly needed.
7176
+*/
7177
+#define SQLITE_INDEX_CONSTRAINT_EQ 2
7178
+#define SQLITE_INDEX_CONSTRAINT_GT 4
7179
+#define SQLITE_INDEX_CONSTRAINT_LE 8
7180
+#define SQLITE_INDEX_CONSTRAINT_LT 16
7181
+#define SQLITE_INDEX_CONSTRAINT_GE 32
7182
+#define SQLITE_INDEX_CONSTRAINT_MATCH 64
7183
+#define SQLITE_INDEX_CONSTRAINT_LIKE 65
7184
+#define SQLITE_INDEX_CONSTRAINT_GLOB 66
7185
+#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
7186
+#define SQLITE_INDEX_CONSTRAINT_NE 68
7187
+#define SQLITE_INDEX_CONSTRAINT_ISNOT 69
7188
+#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
7189
+#define SQLITE_INDEX_CONSTRAINT_ISNULL 71
7190
+#define SQLITE_INDEX_CONSTRAINT_IS 72
7191
+#define SQLITE_INDEX_CONSTRAINT_LIMIT 73
7192
+#define SQLITE_INDEX_CONSTRAINT_OFFSET 74
7193
+#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
7194
7195
/*
7196
** CAPI3REF: Register A Virtual Table Implementation
@@ -7034,7 +7219,7 @@ struct sqlite3_index_info {
7219
** destructor.
7220
**
7221
** ^If the third parameter (the pointer to the sqlite3_module object) is
7037
-** NULL then no new module is create and any existing modules with the
7222
+** NULL then no new module is created and any existing modules with the
7223
** same name are dropped.
7224
**
7225
** See also: [sqlite3_drop_modules()]
@@ -7810,7 +7995,8 @@ SQLITE_API int sqlite3_test_control(int op, ...);
7995
#define SQLITE_TESTCTRL_SEEK_COUNT 30
7996
#define SQLITE_TESTCTRL_TRACEFLAGS 31
7997
#define SQLITE_TESTCTRL_TUNE 32
7813
-#define SQLITE_TESTCTRL_LAST 32 /* Largest TESTCTRL */
7998
+#define SQLITE_TESTCTRL_LOGEST 33
7999
+#define SQLITE_TESTCTRL_LAST 33 /* Largest TESTCTRL */
8000
8001
/*
8002
** CAPI3REF: SQL Keyword Checking
@@ -8333,6 +8519,16 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
8519
** The counter is incremented on the first [sqlite3_step()] call of each
8520
** cycle.
8521
**
8522
+** [[SQLITE_STMTSTATUS_FILTER_MISS]]
8523
+** [[SQLITE_STMTSTATUS_FILTER HIT]]
8524
+** <dt>SQLITE_STMTSTATUS_FILTER_HIT<br>
8525
+** SQLITE_STMTSTATUS_FILTER_MISS</dt>
8526
+** <dd>^SQLITE_STMTSTATUS_FILTER_HIT is the number of times that a join
8527
+** step was bypassed because a Bloom filter returned not-found. The
8528
+** corresponding SQLITE_STMTSTATUS_FILTER_MISS value is the number of
8529
+** times that the Bloom filter returned a find, and thus the join step
8530
+** had to be processed as normal.
8531
+**
8532
** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
8533
** <dd>^This is the approximate number of bytes of heap memory
8534
** used to store the prepared statement. ^This value is not actually
@@ -8347,6 +8543,8 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
8543
#define SQLITE_STMTSTATUS_VM_STEP 4
8544
#define SQLITE_STMTSTATUS_REPREPARE 5
8545
#define SQLITE_STMTSTATUS_RUN 6
8546
+#define SQLITE_STMTSTATUS_FILTER_MISS 7
8547
+#define SQLITE_STMTSTATUS_FILTER_HIT 8
8548
#define SQLITE_STMTSTATUS_MEMUSED 99
8549
8550
/*
@@ -9010,8 +9208,9 @@ SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
9208
**
9209
** A single database handle may have at most a single write-ahead log callback
9210
** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any
9013
-** previously registered write-ahead log callback. ^Note that the
9014
-** [sqlite3_wal_autocheckpoint()] interface and the
9211
+** previously registered write-ahead log callback. ^The return value is
9212
+** a copy of the third parameter from the previous call, if any, or 0.
9213
+** ^Note that the [sqlite3_wal_autocheckpoint()] interface and the
9214
** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
9215
** overwrite any prior [sqlite3_wal_hook()] settings.
9216
*/
@@ -9314,19 +9513,269 @@ SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);
9513
9514
/*
9515
** CAPI3REF: Determine The Collation For a Virtual Table Constraint
9516
+** METHOD: sqlite3_index_info
9517
**
9518
** This function may only be called from within a call to the [xBestIndex]
9319
-** method of a [virtual table].
9519
+** method of a [virtual table]. This function returns a pointer to a string
9520
+** that is the name of the appropriate collation sequence to use for text
9521
+** comparisons on the constraint identified by its arguments.
9522
**
9321
-** The first argument must be the sqlite3_index_info object that is the
9322
-** first parameter to the xBestIndex() method. The second argument must be
9323
-** an index into the aConstraint[] array belonging to the sqlite3_index_info
9324
-** structure passed to xBestIndex. This function returns a pointer to a buffer
9325
-** containing the name of the collation sequence for the corresponding
9326
-** constraint.
9523
+** The first argument must be the pointer to the [sqlite3_index_info] object
9524
+** that is the first parameter to the xBestIndex() method. The second argument
9525
+** must be an index into the aConstraint[] array belonging to the
9526
+** sqlite3_index_info structure passed to xBestIndex.
9527
+**
9528
+** Important:
9529
+** The first parameter must be the same pointer that is passed into the
9530
+** xBestMethod() method. The first parameter may not be a pointer to a
9531
+** different [sqlite3_index_info] object, even an exact copy.
9532
+**
9533
+** The return value is computed as follows:
9534
+**
9535
+** <ol>
9536
+** <li><p> If the constraint comes from a WHERE clause expression that contains
9537
+** a [COLLATE operator], then the name of the collation specified by
9538
+** that COLLATE operator is returned.
9539
+** <li><p> If there is no COLLATE operator, but the column that is the subject
9540
+** of the constraint specifies an alternative collating sequence via
9541
+** a [COLLATE clause] on the column definition within the CREATE TABLE
9542
+** statement that was passed into [sqlite3_declare_vtab()], then the
9543
+** name of that alternative collating sequence is returned.
9544
+** <li><p> Otherwise, "BINARY" is returned.
9545
+** </ol>
9546
*/
9547
SQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
9548
9549
+/*
9550
+** CAPI3REF: Determine if a virtual table query is DISTINCT
9551
+** METHOD: sqlite3_index_info
9552
+**
9553
+** This API may only be used from within an [xBestIndex|xBestIndex method]
9554
+** of a [virtual table] implementation. The result of calling this
9555
+** interface from outside of xBestIndex() is undefined and probably harmful.
9556
+**
9557
+** ^The sqlite3_vtab_distinct() interface returns an integer that is
9558
+** either 0, 1, or 2. The integer returned by sqlite3_vtab_distinct()
9559
+** gives the virtual table additional information about how the query
9560
+** planner wants the output to be ordered. As long as the virtual table
9561
+** can meet the ordering requirements of the query planner, it may set
9562
+** the "orderByConsumed" flag.
9563
+**
9564
+** <ol><li value="0"><p>
9565
+** ^If the sqlite3_vtab_distinct() interface returns 0, that means
9566
+** that the query planner needs the virtual table to return all rows in the
9567
+** sort order defined by the "nOrderBy" and "aOrderBy" fields of the
9568
+** [sqlite3_index_info] object. This is the default expectation. If the
9569
+** virtual table outputs all rows in sorted order, then it is always safe for
9570
+** the xBestIndex method to set the "orderByConsumed" flag, regardless of
9571
+** the return value from sqlite3_vtab_distinct().
9572
+** <li value="1"><p>
9573
+** ^(If the sqlite3_vtab_distinct() interface returns 1, that means
9574
+** that the query planner does not need the rows to be returned in sorted order
9575
+** as long as all rows with the same values in all columns identified by the
9576
+** "aOrderBy" field are adjacent.)^ This mode is used when the query planner
9577
+** is doing a GROUP BY.
9578
+** <li value="2"><p>
9579
+** ^(If the sqlite3_vtab_distinct() interface returns 2, that means
9580
+** that the query planner does not need the rows returned in any particular
9581
+** order, as long as rows with the same values in all "aOrderBy" columns
9582
+** are adjacent.)^ ^(Furthermore, only a single row for each particular
9583
+** combination of values in the columns identified by the "aOrderBy" field
9584
+** needs to be returned.)^ ^It is always ok for two or more rows with the same
9585
+** values in all "aOrderBy" columns to be returned, as long as all such rows
9586
+** are adjacent. ^The virtual table may, if it chooses, omit extra rows
9587
+** that have the same value for all columns identified by "aOrderBy".
9588
+** ^However omitting the extra rows is optional.
9589
+** This mode is used for a DISTINCT query.
9590
+** </ol>
9591
+**
9592
+** ^For the purposes of comparing virtual table output values to see if the
9593
+** values are same value for sorting purposes, two NULL values are considered
9594
+** to be the same. In other words, the comparison operator is "IS"
9595
+** (or "IS NOT DISTINCT FROM") and not "==".
9596
+**
9597
+** If a virtual table implementation is unable to meet the requirements
9598
+** specified above, then it must not set the "orderByConsumed" flag in the
9599
+** [sqlite3_index_info] object or an incorrect answer may result.
9600
+**
9601
+** ^A virtual table implementation is always free to return rows in any order
9602
+** it wants, as long as the "orderByConsumed" flag is not set. ^When the
9603
+** the "orderByConsumed" flag is unset, the query planner will add extra
9604
+** [bytecode] to ensure that the final results returned by the SQL query are
9605
+** ordered correctly. The use of the "orderByConsumed" flag and the
9606
+** sqlite3_vtab_distinct() interface is merely an optimization. ^Careful
9607
+** use of the sqlite3_vtab_distinct() interface and the "orderByConsumed"
9608
+** flag might help queries against a virtual table to run faster. Being
9609
+** overly aggressive and setting the "orderByConsumed" flag when it is not
9610
+** valid to do so, on the other hand, might cause SQLite to return incorrect
9611
+** results.
9612
+*/
9613
+SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info*);
9614
+
9615
+/*
9616
+** CAPI3REF: Identify and handle IN constraints in xBestIndex
9617
+**
9618
+** This interface may only be used from within an
9619
+** [xBestIndex|xBestIndex() method] of a [virtual table] implementation.
9620
+** The result of invoking this interface from any other context is
9621
+** undefined and probably harmful.
9622
+**
9623
+** ^(A constraint on a virtual table of the form
9624
+** "[IN operator|column IN (...)]" is
9625
+** communicated to the xBestIndex method as a
9626
+** [SQLITE_INDEX_CONSTRAINT_EQ] constraint.)^ If xBestIndex wants to use
9627
+** this constraint, it must set the corresponding
9628
+** aConstraintUsage[].argvIndex to a postive integer. ^(Then, under
9629
+** the usual mode of handling IN operators, SQLite generates [bytecode]
9630
+** that invokes the [xFilter|xFilter() method] once for each value
9631
+** on the right-hand side of the IN operator.)^ Thus the virtual table
9632
+** only sees a single value from the right-hand side of the IN operator
9633
+** at a time.
9634
+**
9635
+** In some cases, however, it would be advantageous for the virtual
9636
+** table to see all values on the right-hand of the IN operator all at
9637
+** once. The sqlite3_vtab_in() interfaces facilitates this in two ways:
9638
+**
9639
+** <ol>
9640
+** <li><p>
9641
+** ^A call to sqlite3_vtab_in(P,N,-1) will return true (non-zero)
9642
+** if and only if the [sqlite3_index_info|P->aConstraint][N] constraint
9643
+** is an [IN operator] that can be processed all at once. ^In other words,
9644
+** sqlite3_vtab_in() with -1 in the third argument is a mechanism
9645
+** by which the virtual table can ask SQLite if all-at-once processing
9646
+** of the IN operator is even possible.
9647
+**
9648
+** <li><p>
9649
+** ^A call to sqlite3_vtab_in(P,N,F) with F==1 or F==0 indicates
9650
+** to SQLite that the virtual table does or does not want to process
9651
+** the IN operator all-at-once, respectively. ^Thus when the third
9652
+** parameter (F) is non-negative, this interface is the mechanism by
9653
+** which the virtual table tells SQLite how it wants to process the
9654
+** IN operator.
9655
+** </ol>
9656
+**
9657
+** ^The sqlite3_vtab_in(P,N,F) interface can be invoked multiple times
9658
+** within the same xBestIndex method call. ^For any given P,N pair,
9659
+** the return value from sqlite3_vtab_in(P,N,F) will always be the same
9660
+** within the same xBestIndex call. ^If the interface returns true
9661
+** (non-zero), that means that the constraint is an IN operator
9662
+** that can be processed all-at-once. ^If the constraint is not an IN
9663
+** operator or cannot be processed all-at-once, then the interface returns
9664
+** false.
9665
+**
9666
+** ^(All-at-once processing of the IN operator is selected if both of the
9667
+** following conditions are met:
9668
+**
9669
+** <ol>
9670
+** <li><p> The P->aConstraintUsage[N].argvIndex value is set to a positive
9671
+** integer. This is how the virtual table tells SQLite that it wants to
9672
+** use the N-th constraint.
9673
+**
9674
+** <li><p> The last call to sqlite3_vtab_in(P,N,F) for which F was
9675
+** non-negative had F>=1.
9676
+** </ol>)^
9677
+**
9678
+** ^If either or both of the conditions above are false, then SQLite uses
9679
+** the traditional one-at-a-time processing strategy for the IN constraint.
9680
+** ^If both conditions are true, then the argvIndex-th parameter to the
9681
+** xFilter method will be an [sqlite3_value] that appears to be NULL,
9682
+** but which can be passed to [sqlite3_vtab_in_first()] and
9683
+** [sqlite3_vtab_in_next()] to find all values on the right-hand side
9684
+** of the IN constraint.
9685
+*/
9686
+SQLITE_API int sqlite3_vtab_in(sqlite3_index_info*, int iCons, int bHandle);
9687
+
9688
+/*
9689
+** CAPI3REF: Find all elements on the right-hand side of an IN constraint.
9690
+**
9691
+** These interfaces are only useful from within the
9692
+** [xFilter|xFilter() method] of a [virtual table] implementation.
9693
+** The result of invoking these interfaces from any other context
9694
+** is undefined and probably harmful.
9695
+**
9696
+** The X parameter in a call to sqlite3_vtab_in_first(X,P) or
9697
+** sqlite3_vtab_in_next(X,P) must be one of the parameters to the
9698
+** xFilter method which invokes these routines, and specifically
9699
+** a parameter that was previously selected for all-at-once IN constraint
9700
+** processing use the [sqlite3_vtab_in()] interface in the
9701
+** [xBestIndex|xBestIndex method]. ^(If the X parameter is not
9702
+** an xFilter argument that was selected for all-at-once IN constraint
9703
+** processing, then these routines return [SQLITE_MISUSE])^ or perhaps
9704
+** exhibit some other undefined or harmful behavior.
9705
+**
9706
+** ^(Use these routines to access all values on the right-hand side
9707
+** of the IN constraint using code like the following:
9708
+**
9709
+** <blockquote><pre>
9710
+** for(rc=sqlite3_vtab_in_first(pList, &pVal);
9711
+** rc==SQLITE_OK && pVal
9712
+** rc=sqlite3_vtab_in_next(pList, &pVal)
9713
+** ){
9714
+** // do something with pVal
9715
+** }
9716
+** if( rc!=SQLITE_OK ){
9717
+** // an error has occurred
9718
+** }
9719
+** </pre></blockquote>)^
9720
+**
9721
+** ^On success, the sqlite3_vtab_in_first(X,P) and sqlite3_vtab_in_next(X,P)
9722
+** routines return SQLITE_OK and set *P to point to the first or next value
9723
+** on the RHS of the IN constraint. ^If there are no more values on the
9724
+** right hand side of the IN constraint, then *P is set to NULL and these
9725
+** routines return [SQLITE_DONE]. ^The return value might be
9726
+** some other value, such as SQLITE_NOMEM, in the event of a malfunction.
9727
+**
9728
+** The *ppOut values returned by these routines are only valid until the
9729
+** next call to either of these routines or until the end of the xFilter
9730
+** method from which these routines were called. If the virtual table
9731
+** implementation needs to retain the *ppOut values for longer, it must make
9732
+** copies. The *ppOut values are [protected sqlite3_value|protected].
9733
+*/
9734
+SQLITE_API int sqlite3_vtab_in_first(sqlite3_value *pVal, sqlite3_value **ppOut);
9735
+SQLITE_API int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut);
9736
+
9737
+/*
9738
+** CAPI3REF: Constraint values in xBestIndex()
9739
+** METHOD: sqlite3_index_info
9740
+**
9741
+** This API may only be used from within the [xBestIndex|xBestIndex method]
9742
+** of a [virtual table] implementation. The result of calling this interface
9743
+** from outside of an xBestIndex method are undefined and probably harmful.
9744
+**
9745
+** ^When the sqlite3_vtab_rhs_value(P,J,V) interface is invoked from within
9746
+** the [xBestIndex] method of a [virtual table] implementation, with P being
9747
+** a copy of the [sqlite3_index_info] object pointer passed into xBestIndex and
9748
+** J being a 0-based index into P->aConstraint[], then this routine
9749
+** attempts to set *V to the value of the right-hand operand of
9750
+** that constraint if the right-hand operand is known. ^If the
9751
+** right-hand operand is not known, then *V is set to a NULL pointer.
9752
+** ^The sqlite3_vtab_rhs_value(P,J,V) interface returns SQLITE_OK if
9753
+** and only if *V is set to a value. ^The sqlite3_vtab_rhs_value(P,J,V)
9754
+** inteface returns SQLITE_NOTFOUND if the right-hand side of the J-th
9755
+** constraint is not available. ^The sqlite3_vtab_rhs_value() interface
9756
+** can return an result code other than SQLITE_OK or SQLITE_NOTFOUND if
9757
+** something goes wrong.
9758
+**
9759
+** The sqlite3_vtab_rhs_value() interface is usually only successful if
9760
+** the right-hand operand of a constraint is a literal value in the original
9761
+** SQL statement. If the right-hand operand is an expression or a reference
9762
+** to some other column or a [host parameter], then sqlite3_vtab_rhs_value()
9763
+** will probably return [SQLITE_NOTFOUND].
9764
+**
9765
+** ^(Some constraints, such as [SQLITE_INDEX_CONSTRAINT_ISNULL] and
9766
+** [SQLITE_INDEX_CONSTRAINT_ISNOTNULL], have no right-hand operand. For such
9767
+** constraints, sqlite3_vtab_rhs_value() always returns SQLITE_NOTFOUND.)^
9768
+**
9769
+** ^The [sqlite3_value] object returned in *V is a protected sqlite3_value
9770
+** and remains valid for the duration of the xBestIndex method call.
9771
+** ^When xBestIndex returns, the sqlite3_value object returned by
9772
+** sqlite3_vtab_rhs_value() is automatically deallocated.
9773
+**
9774
+** The "_rhs_" in the name of this routine is an abbreviation for
9775
+** "Right-Hand Side".
9776
+*/
9777
+SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);
9778
+
9779
/*
9780
** CAPI3REF: Conflict resolution modes
9781
** KEYWORDS: {conflict resolution mode}
@@ -9878,6 +10327,10 @@ SQLITE_API unsigned char *sqlite3_serialize(
10327
** database is currently in a read transaction or is involved in a backup
10328
** operation.
10329
**
10330
+** It is not possible to deserialized into the TEMP database. If the
10331
+** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the
10332
+** function returns SQLITE_ERROR.
10333
+**
10334
** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
10335
** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
10336
** [sqlite3_free()] is invoked on argument P prior to returning.