-
Notifications
You must be signed in to change notification settings - Fork 377
/
sqliteInt.h
4585 lines (4223 loc) · 175 KB
/
sqliteInt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2010-2017, Tarantool AUTHORS, please see AUTHORS file.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Internal interface definitions for SQLite.
*
*/
#ifndef SQLITEINT_H
#define SQLITEINT_H
#define IdChar(C) ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0)
/* Special Comments:
*
* Some comments have special meaning to the tools that measure test
* coverage:
*
* NO_TEST - The branches on this line are not
* measured by branch coverage. This is
* used on lines of code that actually
* implement parts of coverage testing.
*
* OPTIMIZATION-IF-TRUE - This branch is allowed to alway be false
* and the correct answer is still obtained,
* though perhaps more slowly.
*
* OPTIMIZATION-IF-FALSE - This branch is allowed to alway be true
* and the correct answer is still obtained,
* though perhaps more slowly.
*
* PREVENTS-HARMLESS-OVERREAD - This branch prevents a buffer overread
* that would be harmless and undetectable
* if it did occur.
*
* In all cases, the special comment must be enclosed in the usual
* slash-asterisk...asterisk-slash comment marks, with no spaces between the
* asterisks and the comment text.
*/
#include <stdbool.h>
#include "box/field_def.h"
#include "box/sql.h"
#include "box/txn.h"
#include "trivia/util.h"
/*
* These #defines should enable >2GB file support on POSIX if the
* underlying operating system supports it. If the OS lacks
* large file support, these should be no-ops.
*
* Ticket #2739: The _LARGEFILE_SOURCE macro must appear before any
* system #includes. Hence, this block of code must be the very first
* code in all source files.
*
* Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
* on the compiler command line. This is necessary if you are compiling
* on a recent machine (ex: Red Hat 7.2) but you want your code to work
* on an older machine (ex: Red Hat 6.0). If you compile on Red Hat 7.2
* without this option, LFS is enable. But LFS does not exist in the kernel
* in Red Hat 6.0, so the code won't work. Hence, for maximum binary
* portability you should omit LFS.
*
* The previous paragraph was written in 2005. (This paragraph is written
* on 2008-11-28.) These days, all Linux kernels support large files, so
* you should probably leave LFS enabled. But some embedded platforms might
* lack LFS in which case the SQLITE_DISABLE_LFS macro might still be useful.
*
* Similar is true for Mac OS X. LFS is only supported on Mac OS X 9 and later.
*/
#ifndef SQLITE_DISABLE_LFS
#define _LARGE_FILE 1
#ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
#endif
#define _LARGEFILE_SOURCE 1
#endif
/* What version of GCC is being used. 0 means GCC is not being used */
#ifdef __GNUC__
#define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__)
#else
#define GCC_VERSION 0
#endif
/* Needed for various definitions... */
#if defined(__GNUC__) && !defined(_GNU_SOURCE)
#define _GNU_SOURCE
#endif
#include "sqliteLimit.h"
/*
* Include standard header files as necessary
*/
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
/*
* The following macros are used to cast pointers to integers and
* integers to pointers. The way you do this varies from one compiler
* to the next, so we have developed the following set of #if statements
* to generate appropriate macros for a wide range of compilers.
*
* The correct "ANSI" way to do this is to use the intptr_t type.
* Unfortunately, that typedef is not available on all compilers, or
* if it is available, it requires an #include of specific headers
* that vary from one machine to the next.
*
* Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on
* the ((void*)&((char*)0)[X]) construct.
*/
#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */
#define SQLITE_INT_TO_PTR(X) ((void*)(__PTRDIFF_TYPE__)(X))
#define SQLITE_PTR_TO_INT(X) ((int)(__PTRDIFF_TYPE__)(X))
#elif !defined(__GNUC__) /* Works for compilers other than LLVM */
#define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X])
#define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0))
#elif defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
#define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X))
#define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X))
#else /* Generates a warning - but it always works */
#define SQLITE_INT_TO_PTR(X) ((void*)(X))
#define SQLITE_PTR_TO_INT(X) ((int)(X))
#endif
/*
* A macro to hint to the compiler that a function should not be
* inlined.
*/
#if defined(__GNUC__)
#define SQLITE_NOINLINE __attribute__((noinline))
#else
#define SQLITE_NOINLINE
#endif
/*
* Powersafe overwrite is on by default. But can be turned off using
* the -DSQLITE_POWERSAFE_OVERWRITE=0 command-line option.
*/
#ifndef SQLITE_POWERSAFE_OVERWRITE
#define SQLITE_POWERSAFE_OVERWRITE 1
#endif
/*
* EVIDENCE-OF: R-25715-37072 Memory allocation statistics are enabled by
* default unless SQLite is compiled with SQLITE_DEFAULT_MEMSTATUS=0 in
* which case memory allocation statistics are disabled by default.
*/
#if !defined(SQLITE_DEFAULT_MEMSTATUS)
#define SQLITE_DEFAULT_MEMSTATUS 1
#endif
#if defined(SQLITE_SYSTEM_MALLOC) \
+ defined(SQLITE_ZERO_MALLOC) \
+ defined(SQLITE_MEMDEBUG)>1
#error "Two or more of the following compile-time configuration options\
are defined but at most one is allowed:\
SQLITE_SYSTEM_MALLOC, SQLITE_MEMDEBUG,\
SQLITE_ZERO_MALLOC"
#endif
#if defined(SQLITE_SYSTEM_MALLOC) \
+ defined(SQLITE_ZERO_MALLOC) \
+ defined(SQLITE_MEMDEBUG)==0
#define SQLITE_SYSTEM_MALLOC 1
#endif
/*
* If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the
* sizes of memory allocations below this value where possible.
*/
#if !defined(SQLITE_MALLOC_SOFT_LIMIT)
#define SQLITE_MALLOC_SOFT_LIMIT 1024
#endif
/*
* Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on.
*/
#if !defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) && defined(SQLITE_DEBUG)
#define SQLITE_ENABLE_EXPLAIN_COMMENTS 1
#endif
/*
* The testcase() macro is used to aid in coverage testing. When
* doing coverage testing, the condition inside the argument to
* testcase() must be evaluated both true and false in order to
* get full branch coverage. The testcase() macro is inserted
* to help ensure adequate test coverage in places where simple
* condition/decision coverage is inadequate. For example, testcase()
* can be used to make sure boundary values are tested. For
* bitmask tests, testcase() can be used to make sure each bit
* is significant and used at least once. On switch statements
* where multiple cases go to the same block of code, testcase()
* can insure that all cases are evaluated.
*
*/
#ifdef SQLITE_COVERAGE_TEST
void sqlite3Coverage(int);
#define testcase(X) if( X ){ sqlite3Coverage(__LINE__); }
#else
#define testcase(X)
#endif
/*
* The TESTONLY macro is used to enclose variable declarations or
* other bits of code that are needed to support the arguments
* within testcase() and assert() macros.
*/
#if !defined(NDEBUG) || defined(SQLITE_COVERAGE_TEST)
#define TESTONLY(X) X
#else
#define TESTONLY(X)
#endif
/*
* Sometimes we need a small amount of code such as a variable initialization
* to setup for a later assert() statement. We do not want this code to
* appear when assert() is disabled. The following macro is therefore
* used to contain that setup code. The "VVA" acronym stands for
* "Verification, Validation, and Accreditation". In other words, the
* code within VVA_ONLY() will only run during verification processes.
*/
#ifndef NDEBUG
#define VVA_ONLY(X) X
#else
#define VVA_ONLY(X)
#endif
/*
* The ALWAYS and NEVER macros surround boolean expressions which
* are intended to always be true or false, respectively. Such
* expressions could be omitted from the code completely. But they
* are included in a few cases in order to enhance the resilience
* of SQLite to unexpected behavior - to make the code "self-healing"
* or "ductile" rather than being "brittle" and crashing at the first
* hint of unplanned behavior.
*
* In other words, ALWAYS and NEVER are added for defensive code.
*
* When doing coverage testing ALWAYS and NEVER are hard-coded to
* be true and false so that the unreachable code they specify will
* not be counted as untested code.
*/
#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
#define ALWAYS(X) (1)
#define NEVER(X) (0)
#elif !defined(NDEBUG)
#define ALWAYS(X) ((X)?1:(assert(0),0))
#define NEVER(X) ((X)?(assert(0),1):0)
#else
#define ALWAYS(X) (X)
#define NEVER(X) (X)
#endif
/*
* Some malloc failures are only possible if SQLITE_TEST_REALLOC_STRESS is
* defined. We need to defend against those failures when testing with
* SQLITE_TEST_REALLOC_STRESS, but we don't want the unreachable branches
* during a normal build. The following macro can be used to disable tests
* that are always false except when SQLITE_TEST_REALLOC_STRESS is set.
*/
#if defined(SQLITE_TEST_REALLOC_STRESS)
#define ONLY_IF_REALLOC_STRESS(X) (X)
#elif !defined(NDEBUG)
#define ONLY_IF_REALLOC_STRESS(X) ((X)?(assert(0),1):0)
#else
#define ONLY_IF_REALLOC_STRESS(X) (0)
#endif
/*
* Is the sqlite3ErrName() function needed in the build? Currently,
* it is needed by several "test*.c" files (which are
* compiled using SQLITE_TEST).
*/
#if defined(SQLITE_TEST)
#define SQLITE_NEED_ERR_NAME
#else
#undef SQLITE_NEED_ERR_NAME
#endif
/*
* Return true (non-zero) if the input is an integer that is too large
* to fit in 32-bits. This macro is used inside of various testcase()
* macros to verify that we have tested SQLite for large-file support.
*/
#define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
#include "hash.h"
#include "parse.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stddef.h>
typedef long long int sqlite_int64;
typedef unsigned long long int sqlite_uint64;
typedef sqlite_int64 sqlite3_int64;
typedef sqlite_uint64 sqlite3_uint64;
typedef struct sqlite3_stmt sqlite3_stmt;
typedef struct sqlite3_context sqlite3_context;
typedef struct sqlite3 sqlite3;
typedef struct Mem sqlite3_value;
typedef struct sqlite3_file sqlite3_file;
struct sqlite3_file {
const struct sqlite3_io_methods *pMethods; /* Methods for an open file */
};
typedef int (*sqlite3_callback) (void *, int, char **, char **);
typedef struct sqlite3_vfs sqlite3_vfs;
typedef void (*sqlite3_syscall_ptr) (void);
struct sqlite3_vfs {
int iVersion; /* Structure version number (currently 3) */
int szOsFile; /* Size of subclassed sqlite3_file */
int mxPathname; /* Maximum file pathname length */
sqlite3_vfs *pNext; /* Next registered VFS */
const char *zName; /* Name of this virtual file system */
void *pAppData; /* Pointer to application-specific data */
int (*xOpen) (sqlite3_vfs *, const char *zName, sqlite3_file *,
int flags, int *pOutFlags);
int (*xDelete) (sqlite3_vfs *, const char *zName, int syncDir);
int (*xAccess) (sqlite3_vfs *, const char *zName, int flags,
int *pResOut);
int (*xFullPathname) (sqlite3_vfs *, const char *zName,
int nOut, char *zOut);
void *(*xDlOpen) (sqlite3_vfs *, const char *zFilename);
void (*xDlError) (sqlite3_vfs *, int nByte, char *zErrMsg);
void (*(*xDlSym) (sqlite3_vfs *, void *, const char *zSymbol))
(void);
void (*xDlClose) (sqlite3_vfs *, void *);
int (*xRandomness) (sqlite3_vfs *, int nByte, char *zOut);
int (*xSleep) (sqlite3_vfs *, int microseconds);
int (*xCurrentTime) (sqlite3_vfs *, double *);
int (*xGetLastError) (sqlite3_vfs *, int, char *);
/*
** The methods above are in version 1 of the sqlite_vfs object
** definition. Those that follow are added in version 2 or later
*/
int (*xCurrentTimeInt64) (sqlite3_vfs *, sqlite3_int64 *);
/*
** The methods above are in versions 1 and 2 of the sqlite_vfs object.
** Those below are for version 3 and greater.
*/
int (*xSetSystemCall) (sqlite3_vfs *, const char *zName,
sqlite3_syscall_ptr);
sqlite3_syscall_ptr(*xGetSystemCall) (sqlite3_vfs *,
const char *zName);
const char *(*xNextSystemCall) (sqlite3_vfs *,
const char *zName);
/*
** The methods above are in versions 1 through 3 of the sqlite_vfs object.
** New fields may be appended in future versions. The iVersion
** value will increment whenever this happens.
*/
};
#define SQLITE_LIMIT_LENGTH 0
#define SQLITE_LIMIT_SQL_LENGTH 1
#define SQLITE_LIMIT_COLUMN 2
#define SQLITE_LIMIT_EXPR_DEPTH 3
#define SQLITE_LIMIT_COMPOUND_SELECT 4
#define SQLITE_LIMIT_VDBE_OP 5
#define SQLITE_LIMIT_FUNCTION_ARG 6
#define SQLITE_LIMIT_ATTACHED 7
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
#define SQLITE_LIMIT_TRIGGER_DEPTH 9
#define SQLITE_LIMIT_WORKER_THREADS 10
enum sql_ret_code {
/** Result of a routine is ok. */
SQLITE_OK = 0,
/** Common error code. */
SQLITE_ERROR,
/** Access permission denied. */
SQLITE_PERM,
/** Callback routine requested an abort. */
SQLITE_ABORT,
/** The database file is locked. */
SQLITE_BUSY,
/** A table in the database is locked. */
SQLITE_LOCKED,
/** A malloc() failed. */
SQLITE_NOMEM,
/** Operation terminated by sqlite3_interrupt(). */
SQLITE_INTERRUPT,
/** Some kind of disk I/O error occurred. */
SQLITE_IOERR,
/** The database disk image is malformed. */
SQLITE_CORRUPT,
/** Unknown opcode in sqlite3_file_control(). */
SQLITE_NOTFOUND,
/** Insertion failed because database is full. */
SQLITE_FULL,
/** Unable to open the database file. */
SQLITE_CANTOPEN,
/** The database schema changed. */
SQLITE_SCHEMA,
/** String or BLOB exceeds size limit. */
SQLITE_TOOBIG,
/** Abort due to constraint violation. */
SQLITE_CONSTRAINT,
/** Data type mismatch. */
SQLITE_MISMATCH,
/** Library used incorrectly. */
SQLITE_MISUSE,
/** 2nd parameter to sqlite3_bind out of range. */
SQLITE_RANGE,
SQL_TARANTOOL_ITERATOR_FAIL,
SQL_TARANTOOL_INSERT_FAIL,
SQL_TARANTOOL_DELETE_FAIL,
SQL_TARANTOOL_ERROR,
/** Warnings from sqlite3_log(). */
SQLITE_WARNING,
/** sqlite3_step() has another row ready. */
SQLITE_ROW,
/** sqlite3_step() has finished executing. */
SQLITE_DONE,
};
void *
sqlite3_malloc(int);
void *
sqlite3_malloc64(sqlite3_uint64);
void *
sqlite3_realloc(void *, int);
void *
sqlite3_realloc64(void *, sqlite3_uint64);
void
sqlite3_free(void *);
sqlite3_uint64
sqlite3_msize(void *);
int
sqlite3_stricmp(const char *, const char *);
int
sqlite3_strnicmp(const char *, const char *, int);
const void *
sqlite3_value_blob(sqlite3_value *);
int
sqlite3_value_bytes(sqlite3_value *);
double
sqlite3_value_double(sqlite3_value *);
int
sqlite3_value_int(sqlite3_value *);
sqlite3_int64
sqlite3_value_int64(sqlite3_value *);
const unsigned char *
sqlite3_value_text(sqlite3_value *);
int
sqlite3_value_type(sqlite3_value *);
int
sqlite3_value_numeric_type(sqlite3_value *);
sqlite3 *
sqlite3_context_db_handle(sqlite3_context *);
void
sqlite3_result_blob(sqlite3_context *, const void *,
int, void (*)(void *));
void
sqlite3_result_blob64(sqlite3_context *, const void *,
sqlite3_uint64, void (*)(void *));
void
sqlite3_result_double(sqlite3_context *, double);
void
sqlite3_result_error(sqlite3_context *, const char *,
int);
void
sqlite3_result_error_toobig(sqlite3_context *);
void
sqlite3_result_error_nomem(sqlite3_context *);
void
sqlite3_result_error_code(sqlite3_context *, int);
void
sqlite3_result_int(sqlite3_context *, int);
void
sqlite3_result_int64(sqlite3_context *, sqlite3_int64);
void
sqlite3_result_null(sqlite3_context *);
void
sqlite3_result_text(sqlite3_context *, const char *,
int, void (*)(void *));
void
sqlite3_result_text64(sqlite3_context *, const char *,
sqlite3_uint64, void (*)(void *));
void
sqlite3_result_value(sqlite3_context *,
sqlite3_value *);
void
sqlite3_result_zeroblob(sqlite3_context *, int n);
int
sqlite3_result_zeroblob64(sqlite3_context *,
sqlite3_uint64 n);
char *
sqlite3_mprintf(const char *, ...);
char *
sqlite3_vmprintf(const char *, va_list);
char *
sqlite3_snprintf(int, char *, const char *, ...);
char *
sqlite3_vsnprintf(int, char *, const char *, va_list);
int
sqlite3_strlike(const char *zGlob, const char *zStr,
unsigned int cEsc);
typedef void (*sqlite3_destructor_type) (void *);
#define SQLITE_STATIC ((sqlite3_destructor_type)0)
#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
int
sqlite3_strglob(const char *zGlob, const char *zStr);
int
sqlite3_prepare(sqlite3 * db, /* Database handle */
const char *zSql, /* SQL statement, UTF-8 encoded */
int nByte, /* Maximum length of zSql in bytes. */
sqlite3_stmt ** ppStmt, /* OUT: Statement handle */
const char **pzTail /* OUT: Pointer to unused portion of zSql */
);
int
sqlite3_prepare_v2(sqlite3 * db, /* Database handle */
const char *zSql, /* SQL statement, UTF-8 encoded */
int nByte, /* Maximum length of zSql in bytes. */
sqlite3_stmt ** ppStmt, /* OUT: Statement handle */
const char **pzTail /* OUT: Pointer to unused portion of zSql */
);
int
sqlite3_step(sqlite3_stmt *);
const void *
sqlite3_column_blob(sqlite3_stmt *, int iCol);
int
sqlite3_column_bytes(sqlite3_stmt *, int iCol);
int
sqlite3_column_bytes16(sqlite3_stmt *, int iCol);
double
sqlite3_column_double(sqlite3_stmt *, int iCol);
int
sqlite3_column_int(sqlite3_stmt *, int iCol);
sqlite3_int64
sqlite3_column_int64(sqlite3_stmt *, int iCol);
const unsigned char *
sqlite3_column_text(sqlite3_stmt *,
int iCol);
int
sqlite3_column_type(sqlite3_stmt *, int iCol);
sqlite3_value *
sqlite3_column_value(sqlite3_stmt *,
int iCol);
int
sqlite3_finalize(sqlite3_stmt * pStmt);
int
sqlite3_exec(sqlite3 *, /* An open database */
const char *sql, /* SQL to be evaluated */
int (*callback) (void *, int, char **, char **), /* Callback function */
void *, /* 1st argument to callback */
char **errmsg /* Error msg written here */
);
#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8))
#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8))
#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8))
#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8))
#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8))
#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8))
#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8))
#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8))
#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))
#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8))
#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
#define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8))
#define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8))
#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
#define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8))
#define SQLITE_IOERR_VNODE (SQLITE_IOERR | (27<<8))
#define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
#define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1<<8))
#define SQLITE_CONSTRAINT_FOREIGNKEY (SQLITE_CONSTRAINT | (3<<8))
#define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (4<<8))
#define SQLITE_CONSTRAINT_NOTNULL (SQLITE_CONSTRAINT | (5<<8))
#define SQLITE_CONSTRAINT_PRIMARYKEY (SQLITE_CONSTRAINT | (6<<8))
#define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8))
#define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8))
enum sql_type {
SQLITE_INTEGER = 1,
SQLITE_FLOAT = 2,
SQLITE_TEXT = 3,
SQLITE_BLOB = 4,
SQLITE_NULL = 5,
};
/**
* Structure for internal usage during INSERT/UPDATE
* statements compilation.
*/
struct on_conflict {
/**
* Represents an error action in queries like
* INSERT/UPDATE OR <override_error>, which
* overrides all space constraints error actions.
* That kind of error action is strictly specified by
* user and therefore have highest priority.
*/
enum on_conflict_action override_error;
/**
* Represents an ON CONFLICT action which can be
* optimized and executed without VDBE bytecode, by
* Tarantool facilities. If optimization is not available,
* then the value is ON_CONFLICT_ACTION_NONE, otherwise
* it is ON_CONFLICT_ACTON_IGNORE or
* ON_CONFLICT_ACTION_REPLACE.
*/
enum on_conflict_action optimized_action;
};
void *
sqlite3_user_data(sqlite3_context *);
void
sqlite3_randomness(int N, void *P);
int
sqlite3_changes(sqlite3 *);
int
sqlite3_total_changes(sqlite3 *);
void *
sqlite3_user_data(sqlite3_context *);
const char *
sqlite3_libversion(void);
const char *
sqlite3_sourceid(void);
void
sqlite3_log(int iErrCode, const char *zFormat, ...);
void *
sqlite3_aggregate_context(sqlite3_context *,
int nBytes);
int
sqlite3_column_count(sqlite3_stmt * pStmt);
const char *
sqlite3_column_name(sqlite3_stmt *, int N);
const char *
sqlite3_errmsg(sqlite3 *);
int
sqlite3_initialize(void);
#define SQLITE_VERSION "3.16.2"
#define SQLITE_VERSION_NUMBER 3016002
#define SQLITE_SOURCE_ID "D 1970-01-01 00:00:00 00000000-0000-0000-0000-000000000000"
int
sqlite3_os_end(void);
#define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */
#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */
#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
#define SQLITE_CONFIG_URI 17 /* int */
#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */
#define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
#define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */
#define SQLITE_CONFIG_PMASZ 24 /* unsigned int szPma */
#define SQLITE_CONFIG_STMTJRNL_SPILL 25 /* int nByte */
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
#define SQLITE_TRACE_STMT 0x01
#define SQLITE_TRACE_PROFILE 0x02
#define SQLITE_TRACE_ROW 0x04
#define SQLITE_TRACE_CLOSE 0x08
#define SQLITE_DETERMINISTIC 0x800
#define SQLITE_STATUS_MEMORY_USED 0
#define SQLITE_STATUS_PAGECACHE_USED 1
#define SQLITE_STATUS_PAGECACHE_OVERFLOW 2
#define SQLITE_STATUS_SCRATCH_USED 3
#define SQLITE_STATUS_SCRATCH_OVERFLOW 4
#define SQLITE_STATUS_MALLOC_SIZE 5
#define SQLITE_STATUS_PARSER_STACK 6
#define SQLITE_STATUS_PAGECACHE_SIZE 7
#define SQLITE_STATUS_SCRATCH_SIZE 8
#define SQLITE_STATUS_MALLOC_COUNT 9
sqlite3_int64
sqlite3_memory_used(void);
int
sqlite3_create_function_v2(sqlite3 * db,
const char *zFunctionName,
int nArg,
int flags,
void *pApp,
void (*xFunc) (sqlite3_context *,
int,
sqlite3_value **),
void (*xStep) (sqlite3_context *,
int,
sqlite3_value **),
void (*xFinal)
(sqlite3_context *),
void (*xDestroy) (void *)
);
#define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */
#define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */
#define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */
#define SQLITE_OPEN_URI 0x00000040 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_MEMORY 0x00000080 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */
#define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */
#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
sqlite3_vfs *
sqlite3_vfs_find(const char *zVfsName);
#define SQLITE_TESTCTRL_FIRST 5
#define SQLITE_TESTCTRL_PRNG_SAVE 5
#define SQLITE_TESTCTRL_PRNG_RESTORE 6
#define SQLITE_TESTCTRL_PRNG_RESET 7
#define SQLITE_TESTCTRL_BITVEC_TEST 8
#define SQLITE_TESTCTRL_FAULT_INSTALL 9
#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
#define SQLITE_TESTCTRL_PENDING_BYTE 11
#define SQLITE_TESTCTRL_ASSERT 12
#define SQLITE_TESTCTRL_ALWAYS 13
#define SQLITE_TESTCTRL_RESERVE 14
#define SQLITE_TESTCTRL_OPTIMIZATIONS 15
#define SQLITE_TESTCTRL_ISKEYWORD 16
#define SQLITE_TESTCTRL_SCRATCHMALLOC 17
#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
#define SQLITE_TESTCTRL_EXPLAIN_STMT 19 /* NOT USED */
#define SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD 19
#define SQLITE_TESTCTRL_NEVER_CORRUPT 20
#define SQLITE_TESTCTRL_VDBE_COVERAGE 21
#define SQLITE_TESTCTRL_BYTEORDER 22
#define SQLITE_TESTCTRL_ISINIT 23
#define SQLITE_TESTCTRL_SORTER_MMAP 24
#define SQLITE_TESTCTRL_IMPOSTER 25
#define SQLITE_TESTCTRL_LAST 25
int
sqlite3_status64(int op, sqlite3_int64 * pCurrent,
sqlite3_int64 * pHighwater,
int resetFlag);
int
sqlite3_config(int, ...);
typedef struct sqlite3_io_methods sqlite3_io_methods;
struct sqlite3_io_methods {
int iVersion;
int (*xClose) (sqlite3_file *);
int (*xRead) (sqlite3_file *, void *, int iAmt,
sqlite3_int64 iOfst);
int (*xWrite) (sqlite3_file *, const void *, int iAmt,
sqlite3_int64 iOfst);
int (*xTruncate) (sqlite3_file *, sqlite3_int64 size);
int (*xSync) (sqlite3_file *, int flags);
int (*xFileSize) (sqlite3_file *, sqlite3_int64 * pSize);
int (*xLock) (sqlite3_file *, int);
int (*xUnlock) (sqlite3_file *, int);
int (*xCheckReservedLock) (sqlite3_file *, int *pResOut);
int (*xFileControl) (sqlite3_file *, int op, void *pArg);
int (*xSectorSize) (sqlite3_file *);
int (*xDeviceCharacteristics) (sqlite3_file *);
/* Methods above are valid for version 1 */
int (*xShmMap) (sqlite3_file *, int iPg, int pgsz, int,
void volatile **);
int (*xShmLock) (sqlite3_file *, int offset, int n, int flags);
void (*xShmBarrier) (sqlite3_file *);
int (*xShmUnmap) (sqlite3_file *, int deleteFlag);
/* Methods above are valid for version 2 */
int (*xFetch) (sqlite3_file *, sqlite3_int64 iOfst, int iAmt,
void **pp);
int (*xUnfetch) (sqlite3_file *, sqlite3_int64 iOfst, void *p);
/* Methods above are valid for version 3 */
/* Additional methods may be added in future releases */
};
#define SQLITE_FCNTL_LOCKSTATE 1
#define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
#define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
#define SQLITE_FCNTL_LAST_ERRNO 4
#define SQLITE_FCNTL_SIZE_HINT 5
#define SQLITE_FCNTL_CHUNK_SIZE 6
#define SQLITE_FCNTL_FILE_POINTER 7
#define SQLITE_FCNTL_SYNC_OMITTED 8
#define SQLITE_FCNTL_OVERWRITE 10
#define SQLITE_FCNTL_VFSNAME 11
#define SQLITE_FCNTL_POWERSAFE_OVERWRITE 12
#define SQLITE_FCNTL_PRAGMA 13
#define SQLITE_FCNTL_BUSYHANDLER 14
#define SQLITE_FCNTL_TEMPFILENAME 15
#define SQLITE_FCNTL_MMAP_SIZE 16
#define SQLITE_FCNTL_TRACE 17
#define SQLITE_FCNTL_HAS_MOVED 18
#define SQLITE_FCNTL_SYNC 19
#define SQLITE_FCNTL_COMMIT_PHASETWO 20
#define SQLITE_FCNTL_ZIPVFS 22
#define SQLITE_FCNTL_RBU 23
#define SQLITE_FCNTL_VFS_POINTER 24
#define SQLITE_FCNTL_PDB 26
int
sqlite3_os_init(void);
int
sqlite3_db_release_memory(sqlite3 *);
int
sqlite3_busy_timeout(sqlite3 *, int ms);
sqlite3_int64
sqlite3_soft_heap_limit64(sqlite3_int64 N);
int
sqlite3_limit(sqlite3 *, int id, int newVal);
#define SQLITE_SYNC_NORMAL 0x00002
#define SQLITE_SYNC_FULL 0x00003
#define SQLITE_SYNC_DATAONLY 0x00010
int
sqlite3_uri_boolean(const char *zFile,
const char *zParam, int bDefault);
extern char *
sqlite3_temp_directory;
const char *
sqlite3_uri_parameter(const char *zFilename,
const char *zParam);
#define SQLITE_ACCESS_EXISTS 0
#define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */
#define SQLITE_ACCESS_READ 2 /* Unused */
#define SQLITE_DBSTATUS_LOOKASIDE_USED 0
#define SQLITE_DBSTATUS_CACHE_USED 1
#define SQLITE_DBSTATUS_SCHEMA_USED 2
#define SQLITE_DBSTATUS_STMT_USED 3
#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
#define SQLITE_DBSTATUS_CACHE_HIT 7
#define SQLITE_DBSTATUS_CACHE_MISS 8
#define SQLITE_DBSTATUS_CACHE_WRITE 9
#define SQLITE_DBSTATUS_DEFERRED_FKS 10
#define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
#define SQLITE_DBSTATUS_MAX 11 /* Largest defined DBSTATUS */
const char *
sqlite3_sql(sqlite3_stmt * pStmt);
int
sqlite3_vfs_register(sqlite3_vfs *, int makeDflt);
void
sqlite3_free_table(char **result);
#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
#define SQLITE_STMTSTATUS_SORT 2
#define SQLITE_STMTSTATUS_AUTOINDEX 3
#define SQLITE_STMTSTATUS_VM_STEP 4
void
sqlite3_interrupt(sqlite3 *);
int
sqlite3_bind_blob(sqlite3_stmt *, int, const void *,
int n, void (*)(void *));
int
sqlite3_bind_blob64(sqlite3_stmt *, int, const void *,
sqlite3_uint64, void (*)(void *));
int
sqlite3_bind_double(sqlite3_stmt *, int, double);
int
sqlite3_bind_int(sqlite3_stmt *, int, int);
int
sqlite3_bind_int64(sqlite3_stmt *, int, sqlite3_int64);
int
sqlite3_bind_null(sqlite3_stmt *, int);
int
sqlite3_bind_text(sqlite3_stmt *, int, const char *, int,
void (*)(void *));
int