0000: 2f 2a 0a 2a 2a 20 32 30 30 31 20 53 65 70 74 65 /*.** 2001 Septe
0010: 6d 62 65 72 20 31 35 0a 2a 2a 0a 2a 2a 20 54 68 mber 15.**.** Th
0020: 65 20 61 75 74 68 6f 72 20 64 69 73 63 6c 61 69 e author disclai
0030: 6d 73 20 63 6f 70 79 72 69 67 68 74 20 74 6f 20 ms copyright to
0040: 74 68 69 73 20 73 6f 75 72 63 65 20 63 6f 64 65 this source code
0050: 2e 20 20 49 6e 20 70 6c 61 63 65 20 6f 66 0a 2a . In place of.*
0060: 2a 20 61 20 6c 65 67 61 6c 20 6e 6f 74 69 63 65 * a legal notice
0070: 2c 20 68 65 72 65 20 69 73 20 61 20 62 6c 65 73 , here is a bles
0080: 73 69 6e 67 3a 0a 2a 2a 0a 2a 2a 20 20 20 20 4d sing:.**.** M
0090: 61 79 20 79 6f 75 20 64 6f 20 67 6f 6f 64 20 61 ay you do good a
00a0: 6e 64 20 6e 6f 74 20 65 76 69 6c 2e 0a 2a 2a 20 nd not evil..**
00b0: 20 20 20 4d 61 79 20 79 6f 75 20 66 69 6e 64 20 May you find
00c0: 66 6f 72 67 69 76 65 6e 65 73 73 20 66 6f 72 20 forgiveness for
00d0: 79 6f 75 72 73 65 6c 66 20 61 6e 64 20 66 6f 72 yourself and for
00e0: 67 69 76 65 20 6f 74 68 65 72 73 2e 0a 2a 2a 20 give others..**
00f0: 20 20 20 4d 61 79 20 79 6f 75 20 73 68 61 72 65 May you share
0100: 20 66 72 65 65 6c 79 2c 20 6e 65 76 65 72 20 74 freely, never t
0110: 61 6b 69 6e 67 20 6d 6f 72 65 20 74 68 61 6e 20 aking more than
0120: 79 6f 75 20 67 69 76 65 2e 0a 2a 2a 0a 2a 2a 2a you give..**.***
0130: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0140: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0150: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0160: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0170: 2a 2a 2a 2a 2a 2a 0a 2a 2a 20 54 68 69 73 20 68 ******.** This h
0180: 65 61 64 65 72 20 66 69 6c 65 20 64 65 66 69 6e eader file defin
0190: 65 73 20 74 68 65 20 69 6e 74 65 72 66 61 63 65 es the interface
01a0: 20 74 68 61 74 20 74 68 65 20 53 51 4c 69 74 65 that the SQLite
01b0: 20 6c 69 62 72 61 72 79 0a 2a 2a 20 70 72 65 73 library.** pres
01c0: 65 6e 74 73 20 74 6f 20 63 6c 69 65 6e 74 20 70 ents to client p
01d0: 72 6f 67 72 61 6d 73 2e 20 20 49 66 20 61 20 43 rograms. If a C
01e0: 2d 66 75 6e 63 74 69 6f 6e 2c 20 73 74 72 75 63 -function, struc
01f0: 74 75 72 65 2c 20 64 61 74 61 74 79 70 65 2c 0a ture, datatype,.
0200: 2a 2a 20 6f 72 20 63 6f 6e 73 74 61 6e 74 20 64 ** or constant d
0210: 65 66 69 6e 69 74 69 6f 6e 20 64 6f 65 73 20 6e efinition does n
0220: 6f 74 20 61 70 70 65 61 72 20 69 6e 20 74 68 69 ot appear in thi
0230: 73 20 66 69 6c 65 2c 20 74 68 65 6e 20 69 74 20 s file, then it
0240: 69 73 0a 2a 2a 20 6e 6f 74 20 61 20 70 75 62 6c is.** not a publ
0250: 69 73 68 65 64 20 41 50 49 20 6f 66 20 53 51 4c ished API of SQL
0260: 69 74 65 2c 20 69 73 20 73 75 62 6a 65 63 74 20 ite, is subject
0270: 74 6f 20 63 68 61 6e 67 65 20 77 69 74 68 6f 75 to change withou
0280: 74 0a 2a 2a 20 6e 6f 74 69 63 65 2c 20 61 6e 64 t.** notice, and
0290: 20 73 68 6f 75 6c 64 20 6e 6f 74 20 62 65 20 72 should not be r
02a0: 65 66 65 72 65 6e 63 65 64 20 62 79 20 70 72 6f eferenced by pro
02b0: 67 72 61 6d 73 20 74 68 61 74 20 75 73 65 20 53 grams that use S
02c0: 51 4c 69 74 65 2e 0a 2a 2a 0a 2a 2a 20 53 6f 6d QLite..**.** Som
02d0: 65 20 6f 66 20 74 68 65 20 64 65 66 69 6e 69 74 e of the definit
02e0: 69 6f 6e 73 20 74 68 61 74 20 61 72 65 20 69 6e ions that are in
02f0: 20 74 68 69 73 20 66 69 6c 65 20 61 72 65 20 6d this file are m
0300: 61 72 6b 65 64 20 61 73 0a 2a 2a 20 22 65 78 70 arked as.** "exp
0310: 65 72 69 6d 65 6e 74 61 6c 22 2e 20 20 45 78 70 erimental". Exp
0320: 65 72 69 6d 65 6e 74 61 6c 20 69 6e 74 65 72 66 erimental interf
0330: 61 63 65 73 20 61 72 65 20 6e 6f 72 6d 61 6c 6c aces are normall
0340: 79 20 6e 65 77 0a 2a 2a 20 66 65 61 74 75 72 65 y new.** feature
0350: 73 20 72 65 63 65 6e 74 6c 79 20 61 64 64 65 64 s recently added
0360: 20 74 6f 20 53 51 4c 69 74 65 2e 20 20 57 65 20 to SQLite. We
0370: 64 6f 20 6e 6f 74 20 61 6e 74 69 63 69 70 61 74 do not anticipat
0380: 65 20 63 68 61 6e 67 65 73 0a 2a 2a 20 74 6f 20 e changes.** to
0390: 65 78 70 65 72 69 6d 65 6e 74 61 6c 20 69 6e 74 experimental int
03a0: 65 72 66 61 63 65 73 20 62 75 74 20 72 65 73 65 erfaces but rese
03b0: 72 76 65 20 74 68 65 20 72 69 67 68 74 20 74 6f rve the right to
03c0: 20 6d 61 6b 65 20 6d 69 6e 6f 72 20 63 68 61 6e make minor chan
03d0: 67 65 73 0a 2a 2a 20 69 66 20 65 78 70 65 72 69 ges.** if experi
03e0: 65 6e 63 65 20 66 72 6f 6d 20 75 73 65 20 22 69 ence from use "i
03f0: 6e 20 74 68 65 20 77 69 6c 64 22 20 73 75 67 67 n the wild" sugg
0400: 65 73 74 20 73 75 63 68 20 63 68 61 6e 67 65 73 est such changes
0410: 20 61 72 65 20 70 72 75 64 65 6e 74 2e 0a 2a 2a are prudent..**
0420: 0a 2a 2a 20 54 68 65 20 6f 66 66 69 63 69 61 6c .** The official
0430: 20 43 2d 6c 61 6e 67 75 61 67 65 20 41 50 49 20 C-language API
0440: 64 6f 63 75 6d 65 6e 74 61 74 69 6f 6e 20 66 6f documentation fo
0450: 72 20 53 51 4c 69 74 65 20 69 73 20 64 65 72 69 r SQLite is deri
0460: 76 65 64 0a 2a 2a 20 66 72 6f 6d 20 63 6f 6d 6d ved.** from comm
0470: 65 6e 74 73 20 69 6e 20 74 68 69 73 20 66 69 6c ents in this fil
0480: 65 2e 20 20 54 68 69 73 20 66 69 6c 65 20 69 73 e. This file is
0490: 20 74 68 65 20 61 75 74 68 6f 72 69 74 61 74 69 the authoritati
04a0: 76 65 20 73 6f 75 72 63 65 0a 2a 2a 20 6f 6e 20 ve source.** on
04b0: 68 6f 77 20 53 51 4c 69 74 65 20 69 6e 74 65 72 how SQLite inter
04c0: 66 61 63 65 73 20 61 72 65 20 73 75 70 70 6f 73 faces are suppos
04d0: 65 64 20 74 6f 20 6f 70 65 72 61 74 65 2e 0a 2a ed to operate..*
04e0: 2a 0a 2a 2a 20 54 68 65 20 6e 61 6d 65 20 6f 66 *.** The name of
04f0: 20 74 68 69 73 20 66 69 6c 65 20 75 6e 64 65 72 this file under
0500: 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 6d configuration m
0510: 61 6e 61 67 65 6d 65 6e 74 20 69 73 20 22 73 71 anagement is "sq
0520: 6c 69 74 65 2e 68 2e 69 6e 22 2e 0a 2a 2a 20 54 lite.h.in"..** T
0530: 68 65 20 6d 61 6b 65 66 69 6c 65 20 6d 61 6b 65 he makefile make
0540: 73 20 73 6f 6d 65 20 6d 69 6e 6f 72 20 63 68 61 s some minor cha
0550: 6e 67 65 73 20 74 6f 20 74 68 69 73 20 66 69 6c nges to this fil
0560: 65 20 28 73 75 63 68 20 61 73 20 69 6e 73 65 72 e (such as inser
0570: 74 69 6e 67 0a 2a 2a 20 74 68 65 20 76 65 72 73 ting.** the vers
0580: 69 6f 6e 20 6e 75 6d 62 65 72 29 20 61 6e 64 20 ion number) and
0590: 63 68 61 6e 67 65 73 20 69 74 73 20 6e 61 6d 65 changes its name
05a0: 20 74 6f 20 22 73 71 6c 69 74 65 33 2e 68 22 20 to "sqlite3.h"
05b0: 61 73 0a 2a 2a 20 70 61 72 74 20 6f 66 20 74 68 as.** part of th
05c0: 65 20 62 75 69 6c 64 20 70 72 6f 63 65 73 73 2e e build process.
05d0: 0a 2a 2f 0a 23 69 66 6e 64 65 66 20 53 51 4c 49 .*/.#ifndef SQLI
05e0: 54 45 33 5f 48 0a 23 64 65 66 69 6e 65 20 53 51 TE3_H.#define SQ
05f0: 4c 49 54 45 33 5f 48 0a 23 69 6e 63 6c 75 64 65 LITE3_H.#include
0600: 20 3c 73 74 64 61 72 67 2e 68 3e 20 20 20 20 20 <stdarg.h>
0610: 2f 2a 20 4e 65 65 64 65 64 20 66 6f 72 20 74 68 /* Needed for th
0620: 65 20 64 65 66 69 6e 69 74 69 6f 6e 20 6f 66 20 e definition of
0630: 76 61 5f 6c 69 73 74 20 2a 2f 0a 0a 2f 2a 0a 2a va_list */../*.*
0640: 2a 20 4d 61 6b 65 20 73 75 72 65 20 77 65 20 63 * Make sure we c
0650: 61 6e 20 63 61 6c 6c 20 74 68 69 73 20 73 74 75 an call this stu
0660: 66 66 20 66 72 6f 6d 20 43 2b 2b 2e 0a 2a 2f 0a ff from C++..*/.
0670: 23 69 66 64 65 66 20 5f 5f 63 70 6c 75 73 70 6c #ifdef __cpluspl
0680: 75 73 0a 65 78 74 65 72 6e 20 22 43 22 20 7b 0a us.extern "C" {.
0690: 23 65 6e 64 69 66 0a 0a 0a 2f 2a 0a 2a 2a 20 50 #endif.../*.** P
06a0: 72 6f 76 69 64 65 20 74 68 65 20 61 62 69 6c 69 rovide the abili
06b0: 74 79 20 74 6f 20 6f 76 65 72 72 69 64 65 20 6c ty to override l
06c0: 69 6e 6b 61 67 65 20 66 65 61 74 75 72 65 73 20 inkage features
06d0: 6f 66 20 74 68 65 20 69 6e 74 65 72 66 61 63 65 of the interface
06e0: 2e 0a 2a 2f 0a 23 69 66 6e 64 65 66 20 53 51 4c ..*/.#ifndef SQL
06f0: 49 54 45 5f 45 58 54 45 52 4e 0a 23 20 64 65 66 ITE_EXTERN.# def
0700: 69 6e 65 20 53 51 4c 49 54 45 5f 45 58 54 45 52 ine SQLITE_EXTER
0710: 4e 20 65 78 74 65 72 6e 0a 23 65 6e 64 69 66 0a N extern.#endif.
0720: 23 69 66 6e 64 65 66 20 53 51 4c 49 54 45 5f 41 #ifndef SQLITE_A
0730: 50 49 0a 23 20 64 65 66 69 6e 65 20 53 51 4c 49 PI.# define SQLI
0740: 54 45 5f 41 50 49 0a 23 65 6e 64 69 66 0a 23 69 TE_API.#endif.#i
0750: 66 6e 64 65 66 20 53 51 4c 49 54 45 5f 43 44 45 fndef SQLITE_CDE
0760: 43 4c 0a 23 20 64 65 66 69 6e 65 20 53 51 4c 49 CL.# define SQLI
0770: 54 45 5f 43 44 45 43 4c 0a 23 65 6e 64 69 66 0a TE_CDECL.#endif.
0780: 23 69 66 6e 64 65 66 20 53 51 4c 49 54 45 5f 41 #ifndef SQLITE_A
0790: 50 49 43 41 4c 4c 0a 23 20 64 65 66 69 6e 65 20 PICALL.# define
07a0: 53 51 4c 49 54 45 5f 41 50 49 43 41 4c 4c 0a 23 SQLITE_APICALL.#
07b0: 65 6e 64 69 66 0a 23 69 66 6e 64 65 66 20 53 51 endif.#ifndef SQ
07c0: 4c 49 54 45 5f 53 54 44 43 41 4c 4c 0a 23 20 64 LITE_STDCALL.# d
07d0: 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 53 54 44 efine SQLITE_STD
07e0: 43 41 4c 4c 20 53 51 4c 49 54 45 5f 41 50 49 43 CALL SQLITE_APIC
07f0: 41 4c 4c 0a 23 65 6e 64 69 66 0a 23 69 66 6e 64 ALL.#endif.#ifnd
0800: 65 66 20 53 51 4c 49 54 45 5f 43 41 4c 4c 42 41 ef SQLITE_CALLBA
0810: 43 4b 0a 23 20 64 65 66 69 6e 65 20 53 51 4c 49 CK.# define SQLI
0820: 54 45 5f 43 41 4c 4c 42 41 43 4b 0a 23 65 6e 64 TE_CALLBACK.#end
0830: 69 66 0a 23 69 66 6e 64 65 66 20 53 51 4c 49 54 if.#ifndef SQLIT
0840: 45 5f 53 59 53 41 50 49 0a 23 20 64 65 66 69 6e E_SYSAPI.# defin
0850: 65 20 53 51 4c 49 54 45 5f 53 59 53 41 50 49 0a e SQLITE_SYSAPI.
0860: 23 65 6e 64 69 66 0a 0a 2f 2a 0a 2a 2a 20 54 68 #endif../*.** Th
0870: 65 73 65 20 6e 6f 2d 6f 70 20 6d 61 63 72 6f 73 ese no-op macros
0880: 20 61 72 65 20 75 73 65 64 20 69 6e 20 66 72 6f are used in fro
0890: 6e 74 20 6f 66 20 69 6e 74 65 72 66 61 63 65 73 nt of interfaces
08a0: 20 74 6f 20 6d 61 72 6b 20 74 68 6f 73 65 0a 2a to mark those.*
08b0: 2a 20 69 6e 74 65 72 66 61 63 65 73 20 61 73 20 * interfaces as
08c0: 65 69 74 68 65 72 20 64 65 70 72 65 63 61 74 65 either deprecate
08d0: 64 20 6f 72 20 65 78 70 65 72 69 6d 65 6e 74 61 d or experimenta
08e0: 6c 2e 20 20 4e 65 77 20 61 70 70 6c 69 63 61 74 l. New applicat
08f0: 69 6f 6e 73 0a 2a 2a 20 73 68 6f 75 6c 64 20 6e ions.** should n
0900: 6f 74 20 75 73 65 20 64 65 70 72 65 63 61 74 65 ot use deprecate
0910: 64 20 69 6e 74 65 72 66 61 63 65 73 20 2d 20 74 d interfaces - t
0920: 68 65 79 20 61 72 65 20 73 75 70 70 6f 72 74 65 hey are supporte
0930: 64 20 66 6f 72 20 62 61 63 6b 77 61 72 64 73 0a d for backwards.
0940: 2a 2a 20 63 6f 6d 70 61 74 69 62 69 6c 69 74 79 ** compatibility
0950: 20 6f 6e 6c 79 2e 20 20 41 70 70 6c 69 63 61 74 only. Applicat
0960: 69 6f 6e 20 77 72 69 74 65 72 73 20 73 68 6f 75 ion writers shou
0970: 6c 64 20 62 65 20 61 77 61 72 65 20 74 68 61 74 ld be aware that
0980: 0a 2a 2a 20 65 78 70 65 72 69 6d 65 6e 74 61 6c .** experimental
0990: 20 69 6e 74 65 72 66 61 63 65 73 20 61 72 65 20 interfaces are
09a0: 73 75 62 6a 65 63 74 20 74 6f 20 63 68 61 6e 67 subject to chang
09b0: 65 20 69 6e 20 70 6f 69 6e 74 20 72 65 6c 65 61 e in point relea
09c0: 73 65 73 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 73 65 ses..**.** These
09d0: 20 6d 61 63 72 6f 73 20 75 73 65 64 20 74 6f 20 macros used to
09e0: 72 65 73 6f 6c 76 65 20 74 6f 20 76 61 72 69 6f resolve to vario
09f0: 75 73 20 6b 69 6e 64 73 20 6f 66 20 63 6f 6d 70 us kinds of comp
0a00: 69 6c 65 72 20 6d 61 67 69 63 20 74 68 61 74 0a iler magic that.
0a10: 2a 2a 20 77 6f 75 6c 64 20 67 65 6e 65 72 61 74 ** would generat
0a20: 65 20 77 61 72 6e 69 6e 67 20 6d 65 73 73 61 67 e warning messag
0a30: 65 73 20 77 68 65 6e 20 74 68 65 79 20 77 65 72 es when they wer
0a40: 65 20 75 73 65 64 2e 20 20 42 75 74 20 74 68 61 e used. But tha
0a50: 74 0a 2a 2a 20 63 6f 6d 70 69 6c 65 72 20 6d 61 t.** compiler ma
0a60: 67 69 63 20 65 6e 64 65 64 20 75 70 20 67 65 6e gic ended up gen
0a70: 65 72 61 74 69 6e 67 20 73 75 63 68 20 61 20 66 erating such a f
0a80: 6c 75 72 72 79 20 6f 66 20 62 75 67 20 72 65 70 lurry of bug rep
0a90: 6f 72 74 73 0a 2a 2a 20 74 68 61 74 20 77 65 20 orts.** that we
0aa0: 68 61 76 65 20 74 61 6b 65 6e 20 69 74 20 61 6c have taken it al
0ab0: 6c 20 6f 75 74 20 61 6e 64 20 67 6f 6e 65 20 62 l out and gone b
0ac0: 61 63 6b 20 74 6f 20 75 73 69 6e 67 20 73 69 6d ack to using sim
0ad0: 70 6c 65 0a 2a 2a 20 6e 6f 6f 70 20 6d 61 63 72 ple.** noop macr
0ae0: 6f 73 2e 0a 2a 2f 0a 23 64 65 66 69 6e 65 20 53 os..*/.#define S
0af0: 51 4c 49 54 45 5f 44 45 50 52 45 43 41 54 45 44 QLITE_DEPRECATED
0b00: 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f .#define SQLITE_
0b10: 45 58 50 45 52 49 4d 45 4e 54 41 4c 0a 0a 2f 2a EXPERIMENTAL../*
0b20: 0a 2a 2a 20 45 6e 73 75 72 65 20 74 68 65 73 65 .** Ensure these
0b30: 20 73 79 6d 62 6f 6c 73 20 77 65 72 65 20 6e 6f symbols were no
0b40: 74 20 64 65 66 69 6e 65 64 20 62 79 20 73 6f 6d t defined by som
0b50: 65 20 70 72 65 76 69 6f 75 73 20 68 65 61 64 65 e previous heade
0b60: 72 20 66 69 6c 65 2e 0a 2a 2f 0a 23 69 66 64 65 r file..*/.#ifde
0b70: 66 20 53 51 4c 49 54 45 5f 56 45 52 53 49 4f 4e f SQLITE_VERSION
0b80: 0a 23 20 75 6e 64 65 66 20 53 51 4c 49 54 45 5f .# undef SQLITE_
0b90: 56 45 52 53 49 4f 4e 0a 23 65 6e 64 69 66 0a 23 VERSION.#endif.#
0ba0: 69 66 64 65 66 20 53 51 4c 49 54 45 5f 56 45 52 ifdef SQLITE_VER
0bb0: 53 49 4f 4e 5f 4e 55 4d 42 45 52 0a 23 20 75 6e SION_NUMBER.# un
0bc0: 64 65 66 20 53 51 4c 49 54 45 5f 56 45 52 53 49 def SQLITE_VERSI
0bd0: 4f 4e 5f 4e 55 4d 42 45 52 0a 23 65 6e 64 69 66 ON_NUMBER.#endif
0be0: 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 ../*.** CAPI3REF
0bf0: 3a 20 43 6f 6d 70 69 6c 65 2d 54 69 6d 65 20 4c : Compile-Time L
0c00: 69 62 72 61 72 79 20 56 65 72 73 69 6f 6e 20 4e ibrary Version N
0c10: 75 6d 62 65 72 73 0a 2a 2a 0a 2a 2a 20 5e 28 54 umbers.**.** ^(T
0c20: 68 65 20 5b 53 51 4c 49 54 45 5f 56 45 52 53 49 he [SQLITE_VERSI
0c30: 4f 4e 5d 20 43 20 70 72 65 70 72 6f 63 65 73 73 ON] C preprocess
0c40: 6f 72 20 6d 61 63 72 6f 20 69 6e 20 74 68 65 20 or macro in the
0c50: 73 71 6c 69 74 65 33 2e 68 20 68 65 61 64 65 72 sqlite3.h header
0c60: 0a 2a 2a 20 65 76 61 6c 75 61 74 65 73 20 74 6f .** evaluates to
0c70: 20 61 20 73 74 72 69 6e 67 20 6c 69 74 65 72 61 a string litera
0c80: 6c 20 74 68 61 74 20 69 73 20 74 68 65 20 53 51 l that is the SQ
0c90: 4c 69 74 65 20 76 65 72 73 69 6f 6e 20 69 6e 20 Lite version in
0ca0: 74 68 65 0a 2a 2a 20 66 6f 72 6d 61 74 20 22 58 the.** format "X
0cb0: 2e 59 2e 5a 22 20 77 68 65 72 65 20 58 20 69 73 .Y.Z" where X is
0cc0: 20 74 68 65 20 6d 61 6a 6f 72 20 76 65 72 73 69 the major versi
0cd0: 6f 6e 20 6e 75 6d 62 65 72 20 28 61 6c 77 61 79 on number (alway
0ce0: 73 20 33 20 66 6f 72 0a 2a 2a 20 53 51 4c 69 74 s 3 for.** SQLit
0cf0: 65 33 29 20 61 6e 64 20 59 20 69 73 20 74 68 65 e3) and Y is the
0d00: 20 6d 69 6e 6f 72 20 76 65 72 73 69 6f 6e 20 6e minor version n
0d10: 75 6d 62 65 72 20 61 6e 64 20 5a 20 69 73 20 74 umber and Z is t
0d20: 68 65 20 72 65 6c 65 61 73 65 20 6e 75 6d 62 65 he release numbe
0d30: 72 2e 29 5e 0a 2a 2a 20 5e 28 54 68 65 20 5b 53 r.)^.** ^(The [S
0d40: 51 4c 49 54 45 5f 56 45 52 53 49 4f 4e 5f 4e 55 QLITE_VERSION_NU
0d50: 4d 42 45 52 5d 20 43 20 70 72 65 70 72 6f 63 65 MBER] C preproce
0d60: 73 73 6f 72 20 6d 61 63 72 6f 20 72 65 73 6f 6c ssor macro resol
0d70: 76 65 73 20 74 6f 20 61 6e 20 69 6e 74 65 67 65 ves to an intege
0d80: 72 0a 2a 2a 20 77 69 74 68 20 74 68 65 20 76 61 r.** with the va
0d90: 6c 75 65 20 28 58 2a 31 30 30 30 30 30 30 20 2b lue (X*1000000 +
0da0: 20 59 2a 31 30 30 30 20 2b 20 5a 29 20 77 68 65 Y*1000 + Z) whe
0db0: 72 65 20 58 2c 20 59 2c 20 61 6e 64 20 5a 20 61 re X, Y, and Z a
0dc0: 72 65 20 74 68 65 20 73 61 6d 65 0a 2a 2a 20 6e re the same.** n
0dd0: 75 6d 62 65 72 73 20 75 73 65 64 20 69 6e 20 5b umbers used in [
0de0: 53 51 4c 49 54 45 5f 56 45 52 53 49 4f 4e 5d 2e SQLITE_VERSION].
0df0: 29 5e 0a 2a 2a 20 54 68 65 20 53 51 4c 49 54 45 )^.** The SQLITE
0e00: 5f 56 45 52 53 49 4f 4e 5f 4e 55 4d 42 45 52 20 _VERSION_NUMBER
0e10: 66 6f 72 20 61 6e 79 20 67 69 76 65 6e 20 72 65 for any given re
0e20: 6c 65 61 73 65 20 6f 66 20 53 51 4c 69 74 65 20 lease of SQLite
0e30: 77 69 6c 6c 20 61 6c 73 6f 0a 2a 2a 20 62 65 20 will also.** be
0e40: 6c 61 72 67 65 72 20 74 68 61 6e 20 74 68 65 20 larger than the
0e50: 72 65 6c 65 61 73 65 20 66 72 6f 6d 20 77 68 69 release from whi
0e60: 63 68 20 69 74 20 69 73 20 64 65 72 69 76 65 64 ch it is derived
0e70: 2e 20 20 45 69 74 68 65 72 20 59 20 77 69 6c 6c . Either Y will
0e80: 0a 2a 2a 20 62 65 20 68 65 6c 64 20 63 6f 6e 73 .** be held cons
0e90: 74 61 6e 74 20 61 6e 64 20 5a 20 77 69 6c 6c 20 tant and Z will
0ea0: 62 65 20 69 6e 63 72 65 6d 65 6e 74 65 64 20 6f be incremented o
0eb0: 72 20 65 6c 73 65 20 59 20 77 69 6c 6c 20 62 65 r else Y will be
0ec0: 20 69 6e 63 72 65 6d 65 6e 74 65 64 0a 2a 2a 20 incremented.**
0ed0: 61 6e 64 20 5a 20 77 69 6c 6c 20 62 65 20 72 65 and Z will be re
0ee0: 73 65 74 20 74 6f 20 7a 65 72 6f 2e 0a 2a 2a 0a set to zero..**.
0ef0: 2a 2a 20 53 69 6e 63 65 20 5b 76 65 72 73 69 6f ** Since [versio
0f00: 6e 20 33 2e 36 2e 31 38 5d 20 28 5b 64 61 74 65 n 3.6.18] ([date
0f10: 6f 66 3a 33 2e 36 2e 31 38 5d 29 2c 20 0a 2a 2a of:3.6.18]), .**
0f20: 20 53 51 4c 69 74 65 20 73 6f 75 72 63 65 20 63 SQLite source c
0f30: 6f 64 65 20 68 61 73 20 62 65 65 6e 20 73 74 6f ode has been sto
0f40: 72 65 64 20 69 6e 20 74 68 65 0a 2a 2a 20 3c 61 red in the.** <a
0f50: 20 68 72 65 66 3d 22 68 74 74 70 3a 2f 2f 77 77 href="http://ww
0f60: 77 2e 66 6f 73 73 69 6c 2d 73 63 6d 2e 6f 72 67 w.fossil-scm.org
0f70: 2f 22 3e 46 6f 73 73 69 6c 20 63 6f 6e 66 69 67 /">Fossil config
0f80: 75 72 61 74 69 6f 6e 20 6d 61 6e 61 67 65 6d 65 uration manageme
0f90: 6e 74 0a 2a 2a 20 73 79 73 74 65 6d 3c 2f 61 3e nt.** system</a>
0fa0: 2e 20 20 5e 54 68 65 20 53 51 4c 49 54 45 5f 53 . ^The SQLITE_S
0fb0: 4f 55 52 43 45 5f 49 44 20 6d 61 63 72 6f 20 65 OURCE_ID macro e
0fc0: 76 61 6c 75 61 74 65 73 20 74 6f 0a 2a 2a 20 61 valuates to.** a
0fd0: 20 73 74 72 69 6e 67 20 77 68 69 63 68 20 69 64 string which id
0fe0: 65 6e 74 69 66 69 65 73 20 61 20 70 61 72 74 69 entifies a parti
0ff0: 63 75 6c 61 72 20 63 68 65 63 6b 2d 69 6e 20 6f cular check-in o
1000: 66 20 53 51 4c 69 74 65 0a 2a 2a 20 77 69 74 68 f SQLite.** with
1010: 69 6e 20 69 74 73 20 63 6f 6e 66 69 67 75 72 61 in its configura
1020: 74 69 6f 6e 20 6d 61 6e 61 67 65 6d 65 6e 74 20 tion management
1030: 73 79 73 74 65 6d 2e 20 20 5e 54 68 65 20 53 51 system. ^The SQ
1040: 4c 49 54 45 5f 53 4f 55 52 43 45 5f 49 44 0a 2a LITE_SOURCE_ID.*
1050: 2a 20 73 74 72 69 6e 67 20 63 6f 6e 74 61 69 6e * string contain
1060: 73 20 74 68 65 20 64 61 74 65 20 61 6e 64 20 74 s the date and t
1070: 69 6d 65 20 6f 66 20 74 68 65 20 63 68 65 63 6b ime of the check
1080: 2d 69 6e 20 28 55 54 43 29 20 61 6e 64 20 61 6e -in (UTC) and an
1090: 20 53 48 41 31 0a 2a 2a 20 68 61 73 68 20 6f 66 SHA1.** hash of
10a0: 20 74 68 65 20 65 6e 74 69 72 65 20 73 6f 75 72 the entire sour
10b0: 63 65 20 74 72 65 65 2e 0a 2a 2a 0a 2a 2a 20 53 ce tree..**.** S
10c0: 65 65 20 61 6c 73 6f 3a 20 5b 73 71 6c 69 74 65 ee also: [sqlite
10d0: 33 5f 6c 69 62 76 65 72 73 69 6f 6e 28 29 5d 2c 3_libversion()],
10e0: 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 6c 69 62 .** [sqlite3_lib
10f0: 76 65 72 73 69 6f 6e 5f 6e 75 6d 62 65 72 28 29 version_number()
1100: 5d 2c 20 5b 73 71 6c 69 74 65 33 5f 73 6f 75 72 ], [sqlite3_sour
1110: 63 65 69 64 28 29 5d 2c 0a 2a 2a 20 5b 73 71 6c ceid()],.** [sql
1120: 69 74 65 5f 76 65 72 73 69 6f 6e 28 29 5d 20 61 ite_version()] a
1130: 6e 64 20 5b 73 71 6c 69 74 65 5f 73 6f 75 72 63 nd [sqlite_sourc
1140: 65 5f 69 64 28 29 5d 2e 0a 2a 2f 0a 23 64 65 66 e_id()]..*/.#def
1150: 69 6e 65 20 53 51 4c 49 54 45 5f 56 45 52 53 49 ine SQLITE_VERSI
1160: 4f 4e 20 20 20 20 20 20 20 20 22 2d 2d 56 45 52 ON "--VER
1170: 53 2d 2d 22 0a 23 64 65 66 69 6e 65 20 53 51 4c S--".#define SQL
1180: 49 54 45 5f 56 45 52 53 49 4f 4e 5f 4e 55 4d 42 ITE_VERSION_NUMB
1190: 45 52 20 2d 2d 56 45 52 53 49 4f 4e 2d 4e 55 4d ER --VERSION-NUM
11a0: 42 45 52 2d 2d 0a 23 64 65 66 69 6e 65 20 53 51 BER--.#define SQ
11b0: 4c 49 54 45 5f 53 4f 55 52 43 45 5f 49 44 20 20 LITE_SOURCE_ID
11c0: 20 20 20 20 22 2d 2d 53 4f 55 52 43 45 2d 49 44 "--SOURCE-ID
11d0: 2d 2d 22 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 --"../*.** CAPI3
11e0: 52 45 46 3a 20 52 75 6e 2d 54 69 6d 65 20 4c 69 REF: Run-Time Li
11f0: 62 72 61 72 79 20 56 65 72 73 69 6f 6e 20 4e 75 brary Version Nu
1200: 6d 62 65 72 73 0a 2a 2a 20 4b 45 59 57 4f 52 44 mbers.** KEYWORD
1210: 53 3a 20 73 71 6c 69 74 65 33 5f 76 65 72 73 69 S: sqlite3_versi
1220: 6f 6e 20 73 71 6c 69 74 65 33 5f 73 6f 75 72 63 on sqlite3_sourc
1230: 65 69 64 0a 2a 2a 0a 2a 2a 20 54 68 65 73 65 20 eid.**.** These
1240: 69 6e 74 65 72 66 61 63 65 73 20 70 72 6f 76 69 interfaces provi
1250: 64 65 20 74 68 65 20 73 61 6d 65 20 69 6e 66 6f de the same info
1260: 72 6d 61 74 69 6f 6e 20 61 73 20 74 68 65 20 5b rmation as the [
1270: 53 51 4c 49 54 45 5f 56 45 52 53 49 4f 4e 5d 2c SQLITE_VERSION],
1280: 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f 56 45 52 53 .** [SQLITE_VERS
1290: 49 4f 4e 5f 4e 55 4d 42 45 52 5d 2c 20 61 6e 64 ION_NUMBER], and
12a0: 20 5b 53 51 4c 49 54 45 5f 53 4f 55 52 43 45 5f [SQLITE_SOURCE_
12b0: 49 44 5d 20 43 20 70 72 65 70 72 6f 63 65 73 73 ID] C preprocess
12c0: 6f 72 20 6d 61 63 72 6f 73 0a 2a 2a 20 62 75 74 or macros.** but
12d0: 20 61 72 65 20 61 73 73 6f 63 69 61 74 65 64 20 are associated
12e0: 77 69 74 68 20 74 68 65 20 6c 69 62 72 61 72 79 with the library
12f0: 20 69 6e 73 74 65 61 64 20 6f 66 20 74 68 65 20 instead of the
1300: 68 65 61 64 65 72 20 66 69 6c 65 2e 20 20 5e 28 header file. ^(
1310: 43 61 75 74 69 6f 75 73 0a 2a 2a 20 70 72 6f 67 Cautious.** prog
1320: 72 61 6d 6d 65 72 73 20 6d 69 67 68 74 20 69 6e rammers might in
1330: 63 6c 75 64 65 20 61 73 73 65 72 74 28 29 20 73 clude assert() s
1340: 74 61 74 65 6d 65 6e 74 73 20 69 6e 20 74 68 65 tatements in the
1350: 69 72 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 74 ir application t
1360: 6f 0a 2a 2a 20 76 65 72 69 66 79 20 74 68 61 74 o.** verify that
1370: 20 76 61 6c 75 65 73 20 72 65 74 75 72 6e 65 64 values returned
1380: 20 62 79 20 74 68 65 73 65 20 69 6e 74 65 72 66 by these interf
1390: 61 63 65 73 20 6d 61 74 63 68 20 74 68 65 20 6d aces match the m
13a0: 61 63 72 6f 73 20 69 6e 0a 2a 2a 20 74 68 65 20 acros in.** the
13b0: 68 65 61 64 65 72 2c 20 61 6e 64 20 74 68 75 73 header, and thus
13c0: 20 65 6e 73 75 72 65 20 74 68 61 74 20 74 68 65 ensure that the
13d0: 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 69 73 0a application is.
13e0: 2a 2a 20 63 6f 6d 70 69 6c 65 64 20 77 69 74 68 ** compiled with
13f0: 20 6d 61 74 63 68 69 6e 67 20 6c 69 62 72 61 72 matching librar
1400: 79 20 61 6e 64 20 68 65 61 64 65 72 20 66 69 6c y and header fil
1410: 65 73 2e 0a 2a 2a 0a 2a 2a 20 3c 62 6c 6f 63 6b es..**.** <block
1420: 71 75 6f 74 65 3e 3c 70 72 65 3e 0a 2a 2a 20 61 quote><pre>.** a
1430: 73 73 65 72 74 28 20 73 71 6c 69 74 65 33 5f 6c ssert( sqlite3_l
1440: 69 62 76 65 72 73 69 6f 6e 5f 6e 75 6d 62 65 72 ibversion_number
1450: 28 29 3d 3d 53 51 4c 49 54 45 5f 56 45 52 53 49 ()==SQLITE_VERSI
1460: 4f 4e 5f 4e 55 4d 42 45 52 20 29 3b 0a 2a 2a 20 ON_NUMBER );.**
1470: 61 73 73 65 72 74 28 20 73 74 72 63 6d 70 28 73 assert( strcmp(s
1480: 71 6c 69 74 65 33 5f 73 6f 75 72 63 65 69 64 28 qlite3_sourceid(
1490: 29 2c 53 51 4c 49 54 45 5f 53 4f 55 52 43 45 5f ),SQLITE_SOURCE_
14a0: 49 44 29 3d 3d 30 20 29 3b 0a 2a 2a 20 61 73 73 ID)==0 );.** ass
14b0: 65 72 74 28 20 73 74 72 63 6d 70 28 73 71 6c 69 ert( strcmp(sqli
14c0: 74 65 33 5f 6c 69 62 76 65 72 73 69 6f 6e 28 29 te3_libversion()
14d0: 2c 53 51 4c 49 54 45 5f 56 45 52 53 49 4f 4e 29 ,SQLITE_VERSION)
14e0: 3d 3d 30 20 29 3b 0a 2a 2a 20 3c 2f 70 72 65 3e ==0 );.** </pre>
14f0: 3c 2f 62 6c 6f 63 6b 71 75 6f 74 65 3e 29 5e 0a </blockquote>)^.
1500: 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 6c 69 74 **.** ^The sqlit
1510: 65 33 5f 76 65 72 73 69 6f 6e 5b 5d 20 73 74 72 e3_version[] str
1520: 69 6e 67 20 63 6f 6e 73 74 61 6e 74 20 63 6f 6e ing constant con
1530: 74 61 69 6e 73 20 74 68 65 20 74 65 78 74 20 6f tains the text o
1540: 66 20 5b 53 51 4c 49 54 45 5f 56 45 52 53 49 4f f [SQLITE_VERSIO
1550: 4e 5d 0a 2a 2a 20 6d 61 63 72 6f 2e 20 20 5e 54 N].** macro. ^T
1560: 68 65 20 73 71 6c 69 74 65 33 5f 6c 69 62 76 65 he sqlite3_libve
1570: 72 73 69 6f 6e 28 29 20 66 75 6e 63 74 69 6f 6e rsion() function
1580: 20 72 65 74 75 72 6e 73 20 61 20 70 6f 69 6e 74 returns a point
1590: 65 72 20 74 6f 20 74 68 65 0a 2a 2a 20 74 6f 20 er to the.** to
15a0: 74 68 65 20 73 71 6c 69 74 65 33 5f 76 65 72 73 the sqlite3_vers
15b0: 69 6f 6e 5b 5d 20 73 74 72 69 6e 67 20 63 6f 6e ion[] string con
15c0: 73 74 61 6e 74 2e 20 20 54 68 65 20 73 71 6c 69 stant. The sqli
15d0: 74 65 33 5f 6c 69 62 76 65 72 73 69 6f 6e 28 29 te3_libversion()
15e0: 0a 2a 2a 20 66 75 6e 63 74 69 6f 6e 20 69 73 20 .** function is
15f0: 70 72 6f 76 69 64 65 64 20 66 6f 72 20 75 73 65 provided for use
1600: 20 69 6e 20 44 4c 4c 73 20 73 69 6e 63 65 20 44 in DLLs since D
1610: 4c 4c 20 75 73 65 72 73 20 75 73 75 61 6c 6c 79 LL users usually
1620: 20 64 6f 20 6e 6f 74 20 68 61 76 65 0a 2a 2a 20 do not have.**
1630: 64 69 72 65 63 74 20 61 63 63 65 73 73 20 74 6f direct access to
1640: 20 73 74 72 69 6e 67 20 63 6f 6e 73 74 61 6e 74 string constant
1650: 73 20 77 69 74 68 69 6e 20 74 68 65 20 44 4c 4c s within the DLL
1660: 2e 20 20 5e 54 68 65 0a 2a 2a 20 73 71 6c 69 74 . ^The.** sqlit
1670: 65 33 5f 6c 69 62 76 65 72 73 69 6f 6e 5f 6e 75 e3_libversion_nu
1680: 6d 62 65 72 28 29 20 66 75 6e 63 74 69 6f 6e 20 mber() function
1690: 72 65 74 75 72 6e 73 20 61 6e 20 69 6e 74 65 67 returns an integ
16a0: 65 72 20 65 71 75 61 6c 20 74 6f 0a 2a 2a 20 5b er equal to.** [
16b0: 53 51 4c 49 54 45 5f 56 45 52 53 49 4f 4e 5f 4e SQLITE_VERSION_N
16c0: 55 4d 42 45 52 5d 2e 20 20 5e 54 68 65 20 73 71 UMBER]. ^The sq
16d0: 6c 69 74 65 33 5f 73 6f 75 72 63 65 69 64 28 29 lite3_sourceid()
16e0: 20 66 75 6e 63 74 69 6f 6e 20 72 65 74 75 72 6e function return
16f0: 73 20 0a 2a 2a 20 61 20 70 6f 69 6e 74 65 72 20 s .** a pointer
1700: 74 6f 20 61 20 73 74 72 69 6e 67 20 63 6f 6e 73 to a string cons
1710: 74 61 6e 74 20 77 68 6f 73 65 20 76 61 6c 75 65 tant whose value
1720: 20 69 73 20 74 68 65 20 73 61 6d 65 20 61 73 20 is the same as
1730: 74 68 65 20 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f the .** [SQLITE_
1740: 53 4f 55 52 43 45 5f 49 44 5d 20 43 20 70 72 65 SOURCE_ID] C pre
1750: 70 72 6f 63 65 73 73 6f 72 20 6d 61 63 72 6f 2e processor macro.
1760: 0a 2a 2a 0a 2a 2a 20 53 65 65 20 61 6c 73 6f 3a .**.** See also:
1770: 20 5b 73 71 6c 69 74 65 5f 76 65 72 73 69 6f 6e [sqlite_version
1780: 28 29 5d 20 61 6e 64 20 5b 73 71 6c 69 74 65 5f ()] and [sqlite_
1790: 73 6f 75 72 63 65 5f 69 64 28 29 5d 2e 0a 2a 2f source_id()]..*/
17a0: 0a 53 51 4c 49 54 45 5f 45 58 54 45 52 4e 20 63 .SQLITE_EXTERN c
17b0: 6f 6e 73 74 20 63 68 61 72 20 73 71 6c 69 74 65 onst char sqlite
17c0: 33 5f 76 65 72 73 69 6f 6e 5b 5d 3b 0a 63 6f 6e 3_version[];.con
17d0: 73 74 20 63 68 61 72 20 2a 73 71 6c 69 74 65 33 st char *sqlite3
17e0: 5f 6c 69 62 76 65 72 73 69 6f 6e 28 76 6f 69 64 _libversion(void
17f0: 29 3b 0a 63 6f 6e 73 74 20 63 68 61 72 20 2a 73 );.const char *s
1800: 71 6c 69 74 65 33 5f 73 6f 75 72 63 65 69 64 28 qlite3_sourceid(
1810: 76 6f 69 64 29 3b 0a 69 6e 74 20 73 71 6c 69 74 void);.int sqlit
1820: 65 33 5f 6c 69 62 76 65 72 73 69 6f 6e 5f 6e 75 e3_libversion_nu
1830: 6d 62 65 72 28 76 6f 69 64 29 3b 0a 0a 2f 2a 0a mber(void);../*.
1840: 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 52 75 6e ** CAPI3REF: Run
1850: 2d 54 69 6d 65 20 4c 69 62 72 61 72 79 20 43 6f -Time Library Co
1860: 6d 70 69 6c 61 74 69 6f 6e 20 4f 70 74 69 6f 6e mpilation Option
1870: 73 20 44 69 61 67 6e 6f 73 74 69 63 73 0a 2a 2a s Diagnostics.**
1880: 0a 2a 2a 20 5e 54 68 65 20 73 71 6c 69 74 65 33 .** ^The sqlite3
1890: 5f 63 6f 6d 70 69 6c 65 6f 70 74 69 6f 6e 5f 75 _compileoption_u
18a0: 73 65 64 28 29 20 66 75 6e 63 74 69 6f 6e 20 72 sed() function r
18b0: 65 74 75 72 6e 73 20 30 20 6f 72 20 31 20 0a 2a eturns 0 or 1 .*
18c0: 2a 20 69 6e 64 69 63 61 74 69 6e 67 20 77 68 65 * indicating whe
18d0: 74 68 65 72 20 74 68 65 20 73 70 65 63 69 66 69 ther the specifi
18e0: 65 64 20 6f 70 74 69 6f 6e 20 77 61 73 20 64 65 ed option was de
18f0: 66 69 6e 65 64 20 61 74 20 0a 2a 2a 20 63 6f 6d fined at .** com
1900: 70 69 6c 65 20 74 69 6d 65 2e 20 20 5e 54 68 65 pile time. ^The
1910: 20 53 51 4c 49 54 45 5f 20 70 72 65 66 69 78 20 SQLITE_ prefix
1920: 6d 61 79 20 62 65 20 6f 6d 69 74 74 65 64 20 66 may be omitted f
1930: 72 6f 6d 20 74 68 65 20 0a 2a 2a 20 6f 70 74 69 rom the .** opti
1940: 6f 6e 20 6e 61 6d 65 20 70 61 73 73 65 64 20 74 on name passed t
1950: 6f 20 73 71 6c 69 74 65 33 5f 63 6f 6d 70 69 6c o sqlite3_compil
1960: 65 6f 70 74 69 6f 6e 5f 75 73 65 64 28 29 2e 20 eoption_used().
1970: 20 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 6c .**.** ^The sql
1980: 69 74 65 33 5f 63 6f 6d 70 69 6c 65 6f 70 74 69 ite3_compileopti
1990: 6f 6e 5f 67 65 74 28 29 20 66 75 6e 63 74 69 6f on_get() functio
19a0: 6e 20 61 6c 6c 6f 77 73 20 69 74 65 72 61 74 69 n allows iterati
19b0: 6e 67 0a 2a 2a 20 6f 76 65 72 20 74 68 65 20 6c ng.** over the l
19c0: 69 73 74 20 6f 66 20 6f 70 74 69 6f 6e 73 20 74 ist of options t
19d0: 68 61 74 20 77 65 72 65 20 64 65 66 69 6e 65 64 hat were defined
19e0: 20 61 74 20 63 6f 6d 70 69 6c 65 20 74 69 6d 65 at compile time
19f0: 20 62 79 0a 2a 2a 20 72 65 74 75 72 6e 69 6e 67 by.** returning
1a00: 20 74 68 65 20 4e 2d 74 68 20 63 6f 6d 70 69 6c the N-th compil
1a10: 65 20 74 69 6d 65 20 6f 70 74 69 6f 6e 20 73 74 e time option st
1a20: 72 69 6e 67 2e 20 20 5e 49 66 20 4e 20 69 73 20 ring. ^If N is
1a30: 6f 75 74 20 6f 66 20 72 61 6e 67 65 2c 0a 2a 2a out of range,.**
1a40: 20 73 71 6c 69 74 65 33 5f 63 6f 6d 70 69 6c 65 sqlite3_compile
1a50: 6f 70 74 69 6f 6e 5f 67 65 74 28 29 20 72 65 74 option_get() ret
1a60: 75 72 6e 73 20 61 20 4e 55 4c 4c 20 70 6f 69 6e urns a NULL poin
1a70: 74 65 72 2e 20 20 5e 54 68 65 20 53 51 4c 49 54 ter. ^The SQLIT
1a80: 45 5f 20 0a 2a 2a 20 70 72 65 66 69 78 20 69 73 E_ .** prefix is
1a90: 20 6f 6d 69 74 74 65 64 20 66 72 6f 6d 20 61 6e omitted from an
1aa0: 79 20 73 74 72 69 6e 67 73 20 72 65 74 75 72 6e y strings return
1ab0: 65 64 20 62 79 20 0a 2a 2a 20 73 71 6c 69 74 65 ed by .** sqlite
1ac0: 33 5f 63 6f 6d 70 69 6c 65 6f 70 74 69 6f 6e 5f 3_compileoption_
1ad0: 67 65 74 28 29 2e 0a 2a 2a 0a 2a 2a 20 5e 53 75 get()..**.** ^Su
1ae0: 70 70 6f 72 74 20 66 6f 72 20 74 68 65 20 64 69 pport for the di
1af0: 61 67 6e 6f 73 74 69 63 20 66 75 6e 63 74 69 6f agnostic functio
1b00: 6e 73 20 73 71 6c 69 74 65 33 5f 63 6f 6d 70 69 ns sqlite3_compi
1b10: 6c 65 6f 70 74 69 6f 6e 5f 75 73 65 64 28 29 0a leoption_used().
1b20: 2a 2a 20 61 6e 64 20 73 71 6c 69 74 65 33 5f 63 ** and sqlite3_c
1b30: 6f 6d 70 69 6c 65 6f 70 74 69 6f 6e 5f 67 65 74 ompileoption_get
1b40: 28 29 20 6d 61 79 20 62 65 20 6f 6d 69 74 74 65 () may be omitte
1b50: 64 20 62 79 20 73 70 65 63 69 66 79 69 6e 67 20 d by specifying
1b60: 74 68 65 20 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f the .** [SQLITE_
1b70: 4f 4d 49 54 5f 43 4f 4d 50 49 4c 45 4f 50 54 49 OMIT_COMPILEOPTI
1b80: 4f 4e 5f 44 49 41 47 53 5d 20 6f 70 74 69 6f 6e ON_DIAGS] option
1b90: 20 61 74 20 63 6f 6d 70 69 6c 65 20 74 69 6d 65 at compile time
1ba0: 2e 0a 2a 2a 0a 2a 2a 20 53 65 65 20 61 6c 73 6f ..**.** See also
1bb0: 3a 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 : SQL functions
1bc0: 5b 73 71 6c 69 74 65 5f 63 6f 6d 70 69 6c 65 6f [sqlite_compileo
1bd0: 70 74 69 6f 6e 5f 75 73 65 64 28 29 5d 20 61 6e ption_used()] an
1be0: 64 0a 2a 2a 20 5b 73 71 6c 69 74 65 5f 63 6f 6d d.** [sqlite_com
1bf0: 70 69 6c 65 6f 70 74 69 6f 6e 5f 67 65 74 28 29 pileoption_get()
1c00: 5d 20 61 6e 64 20 74 68 65 20 5b 63 6f 6d 70 69 ] and the [compi
1c10: 6c 65 5f 6f 70 74 69 6f 6e 73 20 70 72 61 67 6d le_options pragm
1c20: 61 5d 2e 0a 2a 2f 0a 23 69 66 6e 64 65 66 20 53 a]..*/.#ifndef S
1c30: 51 4c 49 54 45 5f 4f 4d 49 54 5f 43 4f 4d 50 49 QLITE_OMIT_COMPI
1c40: 4c 45 4f 50 54 49 4f 4e 5f 44 49 41 47 53 0a 69 LEOPTION_DIAGS.i
1c50: 6e 74 20 73 71 6c 69 74 65 33 5f 63 6f 6d 70 69 nt sqlite3_compi
1c60: 6c 65 6f 70 74 69 6f 6e 5f 75 73 65 64 28 63 6f leoption_used(co
1c70: 6e 73 74 20 63 68 61 72 20 2a 7a 4f 70 74 4e 61 nst char *zOptNa
1c80: 6d 65 29 3b 0a 63 6f 6e 73 74 20 63 68 61 72 20 me);.const char
1c90: 2a 73 71 6c 69 74 65 33 5f 63 6f 6d 70 69 6c 65 *sqlite3_compile
1ca0: 6f 70 74 69 6f 6e 5f 67 65 74 28 69 6e 74 20 4e option_get(int N
1cb0: 29 3b 0a 23 65 6e 64 69 66 0a 0a 2f 2a 0a 2a 2a );.#endif../*.**
1cc0: 20 43 41 50 49 33 52 45 46 3a 20 54 65 73 74 20 CAPI3REF: Test
1cd0: 54 6f 20 53 65 65 20 49 66 20 54 68 65 20 4c 69 To See If The Li
1ce0: 62 72 61 72 79 20 49 73 20 54 68 72 65 61 64 73 brary Is Threads
1cf0: 61 66 65 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 afe.**.** ^The s
1d00: 71 6c 69 74 65 33 5f 74 68 72 65 61 64 73 61 66 qlite3_threadsaf
1d10: 65 28 29 20 66 75 6e 63 74 69 6f 6e 20 72 65 74 e() function ret
1d20: 75 72 6e 73 20 7a 65 72 6f 20 69 66 20 61 6e 64 urns zero if and
1d30: 20 6f 6e 6c 79 20 69 66 0a 2a 2a 20 53 51 4c 69 only if.** SQLi
1d40: 74 65 20 77 61 73 20 63 6f 6d 70 69 6c 65 64 20 te was compiled
1d50: 77 69 74 68 20 6d 75 74 65 78 69 6e 67 20 63 6f with mutexing co
1d60: 64 65 20 6f 6d 69 74 74 65 64 20 64 75 65 20 74 de omitted due t
1d70: 6f 20 74 68 65 0a 2a 2a 20 5b 53 51 4c 49 54 45 o the.** [SQLITE
1d80: 5f 54 48 52 45 41 44 53 41 46 45 5d 20 63 6f 6d _THREADSAFE] com
1d90: 70 69 6c 65 2d 74 69 6d 65 20 6f 70 74 69 6f 6e pile-time option
1da0: 20 62 65 69 6e 67 20 73 65 74 20 74 6f 20 30 2e being set to 0.
1db0: 0a 2a 2a 0a 2a 2a 20 53 51 4c 69 74 65 20 63 61 .**.** SQLite ca
1dc0: 6e 20 62 65 20 63 6f 6d 70 69 6c 65 64 20 77 69 n be compiled wi
1dd0: 74 68 20 6f 72 20 77 69 74 68 6f 75 74 20 6d 75 th or without mu
1de0: 74 65 78 65 73 2e 20 20 57 68 65 6e 0a 2a 2a 20 texes. When.**
1df0: 74 68 65 20 5b 53 51 4c 49 54 45 5f 54 48 52 45 the [SQLITE_THRE
1e00: 41 44 53 41 46 45 5d 20 43 20 70 72 65 70 72 6f ADSAFE] C prepro
1e10: 63 65 73 73 6f 72 20 6d 61 63 72 6f 20 69 73 20 cessor macro is
1e20: 31 20 6f 72 20 32 2c 20 6d 75 74 65 78 65 73 0a 1 or 2, mutexes.
1e30: 2a 2a 20 61 72 65 20 65 6e 61 62 6c 65 64 20 61 ** are enabled a
1e40: 6e 64 20 53 51 4c 69 74 65 20 69 73 20 74 68 72 nd SQLite is thr
1e50: 65 61 64 73 61 66 65 2e 20 20 57 68 65 6e 20 74 eadsafe. When t
1e60: 68 65 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f 54 48 he.** [SQLITE_TH
1e70: 52 45 41 44 53 41 46 45 5d 20 6d 61 63 72 6f 20 READSAFE] macro
1e80: 69 73 20 30 2c 20 0a 2a 2a 20 74 68 65 20 6d 75 is 0, .** the mu
1e90: 74 65 78 65 73 20 61 72 65 20 6f 6d 69 74 74 65 texes are omitte
1ea0: 64 2e 20 20 57 69 74 68 6f 75 74 20 74 68 65 20 d. Without the
1eb0: 6d 75 74 65 78 65 73 2c 20 69 74 20 69 73 20 6e mutexes, it is n
1ec0: 6f 74 20 73 61 66 65 0a 2a 2a 20 74 6f 20 75 73 ot safe.** to us
1ed0: 65 20 53 51 4c 69 74 65 20 63 6f 6e 63 75 72 72 e SQLite concurr
1ee0: 65 6e 74 6c 79 20 66 72 6f 6d 20 6d 6f 72 65 20 ently from more
1ef0: 74 68 61 6e 20 6f 6e 65 20 74 68 72 65 61 64 2e than one thread.
1f00: 0a 2a 2a 0a 2a 2a 20 45 6e 61 62 6c 69 6e 67 20 .**.** Enabling
1f10: 6d 75 74 65 78 65 73 20 69 6e 63 75 72 73 20 61 mutexes incurs a
1f20: 20 6d 65 61 73 75 72 61 62 6c 65 20 70 65 72 66 measurable perf
1f30: 6f 72 6d 61 6e 63 65 20 70 65 6e 61 6c 74 79 2e ormance penalty.
1f40: 0a 2a 2a 20 53 6f 20 69 66 20 73 70 65 65 64 20 .** So if speed
1f50: 69 73 20 6f 66 20 75 74 6d 6f 73 74 20 69 6d 70 is of utmost imp
1f60: 6f 72 74 61 6e 63 65 2c 20 69 74 20 6d 61 6b 65 ortance, it make
1f70: 73 20 73 65 6e 73 65 20 74 6f 20 64 69 73 61 62 s sense to disab
1f80: 6c 65 0a 2a 2a 20 74 68 65 20 6d 75 74 65 78 65 le.** the mutexe
1f90: 73 2e 20 20 42 75 74 20 66 6f 72 20 6d 61 78 69 s. But for maxi
1fa0: 6d 75 6d 20 73 61 66 65 74 79 2c 20 6d 75 74 65 mum safety, mute
1fb0: 78 65 73 20 73 68 6f 75 6c 64 20 62 65 20 65 6e xes should be en
1fc0: 61 62 6c 65 64 2e 0a 2a 2a 20 5e 54 68 65 20 64 abled..** ^The d
1fd0: 65 66 61 75 6c 74 20 62 65 68 61 76 69 6f 72 20 efault behavior
1fe0: 69 73 20 66 6f 72 20 6d 75 74 65 78 65 73 20 74 is for mutexes t
1ff0: 6f 20 62 65 20 65 6e 61 62 6c 65 64 2e 0a 2a 2a o be enabled..**
2000: 0a 2a 2a 20 54 68 69 73 20 69 6e 74 65 72 66 61 .** This interfa
2010: 63 65 20 63 61 6e 20 62 65 20 75 73 65 64 20 62 ce can be used b
2020: 79 20 61 6e 20 61 70 70 6c 69 63 61 74 69 6f 6e y an application
2030: 20 74 6f 20 6d 61 6b 65 20 73 75 72 65 20 74 68 to make sure th
2040: 61 74 20 74 68 65 0a 2a 2a 20 76 65 72 73 69 6f at the.** versio
2050: 6e 20 6f 66 20 53 51 4c 69 74 65 20 74 68 61 74 n of SQLite that
2060: 20 69 74 20 69 73 20 6c 69 6e 6b 69 6e 67 20 61 it is linking a
2070: 67 61 69 6e 73 74 20 77 61 73 20 63 6f 6d 70 69 gainst was compi
2080: 6c 65 64 20 77 69 74 68 0a 2a 2a 20 74 68 65 20 led with.** the
2090: 64 65 73 69 72 65 64 20 73 65 74 74 69 6e 67 20 desired setting
20a0: 6f 66 20 74 68 65 20 5b 53 51 4c 49 54 45 5f 54 of the [SQLITE_T
20b0: 48 52 45 41 44 53 41 46 45 5d 20 6d 61 63 72 6f HREADSAFE] macro
20c0: 2e 0a 2a 2a 0a 2a 2a 20 54 68 69 73 20 69 6e 74 ..**.** This int
20d0: 65 72 66 61 63 65 20 6f 6e 6c 79 20 72 65 70 6f erface only repo
20e0: 72 74 73 20 6f 6e 20 74 68 65 20 63 6f 6d 70 69 rts on the compi
20f0: 6c 65 2d 74 69 6d 65 20 6d 75 74 65 78 20 73 65 le-time mutex se
2100: 74 74 69 6e 67 0a 2a 2a 20 6f 66 20 74 68 65 20 tting.** of the
2110: 5b 53 51 4c 49 54 45 5f 54 48 52 45 41 44 53 41 [SQLITE_THREADSA
2120: 46 45 5d 20 66 6c 61 67 2e 20 20 49 66 20 53 51 FE] flag. If SQ
2130: 4c 69 74 65 20 69 73 20 63 6f 6d 70 69 6c 65 64 Lite is compiled
2140: 20 77 69 74 68 0a 2a 2a 20 53 51 4c 49 54 45 5f with.** SQLITE_
2150: 54 48 52 45 41 44 53 41 46 45 3d 31 20 6f 72 20 THREADSAFE=1 or
2160: 3d 32 20 74 68 65 6e 20 6d 75 74 65 78 65 73 20 =2 then mutexes
2170: 61 72 65 20 65 6e 61 62 6c 65 64 20 62 79 20 64 are enabled by d
2180: 65 66 61 75 6c 74 20 62 75 74 0a 2a 2a 20 63 61 efault but.** ca
2190: 6e 20 62 65 20 66 75 6c 6c 79 20 6f 72 20 70 61 n be fully or pa
21a0: 72 74 69 61 6c 6c 79 20 64 69 73 61 62 6c 65 64 rtially disabled
21b0: 20 75 73 69 6e 67 20 61 20 63 61 6c 6c 20 74 6f using a call to
21c0: 20 5b 73 71 6c 69 74 65 33 5f 63 6f 6e 66 69 67 [sqlite3_config
21d0: 28 29 5d 0a 2a 2a 20 77 69 74 68 20 74 68 65 20 ()].** with the
21e0: 76 65 72 62 73 20 5b 53 51 4c 49 54 45 5f 43 4f verbs [SQLITE_CO
21f0: 4e 46 49 47 5f 53 49 4e 47 4c 45 54 48 52 45 41 NFIG_SINGLETHREA
2200: 44 5d 2c 20 5b 53 51 4c 49 54 45 5f 43 4f 4e 46 D], [SQLITE_CONF
2210: 49 47 5f 4d 55 4c 54 49 54 48 52 45 41 44 5d 2c IG_MULTITHREAD],
2220: 0a 2a 2a 20 6f 72 20 5b 53 51 4c 49 54 45 5f 43 .** or [SQLITE_C
2230: 4f 4e 46 49 47 5f 53 45 52 49 41 4c 49 5a 45 44 ONFIG_SERIALIZED
2240: 5d 2e 20 20 5e 28 54 68 65 20 72 65 74 75 72 6e ]. ^(The return
2250: 20 76 61 6c 75 65 20 6f 66 20 74 68 65 0a 2a 2a value of the.**
2260: 20 73 71 6c 69 74 65 33 5f 74 68 72 65 61 64 73 sqlite3_threads
2270: 61 66 65 28 29 20 66 75 6e 63 74 69 6f 6e 20 73 afe() function s
2280: 68 6f 77 73 20 6f 6e 6c 79 20 74 68 65 20 63 6f hows only the co
2290: 6d 70 69 6c 65 2d 74 69 6d 65 20 73 65 74 74 69 mpile-time setti
22a0: 6e 67 20 6f 66 0a 2a 2a 20 74 68 72 65 61 64 20 ng of.** thread
22b0: 73 61 66 65 74 79 2c 20 6e 6f 74 20 61 6e 79 20 safety, not any
22c0: 72 75 6e 2d 74 69 6d 65 20 63 68 61 6e 67 65 73 run-time changes
22d0: 20 74 6f 20 74 68 61 74 20 73 65 74 74 69 6e 67 to that setting
22e0: 20 6d 61 64 65 20 62 79 0a 2a 2a 20 73 71 6c 69 made by.** sqli
22f0: 74 65 33 5f 63 6f 6e 66 69 67 28 29 2e 20 49 6e te3_config(). In
2300: 20 6f 74 68 65 72 20 77 6f 72 64 73 2c 20 74 68 other words, th
2310: 65 20 72 65 74 75 72 6e 20 76 61 6c 75 65 20 66 e return value f
2320: 72 6f 6d 20 73 71 6c 69 74 65 33 5f 74 68 72 65 rom sqlite3_thre
2330: 61 64 73 61 66 65 28 29 0a 2a 2a 20 69 73 20 75 adsafe().** is u
2340: 6e 63 68 61 6e 67 65 64 20 62 79 20 63 61 6c 6c nchanged by call
2350: 73 20 74 6f 20 73 71 6c 69 74 65 33 5f 63 6f 6e s to sqlite3_con
2360: 66 69 67 28 29 2e 29 5e 0a 2a 2a 0a 2a 2a 20 53 fig().)^.**.** S
2370: 65 65 20 74 68 65 20 5b 74 68 72 65 61 64 69 6e ee the [threadin
2380: 67 20 6d 6f 64 65 5d 20 64 6f 63 75 6d 65 6e 74 g mode] document
2390: 61 74 69 6f 6e 20 66 6f 72 20 61 64 64 69 74 69 ation for additi
23a0: 6f 6e 61 6c 20 69 6e 66 6f 72 6d 61 74 69 6f 6e onal information
23b0: 2e 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 65 33 ..*/.int sqlite3
23c0: 5f 74 68 72 65 61 64 73 61 66 65 28 76 6f 69 64 _threadsafe(void
23d0: 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 );../*.** CAPI3R
23e0: 45 46 3a 20 44 61 74 61 62 61 73 65 20 43 6f 6e EF: Database Con
23f0: 6e 65 63 74 69 6f 6e 20 48 61 6e 64 6c 65 0a 2a nection Handle.*
2400: 2a 20 4b 45 59 57 4f 52 44 53 3a 20 7b 64 61 74 * KEYWORDS: {dat
2410: 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e abase connection
2420: 7d 20 7b 64 61 74 61 62 61 73 65 20 63 6f 6e 6e } {database conn
2430: 65 63 74 69 6f 6e 73 7d 0a 2a 2a 0a 2a 2a 20 45 ections}.**.** E
2440: 61 63 68 20 6f 70 65 6e 20 53 51 4c 69 74 65 20 ach open SQLite
2450: 64 61 74 61 62 61 73 65 20 69 73 20 72 65 70 72 database is repr
2460: 65 73 65 6e 74 65 64 20 62 79 20 61 20 70 6f 69 esented by a poi
2470: 6e 74 65 72 20 74 6f 20 61 6e 20 69 6e 73 74 61 nter to an insta
2480: 6e 63 65 20 6f 66 0a 2a 2a 20 74 68 65 20 6f 70 nce of.** the op
2490: 61 71 75 65 20 73 74 72 75 63 74 75 72 65 20 6e aque structure n
24a0: 61 6d 65 64 20 22 73 71 6c 69 74 65 33 22 2e 20 amed "sqlite3".
24b0: 20 49 74 20 69 73 20 75 73 65 66 75 6c 20 74 6f It is useful to
24c0: 20 74 68 69 6e 6b 20 6f 66 20 61 6e 20 73 71 6c think of an sql
24d0: 69 74 65 33 0a 2a 2a 20 70 6f 69 6e 74 65 72 20 ite3.** pointer
24e0: 61 73 20 61 6e 20 6f 62 6a 65 63 74 2e 20 20 54 as an object. T
24f0: 68 65 20 5b 73 71 6c 69 74 65 33 5f 6f 70 65 6e he [sqlite3_open
2500: 28 29 5d 2c 20 5b 73 71 6c 69 74 65 33 5f 6f 70 ()], [sqlite3_op
2510: 65 6e 31 36 28 29 5d 2c 20 61 6e 64 0a 2a 2a 20 en16()], and.**
2520: 5b 73 71 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 32 [sqlite3_open_v2
2530: 28 29 5d 20 69 6e 74 65 72 66 61 63 65 73 20 61 ()] interfaces a
2540: 72 65 20 69 74 73 20 63 6f 6e 73 74 72 75 63 74 re its construct
2550: 6f 72 73 2c 20 61 6e 64 20 5b 73 71 6c 69 74 65 ors, and [sqlite
2560: 33 5f 63 6c 6f 73 65 28 29 5d 0a 2a 2a 20 61 6e 3_close()].** an
2570: 64 20 5b 73 71 6c 69 74 65 33 5f 63 6c 6f 73 65 d [sqlite3_close
2580: 5f 76 32 28 29 5d 20 61 72 65 20 69 74 73 20 64 _v2()] are its d
2590: 65 73 74 72 75 63 74 6f 72 73 2e 20 20 54 68 65 estructors. The
25a0: 72 65 20 61 72 65 20 6d 61 6e 79 20 6f 74 68 65 re are many othe
25b0: 72 0a 2a 2a 20 69 6e 74 65 72 66 61 63 65 73 20 r.** interfaces
25c0: 28 73 75 63 68 20 61 73 0a 2a 2a 20 5b 73 71 6c (such as.** [sql
25d0: 69 74 65 33 5f 70 72 65 70 61 72 65 5f 76 32 28 ite3_prepare_v2(
25e0: 29 5d 2c 20 5b 73 71 6c 69 74 65 33 5f 63 72 65 )], [sqlite3_cre
25f0: 61 74 65 5f 66 75 6e 63 74 69 6f 6e 28 29 5d 2c ate_function()],
2600: 20 61 6e 64 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 and.** [sqlite3
2610: 5f 62 75 73 79 5f 74 69 6d 65 6f 75 74 28 29 5d _busy_timeout()]
2620: 20 74 6f 20 6e 61 6d 65 20 62 75 74 20 74 68 72 to name but thr
2630: 65 65 29 20 74 68 61 74 20 61 72 65 20 6d 65 74 ee) that are met
2640: 68 6f 64 73 20 6f 6e 20 61 6e 0a 2a 2a 20 73 71 hods on an.** sq
2650: 6c 69 74 65 33 20 6f 62 6a 65 63 74 2e 0a 2a 2f lite3 object..*/
2660: 0a 74 79 70 65 64 65 66 20 73 74 72 75 63 74 20 .typedef struct
2670: 73 71 6c 69 74 65 33 20 73 71 6c 69 74 65 33 3b sqlite3 sqlite3;
2680: 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 ../*.** CAPI3REF
2690: 3a 20 36 34 2d 42 69 74 20 49 6e 74 65 67 65 72 : 64-Bit Integer
26a0: 20 54 79 70 65 73 0a 2a 2a 20 4b 45 59 57 4f 52 Types.** KEYWOR
26b0: 44 53 3a 20 73 71 6c 69 74 65 5f 69 6e 74 36 34 DS: sqlite_int64
26c0: 20 73 71 6c 69 74 65 5f 75 69 6e 74 36 34 0a 2a sqlite_uint64.*
26d0: 2a 0a 2a 2a 20 42 65 63 61 75 73 65 20 74 68 65 *.** Because the
26e0: 72 65 20 69 73 20 6e 6f 20 63 72 6f 73 73 2d 70 re is no cross-p
26f0: 6c 61 74 66 6f 72 6d 20 77 61 79 20 74 6f 20 73 latform way to s
2700: 70 65 63 69 66 79 20 36 34 2d 62 69 74 20 69 6e pecify 64-bit in
2710: 74 65 67 65 72 20 74 79 70 65 73 0a 2a 2a 20 53 teger types.** S
2720: 51 4c 69 74 65 20 69 6e 63 6c 75 64 65 73 20 74 QLite includes t
2730: 79 70 65 64 65 66 73 20 66 6f 72 20 36 34 2d 62 ypedefs for 64-b
2740: 69 74 20 73 69 67 6e 65 64 20 61 6e 64 20 75 6e it signed and un
2750: 73 69 67 6e 65 64 20 69 6e 74 65 67 65 72 73 2e signed integers.
2760: 0a 2a 2a 0a 2a 2a 20 54 68 65 20 73 71 6c 69 74 .**.** The sqlit
2770: 65 33 5f 69 6e 74 36 34 20 61 6e 64 20 73 71 6c e3_int64 and sql
2780: 69 74 65 33 5f 75 69 6e 74 36 34 20 61 72 65 20 ite3_uint64 are
2790: 74 68 65 20 70 72 65 66 65 72 72 65 64 20 74 79 the preferred ty
27a0: 70 65 20 64 65 66 69 6e 69 74 69 6f 6e 73 2e 0a pe definitions..
27b0: 2a 2a 20 54 68 65 20 73 71 6c 69 74 65 5f 69 6e ** The sqlite_in
27c0: 74 36 34 20 61 6e 64 20 73 71 6c 69 74 65 5f 75 t64 and sqlite_u
27d0: 69 6e 74 36 34 20 74 79 70 65 73 20 61 72 65 20 int64 types are
27e0: 73 75 70 70 6f 72 74 65 64 20 66 6f 72 20 62 61 supported for ba
27f0: 63 6b 77 61 72 64 73 0a 2a 2a 20 63 6f 6d 70 61 ckwards.** compa
2800: 74 69 62 69 6c 69 74 79 20 6f 6e 6c 79 2e 0a 2a tibility only..*
2810: 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 6c 69 74 65 *.** ^The sqlite
2820: 33 5f 69 6e 74 36 34 20 61 6e 64 20 73 71 6c 69 3_int64 and sqli
2830: 74 65 5f 69 6e 74 36 34 20 74 79 70 65 73 20 63 te_int64 types c
2840: 61 6e 20 73 74 6f 72 65 20 69 6e 74 65 67 65 72 an store integer
2850: 20 76 61 6c 75 65 73 0a 2a 2a 20 62 65 74 77 65 values.** betwe
2860: 65 6e 20 2d 39 32 32 33 33 37 32 30 33 36 38 35 en -922337203685
2870: 34 37 37 35 38 30 38 20 61 6e 64 20 2b 39 32 32 4775808 and +922
2880: 33 33 37 32 30 33 36 38 35 34 37 37 35 38 30 37 3372036854775807
2890: 20 69 6e 63 6c 75 73 69 76 65 2e 20 20 5e 54 68 inclusive. ^Th
28a0: 65 0a 2a 2a 20 73 71 6c 69 74 65 33 5f 75 69 6e e.** sqlite3_uin
28b0: 74 36 34 20 61 6e 64 20 73 71 6c 69 74 65 5f 75 t64 and sqlite_u
28c0: 69 6e 74 36 34 20 74 79 70 65 73 20 63 61 6e 20 int64 types can
28d0: 73 74 6f 72 65 20 69 6e 74 65 67 65 72 20 76 61 store integer va
28e0: 6c 75 65 73 20 0a 2a 2a 20 62 65 74 77 65 65 6e lues .** between
28f0: 20 30 20 61 6e 64 20 2b 31 38 34 34 36 37 34 34 0 and +18446744
2900: 30 37 33 37 30 39 35 35 31 36 31 35 20 69 6e 63 073709551615 inc
2910: 6c 75 73 69 76 65 2e 0a 2a 2f 0a 23 69 66 64 65 lusive..*/.#ifde
2920: 66 20 53 51 4c 49 54 45 5f 49 4e 54 36 34 5f 54 f SQLITE_INT64_T
2930: 59 50 45 0a 20 20 74 79 70 65 64 65 66 20 53 51 YPE. typedef SQ
2940: 4c 49 54 45 5f 49 4e 54 36 34 5f 54 59 50 45 20 LITE_INT64_TYPE
2950: 73 71 6c 69 74 65 5f 69 6e 74 36 34 3b 0a 20 20 sqlite_int64;.
2960: 74 79 70 65 64 65 66 20 75 6e 73 69 67 6e 65 64 typedef unsigned
2970: 20 53 51 4c 49 54 45 5f 49 4e 54 36 34 5f 54 59 SQLITE_INT64_TY
2980: 50 45 20 73 71 6c 69 74 65 5f 75 69 6e 74 36 34 PE sqlite_uint64
2990: 3b 0a 23 65 6c 69 66 20 64 65 66 69 6e 65 64 28 ;.#elif defined(
29a0: 5f 4d 53 43 5f 56 45 52 29 20 7c 7c 20 64 65 66 _MSC_VER) || def
29b0: 69 6e 65 64 28 5f 5f 42 4f 52 4c 41 4e 44 43 5f ined(__BORLANDC_
29c0: 5f 29 0a 20 20 74 79 70 65 64 65 66 20 5f 5f 69 _). typedef __i
29d0: 6e 74 36 34 20 73 71 6c 69 74 65 5f 69 6e 74 36 nt64 sqlite_int6
29e0: 34 3b 0a 20 20 74 79 70 65 64 65 66 20 75 6e 73 4;. typedef uns
29f0: 69 67 6e 65 64 20 5f 5f 69 6e 74 36 34 20 73 71 igned __int64 sq
2a00: 6c 69 74 65 5f 75 69 6e 74 36 34 3b 0a 23 65 6c lite_uint64;.#el
2a10: 73 65 0a 20 20 74 79 70 65 64 65 66 20 6c 6f 6e se. typedef lon
2a20: 67 20 6c 6f 6e 67 20 69 6e 74 20 73 71 6c 69 74 g long int sqlit
2a30: 65 5f 69 6e 74 36 34 3b 0a 20 20 74 79 70 65 64 e_int64;. typed
2a40: 65 66 20 75 6e 73 69 67 6e 65 64 20 6c 6f 6e 67 ef unsigned long
2a50: 20 6c 6f 6e 67 20 69 6e 74 20 73 71 6c 69 74 65 long int sqlite
2a60: 5f 75 69 6e 74 36 34 3b 0a 23 65 6e 64 69 66 0a _uint64;.#endif.
2a70: 74 79 70 65 64 65 66 20 73 71 6c 69 74 65 5f 69 typedef sqlite_i
2a80: 6e 74 36 34 20 73 71 6c 69 74 65 33 5f 69 6e 74 nt64 sqlite3_int
2a90: 36 34 3b 0a 74 79 70 65 64 65 66 20 73 71 6c 69 64;.typedef sqli
2aa0: 74 65 5f 75 69 6e 74 36 34 20 73 71 6c 69 74 65 te_uint64 sqlite
2ab0: 33 5f 75 69 6e 74 36 34 3b 0a 0a 2f 2a 0a 2a 2a 3_uint64;../*.**
2ac0: 20 49 66 20 63 6f 6d 70 69 6c 69 6e 67 20 66 6f If compiling fo
2ad0: 72 20 61 20 70 72 6f 63 65 73 73 6f 72 20 74 68 r a processor th
2ae0: 61 74 20 6c 61 63 6b 73 20 66 6c 6f 61 74 69 6e at lacks floatin
2af0: 67 20 70 6f 69 6e 74 20 73 75 70 70 6f 72 74 2c g point support,
2b00: 0a 2a 2a 20 73 75 62 73 74 69 74 75 74 65 20 69 .** substitute i
2b10: 6e 74 65 67 65 72 20 66 6f 72 20 66 6c 6f 61 74 nteger for float
2b20: 69 6e 67 2d 70 6f 69 6e 74 2e 0a 2a 2f 0a 23 69 ing-point..*/.#i
2b30: 66 64 65 66 20 53 51 4c 49 54 45 5f 4f 4d 49 54 fdef SQLITE_OMIT
2b40: 5f 46 4c 4f 41 54 49 4e 47 5f 50 4f 49 4e 54 0a _FLOATING_POINT.
2b50: 23 20 64 65 66 69 6e 65 20 64 6f 75 62 6c 65 20 # define double
2b60: 73 71 6c 69 74 65 33 5f 69 6e 74 36 34 0a 23 65 sqlite3_int64.#e
2b70: 6e 64 69 66 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 ndif../*.** CAPI
2b80: 33 52 45 46 3a 20 43 6c 6f 73 69 6e 67 20 41 20 3REF: Closing A
2b90: 44 61 74 61 62 61 73 65 20 43 6f 6e 6e 65 63 74 Database Connect
2ba0: 69 6f 6e 0a 2a 2a 20 44 45 53 54 52 55 43 54 4f ion.** DESTRUCTO
2bb0: 52 3a 20 73 71 6c 69 74 65 33 0a 2a 2a 0a 2a 2a R: sqlite3.**.**
2bc0: 20 5e 54 68 65 20 73 71 6c 69 74 65 33 5f 63 6c ^The sqlite3_cl
2bd0: 6f 73 65 28 29 20 61 6e 64 20 73 71 6c 69 74 65 ose() and sqlite
2be0: 33 5f 63 6c 6f 73 65 5f 76 32 28 29 20 72 6f 75 3_close_v2() rou
2bf0: 74 69 6e 65 73 20 61 72 65 20 64 65 73 74 72 75 tines are destru
2c00: 63 74 6f 72 73 0a 2a 2a 20 66 6f 72 20 74 68 65 ctors.** for the
2c10: 20 5b 73 71 6c 69 74 65 33 5d 20 6f 62 6a 65 63 [sqlite3] objec
2c20: 74 2e 0a 2a 2a 20 5e 43 61 6c 6c 73 20 74 6f 20 t..** ^Calls to
2c30: 73 71 6c 69 74 65 33 5f 63 6c 6f 73 65 28 29 20 sqlite3_close()
2c40: 61 6e 64 20 73 71 6c 69 74 65 33 5f 63 6c 6f 73 and sqlite3_clos
2c50: 65 5f 76 32 28 29 20 72 65 74 75 72 6e 20 5b 53 e_v2() return [S
2c60: 51 4c 49 54 45 5f 4f 4b 5d 20 69 66 0a 2a 2a 20 QLITE_OK] if.**
2c70: 74 68 65 20 5b 73 71 6c 69 74 65 33 5d 20 6f 62 the [sqlite3] ob
2c80: 6a 65 63 74 20 69 73 20 73 75 63 63 65 73 73 66 ject is successf
2c90: 75 6c 6c 79 20 64 65 73 74 72 6f 79 65 64 20 61 ully destroyed a
2ca0: 6e 64 20 61 6c 6c 20 61 73 73 6f 63 69 61 74 65 nd all associate
2cb0: 64 0a 2a 2a 20 72 65 73 6f 75 72 63 65 73 20 61 d.** resources a
2cc0: 72 65 20 64 65 61 6c 6c 6f 63 61 74 65 64 2e 0a re deallocated..
2cd0: 2a 2a 0a 2a 2a 20 5e 49 66 20 74 68 65 20 64 61 **.** ^If the da
2ce0: 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f tabase connectio
2cf0: 6e 20 69 73 20 61 73 73 6f 63 69 61 74 65 64 20 n is associated
2d00: 77 69 74 68 20 75 6e 66 69 6e 61 6c 69 7a 65 64 with unfinalized
2d10: 20 70 72 65 70 61 72 65 64 0a 2a 2a 20 73 74 61 prepared.** sta
2d20: 74 65 6d 65 6e 74 73 20 6f 72 20 75 6e 66 69 6e tements or unfin
2d30: 69 73 68 65 64 20 73 71 6c 69 74 65 33 5f 62 61 ished sqlite3_ba
2d40: 63 6b 75 70 20 6f 62 6a 65 63 74 73 20 74 68 65 ckup objects the
2d50: 6e 20 73 71 6c 69 74 65 33 5f 63 6c 6f 73 65 28 n sqlite3_close(
2d60: 29 0a 2a 2a 20 77 69 6c 6c 20 6c 65 61 76 65 20 ).** will leave
2d70: 74 68 65 20 64 61 74 61 62 61 73 65 20 63 6f 6e the database con
2d80: 6e 65 63 74 69 6f 6e 20 6f 70 65 6e 20 61 6e 64 nection open and
2d90: 20 72 65 74 75 72 6e 20 5b 53 51 4c 49 54 45 5f return [SQLITE_
2da0: 42 55 53 59 5d 2e 0a 2a 2a 20 5e 49 66 20 73 71 BUSY]..** ^If sq
2db0: 6c 69 74 65 33 5f 63 6c 6f 73 65 5f 76 32 28 29 lite3_close_v2()
2dc0: 20 69 73 20 63 61 6c 6c 65 64 20 77 69 74 68 20 is called with
2dd0: 75 6e 66 69 6e 61 6c 69 7a 65 64 20 70 72 65 70 unfinalized prep
2de0: 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 73 0a ared statements.
2df0: 2a 2a 20 61 6e 64 2f 6f 72 20 75 6e 66 69 6e 69 ** and/or unfini
2e00: 73 68 65 64 20 73 71 6c 69 74 65 33 5f 62 61 63 shed sqlite3_bac
2e10: 6b 75 70 73 2c 20 74 68 65 6e 20 74 68 65 20 64 kups, then the d
2e20: 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 atabase connecti
2e30: 6f 6e 20 62 65 63 6f 6d 65 73 0a 2a 2a 20 61 6e on becomes.** an
2e40: 20 75 6e 75 73 61 62 6c 65 20 22 7a 6f 6d 62 69 unusable "zombi
2e50: 65 22 20 77 68 69 63 68 20 77 69 6c 6c 20 61 75 e" which will au
2e60: 74 6f 6d 61 74 69 63 61 6c 6c 79 20 62 65 20 64 tomatically be d
2e70: 65 61 6c 6c 6f 63 61 74 65 64 20 77 68 65 6e 20 eallocated when
2e80: 74 68 65 0a 2a 2a 20 6c 61 73 74 20 70 72 65 70 the.** last prep
2e90: 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 20 69 ared statement i
2ea0: 73 20 66 69 6e 61 6c 69 7a 65 64 20 6f 72 20 74 s finalized or t
2eb0: 68 65 20 6c 61 73 74 20 73 71 6c 69 74 65 33 5f he last sqlite3_
2ec0: 62 61 63 6b 75 70 20 69 73 0a 2a 2a 20 66 69 6e backup is.** fin
2ed0: 69 73 68 65 64 2e 20 20 54 68 65 20 73 71 6c 69 ished. The sqli
2ee0: 74 65 33 5f 63 6c 6f 73 65 5f 76 32 28 29 20 69 te3_close_v2() i
2ef0: 6e 74 65 72 66 61 63 65 20 69 73 20 69 6e 74 65 nterface is inte
2f00: 6e 64 65 64 20 66 6f 72 20 75 73 65 20 77 69 74 nded for use wit
2f10: 68 0a 2a 2a 20 68 6f 73 74 20 6c 61 6e 67 75 61 h.** host langua
2f20: 67 65 73 20 74 68 61 74 20 61 72 65 20 67 61 72 ges that are gar
2f30: 62 61 67 65 20 63 6f 6c 6c 65 63 74 65 64 2c 20 bage collected,
2f40: 61 6e 64 20 77 68 65 72 65 20 74 68 65 20 6f 72 and where the or
2f50: 64 65 72 20 69 6e 20 77 68 69 63 68 0a 2a 2a 20 der in which.**
2f60: 64 65 73 74 72 75 63 74 6f 72 73 20 61 72 65 20 destructors are
2f70: 63 61 6c 6c 65 64 20 69 73 20 61 72 62 69 74 72 called is arbitr
2f80: 61 72 79 2e 0a 2a 2a 0a 2a 2a 20 41 70 70 6c 69 ary..**.** Appli
2f90: 63 61 74 69 6f 6e 73 20 73 68 6f 75 6c 64 20 5b cations should [
2fa0: 73 71 6c 69 74 65 33 5f 66 69 6e 61 6c 69 7a 65 sqlite3_finalize
2fb0: 20 7c 20 66 69 6e 61 6c 69 7a 65 5d 20 61 6c 6c | finalize] all
2fc0: 20 5b 70 72 65 70 61 72 65 64 20 73 74 61 74 65 [prepared state
2fd0: 6d 65 6e 74 73 5d 2c 0a 2a 2a 20 5b 73 71 6c 69 ments],.** [sqli
2fe0: 74 65 33 5f 62 6c 6f 62 5f 63 6c 6f 73 65 20 7c te3_blob_close |
2ff0: 20 63 6c 6f 73 65 5d 20 61 6c 6c 20 5b 42 4c 4f close] all [BLO
3000: 42 20 68 61 6e 64 6c 65 73 5d 2c 20 61 6e 64 20 B handles], and
3010: 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 62 61 63 .** [sqlite3_bac
3020: 6b 75 70 5f 66 69 6e 69 73 68 20 7c 20 66 69 6e kup_finish | fin
3030: 69 73 68 5d 20 61 6c 6c 20 5b 73 71 6c 69 74 65 ish] all [sqlite
3040: 33 5f 62 61 63 6b 75 70 5d 20 6f 62 6a 65 63 74 3_backup] object
3050: 73 20 61 73 73 6f 63 69 61 74 65 64 0a 2a 2a 20 s associated.**
3060: 77 69 74 68 20 74 68 65 20 5b 73 71 6c 69 74 65 with the [sqlite
3070: 33 5d 20 6f 62 6a 65 63 74 20 70 72 69 6f 72 20 3] object prior
3080: 74 6f 20 61 74 74 65 6d 70 74 69 6e 67 20 74 6f to attempting to
3090: 20 63 6c 6f 73 65 20 74 68 65 20 6f 62 6a 65 63 close the objec
30a0: 74 2e 20 20 5e 49 66 0a 2a 2a 20 73 71 6c 69 74 t. ^If.** sqlit
30b0: 65 33 5f 63 6c 6f 73 65 5f 76 32 28 29 20 69 73 e3_close_v2() is
30c0: 20 63 61 6c 6c 65 64 20 6f 6e 20 61 20 5b 64 61 called on a [da
30d0: 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f tabase connectio
30e0: 6e 5d 20 74 68 61 74 20 73 74 69 6c 6c 20 68 61 n] that still ha
30f0: 73 0a 2a 2a 20 6f 75 74 73 74 61 6e 64 69 6e 67 s.** outstanding
3100: 20 5b 70 72 65 70 61 72 65 64 20 73 74 61 74 65 [prepared state
3110: 6d 65 6e 74 73 5d 2c 20 5b 42 4c 4f 42 20 68 61 ments], [BLOB ha
3120: 6e 64 6c 65 73 5d 2c 20 61 6e 64 2f 6f 72 0a 2a ndles], and/or.*
3130: 2a 20 5b 73 71 6c 69 74 65 33 5f 62 61 63 6b 75 * [sqlite3_backu
3140: 70 5d 20 6f 62 6a 65 63 74 73 20 74 68 65 6e 20 p] objects then
3150: 69 74 20 72 65 74 75 72 6e 73 20 5b 53 51 4c 49 it returns [SQLI
3160: 54 45 5f 4f 4b 5d 20 61 6e 64 20 74 68 65 20 64 TE_OK] and the d
3170: 65 61 6c 6c 6f 63 61 74 69 6f 6e 0a 2a 2a 20 6f eallocation.** o
3180: 66 20 72 65 73 6f 75 72 63 65 73 20 69 73 20 64 f resources is d
3190: 65 66 65 72 72 65 64 20 75 6e 74 69 6c 20 61 6c eferred until al
31a0: 6c 20 5b 70 72 65 70 61 72 65 64 20 73 74 61 74 l [prepared stat
31b0: 65 6d 65 6e 74 73 5d 2c 20 5b 42 4c 4f 42 20 68 ements], [BLOB h
31c0: 61 6e 64 6c 65 73 5d 2c 0a 2a 2a 20 61 6e 64 20 andles],.** and
31d0: 5b 73 71 6c 69 74 65 33 5f 62 61 63 6b 75 70 5d [sqlite3_backup]
31e0: 20 6f 62 6a 65 63 74 73 20 61 72 65 20 61 6c 73 objects are als
31f0: 6f 20 64 65 73 74 72 6f 79 65 64 2e 0a 2a 2a 0a o destroyed..**.
3200: 2a 2a 20 5e 49 66 20 61 6e 20 5b 73 71 6c 69 74 ** ^If an [sqlit
3210: 65 33 5d 20 6f 62 6a 65 63 74 20 69 73 20 64 65 e3] object is de
3220: 73 74 72 6f 79 65 64 20 77 68 69 6c 65 20 61 20 stroyed while a
3230: 74 72 61 6e 73 61 63 74 69 6f 6e 20 69 73 20 6f transaction is o
3240: 70 65 6e 2c 0a 2a 2a 20 74 68 65 20 74 72 61 6e pen,.** the tran
3250: 73 61 63 74 69 6f 6e 20 69 73 20 61 75 74 6f 6d saction is autom
3260: 61 74 69 63 61 6c 6c 79 20 72 6f 6c 6c 65 64 20 atically rolled
3270: 62 61 63 6b 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 back..**.** The
3280: 43 20 70 61 72 61 6d 65 74 65 72 20 74 6f 20 5b C parameter to [
3290: 73 71 6c 69 74 65 33 5f 63 6c 6f 73 65 28 43 29 sqlite3_close(C)
32a0: 5d 20 61 6e 64 20 5b 73 71 6c 69 74 65 33 5f 63 ] and [sqlite3_c
32b0: 6c 6f 73 65 5f 76 32 28 43 29 5d 0a 2a 2a 20 6d lose_v2(C)].** m
32c0: 75 73 74 20 62 65 20 65 69 74 68 65 72 20 61 20 ust be either a
32d0: 4e 55 4c 4c 0a 2a 2a 20 70 6f 69 6e 74 65 72 20 NULL.** pointer
32e0: 6f 72 20 61 6e 20 5b 73 71 6c 69 74 65 33 5d 20 or an [sqlite3]
32f0: 6f 62 6a 65 63 74 20 70 6f 69 6e 74 65 72 20 6f object pointer o
3300: 62 74 61 69 6e 65 64 0a 2a 2a 20 66 72 6f 6d 20 btained.** from
3310: 5b 73 71 6c 69 74 65 33 5f 6f 70 65 6e 28 29 5d [sqlite3_open()]
3320: 2c 20 5b 73 71 6c 69 74 65 33 5f 6f 70 65 6e 31 , [sqlite3_open1
3330: 36 28 29 5d 2c 20 6f 72 0a 2a 2a 20 5b 73 71 6c 6()], or.** [sql
3340: 69 74 65 33 5f 6f 70 65 6e 5f 76 32 28 29 5d 2c ite3_open_v2()],
3350: 20 61 6e 64 20 6e 6f 74 20 70 72 65 76 69 6f 75 and not previou
3360: 73 6c 79 20 63 6c 6f 73 65 64 2e 0a 2a 2a 20 5e sly closed..** ^
3370: 43 61 6c 6c 69 6e 67 20 73 71 6c 69 74 65 33 5f Calling sqlite3_
3380: 63 6c 6f 73 65 28 29 20 6f 72 20 73 71 6c 69 74 close() or sqlit
3390: 65 33 5f 63 6c 6f 73 65 5f 76 32 28 29 20 77 69 e3_close_v2() wi
33a0: 74 68 20 61 20 4e 55 4c 4c 20 70 6f 69 6e 74 65 th a NULL pointe
33b0: 72 0a 2a 2a 20 61 72 67 75 6d 65 6e 74 20 69 73 r.** argument is
33c0: 20 61 20 68 61 72 6d 6c 65 73 73 20 6e 6f 2d 6f a harmless no-o
33d0: 70 2e 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 65 p..*/.int sqlite
33e0: 33 5f 63 6c 6f 73 65 28 73 71 6c 69 74 65 33 2a 3_close(sqlite3*
33f0: 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f 63 );.int sqlite3_c
3400: 6c 6f 73 65 5f 76 32 28 73 71 6c 69 74 65 33 2a lose_v2(sqlite3*
3410: 29 3b 0a 0a 2f 2a 0a 2a 2a 20 54 68 65 20 74 79 );../*.** The ty
3420: 70 65 20 66 6f 72 20 61 20 63 61 6c 6c 62 61 63 pe for a callbac
3430: 6b 20 66 75 6e 63 74 69 6f 6e 2e 0a 2a 2a 20 54 k function..** T
3440: 68 69 73 20 69 73 20 6c 65 67 61 63 79 20 61 6e his is legacy an
3450: 64 20 64 65 70 72 65 63 61 74 65 64 2e 20 20 49 d deprecated. I
3460: 74 20 69 73 20 69 6e 63 6c 75 64 65 64 20 66 6f t is included fo
3470: 72 20 68 69 73 74 6f 72 69 63 61 6c 0a 2a 2a 20 r historical.**
3480: 63 6f 6d 70 61 74 69 62 69 6c 69 74 79 20 61 6e compatibility an
3490: 64 20 69 73 20 6e 6f 74 20 64 6f 63 75 6d 65 6e d is not documen
34a0: 74 65 64 2e 0a 2a 2f 0a 74 79 70 65 64 65 66 20 ted..*/.typedef
34b0: 69 6e 74 20 28 2a 73 71 6c 69 74 65 33 5f 63 61 int (*sqlite3_ca
34c0: 6c 6c 62 61 63 6b 29 28 76 6f 69 64 2a 2c 69 6e llback)(void*,in
34d0: 74 2c 63 68 61 72 2a 2a 2c 20 63 68 61 72 2a 2a t,char**, char**
34e0: 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 );../*.** CAPI3R
34f0: 45 46 3a 20 4f 6e 65 2d 53 74 65 70 20 51 75 65 EF: One-Step Que
3500: 72 79 20 45 78 65 63 75 74 69 6f 6e 20 49 6e 74 ry Execution Int
3510: 65 72 66 61 63 65 0a 2a 2a 20 4d 45 54 48 4f 44 erface.** METHOD
3520: 3a 20 73 71 6c 69 74 65 33 0a 2a 2a 0a 2a 2a 20 : sqlite3.**.**
3530: 54 68 65 20 73 71 6c 69 74 65 33 5f 65 78 65 63 The sqlite3_exec
3540: 28 29 20 69 6e 74 65 72 66 61 63 65 20 69 73 20 () interface is
3550: 61 20 63 6f 6e 76 65 6e 69 65 6e 63 65 20 77 72 a convenience wr
3560: 61 70 70 65 72 20 61 72 6f 75 6e 64 0a 2a 2a 20 apper around.**
3570: 5b 73 71 6c 69 74 65 33 5f 70 72 65 70 61 72 65 [sqlite3_prepare
3580: 5f 76 32 28 29 5d 2c 20 5b 73 71 6c 69 74 65 33 _v2()], [sqlite3
3590: 5f 73 74 65 70 28 29 5d 2c 20 61 6e 64 20 5b 73 _step()], and [s
35a0: 71 6c 69 74 65 33 5f 66 69 6e 61 6c 69 7a 65 28 qlite3_finalize(
35b0: 29 5d 2c 0a 2a 2a 20 74 68 61 74 20 61 6c 6c 6f )],.** that allo
35c0: 77 73 20 61 6e 20 61 70 70 6c 69 63 61 74 69 6f ws an applicatio
35d0: 6e 20 74 6f 20 72 75 6e 20 6d 75 6c 74 69 70 6c n to run multipl
35e0: 65 20 73 74 61 74 65 6d 65 6e 74 73 20 6f 66 20 e statements of
35f0: 53 51 4c 0a 2a 2a 20 77 69 74 68 6f 75 74 20 68 SQL.** without h
3600: 61 76 69 6e 67 20 74 6f 20 75 73 65 20 61 20 6c aving to use a l
3610: 6f 74 20 6f 66 20 43 20 63 6f 64 65 2e 20 0a 2a ot of C code. .*
3620: 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 6c 69 74 65 *.** ^The sqlite
3630: 33 5f 65 78 65 63 28 29 20 69 6e 74 65 72 66 61 3_exec() interfa
3640: 63 65 20 72 75 6e 73 20 7a 65 72 6f 20 6f 72 20 ce runs zero or
3650: 6d 6f 72 65 20 55 54 46 2d 38 20 65 6e 63 6f 64 more UTF-8 encod
3660: 65 64 2c 0a 2a 2a 20 73 65 6d 69 63 6f 6c 6f 6e ed,.** semicolon
3670: 2d 73 65 70 61 72 61 74 65 20 53 51 4c 20 73 74 -separate SQL st
3680: 61 74 65 6d 65 6e 74 73 20 70 61 73 73 65 64 20 atements passed
3690: 69 6e 74 6f 20 69 74 73 20 32 6e 64 20 61 72 67 into its 2nd arg
36a0: 75 6d 65 6e 74 2c 0a 2a 2a 20 69 6e 20 74 68 65 ument,.** in the
36b0: 20 63 6f 6e 74 65 78 74 20 6f 66 20 74 68 65 20 context of the
36c0: 5b 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 [database connec
36d0: 74 69 6f 6e 5d 20 70 61 73 73 65 64 20 69 6e 20 tion] passed in
36e0: 61 73 20 69 74 73 20 31 73 74 0a 2a 2a 20 61 72 as its 1st.** ar
36f0: 67 75 6d 65 6e 74 2e 20 20 5e 49 66 20 74 68 65 gument. ^If the
3700: 20 63 61 6c 6c 62 61 63 6b 20 66 75 6e 63 74 69 callback functi
3710: 6f 6e 20 6f 66 20 74 68 65 20 33 72 64 20 61 72 on of the 3rd ar
3720: 67 75 6d 65 6e 74 20 74 6f 0a 2a 2a 20 73 71 6c gument to.** sql
3730: 69 74 65 33 5f 65 78 65 63 28 29 20 69 73 20 6e ite3_exec() is n
3740: 6f 74 20 4e 55 4c 4c 2c 20 74 68 65 6e 20 69 74 ot NULL, then it
3750: 20 69 73 20 69 6e 76 6f 6b 65 64 20 66 6f 72 20 is invoked for
3760: 65 61 63 68 20 72 65 73 75 6c 74 20 72 6f 77 0a each result row.
3770: 2a 2a 20 63 6f 6d 69 6e 67 20 6f 75 74 20 6f 66 ** coming out of
3780: 20 74 68 65 20 65 76 61 6c 75 61 74 65 64 20 53 the evaluated S
3790: 51 4c 20 73 74 61 74 65 6d 65 6e 74 73 2e 20 20 QL statements.
37a0: 5e 54 68 65 20 34 74 68 20 61 72 67 75 6d 65 6e ^The 4th argumen
37b0: 74 20 74 6f 0a 2a 2a 20 73 71 6c 69 74 65 33 5f t to.** sqlite3_
37c0: 65 78 65 63 28 29 20 69 73 20 72 65 6c 61 79 65 exec() is relaye
37d0: 64 20 74 68 72 6f 75 67 68 20 74 6f 20 74 68 65 d through to the
37e0: 20 31 73 74 20 61 72 67 75 6d 65 6e 74 20 6f 66 1st argument of
37f0: 20 65 61 63 68 0a 2a 2a 20 63 61 6c 6c 62 61 63 each.** callbac
3800: 6b 20 69 6e 76 6f 63 61 74 69 6f 6e 2e 20 20 5e k invocation. ^
3810: 49 66 20 74 68 65 20 63 61 6c 6c 62 61 63 6b 20 If the callback
3820: 70 6f 69 6e 74 65 72 20 74 6f 20 73 71 6c 69 74 pointer to sqlit
3830: 65 33 5f 65 78 65 63 28 29 0a 2a 2a 20 69 73 20 e3_exec().** is
3840: 4e 55 4c 4c 2c 20 74 68 65 6e 20 6e 6f 20 63 61 NULL, then no ca
3850: 6c 6c 62 61 63 6b 20 69 73 20 65 76 65 72 20 69 llback is ever i
3860: 6e 76 6f 6b 65 64 20 61 6e 64 20 72 65 73 75 6c nvoked and resul
3870: 74 20 72 6f 77 73 20 61 72 65 0a 2a 2a 20 69 67 t rows are.** ig
3880: 6e 6f 72 65 64 2e 0a 2a 2a 0a 2a 2a 20 5e 49 66 nored..**.** ^If
3890: 20 61 6e 20 65 72 72 6f 72 20 6f 63 63 75 72 73 an error occurs
38a0: 20 77 68 69 6c 65 20 65 76 61 6c 75 61 74 69 6e while evaluatin
38b0: 67 20 74 68 65 20 53 51 4c 20 73 74 61 74 65 6d g the SQL statem
38c0: 65 6e 74 73 20 70 61 73 73 65 64 20 69 6e 74 6f ents passed into
38d0: 0a 2a 2a 20 73 71 6c 69 74 65 33 5f 65 78 65 63 .** sqlite3_exec
38e0: 28 29 2c 20 74 68 65 6e 20 65 78 65 63 75 74 69 (), then executi
38f0: 6f 6e 20 6f 66 20 74 68 65 20 63 75 72 72 65 6e on of the curren
3900: 74 20 73 74 61 74 65 6d 65 6e 74 20 73 74 6f 70 t statement stop
3910: 73 20 61 6e 64 0a 2a 2a 20 73 75 62 73 65 71 75 s and.** subsequ
3920: 65 6e 74 20 73 74 61 74 65 6d 65 6e 74 73 20 61 ent statements a
3930: 72 65 20 73 6b 69 70 70 65 64 2e 20 20 5e 49 66 re skipped. ^If
3940: 20 74 68 65 20 35 74 68 20 70 61 72 61 6d 65 74 the 5th paramet
3950: 65 72 20 74 6f 20 73 71 6c 69 74 65 33 5f 65 78 er to sqlite3_ex
3960: 65 63 28 29 0a 2a 2a 20 69 73 20 6e 6f 74 20 4e ec().** is not N
3970: 55 4c 4c 20 74 68 65 6e 20 61 6e 79 20 65 72 72 ULL then any err
3980: 6f 72 20 6d 65 73 73 61 67 65 20 69 73 20 77 72 or message is wr
3990: 69 74 74 65 6e 20 69 6e 74 6f 20 6d 65 6d 6f 72 itten into memor
39a0: 79 20 6f 62 74 61 69 6e 65 64 0a 2a 2a 20 66 72 y obtained.** fr
39b0: 6f 6d 20 5b 73 71 6c 69 74 65 33 5f 6d 61 6c 6c om [sqlite3_mall
39c0: 6f 63 28 29 5d 20 61 6e 64 20 70 61 73 73 65 64 oc()] and passed
39d0: 20 62 61 63 6b 20 74 68 72 6f 75 67 68 20 74 68 back through th
39e0: 65 20 35 74 68 20 70 61 72 61 6d 65 74 65 72 2e e 5th parameter.
39f0: 0a 2a 2a 20 54 6f 20 61 76 6f 69 64 20 6d 65 6d .** To avoid mem
3a00: 6f 72 79 20 6c 65 61 6b 73 2c 20 74 68 65 20 61 ory leaks, the a
3a10: 70 70 6c 69 63 61 74 69 6f 6e 20 73 68 6f 75 6c pplication shoul
3a20: 64 20 69 6e 76 6f 6b 65 20 5b 73 71 6c 69 74 65 d invoke [sqlite
3a30: 33 5f 66 72 65 65 28 29 5d 0a 2a 2a 20 6f 6e 20 3_free()].** on
3a40: 65 72 72 6f 72 20 6d 65 73 73 61 67 65 20 73 74 error message st
3a50: 72 69 6e 67 73 20 72 65 74 75 72 6e 65 64 20 74 rings returned t
3a60: 68 72 6f 75 67 68 20 74 68 65 20 35 74 68 20 70 hrough the 5th p
3a70: 61 72 61 6d 65 74 65 72 20 6f 66 0a 2a 2a 20 73 arameter of.** s
3a80: 71 6c 69 74 65 33 5f 65 78 65 63 28 29 20 61 66 qlite3_exec() af
3a90: 74 65 72 20 74 68 65 20 65 72 72 6f 72 20 6d 65 ter the error me
3aa0: 73 73 61 67 65 20 73 74 72 69 6e 67 20 69 73 20 ssage string is
3ab0: 6e 6f 20 6c 6f 6e 67 65 72 20 6e 65 65 64 65 64 no longer needed
3ac0: 2e 0a 2a 2a 20 5e 49 66 20 74 68 65 20 35 74 68 ..** ^If the 5th
3ad0: 20 70 61 72 61 6d 65 74 65 72 20 74 6f 20 73 71 parameter to sq
3ae0: 6c 69 74 65 33 5f 65 78 65 63 28 29 20 69 73 20 lite3_exec() is
3af0: 6e 6f 74 20 4e 55 4c 4c 20 61 6e 64 20 6e 6f 20 not NULL and no
3b00: 65 72 72 6f 72 73 0a 2a 2a 20 6f 63 63 75 72 2c errors.** occur,
3b10: 20 74 68 65 6e 20 73 71 6c 69 74 65 33 5f 65 78 then sqlite3_ex
3b20: 65 63 28 29 20 73 65 74 73 20 74 68 65 20 70 6f ec() sets the po
3b30: 69 6e 74 65 72 20 69 6e 20 69 74 73 20 35 74 68 inter in its 5th
3b40: 20 70 61 72 61 6d 65 74 65 72 20 74 6f 0a 2a 2a parameter to.**
3b50: 20 4e 55 4c 4c 20 62 65 66 6f 72 65 20 72 65 74 NULL before ret
3b60: 75 72 6e 69 6e 67 2e 0a 2a 2a 0a 2a 2a 20 5e 49 urning..**.** ^I
3b70: 66 20 61 6e 20 73 71 6c 69 74 65 33 5f 65 78 65 f an sqlite3_exe
3b80: 63 28 29 20 63 61 6c 6c 62 61 63 6b 20 72 65 74 c() callback ret
3b90: 75 72 6e 73 20 6e 6f 6e 2d 7a 65 72 6f 2c 20 74 urns non-zero, t
3ba0: 68 65 20 73 71 6c 69 74 65 33 5f 65 78 65 63 28 he sqlite3_exec(
3bb0: 29 0a 2a 2a 20 72 6f 75 74 69 6e 65 20 72 65 74 ).** routine ret
3bc0: 75 72 6e 73 20 53 51 4c 49 54 45 5f 41 42 4f 52 urns SQLITE_ABOR
3bd0: 54 20 77 69 74 68 6f 75 74 20 69 6e 76 6f 6b 69 T without invoki
3be0: 6e 67 20 74 68 65 20 63 61 6c 6c 62 61 63 6b 20 ng the callback
3bf0: 61 67 61 69 6e 20 61 6e 64 0a 2a 2a 20 77 69 74 again and.** wit
3c00: 68 6f 75 74 20 72 75 6e 6e 69 6e 67 20 61 6e 79 hout running any
3c10: 20 73 75 62 73 65 71 75 65 6e 74 20 53 51 4c 20 subsequent SQL
3c20: 73 74 61 74 65 6d 65 6e 74 73 2e 0a 2a 2a 0a 2a statements..**.*
3c30: 2a 20 5e 54 68 65 20 32 6e 64 20 61 72 67 75 6d * ^The 2nd argum
3c40: 65 6e 74 20 74 6f 20 74 68 65 20 73 71 6c 69 74 ent to the sqlit
3c50: 65 33 5f 65 78 65 63 28 29 20 63 61 6c 6c 62 61 e3_exec() callba
3c60: 63 6b 20 66 75 6e 63 74 69 6f 6e 20 69 73 20 74 ck function is t
3c70: 68 65 0a 2a 2a 20 6e 75 6d 62 65 72 20 6f 66 20 he.** number of
3c80: 63 6f 6c 75 6d 6e 73 20 69 6e 20 74 68 65 20 72 columns in the r
3c90: 65 73 75 6c 74 2e 20 20 5e 54 68 65 20 33 72 64 esult. ^The 3rd
3ca0: 20 61 72 67 75 6d 65 6e 74 20 74 6f 20 74 68 65 argument to the
3cb0: 20 73 71 6c 69 74 65 33 5f 65 78 65 63 28 29 0a sqlite3_exec().
3cc0: 2a 2a 20 63 61 6c 6c 62 61 63 6b 20 69 73 20 61 ** callback is a
3cd0: 6e 20 61 72 72 61 79 20 6f 66 20 70 6f 69 6e 74 n array of point
3ce0: 65 72 73 20 74 6f 20 73 74 72 69 6e 67 73 20 6f ers to strings o
3cf0: 62 74 61 69 6e 65 64 20 61 73 20 69 66 20 66 72 btained as if fr
3d00: 6f 6d 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 63 om.** [sqlite3_c
3d10: 6f 6c 75 6d 6e 5f 74 65 78 74 28 29 5d 2c 20 6f olumn_text()], o
3d20: 6e 65 20 66 6f 72 20 65 61 63 68 20 63 6f 6c 75 ne for each colu
3d30: 6d 6e 2e 20 20 5e 49 66 20 61 6e 20 65 6c 65 6d mn. ^If an elem
3d40: 65 6e 74 20 6f 66 20 61 0a 2a 2a 20 72 65 73 75 ent of a.** resu
3d50: 6c 74 20 72 6f 77 20 69 73 20 4e 55 4c 4c 20 74 lt row is NULL t
3d60: 68 65 6e 20 74 68 65 20 63 6f 72 72 65 73 70 6f hen the correspo
3d70: 6e 64 69 6e 67 20 73 74 72 69 6e 67 20 70 6f 69 nding string poi
3d80: 6e 74 65 72 20 66 6f 72 20 74 68 65 0a 2a 2a 20 nter for the.**
3d90: 73 71 6c 69 74 65 33 5f 65 78 65 63 28 29 20 63 sqlite3_exec() c
3da0: 61 6c 6c 62 61 63 6b 20 69 73 20 61 20 4e 55 4c allback is a NUL
3db0: 4c 20 70 6f 69 6e 74 65 72 2e 20 20 5e 54 68 65 L pointer. ^The
3dc0: 20 34 74 68 20 61 72 67 75 6d 65 6e 74 20 74 6f 4th argument to
3dd0: 20 74 68 65 0a 2a 2a 20 73 71 6c 69 74 65 33 5f the.** sqlite3_
3de0: 65 78 65 63 28 29 20 63 61 6c 6c 62 61 63 6b 20 exec() callback
3df0: 69 73 20 61 6e 20 61 72 72 61 79 20 6f 66 20 70 is an array of p
3e00: 6f 69 6e 74 65 72 73 20 74 6f 20 73 74 72 69 6e ointers to strin
3e10: 67 73 20 77 68 65 72 65 20 65 61 63 68 0a 2a 2a gs where each.**
3e20: 20 65 6e 74 72 79 20 72 65 70 72 65 73 65 6e 74 entry represent
3e30: 73 20 74 68 65 20 6e 61 6d 65 20 6f 66 20 63 6f s the name of co
3e40: 72 72 65 73 70 6f 6e 64 69 6e 67 20 72 65 73 75 rresponding resu
3e50: 6c 74 20 63 6f 6c 75 6d 6e 20 61 73 20 6f 62 74 lt column as obt
3e60: 61 69 6e 65 64 0a 2a 2a 20 66 72 6f 6d 20 5b 73 ained.** from [s
3e70: 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 6e 61 qlite3_column_na
3e80: 6d 65 28 29 5d 2e 0a 2a 2a 0a 2a 2a 20 5e 49 66 me()]..**.** ^If
3e90: 20 74 68 65 20 32 6e 64 20 70 61 72 61 6d 65 74 the 2nd paramet
3ea0: 65 72 20 74 6f 20 73 71 6c 69 74 65 33 5f 65 78 er to sqlite3_ex
3eb0: 65 63 28 29 20 69 73 20 61 20 4e 55 4c 4c 20 70 ec() is a NULL p
3ec0: 6f 69 6e 74 65 72 2c 20 61 20 70 6f 69 6e 74 65 ointer, a pointe
3ed0: 72 0a 2a 2a 20 74 6f 20 61 6e 20 65 6d 70 74 79 r.** to an empty
3ee0: 20 73 74 72 69 6e 67 2c 20 6f 72 20 61 20 70 6f string, or a po
3ef0: 69 6e 74 65 72 20 74 68 61 74 20 63 6f 6e 74 61 inter that conta
3f00: 69 6e 73 20 6f 6e 6c 79 20 77 68 69 74 65 73 70 ins only whitesp
3f10: 61 63 65 20 61 6e 64 2f 6f 72 20 0a 2a 2a 20 53 ace and/or .** S
3f20: 51 4c 20 63 6f 6d 6d 65 6e 74 73 2c 20 74 68 65 QL comments, the
3f30: 6e 20 6e 6f 20 53 51 4c 20 73 74 61 74 65 6d 65 n no SQL stateme
3f40: 6e 74 73 20 61 72 65 20 65 76 61 6c 75 61 74 65 nts are evaluate
3f50: 64 20 61 6e 64 20 74 68 65 20 64 61 74 61 62 61 d and the databa
3f60: 73 65 0a 2a 2a 20 69 73 20 6e 6f 74 20 63 68 61 se.** is not cha
3f70: 6e 67 65 64 2e 0a 2a 2a 0a 2a 2a 20 52 65 73 74 nged..**.** Rest
3f80: 72 69 63 74 69 6f 6e 73 3a 0a 2a 2a 0a 2a 2a 20 rictions:.**.**
3f90: 3c 75 6c 3e 0a 2a 2a 20 3c 6c 69 3e 20 54 68 65 <ul>.** <li> The
3fa0: 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 6d 75 73 application mus
3fb0: 74 20 65 6e 73 75 72 65 20 74 68 61 74 20 74 68 t ensure that th
3fc0: 65 20 31 73 74 20 70 61 72 61 6d 65 74 65 72 20 e 1st parameter
3fd0: 74 6f 20 73 71 6c 69 74 65 33 5f 65 78 65 63 28 to sqlite3_exec(
3fe0: 29 0a 2a 2a 20 20 20 20 20 20 69 73 20 61 20 76 ).** is a v
3ff0: 61 6c 69 64 20 61 6e 64 20 6f 70 65 6e 20 5b 64 alid and open [d
4000: 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 atabase connecti
4010: 6f 6e 5d 2e 0a 2a 2a 20 3c 6c 69 3e 20 54 68 65 on]..** <li> The
4020: 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 6d 75 73 application mus
4030: 74 20 6e 6f 74 20 63 6c 6f 73 65 20 74 68 65 20 t not close the
4040: 5b 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 [database connec
4050: 74 69 6f 6e 5d 20 73 70 65 63 69 66 69 65 64 20 tion] specified
4060: 62 79 0a 2a 2a 20 20 20 20 20 20 74 68 65 20 31 by.** the 1
4070: 73 74 20 70 61 72 61 6d 65 74 65 72 20 74 6f 20 st parameter to
4080: 73 71 6c 69 74 65 33 5f 65 78 65 63 28 29 20 77 sqlite3_exec() w
4090: 68 69 6c 65 20 73 71 6c 69 74 65 33 5f 65 78 65 hile sqlite3_exe
40a0: 63 28 29 20 69 73 20 72 75 6e 6e 69 6e 67 2e 0a c() is running..
40b0: 2a 2a 20 3c 6c 69 3e 20 54 68 65 20 61 70 70 6c ** <li> The appl
40c0: 69 63 61 74 69 6f 6e 20 6d 75 73 74 20 6e 6f 74 ication must not
40d0: 20 6d 6f 64 69 66 79 20 74 68 65 20 53 51 4c 20 modify the SQL
40e0: 73 74 61 74 65 6d 65 6e 74 20 74 65 78 74 20 70 statement text p
40f0: 61 73 73 65 64 20 69 6e 74 6f 0a 2a 2a 20 20 20 assed into.**
4100: 20 20 20 74 68 65 20 32 6e 64 20 70 61 72 61 6d the 2nd param
4110: 65 74 65 72 20 6f 66 20 73 71 6c 69 74 65 33 5f eter of sqlite3_
4120: 65 78 65 63 28 29 20 77 68 69 6c 65 20 73 71 6c exec() while sql
4130: 69 74 65 33 5f 65 78 65 63 28 29 20 69 73 20 72 ite3_exec() is r
4140: 75 6e 6e 69 6e 67 2e 0a 2a 2a 20 3c 2f 75 6c 3e unning..** </ul>
4150: 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f .*/.int sqlite3_
4160: 65 78 65 63 28 0a 20 20 73 71 6c 69 74 65 33 2a exec(. sqlite3*
4170: 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ,
4180: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4190: 20 20 20 2f 2a 20 41 6e 20 6f 70 65 6e 20 64 61 /* An open da
41a0: 74 61 62 61 73 65 20 2a 2f 0a 20 20 63 6f 6e 73 tabase */. cons
41b0: 74 20 63 68 61 72 20 2a 73 71 6c 2c 20 20 20 20 t char *sql,
41c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
41d0: 20 20 20 20 20 20 20 2f 2a 20 53 51 4c 20 74 6f /* SQL to
41e0: 20 62 65 20 65 76 61 6c 75 61 74 65 64 20 2a 2f be evaluated */
41f0: 0a 20 20 69 6e 74 20 28 2a 63 61 6c 6c 62 61 63 . int (*callbac
4200: 6b 29 28 76 6f 69 64 2a 2c 69 6e 74 2c 63 68 61 k)(void*,int,cha
4210: 72 2a 2a 2c 63 68 61 72 2a 2a 29 2c 20 20 2f 2a r**,char**), /*
4220: 20 43 61 6c 6c 62 61 63 6b 20 66 75 6e 63 74 69 Callback functi
4230: 6f 6e 20 2a 2f 0a 20 20 76 6f 69 64 20 2a 2c 20 on */. void *,
4240: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4250: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4260: 20 20 20 2f 2a 20 31 73 74 20 61 72 67 75 6d 65 /* 1st argume
4270: 6e 74 20 74 6f 20 63 61 6c 6c 62 61 63 6b 20 2a nt to callback *
4280: 2f 0a 20 20 63 68 61 72 20 2a 2a 65 72 72 6d 73 /. char **errms
4290: 67 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 g
42a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f /
42b0: 2a 20 45 72 72 6f 72 20 6d 73 67 20 77 72 69 74 * Error msg writ
42c0: 74 65 6e 20 68 65 72 65 20 2a 2f 0a 29 3b 0a 0a ten here */.);..
42d0: 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 /*.** CAPI3REF:
42e0: 52 65 73 75 6c 74 20 43 6f 64 65 73 0a 2a 2a 20 Result Codes.**
42f0: 4b 45 59 57 4f 52 44 53 3a 20 7b 72 65 73 75 6c KEYWORDS: {resul
4300: 74 20 63 6f 64 65 20 64 65 66 69 6e 69 74 69 6f t code definitio
4310: 6e 73 7d 0a 2a 2a 0a 2a 2a 20 4d 61 6e 79 20 53 ns}.**.** Many S
4320: 51 4c 69 74 65 20 66 75 6e 63 74 69 6f 6e 73 20 QLite functions
4330: 72 65 74 75 72 6e 20 61 6e 20 69 6e 74 65 67 65 return an intege
4340: 72 20 72 65 73 75 6c 74 20 63 6f 64 65 20 66 72 r result code fr
4350: 6f 6d 20 74 68 65 20 73 65 74 20 73 68 6f 77 6e om the set shown
4360: 0a 2a 2a 20 68 65 72 65 20 69 6e 20 6f 72 64 65 .** here in orde
4370: 72 20 74 6f 20 69 6e 64 69 63 61 74 65 20 73 75 r to indicate su
4380: 63 63 65 73 73 20 6f 72 20 66 61 69 6c 75 72 65 ccess or failure
4390: 2e 0a 2a 2a 0a 2a 2a 20 4e 65 77 20 65 72 72 6f ..**.** New erro
43a0: 72 20 63 6f 64 65 73 20 6d 61 79 20 62 65 20 61 r codes may be a
43b0: 64 64 65 64 20 69 6e 20 66 75 74 75 72 65 20 76 dded in future v
43c0: 65 72 73 69 6f 6e 73 20 6f 66 20 53 51 4c 69 74 ersions of SQLit
43d0: 65 2e 0a 2a 2a 0a 2a 2a 20 53 65 65 20 61 6c 73 e..**.** See als
43e0: 6f 3a 20 5b 65 78 74 65 6e 64 65 64 20 72 65 73 o: [extended res
43f0: 75 6c 74 20 63 6f 64 65 20 64 65 66 69 6e 69 74 ult code definit
4400: 69 6f 6e 73 5d 0a 2a 2f 0a 23 64 65 66 69 6e 65 ions].*/.#define
4410: 20 53 51 4c 49 54 45 5f 4f 4b 20 20 20 20 20 20 SQLITE_OK
4420: 20 20 20 20 20 30 20 20 20 2f 2a 20 53 75 63 63 0 /* Succ
4430: 65 73 73 66 75 6c 20 72 65 73 75 6c 74 20 2a 2f essful result */
4440: 0a 2f 2a 20 62 65 67 69 6e 6e 69 6e 67 2d 6f 66 ./* beginning-of
4450: 2d 65 72 72 6f 72 2d 63 6f 64 65 73 20 2a 2f 0a -error-codes */.
4460: 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 45 #define SQLITE_E
4470: 52 52 4f 52 20 20 20 20 20 20 20 20 31 20 20 20 RROR 1
4480: 2f 2a 20 53 51 4c 20 65 72 72 6f 72 20 6f 72 20 /* SQL error or
4490: 6d 69 73 73 69 6e 67 20 64 61 74 61 62 61 73 65 missing database
44a0: 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 */.#define SQLI
44b0: 54 45 5f 49 4e 54 45 52 4e 41 4c 20 20 20 20 20 TE_INTERNAL
44c0: 32 20 20 20 2f 2a 20 49 6e 74 65 72 6e 61 6c 20 2 /* Internal
44d0: 6c 6f 67 69 63 20 65 72 72 6f 72 20 69 6e 20 53 logic error in S
44e0: 51 4c 69 74 65 20 2a 2f 0a 23 64 65 66 69 6e 65 QLite */.#define
44f0: 20 53 51 4c 49 54 45 5f 50 45 52 4d 20 20 20 20 SQLITE_PERM
4500: 20 20 20 20 20 33 20 20 20 2f 2a 20 41 63 63 65 3 /* Acce
4510: 73 73 20 70 65 72 6d 69 73 73 69 6f 6e 20 64 65 ss permission de
4520: 6e 69 65 64 20 2a 2f 0a 23 64 65 66 69 6e 65 20 nied */.#define
4530: 53 51 4c 49 54 45 5f 41 42 4f 52 54 20 20 20 20 SQLITE_ABORT
4540: 20 20 20 20 34 20 20 20 2f 2a 20 43 61 6c 6c 62 4 /* Callb
4550: 61 63 6b 20 72 6f 75 74 69 6e 65 20 72 65 71 75 ack routine requ
4560: 65 73 74 65 64 20 61 6e 20 61 62 6f 72 74 20 2a ested an abort *
4570: 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 /.#define SQLITE
4580: 5f 42 55 53 59 20 20 20 20 20 20 20 20 20 35 20 _BUSY 5
4590: 20 20 2f 2a 20 54 68 65 20 64 61 74 61 62 61 73 /* The databas
45a0: 65 20 66 69 6c 65 20 69 73 20 6c 6f 63 6b 65 64 e file is locked
45b0: 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 */.#define SQLI
45c0: 54 45 5f 4c 4f 43 4b 45 44 20 20 20 20 20 20 20 TE_LOCKED
45d0: 36 20 20 20 2f 2a 20 41 20 74 61 62 6c 65 20 69 6 /* A table i
45e0: 6e 20 74 68 65 20 64 61 74 61 62 61 73 65 20 69 n the database i
45f0: 73 20 6c 6f 63 6b 65 64 20 2a 2f 0a 23 64 65 66 s locked */.#def
4600: 69 6e 65 20 53 51 4c 49 54 45 5f 4e 4f 4d 45 4d ine SQLITE_NOMEM
4610: 20 20 20 20 20 20 20 20 37 20 20 20 2f 2a 20 41 7 /* A
4620: 20 6d 61 6c 6c 6f 63 28 29 20 66 61 69 6c 65 64 malloc() failed
4630: 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 */.#define SQLI
4640: 54 45 5f 52 45 41 44 4f 4e 4c 59 20 20 20 20 20 TE_READONLY
4650: 38 20 20 20 2f 2a 20 41 74 74 65 6d 70 74 20 74 8 /* Attempt t
4660: 6f 20 77 72 69 74 65 20 61 20 72 65 61 64 6f 6e o write a readon
4670: 6c 79 20 64 61 74 61 62 61 73 65 20 2a 2f 0a 23 ly database */.#
4680: 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 49 4e define SQLITE_IN
4690: 54 45 52 52 55 50 54 20 20 20 20 39 20 20 20 2f TERRUPT 9 /
46a0: 2a 20 4f 70 65 72 61 74 69 6f 6e 20 74 65 72 6d * Operation term
46b0: 69 6e 61 74 65 64 20 62 79 20 73 71 6c 69 74 65 inated by sqlite
46c0: 33 5f 69 6e 74 65 72 72 75 70 74 28 29 2a 2f 0a 3_interrupt()*/.
46d0: 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 49 #define SQLITE_I
46e0: 4f 45 52 52 20 20 20 20 20 20 20 31 30 20 20 20 OERR 10
46f0: 2f 2a 20 53 6f 6d 65 20 6b 69 6e 64 20 6f 66 20 /* Some kind of
4700: 64 69 73 6b 20 49 2f 4f 20 65 72 72 6f 72 20 6f disk I/O error o
4710: 63 63 75 72 72 65 64 20 2a 2f 0a 23 64 65 66 69 ccurred */.#defi
4720: 6e 65 20 53 51 4c 49 54 45 5f 43 4f 52 52 55 50 ne SQLITE_CORRUP
4730: 54 20 20 20 20 20 31 31 20 20 20 2f 2a 20 54 68 T 11 /* Th
4740: 65 20 64 61 74 61 62 61 73 65 20 64 69 73 6b 20 e database disk
4750: 69 6d 61 67 65 20 69 73 20 6d 61 6c 66 6f 72 6d image is malform
4760: 65 64 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 ed */.#define SQ
4770: 4c 49 54 45 5f 4e 4f 54 46 4f 55 4e 44 20 20 20 LITE_NOTFOUND
4780: 20 31 32 20 20 20 2f 2a 20 55 6e 6b 6e 6f 77 6e 12 /* Unknown
4790: 20 6f 70 63 6f 64 65 20 69 6e 20 73 71 6c 69 74 opcode in sqlit
47a0: 65 33 5f 66 69 6c 65 5f 63 6f 6e 74 72 6f 6c 28 e3_file_control(
47b0: 29 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c ) */.#define SQL
47c0: 49 54 45 5f 46 55 4c 4c 20 20 20 20 20 20 20 20 ITE_FULL
47d0: 31 33 20 20 20 2f 2a 20 49 6e 73 65 72 74 69 6f 13 /* Insertio
47e0: 6e 20 66 61 69 6c 65 64 20 62 65 63 61 75 73 65 n failed because
47f0: 20 64 61 74 61 62 61 73 65 20 69 73 20 66 75 6c database is ful
4800: 6c 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c l */.#define SQL
4810: 49 54 45 5f 43 41 4e 54 4f 50 45 4e 20 20 20 20 ITE_CANTOPEN
4820: 31 34 20 20 20 2f 2a 20 55 6e 61 62 6c 65 20 74 14 /* Unable t
4830: 6f 20 6f 70 65 6e 20 74 68 65 20 64 61 74 61 62 o open the datab
4840: 61 73 65 20 66 69 6c 65 20 2a 2f 0a 23 64 65 66 ase file */.#def
4850: 69 6e 65 20 53 51 4c 49 54 45 5f 50 52 4f 54 4f ine SQLITE_PROTO
4860: 43 4f 4c 20 20 20 20 31 35 20 20 20 2f 2a 20 44 COL 15 /* D
4870: 61 74 61 62 61 73 65 20 6c 6f 63 6b 20 70 72 6f atabase lock pro
4880: 74 6f 63 6f 6c 20 65 72 72 6f 72 20 2a 2f 0a 23 tocol error */.#
4890: 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 45 4d define SQLITE_EM
48a0: 50 54 59 20 20 20 20 20 20 20 31 36 20 20 20 2f PTY 16 /
48b0: 2a 20 44 61 74 61 62 61 73 65 20 69 73 20 65 6d * Database is em
48c0: 70 74 79 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 pty */.#define S
48d0: 51 4c 49 54 45 5f 53 43 48 45 4d 41 20 20 20 20 QLITE_SCHEMA
48e0: 20 20 31 37 20 20 20 2f 2a 20 54 68 65 20 64 61 17 /* The da
48f0: 74 61 62 61 73 65 20 73 63 68 65 6d 61 20 63 68 tabase schema ch
4900: 61 6e 67 65 64 20 2a 2f 0a 23 64 65 66 69 6e 65 anged */.#define
4910: 20 53 51 4c 49 54 45 5f 54 4f 4f 42 49 47 20 20 SQLITE_TOOBIG
4920: 20 20 20 20 31 38 20 20 20 2f 2a 20 53 74 72 69 18 /* Stri
4930: 6e 67 20 6f 72 20 42 4c 4f 42 20 65 78 63 65 65 ng or BLOB excee
4940: 64 73 20 73 69 7a 65 20 6c 69 6d 69 74 20 2a 2f ds size limit */
4950: 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f .#define SQLITE_
4960: 43 4f 4e 53 54 52 41 49 4e 54 20 20 31 39 20 20 CONSTRAINT 19
4970: 20 2f 2a 20 41 62 6f 72 74 20 64 75 65 20 74 6f /* Abort due to
4980: 20 63 6f 6e 73 74 72 61 69 6e 74 20 76 69 6f 6c constraint viol
4990: 61 74 69 6f 6e 20 2a 2f 0a 23 64 65 66 69 6e 65 ation */.#define
49a0: 20 53 51 4c 49 54 45 5f 4d 49 53 4d 41 54 43 48 SQLITE_MISMATCH
49b0: 20 20 20 20 32 30 20 20 20 2f 2a 20 44 61 74 61 20 /* Data
49c0: 20 74 79 70 65 20 6d 69 73 6d 61 74 63 68 20 2a type mismatch *
49d0: 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 /.#define SQLITE
49e0: 5f 4d 49 53 55 53 45 20 20 20 20 20 20 32 31 20 _MISUSE 21
49f0: 20 20 2f 2a 20 4c 69 62 72 61 72 79 20 75 73 65 /* Library use
4a00: 64 20 69 6e 63 6f 72 72 65 63 74 6c 79 20 2a 2f d incorrectly */
4a10: 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f .#define SQLITE_
4a20: 4e 4f 4c 46 53 20 20 20 20 20 20 20 32 32 20 20 NOLFS 22
4a30: 20 2f 2a 20 55 73 65 73 20 4f 53 20 66 65 61 74 /* Uses OS feat
4a40: 75 72 65 73 20 6e 6f 74 20 73 75 70 70 6f 72 74 ures not support
4a50: 65 64 20 6f 6e 20 68 6f 73 74 20 2a 2f 0a 23 64 ed on host */.#d
4a60: 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 41 55 54 efine SQLITE_AUT
4a70: 48 20 20 20 20 20 20 20 20 32 33 20 20 20 2f 2a H 23 /*
4a80: 20 41 75 74 68 6f 72 69 7a 61 74 69 6f 6e 20 64 Authorization d
4a90: 65 6e 69 65 64 20 2a 2f 0a 23 64 65 66 69 6e 65 enied */.#define
4aa0: 20 53 51 4c 49 54 45 5f 46 4f 52 4d 41 54 20 20 SQLITE_FORMAT
4ab0: 20 20 20 20 32 34 20 20 20 2f 2a 20 41 75 78 69 24 /* Auxi
4ac0: 6c 69 61 72 79 20 64 61 74 61 62 61 73 65 20 66 liary database f
4ad0: 6f 72 6d 61 74 20 65 72 72 6f 72 20 2a 2f 0a 23 ormat error */.#
4ae0: 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 52 41 define SQLITE_RA
4af0: 4e 47 45 20 20 20 20 20 20 20 32 35 20 20 20 2f NGE 25 /
4b00: 2a 20 32 6e 64 20 70 61 72 61 6d 65 74 65 72 20 * 2nd parameter
4b10: 74 6f 20 73 71 6c 69 74 65 33 5f 62 69 6e 64 20 to sqlite3_bind
4b20: 6f 75 74 20 6f 66 20 72 61 6e 67 65 20 2a 2f 0a out of range */.
4b30: 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 4e #define SQLITE_N
4b40: 4f 54 41 44 42 20 20 20 20 20 20 32 36 20 20 20 OTADB 26
4b50: 2f 2a 20 46 69 6c 65 20 6f 70 65 6e 65 64 20 74 /* File opened t
4b60: 68 61 74 20 69 73 20 6e 6f 74 20 61 20 64 61 74 hat is not a dat
4b70: 61 62 61 73 65 20 66 69 6c 65 20 2a 2f 0a 23 64 abase file */.#d
4b80: 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 4e 4f 54 efine SQLITE_NOT
4b90: 49 43 45 20 20 20 20 20 20 32 37 20 20 20 2f 2a ICE 27 /*
4ba0: 20 4e 6f 74 69 66 69 63 61 74 69 6f 6e 73 20 66 Notifications f
4bb0: 72 6f 6d 20 73 71 6c 69 74 65 33 5f 6c 6f 67 28 rom sqlite3_log(
4bc0: 29 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c ) */.#define SQL
4bd0: 49 54 45 5f 57 41 52 4e 49 4e 47 20 20 20 20 20 ITE_WARNING
4be0: 32 38 20 20 20 2f 2a 20 57 61 72 6e 69 6e 67 73 28 /* Warnings
4bf0: 20 66 72 6f 6d 20 73 71 6c 69 74 65 33 5f 6c 6f from sqlite3_lo
4c00: 67 28 29 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 g() */.#define S
4c10: 51 4c 49 54 45 5f 52 4f 57 20 20 20 20 20 20 20 QLITE_ROW
4c20: 20 20 31 30 30 20 20 2f 2a 20 73 71 6c 69 74 65 100 /* sqlite
4c30: 33 5f 73 74 65 70 28 29 20 68 61 73 20 61 6e 6f 3_step() has ano
4c40: 74 68 65 72 20 72 6f 77 20 72 65 61 64 79 20 2a ther row ready *
4c50: 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 /.#define SQLITE
4c60: 5f 44 4f 4e 45 20 20 20 20 20 20 20 20 31 30 31 _DONE 101
4c70: 20 20 2f 2a 20 73 71 6c 69 74 65 33 5f 73 74 65 /* sqlite3_ste
4c80: 70 28 29 20 68 61 73 20 66 69 6e 69 73 68 65 64 p() has finished
4c90: 20 65 78 65 63 75 74 69 6e 67 20 2a 2f 0a 2f 2a executing */./*
4ca0: 20 65 6e 64 2d 6f 66 2d 65 72 72 6f 72 2d 63 6f end-of-error-co
4cb0: 64 65 73 20 2a 2f 0a 0a 2f 2a 0a 2a 2a 20 43 41 des */../*.** CA
4cc0: 50 49 33 52 45 46 3a 20 45 78 74 65 6e 64 65 64 PI3REF: Extended
4cd0: 20 52 65 73 75 6c 74 20 43 6f 64 65 73 0a 2a 2a Result Codes.**
4ce0: 20 4b 45 59 57 4f 52 44 53 3a 20 7b 65 78 74 65 KEYWORDS: {exte
4cf0: 6e 64 65 64 20 72 65 73 75 6c 74 20 63 6f 64 65 nded result code
4d00: 20 64 65 66 69 6e 69 74 69 6f 6e 73 7d 0a 2a 2a definitions}.**
4d10: 0a 2a 2a 20 49 6e 20 69 74 73 20 64 65 66 61 75 .** In its defau
4d20: 6c 74 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e lt configuration
4d30: 2c 20 53 51 4c 69 74 65 20 41 50 49 20 72 6f 75 , SQLite API rou
4d40: 74 69 6e 65 73 20 72 65 74 75 72 6e 20 6f 6e 65 tines return one
4d50: 20 6f 66 20 33 30 20 69 6e 74 65 67 65 72 0a 2a of 30 integer.*
4d60: 2a 20 5b 72 65 73 75 6c 74 20 63 6f 64 65 73 5d * [result codes]
4d70: 2e 20 20 48 6f 77 65 76 65 72 2c 20 65 78 70 65 . However, expe
4d80: 72 69 65 6e 63 65 20 68 61 73 20 73 68 6f 77 6e rience has shown
4d90: 20 74 68 61 74 20 6d 61 6e 79 20 6f 66 0a 2a 2a that many of.**
4da0: 20 74 68 65 73 65 20 72 65 73 75 6c 74 20 63 6f these result co
4db0: 64 65 73 20 61 72 65 20 74 6f 6f 20 63 6f 61 72 des are too coar
4dc0: 73 65 2d 67 72 61 69 6e 65 64 2e 20 20 54 68 65 se-grained. The
4dd0: 79 20 64 6f 20 6e 6f 74 20 70 72 6f 76 69 64 65 y do not provide
4de0: 20 61 73 0a 2a 2a 20 6d 75 63 68 20 69 6e 66 6f as.** much info
4df0: 72 6d 61 74 69 6f 6e 20 61 62 6f 75 74 20 70 72 rmation about pr
4e00: 6f 62 6c 65 6d 73 20 61 73 20 70 72 6f 67 72 61 oblems as progra
4e10: 6d 6d 65 72 73 20 6d 69 67 68 74 20 6c 69 6b 65 mmers might like
4e20: 2e 20 20 49 6e 20 61 6e 20 65 66 66 6f 72 74 20 . In an effort
4e30: 74 6f 0a 2a 2a 20 61 64 64 72 65 73 73 20 74 68 to.** address th
4e40: 69 73 2c 20 6e 65 77 65 72 20 76 65 72 73 69 6f is, newer versio
4e50: 6e 73 20 6f 66 20 53 51 4c 69 74 65 20 28 76 65 ns of SQLite (ve
4e60: 72 73 69 6f 6e 20 33 2e 33 2e 38 20 5b 64 61 74 rsion 3.3.8 [dat
4e70: 65 6f 66 3a 33 2e 33 2e 38 5d 0a 2a 2a 20 61 6e eof:3.3.8].** an
4e80: 64 20 6c 61 74 65 72 29 20 69 6e 63 6c 75 64 65 d later) include
4e90: 0a 2a 2a 20 73 75 70 70 6f 72 74 20 66 6f 72 20 .** support for
4ea0: 61 64 64 69 74 69 6f 6e 61 6c 20 72 65 73 75 6c additional resul
4eb0: 74 20 63 6f 64 65 73 20 74 68 61 74 20 70 72 6f t codes that pro
4ec0: 76 69 64 65 20 6d 6f 72 65 20 64 65 74 61 69 6c vide more detail
4ed0: 65 64 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 0a 2a ed information.*
4ee0: 2a 20 61 62 6f 75 74 20 65 72 72 6f 72 73 2e 20 * about errors.
4ef0: 54 68 65 73 65 20 5b 65 78 74 65 6e 64 65 64 20 These [extended
4f00: 72 65 73 75 6c 74 20 63 6f 64 65 73 5d 20 61 72 result codes] ar
4f10: 65 20 65 6e 61 62 6c 65 64 20 6f 72 20 64 69 73 e enabled or dis
4f20: 61 62 6c 65 64 0a 2a 2a 20 6f 6e 20 61 20 70 65 abled.** on a pe
4f30: 72 20 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 r database conne
4f40: 63 74 69 6f 6e 20 62 61 73 69 73 20 75 73 69 6e ction basis usin
4f50: 67 20 74 68 65 0a 2a 2a 20 5b 73 71 6c 69 74 65 g the.** [sqlite
4f60: 33 5f 65 78 74 65 6e 64 65 64 5f 72 65 73 75 6c 3_extended_resul
4f70: 74 5f 63 6f 64 65 73 28 29 5d 20 41 50 49 2e 20 t_codes()] API.
4f80: 20 4f 72 2c 20 74 68 65 20 65 78 74 65 6e 64 65 Or, the extende
4f90: 64 20 63 6f 64 65 20 66 6f 72 0a 2a 2a 20 74 68 d code for.** th
4fa0: 65 20 6d 6f 73 74 20 72 65 63 65 6e 74 20 65 72 e most recent er
4fb0: 72 6f 72 20 63 61 6e 20 62 65 20 6f 62 74 61 69 ror can be obtai
4fc0: 6e 65 64 20 75 73 69 6e 67 0a 2a 2a 20 5b 73 71 ned using.** [sq
4fd0: 6c 69 74 65 33 5f 65 78 74 65 6e 64 65 64 5f 65 lite3_extended_e
4fe0: 72 72 63 6f 64 65 28 29 5d 2e 0a 2a 2f 0a 23 64 rrcode()]..*/.#d
4ff0: 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 49 4f 45 efine SQLITE_IOE
5000: 52 52 5f 52 45 41 44 20 20 20 20 20 20 20 20 20 RR_READ
5010: 20 20 20 20 20 28 53 51 4c 49 54 45 5f 49 4f 45 (SQLITE_IOE
5020: 52 52 20 7c 20 28 31 3c 3c 38 29 29 0a 23 64 65 RR | (1<<8)).#de
5030: 66 69 6e 65 20 53 51 4c 49 54 45 5f 49 4f 45 52 fine SQLITE_IOER
5040: 52 5f 53 48 4f 52 54 5f 52 45 41 44 20 20 20 20 R_SHORT_READ
5050: 20 20 20 20 28 53 51 4c 49 54 45 5f 49 4f 45 52 (SQLITE_IOER
5060: 52 20 7c 20 28 32 3c 3c 38 29 29 0a 23 64 65 66 R | (2<<8)).#def
5070: 69 6e 65 20 53 51 4c 49 54 45 5f 49 4f 45 52 52 ine SQLITE_IOERR
5080: 5f 57 52 49 54 45 20 20 20 20 20 20 20 20 20 20 _WRITE
5090: 20 20 20 28 53 51 4c 49 54 45 5f 49 4f 45 52 52 (SQLITE_IOERR
50a0: 20 7c 20 28 33 3c 3c 38 29 29 0a 23 64 65 66 69 | (3<<8)).#defi
50b0: 6e 65 20 53 51 4c 49 54 45 5f 49 4f 45 52 52 5f ne SQLITE_IOERR_
50c0: 46 53 59 4e 43 20 20 20 20 20 20 20 20 20 20 20 FSYNC
50d0: 20 20 28 53 51 4c 49 54 45 5f 49 4f 45 52 52 20 (SQLITE_IOERR
50e0: 7c 20 28 34 3c 3c 38 29 29 0a 23 64 65 66 69 6e | (4<<8)).#defin
50f0: 65 20 53 51 4c 49 54 45 5f 49 4f 45 52 52 5f 44 e SQLITE_IOERR_D
5100: 49 52 5f 46 53 59 4e 43 20 20 20 20 20 20 20 20 IR_FSYNC
5110: 20 28 53 51 4c 49 54 45 5f 49 4f 45 52 52 20 7c (SQLITE_IOERR |
5120: 20 28 35 3c 3c 38 29 29 0a 23 64 65 66 69 6e 65 (5<<8)).#define
5130: 20 53 51 4c 49 54 45 5f 49 4f 45 52 52 5f 54 52 SQLITE_IOERR_TR
5140: 55 4e 43 41 54 45 20 20 20 20 20 20 20 20 20 20 UNCATE
5150: 28 53 51 4c 49 54 45 5f 49 4f 45 52 52 20 7c 20 (SQLITE_IOERR |
5160: 28 36 3c 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 (6<<8)).#define
5170: 53 51 4c 49 54 45 5f 49 4f 45 52 52 5f 46 53 54 SQLITE_IOERR_FST
5180: 41 54 20 20 20 20 20 20 20 20 20 20 20 20 20 28 AT (
5190: 53 51 4c 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 SQLITE_IOERR | (
51a0: 37 3c 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 7<<8)).#define S
51b0: 51 4c 49 54 45 5f 49 4f 45 52 52 5f 55 4e 4c 4f QLITE_IOERR_UNLO
51c0: 43 4b 20 20 20 20 20 20 20 20 20 20 20 20 28 53 CK (S
51d0: 51 4c 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 38 QLITE_IOERR | (8
51e0: 3c 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 <<8)).#define SQ
51f0: 4c 49 54 45 5f 49 4f 45 52 52 5f 52 44 4c 4f 43 LITE_IOERR_RDLOC
5200: 4b 20 20 20 20 20 20 20 20 20 20 20 20 28 53 51 K (SQ
5210: 4c 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 39 3c LITE_IOERR | (9<
5220: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
5230: 49 54 45 5f 49 4f 45 52 52 5f 44 45 4c 45 54 45 ITE_IOERR_DELETE
5240: 20 20 20 20 20 20 20 20 20 20 20 20 28 53 51 4c (SQL
5250: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 31 30 3c ITE_IOERR | (10<
5260: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
5270: 49 54 45 5f 49 4f 45 52 52 5f 42 4c 4f 43 4b 45 ITE_IOERR_BLOCKE
5280: 44 20 20 20 20 20 20 20 20 20 20 20 28 53 51 4c D (SQL
5290: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 31 31 3c ITE_IOERR | (11<
52a0: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
52b0: 49 54 45 5f 49 4f 45 52 52 5f 4e 4f 4d 45 4d 20 ITE_IOERR_NOMEM
52c0: 20 20 20 20 20 20 20 20 20 20 20 20 28 53 51 4c (SQL
52d0: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 31 32 3c ITE_IOERR | (12<
52e0: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
52f0: 49 54 45 5f 49 4f 45 52 52 5f 41 43 43 45 53 53 ITE_IOERR_ACCESS
5300: 20 20 20 20 20 20 20 20 20 20 20 20 28 53 51 4c (SQL
5310: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 31 33 3c ITE_IOERR | (13<
5320: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
5330: 49 54 45 5f 49 4f 45 52 52 5f 43 48 45 43 4b 52 ITE_IOERR_CHECKR
5340: 45 53 45 52 56 45 44 4c 4f 43 4b 20 28 53 51 4c ESERVEDLOCK (SQL
5350: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 31 34 3c ITE_IOERR | (14<
5360: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
5370: 49 54 45 5f 49 4f 45 52 52 5f 4c 4f 43 4b 20 20 ITE_IOERR_LOCK
5380: 20 20 20 20 20 20 20 20 20 20 20 20 28 53 51 4c (SQL
5390: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 31 35 3c ITE_IOERR | (15<
53a0: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
53b0: 49 54 45 5f 49 4f 45 52 52 5f 43 4c 4f 53 45 20 ITE_IOERR_CLOSE
53c0: 20 20 20 20 20 20 20 20 20 20 20 20 28 53 51 4c (SQL
53d0: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 31 36 3c ITE_IOERR | (16<
53e0: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
53f0: 49 54 45 5f 49 4f 45 52 52 5f 44 49 52 5f 43 4c ITE_IOERR_DIR_CL
5400: 4f 53 45 20 20 20 20 20 20 20 20 20 28 53 51 4c OSE (SQL
5410: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 31 37 3c ITE_IOERR | (17<
5420: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
5430: 49 54 45 5f 49 4f 45 52 52 5f 53 48 4d 4f 50 45 ITE_IOERR_SHMOPE
5440: 4e 20 20 20 20 20 20 20 20 20 20 20 28 53 51 4c N (SQL
5450: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 31 38 3c ITE_IOERR | (18<
5460: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
5470: 49 54 45 5f 49 4f 45 52 52 5f 53 48 4d 53 49 5a ITE_IOERR_SHMSIZ
5480: 45 20 20 20 20 20 20 20 20 20 20 20 28 53 51 4c E (SQL
5490: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 31 39 3c ITE_IOERR | (19<
54a0: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
54b0: 49 54 45 5f 49 4f 45 52 52 5f 53 48 4d 4c 4f 43 ITE_IOERR_SHMLOC
54c0: 4b 20 20 20 20 20 20 20 20 20 20 20 28 53 51 4c K (SQL
54d0: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 32 30 3c ITE_IOERR | (20<
54e0: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
54f0: 49 54 45 5f 49 4f 45 52 52 5f 53 48 4d 4d 41 50 ITE_IOERR_SHMMAP
5500: 20 20 20 20 20 20 20 20 20 20 20 20 28 53 51 4c (SQL
5510: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 32 31 3c ITE_IOERR | (21<
5520: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
5530: 49 54 45 5f 49 4f 45 52 52 5f 53 45 45 4b 20 20 ITE_IOERR_SEEK
5540: 20 20 20 20 20 20 20 20 20 20 20 20 28 53 51 4c (SQL
5550: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 32 32 3c ITE_IOERR | (22<
5560: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
5570: 49 54 45 5f 49 4f 45 52 52 5f 44 45 4c 45 54 45 ITE_IOERR_DELETE
5580: 5f 4e 4f 45 4e 54 20 20 20 20 20 20 28 53 51 4c _NOENT (SQL
5590: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 32 33 3c ITE_IOERR | (23<
55a0: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
55b0: 49 54 45 5f 49 4f 45 52 52 5f 4d 4d 41 50 20 20 ITE_IOERR_MMAP
55c0: 20 20 20 20 20 20 20 20 20 20 20 20 28 53 51 4c (SQL
55d0: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 32 34 3c ITE_IOERR | (24<
55e0: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
55f0: 49 54 45 5f 49 4f 45 52 52 5f 47 45 54 54 45 4d ITE_IOERR_GETTEM
5600: 50 50 41 54 48 20 20 20 20 20 20 20 28 53 51 4c PPATH (SQL
5610: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 32 35 3c ITE_IOERR | (25<
5620: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
5630: 49 54 45 5f 49 4f 45 52 52 5f 43 4f 4e 56 50 41 ITE_IOERR_CONVPA
5640: 54 48 20 20 20 20 20 20 20 20 20 20 28 53 51 4c TH (SQL
5650: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 32 36 3c ITE_IOERR | (26<
5660: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
5670: 49 54 45 5f 49 4f 45 52 52 5f 56 4e 4f 44 45 20 ITE_IOERR_VNODE
5680: 20 20 20 20 20 20 20 20 20 20 20 20 28 53 51 4c (SQL
5690: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 32 37 3c ITE_IOERR | (27<
56a0: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
56b0: 49 54 45 5f 49 4f 45 52 52 5f 41 55 54 48 20 20 ITE_IOERR_AUTH
56c0: 20 20 20 20 20 20 20 20 20 20 20 20 28 53 51 4c (SQL
56d0: 49 54 45 5f 49 4f 45 52 52 20 7c 20 28 32 38 3c ITE_IOERR | (28<
56e0: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
56f0: 49 54 45 5f 4c 4f 43 4b 45 44 5f 53 48 41 52 45 ITE_LOCKED_SHARE
5700: 44 43 41 43 48 45 20 20 20 20 20 20 28 53 51 4c DCACHE (SQL
5710: 49 54 45 5f 4c 4f 43 4b 45 44 20 7c 20 20 28 31 ITE_LOCKED | (1
5720: 3c 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 <<8)).#define SQ
5730: 4c 49 54 45 5f 42 55 53 59 5f 52 45 43 4f 56 45 LITE_BUSY_RECOVE
5740: 52 59 20 20 20 20 20 20 20 20 20 20 20 28 53 51 RY (SQ
5750: 4c 49 54 45 5f 42 55 53 59 20 20 20 7c 20 20 28 LITE_BUSY | (
5760: 31 3c 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 1<<8)).#define S
5770: 51 4c 49 54 45 5f 42 55 53 59 5f 53 4e 41 50 53 QLITE_BUSY_SNAPS
5780: 48 4f 54 20 20 20 20 20 20 20 20 20 20 20 28 53 HOT (S
5790: 51 4c 49 54 45 5f 42 55 53 59 20 20 20 7c 20 20 QLITE_BUSY |
57a0: 28 32 3c 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 (2<<8)).#define
57b0: 53 51 4c 49 54 45 5f 43 41 4e 54 4f 50 45 4e 5f SQLITE_CANTOPEN_
57c0: 4e 4f 54 45 4d 50 44 49 52 20 20 20 20 20 20 28 NOTEMPDIR (
57d0: 53 51 4c 49 54 45 5f 43 41 4e 54 4f 50 45 4e 20 SQLITE_CANTOPEN
57e0: 7c 20 28 31 3c 3c 38 29 29 0a 23 64 65 66 69 6e | (1<<8)).#defin
57f0: 65 20 53 51 4c 49 54 45 5f 43 41 4e 54 4f 50 45 e SQLITE_CANTOPE
5800: 4e 5f 49 53 44 49 52 20 20 20 20 20 20 20 20 20 N_ISDIR
5810: 20 28 53 51 4c 49 54 45 5f 43 41 4e 54 4f 50 45 (SQLITE_CANTOPE
5820: 4e 20 7c 20 28 32 3c 3c 38 29 29 0a 23 64 65 66 N | (2<<8)).#def
5830: 69 6e 65 20 53 51 4c 49 54 45 5f 43 41 4e 54 4f ine SQLITE_CANTO
5840: 50 45 4e 5f 46 55 4c 4c 50 41 54 48 20 20 20 20 PEN_FULLPATH
5850: 20 20 20 28 53 51 4c 49 54 45 5f 43 41 4e 54 4f (SQLITE_CANTO
5860: 50 45 4e 20 7c 20 28 33 3c 3c 38 29 29 0a 23 64 PEN | (3<<8)).#d
5870: 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 43 41 4e efine SQLITE_CAN
5880: 54 4f 50 45 4e 5f 43 4f 4e 56 50 41 54 48 20 20 TOPEN_CONVPATH
5890: 20 20 20 20 20 28 53 51 4c 49 54 45 5f 43 41 4e (SQLITE_CAN
58a0: 54 4f 50 45 4e 20 7c 20 28 34 3c 3c 38 29 29 0a TOPEN | (4<<8)).
58b0: 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 43 #define SQLITE_C
58c0: 4f 52 52 55 50 54 5f 56 54 41 42 20 20 20 20 20 ORRUPT_VTAB
58d0: 20 20 20 20 20 20 20 28 53 51 4c 49 54 45 5f 43 (SQLITE_C
58e0: 4f 52 52 55 50 54 20 7c 20 28 31 3c 3c 38 29 29 ORRUPT | (1<<8))
58f0: 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f .#define SQLITE_
5900: 52 45 41 44 4f 4e 4c 59 5f 52 45 43 4f 56 45 52 READONLY_RECOVER
5910: 59 20 20 20 20 20 20 20 28 53 51 4c 49 54 45 5f Y (SQLITE_
5920: 52 45 41 44 4f 4e 4c 59 20 7c 20 28 31 3c 3c 38 READONLY | (1<<8
5930: 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 )).#define SQLIT
5940: 45 5f 52 45 41 44 4f 4e 4c 59 5f 43 41 4e 54 4c E_READONLY_CANTL
5950: 4f 43 4b 20 20 20 20 20 20 20 28 53 51 4c 49 54 OCK (SQLIT
5960: 45 5f 52 45 41 44 4f 4e 4c 59 20 7c 20 28 32 3c E_READONLY | (2<
5970: 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c <8)).#define SQL
5980: 49 54 45 5f 52 45 41 44 4f 4e 4c 59 5f 52 4f 4c ITE_READONLY_ROL
5990: 4c 42 41 43 4b 20 20 20 20 20 20 20 28 53 51 4c LBACK (SQL
59a0: 49 54 45 5f 52 45 41 44 4f 4e 4c 59 20 7c 20 28 ITE_READONLY | (
59b0: 33 3c 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 53 3<<8)).#define S
59c0: 51 4c 49 54 45 5f 52 45 41 44 4f 4e 4c 59 5f 44 QLITE_READONLY_D
59d0: 42 4d 4f 56 45 44 20 20 20 20 20 20 20 20 28 53 BMOVED (S
59e0: 51 4c 49 54 45 5f 52 45 41 44 4f 4e 4c 59 20 7c QLITE_READONLY |
59f0: 20 28 34 3c 3c 38 29 29 0a 23 64 65 66 69 6e 65 (4<<8)).#define
5a00: 20 53 51 4c 49 54 45 5f 41 42 4f 52 54 5f 52 4f SQLITE_ABORT_RO
5a10: 4c 4c 42 41 43 4b 20 20 20 20 20 20 20 20 20 20 LLBACK
5a20: 28 53 51 4c 49 54 45 5f 41 42 4f 52 54 20 7c 20 (SQLITE_ABORT |
5a30: 28 32 3c 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 (2<<8)).#define
5a40: 53 51 4c 49 54 45 5f 43 4f 4e 53 54 52 41 49 4e SQLITE_CONSTRAIN
5a50: 54 5f 43 48 45 43 4b 20 20 20 20 20 20 20 20 28 T_CHECK (
5a60: 53 51 4c 49 54 45 5f 43 4f 4e 53 54 52 41 49 4e SQLITE_CONSTRAIN
5a70: 54 20 7c 20 28 31 3c 3c 38 29 29 0a 23 64 65 66 T | (1<<8)).#def
5a80: 69 6e 65 20 53 51 4c 49 54 45 5f 43 4f 4e 53 54 ine SQLITE_CONST
5a90: 52 41 49 4e 54 5f 43 4f 4d 4d 49 54 48 4f 4f 4b RAINT_COMMITHOOK
5aa0: 20 20 20 28 53 51 4c 49 54 45 5f 43 4f 4e 53 54 (SQLITE_CONST
5ab0: 52 41 49 4e 54 20 7c 20 28 32 3c 3c 38 29 29 0a RAINT | (2<<8)).
5ac0: 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 43 #define SQLITE_C
5ad0: 4f 4e 53 54 52 41 49 4e 54 5f 46 4f 52 45 49 47 ONSTRAINT_FOREIG
5ae0: 4e 4b 45 59 20 20 20 28 53 51 4c 49 54 45 5f 43 NKEY (SQLITE_C
5af0: 4f 4e 53 54 52 41 49 4e 54 20 7c 20 28 33 3c 3c ONSTRAINT | (3<<
5b00: 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 8)).#define SQLI
5b10: 54 45 5f 43 4f 4e 53 54 52 41 49 4e 54 5f 46 55 TE_CONSTRAINT_FU
5b20: 4e 43 54 49 4f 4e 20 20 20 20 20 28 53 51 4c 49 NCTION (SQLI
5b30: 54 45 5f 43 4f 4e 53 54 52 41 49 4e 54 20 7c 20 TE_CONSTRAINT |
5b40: 28 34 3c 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 (4<<8)).#define
5b50: 53 51 4c 49 54 45 5f 43 4f 4e 53 54 52 41 49 4e SQLITE_CONSTRAIN
5b60: 54 5f 4e 4f 54 4e 55 4c 4c 20 20 20 20 20 20 28 T_NOTNULL (
5b70: 53 51 4c 49 54 45 5f 43 4f 4e 53 54 52 41 49 4e SQLITE_CONSTRAIN
5b80: 54 20 7c 20 28 35 3c 3c 38 29 29 0a 23 64 65 66 T | (5<<8)).#def
5b90: 69 6e 65 20 53 51 4c 49 54 45 5f 43 4f 4e 53 54 ine SQLITE_CONST
5ba0: 52 41 49 4e 54 5f 50 52 49 4d 41 52 59 4b 45 59 RAINT_PRIMARYKEY
5bb0: 20 20 20 28 53 51 4c 49 54 45 5f 43 4f 4e 53 54 (SQLITE_CONST
5bc0: 52 41 49 4e 54 20 7c 20 28 36 3c 3c 38 29 29 0a RAINT | (6<<8)).
5bd0: 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 43 #define SQLITE_C
5be0: 4f 4e 53 54 52 41 49 4e 54 5f 54 52 49 47 47 45 ONSTRAINT_TRIGGE
5bf0: 52 20 20 20 20 20 20 28 53 51 4c 49 54 45 5f 43 R (SQLITE_C
5c00: 4f 4e 53 54 52 41 49 4e 54 20 7c 20 28 37 3c 3c ONSTRAINT | (7<<
5c10: 38 29 29 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 8)).#define SQLI
5c20: 54 45 5f 43 4f 4e 53 54 52 41 49 4e 54 5f 55 4e TE_CONSTRAINT_UN
5c30: 49 51 55 45 20 20 20 20 20 20 20 28 53 51 4c 49 IQUE (SQLI
5c40: 54 45 5f 43 4f 4e 53 54 52 41 49 4e 54 20 7c 20 TE_CONSTRAINT |
5c50: 28 38 3c 3c 38 29 29 0a 23 64 65 66 69 6e 65 20 (8<<8)).#define
5c60: 53 51 4c 49 54 45 5f 43 4f 4e 53 54 52 41 49 4e SQLITE_CONSTRAIN
5c70: 54 5f 56 54 41 42 20 20 20 20 20 20 20 20 20 28 T_VTAB (
5c80: 53 51 4c 49 54 45 5f 43 4f 4e 53 54 52 41 49 4e SQLITE_CONSTRAIN
5c90: 54 20 7c 20 28 39 3c 3c 38 29 29 0a 23 64 65 66 T | (9<<8)).#def
5ca0: 69 6e 65 20 53 51 4c 49 54 45 5f 43 4f 4e 53 54 ine SQLITE_CONST
5cb0: 52 41 49 4e 54 5f 52 4f 57 49 44 20 20 20 20 20 RAINT_ROWID
5cc0: 20 20 20 28 53 51 4c 49 54 45 5f 43 4f 4e 53 54 (SQLITE_CONST
5cd0: 52 41 49 4e 54 20 7c 28 31 30 3c 3c 38 29 29 0a RAINT |(10<<8)).
5ce0: 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 4e #define SQLITE_N
5cf0: 4f 54 49 43 45 5f 52 45 43 4f 56 45 52 5f 57 41 OTICE_RECOVER_WA
5d00: 4c 20 20 20 20 20 20 28 53 51 4c 49 54 45 5f 4e L (SQLITE_N
5d10: 4f 54 49 43 45 20 7c 20 28 31 3c 3c 38 29 29 0a OTICE | (1<<8)).
5d20: 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 4e #define SQLITE_N
5d30: 4f 54 49 43 45 5f 52 45 43 4f 56 45 52 5f 52 4f OTICE_RECOVER_RO
5d40: 4c 4c 42 41 43 4b 20 28 53 51 4c 49 54 45 5f 4e LLBACK (SQLITE_N
5d50: 4f 54 49 43 45 20 7c 20 28 32 3c 3c 38 29 29 0a OTICE | (2<<8)).
5d60: 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 57 #define SQLITE_W
5d70: 41 52 4e 49 4e 47 5f 41 55 54 4f 49 4e 44 45 58 ARNING_AUTOINDEX
5d80: 20 20 20 20 20 20 20 28 53 51 4c 49 54 45 5f 57 (SQLITE_W
5d90: 41 52 4e 49 4e 47 20 7c 20 28 31 3c 3c 38 29 29 ARNING | (1<<8))
5da0: 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f .#define SQLITE_
5db0: 41 55 54 48 5f 55 53 45 52 20 20 20 20 20 20 20 AUTH_USER
5dc0: 20 20 20 20 20 20 20 20 28 53 51 4c 49 54 45 5f (SQLITE_
5dd0: 41 55 54 48 20 7c 20 28 31 3c 3c 38 29 29 0a 23 AUTH | (1<<8)).#
5de0: 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 4f 4b define SQLITE_OK
5df0: 5f 4c 4f 41 44 5f 50 45 52 4d 41 4e 45 4e 54 4c _LOAD_PERMANENTL
5e00: 59 20 20 20 20 20 28 53 51 4c 49 54 45 5f 4f 4b Y (SQLITE_OK
5e10: 20 7c 20 28 31 3c 3c 38 29 29 0a 0a 2f 2a 0a 2a | (1<<8))../*.*
5e20: 2a 20 43 41 50 49 33 52 45 46 3a 20 46 6c 61 67 * CAPI3REF: Flag
5e30: 73 20 46 6f 72 20 46 69 6c 65 20 4f 70 65 6e 20 s For File Open
5e40: 4f 70 65 72 61 74 69 6f 6e 73 0a 2a 2a 0a 2a 2a Operations.**.**
5e50: 20 54 68 65 73 65 20 62 69 74 20 76 61 6c 75 65 These bit value
5e60: 73 20 61 72 65 20 69 6e 74 65 6e 64 65 64 20 66 s are intended f
5e70: 6f 72 20 75 73 65 20 69 6e 20 74 68 65 0a 2a 2a or use in the.**
5e80: 20 33 72 64 20 70 61 72 61 6d 65 74 65 72 20 74 3rd parameter t
5e90: 6f 20 74 68 65 20 5b 73 71 6c 69 74 65 33 5f 6f o the [sqlite3_o
5ea0: 70 65 6e 5f 76 32 28 29 5d 20 69 6e 74 65 72 66 pen_v2()] interf
5eb0: 61 63 65 20 61 6e 64 0a 2a 2a 20 69 6e 20 74 68 ace and.** in th
5ec0: 65 20 34 74 68 20 70 61 72 61 6d 65 74 65 72 20 e 4th parameter
5ed0: 74 6f 20 74 68 65 20 5b 73 71 6c 69 74 65 33 5f to the [sqlite3_
5ee0: 76 66 73 2e 78 4f 70 65 6e 5d 20 6d 65 74 68 6f vfs.xOpen] metho
5ef0: 64 2e 0a 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 d..*/.#define SQ
5f00: 4c 49 54 45 5f 4f 50 45 4e 5f 52 45 41 44 4f 4e LITE_OPEN_READON
5f10: 4c 59 20 20 20 20 20 20 20 20 20 30 78 30 30 30 LY 0x000
5f20: 30 30 30 30 31 20 20 2f 2a 20 4f 6b 20 66 6f 72 00001 /* Ok for
5f30: 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 32 sqlite3_open_v2
5f40: 28 29 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 () */.#define SQ
5f50: 4c 49 54 45 5f 4f 50 45 4e 5f 52 45 41 44 57 52 LITE_OPEN_READWR
5f60: 49 54 45 20 20 20 20 20 20 20 20 30 78 30 30 30 ITE 0x000
5f70: 30 30 30 30 32 20 20 2f 2a 20 4f 6b 20 66 6f 72 00002 /* Ok for
5f80: 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 32 sqlite3_open_v2
5f90: 28 29 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 () */.#define SQ
5fa0: 4c 49 54 45 5f 4f 50 45 4e 5f 43 52 45 41 54 45 LITE_OPEN_CREATE
5fb0: 20 20 20 20 20 20 20 20 20 20 20 30 78 30 30 30 0x000
5fc0: 30 30 30 30 34 20 20 2f 2a 20 4f 6b 20 66 6f 72 00004 /* Ok for
5fd0: 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 32 sqlite3_open_v2
5fe0: 28 29 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 () */.#define SQ
5ff0: 4c 49 54 45 5f 4f 50 45 4e 5f 44 45 4c 45 54 45 LITE_OPEN_DELETE
6000: 4f 4e 43 4c 4f 53 45 20 20 20 20 30 78 30 30 30 ONCLOSE 0x000
6010: 30 30 30 30 38 20 20 2f 2a 20 56 46 53 20 6f 6e 00008 /* VFS on
6020: 6c 79 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 ly */.#define SQ
6030: 4c 49 54 45 5f 4f 50 45 4e 5f 45 58 43 4c 55 53 LITE_OPEN_EXCLUS
6040: 49 56 45 20 20 20 20 20 20 20 20 30 78 30 30 30 IVE 0x000
6050: 30 30 30 31 30 20 20 2f 2a 20 56 46 53 20 6f 6e 00010 /* VFS on
6060: 6c 79 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 ly */.#define SQ
6070: 4c 49 54 45 5f 4f 50 45 4e 5f 41 55 54 4f 50 52 LITE_OPEN_AUTOPR
6080: 4f 58 59 20 20 20 20 20 20 20 20 30 78 30 30 30 OXY 0x000
6090: 30 30 30 32 30 20 20 2f 2a 20 56 46 53 20 6f 6e 00020 /* VFS on
60a0: 6c 79 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 ly */.#define SQ
60b0: 4c 49 54 45 5f 4f 50 45 4e 5f 55 52 49 20 20 20 LITE_OPEN_URI
60c0: 20 20 20 20 20 20 20 20 20 20 20 30 78 30 30 30 0x000
60d0: 30 30 30 34 30 20 20 2f 2a 20 4f 6b 20 66 6f 72 00040 /* Ok for
60e0: 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 32 sqlite3_open_v2
60f0: 28 29 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 () */.#define SQ
6100: 4c 49 54 45 5f 4f 50 45 4e 5f 4d 45 4d 4f 52 59 LITE_OPEN_MEMORY
6110: 20 20 20 20 20 20 20 20 20 20 20 30 78 30 30 30 0x000
6120: 30 30 30 38 30 20 20 2f 2a 20 4f 6b 20 66 6f 72 00080 /* Ok for
6130: 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 32 sqlite3_open_v2
6140: 28 29 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 () */.#define SQ
6150: 4c 49 54 45 5f 4f 50 45 4e 5f 4d 41 49 4e 5f 44 LITE_OPEN_MAIN_D
6160: 42 20 20 20 20 20 20 20 20 20 20 30 78 30 30 30 B 0x000
6170: 30 30 31 30 30 20 20 2f 2a 20 56 46 53 20 6f 6e 00100 /* VFS on
6180: 6c 79 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 ly */.#define SQ
6190: 4c 49 54 45 5f 4f 50 45 4e 5f 54 45 4d 50 5f 44 LITE_OPEN_TEMP_D
61a0: 42 20 20 20 20 20 20 20 20 20 20 30 78 30 30 30 B 0x000
61b0: 30 30 32 30 30 20 20 2f 2a 20 56 46 53 20 6f 6e 00200 /* VFS on
61c0: 6c 79 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 ly */.#define SQ
61d0: 4c 49 54 45 5f 4f 50 45 4e 5f 54 52 41 4e 53 49 LITE_OPEN_TRANSI
61e0: 45 4e 54 5f 44 42 20 20 20 20 20 30 78 30 30 30 ENT_DB 0x000
61f0: 30 30 34 30 30 20 20 2f 2a 20 56 46 53 20 6f 6e 00400 /* VFS on
6200: 6c 79 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 ly */.#define SQ
6210: 4c 49 54 45 5f 4f 50 45 4e 5f 4d 41 49 4e 5f 4a LITE_OPEN_MAIN_J
6220: 4f 55 52 4e 41 4c 20 20 20 20 20 30 78 30 30 30 OURNAL 0x000
6230: 30 30 38 30 30 20 20 2f 2a 20 56 46 53 20 6f 6e 00800 /* VFS on
6240: 6c 79 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 ly */.#define SQ
6250: 4c 49 54 45 5f 4f 50 45 4e 5f 54 45 4d 50 5f 4a LITE_OPEN_TEMP_J
6260: 4f 55 52 4e 41 4c 20 20 20 20 20 30 78 30 30 30 OURNAL 0x000
6270: 30 31 30 30 30 20 20 2f 2a 20 56 46 53 20 6f 6e 01000 /* VFS on
6280: 6c 79 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 ly */.#define SQ
6290: 4c 49 54 45 5f 4f 50 45 4e 5f 53 55 42 4a 4f 55 LITE_OPEN_SUBJOU
62a0: 52 4e 41 4c 20 20 20 20 20 20 20 30 78 30 30 30 RNAL 0x000
62b0: 30 32 30 30 30 20 20 2f 2a 20 56 46 53 20 6f 6e 02000 /* VFS on
62c0: 6c 79 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 ly */.#define SQ
62d0: 4c 49 54 45 5f 4f 50 45 4e 5f 4d 41 53 54 45 52 LITE_OPEN_MASTER
62e0: 5f 4a 4f 55 52 4e 41 4c 20 20 20 30 78 30 30 30 _JOURNAL 0x000
62f0: 30 34 30 30 30 20 20 2f 2a 20 56 46 53 20 6f 6e 04000 /* VFS on
6300: 6c 79 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 ly */.#define SQ
6310: 4c 49 54 45 5f 4f 50 45 4e 5f 4e 4f 4d 55 54 45 LITE_OPEN_NOMUTE
6320: 58 20 20 20 20 20 20 20 20 20 20 30 78 30 30 30 X 0x000
6330: 30 38 30 30 30 20 20 2f 2a 20 4f 6b 20 66 6f 72 08000 /* Ok for
6340: 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 32 sqlite3_open_v2
6350: 28 29 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 () */.#define SQ
6360: 4c 49 54 45 5f 4f 50 45 4e 5f 46 55 4c 4c 4d 55 LITE_OPEN_FULLMU
6370: 54 45 58 20 20 20 20 20 20 20 20 30 78 30 30 30 TEX 0x000
6380: 31 30 30 30 30 20 20 2f 2a 20 4f 6b 20 66 6f 72 10000 /* Ok for
6390: 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 32 sqlite3_open_v2
63a0: 28 29 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 () */.#define SQ
63b0: 4c 49 54 45 5f 4f 50 45 4e 5f 53 48 41 52 45 44 LITE_OPEN_SHARED
63c0: 43 41 43 48 45 20 20 20 20 20 20 30 78 30 30 30 CACHE 0x000
63d0: 32 30 30 30 30 20 20 2f 2a 20 4f 6b 20 66 6f 72 20000 /* Ok for
63e0: 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 32 sqlite3_open_v2
63f0: 28 29 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 () */.#define SQ
6400: 4c 49 54 45 5f 4f 50 45 4e 5f 50 52 49 56 41 54 LITE_OPEN_PRIVAT
6410: 45 43 41 43 48 45 20 20 20 20 20 30 78 30 30 30 ECACHE 0x000
6420: 34 30 30 30 30 20 20 2f 2a 20 4f 6b 20 66 6f 72 40000 /* Ok for
6430: 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 32 sqlite3_open_v2
6440: 28 29 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 () */.#define SQ
6450: 4c 49 54 45 5f 4f 50 45 4e 5f 57 41 4c 20 20 20 LITE_OPEN_WAL
6460: 20 20 20 20 20 20 20 20 20 20 20 30 78 30 30 30 0x000
6470: 38 30 30 30 30 20 20 2f 2a 20 56 46 53 20 6f 6e 80000 /* VFS on
6480: 6c 79 20 2a 2f 0a 0a 2f 2a 20 52 65 73 65 72 76 ly */../* Reserv
6490: 65 64 3a 20 20 20 20 20 20 20 20 20 20 20 20 20 ed:
64a0: 20 20 20 20 20 20 20 20 20 20 20 20 30 78 30 30 0x00
64b0: 46 30 30 30 30 30 20 2a 2f 0a 0a 2f 2a 0a 2a 2a F00000 */../*.**
64c0: 20 43 41 50 49 33 52 45 46 3a 20 44 65 76 69 63 CAPI3REF: Devic
64d0: 65 20 43 68 61 72 61 63 74 65 72 69 73 74 69 63 e Characteristic
64e0: 73 0a 2a 2a 0a 2a 2a 20 54 68 65 20 78 44 65 76 s.**.** The xDev
64f0: 69 63 65 43 68 61 72 61 63 74 65 72 69 73 74 69 iceCharacteristi
6500: 63 73 20 6d 65 74 68 6f 64 20 6f 66 20 74 68 65 cs method of the
6510: 20 5b 73 71 6c 69 74 65 33 5f 69 6f 5f 6d 65 74 [sqlite3_io_met
6520: 68 6f 64 73 5d 0a 2a 2a 20 6f 62 6a 65 63 74 20 hods].** object
6530: 72 65 74 75 72 6e 73 20 61 6e 20 69 6e 74 65 67 returns an integ
6540: 65 72 20 77 68 69 63 68 20 69 73 20 61 20 76 65 er which is a ve
6550: 63 74 6f 72 20 6f 66 20 74 68 65 73 65 0a 2a 2a ctor of these.**
6560: 20 62 69 74 20 76 61 6c 75 65 73 20 65 78 70 72 bit values expr
6570: 65 73 73 69 6e 67 20 49 2f 4f 20 63 68 61 72 61 essing I/O chara
6580: 63 74 65 72 69 73 74 69 63 73 20 6f 66 20 74 68 cteristics of th
6590: 65 20 6d 61 73 73 20 73 74 6f 72 61 67 65 0a 2a e mass storage.*
65a0: 2a 20 64 65 76 69 63 65 20 74 68 61 74 20 68 6f * device that ho
65b0: 6c 64 73 20 74 68 65 20 66 69 6c 65 20 74 68 61 lds the file tha
65c0: 74 20 74 68 65 20 5b 73 71 6c 69 74 65 33 5f 69 t the [sqlite3_i
65d0: 6f 5f 6d 65 74 68 6f 64 73 5d 0a 2a 2a 20 72 65 o_methods].** re
65e0: 66 65 72 73 20 74 6f 2e 0a 2a 2a 0a 2a 2a 20 54 fers to..**.** T
65f0: 68 65 20 53 51 4c 49 54 45 5f 49 4f 43 41 50 5f he SQLITE_IOCAP_
6600: 41 54 4f 4d 49 43 20 70 72 6f 70 65 72 74 79 20 ATOMIC property
6610: 6d 65 61 6e 73 20 74 68 61 74 20 61 6c 6c 20 77 means that all w
6620: 72 69 74 65 73 20 6f 66 0a 2a 2a 20 61 6e 79 20 rites of.** any
6630: 73 69 7a 65 20 61 72 65 20 61 74 6f 6d 69 63 2e size are atomic.
6640: 20 20 54 68 65 20 53 51 4c 49 54 45 5f 49 4f 43 The SQLITE_IOC
6650: 41 50 5f 41 54 4f 4d 49 43 6e 6e 6e 20 76 61 6c AP_ATOMICnnn val
6660: 75 65 73 0a 2a 2a 20 6d 65 61 6e 20 74 68 61 74 ues.** mean that
6670: 20 77 72 69 74 65 73 20 6f 66 20 62 6c 6f 63 6b writes of block
6680: 73 20 74 68 61 74 20 61 72 65 20 6e 6e 6e 20 62 s that are nnn b
6690: 79 74 65 73 20 69 6e 20 73 69 7a 65 20 61 6e 64 ytes in size and
66a0: 0a 2a 2a 20 61 72 65 20 61 6c 69 67 6e 65 64 20 .** are aligned
66b0: 74 6f 20 61 6e 20 61 64 64 72 65 73 73 20 77 68 to an address wh
66c0: 69 63 68 20 69 73 20 61 6e 20 69 6e 74 65 67 65 ich is an intege
66d0: 72 20 6d 75 6c 74 69 70 6c 65 20 6f 66 0a 2a 2a r multiple of.**
66e0: 20 6e 6e 6e 20 61 72 65 20 61 74 6f 6d 69 63 2e nnn are atomic.
66f0: 20 20 54 68 65 20 53 51 4c 49 54 45 5f 49 4f 43 The SQLITE_IOC
6700: 41 50 5f 53 41 46 45 5f 41 50 50 45 4e 44 20 76 AP_SAFE_APPEND v
6710: 61 6c 75 65 20 6d 65 61 6e 73 0a 2a 2a 20 74 68 alue means.** th
6720: 61 74 20 77 68 65 6e 20 64 61 74 61 20 69 73 20 at when data is
6730: 61 70 70 65 6e 64 65 64 20 74 6f 20 61 20 66 69 appended to a fi
6740: 6c 65 2c 20 74 68 65 20 64 61 74 61 20 69 73 20 le, the data is
6750: 61 70 70 65 6e 64 65 64 0a 2a 2a 20 66 69 72 73 appended.** firs
6760: 74 20 74 68 65 6e 20 74 68 65 20 73 69 7a 65 20 t then the size
6770: 6f 66 20 74 68 65 20 66 69 6c 65 20 69 73 20 65 of the file is e
6780: 78 74 65 6e 64 65 64 2c 20 6e 65 76 65 72 20 74 xtended, never t
6790: 68 65 20 6f 74 68 65 72 0a 2a 2a 20 77 61 79 20 he other.** way
67a0: 61 72 6f 75 6e 64 2e 20 20 54 68 65 20 53 51 4c around. The SQL
67b0: 49 54 45 5f 49 4f 43 41 50 5f 53 45 51 55 45 4e ITE_IOCAP_SEQUEN
67c0: 54 49 41 4c 20 70 72 6f 70 65 72 74 79 20 6d 65 TIAL property me
67d0: 61 6e 73 20 74 68 61 74 0a 2a 2a 20 69 6e 66 6f ans that.** info
67e0: 72 6d 61 74 69 6f 6e 20 69 73 20 77 72 69 74 74 rmation is writt
67f0: 65 6e 20 74 6f 20 64 69 73 6b 20 69 6e 20 74 68 en to disk in th
6800: 65 20 73 61 6d 65 20 6f 72 64 65 72 20 61 73 20 e same order as
6810: 63 61 6c 6c 73 0a 2a 2a 20 74 6f 20 78 57 72 69 calls.** to xWri
6820: 74 65 28 29 2e 20 20 54 68 65 20 53 51 4c 49 54 te(). The SQLIT
6830: 45 5f 49 4f 43 41 50 5f 50 4f 57 45 52 53 41 46 E_IOCAP_POWERSAF
6840: 45 5f 4f 56 45 52 57 52 49 54 45 20 70 72 6f 70 E_OVERWRITE prop
6850: 65 72 74 79 20 6d 65 61 6e 73 20 74 68 61 74 0a erty means that.
6860: 2a 2a 20 61 66 74 65 72 20 72 65 62 6f 6f 74 20 ** after reboot
6870: 66 6f 6c 6c 6f 77 69 6e 67 20 61 20 63 72 61 73 following a cras
6880: 68 20 6f 72 20 70 6f 77 65 72 20 6c 6f 73 73 2c h or power loss,
6890: 20 74 68 65 20 6f 6e 6c 79 20 62 79 74 65 73 20 the only bytes
68a0: 69 6e 20 61 0a 2a 2a 20 66 69 6c 65 20 74 68 61 in a.** file tha
68b0: 74 20 77 65 72 65 20 77 72 69 74 74 65 6e 20 61 t were written a
68c0: 74 20 74 68 65 20 61 70 70 6c 69 63 61 74 69 6f t the applicatio
68d0: 6e 20 6c 65 76 65 6c 20 6d 69 67 68 74 20 68 61 n level might ha
68e0: 76 65 20 63 68 61 6e 67 65 64 0a 2a 2a 20 61 6e ve changed.** an
68f0: 64 20 74 68 61 74 20 61 64 6a 61 63 65 6e 74 20 d that adjacent
6900: 62 79 74 65 73 2c 20 65 76 65 6e 20 62 79 74 65 bytes, even byte
6910: 73 20 77 69 74 68 69 6e 20 74 68 65 20 73 61 6d s within the sam
6920: 65 20 73 65 63 74 6f 72 20 61 72 65 0a 2a 2a 20 e sector are.**
6930: 67 75 61 72 61 6e 74 65 65 64 20 74 6f 20 62 65 guaranteed to be
6940: 20 75 6e 63 68 61 6e 67 65 64 2e 20 20 54 68 65 unchanged. The
6950: 20 53 51 4c 49 54 45 5f 49 4f 43 41 50 5f 55 4e SQLITE_IOCAP_UN
6960: 44 45 4c 45 54 41 42 4c 45 5f 57 48 45 4e 5f 4f DELETABLE_WHEN_O
6970: 50 45 4e 0a 2a 2a 20 66 6c 61 67 20 69 6e 64 69 PEN.** flag indi
6980: 63 61 74 65 20 74 68 61 74 20 61 20 66 69 6c 65 cate that a file
6990: 20 63 61 6e 6e 6f 74 20 62 65 20 64 65 6c 65 74 cannot be delet
69a0: 65 64 20 77 68 65 6e 20 6f 70 65 6e 2e 20 20 54 ed when open. T
69b0: 68 65 0a 2a 2a 20 53 51 4c 49 54 45 5f 49 4f 43 he.** SQLITE_IOC
69c0: 41 50 5f 49 4d 4d 55 54 41 42 4c 45 20 66 6c 61 AP_IMMUTABLE fla
69d0: 67 20 69 6e 64 69 63 61 74 65 73 20 74 68 61 74 g indicates that
69e0: 20 74 68 65 20 66 69 6c 65 20 69 73 20 6f 6e 0a the file is on.
69f0: 2a 2a 20 72 65 61 64 2d 6f 6e 6c 79 20 6d 65 64 ** read-only med
6a00: 69 61 20 61 6e 64 20 63 61 6e 6e 6f 74 20 62 65 ia and cannot be
6a10: 20 63 68 61 6e 67 65 64 20 65 76 65 6e 20 62 79 changed even by
6a20: 20 70 72 6f 63 65 73 73 65 73 20 77 69 74 68 0a processes with.
6a30: 2a 2a 20 65 6c 65 76 61 74 65 64 20 70 72 69 76 ** elevated priv
6a40: 69 6c 65 67 65 73 2e 0a 2a 2f 0a 23 64 65 66 69 ileges..*/.#defi
6a50: 6e 65 20 53 51 4c 49 54 45 5f 49 4f 43 41 50 5f ne SQLITE_IOCAP_
6a60: 41 54 4f 4d 49 43 20 20 20 20 20 20 20 20 20 20 ATOMIC
6a70: 20 20 20 20 20 20 20 30 78 30 30 30 30 30 30 30 0x0000000
6a80: 31 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 1.#define SQLITE
6a90: 5f 49 4f 43 41 50 5f 41 54 4f 4d 49 43 35 31 32 _IOCAP_ATOMIC512
6aa0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 30 78 0x
6ab0: 30 30 30 30 30 30 30 32 0a 23 64 65 66 69 6e 65 00000002.#define
6ac0: 20 53 51 4c 49 54 45 5f 49 4f 43 41 50 5f 41 54 SQLITE_IOCAP_AT
6ad0: 4f 4d 49 43 31 4b 20 20 20 20 20 20 20 20 20 20 OMIC1K
6ae0: 20 20 20 20 20 30 78 30 30 30 30 30 30 30 34 0a 0x00000004.
6af0: 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 49 #define SQLITE_I
6b00: 4f 43 41 50 5f 41 54 4f 4d 49 43 32 4b 20 20 20 OCAP_ATOMIC2K
6b10: 20 20 20 20 20 20 20 20 20 20 20 20 30 78 30 30 0x00
6b20: 30 30 30 30 30 38 0a 23 64 65 66 69 6e 65 20 53 000008.#define S
6b30: 51 4c 49 54 45 5f 49 4f 43 41 50 5f 41 54 4f 4d QLITE_IOCAP_ATOM
6b40: 49 43 34 4b 20 20 20 20 20 20 20 20 20 20 20 20 IC4K
6b50: 20 20 20 30 78 30 30 30 30 30 30 31 30 0a 23 64 0x00000010.#d
6b60: 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 49 4f 43 efine SQLITE_IOC
6b70: 41 50 5f 41 54 4f 4d 49 43 38 4b 20 20 20 20 20 AP_ATOMIC8K
6b80: 20 20 20 20 20 20 20 20 20 20 30 78 30 30 30 30 0x0000
6b90: 30 30 32 30 0a 23 64 65 66 69 6e 65 20 53 51 4c 0020.#define SQL
6ba0: 49 54 45 5f 49 4f 43 41 50 5f 41 54 4f 4d 49 43 ITE_IOCAP_ATOMIC
6bb0: 31 36 4b 20 20 20 20 20 20 20 20 20 20 20 20 20 16K
6bc0: 20 30 78 30 30 30 30 30 30 34 30 0a 23 64 65 66 0x00000040.#def
6bd0: 69 6e 65 20 53 51 4c 49 54 45 5f 49 4f 43 41 50 ine SQLITE_IOCAP
6be0: 5f 41 54 4f 4d 49 43 33 32 4b 20 20 20 20 20 20 _ATOMIC32K
6bf0: 20 20 20 20 20 20 20 20 30 78 30 30 30 30 30 30 0x000000
6c00: 38 30 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 80.#define SQLIT
6c10: 45 5f 49 4f 43 41 50 5f 41 54 4f 4d 49 43 36 34 E_IOCAP_ATOMIC64
6c20: 4b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 30 K 0
6c30: 78 30 30 30 30 30 31 30 30 0a 23 64 65 66 69 6e x00000100.#defin
6c40: 65 20 53 51 4c 49 54 45 5f 49 4f 43 41 50 5f 53 e SQLITE_IOCAP_S
6c50: 41 46 45 5f 41 50 50 45 4e 44 20 20 20 20 20 20 AFE_APPEND
6c60: 20 20 20 20 20 20 30 78 30 30 30 30 30 32 30 30 0x00000200
6c70: 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f .#define SQLITE_
6c80: 49 4f 43 41 50 5f 53 45 51 55 45 4e 54 49 41 4c IOCAP_SEQUENTIAL
6c90: 20 20 20 20 20 20 20 20 20 20 20 20 20 30 78 30 0x0
6ca0: 30 30 30 30 34 30 30 0a 23 64 65 66 69 6e 65 20 0000400.#define
6cb0: 53 51 4c 49 54 45 5f 49 4f 43 41 50 5f 55 4e 44 SQLITE_IOCAP_UND
6cc0: 45 4c 45 54 41 42 4c 45 5f 57 48 45 4e 5f 4f 50 ELETABLE_WHEN_OP
6cd0: 45 4e 20 20 30 78 30 30 30 30 30 38 30 30 0a 23 EN 0x00000800.#
6ce0: 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 49 4f define SQLITE_IO
6cf0: 43 41 50 5f 50 4f 57 45 52 53 41 46 45 5f 4f 56 CAP_POWERSAFE_OV
6d00: 45 52 57 52 49 54 45 20 20 20 20 30 78 30 30 30 ERWRITE 0x000
6d10: 30 31 30 30 30 0a 23 64 65 66 69 6e 65 20 53 51 01000.#define SQ
6d20: 4c 49 54 45 5f 49 4f 43 41 50 5f 49 4d 4d 55 54 LITE_IOCAP_IMMUT
6d30: 41 42 4c 45 20 20 20 20 20 20 20 20 20 20 20 20 ABLE
6d40: 20 20 30 78 30 30 30 30 32 30 30 30 0a 0a 2f 2a 0x00002000../*
6d50: 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 46 69 .** CAPI3REF: Fi
6d60: 6c 65 20 4c 6f 63 6b 69 6e 67 20 4c 65 76 65 6c le Locking Level
6d70: 73 0a 2a 2a 0a 2a 2a 20 53 51 4c 69 74 65 20 75 s.**.** SQLite u
6d80: 73 65 73 20 6f 6e 65 20 6f 66 20 74 68 65 73 65 ses one of these
6d90: 20 69 6e 74 65 67 65 72 20 76 61 6c 75 65 73 20 integer values
6da0: 61 73 20 74 68 65 20 73 65 63 6f 6e 64 0a 2a 2a as the second.**
6db0: 20 61 72 67 75 6d 65 6e 74 20 74 6f 20 63 61 6c argument to cal
6dc0: 6c 73 20 69 74 20 6d 61 6b 65 73 20 74 6f 20 74 ls it makes to t
6dd0: 68 65 20 78 4c 6f 63 6b 28 29 20 61 6e 64 20 78 he xLock() and x
6de0: 55 6e 6c 6f 63 6b 28 29 20 6d 65 74 68 6f 64 73 Unlock() methods
6df0: 0a 2a 2a 20 6f 66 20 61 6e 20 5b 73 71 6c 69 74 .** of an [sqlit
6e00: 65 33 5f 69 6f 5f 6d 65 74 68 6f 64 73 5d 20 6f e3_io_methods] o
6e10: 62 6a 65 63 74 2e 0a 2a 2f 0a 23 64 65 66 69 6e bject..*/.#defin
6e20: 65 20 53 51 4c 49 54 45 5f 4c 4f 43 4b 5f 4e 4f e SQLITE_LOCK_NO
6e30: 4e 45 20 20 20 20 20 20 20 20 20 20 30 0a 23 64 NE 0.#d
6e40: 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 4c 4f 43 efine SQLITE_LOC
6e50: 4b 5f 53 48 41 52 45 44 20 20 20 20 20 20 20 20 K_SHARED
6e60: 31 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 1.#define SQLITE
6e70: 5f 4c 4f 43 4b 5f 52 45 53 45 52 56 45 44 20 20 _LOCK_RESERVED
6e80: 20 20 20 20 32 0a 23 64 65 66 69 6e 65 20 53 51 2.#define SQ
6e90: 4c 49 54 45 5f 4c 4f 43 4b 5f 50 45 4e 44 49 4e LITE_LOCK_PENDIN
6ea0: 47 20 20 20 20 20 20 20 33 0a 23 64 65 66 69 6e G 3.#defin
6eb0: 65 20 53 51 4c 49 54 45 5f 4c 4f 43 4b 5f 45 58 e SQLITE_LOCK_EX
6ec0: 43 4c 55 53 49 56 45 20 20 20 20 20 34 0a 0a 2f CLUSIVE 4../
6ed0: 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 53 *.** CAPI3REF: S
6ee0: 79 6e 63 68 72 6f 6e 69 7a 61 74 69 6f 6e 20 54 ynchronization T
6ef0: 79 70 65 20 46 6c 61 67 73 0a 2a 2a 0a 2a 2a 20 ype Flags.**.**
6f00: 57 68 65 6e 20 53 51 4c 69 74 65 20 69 6e 76 6f When SQLite invo
6f10: 6b 65 73 20 74 68 65 20 78 53 79 6e 63 28 29 20 kes the xSync()
6f20: 6d 65 74 68 6f 64 20 6f 66 20 61 6e 0a 2a 2a 20 method of an.**
6f30: 5b 73 71 6c 69 74 65 33 5f 69 6f 5f 6d 65 74 68 [sqlite3_io_meth
6f40: 6f 64 73 5d 20 6f 62 6a 65 63 74 20 69 74 20 75 ods] object it u
6f50: 73 65 73 20 61 20 63 6f 6d 62 69 6e 61 74 69 6f ses a combinatio
6f60: 6e 20 6f 66 0a 2a 2a 20 74 68 65 73 65 20 69 6e n of.** these in
6f70: 74 65 67 65 72 20 76 61 6c 75 65 73 20 61 73 20 teger values as
6f80: 74 68 65 20 73 65 63 6f 6e 64 20 61 72 67 75 6d the second argum
6f90: 65 6e 74 2e 0a 2a 2a 0a 2a 2a 20 57 68 65 6e 20 ent..**.** When
6fa0: 74 68 65 20 53 51 4c 49 54 45 5f 53 59 4e 43 5f the SQLITE_SYNC_
6fb0: 44 41 54 41 4f 4e 4c 59 20 66 6c 61 67 20 69 73 DATAONLY flag is
6fc0: 20 75 73 65 64 2c 20 69 74 20 6d 65 61 6e 73 20 used, it means
6fd0: 74 68 61 74 20 74 68 65 0a 2a 2a 20 73 79 6e 63 that the.** sync
6fe0: 20 6f 70 65 72 61 74 69 6f 6e 20 6f 6e 6c 79 20 operation only
6ff0: 6e 65 65 64 73 20 74 6f 20 66 6c 75 73 68 20 64 needs to flush d
7000: 61 74 61 20 74 6f 20 6d 61 73 73 20 73 74 6f 72 ata to mass stor
7010: 61 67 65 2e 20 20 49 6e 6f 64 65 0a 2a 2a 20 69 age. Inode.** i
7020: 6e 66 6f 72 6d 61 74 69 6f 6e 20 6e 65 65 64 20 nformation need
7030: 6e 6f 74 20 62 65 20 66 6c 75 73 68 65 64 2e 20 not be flushed.
7040: 49 66 20 74 68 65 20 6c 6f 77 65 72 20 66 6f 75 If the lower fou
7050: 72 20 62 69 74 73 20 6f 66 20 74 68 65 20 66 6c r bits of the fl
7060: 61 67 0a 2a 2a 20 65 71 75 61 6c 20 53 51 4c 49 ag.** equal SQLI
7070: 54 45 5f 53 59 4e 43 5f 4e 4f 52 4d 41 4c 2c 20 TE_SYNC_NORMAL,
7080: 74 68 61 74 20 6d 65 61 6e 73 20 74 6f 20 75 73 that means to us
7090: 65 20 6e 6f 72 6d 61 6c 20 66 73 79 6e 63 28 29 e normal fsync()
70a0: 20 73 65 6d 61 6e 74 69 63 73 2e 0a 2a 2a 20 49 semantics..** I
70b0: 66 20 74 68 65 20 6c 6f 77 65 72 20 66 6f 75 72 f the lower four
70c0: 20 62 69 74 73 20 65 71 75 61 6c 20 53 51 4c 49 bits equal SQLI
70d0: 54 45 5f 53 59 4e 43 5f 46 55 4c 4c 2c 20 74 68 TE_SYNC_FULL, th
70e0: 61 74 20 6d 65 61 6e 73 0a 2a 2a 20 74 6f 20 75 at means.** to u
70f0: 73 65 20 4d 61 63 20 4f 53 20 58 20 73 74 79 6c se Mac OS X styl
7100: 65 20 66 75 6c 6c 73 79 6e 63 20 69 6e 73 74 65 e fullsync inste
7110: 61 64 20 6f 66 20 66 73 79 6e 63 28 29 2e 0a 2a ad of fsync()..*
7120: 2a 0a 2a 2a 20 44 6f 20 6e 6f 74 20 63 6f 6e 66 *.** Do not conf
7130: 75 73 65 20 74 68 65 20 53 51 4c 49 54 45 5f 53 use the SQLITE_S
7140: 59 4e 43 5f 4e 4f 52 4d 41 4c 20 61 6e 64 20 53 YNC_NORMAL and S
7150: 51 4c 49 54 45 5f 53 59 4e 43 5f 46 55 4c 4c 20 QLITE_SYNC_FULL
7160: 66 6c 61 67 73 0a 2a 2a 20 77 69 74 68 20 74 68 flags.** with th
7170: 65 20 5b 50 52 41 47 4d 41 20 73 79 6e 63 68 72 e [PRAGMA synchr
7180: 6f 6e 6f 75 73 5d 3d 4e 4f 52 4d 41 4c 20 61 6e onous]=NORMAL an
7190: 64 20 5b 50 52 41 47 4d 41 20 73 79 6e 63 68 72 d [PRAGMA synchr
71a0: 6f 6e 6f 75 73 5d 3d 46 55 4c 4c 0a 2a 2a 20 73 onous]=FULL.** s
71b0: 65 74 74 69 6e 67 73 2e 20 20 54 68 65 20 5b 73 ettings. The [s
71c0: 79 6e 63 68 72 6f 6e 6f 75 73 20 70 72 61 67 6d ynchronous pragm
71d0: 61 5d 20 64 65 74 65 72 6d 69 6e 65 73 20 77 68 a] determines wh
71e0: 65 6e 20 63 61 6c 6c 73 20 74 6f 20 74 68 65 0a en calls to the.
71f0: 2a 2a 20 78 53 79 6e 63 20 56 46 53 20 6d 65 74 ** xSync VFS met
7200: 68 6f 64 20 6f 63 63 75 72 20 61 6e 64 20 61 70 hod occur and ap
7210: 70 6c 69 65 73 20 75 6e 69 66 6f 72 6d 6c 79 20 plies uniformly
7220: 61 63 72 6f 73 73 20 61 6c 6c 20 70 6c 61 74 66 across all platf
7230: 6f 72 6d 73 2e 0a 2a 2a 20 54 68 65 20 53 51 4c orms..** The SQL
7240: 49 54 45 5f 53 59 4e 43 5f 4e 4f 52 4d 41 4c 20 ITE_SYNC_NORMAL
7250: 61 6e 64 20 53 51 4c 49 54 45 5f 53 59 4e 43 5f and SQLITE_SYNC_
7260: 46 55 4c 4c 20 66 6c 61 67 73 20 64 65 74 65 72 FULL flags deter
7270: 6d 69 6e 65 20 68 6f 77 0a 2a 2a 20 65 6e 65 72 mine how.** ener
7280: 67 65 74 69 63 20 6f 72 20 72 69 67 6f 72 6f 75 getic or rigorou
7290: 73 20 6f 72 20 66 6f 72 63 65 66 75 6c 20 74 68 s or forceful th
72a0: 65 20 73 79 6e 63 20 6f 70 65 72 61 74 69 6f 6e e sync operation
72b0: 73 20 61 72 65 20 61 6e 64 0a 2a 2a 20 6f 6e 6c s are and.** onl
72c0: 79 20 6d 61 6b 65 20 61 20 64 69 66 66 65 72 65 y make a differe
72d0: 6e 63 65 20 6f 6e 20 4d 61 63 20 4f 53 58 20 66 nce on Mac OSX f
72e0: 6f 72 20 74 68 65 20 64 65 66 61 75 6c 74 20 53 or the default S
72f0: 51 4c 69 74 65 20 63 6f 64 65 2e 0a 2a 2a 20 28 QLite code..** (
7300: 54 68 69 72 64 2d 70 61 72 74 79 20 56 46 53 20 Third-party VFS
7310: 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 73 20 implementations
7320: 6d 69 67 68 74 20 61 6c 73 6f 20 6d 61 6b 65 20 might also make
7330: 74 68 65 20 64 69 73 74 69 6e 63 74 69 6f 6e 0a the distinction.
7340: 2a 2a 20 62 65 74 77 65 65 6e 20 53 51 4c 49 54 ** between SQLIT
7350: 45 5f 53 59 4e 43 5f 4e 4f 52 4d 41 4c 20 61 6e E_SYNC_NORMAL an
7360: 64 20 53 51 4c 49 54 45 5f 53 59 4e 43 5f 46 55 d SQLITE_SYNC_FU
7370: 4c 4c 2c 20 62 75 74 20 61 6d 6f 6e 67 20 74 68 LL, but among th
7380: 65 0a 2a 2a 20 6f 70 65 72 61 74 69 6e 67 20 73 e.** operating s
7390: 79 73 74 65 6d 73 20 6e 61 74 69 76 65 6c 79 20 ystems natively
73a0: 73 75 70 70 6f 72 74 65 64 20 62 79 20 53 51 4c supported by SQL
73b0: 69 74 65 2c 20 6f 6e 6c 79 20 4d 61 63 20 4f 53 ite, only Mac OS
73c0: 58 0a 2a 2a 20 63 61 72 65 73 20 61 62 6f 75 74 X.** cares about
73d0: 20 74 68 65 20 64 69 66 66 65 72 65 6e 63 65 2e the difference.
73e0: 29 0a 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c ).*/.#define SQL
73f0: 49 54 45 5f 53 59 4e 43 5f 4e 4f 52 4d 41 4c 20 ITE_SYNC_NORMAL
7400: 20 20 20 20 20 20 20 30 78 30 30 30 30 32 0a 23 0x00002.#
7410: 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 53 59 define SQLITE_SY
7420: 4e 43 5f 46 55 4c 4c 20 20 20 20 20 20 20 20 20 NC_FULL
7430: 20 30 78 30 30 30 30 33 0a 23 64 65 66 69 6e 65 0x00003.#define
7440: 20 53 51 4c 49 54 45 5f 53 59 4e 43 5f 44 41 54 SQLITE_SYNC_DAT
7450: 41 4f 4e 4c 59 20 20 20 20 20 20 30 78 30 30 30 AONLY 0x000
7460: 31 30 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 10../*.** CAPI3R
7470: 45 46 3a 20 4f 53 20 49 6e 74 65 72 66 61 63 65 EF: OS Interface
7480: 20 4f 70 65 6e 20 46 69 6c 65 20 48 61 6e 64 6c Open File Handl
7490: 65 0a 2a 2a 0a 2a 2a 20 41 6e 20 5b 73 71 6c 69 e.**.** An [sqli
74a0: 74 65 33 5f 66 69 6c 65 5d 20 6f 62 6a 65 63 74 te3_file] object
74b0: 20 72 65 70 72 65 73 65 6e 74 73 20 61 6e 20 6f represents an o
74c0: 70 65 6e 20 66 69 6c 65 20 69 6e 20 74 68 65 20 pen file in the
74d0: 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 76 66 73 .** [sqlite3_vfs
74e0: 20 7c 20 4f 53 20 69 6e 74 65 72 66 61 63 65 20 | OS interface
74f0: 6c 61 79 65 72 5d 2e 20 20 49 6e 64 69 76 69 64 layer]. Individ
7500: 75 61 6c 20 4f 53 20 69 6e 74 65 72 66 61 63 65 ual OS interface
7510: 0a 2a 2a 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 .** implementati
7520: 6f 6e 73 20 77 69 6c 6c 0a 2a 2a 20 77 61 6e 74 ons will.** want
7530: 20 74 6f 20 73 75 62 63 6c 61 73 73 20 74 68 69 to subclass thi
7540: 73 20 6f 62 6a 65 63 74 20 62 79 20 61 70 70 65 s object by appe
7550: 6e 64 69 6e 67 20 61 64 64 69 74 69 6f 6e 61 6c nding additional
7560: 20 66 69 65 6c 64 73 0a 2a 2a 20 66 6f 72 20 74 fields.** for t
7570: 68 65 69 72 20 6f 77 6e 20 75 73 65 2e 20 20 54 heir own use. T
7580: 68 65 20 70 4d 65 74 68 6f 64 73 20 65 6e 74 72 he pMethods entr
7590: 79 20 69 73 20 61 20 70 6f 69 6e 74 65 72 20 74 y is a pointer t
75a0: 6f 20 61 6e 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 o an.** [sqlite3
75b0: 5f 69 6f 5f 6d 65 74 68 6f 64 73 5d 20 6f 62 6a _io_methods] obj
75c0: 65 63 74 20 74 68 61 74 20 64 65 66 69 6e 65 73 ect that defines
75d0: 20 6d 65 74 68 6f 64 73 20 66 6f 72 20 70 65 72 methods for per
75e0: 66 6f 72 6d 69 6e 67 0a 2a 2a 20 49 2f 4f 20 6f forming.** I/O o
75f0: 70 65 72 61 74 69 6f 6e 73 20 6f 6e 20 74 68 65 perations on the
7600: 20 6f 70 65 6e 20 66 69 6c 65 2e 0a 2a 2f 0a 74 open file..*/.t
7610: 79 70 65 64 65 66 20 73 74 72 75 63 74 20 73 71 ypedef struct sq
7620: 6c 69 74 65 33 5f 66 69 6c 65 20 73 71 6c 69 74 lite3_file sqlit
7630: 65 33 5f 66 69 6c 65 3b 0a 73 74 72 75 63 74 20 e3_file;.struct
7640: 73 71 6c 69 74 65 33 5f 66 69 6c 65 20 7b 0a 20 sqlite3_file {.
7650: 20 63 6f 6e 73 74 20 73 74 72 75 63 74 20 73 71 const struct sq
7660: 6c 69 74 65 33 5f 69 6f 5f 6d 65 74 68 6f 64 73 lite3_io_methods
7670: 20 2a 70 4d 65 74 68 6f 64 73 3b 20 20 2f 2a 20 *pMethods; /*
7680: 4d 65 74 68 6f 64 73 20 66 6f 72 20 61 6e 20 6f Methods for an o
7690: 70 65 6e 20 66 69 6c 65 20 2a 2f 0a 7d 3b 0a 0a pen file */.};..
76a0: 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 /*.** CAPI3REF:
76b0: 4f 53 20 49 6e 74 65 72 66 61 63 65 20 46 69 6c OS Interface Fil
76c0: 65 20 56 69 72 74 75 61 6c 20 4d 65 74 68 6f 64 e Virtual Method
76d0: 73 20 4f 62 6a 65 63 74 0a 2a 2a 0a 2a 2a 20 45 s Object.**.** E
76e0: 76 65 72 79 20 66 69 6c 65 20 6f 70 65 6e 65 64 very file opened
76f0: 20 62 79 20 74 68 65 20 5b 73 71 6c 69 74 65 33 by the [sqlite3
7700: 5f 76 66 73 2e 78 4f 70 65 6e 5d 20 6d 65 74 68 _vfs.xOpen] meth
7710: 6f 64 20 70 6f 70 75 6c 61 74 65 73 20 61 6e 0a od populates an.
7720: 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 66 69 6c 65 ** [sqlite3_file
7730: 5d 20 6f 62 6a 65 63 74 20 28 6f 72 2c 20 6d 6f ] object (or, mo
7740: 72 65 20 63 6f 6d 6d 6f 6e 6c 79 2c 20 61 20 73 re commonly, a s
7750: 75 62 63 6c 61 73 73 20 6f 66 20 74 68 65 0a 2a ubclass of the.*
7760: 2a 20 5b 73 71 6c 69 74 65 33 5f 66 69 6c 65 5d * [sqlite3_file]
7770: 20 6f 62 6a 65 63 74 29 20 77 69 74 68 20 61 20 object) with a
7780: 70 6f 69 6e 74 65 72 20 74 6f 20 61 6e 20 69 6e pointer to an in
7790: 73 74 61 6e 63 65 20 6f 66 20 74 68 69 73 20 6f stance of this o
77a0: 62 6a 65 63 74 2e 0a 2a 2a 20 54 68 69 73 20 6f bject..** This o
77b0: 62 6a 65 63 74 20 64 65 66 69 6e 65 73 20 74 68 bject defines th
77c0: 65 20 6d 65 74 68 6f 64 73 20 75 73 65 64 20 74 e methods used t
77d0: 6f 20 70 65 72 66 6f 72 6d 20 76 61 72 69 6f 75 o perform variou
77e0: 73 20 6f 70 65 72 61 74 69 6f 6e 73 0a 2a 2a 20 s operations.**
77f0: 61 67 61 69 6e 73 74 20 74 68 65 20 6f 70 65 6e against the open
7800: 20 66 69 6c 65 20 72 65 70 72 65 73 65 6e 74 65 file represente
7810: 64 20 62 79 20 74 68 65 20 5b 73 71 6c 69 74 65 d by the [sqlite
7820: 33 5f 66 69 6c 65 5d 20 6f 62 6a 65 63 74 2e 0a 3_file] object..
7830: 2a 2a 0a 2a 2a 20 49 66 20 74 68 65 20 5b 73 71 **.** If the [sq
7840: 6c 69 74 65 33 5f 76 66 73 2e 78 4f 70 65 6e 5d lite3_vfs.xOpen]
7850: 20 6d 65 74 68 6f 64 20 73 65 74 73 20 74 68 65 method sets the
7860: 20 73 71 6c 69 74 65 33 5f 66 69 6c 65 2e 70 4d sqlite3_file.pM
7870: 65 74 68 6f 64 73 20 65 6c 65 6d 65 6e 74 20 0a ethods element .
7880: 2a 2a 20 74 6f 20 61 20 6e 6f 6e 2d 4e 55 4c 4c ** to a non-NULL
7890: 20 70 6f 69 6e 74 65 72 2c 20 74 68 65 6e 20 74 pointer, then t
78a0: 68 65 20 73 71 6c 69 74 65 33 5f 69 6f 5f 6d 65 he sqlite3_io_me
78b0: 74 68 6f 64 73 2e 78 43 6c 6f 73 65 20 6d 65 74 thods.xClose met
78c0: 68 6f 64 0a 2a 2a 20 6d 61 79 20 62 65 20 69 6e hod.** may be in
78d0: 76 6f 6b 65 64 20 65 76 65 6e 20 69 66 20 74 68 voked even if th
78e0: 65 20 5b 73 71 6c 69 74 65 33 5f 76 66 73 2e 78 e [sqlite3_vfs.x
78f0: 4f 70 65 6e 5d 20 72 65 70 6f 72 74 65 64 20 74 Open] reported t
7900: 68 61 74 20 69 74 20 66 61 69 6c 65 64 2e 20 20 hat it failed.
7910: 54 68 65 0a 2a 2a 20 6f 6e 6c 79 20 77 61 79 20 The.** only way
7920: 74 6f 20 70 72 65 76 65 6e 74 20 61 20 63 61 6c to prevent a cal
7930: 6c 20 74 6f 20 78 43 6c 6f 73 65 20 66 6f 6c 6c l to xClose foll
7940: 6f 77 69 6e 67 20 61 20 66 61 69 6c 65 64 20 5b owing a failed [
7950: 73 71 6c 69 74 65 33 5f 76 66 73 2e 78 4f 70 65 sqlite3_vfs.xOpe
7960: 6e 5d 0a 2a 2a 20 69 73 20 66 6f 72 20 74 68 65 n].** is for the
7970: 20 5b 73 71 6c 69 74 65 33 5f 76 66 73 2e 78 4f [sqlite3_vfs.xO
7980: 70 65 6e 5d 20 74 6f 20 73 65 74 20 74 68 65 20 pen] to set the
7990: 73 71 6c 69 74 65 33 5f 66 69 6c 65 2e 70 4d 65 sqlite3_file.pMe
79a0: 74 68 6f 64 73 20 65 6c 65 6d 65 6e 74 0a 2a 2a thods element.**
79b0: 20 74 6f 20 4e 55 4c 4c 2e 0a 2a 2a 0a 2a 2a 20 to NULL..**.**
79c0: 54 68 65 20 66 6c 61 67 73 20 61 72 67 75 6d 65 The flags argume
79d0: 6e 74 20 74 6f 20 78 53 79 6e 63 20 6d 61 79 20 nt to xSync may
79e0: 62 65 20 6f 6e 65 20 6f 66 20 5b 53 51 4c 49 54 be one of [SQLIT
79f0: 45 5f 53 59 4e 43 5f 4e 4f 52 4d 41 4c 5d 20 6f E_SYNC_NORMAL] o
7a00: 72 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f 53 59 4e r.** [SQLITE_SYN
7a10: 43 5f 46 55 4c 4c 5d 2e 20 20 54 68 65 20 66 69 C_FULL]. The fi
7a20: 72 73 74 20 63 68 6f 69 63 65 20 69 73 20 74 68 rst choice is th
7a30: 65 20 6e 6f 72 6d 61 6c 20 66 73 79 6e 63 28 29 e normal fsync()
7a40: 2e 0a 2a 2a 20 54 68 65 20 73 65 63 6f 6e 64 20 ..** The second
7a50: 63 68 6f 69 63 65 20 69 73 20 61 20 4d 61 63 20 choice is a Mac
7a60: 4f 53 20 58 20 73 74 79 6c 65 20 66 75 6c 6c 73 OS X style fulls
7a70: 79 6e 63 2e 20 20 54 68 65 20 5b 53 51 4c 49 54 ync. The [SQLIT
7a80: 45 5f 53 59 4e 43 5f 44 41 54 41 4f 4e 4c 59 5d E_SYNC_DATAONLY]
7a90: 0a 2a 2a 20 66 6c 61 67 20 6d 61 79 20 62 65 20 .** flag may be
7aa0: 4f 52 65 64 20 69 6e 20 74 6f 20 69 6e 64 69 63 ORed in to indic
7ab0: 61 74 65 20 74 68 61 74 20 6f 6e 6c 79 20 74 68 ate that only th
7ac0: 65 20 64 61 74 61 20 6f 66 20 74 68 65 20 66 69 e data of the fi
7ad0: 6c 65 0a 2a 2a 20 61 6e 64 20 6e 6f 74 20 69 74 le.** and not it
7ae0: 73 20 69 6e 6f 64 65 20 6e 65 65 64 73 20 74 6f s inode needs to
7af0: 20 62 65 20 73 79 6e 63 65 64 2e 0a 2a 2a 0a 2a be synced..**.*
7b00: 2a 20 54 68 65 20 69 6e 74 65 67 65 72 20 76 61 * The integer va
7b10: 6c 75 65 73 20 74 6f 20 78 4c 6f 63 6b 28 29 20 lues to xLock()
7b20: 61 6e 64 20 78 55 6e 6c 6f 63 6b 28 29 20 61 72 and xUnlock() ar
7b30: 65 20 6f 6e 65 20 6f 66 0a 2a 2a 20 3c 75 6c 3e e one of.** <ul>
7b40: 0a 2a 2a 20 3c 6c 69 3e 20 5b 53 51 4c 49 54 45 .** <li> [SQLITE
7b50: 5f 4c 4f 43 4b 5f 4e 4f 4e 45 5d 2c 0a 2a 2a 20 _LOCK_NONE],.**
7b60: 3c 6c 69 3e 20 5b 53 51 4c 49 54 45 5f 4c 4f 43 <li> [SQLITE_LOC
7b70: 4b 5f 53 48 41 52 45 44 5d 2c 0a 2a 2a 20 3c 6c K_SHARED],.** <l
7b80: 69 3e 20 5b 53 51 4c 49 54 45 5f 4c 4f 43 4b 5f i> [SQLITE_LOCK_
7b90: 52 45 53 45 52 56 45 44 5d 2c 0a 2a 2a 20 3c 6c RESERVED],.** <l
7ba0: 69 3e 20 5b 53 51 4c 49 54 45 5f 4c 4f 43 4b 5f i> [SQLITE_LOCK_
7bb0: 50 45 4e 44 49 4e 47 5d 2c 20 6f 72 0a 2a 2a 20 PENDING], or.**
7bc0: 3c 6c 69 3e 20 5b 53 51 4c 49 54 45 5f 4c 4f 43 <li> [SQLITE_LOC
7bd0: 4b 5f 45 58 43 4c 55 53 49 56 45 5d 2e 0a 2a 2a K_EXCLUSIVE]..**
7be0: 20 3c 2f 75 6c 3e 0a 2a 2a 20 78 4c 6f 63 6b 28 </ul>.** xLock(
7bf0: 29 20 69 6e 63 72 65 61 73 65 73 20 74 68 65 20 ) increases the
7c00: 6c 6f 63 6b 2e 20 78 55 6e 6c 6f 63 6b 28 29 20 lock. xUnlock()
7c10: 64 65 63 72 65 61 73 65 73 20 74 68 65 20 6c 6f decreases the lo
7c20: 63 6b 2e 0a 2a 2a 20 54 68 65 20 78 43 68 65 63 ck..** The xChec
7c30: 6b 52 65 73 65 72 76 65 64 4c 6f 63 6b 28 29 20 kReservedLock()
7c40: 6d 65 74 68 6f 64 20 63 68 65 63 6b 73 20 77 68 method checks wh
7c50: 65 74 68 65 72 20 61 6e 79 20 64 61 74 61 62 61 ether any databa
7c60: 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 2c 0a 2a se connection,.*
7c70: 2a 20 65 69 74 68 65 72 20 69 6e 20 74 68 69 73 * either in this
7c80: 20 70 72 6f 63 65 73 73 20 6f 72 20 69 6e 20 73 process or in s
7c90: 6f 6d 65 20 6f 74 68 65 72 20 70 72 6f 63 65 73 ome other proces
7ca0: 73 2c 20 69 73 20 68 6f 6c 64 69 6e 67 20 61 20 s, is holding a
7cb0: 52 45 53 45 52 56 45 44 2c 0a 2a 2a 20 50 45 4e RESERVED,.** PEN
7cc0: 44 49 4e 47 2c 20 6f 72 20 45 58 43 4c 55 53 49 DING, or EXCLUSI
7cd0: 56 45 20 6c 6f 63 6b 20 6f 6e 20 74 68 65 20 66 VE lock on the f
7ce0: 69 6c 65 2e 20 20 49 74 20 72 65 74 75 72 6e 73 ile. It returns
7cf0: 20 74 72 75 65 0a 2a 2a 20 69 66 20 73 75 63 68 true.** if such
7d00: 20 61 20 6c 6f 63 6b 20 65 78 69 73 74 73 20 61 a lock exists a
7d10: 6e 64 20 66 61 6c 73 65 20 6f 74 68 65 72 77 69 nd false otherwi
7d20: 73 65 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 78 46 se..**.** The xF
7d30: 69 6c 65 43 6f 6e 74 72 6f 6c 28 29 20 6d 65 74 ileControl() met
7d40: 68 6f 64 20 69 73 20 61 20 67 65 6e 65 72 69 63 hod is a generic
7d50: 20 69 6e 74 65 72 66 61 63 65 20 74 68 61 74 20 interface that
7d60: 61 6c 6c 6f 77 73 20 63 75 73 74 6f 6d 0a 2a 2a allows custom.**
7d70: 20 56 46 53 20 69 6d 70 6c 65 6d 65 6e 74 61 74 VFS implementat
7d80: 69 6f 6e 73 20 74 6f 20 64 69 72 65 63 74 6c 79 ions to directly
7d90: 20 63 6f 6e 74 72 6f 6c 20 61 6e 20 6f 70 65 6e control an open
7da0: 20 66 69 6c 65 20 75 73 69 6e 67 20 74 68 65 0a file using the.
7db0: 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 66 69 6c 65 ** [sqlite3_file
7dc0: 5f 63 6f 6e 74 72 6f 6c 28 29 5d 20 69 6e 74 65 _control()] inte
7dd0: 72 66 61 63 65 2e 20 20 54 68 65 20 73 65 63 6f rface. The seco
7de0: 6e 64 20 22 6f 70 22 20 61 72 67 75 6d 65 6e 74 nd "op" argument
7df0: 20 69 73 20 61 6e 0a 2a 2a 20 69 6e 74 65 67 65 is an.** intege
7e00: 72 20 6f 70 63 6f 64 65 2e 20 20 54 68 65 20 74 r opcode. The t
7e10: 68 69 72 64 20 61 72 67 75 6d 65 6e 74 20 69 73 hird argument is
7e20: 20 61 20 67 65 6e 65 72 69 63 20 70 6f 69 6e 74 a generic point
7e30: 65 72 20 69 6e 74 65 6e 64 65 64 20 74 6f 0a 2a er intended to.*
7e40: 2a 20 70 6f 69 6e 74 20 74 6f 20 61 20 73 74 72 * point to a str
7e50: 75 63 74 75 72 65 20 74 68 61 74 20 6d 61 79 20 ucture that may
7e60: 63 6f 6e 74 61 69 6e 20 61 72 67 75 6d 65 6e 74 contain argument
7e70: 73 20 6f 72 20 73 70 61 63 65 20 69 6e 20 77 68 s or space in wh
7e80: 69 63 68 20 74 6f 0a 2a 2a 20 77 72 69 74 65 20 ich to.** write
7e90: 72 65 74 75 72 6e 20 76 61 6c 75 65 73 2e 20 20 return values.
7ea0: 50 6f 74 65 6e 74 69 61 6c 20 75 73 65 73 20 66 Potential uses f
7eb0: 6f 72 20 78 46 69 6c 65 43 6f 6e 74 72 6f 6c 28 or xFileControl(
7ec0: 29 20 6d 69 67 68 74 20 62 65 0a 2a 2a 20 66 75 ) might be.** fu
7ed0: 6e 63 74 69 6f 6e 73 20 74 6f 20 65 6e 61 62 6c nctions to enabl
7ee0: 65 20 62 6c 6f 63 6b 69 6e 67 20 6c 6f 63 6b 73 e blocking locks
7ef0: 20 77 69 74 68 20 74 69 6d 65 6f 75 74 73 2c 20 with timeouts,
7f00: 74 6f 20 63 68 61 6e 67 65 20 74 68 65 0a 2a 2a to change the.**
7f10: 20 6c 6f 63 6b 69 6e 67 20 73 74 72 61 74 65 67 locking strateg
7f20: 79 20 28 66 6f 72 20 65 78 61 6d 70 6c 65 20 74 y (for example t
7f30: 6f 20 75 73 65 20 64 6f 74 2d 66 69 6c 65 20 6c o use dot-file l
7f40: 6f 63 6b 73 29 2c 20 74 6f 20 69 6e 71 75 69 72 ocks), to inquir
7f50: 65 0a 2a 2a 20 61 62 6f 75 74 20 74 68 65 20 73 e.** about the s
7f60: 74 61 74 75 73 20 6f 66 20 61 20 6c 6f 63 6b 2c tatus of a lock,
7f70: 20 6f 72 20 74 6f 20 62 72 65 61 6b 20 73 74 61 or to break sta
7f80: 6c 65 20 6c 6f 63 6b 73 2e 20 20 54 68 65 20 53 le locks. The S
7f90: 51 4c 69 74 65 0a 2a 2a 20 63 6f 72 65 20 72 65 QLite.** core re
7fa0: 73 65 72 76 65 73 20 61 6c 6c 20 6f 70 63 6f 64 serves all opcod
7fb0: 65 73 20 6c 65 73 73 20 74 68 61 6e 20 31 30 30 es less than 100
7fc0: 20 66 6f 72 20 69 74 73 20 6f 77 6e 20 75 73 65 for its own use
7fd0: 2e 0a 2a 2a 20 41 20 5b 66 69 6c 65 20 63 6f 6e ..** A [file con
7fe0: 74 72 6f 6c 20 6f 70 63 6f 64 65 73 20 7c 20 6c trol opcodes | l
7ff0: 69 73 74 20 6f 66 20 6f 70 63 6f 64 65 73 5d 20 ist of opcodes]
8000: 6c 65 73 73 20 74 68 61 6e 20 31 30 30 20 69 73 less than 100 is
8010: 20 61 76 61 69 6c 61 62 6c 65 2e 0a 2a 2a 20 41 available..** A
8020: 70 70 6c 69 63 61 74 69 6f 6e 73 20 74 68 61 74 pplications that
8030: 20 64 65 66 69 6e 65 20 61 20 63 75 73 74 6f 6d define a custom
8040: 20 78 46 69 6c 65 43 6f 6e 74 72 6f 6c 20 6d 65 xFileControl me
8050: 74 68 6f 64 20 73 68 6f 75 6c 64 20 75 73 65 20 thod should use
8060: 6f 70 63 6f 64 65 73 0a 2a 2a 20 67 72 65 61 74 opcodes.** great
8070: 65 72 20 74 68 61 6e 20 31 30 30 20 74 6f 20 61 er than 100 to a
8080: 76 6f 69 64 20 63 6f 6e 66 6c 69 63 74 73 2e 20 void conflicts.
8090: 20 56 46 53 20 69 6d 70 6c 65 6d 65 6e 74 61 74 VFS implementat
80a0: 69 6f 6e 73 20 73 68 6f 75 6c 64 0a 2a 2a 20 72 ions should.** r
80b0: 65 74 75 72 6e 20 5b 53 51 4c 49 54 45 5f 4e 4f eturn [SQLITE_NO
80c0: 54 46 4f 55 4e 44 5d 20 66 6f 72 20 66 69 6c 65 TFOUND] for file
80d0: 20 63 6f 6e 74 72 6f 6c 20 6f 70 63 6f 64 65 73 control opcodes
80e0: 20 74 68 61 74 20 74 68 65 79 20 64 6f 20 6e 6f that they do no
80f0: 74 0a 2a 2a 20 72 65 63 6f 67 6e 69 7a 65 2e 0a t.** recognize..
8100: 2a 2a 0a 2a 2a 20 54 68 65 20 78 53 65 63 74 6f **.** The xSecto
8110: 72 53 69 7a 65 28 29 20 6d 65 74 68 6f 64 20 72 rSize() method r
8120: 65 74 75 72 6e 73 20 74 68 65 20 73 65 63 74 6f eturns the secto
8130: 72 20 73 69 7a 65 20 6f 66 20 74 68 65 0a 2a 2a r size of the.**
8140: 20 64 65 76 69 63 65 20 74 68 61 74 20 75 6e 64 device that und
8150: 65 72 6c 69 65 73 20 74 68 65 20 66 69 6c 65 2e erlies the file.
8160: 20 20 54 68 65 20 73 65 63 74 6f 72 20 73 69 7a The sector siz
8170: 65 20 69 73 20 74 68 65 0a 2a 2a 20 6d 69 6e 69 e is the.** mini
8180: 6d 75 6d 20 77 72 69 74 65 20 74 68 61 74 20 63 mum write that c
8190: 61 6e 20 62 65 20 70 65 72 66 6f 72 6d 65 64 20 an be performed
81a0: 77 69 74 68 6f 75 74 20 64 69 73 74 75 72 62 69 without disturbi
81b0: 6e 67 0a 2a 2a 20 6f 74 68 65 72 20 62 79 74 65 ng.** other byte
81c0: 73 20 69 6e 20 74 68 65 20 66 69 6c 65 2e 20 20 s in the file.
81d0: 54 68 65 20 78 44 65 76 69 63 65 43 68 61 72 61 The xDeviceChara
81e0: 63 74 65 72 69 73 74 69 63 73 28 29 0a 2a 2a 20 cteristics().**
81f0: 6d 65 74 68 6f 64 20 72 65 74 75 72 6e 73 20 61 method returns a
8200: 20 62 69 74 20 76 65 63 74 6f 72 20 64 65 73 63 bit vector desc
8210: 72 69 62 69 6e 67 20 62 65 68 61 76 69 6f 72 73 ribing behaviors
8220: 20 6f 66 20 74 68 65 0a 2a 2a 20 75 6e 64 65 72 of the.** under
8230: 6c 79 69 6e 67 20 64 65 76 69 63 65 3a 0a 2a 2a lying device:.**
8240: 0a 2a 2a 20 3c 75 6c 3e 0a 2a 2a 20 3c 6c 69 3e .** <ul>.** <li>
8250: 20 5b 53 51 4c 49 54 45 5f 49 4f 43 41 50 5f 41 [SQLITE_IOCAP_A
8260: 54 4f 4d 49 43 5d 0a 2a 2a 20 3c 6c 69 3e 20 5b TOMIC].** <li> [
8270: 53 51 4c 49 54 45 5f 49 4f 43 41 50 5f 41 54 4f SQLITE_IOCAP_ATO
8280: 4d 49 43 35 31 32 5d 0a 2a 2a 20 3c 6c 69 3e 20 MIC512].** <li>
8290: 5b 53 51 4c 49 54 45 5f 49 4f 43 41 50 5f 41 54 [SQLITE_IOCAP_AT
82a0: 4f 4d 49 43 31 4b 5d 0a 2a 2a 20 3c 6c 69 3e 20 OMIC1K].** <li>
82b0: 5b 53 51 4c 49 54 45 5f 49 4f 43 41 50 5f 41 54 [SQLITE_IOCAP_AT
82c0: 4f 4d 49 43 32 4b 5d 0a 2a 2a 20 3c 6c 69 3e 20 OMIC2K].** <li>
82d0: 5b 53 51 4c 49 54 45 5f 49 4f 43 41 50 5f 41 54 [SQLITE_IOCAP_AT
82e0: 4f 4d 49 43 34 4b 5d 0a 2a 2a 20 3c 6c 69 3e 20 OMIC4K].** <li>
82f0: 5b 53 51 4c 49 54 45 5f 49 4f 43 41 50 5f 41 54 [SQLITE_IOCAP_AT
8300: 4f 4d 49 43 38 4b 5d 0a 2a 2a 20 3c 6c 69 3e 20 OMIC8K].** <li>
8310: 5b 53 51 4c 49 54 45 5f 49 4f 43 41 50 5f 41 54 [SQLITE_IOCAP_AT
8320: 4f 4d 49 43 31 36 4b 5d 0a 2a 2a 20 3c 6c 69 3e OMIC16K].** <li>
8330: 20 5b 53 51 4c 49 54 45 5f 49 4f 43 41 50 5f 41 [SQLITE_IOCAP_A
8340: 54 4f 4d 49 43 33 32 4b 5d 0a 2a 2a 20 3c 6c 69 TOMIC32K].** <li
8350: 3e 20 5b 53 51 4c 49 54 45 5f 49 4f 43 41 50 5f > [SQLITE_IOCAP_
8360: 41 54 4f 4d 49 43 36 34 4b 5d 0a 2a 2a 20 3c 6c ATOMIC64K].** <l
8370: 69 3e 20 5b 53 51 4c 49 54 45 5f 49 4f 43 41 50 i> [SQLITE_IOCAP
8380: 5f 53 41 46 45 5f 41 50 50 45 4e 44 5d 0a 2a 2a _SAFE_APPEND].**
8390: 20 3c 6c 69 3e 20 5b 53 51 4c 49 54 45 5f 49 4f <li> [SQLITE_IO
83a0: 43 41 50 5f 53 45 51 55 45 4e 54 49 41 4c 5d 0a CAP_SEQUENTIAL].
83b0: 2a 2a 20 3c 2f 75 6c 3e 0a 2a 2a 0a 2a 2a 20 54 ** </ul>.**.** T
83c0: 68 65 20 53 51 4c 49 54 45 5f 49 4f 43 41 50 5f he SQLITE_IOCAP_
83d0: 41 54 4f 4d 49 43 20 70 72 6f 70 65 72 74 79 20 ATOMIC property
83e0: 6d 65 61 6e 73 20 74 68 61 74 20 61 6c 6c 20 77 means that all w
83f0: 72 69 74 65 73 20 6f 66 0a 2a 2a 20 61 6e 79 20 rites of.** any
8400: 73 69 7a 65 20 61 72 65 20 61 74 6f 6d 69 63 2e size are atomic.
8410: 20 20 54 68 65 20 53 51 4c 49 54 45 5f 49 4f 43 The SQLITE_IOC
8420: 41 50 5f 41 54 4f 4d 49 43 6e 6e 6e 20 76 61 6c AP_ATOMICnnn val
8430: 75 65 73 0a 2a 2a 20 6d 65 61 6e 20 74 68 61 74 ues.** mean that
8440: 20 77 72 69 74 65 73 20 6f 66 20 62 6c 6f 63 6b writes of block
8450: 73 20 74 68 61 74 20 61 72 65 20 6e 6e 6e 20 62 s that are nnn b
8460: 79 74 65 73 20 69 6e 20 73 69 7a 65 20 61 6e 64 ytes in size and
8470: 0a 2a 2a 20 61 72 65 20 61 6c 69 67 6e 65 64 20 .** are aligned
8480: 74 6f 20 61 6e 20 61 64 64 72 65 73 73 20 77 68 to an address wh
8490: 69 63 68 20 69 73 20 61 6e 20 69 6e 74 65 67 65 ich is an intege
84a0: 72 20 6d 75 6c 74 69 70 6c 65 20 6f 66 0a 2a 2a r multiple of.**
84b0: 20 6e 6e 6e 20 61 72 65 20 61 74 6f 6d 69 63 2e nnn are atomic.
84c0: 20 20 54 68 65 20 53 51 4c 49 54 45 5f 49 4f 43 The SQLITE_IOC
84d0: 41 50 5f 53 41 46 45 5f 41 50 50 45 4e 44 20 76 AP_SAFE_APPEND v
84e0: 61 6c 75 65 20 6d 65 61 6e 73 0a 2a 2a 20 74 68 alue means.** th
84f0: 61 74 20 77 68 65 6e 20 64 61 74 61 20 69 73 20 at when data is
8500: 61 70 70 65 6e 64 65 64 20 74 6f 20 61 20 66 69 appended to a fi
8510: 6c 65 2c 20 74 68 65 20 64 61 74 61 20 69 73 20 le, the data is
8520: 61 70 70 65 6e 64 65 64 0a 2a 2a 20 66 69 72 73 appended.** firs
8530: 74 20 74 68 65 6e 20 74 68 65 20 73 69 7a 65 20 t then the size
8540: 6f 66 20 74 68 65 20 66 69 6c 65 20 69 73 20 65 of the file is e
8550: 78 74 65 6e 64 65 64 2c 20 6e 65 76 65 72 20 74 xtended, never t
8560: 68 65 20 6f 74 68 65 72 0a 2a 2a 20 77 61 79 20 he other.** way
8570: 61 72 6f 75 6e 64 2e 20 20 54 68 65 20 53 51 4c around. The SQL
8580: 49 54 45 5f 49 4f 43 41 50 5f 53 45 51 55 45 4e ITE_IOCAP_SEQUEN
8590: 54 49 41 4c 20 70 72 6f 70 65 72 74 79 20 6d 65 TIAL property me
85a0: 61 6e 73 20 74 68 61 74 0a 2a 2a 20 69 6e 66 6f ans that.** info
85b0: 72 6d 61 74 69 6f 6e 20 69 73 20 77 72 69 74 74 rmation is writt
85c0: 65 6e 20 74 6f 20 64 69 73 6b 20 69 6e 20 74 68 en to disk in th
85d0: 65 20 73 61 6d 65 20 6f 72 64 65 72 20 61 73 20 e same order as
85e0: 63 61 6c 6c 73 0a 2a 2a 20 74 6f 20 78 57 72 69 calls.** to xWri
85f0: 74 65 28 29 2e 0a 2a 2a 0a 2a 2a 20 49 66 20 78 te()..**.** If x
8600: 52 65 61 64 28 29 20 72 65 74 75 72 6e 73 20 53 Read() returns S
8610: 51 4c 49 54 45 5f 49 4f 45 52 52 5f 53 48 4f 52 QLITE_IOERR_SHOR
8620: 54 5f 52 45 41 44 20 69 74 20 6d 75 73 74 20 61 T_READ it must a
8630: 6c 73 6f 20 66 69 6c 6c 0a 2a 2a 20 69 6e 20 74 lso fill.** in t
8640: 68 65 20 75 6e 72 65 61 64 20 70 6f 72 74 69 6f he unread portio
8650: 6e 73 20 6f 66 20 74 68 65 20 62 75 66 66 65 72 ns of the buffer
8660: 20 77 69 74 68 20 7a 65 72 6f 73 2e 20 20 41 20 with zeros. A
8670: 56 46 53 20 74 68 61 74 0a 2a 2a 20 66 61 69 6c VFS that.** fail
8680: 73 20 74 6f 20 7a 65 72 6f 2d 66 69 6c 6c 20 73 s to zero-fill s
8690: 68 6f 72 74 20 72 65 61 64 73 20 6d 69 67 68 74 hort reads might
86a0: 20 73 65 65 6d 20 74 6f 20 77 6f 72 6b 2e 20 20 seem to work.
86b0: 48 6f 77 65 76 65 72 2c 0a 2a 2a 20 66 61 69 6c However,.** fail
86c0: 75 72 65 20 74 6f 20 7a 65 72 6f 2d 66 69 6c 6c ure to zero-fill
86d0: 20 73 68 6f 72 74 20 72 65 61 64 73 20 77 69 6c short reads wil
86e0: 6c 20 65 76 65 6e 74 75 61 6c 6c 79 20 6c 65 61 l eventually lea
86f0: 64 20 74 6f 0a 2a 2a 20 64 61 74 61 62 61 73 65 d to.** database
8700: 20 63 6f 72 72 75 70 74 69 6f 6e 2e 0a 2a 2f 0a corruption..*/.
8710: 74 79 70 65 64 65 66 20 73 74 72 75 63 74 20 73 typedef struct s
8720: 71 6c 69 74 65 33 5f 69 6f 5f 6d 65 74 68 6f 64 qlite3_io_method
8730: 73 20 73 71 6c 69 74 65 33 5f 69 6f 5f 6d 65 74 s sqlite3_io_met
8740: 68 6f 64 73 3b 0a 73 74 72 75 63 74 20 73 71 6c hods;.struct sql
8750: 69 74 65 33 5f 69 6f 5f 6d 65 74 68 6f 64 73 20 ite3_io_methods
8760: 7b 0a 20 20 69 6e 74 20 69 56 65 72 73 69 6f 6e {. int iVersion
8770: 3b 0a 20 20 69 6e 74 20 28 2a 78 43 6c 6f 73 65 ;. int (*xClose
8780: 29 28 73 71 6c 69 74 65 33 5f 66 69 6c 65 2a 29 )(sqlite3_file*)
8790: 3b 0a 20 20 69 6e 74 20 28 2a 78 52 65 61 64 29 ;. int (*xRead)
87a0: 28 73 71 6c 69 74 65 33 5f 66 69 6c 65 2a 2c 20 (sqlite3_file*,
87b0: 76 6f 69 64 2a 2c 20 69 6e 74 20 69 41 6d 74 2c void*, int iAmt,
87c0: 20 73 71 6c 69 74 65 33 5f 69 6e 74 36 34 20 69 sqlite3_int64 i
87d0: 4f 66 73 74 29 3b 0a 20 20 69 6e 74 20 28 2a 78 Ofst);. int (*x
87e0: 57 72 69 74 65 29 28 73 71 6c 69 74 65 33 5f 66 Write)(sqlite3_f
87f0: 69 6c 65 2a 2c 20 63 6f 6e 73 74 20 76 6f 69 64 ile*, const void
8800: 2a 2c 20 69 6e 74 20 69 41 6d 74 2c 20 73 71 6c *, int iAmt, sql
8810: 69 74 65 33 5f 69 6e 74 36 34 20 69 4f 66 73 74 ite3_int64 iOfst
8820: 29 3b 0a 20 20 69 6e 74 20 28 2a 78 54 72 75 6e );. int (*xTrun
8830: 63 61 74 65 29 28 73 71 6c 69 74 65 33 5f 66 69 cate)(sqlite3_fi
8840: 6c 65 2a 2c 20 73 71 6c 69 74 65 33 5f 69 6e 74 le*, sqlite3_int
8850: 36 34 20 73 69 7a 65 29 3b 0a 20 20 69 6e 74 20 64 size);. int
8860: 28 2a 78 53 79 6e 63 29 28 73 71 6c 69 74 65 33 (*xSync)(sqlite3
8870: 5f 66 69 6c 65 2a 2c 20 69 6e 74 20 66 6c 61 67 _file*, int flag
8880: 73 29 3b 0a 20 20 69 6e 74 20 28 2a 78 46 69 6c s);. int (*xFil
8890: 65 53 69 7a 65 29 28 73 71 6c 69 74 65 33 5f 66 eSize)(sqlite3_f
88a0: 69 6c 65 2a 2c 20 73 71 6c 69 74 65 33 5f 69 6e ile*, sqlite3_in
88b0: 74 36 34 20 2a 70 53 69 7a 65 29 3b 0a 20 20 69 t64 *pSize);. i
88c0: 6e 74 20 28 2a 78 4c 6f 63 6b 29 28 73 71 6c 69 nt (*xLock)(sqli
88d0: 74 65 33 5f 66 69 6c 65 2a 2c 20 69 6e 74 29 3b te3_file*, int);
88e0: 0a 20 20 69 6e 74 20 28 2a 78 55 6e 6c 6f 63 6b . int (*xUnlock
88f0: 29 28 73 71 6c 69 74 65 33 5f 66 69 6c 65 2a 2c )(sqlite3_file*,
8900: 20 69 6e 74 29 3b 0a 20 20 69 6e 74 20 28 2a 78 int);. int (*x
8910: 43 68 65 63 6b 52 65 73 65 72 76 65 64 4c 6f 63 CheckReservedLoc
8920: 6b 29 28 73 71 6c 69 74 65 33 5f 66 69 6c 65 2a k)(sqlite3_file*
8930: 2c 20 69 6e 74 20 2a 70 52 65 73 4f 75 74 29 3b , int *pResOut);
8940: 0a 20 20 69 6e 74 20 28 2a 78 46 69 6c 65 43 6f . int (*xFileCo
8950: 6e 74 72 6f 6c 29 28 73 71 6c 69 74 65 33 5f 66 ntrol)(sqlite3_f
8960: 69 6c 65 2a 2c 20 69 6e 74 20 6f 70 2c 20 76 6f ile*, int op, vo
8970: 69 64 20 2a 70 41 72 67 29 3b 0a 20 20 69 6e 74 id *pArg);. int
8980: 20 28 2a 78 53 65 63 74 6f 72 53 69 7a 65 29 28 (*xSectorSize)(
8990: 73 71 6c 69 74 65 33 5f 66 69 6c 65 2a 29 3b 0a sqlite3_file*);.
89a0: 20 20 69 6e 74 20 28 2a 78 44 65 76 69 63 65 43 int (*xDeviceC
89b0: 68 61 72 61 63 74 65 72 69 73 74 69 63 73 29 28 haracteristics)(
89c0: 73 71 6c 69 74 65 33 5f 66 69 6c 65 2a 29 3b 0a sqlite3_file*);.
89d0: 20 20 2f 2a 20 4d 65 74 68 6f 64 73 20 61 62 6f /* Methods abo
89e0: 76 65 20 61 72 65 20 76 61 6c 69 64 20 66 6f 72 ve are valid for
89f0: 20 76 65 72 73 69 6f 6e 20 31 20 2a 2f 0a 20 20 version 1 */.
8a00: 69 6e 74 20 28 2a 78 53 68 6d 4d 61 70 29 28 73 int (*xShmMap)(s
8a10: 71 6c 69 74 65 33 5f 66 69 6c 65 2a 2c 20 69 6e qlite3_file*, in
8a20: 74 20 69 50 67 2c 20 69 6e 74 20 70 67 73 7a 2c t iPg, int pgsz,
8a30: 20 69 6e 74 2c 20 76 6f 69 64 20 76 6f 6c 61 74 int, void volat
8a40: 69 6c 65 2a 2a 29 3b 0a 20 20 69 6e 74 20 28 2a ile**);. int (*
8a50: 78 53 68 6d 4c 6f 63 6b 29 28 73 71 6c 69 74 65 xShmLock)(sqlite
8a60: 33 5f 66 69 6c 65 2a 2c 20 69 6e 74 20 6f 66 66 3_file*, int off
8a70: 73 65 74 2c 20 69 6e 74 20 6e 2c 20 69 6e 74 20 set, int n, int
8a80: 66 6c 61 67 73 29 3b 0a 20 20 76 6f 69 64 20 28 flags);. void (
8a90: 2a 78 53 68 6d 42 61 72 72 69 65 72 29 28 73 71 *xShmBarrier)(sq
8aa0: 6c 69 74 65 33 5f 66 69 6c 65 2a 29 3b 0a 20 20 lite3_file*);.
8ab0: 69 6e 74 20 28 2a 78 53 68 6d 55 6e 6d 61 70 29 int (*xShmUnmap)
8ac0: 28 73 71 6c 69 74 65 33 5f 66 69 6c 65 2a 2c 20 (sqlite3_file*,
8ad0: 69 6e 74 20 64 65 6c 65 74 65 46 6c 61 67 29 3b int deleteFlag);
8ae0: 0a 20 20 2f 2a 20 4d 65 74 68 6f 64 73 20 61 62 . /* Methods ab
8af0: 6f 76 65 20 61 72 65 20 76 61 6c 69 64 20 66 6f ove are valid fo
8b00: 72 20 76 65 72 73 69 6f 6e 20 32 20 2a 2f 0a 20 r version 2 */.
8b10: 20 69 6e 74 20 28 2a 78 46 65 74 63 68 29 28 73 int (*xFetch)(s
8b20: 71 6c 69 74 65 33 5f 66 69 6c 65 2a 2c 20 73 71 qlite3_file*, sq
8b30: 6c 69 74 65 33 5f 69 6e 74 36 34 20 69 4f 66 73 lite3_int64 iOfs
8b40: 74 2c 20 69 6e 74 20 69 41 6d 74 2c 20 76 6f 69 t, int iAmt, voi
8b50: 64 20 2a 2a 70 70 29 3b 0a 20 20 69 6e 74 20 28 d **pp);. int (
8b60: 2a 78 55 6e 66 65 74 63 68 29 28 73 71 6c 69 74 *xUnfetch)(sqlit
8b70: 65 33 5f 66 69 6c 65 2a 2c 20 73 71 6c 69 74 65 e3_file*, sqlite
8b80: 33 5f 69 6e 74 36 34 20 69 4f 66 73 74 2c 20 76 3_int64 iOfst, v
8b90: 6f 69 64 20 2a 70 29 3b 0a 20 20 2f 2a 20 4d 65 oid *p);. /* Me
8ba0: 74 68 6f 64 73 20 61 62 6f 76 65 20 61 72 65 20 thods above are
8bb0: 76 61 6c 69 64 20 66 6f 72 20 76 65 72 73 69 6f valid for versio
8bc0: 6e 20 33 20 2a 2f 0a 20 20 2f 2a 20 41 64 64 69 n 3 */. /* Addi
8bd0: 74 69 6f 6e 61 6c 20 6d 65 74 68 6f 64 73 20 6d tional methods m
8be0: 61 79 20 62 65 20 61 64 64 65 64 20 69 6e 20 66 ay be added in f
8bf0: 75 74 75 72 65 20 72 65 6c 65 61 73 65 73 20 2a uture releases *
8c00: 2f 0a 7d 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 /.};../*.** CAPI
8c10: 33 52 45 46 3a 20 53 74 61 6e 64 61 72 64 20 46 3REF: Standard F
8c20: 69 6c 65 20 43 6f 6e 74 72 6f 6c 20 4f 70 63 6f ile Control Opco
8c30: 64 65 73 0a 2a 2a 20 4b 45 59 57 4f 52 44 53 3a des.** KEYWORDS:
8c40: 20 7b 66 69 6c 65 20 63 6f 6e 74 72 6f 6c 20 6f {file control o
8c50: 70 63 6f 64 65 73 7d 20 7b 66 69 6c 65 20 63 6f pcodes} {file co
8c60: 6e 74 72 6f 6c 20 6f 70 63 6f 64 65 7d 0a 2a 2a ntrol opcode}.**
8c70: 0a 2a 2a 20 54 68 65 73 65 20 69 6e 74 65 67 65 .** These intege
8c80: 72 20 63 6f 6e 73 74 61 6e 74 73 20 61 72 65 20 r constants are
8c90: 6f 70 63 6f 64 65 73 20 66 6f 72 20 74 68 65 20 opcodes for the
8ca0: 78 46 69 6c 65 43 6f 6e 74 72 6f 6c 20 6d 65 74 xFileControl met
8cb0: 68 6f 64 0a 2a 2a 20 6f 66 20 74 68 65 20 5b 73 hod.** of the [s
8cc0: 71 6c 69 74 65 33 5f 69 6f 5f 6d 65 74 68 6f 64 qlite3_io_method
8cd0: 73 5d 20 6f 62 6a 65 63 74 20 61 6e 64 20 66 6f s] object and fo
8ce0: 72 20 74 68 65 20 5b 73 71 6c 69 74 65 33 5f 66 r the [sqlite3_f
8cf0: 69 6c 65 5f 63 6f 6e 74 72 6f 6c 28 29 5d 0a 2a ile_control()].*
8d00: 2a 20 69 6e 74 65 72 66 61 63 65 2e 0a 2a 2a 0a * interface..**.
8d10: 2a 2a 20 3c 75 6c 3e 0a 2a 2a 20 3c 6c 69 3e 5b ** <ul>.** <li>[
8d20: 5b 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 4c 4f [SQLITE_FCNTL_LO
8d30: 43 4b 53 54 41 54 45 5d 5d 0a 2a 2a 20 54 68 65 CKSTATE]].** The
8d40: 20 5b 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 4c [SQLITE_FCNTL_L
8d50: 4f 43 4b 53 54 41 54 45 5d 20 6f 70 63 6f 64 65 OCKSTATE] opcode
8d60: 20 69 73 20 75 73 65 64 20 66 6f 72 20 64 65 62 is used for deb
8d70: 75 67 67 69 6e 67 2e 20 20 54 68 69 73 0a 2a 2a ugging. This.**
8d80: 20 6f 70 63 6f 64 65 20 63 61 75 73 65 73 20 74 opcode causes t
8d90: 68 65 20 78 46 69 6c 65 43 6f 6e 74 72 6f 6c 20 he xFileControl
8da0: 6d 65 74 68 6f 64 20 74 6f 20 77 72 69 74 65 20 method to write
8db0: 74 68 65 20 63 75 72 72 65 6e 74 20 73 74 61 74 the current stat
8dc0: 65 20 6f 66 0a 2a 2a 20 74 68 65 20 6c 6f 63 6b e of.** the lock
8dd0: 20 28 6f 6e 65 20 6f 66 20 5b 53 51 4c 49 54 45 (one of [SQLITE
8de0: 5f 4c 4f 43 4b 5f 4e 4f 4e 45 5d 2c 20 5b 53 51 _LOCK_NONE], [SQ
8df0: 4c 49 54 45 5f 4c 4f 43 4b 5f 53 48 41 52 45 44 LITE_LOCK_SHARED
8e00: 5d 2c 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f 4c 4f ],.** [SQLITE_LO
8e10: 43 4b 5f 52 45 53 45 52 56 45 44 5d 2c 20 5b 53 CK_RESERVED], [S
8e20: 51 4c 49 54 45 5f 4c 4f 43 4b 5f 50 45 4e 44 49 QLITE_LOCK_PENDI
8e30: 4e 47 5d 2c 20 6f 72 20 5b 53 51 4c 49 54 45 5f NG], or [SQLITE_
8e40: 4c 4f 43 4b 5f 45 58 43 4c 55 53 49 56 45 5d 29 LOCK_EXCLUSIVE])
8e50: 0a 2a 2a 20 69 6e 74 6f 20 61 6e 20 69 6e 74 65 .** into an inte
8e60: 67 65 72 20 74 68 61 74 20 74 68 65 20 70 41 72 ger that the pAr
8e70: 67 20 61 72 67 75 6d 65 6e 74 20 70 6f 69 6e 74 g argument point
8e80: 73 20 74 6f 2e 20 54 68 69 73 20 63 61 70 61 62 s to. This capab
8e90: 69 6c 69 74 79 0a 2a 2a 20 69 73 20 75 73 65 64 ility.** is used
8ea0: 20 64 75 72 69 6e 67 20 74 65 73 74 69 6e 67 20 during testing
8eb0: 61 6e 64 20 69 73 20 6f 6e 6c 79 20 61 76 61 69 and is only avai
8ec0: 6c 61 62 6c 65 20 77 68 65 6e 20 74 68 65 20 53 lable when the S
8ed0: 51 4c 49 54 45 5f 54 45 53 54 0a 2a 2a 20 63 6f QLITE_TEST.** co
8ee0: 6d 70 69 6c 65 2d 74 69 6d 65 20 6f 70 74 69 6f mpile-time optio
8ef0: 6e 20 69 73 20 75 73 65 64 2e 0a 2a 2a 0a 2a 2a n is used..**.**
8f00: 20 3c 6c 69 3e 5b 5b 53 51 4c 49 54 45 5f 46 43 <li>[[SQLITE_FC
8f10: 4e 54 4c 5f 53 49 5a 45 5f 48 49 4e 54 5d 5d 0a NTL_SIZE_HINT]].
8f20: 2a 2a 20 54 68 65 20 5b 53 51 4c 49 54 45 5f 46 ** The [SQLITE_F
8f30: 43 4e 54 4c 5f 53 49 5a 45 5f 48 49 4e 54 5d 20 CNTL_SIZE_HINT]
8f40: 6f 70 63 6f 64 65 20 69 73 20 75 73 65 64 20 62 opcode is used b
8f50: 79 20 53 51 4c 69 74 65 20 74 6f 20 67 69 76 65 y SQLite to give
8f60: 20 74 68 65 20 56 46 53 0a 2a 2a 20 6c 61 79 65 the VFS.** laye
8f70: 72 20 61 20 68 69 6e 74 20 6f 66 20 68 6f 77 20 r a hint of how
8f80: 6c 61 72 67 65 20 74 68 65 20 64 61 74 61 62 61 large the databa
8f90: 73 65 20 66 69 6c 65 20 77 69 6c 6c 20 67 72 6f se file will gro
8fa0: 77 20 74 6f 20 62 65 20 64 75 72 69 6e 67 20 74 w to be during t
8fb0: 68 65 0a 2a 2a 20 63 75 72 72 65 6e 74 20 74 72 he.** current tr
8fc0: 61 6e 73 61 63 74 69 6f 6e 2e 20 20 54 68 69 73 ansaction. This
8fd0: 20 68 69 6e 74 20 69 73 20 6e 6f 74 20 67 75 61 hint is not gua
8fe0: 72 61 6e 74 65 65 64 20 74 6f 20 62 65 20 61 63 ranteed to be ac
8ff0: 63 75 72 61 74 65 20 62 75 74 20 69 74 0a 2a 2a curate but it.**
9000: 20 69 73 20 6f 66 74 65 6e 20 63 6c 6f 73 65 2e is often close.
9010: 20 20 54 68 65 20 75 6e 64 65 72 6c 79 69 6e 67 The underlying
9020: 20 56 46 53 20 6d 69 67 68 74 20 63 68 6f 6f 73 VFS might choos
9030: 65 20 74 6f 20 70 72 65 61 6c 6c 6f 63 61 74 65 e to preallocate
9040: 20 64 61 74 61 62 61 73 65 0a 2a 2a 20 66 69 6c database.** fil
9050: 65 20 73 70 61 63 65 20 62 61 73 65 64 20 6f 6e e space based on
9060: 20 74 68 69 73 20 68 69 6e 74 20 69 6e 20 6f 72 this hint in or
9070: 64 65 72 20 74 6f 20 68 65 6c 70 20 77 72 69 74 der to help writ
9080: 65 73 20 74 6f 20 74 68 65 20 64 61 74 61 62 61 es to the databa
9090: 73 65 0a 2a 2a 20 66 69 6c 65 20 72 75 6e 20 66 se.** file run f
90a0: 61 73 74 65 72 2e 0a 2a 2a 0a 2a 2a 20 3c 6c 69 aster..**.** <li
90b0: 3e 5b 5b 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f >[[SQLITE_FCNTL_
90c0: 43 48 55 4e 4b 5f 53 49 5a 45 5d 5d 0a 2a 2a 20 CHUNK_SIZE]].**
90d0: 54 68 65 20 5b 53 51 4c 49 54 45 5f 46 43 4e 54 The [SQLITE_FCNT
90e0: 4c 5f 43 48 55 4e 4b 5f 53 49 5a 45 5d 20 6f 70 L_CHUNK_SIZE] op
90f0: 63 6f 64 65 20 69 73 20 75 73 65 64 20 74 6f 20 code is used to
9100: 72 65 71 75 65 73 74 20 74 68 61 74 20 74 68 65 request that the
9110: 20 56 46 53 0a 2a 2a 20 65 78 74 65 6e 64 73 20 VFS.** extends
9120: 61 6e 64 20 74 72 75 6e 63 61 74 65 73 20 74 68 and truncates th
9130: 65 20 64 61 74 61 62 61 73 65 20 66 69 6c 65 20 e database file
9140: 69 6e 20 63 68 75 6e 6b 73 20 6f 66 20 61 20 73 in chunks of a s
9150: 69 7a 65 20 73 70 65 63 69 66 69 65 64 0a 2a 2a ize specified.**
9160: 20 62 79 20 74 68 65 20 75 73 65 72 2e 20 54 68 by the user. Th
9170: 65 20 66 6f 75 72 74 68 20 61 72 67 75 6d 65 6e e fourth argumen
9180: 74 20 74 6f 20 5b 73 71 6c 69 74 65 33 5f 66 69 t to [sqlite3_fi
9190: 6c 65 5f 63 6f 6e 74 72 6f 6c 28 29 5d 20 73 68 le_control()] sh
91a0: 6f 75 6c 64 20 0a 2a 2a 20 70 6f 69 6e 74 20 74 ould .** point t
91b0: 6f 20 61 6e 20 69 6e 74 65 67 65 72 20 28 74 79 o an integer (ty
91c0: 70 65 20 69 6e 74 29 20 63 6f 6e 74 61 69 6e 69 pe int) containi
91d0: 6e 67 20 74 68 65 20 6e 65 77 20 63 68 75 6e 6b ng the new chunk
91e0: 2d 73 69 7a 65 20 74 6f 20 75 73 65 0a 2a 2a 20 -size to use.**
91f0: 66 6f 72 20 74 68 65 20 6e 6f 6d 69 6e 61 74 65 for the nominate
9200: 64 20 64 61 74 61 62 61 73 65 2e 20 41 6c 6c 6f d database. Allo
9210: 63 61 74 69 6e 67 20 64 61 74 61 62 61 73 65 20 cating database
9220: 66 69 6c 65 20 73 70 61 63 65 20 69 6e 20 6c 61 file space in la
9230: 72 67 65 0a 2a 2a 20 63 68 75 6e 6b 73 20 28 73 rge.** chunks (s
9240: 61 79 20 31 4d 42 20 61 74 20 61 20 74 69 6d 65 ay 1MB at a time
9250: 29 2c 20 6d 61 79 20 72 65 64 75 63 65 20 66 69 ), may reduce fi
9260: 6c 65 2d 73 79 73 74 65 6d 20 66 72 61 67 6d 65 le-system fragme
9270: 6e 74 61 74 69 6f 6e 20 61 6e 64 0a 2a 2a 20 69 ntation and.** i
9280: 6d 70 72 6f 76 65 20 70 65 72 66 6f 72 6d 61 6e mprove performan
9290: 63 65 20 6f 6e 20 73 6f 6d 65 20 73 79 73 74 65 ce on some syste
92a0: 6d 73 2e 0a 2a 2a 0a 2a 2a 20 3c 6c 69 3e 5b 5b ms..**.** <li>[[
92b0: 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 46 49 4c SQLITE_FCNTL_FIL
92c0: 45 5f 50 4f 49 4e 54 45 52 5d 5d 0a 2a 2a 20 54 E_POINTER]].** T
92d0: 68 65 20 5b 53 51 4c 49 54 45 5f 46 43 4e 54 4c he [SQLITE_FCNTL
92e0: 5f 46 49 4c 45 5f 50 4f 49 4e 54 45 52 5d 20 6f _FILE_POINTER] o
92f0: 70 63 6f 64 65 20 69 73 20 75 73 65 64 20 74 6f pcode is used to
9300: 20 6f 62 74 61 69 6e 20 61 20 70 6f 69 6e 74 65 obtain a pointe
9310: 72 0a 2a 2a 20 74 6f 20 74 68 65 20 5b 73 71 6c r.** to the [sql
9320: 69 74 65 33 5f 66 69 6c 65 5d 20 6f 62 6a 65 63 ite3_file] objec
9330: 74 20 61 73 73 6f 63 69 61 74 65 64 20 77 69 74 t associated wit
9340: 68 20 61 20 70 61 72 74 69 63 75 6c 61 72 20 64 h a particular d
9350: 61 74 61 62 61 73 65 0a 2a 2a 20 63 6f 6e 6e 65 atabase.** conne
9360: 63 74 69 6f 6e 2e 20 20 53 65 65 20 61 6c 73 6f ction. See also
9370: 20 5b 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 4a [SQLITE_FCNTL_J
9380: 4f 55 52 4e 41 4c 5f 50 4f 49 4e 54 45 52 5d 2e OURNAL_POINTER].
9390: 0a 2a 2a 0a 2a 2a 20 3c 6c 69 3e 5b 5b 53 51 4c .**.** <li>[[SQL
93a0: 49 54 45 5f 46 43 4e 54 4c 5f 4a 4f 55 52 4e 41 ITE_FCNTL_JOURNA
93b0: 4c 5f 50 4f 49 4e 54 45 52 5d 5d 0a 2a 2a 20 54 L_POINTER]].** T
93c0: 68 65 20 5b 53 51 4c 49 54 45 5f 46 43 4e 54 4c he [SQLITE_FCNTL
93d0: 5f 4a 4f 55 52 4e 41 4c 5f 50 4f 49 4e 54 45 52 _JOURNAL_POINTER
93e0: 5d 20 6f 70 63 6f 64 65 20 69 73 20 75 73 65 64 ] opcode is used
93f0: 20 74 6f 20 6f 62 74 61 69 6e 20 61 20 70 6f 69 to obtain a poi
9400: 6e 74 65 72 0a 2a 2a 20 74 6f 20 74 68 65 20 5b nter.** to the [
9410: 73 71 6c 69 74 65 33 5f 66 69 6c 65 5d 20 6f 62 sqlite3_file] ob
9420: 6a 65 63 74 20 61 73 73 6f 63 69 61 74 65 64 20 ject associated
9430: 77 69 74 68 20 74 68 65 20 6a 6f 75 72 6e 61 6c with the journal
9440: 20 66 69 6c 65 20 28 65 69 74 68 65 72 0a 2a 2a file (either.**
9450: 20 74 68 65 20 5b 72 6f 6c 6c 62 61 63 6b 20 6a the [rollback j
9460: 6f 75 72 6e 61 6c 5d 20 6f 72 20 74 68 65 20 5b ournal] or the [
9470: 77 72 69 74 65 2d 61 68 65 61 64 20 6c 6f 67 5d write-ahead log]
9480: 29 20 66 6f 72 20 61 20 70 61 72 74 69 63 75 6c ) for a particul
9490: 61 72 20 64 61 74 61 62 61 73 65 0a 2a 2a 20 63 ar database.** c
94a0: 6f 6e 6e 65 63 74 69 6f 6e 2e 20 20 53 65 65 20 onnection. See
94b0: 61 6c 73 6f 20 5b 53 51 4c 49 54 45 5f 46 43 4e also [SQLITE_FCN
94c0: 54 4c 5f 46 49 4c 45 5f 50 4f 49 4e 54 45 52 5d TL_FILE_POINTER]
94d0: 2e 0a 2a 2a 0a 2a 2a 20 3c 6c 69 3e 5b 5b 53 51 ..**.** <li>[[SQ
94e0: 4c 49 54 45 5f 46 43 4e 54 4c 5f 53 59 4e 43 5f LITE_FCNTL_SYNC_
94f0: 4f 4d 49 54 54 45 44 5d 5d 0a 2a 2a 20 4e 6f 20 OMITTED]].** No
9500: 6c 6f 6e 67 65 72 20 69 6e 20 75 73 65 2e 0a 2a longer in use..*
9510: 2a 0a 2a 2a 20 3c 6c 69 3e 5b 5b 53 51 4c 49 54 *.** <li>[[SQLIT
9520: 45 5f 46 43 4e 54 4c 5f 53 59 4e 43 5d 5d 0a 2a E_FCNTL_SYNC]].*
9530: 2a 20 54 68 65 20 5b 53 51 4c 49 54 45 5f 46 43 * The [SQLITE_FC
9540: 4e 54 4c 5f 53 59 4e 43 5d 20 6f 70 63 6f 64 65 NTL_SYNC] opcode
9550: 20 69 73 20 67 65 6e 65 72 61 74 65 64 20 69 6e is generated in
9560: 74 65 72 6e 61 6c 6c 79 20 62 79 20 53 51 4c 69 ternally by SQLi
9570: 74 65 20 61 6e 64 0a 2a 2a 20 73 65 6e 74 20 74 te and.** sent t
9580: 6f 20 74 68 65 20 56 46 53 20 69 6d 6d 65 64 69 o the VFS immedi
9590: 61 74 65 6c 79 20 62 65 66 6f 72 65 20 74 68 65 ately before the
95a0: 20 78 53 79 6e 63 20 6d 65 74 68 6f 64 20 69 73 xSync method is
95b0: 20 69 6e 76 6f 6b 65 64 20 6f 6e 20 61 0a 2a 2a invoked on a.**
95c0: 20 64 61 74 61 62 61 73 65 20 66 69 6c 65 20 64 database file d
95d0: 65 73 63 72 69 70 74 6f 72 2e 20 4f 72 2c 20 69 escriptor. Or, i
95e0: 66 20 74 68 65 20 78 53 79 6e 63 20 6d 65 74 68 f the xSync meth
95f0: 6f 64 20 69 73 20 6e 6f 74 20 69 6e 76 6f 6b 65 od is not invoke
9600: 64 20 0a 2a 2a 20 62 65 63 61 75 73 65 20 74 68 d .** because th
9610: 65 20 75 73 65 72 20 68 61 73 20 63 6f 6e 66 69 e user has confi
9620: 67 75 72 65 64 20 53 51 4c 69 74 65 20 77 69 74 gured SQLite wit
9630: 68 20 0a 2a 2a 20 5b 50 52 41 47 4d 41 20 73 79 h .** [PRAGMA sy
9640: 6e 63 68 72 6f 6e 6f 75 73 20 7c 20 50 52 41 47 nchronous | PRAG
9650: 4d 41 20 73 79 6e 63 68 72 6f 6e 6f 75 73 3d 4f MA synchronous=O
9660: 46 46 5d 20 69 74 20 69 73 20 69 6e 76 6f 6b 65 FF] it is invoke
9670: 64 20 69 6e 20 70 6c 61 63 65 20 0a 2a 2a 20 6f d in place .** o
9680: 66 20 74 68 65 20 78 53 79 6e 63 20 6d 65 74 68 f the xSync meth
9690: 6f 64 2e 20 49 6e 20 6d 6f 73 74 20 63 61 73 65 od. In most case
96a0: 73 2c 20 74 68 65 20 70 6f 69 6e 74 65 72 20 61 s, the pointer a
96b0: 72 67 75 6d 65 6e 74 20 70 61 73 73 65 64 20 77 rgument passed w
96c0: 69 74 68 0a 2a 2a 20 74 68 69 73 20 66 69 6c 65 ith.** this file
96d0: 2d 63 6f 6e 74 72 6f 6c 20 69 73 20 4e 55 4c 4c -control is NULL
96e0: 2e 20 48 6f 77 65 76 65 72 2c 20 69 66 20 74 68 . However, if th
96f0: 65 20 64 61 74 61 62 61 73 65 20 66 69 6c 65 20 e database file
9700: 69 73 20 62 65 69 6e 67 20 73 79 6e 63 65 64 0a is being synced.
9710: 2a 2a 20 61 73 20 70 61 72 74 20 6f 66 20 61 20 ** as part of a
9720: 6d 75 6c 74 69 2d 64 61 74 61 62 61 73 65 20 63 multi-database c
9730: 6f 6d 6d 69 74 2c 20 74 68 65 20 61 72 67 75 6d ommit, the argum
9740: 65 6e 74 20 70 6f 69 6e 74 73 20 74 6f 20 61 20 ent points to a
9750: 6e 75 6c 2d 74 65 72 6d 69 6e 61 74 65 64 0a 2a nul-terminated.*
9760: 2a 20 73 74 72 69 6e 67 20 63 6f 6e 74 61 69 6e * string contain
9770: 69 6e 67 20 74 68 65 20 74 72 61 6e 73 61 63 74 ing the transact
9780: 69 6f 6e 73 20 6d 61 73 74 65 72 2d 6a 6f 75 72 ions master-jour
9790: 6e 61 6c 20 66 69 6c 65 20 6e 61 6d 65 2e 20 56 nal file name. V
97a0: 46 53 65 73 20 74 68 61 74 20 0a 2a 2a 20 64 6f FSes that .** do
97b0: 20 6e 6f 74 20 6e 65 65 64 20 74 68 69 73 20 73 not need this s
97c0: 69 67 6e 61 6c 20 73 68 6f 75 6c 64 20 73 69 6c ignal should sil
97d0: 65 6e 74 6c 79 20 69 67 6e 6f 72 65 20 74 68 69 ently ignore thi
97e0: 73 20 6f 70 63 6f 64 65 2e 20 41 70 70 6c 69 63 s opcode. Applic
97f0: 61 74 69 6f 6e 73 20 0a 2a 2a 20 73 68 6f 75 6c ations .** shoul
9800: 64 20 6e 6f 74 20 63 61 6c 6c 20 5b 73 71 6c 69 d not call [sqli
9810: 74 65 33 5f 66 69 6c 65 5f 63 6f 6e 74 72 6f 6c te3_file_control
9820: 28 29 5d 20 77 69 74 68 20 74 68 69 73 20 6f 70 ()] with this op
9830: 63 6f 64 65 20 61 73 20 64 6f 69 6e 67 20 73 6f code as doing so
9840: 20 6d 61 79 20 0a 2a 2a 20 64 69 73 72 75 70 74 may .** disrupt
9850: 20 74 68 65 20 6f 70 65 72 61 74 69 6f 6e 20 6f the operation o
9860: 66 20 74 68 65 20 73 70 65 63 69 61 6c 69 7a 65 f the specialize
9870: 64 20 56 46 53 65 73 20 74 68 61 74 20 64 6f 20 d VFSes that do
9880: 72 65 71 75 69 72 65 20 69 74 2e 20 20 0a 2a 2a require it. .**
9890: 0a 2a 2a 20 3c 6c 69 3e 5b 5b 53 51 4c 49 54 45 .** <li>[[SQLITE
98a0: 5f 46 43 4e 54 4c 5f 43 4f 4d 4d 49 54 5f 50 48 _FCNTL_COMMIT_PH
98b0: 41 53 45 54 57 4f 5d 5d 0a 2a 2a 20 54 68 65 20 ASETWO]].** The
98c0: 5b 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 43 4f [SQLITE_FCNTL_CO
98d0: 4d 4d 49 54 5f 50 48 41 53 45 54 57 4f 5d 20 6f MMIT_PHASETWO] o
98e0: 70 63 6f 64 65 20 69 73 20 67 65 6e 65 72 61 74 pcode is generat
98f0: 65 64 20 69 6e 74 65 72 6e 61 6c 6c 79 20 62 79 ed internally by
9900: 20 53 51 4c 69 74 65 0a 2a 2a 20 61 6e 64 20 73 SQLite.** and s
9910: 65 6e 74 20 74 6f 20 74 68 65 20 56 46 53 20 61 ent to the VFS a
9920: 66 74 65 72 20 61 20 74 72 61 6e 73 61 63 74 69 fter a transacti
9930: 6f 6e 20 68 61 73 20 62 65 65 6e 20 63 6f 6d 6d on has been comm
9940: 69 74 74 65 64 20 69 6d 6d 65 64 69 61 74 65 6c itted immediatel
9950: 79 0a 2a 2a 20 62 75 74 20 62 65 66 6f 72 65 20 y.** but before
9960: 74 68 65 20 64 61 74 61 62 61 73 65 20 69 73 20 the database is
9970: 75 6e 6c 6f 63 6b 65 64 2e 20 56 46 53 65 73 20 unlocked. VFSes
9980: 74 68 61 74 20 64 6f 20 6e 6f 74 20 6e 65 65 64 that do not need
9990: 20 74 68 69 73 20 73 69 67 6e 61 6c 0a 2a 2a 20 this signal.**
99a0: 73 68 6f 75 6c 64 20 73 69 6c 65 6e 74 6c 79 20 should silently
99b0: 69 67 6e 6f 72 65 20 74 68 69 73 20 6f 70 63 6f ignore this opco
99c0: 64 65 2e 20 41 70 70 6c 69 63 61 74 69 6f 6e 73 de. Applications
99d0: 20 73 68 6f 75 6c 64 20 6e 6f 74 20 63 61 6c 6c should not call
99e0: 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 66 69 6c .** [sqlite3_fil
99f0: 65 5f 63 6f 6e 74 72 6f 6c 28 29 5d 20 77 69 74 e_control()] wit
9a00: 68 20 74 68 69 73 20 6f 70 63 6f 64 65 20 61 73 h this opcode as
9a10: 20 64 6f 69 6e 67 20 73 6f 20 6d 61 79 20 64 69 doing so may di
9a20: 73 72 75 70 74 20 74 68 65 20 0a 2a 2a 20 6f 70 srupt the .** op
9a30: 65 72 61 74 69 6f 6e 20 6f 66 20 74 68 65 20 73 eration of the s
9a40: 70 65 63 69 61 6c 69 7a 65 64 20 56 46 53 65 73 pecialized VFSes
9a50: 20 74 68 61 74 20 64 6f 20 72 65 71 75 69 72 65 that do require
9a60: 20 69 74 2e 20 20 0a 2a 2a 0a 2a 2a 20 3c 6c 69 it. .**.** <li
9a70: 3e 5b 5b 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f >[[SQLITE_FCNTL_
9a80: 57 49 4e 33 32 5f 41 56 5f 52 45 54 52 59 5d 5d WIN32_AV_RETRY]]
9a90: 0a 2a 2a 20 5e 54 68 65 20 5b 53 51 4c 49 54 45 .** ^The [SQLITE
9aa0: 5f 46 43 4e 54 4c 5f 57 49 4e 33 32 5f 41 56 5f _FCNTL_WIN32_AV_
9ab0: 52 45 54 52 59 5d 20 6f 70 63 6f 64 65 20 69 73 RETRY] opcode is
9ac0: 20 75 73 65 64 20 74 6f 20 63 6f 6e 66 69 67 75 used to configu
9ad0: 72 65 20 61 75 74 6f 6d 61 74 69 63 0a 2a 2a 20 re automatic.**
9ae0: 72 65 74 72 79 20 63 6f 75 6e 74 73 20 61 6e 64 retry counts and
9af0: 20 69 6e 74 65 72 76 61 6c 73 20 66 6f 72 20 63 intervals for c
9b00: 65 72 74 61 69 6e 20 64 69 73 6b 20 49 2f 4f 20 ertain disk I/O
9b10: 6f 70 65 72 61 74 69 6f 6e 73 20 66 6f 72 20 74 operations for t
9b20: 68 65 0a 2a 2a 20 77 69 6e 64 6f 77 73 20 5b 56 he.** windows [V
9b30: 46 53 5d 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 FS] in order to
9b40: 70 72 6f 76 69 64 65 20 72 6f 62 75 73 74 6e 65 provide robustne
9b50: 73 73 20 69 6e 20 74 68 65 20 70 72 65 73 65 6e ss in the presen
9b60: 63 65 20 6f 66 0a 2a 2a 20 61 6e 74 69 2d 76 69 ce of.** anti-vi
9b70: 72 75 73 20 70 72 6f 67 72 61 6d 73 2e 20 20 42 rus programs. B
9b80: 79 20 64 65 66 61 75 6c 74 2c 20 74 68 65 20 77 y default, the w
9b90: 69 6e 64 6f 77 73 20 56 46 53 20 77 69 6c 6c 20 indows VFS will
9ba0: 72 65 74 72 79 20 66 69 6c 65 20 72 65 61 64 2c retry file read,
9bb0: 0a 2a 2a 20 66 69 6c 65 20 77 72 69 74 65 2c 20 .** file write,
9bc0: 61 6e 64 20 66 69 6c 65 20 64 65 6c 65 74 65 20 and file delete
9bd0: 6f 70 65 72 61 74 69 6f 6e 73 20 75 70 20 74 6f operations up to
9be0: 20 31 30 20 74 69 6d 65 73 2c 20 77 69 74 68 20 10 times, with
9bf0: 61 20 64 65 6c 61 79 0a 2a 2a 20 6f 66 20 32 35 a delay.** of 25
9c00: 20 6d 69 6c 6c 69 73 65 63 6f 6e 64 73 20 62 65 milliseconds be
9c10: 66 6f 72 65 20 74 68 65 20 66 69 72 73 74 20 72 fore the first r
9c20: 65 74 72 79 20 61 6e 64 20 77 69 74 68 20 74 68 etry and with th
9c30: 65 20 64 65 6c 61 79 20 69 6e 63 72 65 61 73 69 e delay increasi
9c40: 6e 67 0a 2a 2a 20 62 79 20 61 6e 20 61 64 64 69 ng.** by an addi
9c50: 74 69 6f 6e 61 6c 20 32 35 20 6d 69 6c 6c 69 73 tional 25 millis
9c60: 65 63 6f 6e 64 73 20 77 69 74 68 20 65 61 63 68 econds with each
9c70: 20 73 75 62 73 65 71 75 65 6e 74 20 72 65 74 72 subsequent retr
9c80: 79 2e 20 20 54 68 69 73 0a 2a 2a 20 6f 70 63 6f y. This.** opco
9c90: 64 65 20 61 6c 6c 6f 77 73 20 74 68 65 73 65 20 de allows these
9ca0: 74 77 6f 20 76 61 6c 75 65 73 20 28 31 30 20 72 two values (10 r
9cb0: 65 74 72 69 65 73 20 61 6e 64 20 32 35 20 6d 69 etries and 25 mi
9cc0: 6c 6c 69 73 65 63 6f 6e 64 73 20 6f 66 20 64 65 lliseconds of de
9cd0: 6c 61 79 29 0a 2a 2a 20 74 6f 20 62 65 20 61 64 lay).** to be ad
9ce0: 6a 75 73 74 65 64 2e 20 20 54 68 65 20 76 61 6c justed. The val
9cf0: 75 65 73 20 61 72 65 20 63 68 61 6e 67 65 64 20 ues are changed
9d00: 66 6f 72 20 61 6c 6c 20 64 61 74 61 62 61 73 65 for all database
9d10: 20 63 6f 6e 6e 65 63 74 69 6f 6e 73 0a 2a 2a 20 connections.**
9d20: 77 69 74 68 69 6e 20 74 68 65 20 73 61 6d 65 20 within the same
9d30: 70 72 6f 63 65 73 73 2e 20 20 54 68 65 20 61 72 process. The ar
9d40: 67 75 6d 65 6e 74 20 69 73 20 61 20 70 6f 69 6e gument is a poin
9d50: 74 65 72 20 74 6f 20 61 6e 20 61 72 72 61 79 20 ter to an array
9d60: 6f 66 20 74 77 6f 0a 2a 2a 20 69 6e 74 65 67 65 of two.** intege
9d70: 72 73 20 77 68 65 72 65 20 74 68 65 20 66 69 72 rs where the fir
9d80: 73 74 20 69 6e 74 65 67 65 72 20 69 20 74 68 65 st integer i the
9d90: 20 6e 65 77 20 72 65 74 72 79 20 63 6f 75 6e 74 new retry count
9da0: 20 61 6e 64 20 74 68 65 20 73 65 63 6f 6e 64 0a and the second.
9db0: 2a 2a 20 69 6e 74 65 67 65 72 20 69 73 20 74 68 ** integer is th
9dc0: 65 20 64 65 6c 61 79 2e 20 20 49 66 20 65 69 74 e delay. If eit
9dd0: 68 65 72 20 69 6e 74 65 67 65 72 20 69 73 20 6e her integer is n
9de0: 65 67 61 74 69 76 65 2c 20 74 68 65 6e 20 74 68 egative, then th
9df0: 65 20 73 65 74 74 69 6e 67 0a 2a 2a 20 69 73 20 e setting.** is
9e00: 6e 6f 74 20 63 68 61 6e 67 65 64 20 62 75 74 20 not changed but
9e10: 69 6e 73 74 65 61 64 20 74 68 65 20 70 72 69 6f instead the prio
9e20: 72 20 76 61 6c 75 65 20 6f 66 20 74 68 61 74 20 r value of that
9e30: 73 65 74 74 69 6e 67 20 69 73 20 77 72 69 74 74 setting is writt
9e40: 65 6e 0a 2a 2a 20 69 6e 74 6f 20 74 68 65 20 61 en.** into the a
9e50: 72 72 61 79 20 65 6e 74 72 79 2c 20 61 6c 6c 6f rray entry, allo
9e60: 77 69 6e 67 20 74 68 65 20 63 75 72 72 65 6e 74 wing the current
9e70: 20 72 65 74 72 79 20 73 65 74 74 69 6e 67 73 20 retry settings
9e80: 74 6f 20 62 65 0a 2a 2a 20 69 6e 74 65 72 72 6f to be.** interro
9e90: 67 61 74 65 64 2e 20 20 54 68 65 20 7a 44 62 4e gated. The zDbN
9ea0: 61 6d 65 20 70 61 72 61 6d 65 74 65 72 20 69 73 ame parameter is
9eb0: 20 69 67 6e 6f 72 65 64 2e 0a 2a 2a 0a 2a 2a 20 ignored..**.**
9ec0: 3c 6c 69 3e 5b 5b 53 51 4c 49 54 45 5f 46 43 4e <li>[[SQLITE_FCN
9ed0: 54 4c 5f 50 45 52 53 49 53 54 5f 57 41 4c 5d 5d TL_PERSIST_WAL]]
9ee0: 0a 2a 2a 20 5e 54 68 65 20 5b 53 51 4c 49 54 45 .** ^The [SQLITE
9ef0: 5f 46 43 4e 54 4c 5f 50 45 52 53 49 53 54 5f 57 _FCNTL_PERSIST_W
9f00: 41 4c 5d 20 6f 70 63 6f 64 65 20 69 73 20 75 73 AL] opcode is us
9f10: 65 64 20 74 6f 20 73 65 74 20 6f 72 20 71 75 65 ed to set or que
9f20: 72 79 20 74 68 65 0a 2a 2a 20 70 65 72 73 69 73 ry the.** persis
9f30: 74 65 6e 74 20 5b 57 41 4c 20 7c 20 57 72 69 74 tent [WAL | Writ
9f40: 65 20 41 68 65 61 64 20 4c 6f 67 5d 20 73 65 74 e Ahead Log] set
9f50: 74 69 6e 67 2e 20 20 42 79 20 64 65 66 61 75 6c ting. By defaul
9f60: 74 2c 20 74 68 65 20 61 75 78 69 6c 69 61 72 79 t, the auxiliary
9f70: 0a 2a 2a 20 77 72 69 74 65 20 61 68 65 61 64 20 .** write ahead
9f80: 6c 6f 67 20 61 6e 64 20 73 68 61 72 65 64 20 6d log and shared m
9f90: 65 6d 6f 72 79 20 66 69 6c 65 73 20 75 73 65 64 emory files used
9fa0: 20 66 6f 72 20 74 72 61 6e 73 61 63 74 69 6f 6e for transaction
9fb0: 20 63 6f 6e 74 72 6f 6c 0a 2a 2a 20 61 72 65 20 control.** are
9fc0: 61 75 74 6f 6d 61 74 69 63 61 6c 6c 79 20 64 65 automatically de
9fd0: 6c 65 74 65 64 20 77 68 65 6e 20 74 68 65 20 6c leted when the l
9fe0: 61 74 65 73 74 20 63 6f 6e 6e 65 63 74 69 6f 6e atest connection
9ff0: 20 74 6f 20 74 68 65 20 64 61 74 61 62 61 73 65 to the database
a000: 0a 2a 2a 20 63 6c 6f 73 65 73 2e 20 20 53 65 74 .** closes. Set
a010: 74 69 6e 67 20 70 65 72 73 69 73 74 65 6e 74 20 ting persistent
a020: 57 41 4c 20 6d 6f 64 65 20 63 61 75 73 65 73 20 WAL mode causes
a030: 74 68 6f 73 65 20 66 69 6c 65 73 20 74 6f 20 70 those files to p
a040: 65 72 73 69 73 74 20 61 66 74 65 72 0a 2a 2a 20 ersist after.**
a050: 63 6c 6f 73 65 2e 20 20 50 65 72 73 69 73 74 69 close. Persisti
a060: 6e 67 20 74 68 65 20 66 69 6c 65 73 20 69 73 20 ng the files is
a070: 75 73 65 66 75 6c 20 77 68 65 6e 20 6f 74 68 65 useful when othe
a080: 72 20 70 72 6f 63 65 73 73 65 73 20 74 68 61 74 r processes that
a090: 20 64 6f 20 6e 6f 74 0a 2a 2a 20 68 61 76 65 20 do not.** have
a0a0: 77 72 69 74 65 20 70 65 72 6d 69 73 73 69 6f 6e write permission
a0b0: 20 6f 6e 20 74 68 65 20 64 69 72 65 63 74 6f 72 on the director
a0c0: 79 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 y containing the
a0d0: 20 64 61 74 61 62 61 73 65 20 66 69 6c 65 20 77 database file w
a0e0: 61 6e 74 0a 2a 2a 20 74 6f 20 72 65 61 64 20 74 ant.** to read t
a0f0: 68 65 20 64 61 74 61 62 61 73 65 20 66 69 6c 65 he database file
a100: 2c 20 61 73 20 74 68 65 20 57 41 4c 20 61 6e 64 , as the WAL and
a110: 20 73 68 61 72 65 64 20 6d 65 6d 6f 72 79 20 66 shared memory f
a120: 69 6c 65 73 20 6d 75 73 74 20 65 78 69 73 74 0a iles must exist.
a130: 2a 2a 20 69 6e 20 6f 72 64 65 72 20 66 6f 72 20 ** in order for
a140: 74 68 65 20 64 61 74 61 62 61 73 65 20 74 6f 20 the database to
a150: 62 65 20 72 65 61 64 61 62 6c 65 2e 20 20 54 68 be readable. Th
a160: 65 20 66 6f 75 72 74 68 20 70 61 72 61 6d 65 74 e fourth paramet
a170: 65 72 20 74 6f 0a 2a 2a 20 5b 73 71 6c 69 74 65 er to.** [sqlite
a180: 33 5f 66 69 6c 65 5f 63 6f 6e 74 72 6f 6c 28 29 3_file_control()
a190: 5d 20 66 6f 72 20 74 68 69 73 20 6f 70 63 6f 64 ] for this opcod
a1a0: 65 20 73 68 6f 75 6c 64 20 62 65 20 61 20 70 6f e should be a po
a1b0: 69 6e 74 65 72 20 74 6f 20 61 6e 20 69 6e 74 65 inter to an inte
a1c0: 67 65 72 2e 0a 2a 2a 20 54 68 61 74 20 69 6e 74 ger..** That int
a1d0: 65 67 65 72 20 69 73 20 30 20 74 6f 20 64 69 73 eger is 0 to dis
a1e0: 61 62 6c 65 20 70 65 72 73 69 73 74 65 6e 74 20 able persistent
a1f0: 57 41 4c 20 6d 6f 64 65 20 6f 72 20 31 20 74 6f WAL mode or 1 to
a200: 20 65 6e 61 62 6c 65 20 70 65 72 73 69 73 74 65 enable persiste
a210: 6e 74 0a 2a 2a 20 57 41 4c 20 6d 6f 64 65 2e 20 nt.** WAL mode.
a220: 20 49 66 20 74 68 65 20 69 6e 74 65 67 65 72 20 If the integer
a230: 69 73 20 2d 31 2c 20 74 68 65 6e 20 69 74 20 69 is -1, then it i
a240: 73 20 6f 76 65 72 77 72 69 74 74 65 6e 20 77 69 s overwritten wi
a250: 74 68 20 74 68 65 20 63 75 72 72 65 6e 74 0a 2a th the current.*
a260: 2a 20 57 41 4c 20 70 65 72 73 69 73 74 65 6e 63 * WAL persistenc
a270: 65 20 73 65 74 74 69 6e 67 2e 0a 2a 2a 0a 2a 2a e setting..**.**
a280: 20 3c 6c 69 3e 5b 5b 53 51 4c 49 54 45 5f 46 43 <li>[[SQLITE_FC
a290: 4e 54 4c 5f 50 4f 57 45 52 53 41 46 45 5f 4f 56 NTL_POWERSAFE_OV
a2a0: 45 52 57 52 49 54 45 5d 5d 0a 2a 2a 20 5e 54 68 ERWRITE]].** ^Th
a2b0: 65 20 5b 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f e [SQLITE_FCNTL_
a2c0: 50 4f 57 45 52 53 41 46 45 5f 4f 56 45 52 57 52 POWERSAFE_OVERWR
a2d0: 49 54 45 5d 20 6f 70 63 6f 64 65 20 69 73 20 75 ITE] opcode is u
a2e0: 73 65 64 20 74 6f 20 73 65 74 20 6f 72 20 71 75 sed to set or qu
a2f0: 65 72 79 20 74 68 65 0a 2a 2a 20 70 65 72 73 69 ery the.** persi
a300: 73 74 65 6e 74 20 22 70 6f 77 65 72 73 61 66 65 stent "powersafe
a310: 2d 6f 76 65 72 77 72 69 74 65 22 20 6f 72 20 22 -overwrite" or "
a320: 50 53 4f 57 22 20 73 65 74 74 69 6e 67 2e 20 20 PSOW" setting.
a330: 54 68 65 20 50 53 4f 57 20 73 65 74 74 69 6e 67 The PSOW setting
a340: 0a 2a 2a 20 64 65 74 65 72 6d 69 6e 65 73 20 74 .** determines t
a350: 68 65 20 5b 53 51 4c 49 54 45 5f 49 4f 43 41 50 he [SQLITE_IOCAP
a360: 5f 50 4f 57 45 52 53 41 46 45 5f 4f 56 45 52 57 _POWERSAFE_OVERW
a370: 52 49 54 45 5d 20 62 69 74 20 6f 66 20 74 68 65 RITE] bit of the
a380: 0a 2a 2a 20 78 44 65 76 69 63 65 43 68 61 72 61 .** xDeviceChara
a390: 63 74 65 72 69 73 74 69 63 73 20 6d 65 74 68 6f cteristics metho
a3a0: 64 73 2e 20 54 68 65 20 66 6f 75 72 74 68 20 70 ds. The fourth p
a3b0: 61 72 61 6d 65 74 65 72 20 74 6f 0a 2a 2a 20 5b arameter to.** [
a3c0: 73 71 6c 69 74 65 33 5f 66 69 6c 65 5f 63 6f 6e sqlite3_file_con
a3d0: 74 72 6f 6c 28 29 5d 20 66 6f 72 20 74 68 69 73 trol()] for this
a3e0: 20 6f 70 63 6f 64 65 20 73 68 6f 75 6c 64 20 62 opcode should b
a3f0: 65 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 61 e a pointer to a
a400: 6e 20 69 6e 74 65 67 65 72 2e 0a 2a 2a 20 54 68 n integer..** Th
a410: 61 74 20 69 6e 74 65 67 65 72 20 69 73 20 30 20 at integer is 0
a420: 74 6f 20 64 69 73 61 62 6c 65 20 7a 65 72 6f 2d to disable zero-
a430: 64 61 6d 61 67 65 20 6d 6f 64 65 20 6f 72 20 31 damage mode or 1
a440: 20 74 6f 20 65 6e 61 62 6c 65 20 7a 65 72 6f 2d to enable zero-
a450: 64 61 6d 61 67 65 0a 2a 2a 20 6d 6f 64 65 2e 20 damage.** mode.
a460: 20 49 66 20 74 68 65 20 69 6e 74 65 67 65 72 20 If the integer
a470: 69 73 20 2d 31 2c 20 74 68 65 6e 20 69 74 20 69 is -1, then it i
a480: 73 20 6f 76 65 72 77 72 69 74 74 65 6e 20 77 69 s overwritten wi
a490: 74 68 20 74 68 65 20 63 75 72 72 65 6e 74 0a 2a th the current.*
a4a0: 2a 20 7a 65 72 6f 2d 64 61 6d 61 67 65 20 6d 6f * zero-damage mo
a4b0: 64 65 20 73 65 74 74 69 6e 67 2e 0a 2a 2a 0a 2a de setting..**.*
a4c0: 2a 20 3c 6c 69 3e 5b 5b 53 51 4c 49 54 45 5f 46 * <li>[[SQLITE_F
a4d0: 43 4e 54 4c 5f 4f 56 45 52 57 52 49 54 45 5d 5d CNTL_OVERWRITE]]
a4e0: 0a 2a 2a 20 5e 54 68 65 20 5b 53 51 4c 49 54 45 .** ^The [SQLITE
a4f0: 5f 46 43 4e 54 4c 5f 4f 56 45 52 57 52 49 54 45 _FCNTL_OVERWRITE
a500: 5d 20 6f 70 63 6f 64 65 20 69 73 20 69 6e 76 6f ] opcode is invo
a510: 6b 65 64 20 62 79 20 53 51 4c 69 74 65 20 61 66 ked by SQLite af
a520: 74 65 72 20 6f 70 65 6e 69 6e 67 0a 2a 2a 20 61 ter opening.** a
a530: 20 77 72 69 74 65 20 74 72 61 6e 73 61 63 74 69 write transacti
a540: 6f 6e 20 74 6f 20 69 6e 64 69 63 61 74 65 20 74 on to indicate t
a550: 68 61 74 2c 20 75 6e 6c 65 73 73 20 69 74 20 69 hat, unless it i
a560: 73 20 72 6f 6c 6c 65 64 20 62 61 63 6b 20 66 6f s rolled back fo
a570: 72 20 73 6f 6d 65 0a 2a 2a 20 72 65 61 73 6f 6e r some.** reason
a580: 2c 20 74 68 65 20 65 6e 74 69 72 65 20 64 61 74 , the entire dat
a590: 61 62 61 73 65 20 66 69 6c 65 20 77 69 6c 6c 20 abase file will
a5a0: 62 65 20 6f 76 65 72 77 72 69 74 74 65 6e 20 62 be overwritten b
a5b0: 79 20 74 68 65 20 63 75 72 72 65 6e 74 20 0a 2a y the current .*
a5c0: 2a 20 74 72 61 6e 73 61 63 74 69 6f 6e 2e 20 54 * transaction. T
a5d0: 68 69 73 20 69 73 20 75 73 65 64 20 62 79 20 56 his is used by V
a5e0: 41 43 55 55 4d 20 6f 70 65 72 61 74 69 6f 6e 73 ACUUM operations
a5f0: 2e 0a 2a 2a 0a 2a 2a 20 3c 6c 69 3e 5b 5b 53 51 ..**.** <li>[[SQ
a600: 4c 49 54 45 5f 46 43 4e 54 4c 5f 56 46 53 4e 41 LITE_FCNTL_VFSNA
a610: 4d 45 5d 5d 0a 2a 2a 20 5e 54 68 65 20 5b 53 51 ME]].** ^The [SQ
a620: 4c 49 54 45 5f 46 43 4e 54 4c 5f 56 46 53 4e 41 LITE_FCNTL_VFSNA
a630: 4d 45 5d 20 6f 70 63 6f 64 65 20 63 61 6e 20 62 ME] opcode can b
a640: 65 20 75 73 65 64 20 74 6f 20 6f 62 74 61 69 6e e used to obtain
a650: 20 74 68 65 20 6e 61 6d 65 73 20 6f 66 0a 2a 2a the names of.**
a660: 20 61 6c 6c 20 5b 56 46 53 65 73 5d 20 69 6e 20 all [VFSes] in
a670: 74 68 65 20 56 46 53 20 73 74 61 63 6b 2e 20 20 the VFS stack.
a680: 54 68 65 20 6e 61 6d 65 73 20 61 72 65 20 6f 66 The names are of
a690: 20 61 6c 6c 20 56 46 53 20 73 68 69 6d 73 20 61 all VFS shims a
a6a0: 6e 64 20 74 68 65 0a 2a 2a 20 66 69 6e 61 6c 20 nd the.** final
a6b0: 62 6f 74 74 6f 6d 2d 6c 65 76 65 6c 20 56 46 53 bottom-level VFS
a6c0: 20 61 72 65 20 77 72 69 74 74 65 6e 20 69 6e 74 are written int
a6d0: 6f 20 6d 65 6d 6f 72 79 20 6f 62 74 61 69 6e 65 o memory obtaine
a6e0: 64 20 66 72 6f 6d 20 0a 2a 2a 20 5b 73 71 6c 69 d from .** [sqli
a6f0: 74 65 33 5f 6d 61 6c 6c 6f 63 28 29 5d 20 61 6e te3_malloc()] an
a700: 64 20 74 68 65 20 72 65 73 75 6c 74 20 69 73 20 d the result is
a710: 73 74 6f 72 65 64 20 69 6e 20 74 68 65 20 63 68 stored in the ch
a720: 61 72 2a 20 76 61 72 69 61 62 6c 65 0a 2a 2a 20 ar* variable.**
a730: 74 68 61 74 20 74 68 65 20 66 6f 75 72 74 68 20 that the fourth
a740: 70 61 72 61 6d 65 74 65 72 20 6f 66 20 5b 73 71 parameter of [sq
a750: 6c 69 74 65 33 5f 66 69 6c 65 5f 63 6f 6e 74 72 lite3_file_contr
a760: 6f 6c 28 29 5d 20 70 6f 69 6e 74 73 20 74 6f 2e ol()] points to.
a770: 0a 2a 2a 20 54 68 65 20 63 61 6c 6c 65 72 20 69 .** The caller i
a780: 73 20 72 65 73 70 6f 6e 73 69 62 6c 65 20 66 6f s responsible fo
a790: 72 20 66 72 65 65 69 6e 67 20 74 68 65 20 6d 65 r freeing the me
a7a0: 6d 6f 72 79 20 77 68 65 6e 20 64 6f 6e 65 2e 20 mory when done.
a7b0: 20 41 73 20 77 69 74 68 0a 2a 2a 20 61 6c 6c 20 As with.** all
a7c0: 66 69 6c 65 2d 63 6f 6e 74 72 6f 6c 20 61 63 74 file-control act
a7d0: 69 6f 6e 73 2c 20 74 68 65 72 65 20 69 73 20 6e ions, there is n
a7e0: 6f 20 67 75 61 72 61 6e 74 65 65 20 74 68 61 74 o guarantee that
a7f0: 20 74 68 69 73 20 77 69 6c 6c 20 61 63 74 75 61 this will actua
a800: 6c 6c 79 0a 2a 2a 20 64 6f 20 61 6e 79 74 68 69 lly.** do anythi
a810: 6e 67 2e 20 20 43 61 6c 6c 65 72 73 20 73 68 6f ng. Callers sho
a820: 75 6c 64 20 69 6e 69 74 69 61 6c 69 7a 65 20 74 uld initialize t
a830: 68 65 20 63 68 61 72 2a 20 76 61 72 69 61 62 6c he char* variabl
a840: 65 20 74 6f 20 61 20 4e 55 4c 4c 0a 2a 2a 20 70 e to a NULL.** p
a850: 6f 69 6e 74 65 72 20 69 6e 20 63 61 73 65 20 74 ointer in case t
a860: 68 69 73 20 66 69 6c 65 2d 63 6f 6e 74 72 6f 6c his file-control
a870: 20 69 73 20 6e 6f 74 20 69 6d 70 6c 65 6d 65 6e is not implemen
a880: 74 65 64 2e 20 20 54 68 69 73 20 66 69 6c 65 2d ted. This file-
a890: 63 6f 6e 74 72 6f 6c 0a 2a 2a 20 69 73 20 69 6e control.** is in
a8a0: 74 65 6e 64 65 64 20 66 6f 72 20 64 69 61 67 6e tended for diagn
a8b0: 6f 73 74 69 63 20 75 73 65 20 6f 6e 6c 79 2e 0a ostic use only..
a8c0: 2a 2a 0a 2a 2a 20 3c 6c 69 3e 5b 5b 53 51 4c 49 **.** <li>[[SQLI
a8d0: 54 45 5f 46 43 4e 54 4c 5f 56 46 53 5f 50 4f 49 TE_FCNTL_VFS_POI
a8e0: 4e 54 45 52 5d 5d 0a 2a 2a 20 5e 54 68 65 20 5b NTER]].** ^The [
a8f0: 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 56 46 53 SQLITE_FCNTL_VFS
a900: 5f 50 4f 49 4e 54 45 52 5d 20 6f 70 63 6f 64 65 _POINTER] opcode
a910: 20 66 69 6e 64 73 20 61 20 70 6f 69 6e 74 65 72 finds a pointer
a920: 20 74 6f 20 74 68 65 20 74 6f 70 2d 6c 65 76 65 to the top-leve
a930: 6c 0a 2a 2a 20 5b 56 46 53 65 73 5d 20 63 75 72 l.** [VFSes] cur
a940: 72 65 6e 74 6c 79 20 69 6e 20 75 73 65 2e 20 20 rently in use.
a950: 5e 28 54 68 65 20 61 72 67 75 6d 65 6e 74 20 58 ^(The argument X
a960: 20 69 6e 0a 2a 2a 20 73 71 6c 69 74 65 33 5f 66 in.** sqlite3_f
a970: 69 6c 65 5f 63 6f 6e 74 72 6f 6c 28 64 62 2c 53 ile_control(db,S
a980: 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 56 46 53 5f QLITE_FCNTL_VFS_
a990: 50 4f 49 4e 54 45 52 2c 58 29 20 6d 75 73 74 20 POINTER,X) must
a9a0: 62 65 0a 2a 2a 20 6f 66 20 74 79 70 65 20 22 5b be.** of type "[
a9b0: 73 71 6c 69 74 65 33 5f 76 66 73 5d 20 2a 2a 22 sqlite3_vfs] **"
a9c0: 2e 20 20 54 68 69 73 20 6f 70 63 6f 64 65 73 20 . This opcodes
a9d0: 77 69 6c 6c 20 73 65 74 20 2a 58 0a 2a 2a 20 74 will set *X.** t
a9e0: 6f 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 o a pointer to t
a9f0: 68 65 20 74 6f 70 2d 6c 65 76 65 6c 20 56 46 53 he top-level VFS
aa00: 2e 29 5e 0a 2a 2a 20 5e 57 68 65 6e 20 74 68 65 .)^.** ^When the
aa10: 72 65 20 61 72 65 20 6d 75 6c 74 69 70 6c 65 20 re are multiple
aa20: 56 46 53 20 73 68 69 6d 73 20 69 6e 20 74 68 65 VFS shims in the
aa30: 20 73 74 61 63 6b 2c 20 74 68 69 73 20 6f 70 63 stack, this opc
aa40: 6f 64 65 20 66 69 6e 64 73 20 74 68 65 0a 2a 2a ode finds the.**
aa50: 20 75 70 70 65 72 2d 6d 6f 73 74 20 73 68 69 6d upper-most shim
aa60: 20 6f 6e 6c 79 2e 0a 2a 2a 0a 2a 2a 20 3c 6c 69 only..**.** <li
aa70: 3e 5b 5b 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f >[[SQLITE_FCNTL_
aa80: 50 52 41 47 4d 41 5d 5d 0a 2a 2a 20 5e 57 68 65 PRAGMA]].** ^Whe
aa90: 6e 65 76 65 72 20 61 20 5b 50 52 41 47 4d 41 5d never a [PRAGMA]
aaa0: 20 73 74 61 74 65 6d 65 6e 74 20 69 73 20 70 61 statement is pa
aab0: 72 73 65 64 2c 20 61 6e 20 5b 53 51 4c 49 54 45 rsed, an [SQLITE
aac0: 5f 46 43 4e 54 4c 5f 50 52 41 47 4d 41 5d 20 0a _FCNTL_PRAGMA] .
aad0: 2a 2a 20 66 69 6c 65 20 63 6f 6e 74 72 6f 6c 20 ** file control
aae0: 69 73 20 73 65 6e 74 20 74 6f 20 74 68 65 20 6f is sent to the o
aaf0: 70 65 6e 20 5b 73 71 6c 69 74 65 33 5f 66 69 6c pen [sqlite3_fil
ab00: 65 5d 20 6f 62 6a 65 63 74 20 63 6f 72 72 65 73 e] object corres
ab10: 70 6f 6e 64 69 6e 67 0a 2a 2a 20 74 6f 20 74 68 ponding.** to th
ab20: 65 20 64 61 74 61 62 61 73 65 20 66 69 6c 65 20 e database file
ab30: 74 6f 20 77 68 69 63 68 20 74 68 65 20 70 72 61 to which the pra
ab40: 67 6d 61 20 73 74 61 74 65 6d 65 6e 74 20 72 65 gma statement re
ab50: 66 65 72 73 2e 20 5e 54 68 65 20 61 72 67 75 6d fers. ^The argum
ab60: 65 6e 74 0a 2a 2a 20 74 6f 20 74 68 65 20 5b 53 ent.** to the [S
ab70: 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 50 52 41 47 QLITE_FCNTL_PRAG
ab80: 4d 41 5d 20 66 69 6c 65 20 63 6f 6e 74 72 6f 6c MA] file control
ab90: 20 69 73 20 61 6e 20 61 72 72 61 79 20 6f 66 0a is an array of.
aba0: 2a 2a 20 70 6f 69 6e 74 65 72 73 20 74 6f 20 73 ** pointers to s
abb0: 74 72 69 6e 67 73 20 28 63 68 61 72 2a 2a 29 20 trings (char**)
abc0: 69 6e 20 77 68 69 63 68 20 74 68 65 20 73 65 63 in which the sec
abd0: 6f 6e 64 20 65 6c 65 6d 65 6e 74 20 6f 66 20 74 ond element of t
abe0: 68 65 20 61 72 72 61 79 0a 2a 2a 20 69 73 20 74 he array.** is t
abf0: 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 70 he name of the p
ac00: 72 61 67 6d 61 20 61 6e 64 20 74 68 65 20 74 68 ragma and the th
ac10: 69 72 64 20 65 6c 65 6d 65 6e 74 20 69 73 20 74 ird element is t
ac20: 68 65 20 61 72 67 75 6d 65 6e 74 20 74 6f 20 74 he argument to t
ac30: 68 65 0a 2a 2a 20 70 72 61 67 6d 61 20 6f 72 20 he.** pragma or
ac40: 4e 55 4c 4c 20 69 66 20 74 68 65 20 70 72 61 67 NULL if the prag
ac50: 6d 61 20 68 61 73 20 6e 6f 20 61 72 67 75 6d 65 ma has no argume
ac60: 6e 74 2e 20 20 5e 54 68 65 20 68 61 6e 64 6c 65 nt. ^The handle
ac70: 72 20 66 6f 72 20 61 6e 0a 2a 2a 20 5b 53 51 4c r for an.** [SQL
ac80: 49 54 45 5f 46 43 4e 54 4c 5f 50 52 41 47 4d 41 ITE_FCNTL_PRAGMA
ac90: 5d 20 66 69 6c 65 20 63 6f 6e 74 72 6f 6c 20 63 ] file control c
aca0: 61 6e 20 6f 70 74 69 6f 6e 61 6c 6c 79 20 6d 61 an optionally ma
acb0: 6b 65 20 74 68 65 20 66 69 72 73 74 20 65 6c 65 ke the first ele
acc0: 6d 65 6e 74 0a 2a 2a 20 6f 66 20 74 68 65 20 63 ment.** of the c
acd0: 68 61 72 2a 2a 20 61 72 67 75 6d 65 6e 74 20 70 har** argument p
ace0: 6f 69 6e 74 20 74 6f 20 61 20 73 74 72 69 6e 67 oint to a string
acf0: 20 6f 62 74 61 69 6e 65 64 20 66 72 6f 6d 20 5b obtained from [
ad00: 73 71 6c 69 74 65 33 5f 6d 70 72 69 6e 74 66 28 sqlite3_mprintf(
ad10: 29 5d 0a 2a 2a 20 6f 72 20 74 68 65 20 65 71 75 )].** or the equ
ad20: 69 76 61 6c 65 6e 74 20 61 6e 64 20 74 68 61 74 ivalent and that
ad30: 20 73 74 72 69 6e 67 20 77 69 6c 6c 20 62 65 63 string will bec
ad40: 6f 6d 65 20 74 68 65 20 72 65 73 75 6c 74 20 6f ome the result o
ad50: 66 20 74 68 65 20 70 72 61 67 6d 61 20 6f 72 0a f the pragma or.
ad60: 2a 2a 20 74 68 65 20 65 72 72 6f 72 20 6d 65 73 ** the error mes
ad70: 73 61 67 65 20 69 66 20 74 68 65 20 70 72 61 67 sage if the prag
ad80: 6d 61 20 66 61 69 6c 73 2e 20 5e 49 66 20 74 68 ma fails. ^If th
ad90: 65 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f 46 43 4e e.** [SQLITE_FCN
ada0: 54 4c 5f 50 52 41 47 4d 41 5d 20 66 69 6c 65 20 TL_PRAGMA] file
adb0: 63 6f 6e 74 72 6f 6c 20 72 65 74 75 72 6e 73 20 control returns
adc0: 5b 53 51 4c 49 54 45 5f 4e 4f 54 46 4f 55 4e 44 [SQLITE_NOTFOUND
add0: 5d 2c 20 74 68 65 6e 20 6e 6f 72 6d 61 6c 20 0a ], then normal .
ade0: 2a 2a 20 5b 50 52 41 47 4d 41 5d 20 70 72 6f 63 ** [PRAGMA] proc
adf0: 65 73 73 69 6e 67 20 63 6f 6e 74 69 6e 75 65 73 essing continues
ae00: 2e 20 20 5e 49 66 20 74 68 65 20 5b 53 51 4c 49 . ^If the [SQLI
ae10: 54 45 5f 46 43 4e 54 4c 5f 50 52 41 47 4d 41 5d TE_FCNTL_PRAGMA]
ae20: 0a 2a 2a 20 66 69 6c 65 20 63 6f 6e 74 72 6f 6c .** file control
ae30: 20 72 65 74 75 72 6e 73 20 5b 53 51 4c 49 54 45 returns [SQLITE
ae40: 5f 4f 4b 5d 2c 20 74 68 65 6e 20 74 68 65 20 70 _OK], then the p
ae50: 61 72 73 65 72 20 61 73 73 75 6d 65 73 20 74 68 arser assumes th
ae60: 61 74 20 74 68 65 0a 2a 2a 20 56 46 53 20 68 61 at the.** VFS ha
ae70: 73 20 68 61 6e 64 6c 65 64 20 74 68 65 20 50 52 s handled the PR
ae80: 41 47 4d 41 20 69 74 73 65 6c 66 20 61 6e 64 20 AGMA itself and
ae90: 74 68 65 20 70 61 72 73 65 72 20 67 65 6e 65 72 the parser gener
aea0: 61 74 65 73 20 61 20 6e 6f 2d 6f 70 0a 2a 2a 20 ates a no-op.**
aeb0: 70 72 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 prepared stateme
aec0: 6e 74 20 69 66 20 72 65 73 75 6c 74 20 73 74 72 nt if result str
aed0: 69 6e 67 20 69 73 20 4e 55 4c 4c 2c 20 6f 72 20 ing is NULL, or
aee0: 74 68 61 74 20 72 65 74 75 72 6e 73 20 61 20 63 that returns a c
aef0: 6f 70 79 0a 2a 2a 20 6f 66 20 74 68 65 20 72 65 opy.** of the re
af00: 73 75 6c 74 20 73 74 72 69 6e 67 20 69 66 20 74 sult string if t
af10: 68 65 20 73 74 72 69 6e 67 20 69 73 20 6e 6f 6e he string is non
af20: 2d 4e 55 4c 4c 2e 0a 2a 2a 20 5e 49 66 20 74 68 -NULL..** ^If th
af30: 65 20 5b 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f e [SQLITE_FCNTL_
af40: 50 52 41 47 4d 41 5d 20 66 69 6c 65 20 63 6f 6e PRAGMA] file con
af50: 74 72 6f 6c 20 72 65 74 75 72 6e 73 0a 2a 2a 20 trol returns.**
af60: 61 6e 79 20 72 65 73 75 6c 74 20 63 6f 64 65 20 any result code
af70: 6f 74 68 65 72 20 74 68 61 6e 20 5b 53 51 4c 49 other than [SQLI
af80: 54 45 5f 4f 4b 5d 20 6f 72 20 5b 53 51 4c 49 54 TE_OK] or [SQLIT
af90: 45 5f 4e 4f 54 46 4f 55 4e 44 5d 2c 20 74 68 61 E_NOTFOUND], tha
afa0: 74 20 6d 65 61 6e 73 0a 2a 2a 20 74 68 61 74 20 t means.** that
afb0: 74 68 65 20 56 46 53 20 65 6e 63 6f 75 6e 74 65 the VFS encounte
afc0: 72 65 64 20 61 6e 20 65 72 72 6f 72 20 77 68 69 red an error whi
afd0: 6c 65 20 68 61 6e 64 6c 69 6e 67 20 74 68 65 20 le handling the
afe0: 5b 50 52 41 47 4d 41 5d 20 61 6e 64 20 74 68 65 [PRAGMA] and the
aff0: 0a 2a 2a 20 63 6f 6d 70 69 6c 61 74 69 6f 6e 20 .** compilation
b000: 6f 66 20 74 68 65 20 50 52 41 47 4d 41 20 66 61 of the PRAGMA fa
b010: 69 6c 73 20 77 69 74 68 20 61 6e 20 65 72 72 6f ils with an erro
b020: 72 2e 20 20 5e 54 68 65 20 5b 53 51 4c 49 54 45 r. ^The [SQLITE
b030: 5f 46 43 4e 54 4c 5f 50 52 41 47 4d 41 5d 0a 2a _FCNTL_PRAGMA].*
b040: 2a 20 66 69 6c 65 20 63 6f 6e 74 72 6f 6c 20 6f * file control o
b050: 63 63 75 72 73 20 61 74 20 74 68 65 20 62 65 67 ccurs at the beg
b060: 69 6e 6e 69 6e 67 20 6f 66 20 70 72 61 67 6d 61 inning of pragma
b070: 20 73 74 61 74 65 6d 65 6e 74 20 61 6e 61 6c 79 statement analy
b080: 73 69 73 20 61 6e 64 20 73 6f 0a 2a 2a 20 69 74 sis and so.** it
b090: 20 69 73 20 61 62 6c 65 20 74 6f 20 6f 76 65 72 is able to over
b0a0: 72 69 64 65 20 62 75 69 6c 74 2d 69 6e 20 5b 50 ride built-in [P
b0b0: 52 41 47 4d 41 5d 20 73 74 61 74 65 6d 65 6e 74 RAGMA] statement
b0c0: 73 2e 0a 2a 2a 0a 2a 2a 20 3c 6c 69 3e 5b 5b 53 s..**.** <li>[[S
b0d0: 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 42 55 53 59 QLITE_FCNTL_BUSY
b0e0: 48 41 4e 44 4c 45 52 5d 5d 0a 2a 2a 20 5e 54 68 HANDLER]].** ^Th
b0f0: 65 20 5b 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f e [SQLITE_FCNTL_
b100: 42 55 53 59 48 41 4e 44 4c 45 52 5d 0a 2a 2a 20 BUSYHANDLER].**
b110: 66 69 6c 65 2d 63 6f 6e 74 72 6f 6c 20 6d 61 79 file-control may
b120: 20 62 65 20 69 6e 76 6f 6b 65 64 20 62 79 20 53 be invoked by S
b130: 51 4c 69 74 65 20 6f 6e 20 74 68 65 20 64 61 74 QLite on the dat
b140: 61 62 61 73 65 20 66 69 6c 65 20 68 61 6e 64 6c abase file handl
b150: 65 0a 2a 2a 20 73 68 6f 72 74 6c 79 20 61 66 74 e.** shortly aft
b160: 65 72 20 69 74 20 69 73 20 6f 70 65 6e 65 64 20 er it is opened
b170: 69 6e 20 6f 72 64 65 72 20 74 6f 20 70 72 6f 76 in order to prov
b180: 69 64 65 20 61 20 63 75 73 74 6f 6d 20 56 46 53 ide a custom VFS
b190: 20 77 69 74 68 20 61 63 63 65 73 73 0a 2a 2a 20 with access.**
b1a0: 74 6f 20 74 68 65 20 63 6f 6e 6e 65 63 74 69 6f to the connectio
b1b0: 6e 73 20 62 75 73 79 2d 68 61 6e 64 6c 65 72 20 ns busy-handler
b1c0: 63 61 6c 6c 62 61 63 6b 2e 20 54 68 65 20 61 72 callback. The ar
b1d0: 67 75 6d 65 6e 74 20 69 73 20 6f 66 20 74 79 70 gument is of typ
b1e0: 65 20 28 76 6f 69 64 20 2a 2a 29 0a 2a 2a 20 2d e (void **).** -
b1f0: 20 61 6e 20 61 72 72 61 79 20 6f 66 20 74 77 6f an array of two
b200: 20 28 76 6f 69 64 20 2a 29 20 76 61 6c 75 65 73 (void *) values
b210: 2e 20 54 68 65 20 66 69 72 73 74 20 28 76 6f 69 . The first (voi
b220: 64 20 2a 29 20 61 63 74 75 61 6c 6c 79 20 70 6f d *) actually po
b230: 69 6e 74 73 0a 2a 2a 20 74 6f 20 61 20 66 75 6e ints.** to a fun
b240: 63 74 69 6f 6e 20 6f 66 20 74 79 70 65 20 28 69 ction of type (i
b250: 6e 74 20 28 2a 29 28 76 6f 69 64 20 2a 29 29 2e nt (*)(void *)).
b260: 20 49 6e 20 6f 72 64 65 72 20 74 6f 20 69 6e 76 In order to inv
b270: 6f 6b 65 20 74 68 65 20 63 6f 6e 6e 65 63 74 69 oke the connecti
b280: 6f 6e 73 0a 2a 2a 20 62 75 73 79 2d 68 61 6e 64 ons.** busy-hand
b290: 6c 65 72 2c 20 74 68 69 73 20 66 75 6e 63 74 69 ler, this functi
b2a0: 6f 6e 20 73 68 6f 75 6c 64 20 62 65 20 69 6e 76 on should be inv
b2b0: 6f 6b 65 64 20 77 69 74 68 20 74 68 65 20 73 65 oked with the se
b2c0: 63 6f 6e 64 20 28 76 6f 69 64 20 2a 29 20 69 6e cond (void *) in
b2d0: 0a 2a 2a 20 74 68 65 20 61 72 72 61 79 20 61 73 .** the array as
b2e0: 20 74 68 65 20 6f 6e 6c 79 20 61 72 67 75 6d 65 the only argume
b2f0: 6e 74 2e 20 49 66 20 69 74 20 72 65 74 75 72 6e nt. If it return
b300: 73 20 6e 6f 6e 2d 7a 65 72 6f 2c 20 74 68 65 6e s non-zero, then
b310: 20 74 68 65 20 6f 70 65 72 61 74 69 6f 6e 0a 2a the operation.*
b320: 2a 20 73 68 6f 75 6c 64 20 62 65 20 72 65 74 72 * should be retr
b330: 69 65 64 2e 20 49 66 20 69 74 20 72 65 74 75 72 ied. If it retur
b340: 6e 73 20 7a 65 72 6f 2c 20 74 68 65 20 63 75 73 ns zero, the cus
b350: 74 6f 6d 20 56 46 53 20 73 68 6f 75 6c 64 20 61 tom VFS should a
b360: 62 61 6e 64 6f 6e 20 74 68 65 0a 2a 2a 20 63 75 bandon the.** cu
b370: 72 72 65 6e 74 20 6f 70 65 72 61 74 69 6f 6e 2e rrent operation.
b380: 0a 2a 2a 0a 2a 2a 20 3c 6c 69 3e 5b 5b 53 51 4c .**.** <li>[[SQL
b390: 49 54 45 5f 46 43 4e 54 4c 5f 54 45 4d 50 46 49 ITE_FCNTL_TEMPFI
b3a0: 4c 45 4e 41 4d 45 5d 5d 0a 2a 2a 20 5e 41 70 70 LENAME]].** ^App
b3b0: 6c 69 63 61 74 69 6f 6e 20 63 61 6e 20 69 6e 76 lication can inv
b3c0: 6f 6b 65 20 74 68 65 20 5b 53 51 4c 49 54 45 5f oke the [SQLITE_
b3d0: 46 43 4e 54 4c 5f 54 45 4d 50 46 49 4c 45 4e 41 FCNTL_TEMPFILENA
b3e0: 4d 45 5d 20 66 69 6c 65 2d 63 6f 6e 74 72 6f 6c ME] file-control
b3f0: 0a 2a 2a 20 74 6f 20 68 61 76 65 20 53 51 4c 69 .** to have SQLi
b400: 74 65 20 67 65 6e 65 72 61 74 65 20 61 0a 2a 2a te generate a.**
b410: 20 74 65 6d 70 6f 72 61 72 79 20 66 69 6c 65 6e temporary filen
b420: 61 6d 65 20 75 73 69 6e 67 20 74 68 65 20 73 61 ame using the sa
b430: 6d 65 20 61 6c 67 6f 72 69 74 68 6d 20 74 68 61 me algorithm tha
b440: 74 20 69 73 20 66 6f 6c 6c 6f 77 65 64 20 74 6f t is followed to
b450: 20 67 65 6e 65 72 61 74 65 0a 2a 2a 20 74 65 6d generate.** tem
b460: 70 6f 72 61 72 79 20 66 69 6c 65 6e 61 6d 65 73 porary filenames
b470: 20 66 6f 72 20 54 45 4d 50 20 74 61 62 6c 65 73 for TEMP tables
b480: 20 61 6e 64 20 6f 74 68 65 72 20 69 6e 74 65 72 and other inter
b490: 6e 61 6c 20 75 73 65 73 2e 20 20 54 68 65 0a 2a nal uses. The.*
b4a0: 2a 20 61 72 67 75 6d 65 6e 74 20 73 68 6f 75 6c * argument shoul
b4b0: 64 20 62 65 20 61 20 63 68 61 72 2a 2a 20 77 68 d be a char** wh
b4c0: 69 63 68 20 77 69 6c 6c 20 62 65 20 66 69 6c 6c ich will be fill
b4d0: 65 64 20 77 69 74 68 20 74 68 65 20 66 69 6c 65 ed with the file
b4e0: 6e 61 6d 65 0a 2a 2a 20 77 72 69 74 74 65 6e 20 name.** written
b4f0: 69 6e 74 6f 20 6d 65 6d 6f 72 79 20 6f 62 74 61 into memory obta
b500: 69 6e 65 64 20 66 72 6f 6d 20 5b 73 71 6c 69 74 ined from [sqlit
b510: 65 33 5f 6d 61 6c 6c 6f 63 28 29 5d 2e 20 20 54 e3_malloc()]. T
b520: 68 65 20 63 61 6c 6c 65 72 20 73 68 6f 75 6c 64 he caller should
b530: 0a 2a 2a 20 69 6e 76 6f 6b 65 20 5b 73 71 6c 69 .** invoke [sqli
b540: 74 65 33 5f 66 72 65 65 28 29 5d 20 6f 6e 20 74 te3_free()] on t
b550: 68 65 20 72 65 73 75 6c 74 20 74 6f 20 61 76 6f he result to avo
b560: 69 64 20 61 20 6d 65 6d 6f 72 79 20 6c 65 61 6b id a memory leak
b570: 2e 0a 2a 2a 0a 2a 2a 20 3c 6c 69 3e 5b 5b 53 51 ..**.** <li>[[SQ
b580: 4c 49 54 45 5f 46 43 4e 54 4c 5f 4d 4d 41 50 5f LITE_FCNTL_MMAP_
b590: 53 49 5a 45 5d 5d 0a 2a 2a 20 54 68 65 20 5b 53 SIZE]].** The [S
b5a0: 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 4d 4d 41 50 QLITE_FCNTL_MMAP
b5b0: 5f 53 49 5a 45 5d 20 66 69 6c 65 20 63 6f 6e 74 _SIZE] file cont
b5c0: 72 6f 6c 20 69 73 20 75 73 65 64 20 74 6f 20 71 rol is used to q
b5d0: 75 65 72 79 20 6f 72 20 73 65 74 20 74 68 65 0a uery or set the.
b5e0: 2a 2a 20 6d 61 78 69 6d 75 6d 20 6e 75 6d 62 65 ** maximum numbe
b5f0: 72 20 6f 66 20 62 79 74 65 73 20 74 68 61 74 20 r of bytes that
b600: 77 69 6c 6c 20 62 65 20 75 73 65 64 20 66 6f 72 will be used for
b610: 20 6d 65 6d 6f 72 79 2d 6d 61 70 70 65 64 20 49 memory-mapped I
b620: 2f 4f 2e 0a 2a 2a 20 54 68 65 20 61 72 67 75 6d /O..** The argum
b630: 65 6e 74 20 69 73 20 61 20 70 6f 69 6e 74 65 72 ent is a pointer
b640: 20 74 6f 20 61 20 76 61 6c 75 65 20 6f 66 20 74 to a value of t
b650: 79 70 65 20 73 71 6c 69 74 65 33 5f 69 6e 74 36 ype sqlite3_int6
b660: 34 20 74 68 61 74 0a 2a 2a 20 69 73 20 61 6e 20 4 that.** is an
b670: 61 64 76 69 73 6f 72 79 20 6d 61 78 69 6d 75 6d advisory maximum
b680: 20 6e 75 6d 62 65 72 20 6f 66 20 62 79 74 65 73 number of bytes
b690: 20 69 6e 20 74 68 65 20 66 69 6c 65 20 74 6f 20 in the file to
b6a0: 6d 65 6d 6f 72 79 20 6d 61 70 2e 20 20 54 68 65 memory map. The
b6b0: 0a 2a 2a 20 70 6f 69 6e 74 65 72 20 69 73 20 6f .** pointer is o
b6c0: 76 65 72 77 72 69 74 74 65 6e 20 77 69 74 68 20 verwritten with
b6d0: 74 68 65 20 6f 6c 64 20 76 61 6c 75 65 2e 20 20 the old value.
b6e0: 54 68 65 20 6c 69 6d 69 74 20 69 73 20 6e 6f 74 The limit is not
b6f0: 20 63 68 61 6e 67 65 64 20 69 66 0a 2a 2a 20 74 changed if.** t
b700: 68 65 20 76 61 6c 75 65 20 6f 72 69 67 69 6e 61 he value origina
b710: 6c 6c 79 20 70 6f 69 6e 74 65 64 20 74 6f 20 69 lly pointed to i
b720: 73 20 6e 65 67 61 74 69 76 65 2c 20 61 6e 64 20 s negative, and
b730: 73 6f 20 74 68 65 20 63 75 72 72 65 6e 74 20 6c so the current l
b740: 69 6d 69 74 20 0a 2a 2a 20 63 61 6e 20 62 65 20 imit .** can be
b750: 71 75 65 72 69 65 64 20 62 79 20 70 61 73 73 69 queried by passi
b760: 6e 67 20 69 6e 20 61 20 70 6f 69 6e 74 65 72 20 ng in a pointer
b770: 74 6f 20 61 20 6e 65 67 61 74 69 76 65 20 6e 75 to a negative nu
b780: 6d 62 65 72 2e 20 20 54 68 69 73 0a 2a 2a 20 66 mber. This.** f
b790: 69 6c 65 2d 63 6f 6e 74 72 6f 6c 20 69 73 20 75 ile-control is u
b7a0: 73 65 64 20 69 6e 74 65 72 6e 61 6c 6c 79 20 74 sed internally t
b7b0: 6f 20 69 6d 70 6c 65 6d 65 6e 74 20 5b 50 52 41 o implement [PRA
b7c0: 47 4d 41 20 6d 6d 61 70 5f 73 69 7a 65 5d 2e 0a GMA mmap_size]..
b7d0: 2a 2a 0a 2a 2a 20 3c 6c 69 3e 5b 5b 53 51 4c 49 **.** <li>[[SQLI
b7e0: 54 45 5f 46 43 4e 54 4c 5f 54 52 41 43 45 5d 5d TE_FCNTL_TRACE]]
b7f0: 0a 2a 2a 20 54 68 65 20 5b 53 51 4c 49 54 45 5f .** The [SQLITE_
b800: 46 43 4e 54 4c 5f 54 52 41 43 45 5d 20 66 69 6c FCNTL_TRACE] fil
b810: 65 20 63 6f 6e 74 72 6f 6c 20 70 72 6f 76 69 64 e control provid
b820: 65 73 20 61 64 76 69 73 6f 72 79 20 69 6e 66 6f es advisory info
b830: 72 6d 61 74 69 6f 6e 0a 2a 2a 20 74 6f 20 74 68 rmation.** to th
b840: 65 20 56 46 53 20 61 62 6f 75 74 20 77 68 61 74 e VFS about what
b850: 20 74 68 65 20 68 69 67 68 65 72 20 6c 61 79 65 the higher laye
b860: 72 73 20 6f 66 20 74 68 65 20 53 51 4c 69 74 65 rs of the SQLite
b870: 20 73 74 61 63 6b 20 61 72 65 20 64 6f 69 6e 67 stack are doing
b880: 2e 0a 2a 2a 20 54 68 69 73 20 66 69 6c 65 20 63 ..** This file c
b890: 6f 6e 74 72 6f 6c 20 69 73 20 75 73 65 64 20 62 ontrol is used b
b8a0: 79 20 73 6f 6d 65 20 56 46 53 20 61 63 74 69 76 y some VFS activ
b8b0: 69 74 79 20 74 72 61 63 69 6e 67 20 5b 73 68 69 ity tracing [shi
b8c0: 6d 73 5d 2e 0a 2a 2a 20 54 68 65 20 61 72 67 75 ms]..** The argu
b8d0: 6d 65 6e 74 20 69 73 20 61 20 7a 65 72 6f 2d 74 ment is a zero-t
b8e0: 65 72 6d 69 6e 61 74 65 64 20 73 74 72 69 6e 67 erminated string
b8f0: 2e 20 20 48 69 67 68 65 72 20 6c 61 79 65 72 73 . Higher layers
b900: 20 69 6e 20 74 68 65 0a 2a 2a 20 53 51 4c 69 74 in the.** SQLit
b910: 65 20 73 74 61 63 6b 20 6d 61 79 20 67 65 6e 65 e stack may gene
b920: 72 61 74 65 20 69 6e 73 74 61 6e 63 65 73 20 6f rate instances o
b930: 66 20 74 68 69 73 20 66 69 6c 65 20 63 6f 6e 74 f this file cont
b940: 72 6f 6c 20 69 66 0a 2a 2a 20 74 68 65 20 5b 53 rol if.** the [S
b950: 51 4c 49 54 45 5f 55 53 45 5f 46 43 4e 54 4c 5f QLITE_USE_FCNTL_
b960: 54 52 41 43 45 5d 20 63 6f 6d 70 69 6c 65 2d 74 TRACE] compile-t
b970: 69 6d 65 20 6f 70 74 69 6f 6e 20 69 73 20 65 6e ime option is en
b980: 61 62 6c 65 64 2e 0a 2a 2a 0a 2a 2a 20 3c 6c 69 abled..**.** <li
b990: 3e 5b 5b 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f >[[SQLITE_FCNTL_
b9a0: 48 41 53 5f 4d 4f 56 45 44 5d 5d 0a 2a 2a 20 54 HAS_MOVED]].** T
b9b0: 68 65 20 5b 53 51 4c 49 54 45 5f 46 43 4e 54 4c he [SQLITE_FCNTL
b9c0: 5f 48 41 53 5f 4d 4f 56 45 44 5d 20 66 69 6c 65 _HAS_MOVED] file
b9d0: 20 63 6f 6e 74 72 6f 6c 20 69 6e 74 65 72 70 72 control interpr
b9e0: 65 74 73 20 69 74 73 20 61 72 67 75 6d 65 6e 74 ets its argument
b9f0: 20 61 73 20 61 0a 2a 2a 20 70 6f 69 6e 74 65 72 as a.** pointer
ba00: 20 74 6f 20 61 6e 20 69 6e 74 65 67 65 72 20 61 to an integer a
ba10: 6e 64 20 69 74 20 77 72 69 74 65 73 20 61 20 62 nd it writes a b
ba20: 6f 6f 6c 65 61 6e 20 69 6e 74 6f 20 74 68 61 74 oolean into that
ba30: 20 69 6e 74 65 67 65 72 20 64 65 70 65 6e 64 69 integer dependi
ba40: 6e 67 0a 2a 2a 20 6f 6e 20 77 68 65 74 68 65 72 ng.** on whether
ba50: 20 6f 72 20 6e 6f 74 20 74 68 65 20 66 69 6c 65 or not the file
ba60: 20 68 61 73 20 62 65 65 6e 20 72 65 6e 61 6d 65 has been rename
ba70: 64 2c 20 6d 6f 76 65 64 2c 20 6f 72 20 64 65 6c d, moved, or del
ba80: 65 74 65 64 20 73 69 6e 63 65 20 69 74 0a 2a 2a eted since it.**
ba90: 20 77 61 73 20 66 69 72 73 74 20 6f 70 65 6e 65 was first opene
baa0: 64 2e 0a 2a 2a 0a 2a 2a 20 3c 6c 69 3e 5b 5b 53 d..**.** <li>[[S
bab0: 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 57 49 4e 33 QLITE_FCNTL_WIN3
bac0: 32 5f 47 45 54 5f 48 41 4e 44 4c 45 5d 5d 0a 2a 2_GET_HANDLE]].*
bad0: 2a 20 54 68 65 20 5b 53 51 4c 49 54 45 5f 46 43 * The [SQLITE_FC
bae0: 4e 54 4c 5f 57 49 4e 33 32 5f 47 45 54 5f 48 41 NTL_WIN32_GET_HA
baf0: 4e 44 4c 45 5d 20 6f 70 63 6f 64 65 20 63 61 6e NDLE] opcode can
bb00: 20 62 65 20 75 73 65 64 20 74 6f 20 6f 62 74 61 be used to obta
bb10: 69 6e 20 74 68 65 0a 2a 2a 20 75 6e 64 65 72 6c in the.** underl
bb20: 79 69 6e 67 20 6e 61 74 69 76 65 20 66 69 6c 65 ying native file
bb30: 20 68 61 6e 64 6c 65 20 61 73 73 6f 63 69 61 74 handle associat
bb40: 65 64 20 77 69 74 68 20 61 20 66 69 6c 65 20 68 ed with a file h
bb50: 61 6e 64 6c 65 2e 20 20 54 68 69 73 20 66 69 6c andle. This fil
bb60: 65 0a 2a 2a 20 63 6f 6e 74 72 6f 6c 20 69 6e 74 e.** control int
bb70: 65 72 70 72 65 74 73 20 69 74 73 20 61 72 67 75 erprets its argu
bb80: 6d 65 6e 74 20 61 73 20 61 20 70 6f 69 6e 74 65 ment as a pointe
bb90: 72 20 74 6f 20 61 20 6e 61 74 69 76 65 20 66 69 r to a native fi
bba0: 6c 65 20 68 61 6e 64 6c 65 20 61 6e 64 0a 2a 2a le handle and.**
bbb0: 20 77 72 69 74 65 73 20 74 68 65 20 72 65 73 75 writes the resu
bbc0: 6c 74 69 6e 67 20 76 61 6c 75 65 20 74 68 65 72 lting value ther
bbd0: 65 2e 0a 2a 2a 0a 2a 2a 20 3c 6c 69 3e 5b 5b 53 e..**.** <li>[[S
bbe0: 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 57 49 4e 33 QLITE_FCNTL_WIN3
bbf0: 32 5f 53 45 54 5f 48 41 4e 44 4c 45 5d 5d 0a 2a 2_SET_HANDLE]].*
bc00: 2a 20 54 68 65 20 5b 53 51 4c 49 54 45 5f 46 43 * The [SQLITE_FC
bc10: 4e 54 4c 5f 57 49 4e 33 32 5f 53 45 54 5f 48 41 NTL_WIN32_SET_HA
bc20: 4e 44 4c 45 5d 20 6f 70 63 6f 64 65 20 69 73 20 NDLE] opcode is
bc30: 75 73 65 64 20 66 6f 72 20 64 65 62 75 67 67 69 used for debuggi
bc40: 6e 67 2e 20 20 54 68 69 73 0a 2a 2a 20 6f 70 63 ng. This.** opc
bc50: 6f 64 65 20 63 61 75 73 65 73 20 74 68 65 20 78 ode causes the x
bc60: 46 69 6c 65 43 6f 6e 74 72 6f 6c 20 6d 65 74 68 FileControl meth
bc70: 6f 64 20 74 6f 20 73 77 61 70 20 74 68 65 20 66 od to swap the f
bc80: 69 6c 65 20 68 61 6e 64 6c 65 20 77 69 74 68 20 ile handle with
bc90: 74 68 65 20 6f 6e 65 0a 2a 2a 20 70 6f 69 6e 74 the one.** point
bca0: 65 64 20 74 6f 20 62 79 20 74 68 65 20 70 41 72 ed to by the pAr
bcb0: 67 20 61 72 67 75 6d 65 6e 74 2e 20 20 54 68 69 g argument. Thi
bcc0: 73 20 63 61 70 61 62 69 6c 69 74 79 20 69 73 20 s capability is
bcd0: 75 73 65 64 20 64 75 72 69 6e 67 20 74 65 73 74 used during test
bce0: 69 6e 67 0a 2a 2a 20 61 6e 64 20 6f 6e 6c 79 20 ing.** and only
bcf0: 6e 65 65 64 73 20 74 6f 20 62 65 20 73 75 70 70 needs to be supp
bd00: 6f 72 74 65 64 20 77 68 65 6e 20 53 51 4c 49 54 orted when SQLIT
bd10: 45 5f 54 45 53 54 20 69 73 20 64 65 66 69 6e 65 E_TEST is define
bd20: 64 2e 0a 2a 2a 0a 2a 2a 20 3c 6c 69 3e 5b 5b 53 d..**.** <li>[[S
bd30: 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 57 41 4c 5f QLITE_FCNTL_WAL_
bd40: 42 4c 4f 43 4b 5d 5d 0a 2a 2a 20 54 68 65 20 5b BLOCK]].** The [
bd50: 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 57 41 4c SQLITE_FCNTL_WAL
bd60: 5f 42 4c 4f 43 4b 5d 20 69 73 20 61 20 73 69 67 _BLOCK] is a sig
bd70: 6e 61 6c 20 74 6f 20 74 68 65 20 56 46 53 20 6c nal to the VFS l
bd80: 61 79 65 72 20 74 68 61 74 20 69 74 20 6d 69 67 ayer that it mig
bd90: 68 74 0a 2a 2a 20 62 65 20 61 64 76 61 6e 74 61 ht.** be advanta
bda0: 67 65 6f 75 73 20 74 6f 20 62 6c 6f 63 6b 20 6f geous to block o
bdb0: 6e 20 74 68 65 20 6e 65 78 74 20 57 41 4c 20 6c n the next WAL l
bdc0: 6f 63 6b 20 69 66 20 74 68 65 20 6c 6f 63 6b 20 ock if the lock
bdd0: 69 73 20 6e 6f 74 20 69 6d 6d 65 64 69 61 74 65 is not immediate
bde0: 6c 79 0a 2a 2a 20 61 76 61 69 6c 61 62 6c 65 2e ly.** available.
bdf0: 20 20 54 68 65 20 57 41 4c 20 73 75 62 73 79 73 The WAL subsys
be00: 74 65 6d 20 69 73 73 75 65 73 20 74 68 69 73 20 tem issues this
be10: 73 69 67 6e 61 6c 20 64 75 72 69 6e 67 20 72 61 signal during ra
be20: 72 65 0a 2a 2a 20 63 69 72 63 75 6d 73 74 61 6e re.** circumstan
be30: 63 65 73 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 ces in order to
be40: 66 69 78 20 61 20 70 72 6f 62 6c 65 6d 20 77 69 fix a problem wi
be50: 74 68 20 70 72 69 6f 72 69 74 79 20 69 6e 76 65 th priority inve
be60: 72 73 69 6f 6e 2e 0a 2a 2a 20 41 70 70 6c 69 63 rsion..** Applic
be70: 61 74 69 6f 6e 73 20 73 68 6f 75 6c 64 20 3c 65 ations should <e
be80: 6d 3e 6e 6f 74 3c 2f 65 6d 3e 20 75 73 65 20 74 m>not</em> use t
be90: 68 69 73 20 66 69 6c 65 2d 63 6f 6e 74 72 6f 6c his file-control
bea0: 2e 0a 2a 2a 0a 2a 2a 20 3c 6c 69 3e 5b 5b 53 51 ..**.** <li>[[SQ
beb0: 4c 49 54 45 5f 46 43 4e 54 4c 5f 5a 49 50 56 46 LITE_FCNTL_ZIPVF
bec0: 53 5d 5d 0a 2a 2a 20 54 68 65 20 5b 53 51 4c 49 S]].** The [SQLI
bed0: 54 45 5f 46 43 4e 54 4c 5f 5a 49 50 56 46 53 5d TE_FCNTL_ZIPVFS]
bee0: 20 6f 70 63 6f 64 65 20 69 73 20 69 6d 70 6c 65 opcode is imple
bef0: 6d 65 6e 74 65 64 20 62 79 20 7a 69 70 76 66 73 mented by zipvfs
bf00: 20 6f 6e 6c 79 2e 20 41 6c 6c 20 6f 74 68 65 72 only. All other
bf10: 0a 2a 2a 20 56 46 53 20 73 68 6f 75 6c 64 20 72 .** VFS should r
bf20: 65 74 75 72 6e 20 53 51 4c 49 54 45 5f 4e 4f 54 eturn SQLITE_NOT
bf30: 46 4f 55 4e 44 20 66 6f 72 20 74 68 69 73 20 6f FOUND for this o
bf40: 70 63 6f 64 65 2e 0a 2a 2a 0a 2a 2a 20 3c 6c 69 pcode..**.** <li
bf50: 3e 5b 5b 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f >[[SQLITE_FCNTL_
bf60: 52 42 55 5d 5d 0a 2a 2a 20 54 68 65 20 5b 53 51 RBU]].** The [SQ
bf70: 4c 49 54 45 5f 46 43 4e 54 4c 5f 52 42 55 5d 20 LITE_FCNTL_RBU]
bf80: 6f 70 63 6f 64 65 20 69 73 20 69 6d 70 6c 65 6d opcode is implem
bf90: 65 6e 74 65 64 20 62 79 20 74 68 65 20 73 70 65 ented by the spe
bfa0: 63 69 61 6c 20 56 46 53 20 75 73 65 64 20 62 79 cial VFS used by
bfb0: 0a 2a 2a 20 74 68 65 20 52 42 55 20 65 78 74 65 .** the RBU exte
bfc0: 6e 73 69 6f 6e 20 6f 6e 6c 79 2e 20 20 41 6c 6c nsion only. All
bfd0: 20 6f 74 68 65 72 20 56 46 53 20 73 68 6f 75 6c other VFS shoul
bfe0: 64 20 72 65 74 75 72 6e 20 53 51 4c 49 54 45 5f d return SQLITE_
bff0: 4e 4f 54 46 4f 55 4e 44 20 66 6f 72 0a 2a 2a 20 NOTFOUND for.**
c000: 74 68 69 73 20 6f 70 63 6f 64 65 2e 20 20 0a 2a this opcode. .*
c010: 2a 20 3c 2f 75 6c 3e 0a 2a 2f 0a 23 64 65 66 69 * </ul>.*/.#defi
c020: 6e 65 20 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f ne SQLITE_FCNTL_
c030: 4c 4f 43 4b 53 54 41 54 45 20 20 20 20 20 20 20 LOCKSTATE
c040: 20 20 20 20 20 20 20 20 31 0a 23 64 65 66 69 6e 1.#defin
c050: 65 20 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 47 e SQLITE_FCNTL_G
c060: 45 54 5f 4c 4f 43 4b 50 52 4f 58 59 46 49 4c 45 ET_LOCKPROXYFILE
c070: 20 20 20 20 20 20 20 32 0a 23 64 65 66 69 6e 65 2.#define
c080: 20 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 53 45 SQLITE_FCNTL_SE
c090: 54 5f 4c 4f 43 4b 50 52 4f 58 59 46 49 4c 45 20 T_LOCKPROXYFILE
c0a0: 20 20 20 20 20 20 33 0a 23 64 65 66 69 6e 65 20 3.#define
c0b0: 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 4c 41 53 SQLITE_FCNTL_LAS
c0c0: 54 5f 45 52 52 4e 4f 20 20 20 20 20 20 20 20 20 T_ERRNO
c0d0: 20 20 20 20 20 34 0a 23 64 65 66 69 6e 65 20 53 4.#define S
c0e0: 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 53 49 5a 45 QLITE_FCNTL_SIZE
c0f0: 5f 48 49 4e 54 20 20 20 20 20 20 20 20 20 20 20 _HINT
c100: 20 20 20 20 35 0a 23 64 65 66 69 6e 65 20 53 51 5.#define SQ
c110: 4c 49 54 45 5f 46 43 4e 54 4c 5f 43 48 55 4e 4b LITE_FCNTL_CHUNK
c120: 5f 53 49 5a 45 20 20 20 20 20 20 20 20 20 20 20 _SIZE
c130: 20 20 20 36 0a 23 64 65 66 69 6e 65 20 53 51 4c 6.#define SQL
c140: 49 54 45 5f 46 43 4e 54 4c 5f 46 49 4c 45 5f 50 ITE_FCNTL_FILE_P
c150: 4f 49 4e 54 45 52 20 20 20 20 20 20 20 20 20 20 OINTER
c160: 20 20 37 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 7.#define SQLI
c170: 54 45 5f 46 43 4e 54 4c 5f 53 59 4e 43 5f 4f 4d TE_FCNTL_SYNC_OM
c180: 49 54 54 45 44 20 20 20 20 20 20 20 20 20 20 20 ITTED
c190: 20 38 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 8.#define SQLIT
c1a0: 45 5f 46 43 4e 54 4c 5f 57 49 4e 33 32 5f 41 56 E_FCNTL_WIN32_AV
c1b0: 5f 52 45 54 52 59 20 20 20 20 20 20 20 20 20 20 _RETRY
c1c0: 39 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 9.#define SQLITE
c1d0: 5f 46 43 4e 54 4c 5f 50 45 52 53 49 53 54 5f 57 _FCNTL_PERSIST_W
c1e0: 41 4c 20 20 20 20 20 20 20 20 20 20 20 20 31 30 AL 10
c1f0: 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f .#define SQLITE_
c200: 46 43 4e 54 4c 5f 4f 56 45 52 57 52 49 54 45 20 FCNTL_OVERWRITE
c210: 20 20 20 20 20 20 20 20 20 20 20 20 20 31 31 0a 11.
c220: 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 46 #define SQLITE_F
c230: 43 4e 54 4c 5f 56 46 53 4e 41 4d 45 20 20 20 20 CNTL_VFSNAME
c240: 20 20 20 20 20 20 20 20 20 20 20 20 31 32 0a 23 12.#
c250: 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 46 43 define SQLITE_FC
c260: 4e 54 4c 5f 50 4f 57 45 52 53 41 46 45 5f 4f 56 NTL_POWERSAFE_OV
c270: 45 52 57 52 49 54 45 20 20 20 20 31 33 0a 23 64 ERWRITE 13.#d
c280: 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 46 43 4e efine SQLITE_FCN
c290: 54 4c 5f 50 52 41 47 4d 41 20 20 20 20 20 20 20 TL_PRAGMA
c2a0: 20 20 20 20 20 20 20 20 20 20 31 34 0a 23 64 65 14.#de
c2b0: 66 69 6e 65 20 53 51 4c 49 54 45 5f 46 43 4e 54 fine SQLITE_FCNT
c2c0: 4c 5f 42 55 53 59 48 41 4e 44 4c 45 52 20 20 20 L_BUSYHANDLER
c2d0: 20 20 20 20 20 20 20 20 20 31 35 0a 23 64 65 66 15.#def
c2e0: 69 6e 65 20 53 51 4c 49 54 45 5f 46 43 4e 54 4c ine SQLITE_FCNTL
c2f0: 5f 54 45 4d 50 46 49 4c 45 4e 41 4d 45 20 20 20 _TEMPFILENAME
c300: 20 20 20 20 20 20 20 20 31 36 0a 23 64 65 66 69 16.#defi
c310: 6e 65 20 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f ne SQLITE_FCNTL_
c320: 4d 4d 41 50 5f 53 49 5a 45 20 20 20 20 20 20 20 MMAP_SIZE
c330: 20 20 20 20 20 20 20 31 38 0a 23 64 65 66 69 6e 18.#defin
c340: 65 20 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 54 e SQLITE_FCNTL_T
c350: 52 41 43 45 20 20 20 20 20 20 20 20 20 20 20 20 RACE
c360: 20 20 20 20 20 20 31 39 0a 23 64 65 66 69 6e 65 19.#define
c370: 20 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 48 41 SQLITE_FCNTL_HA
c380: 53 5f 4d 4f 56 45 44 20 20 20 20 20 20 20 20 20 S_MOVED
c390: 20 20 20 20 20 32 30 0a 23 64 65 66 69 6e 65 20 20.#define
c3a0: 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 53 59 4e SQLITE_FCNTL_SYN
c3b0: 43 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 C
c3c0: 20 20 20 20 32 31 0a 23 64 65 66 69 6e 65 20 53 21.#define S
c3d0: 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 43 4f 4d 4d QLITE_FCNTL_COMM
c3e0: 49 54 5f 50 48 41 53 45 54 57 4f 20 20 20 20 20 IT_PHASETWO
c3f0: 20 20 20 32 32 0a 23 64 65 66 69 6e 65 20 53 51 22.#define SQ
c400: 4c 49 54 45 5f 46 43 4e 54 4c 5f 57 49 4e 33 32 LITE_FCNTL_WIN32
c410: 5f 53 45 54 5f 48 41 4e 44 4c 45 20 20 20 20 20 _SET_HANDLE
c420: 20 20 32 33 0a 23 64 65 66 69 6e 65 20 53 51 4c 23.#define SQL
c430: 49 54 45 5f 46 43 4e 54 4c 5f 57 41 4c 5f 42 4c ITE_FCNTL_WAL_BL
c440: 4f 43 4b 20 20 20 20 20 20 20 20 20 20 20 20 20 OCK
c450: 20 32 34 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 24.#define SQLI
c460: 54 45 5f 46 43 4e 54 4c 5f 5a 49 50 56 46 53 20 TE_FCNTL_ZIPVFS
c470: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
c480: 32 35 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 25.#define SQLIT
c490: 45 5f 46 43 4e 54 4c 5f 52 42 55 20 20 20 20 20 E_FCNTL_RBU
c4a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 32 2
c4b0: 36 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 6.#define SQLITE
c4c0: 5f 46 43 4e 54 4c 5f 56 46 53 5f 50 4f 49 4e 54 _FCNTL_VFS_POINT
c4d0: 45 52 20 20 20 20 20 20 20 20 20 20 20 20 32 37 ER 27
c4e0: 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f .#define SQLITE_
c4f0: 46 43 4e 54 4c 5f 4a 4f 55 52 4e 41 4c 5f 50 4f FCNTL_JOURNAL_PO
c500: 49 4e 54 45 52 20 20 20 20 20 20 20 20 32 38 0a INTER 28.
c510: 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 46 #define SQLITE_F
c520: 43 4e 54 4c 5f 57 49 4e 33 32 5f 47 45 54 5f 48 CNTL_WIN32_GET_H
c530: 41 4e 44 4c 45 20 20 20 20 20 20 20 32 39 0a 23 ANDLE 29.#
c540: 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 46 43 define SQLITE_FC
c550: 4e 54 4c 5f 50 44 42 20 20 20 20 20 20 20 20 20 NTL_PDB
c560: 20 20 20 20 20 20 20 20 20 20 20 33 30 0a 0a 2f 30../
c570: 2a 20 64 65 70 72 65 63 61 74 65 64 20 6e 61 6d * deprecated nam
c580: 65 73 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 es */.#define SQ
c590: 4c 49 54 45 5f 47 45 54 5f 4c 4f 43 4b 50 52 4f LITE_GET_LOCKPRO
c5a0: 58 59 46 49 4c 45 20 20 20 20 20 20 53 51 4c 49 XYFILE SQLI
c5b0: 54 45 5f 46 43 4e 54 4c 5f 47 45 54 5f 4c 4f 43 TE_FCNTL_GET_LOC
c5c0: 4b 50 52 4f 58 59 46 49 4c 45 0a 23 64 65 66 69 KPROXYFILE.#defi
c5d0: 6e 65 20 53 51 4c 49 54 45 5f 53 45 54 5f 4c 4f ne SQLITE_SET_LO
c5e0: 43 4b 50 52 4f 58 59 46 49 4c 45 20 20 20 20 20 CKPROXYFILE
c5f0: 20 53 51 4c 49 54 45 5f 46 43 4e 54 4c 5f 53 45 SQLITE_FCNTL_SE
c600: 54 5f 4c 4f 43 4b 50 52 4f 58 59 46 49 4c 45 0a T_LOCKPROXYFILE.
c610: 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 4c #define SQLITE_L
c620: 41 53 54 5f 45 52 52 4e 4f 20 20 20 20 20 20 20 AST_ERRNO
c630: 20 20 20 20 20 20 53 51 4c 49 54 45 5f 46 43 4e SQLITE_FCN
c640: 54 4c 5f 4c 41 53 54 5f 45 52 52 4e 4f 0a 0a 0a TL_LAST_ERRNO...
c650: 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 /*.** CAPI3REF:
c660: 4d 75 74 65 78 20 48 61 6e 64 6c 65 0a 2a 2a 0a Mutex Handle.**.
c670: 2a 2a 20 54 68 65 20 6d 75 74 65 78 20 6d 6f 64 ** The mutex mod
c680: 75 6c 65 20 77 69 74 68 69 6e 20 53 51 4c 69 74 ule within SQLit
c690: 65 20 64 65 66 69 6e 65 73 20 5b 73 71 6c 69 74 e defines [sqlit
c6a0: 65 33 5f 6d 75 74 65 78 5d 20 74 6f 20 62 65 20 e3_mutex] to be
c6b0: 61 6e 0a 2a 2a 20 61 62 73 74 72 61 63 74 20 74 an.** abstract t
c6c0: 79 70 65 20 66 6f 72 20 61 20 6d 75 74 65 78 20 ype for a mutex
c6d0: 6f 62 6a 65 63 74 2e 20 20 54 68 65 20 53 51 4c object. The SQL
c6e0: 69 74 65 20 63 6f 72 65 20 6e 65 76 65 72 20 6c ite core never l
c6f0: 6f 6f 6b 73 0a 2a 2a 20 61 74 20 74 68 65 20 69 ooks.** at the i
c700: 6e 74 65 72 6e 61 6c 20 72 65 70 72 65 73 65 6e nternal represen
c710: 74 61 74 69 6f 6e 20 6f 66 20 61 6e 20 5b 73 71 tation of an [sq
c720: 6c 69 74 65 33 5f 6d 75 74 65 78 5d 2e 20 20 49 lite3_mutex]. I
c730: 74 20 6f 6e 6c 79 0a 2a 2a 20 64 65 61 6c 73 20 t only.** deals
c740: 77 69 74 68 20 70 6f 69 6e 74 65 72 73 20 74 6f with pointers to
c750: 20 74 68 65 20 5b 73 71 6c 69 74 65 33 5f 6d 75 the [sqlite3_mu
c760: 74 65 78 5d 20 6f 62 6a 65 63 74 2e 0a 2a 2a 0a tex] object..**.
c770: 2a 2a 20 4d 75 74 65 78 65 73 20 61 72 65 20 63 ** Mutexes are c
c780: 72 65 61 74 65 64 20 75 73 69 6e 67 20 5b 73 71 reated using [sq
c790: 6c 69 74 65 33 5f 6d 75 74 65 78 5f 61 6c 6c 6f lite3_mutex_allo
c7a0: 63 28 29 5d 2e 0a 2a 2f 0a 74 79 70 65 64 65 66 c()]..*/.typedef
c7b0: 20 73 74 72 75 63 74 20 73 71 6c 69 74 65 33 5f struct sqlite3_
c7c0: 6d 75 74 65 78 20 73 71 6c 69 74 65 33 5f 6d 75 mutex sqlite3_mu
c7d0: 74 65 78 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 tex;../*.** CAPI
c7e0: 33 52 45 46 3a 20 4c 6f 61 64 61 62 6c 65 20 45 3REF: Loadable E
c7f0: 78 74 65 6e 73 69 6f 6e 20 54 68 75 6e 6b 0a 2a xtension Thunk.*
c800: 2a 0a 2a 2a 20 41 20 70 6f 69 6e 74 65 72 20 74 *.** A pointer t
c810: 6f 20 74 68 65 20 6f 70 61 71 75 65 20 73 71 6c o the opaque sql
c820: 69 74 65 33 5f 61 70 69 5f 72 6f 75 74 69 6e 65 ite3_api_routine
c830: 73 20 73 74 72 75 63 74 75 72 65 20 69 73 20 70 s structure is p
c840: 61 73 73 65 64 20 61 73 0a 2a 2a 20 74 68 65 20 assed as.** the
c850: 74 68 69 72 64 20 70 61 72 61 6d 65 74 65 72 20 third parameter
c860: 74 6f 20 65 6e 74 72 79 20 70 6f 69 6e 74 73 20 to entry points
c870: 6f 66 20 5b 6c 6f 61 64 61 62 6c 65 20 65 78 74 of [loadable ext
c880: 65 6e 73 69 6f 6e 73 5d 2e 20 20 54 68 69 73 0a ensions]. This.
c890: 2a 2a 20 73 74 72 75 63 74 75 72 65 20 6d 75 73 ** structure mus
c8a0: 74 20 62 65 20 74 79 70 65 64 65 66 65 64 20 69 t be typedefed i
c8b0: 6e 20 6f 72 64 65 72 20 74 6f 20 77 6f 72 6b 20 n order to work
c8c0: 61 72 6f 75 6e 64 20 63 6f 6d 70 69 6c 65 72 20 around compiler
c8d0: 77 61 72 6e 69 6e 67 73 0a 2a 2a 20 6f 6e 20 73 warnings.** on s
c8e0: 6f 6d 65 20 70 6c 61 74 66 6f 72 6d 73 2e 0a 2a ome platforms..*
c8f0: 2f 0a 74 79 70 65 64 65 66 20 73 74 72 75 63 74 /.typedef struct
c900: 20 73 71 6c 69 74 65 33 5f 61 70 69 5f 72 6f 75 sqlite3_api_rou
c910: 74 69 6e 65 73 20 73 71 6c 69 74 65 33 5f 61 70 tines sqlite3_ap
c920: 69 5f 72 6f 75 74 69 6e 65 73 3b 0a 0a 2f 2a 0a i_routines;../*.
c930: 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 4f 53 20 ** CAPI3REF: OS
c940: 49 6e 74 65 72 66 61 63 65 20 4f 62 6a 65 63 74 Interface Object
c950: 0a 2a 2a 0a 2a 2a 20 41 6e 20 69 6e 73 74 61 6e .**.** An instan
c960: 63 65 20 6f 66 20 74 68 65 20 73 71 6c 69 74 65 ce of the sqlite
c970: 33 5f 76 66 73 20 6f 62 6a 65 63 74 20 64 65 66 3_vfs object def
c980: 69 6e 65 73 20 74 68 65 20 69 6e 74 65 72 66 61 ines the interfa
c990: 63 65 20 62 65 74 77 65 65 6e 0a 2a 2a 20 74 68 ce between.** th
c9a0: 65 20 53 51 4c 69 74 65 20 63 6f 72 65 20 61 6e e SQLite core an
c9b0: 64 20 74 68 65 20 75 6e 64 65 72 6c 79 69 6e 67 d the underlying
c9c0: 20 6f 70 65 72 61 74 69 6e 67 20 73 79 73 74 65 operating syste
c9d0: 6d 2e 20 20 54 68 65 20 22 76 66 73 22 0a 2a 2a m. The "vfs".**
c9e0: 20 69 6e 20 74 68 65 20 6e 61 6d 65 20 6f 66 20 in the name of
c9f0: 74 68 65 20 6f 62 6a 65 63 74 20 73 74 61 6e 64 the object stand
ca00: 73 20 66 6f 72 20 22 76 69 72 74 75 61 6c 20 66 s for "virtual f
ca10: 69 6c 65 20 73 79 73 74 65 6d 22 2e 20 20 53 65 ile system". Se
ca20: 65 0a 2a 2a 20 74 68 65 20 5b 56 46 53 20 7c 20 e.** the [VFS |
ca30: 56 46 53 20 64 6f 63 75 6d 65 6e 74 61 74 69 6f VFS documentatio
ca40: 6e 5d 20 66 6f 72 20 66 75 72 74 68 65 72 20 69 n] for further i
ca50: 6e 66 6f 72 6d 61 74 69 6f 6e 2e 0a 2a 2a 0a 2a nformation..**.*
ca60: 2a 20 54 68 65 20 76 61 6c 75 65 20 6f 66 20 74 * The value of t
ca70: 68 65 20 69 56 65 72 73 69 6f 6e 20 66 69 65 6c he iVersion fiel
ca80: 64 20 69 73 20 69 6e 69 74 69 61 6c 6c 79 20 31 d is initially 1
ca90: 20 62 75 74 20 6d 61 79 20 62 65 20 6c 61 72 67 but may be larg
caa0: 65 72 20 69 6e 0a 2a 2a 20 66 75 74 75 72 65 20 er in.** future
cab0: 76 65 72 73 69 6f 6e 73 20 6f 66 20 53 51 4c 69 versions of SQLi
cac0: 74 65 2e 20 20 41 64 64 69 74 69 6f 6e 61 6c 20 te. Additional
cad0: 66 69 65 6c 64 73 20 6d 61 79 20 62 65 20 61 70 fields may be ap
cae0: 70 65 6e 64 65 64 20 74 6f 20 74 68 69 73 0a 2a pended to this.*
caf0: 2a 20 6f 62 6a 65 63 74 20 77 68 65 6e 20 74 68 * object when th
cb00: 65 20 69 56 65 72 73 69 6f 6e 20 76 61 6c 75 65 e iVersion value
cb10: 20 69 73 20 69 6e 63 72 65 61 73 65 64 2e 20 20 is increased.
cb20: 4e 6f 74 65 20 74 68 61 74 20 74 68 65 20 73 74 Note that the st
cb30: 72 75 63 74 75 72 65 0a 2a 2a 20 6f 66 20 74 68 ructure.** of th
cb40: 65 20 73 71 6c 69 74 65 33 5f 76 66 73 20 6f 62 e sqlite3_vfs ob
cb50: 6a 65 63 74 20 63 68 61 6e 67 65 73 20 69 6e 20 ject changes in
cb60: 74 68 65 20 74 72 61 6e 73 61 63 74 69 6f 6e 20 the transaction
cb70: 62 65 74 77 65 65 6e 0a 2a 2a 20 53 51 4c 69 74 between.** SQLit
cb80: 65 20 76 65 72 73 69 6f 6e 20 33 2e 35 2e 39 20 e version 3.5.9
cb90: 61 6e 64 20 33 2e 36 2e 30 20 61 6e 64 20 79 65 and 3.6.0 and ye
cba0: 74 20 74 68 65 20 69 56 65 72 73 69 6f 6e 20 66 t the iVersion f
cbb0: 69 65 6c 64 20 77 61 73 20 6e 6f 74 0a 2a 2a 20 ield was not.**
cbc0: 6d 6f 64 69 66 69 65 64 2e 0a 2a 2a 0a 2a 2a 20 modified..**.**
cbd0: 54 68 65 20 73 7a 4f 73 46 69 6c 65 20 66 69 65 The szOsFile fie
cbe0: 6c 64 20 69 73 20 74 68 65 20 73 69 7a 65 20 6f ld is the size o
cbf0: 66 20 74 68 65 20 73 75 62 63 6c 61 73 73 65 64 f the subclassed
cc00: 20 5b 73 71 6c 69 74 65 33 5f 66 69 6c 65 5d 0a [sqlite3_file].
cc10: 2a 2a 20 73 74 72 75 63 74 75 72 65 20 75 73 65 ** structure use
cc20: 64 20 62 79 20 74 68 69 73 20 56 46 53 2e 20 20 d by this VFS.
cc30: 6d 78 50 61 74 68 6e 61 6d 65 20 69 73 20 74 68 mxPathname is th
cc40: 65 20 6d 61 78 69 6d 75 6d 20 6c 65 6e 67 74 68 e maximum length
cc50: 20 6f 66 0a 2a 2a 20 61 20 70 61 74 68 6e 61 6d of.** a pathnam
cc60: 65 20 69 6e 20 74 68 69 73 20 56 46 53 2e 0a 2a e in this VFS..*
cc70: 2a 0a 2a 2a 20 52 65 67 69 73 74 65 72 65 64 20 *.** Registered
cc80: 73 71 6c 69 74 65 33 5f 76 66 73 20 6f 62 6a 65 sqlite3_vfs obje
cc90: 63 74 73 20 61 72 65 20 6b 65 70 74 20 6f 6e 20 cts are kept on
cca0: 61 20 6c 69 6e 6b 65 64 20 6c 69 73 74 20 66 6f a linked list fo
ccb0: 72 6d 65 64 20 62 79 0a 2a 2a 20 74 68 65 20 70 rmed by.** the p
ccc0: 4e 65 78 74 20 70 6f 69 6e 74 65 72 2e 20 20 54 Next pointer. T
ccd0: 68 65 20 5b 73 71 6c 69 74 65 33 5f 76 66 73 5f he [sqlite3_vfs_
cce0: 72 65 67 69 73 74 65 72 28 29 5d 0a 2a 2a 20 61 register()].** a
ccf0: 6e 64 20 5b 73 71 6c 69 74 65 33 5f 76 66 73 5f nd [sqlite3_vfs_
cd00: 75 6e 72 65 67 69 73 74 65 72 28 29 5d 20 69 6e unregister()] in
cd10: 74 65 72 66 61 63 65 73 20 6d 61 6e 61 67 65 20 terfaces manage
cd20: 74 68 69 73 20 6c 69 73 74 0a 2a 2a 20 69 6e 20 this list.** in
cd30: 61 20 74 68 72 65 61 64 2d 73 61 66 65 20 77 61 a thread-safe wa
cd40: 79 2e 20 20 54 68 65 20 5b 73 71 6c 69 74 65 33 y. The [sqlite3
cd50: 5f 76 66 73 5f 66 69 6e 64 28 29 5d 20 69 6e 74 _vfs_find()] int
cd60: 65 72 66 61 63 65 0a 2a 2a 20 73 65 61 72 63 68 erface.** search
cd70: 65 73 20 74 68 65 20 6c 69 73 74 2e 20 20 4e 65 es the list. Ne
cd80: 69 74 68 65 72 20 74 68 65 20 61 70 70 6c 69 63 ither the applic
cd90: 61 74 69 6f 6e 20 63 6f 64 65 20 6e 6f 72 20 74 ation code nor t
cda0: 68 65 20 56 46 53 0a 2a 2a 20 69 6d 70 6c 65 6d he VFS.** implem
cdb0: 65 6e 74 61 74 69 6f 6e 20 73 68 6f 75 6c 64 20 entation should
cdc0: 75 73 65 20 74 68 65 20 70 4e 65 78 74 20 70 6f use the pNext po
cdd0: 69 6e 74 65 72 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 inter..**.** The
cde0: 20 70 4e 65 78 74 20 66 69 65 6c 64 20 69 73 20 pNext field is
cdf0: 74 68 65 20 6f 6e 6c 79 20 66 69 65 6c 64 20 69 the only field i
ce00: 6e 20 74 68 65 20 73 71 6c 69 74 65 33 5f 76 66 n the sqlite3_vf
ce10: 73 0a 2a 2a 20 73 74 72 75 63 74 75 72 65 20 74 s.** structure t
ce20: 68 61 74 20 53 51 4c 69 74 65 20 77 69 6c 6c 20 hat SQLite will
ce30: 65 76 65 72 20 6d 6f 64 69 66 79 2e 20 20 53 51 ever modify. SQ
ce40: 4c 69 74 65 20 77 69 6c 6c 20 6f 6e 6c 79 20 61 Lite will only a
ce50: 63 63 65 73 73 0a 2a 2a 20 6f 72 20 6d 6f 64 69 ccess.** or modi
ce60: 66 79 20 74 68 69 73 20 66 69 65 6c 64 20 77 68 fy this field wh
ce70: 69 6c 65 20 68 6f 6c 64 69 6e 67 20 61 20 70 61 ile holding a pa
ce80: 72 74 69 63 75 6c 61 72 20 73 74 61 74 69 63 20 rticular static
ce90: 6d 75 74 65 78 2e 0a 2a 2a 20 54 68 65 20 61 70 mutex..** The ap
cea0: 70 6c 69 63 61 74 69 6f 6e 20 73 68 6f 75 6c 64 plication should
ceb0: 20 6e 65 76 65 72 20 6d 6f 64 69 66 79 20 61 6e never modify an
cec0: 79 74 68 69 6e 67 20 77 69 74 68 69 6e 20 74 68 ything within th
ced0: 65 20 73 71 6c 69 74 65 33 5f 76 66 73 0a 2a 2a e sqlite3_vfs.**
cee0: 20 6f 62 6a 65 63 74 20 6f 6e 63 65 20 74 68 65 object once the
cef0: 20 6f 62 6a 65 63 74 20 68 61 73 20 62 65 65 6e object has been
cf00: 20 72 65 67 69 73 74 65 72 65 64 2e 0a 2a 2a 0a registered..**.
cf10: 2a 2a 20 54 68 65 20 7a 4e 61 6d 65 20 66 69 65 ** The zName fie
cf20: 6c 64 20 68 6f 6c 64 73 20 74 68 65 20 6e 61 6d ld holds the nam
cf30: 65 20 6f 66 20 74 68 65 20 56 46 53 20 6d 6f 64 e of the VFS mod
cf40: 75 6c 65 2e 20 20 54 68 65 20 6e 61 6d 65 20 6d ule. The name m
cf50: 75 73 74 0a 2a 2a 20 62 65 20 75 6e 69 71 75 65 ust.** be unique
cf60: 20 61 63 72 6f 73 73 20 61 6c 6c 20 56 46 53 20 across all VFS
cf70: 6d 6f 64 75 6c 65 73 2e 0a 2a 2a 0a 2a 2a 20 5b modules..**.** [
cf80: 5b 73 71 6c 69 74 65 33 5f 76 66 73 2e 78 4f 70 [sqlite3_vfs.xOp
cf90: 65 6e 5d 5d 0a 2a 2a 20 5e 53 51 4c 69 74 65 20 en]].** ^SQLite
cfa0: 67 75 61 72 61 6e 74 65 65 73 20 74 68 61 74 20 guarantees that
cfb0: 74 68 65 20 7a 46 69 6c 65 6e 61 6d 65 20 70 61 the zFilename pa
cfc0: 72 61 6d 65 74 65 72 20 74 6f 20 78 4f 70 65 6e rameter to xOpen
cfd0: 0a 2a 2a 20 69 73 20 65 69 74 68 65 72 20 61 20 .** is either a
cfe0: 4e 55 4c 4c 20 70 6f 69 6e 74 65 72 20 6f 72 20 NULL pointer or
cff0: 73 74 72 69 6e 67 20 6f 62 74 61 69 6e 65 64 0a string obtained.
d000: 2a 2a 20 66 72 6f 6d 20 78 46 75 6c 6c 50 61 74 ** from xFullPat
d010: 68 6e 61 6d 65 28 29 20 77 69 74 68 20 61 6e 20 hname() with an
d020: 6f 70 74 69 6f 6e 61 6c 20 73 75 66 66 69 78 20 optional suffix
d030: 61 64 64 65 64 2e 0a 2a 2a 20 5e 49 66 20 61 20 added..** ^If a
d040: 73 75 66 66 69 78 20 69 73 20 61 64 64 65 64 20 suffix is added
d050: 74 6f 20 74 68 65 20 7a 46 69 6c 65 6e 61 6d 65 to the zFilename
d060: 20 70 61 72 61 6d 65 74 65 72 2c 20 69 74 20 77 parameter, it w
d070: 69 6c 6c 0a 2a 2a 20 63 6f 6e 73 69 73 74 20 6f ill.** consist o
d080: 66 20 61 20 73 69 6e 67 6c 65 20 22 2d 22 20 63 f a single "-" c
d090: 68 61 72 61 63 74 65 72 20 66 6f 6c 6c 6f 77 65 haracter followe
d0a0: 64 20 62 79 20 6e 6f 20 6d 6f 72 65 20 74 68 61 d by no more tha
d0b0: 6e 0a 2a 2a 20 31 31 20 61 6c 70 68 61 6e 75 6d n.** 11 alphanum
d0c0: 65 72 69 63 20 61 6e 64 2f 6f 72 20 22 2d 22 20 eric and/or "-"
d0d0: 63 68 61 72 61 63 74 65 72 73 2e 0a 2a 2a 20 5e characters..** ^
d0e0: 53 51 4c 69 74 65 20 66 75 72 74 68 65 72 20 67 SQLite further g
d0f0: 75 61 72 61 6e 74 65 65 73 20 74 68 61 74 0a 2a uarantees that.*
d100: 2a 20 74 68 65 20 73 74 72 69 6e 67 20 77 69 6c * the string wil
d110: 6c 20 62 65 20 76 61 6c 69 64 20 61 6e 64 20 75 l be valid and u
d120: 6e 63 68 61 6e 67 65 64 20 75 6e 74 69 6c 20 78 nchanged until x
d130: 43 6c 6f 73 65 28 29 20 69 73 0a 2a 2a 20 63 61 Close() is.** ca
d140: 6c 6c 65 64 2e 20 42 65 63 61 75 73 65 20 6f 66 lled. Because of
d150: 20 74 68 65 20 70 72 65 76 69 6f 75 73 20 73 65 the previous se
d160: 6e 74 65 6e 63 65 2c 0a 2a 2a 20 74 68 65 20 5b ntence,.** the [
d170: 73 71 6c 69 74 65 33 5f 66 69 6c 65 5d 20 63 61 sqlite3_file] ca
d180: 6e 20 73 61 66 65 6c 79 20 73 74 6f 72 65 20 61 n safely store a
d190: 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 68 65 0a pointer to the.
d1a0: 2a 2a 20 66 69 6c 65 6e 61 6d 65 20 69 66 20 69 ** filename if i
d1b0: 74 20 6e 65 65 64 73 20 74 6f 20 72 65 6d 65 6d t needs to remem
d1c0: 62 65 72 20 74 68 65 20 66 69 6c 65 6e 61 6d 65 ber the filename
d1d0: 20 66 6f 72 20 73 6f 6d 65 20 72 65 61 73 6f 6e for some reason
d1e0: 2e 0a 2a 2a 20 49 66 20 74 68 65 20 7a 46 69 6c ..** If the zFil
d1f0: 65 6e 61 6d 65 20 70 61 72 61 6d 65 74 65 72 20 ename parameter
d200: 74 6f 20 78 4f 70 65 6e 20 69 73 20 61 20 4e 55 to xOpen is a NU
d210: 4c 4c 20 70 6f 69 6e 74 65 72 20 74 68 65 6e 20 LL pointer then
d220: 78 4f 70 65 6e 0a 2a 2a 20 6d 75 73 74 20 69 6e xOpen.** must in
d230: 76 65 6e 74 20 69 74 73 20 6f 77 6e 20 74 65 6d vent its own tem
d240: 70 6f 72 61 72 79 20 6e 61 6d 65 20 66 6f 72 20 porary name for
d250: 74 68 65 20 66 69 6c 65 2e 20 20 5e 57 68 65 6e the file. ^When
d260: 65 76 65 72 20 74 68 65 20 0a 2a 2a 20 78 46 69 ever the .** xFi
d270: 6c 65 6e 61 6d 65 20 70 61 72 61 6d 65 74 65 72 lename parameter
d280: 20 69 73 20 4e 55 4c 4c 20 69 74 20 77 69 6c 6c is NULL it will
d290: 20 61 6c 73 6f 20 62 65 20 74 68 65 20 63 61 73 also be the cas
d2a0: 65 20 74 68 61 74 20 74 68 65 0a 2a 2a 20 66 6c e that the.** fl
d2b0: 61 67 73 20 70 61 72 61 6d 65 74 65 72 20 77 69 ags parameter wi
d2c0: 6c 6c 20 69 6e 63 6c 75 64 65 20 5b 53 51 4c 49 ll include [SQLI
d2d0: 54 45 5f 4f 50 45 4e 5f 44 45 4c 45 54 45 4f 4e TE_OPEN_DELETEON
d2e0: 43 4c 4f 53 45 5d 2e 0a 2a 2a 0a 2a 2a 20 54 68 CLOSE]..**.** Th
d2f0: 65 20 66 6c 61 67 73 20 61 72 67 75 6d 65 6e 74 e flags argument
d300: 20 74 6f 20 78 4f 70 65 6e 28 29 20 69 6e 63 6c to xOpen() incl
d310: 75 64 65 73 20 61 6c 6c 20 62 69 74 73 20 73 65 udes all bits se
d320: 74 20 69 6e 0a 2a 2a 20 74 68 65 20 66 6c 61 67 t in.** the flag
d330: 73 20 61 72 67 75 6d 65 6e 74 20 74 6f 20 5b 73 s argument to [s
d340: 71 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 32 28 29 qlite3_open_v2()
d350: 5d 2e 20 20 4f 72 20 69 66 20 5b 73 71 6c 69 74 ]. Or if [sqlit
d360: 65 33 5f 6f 70 65 6e 28 29 5d 0a 2a 2a 20 6f 72 e3_open()].** or
d370: 20 5b 73 71 6c 69 74 65 33 5f 6f 70 65 6e 31 36 [sqlite3_open16
d380: 28 29 5d 20 69 73 20 75 73 65 64 2c 20 74 68 65 ()] is used, the
d390: 6e 20 66 6c 61 67 73 20 69 6e 63 6c 75 64 65 73 n flags includes
d3a0: 20 61 74 20 6c 65 61 73 74 0a 2a 2a 20 5b 53 51 at least.** [SQ
d3b0: 4c 49 54 45 5f 4f 50 45 4e 5f 52 45 41 44 57 52 LITE_OPEN_READWR
d3c0: 49 54 45 5d 20 7c 20 5b 53 51 4c 49 54 45 5f 4f ITE] | [SQLITE_O
d3d0: 50 45 4e 5f 43 52 45 41 54 45 5d 2e 20 0a 2a 2a PEN_CREATE]. .**
d3e0: 20 49 66 20 78 4f 70 65 6e 28 29 20 6f 70 65 6e If xOpen() open
d3f0: 73 20 61 20 66 69 6c 65 20 72 65 61 64 2d 6f 6e s a file read-on
d400: 6c 79 20 74 68 65 6e 20 69 74 20 73 65 74 73 20 ly then it sets
d410: 2a 70 4f 75 74 46 6c 61 67 73 20 74 6f 0a 2a 2a *pOutFlags to.**
d420: 20 69 6e 63 6c 75 64 65 20 5b 53 51 4c 49 54 45 include [SQLITE
d430: 5f 4f 50 45 4e 5f 52 45 41 44 4f 4e 4c 59 5d 2e _OPEN_READONLY].
d440: 20 20 4f 74 68 65 72 20 62 69 74 73 20 69 6e 20 Other bits in
d450: 2a 70 4f 75 74 46 6c 61 67 73 20 6d 61 79 20 62 *pOutFlags may b
d460: 65 20 73 65 74 2e 0a 2a 2a 0a 2a 2a 20 5e 28 53 e set..**.** ^(S
d470: 51 4c 69 74 65 20 77 69 6c 6c 20 61 6c 73 6f 20 QLite will also
d480: 61 64 64 20 6f 6e 65 20 6f 66 20 74 68 65 20 66 add one of the f
d490: 6f 6c 6c 6f 77 69 6e 67 20 66 6c 61 67 73 20 74 ollowing flags t
d4a0: 6f 20 74 68 65 20 78 4f 70 65 6e 28 29 0a 2a 2a o the xOpen().**
d4b0: 20 63 61 6c 6c 2c 20 64 65 70 65 6e 64 69 6e 67 call, depending
d4c0: 20 6f 6e 20 74 68 65 20 6f 62 6a 65 63 74 20 62 on the object b
d4d0: 65 69 6e 67 20 6f 70 65 6e 65 64 3a 0a 2a 2a 0a eing opened:.**.
d4e0: 2a 2a 20 3c 75 6c 3e 0a 2a 2a 20 3c 6c 69 3e 20 ** <ul>.** <li>
d4f0: 20 5b 53 51 4c 49 54 45 5f 4f 50 45 4e 5f 4d 41 [SQLITE_OPEN_MA
d500: 49 4e 5f 44 42 5d 0a 2a 2a 20 3c 6c 69 3e 20 20 IN_DB].** <li>
d510: 5b 53 51 4c 49 54 45 5f 4f 50 45 4e 5f 4d 41 49 [SQLITE_OPEN_MAI
d520: 4e 5f 4a 4f 55 52 4e 41 4c 5d 0a 2a 2a 20 3c 6c N_JOURNAL].** <l
d530: 69 3e 20 20 5b 53 51 4c 49 54 45 5f 4f 50 45 4e i> [SQLITE_OPEN
d540: 5f 54 45 4d 50 5f 44 42 5d 0a 2a 2a 20 3c 6c 69 _TEMP_DB].** <li
d550: 3e 20 20 5b 53 51 4c 49 54 45 5f 4f 50 45 4e 5f > [SQLITE_OPEN_
d560: 54 45 4d 50 5f 4a 4f 55 52 4e 41 4c 5d 0a 2a 2a TEMP_JOURNAL].**
d570: 20 3c 6c 69 3e 20 20 5b 53 51 4c 49 54 45 5f 4f <li> [SQLITE_O
d580: 50 45 4e 5f 54 52 41 4e 53 49 45 4e 54 5f 44 42 PEN_TRANSIENT_DB
d590: 5d 0a 2a 2a 20 3c 6c 69 3e 20 20 5b 53 51 4c 49 ].** <li> [SQLI
d5a0: 54 45 5f 4f 50 45 4e 5f 53 55 42 4a 4f 55 52 4e TE_OPEN_SUBJOURN
d5b0: 41 4c 5d 0a 2a 2a 20 3c 6c 69 3e 20 20 5b 53 51 AL].** <li> [SQ
d5c0: 4c 49 54 45 5f 4f 50 45 4e 5f 4d 41 53 54 45 52 LITE_OPEN_MASTER
d5d0: 5f 4a 4f 55 52 4e 41 4c 5d 0a 2a 2a 20 3c 6c 69 _JOURNAL].** <li
d5e0: 3e 20 20 5b 53 51 4c 49 54 45 5f 4f 50 45 4e 5f > [SQLITE_OPEN_
d5f0: 57 41 4c 5d 0a 2a 2a 20 3c 2f 75 6c 3e 29 5e 0a WAL].** </ul>)^.
d600: 2a 2a 0a 2a 2a 20 54 68 65 20 66 69 6c 65 20 49 **.** The file I
d610: 2f 4f 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f /O implementatio
d620: 6e 20 63 61 6e 20 75 73 65 20 74 68 65 20 6f 62 n can use the ob
d630: 6a 65 63 74 20 74 79 70 65 20 66 6c 61 67 73 20 ject type flags
d640: 74 6f 0a 2a 2a 20 63 68 61 6e 67 65 20 74 68 65 to.** change the
d650: 20 77 61 79 20 69 74 20 64 65 61 6c 73 20 77 69 way it deals wi
d660: 74 68 20 66 69 6c 65 73 2e 20 20 46 6f 72 20 65 th files. For e
d670: 78 61 6d 70 6c 65 2c 20 61 6e 20 61 70 70 6c 69 xample, an appli
d680: 63 61 74 69 6f 6e 0a 2a 2a 20 74 68 61 74 20 64 cation.** that d
d690: 6f 65 73 20 6e 6f 74 20 63 61 72 65 20 61 62 6f oes not care abo
d6a0: 75 74 20 63 72 61 73 68 20 72 65 63 6f 76 65 72 ut crash recover
d6b0: 79 20 6f 72 20 72 6f 6c 6c 62 61 63 6b 20 6d 69 y or rollback mi
d6c0: 67 68 74 20 6d 61 6b 65 0a 2a 2a 20 74 68 65 20 ght make.** the
d6d0: 6f 70 65 6e 20 6f 66 20 61 20 6a 6f 75 72 6e 61 open of a journa
d6e0: 6c 20 66 69 6c 65 20 61 20 6e 6f 2d 6f 70 2e 20 l file a no-op.
d6f0: 20 57 72 69 74 65 73 20 74 6f 20 74 68 69 73 20 Writes to this
d700: 6a 6f 75 72 6e 61 6c 20 77 6f 75 6c 64 0a 2a 2a journal would.**
d710: 20 61 6c 73 6f 20 62 65 20 6e 6f 2d 6f 70 73 2c also be no-ops,
d720: 20 61 6e 64 20 61 6e 79 20 61 74 74 65 6d 70 74 and any attempt
d730: 20 74 6f 20 72 65 61 64 20 74 68 65 20 6a 6f 75 to read the jou
d740: 72 6e 61 6c 20 77 6f 75 6c 64 20 72 65 74 75 72 rnal would retur
d750: 6e 0a 2a 2a 20 53 51 4c 49 54 45 5f 49 4f 45 52 n.** SQLITE_IOER
d760: 52 2e 20 20 4f 72 20 74 68 65 20 69 6d 70 6c 65 R. Or the imple
d770: 6d 65 6e 74 61 74 69 6f 6e 20 6d 69 67 68 74 20 mentation might
d780: 72 65 63 6f 67 6e 69 7a 65 20 74 68 61 74 20 61 recognize that a
d790: 20 64 61 74 61 62 61 73 65 0a 2a 2a 20 66 69 6c database.** fil
d7a0: 65 20 77 69 6c 6c 20 62 65 20 64 6f 69 6e 67 20 e will be doing
d7b0: 70 61 67 65 2d 61 6c 69 67 6e 65 64 20 73 65 63 page-aligned sec
d7c0: 74 6f 72 20 72 65 61 64 73 20 61 6e 64 20 77 72 tor reads and wr
d7d0: 69 74 65 73 20 69 6e 20 61 20 72 61 6e 64 6f 6d ites in a random
d7e0: 0a 2a 2a 20 6f 72 64 65 72 20 61 6e 64 20 73 65 .** order and se
d7f0: 74 20 75 70 20 69 74 73 20 49 2f 4f 20 73 75 62 t up its I/O sub
d800: 73 79 73 74 65 6d 20 61 63 63 6f 72 64 69 6e 67 system according
d810: 6c 79 2e 0a 2a 2a 0a 2a 2a 20 53 51 4c 69 74 65 ly..**.** SQLite
d820: 20 6d 69 67 68 74 20 61 6c 73 6f 20 61 64 64 20 might also add
d830: 6f 6e 65 20 6f 66 20 74 68 65 20 66 6f 6c 6c 6f one of the follo
d840: 77 69 6e 67 20 66 6c 61 67 73 20 74 6f 20 74 68 wing flags to th
d850: 65 20 78 4f 70 65 6e 20 6d 65 74 68 6f 64 3a 0a e xOpen method:.
d860: 2a 2a 0a 2a 2a 20 3c 75 6c 3e 0a 2a 2a 20 3c 6c **.** <ul>.** <l
d870: 69 3e 20 5b 53 51 4c 49 54 45 5f 4f 50 45 4e 5f i> [SQLITE_OPEN_
d880: 44 45 4c 45 54 45 4f 4e 43 4c 4f 53 45 5d 0a 2a DELETEONCLOSE].*
d890: 2a 20 3c 6c 69 3e 20 5b 53 51 4c 49 54 45 5f 4f * <li> [SQLITE_O
d8a0: 50 45 4e 5f 45 58 43 4c 55 53 49 56 45 5d 0a 2a PEN_EXCLUSIVE].*
d8b0: 2a 20 3c 2f 75 6c 3e 0a 2a 2a 0a 2a 2a 20 54 68 * </ul>.**.** Th
d8c0: 65 20 5b 53 51 4c 49 54 45 5f 4f 50 45 4e 5f 44 e [SQLITE_OPEN_D
d8d0: 45 4c 45 54 45 4f 4e 43 4c 4f 53 45 5d 20 66 6c ELETEONCLOSE] fl
d8e0: 61 67 20 6d 65 61 6e 73 20 74 68 65 20 66 69 6c ag means the fil
d8f0: 65 20 73 68 6f 75 6c 64 20 62 65 0a 2a 2a 20 64 e should be.** d
d900: 65 6c 65 74 65 64 20 77 68 65 6e 20 69 74 20 69 eleted when it i
d910: 73 20 63 6c 6f 73 65 64 2e 20 20 5e 54 68 65 20 s closed. ^The
d920: 5b 53 51 4c 49 54 45 5f 4f 50 45 4e 5f 44 45 4c [SQLITE_OPEN_DEL
d930: 45 54 45 4f 4e 43 4c 4f 53 45 5d 0a 2a 2a 20 77 ETEONCLOSE].** w
d940: 69 6c 6c 20 62 65 20 73 65 74 20 66 6f 72 20 54 ill be set for T
d950: 45 4d 50 20 64 61 74 61 62 61 73 65 73 20 61 6e EMP databases an
d960: 64 20 74 68 65 69 72 20 6a 6f 75 72 6e 61 6c 73 d their journals
d970: 2c 20 74 72 61 6e 73 69 65 6e 74 0a 2a 2a 20 64 , transient.** d
d980: 61 74 61 62 61 73 65 73 2c 20 61 6e 64 20 73 75 atabases, and su
d990: 62 6a 6f 75 72 6e 61 6c 73 2e 0a 2a 2a 0a 2a 2a bjournals..**.**
d9a0: 20 5e 54 68 65 20 5b 53 51 4c 49 54 45 5f 4f 50 ^The [SQLITE_OP
d9b0: 45 4e 5f 45 58 43 4c 55 53 49 56 45 5d 20 66 6c EN_EXCLUSIVE] fl
d9c0: 61 67 20 69 73 20 61 6c 77 61 79 73 20 75 73 65 ag is always use
d9d0: 64 20 69 6e 20 63 6f 6e 6a 75 6e 63 74 69 6f 6e d in conjunction
d9e0: 0a 2a 2a 20 77 69 74 68 20 74 68 65 20 5b 53 51 .** with the [SQ
d9f0: 4c 49 54 45 5f 4f 50 45 4e 5f 43 52 45 41 54 45 LITE_OPEN_CREATE
da00: 5d 20 66 6c 61 67 2c 20 77 68 69 63 68 20 61 72 ] flag, which ar
da10: 65 20 62 6f 74 68 20 64 69 72 65 63 74 6c 79 0a e both directly.
da20: 2a 2a 20 61 6e 61 6c 6f 67 6f 75 73 20 74 6f 20 ** analogous to
da30: 74 68 65 20 4f 5f 45 58 43 4c 20 61 6e 64 20 4f the O_EXCL and O
da40: 5f 43 52 45 41 54 20 66 6c 61 67 73 20 6f 66 20 _CREAT flags of
da50: 74 68 65 20 50 4f 53 49 58 20 6f 70 65 6e 28 29 the POSIX open()
da60: 0a 2a 2a 20 41 50 49 2e 20 20 54 68 65 20 53 51 .** API. The SQ
da70: 4c 49 54 45 5f 4f 50 45 4e 5f 45 58 43 4c 55 53 LITE_OPEN_EXCLUS
da80: 49 56 45 20 66 6c 61 67 2c 20 77 68 65 6e 20 70 IVE flag, when p
da90: 61 69 72 65 64 20 77 69 74 68 20 74 68 65 20 0a aired with the .
daa0: 2a 2a 20 53 51 4c 49 54 45 5f 4f 50 45 4e 5f 43 ** SQLITE_OPEN_C
dab0: 52 45 41 54 45 2c 20 69 73 20 75 73 65 64 20 74 REATE, is used t
dac0: 6f 20 69 6e 64 69 63 61 74 65 20 74 68 61 74 20 o indicate that
dad0: 66 69 6c 65 20 73 68 6f 75 6c 64 20 61 6c 77 61 file should alwa
dae0: 79 73 0a 2a 2a 20 62 65 20 63 72 65 61 74 65 64 ys.** be created
daf0: 2c 20 61 6e 64 20 74 68 61 74 20 69 74 20 69 73 , and that it is
db00: 20 61 6e 20 65 72 72 6f 72 20 69 66 20 69 74 20 an error if it
db10: 61 6c 72 65 61 64 79 20 65 78 69 73 74 73 2e 0a already exists..
db20: 2a 2a 20 49 74 20 69 73 20 3c 69 3e 6e 6f 74 3c ** It is <i>not<
db30: 2f 69 3e 20 75 73 65 64 20 74 6f 20 69 6e 64 69 /i> used to indi
db40: 63 61 74 65 20 74 68 65 20 66 69 6c 65 20 73 68 cate the file sh
db50: 6f 75 6c 64 20 62 65 20 6f 70 65 6e 65 64 20 0a ould be opened .
db60: 2a 2a 20 66 6f 72 20 65 78 63 6c 75 73 69 76 65 ** for exclusive
db70: 20 61 63 63 65 73 73 2e 0a 2a 2a 0a 2a 2a 20 5e access..**.** ^
db80: 41 74 20 6c 65 61 73 74 20 73 7a 4f 73 46 69 6c At least szOsFil
db90: 65 20 62 79 74 65 73 20 6f 66 20 6d 65 6d 6f 72 e bytes of memor
dba0: 79 20 61 72 65 20 61 6c 6c 6f 63 61 74 65 64 20 y are allocated
dbb0: 62 79 20 53 51 4c 69 74 65 0a 2a 2a 20 74 6f 20 by SQLite.** to
dbc0: 68 6f 6c 64 20 74 68 65 20 20 5b 73 71 6c 69 74 hold the [sqlit
dbd0: 65 33 5f 66 69 6c 65 5d 20 73 74 72 75 63 74 75 e3_file] structu
dbe0: 72 65 20 70 61 73 73 65 64 20 61 73 20 74 68 65 re passed as the
dbf0: 20 74 68 69 72 64 0a 2a 2a 20 61 72 67 75 6d 65 third.** argume
dc00: 6e 74 20 74 6f 20 78 4f 70 65 6e 2e 20 20 54 68 nt to xOpen. Th
dc10: 65 20 78 4f 70 65 6e 20 6d 65 74 68 6f 64 20 64 e xOpen method d
dc20: 6f 65 73 20 6e 6f 74 20 68 61 76 65 20 74 6f 0a oes not have to.
dc30: 2a 2a 20 61 6c 6c 6f 63 61 74 65 20 74 68 65 20 ** allocate the
dc40: 73 74 72 75 63 74 75 72 65 3b 20 69 74 20 73 68 structure; it sh
dc50: 6f 75 6c 64 20 6a 75 73 74 20 66 69 6c 6c 20 69 ould just fill i
dc60: 74 20 69 6e 2e 20 20 4e 6f 74 65 20 74 68 61 74 t in. Note that
dc70: 0a 2a 2a 20 74 68 65 20 78 4f 70 65 6e 20 6d 65 .** the xOpen me
dc80: 74 68 6f 64 20 6d 75 73 74 20 73 65 74 20 74 68 thod must set th
dc90: 65 20 73 71 6c 69 74 65 33 5f 66 69 6c 65 2e 70 e sqlite3_file.p
dca0: 4d 65 74 68 6f 64 73 20 74 6f 20 65 69 74 68 65 Methods to eithe
dcb0: 72 0a 2a 2a 20 61 20 76 61 6c 69 64 20 5b 73 71 r.** a valid [sq
dcc0: 6c 69 74 65 33 5f 69 6f 5f 6d 65 74 68 6f 64 73 lite3_io_methods
dcd0: 5d 20 6f 62 6a 65 63 74 20 6f 72 20 74 6f 20 4e ] object or to N
dce0: 55 4c 4c 2e 20 20 78 4f 70 65 6e 20 6d 75 73 74 ULL. xOpen must
dcf0: 20 64 6f 0a 2a 2a 20 74 68 69 73 20 65 76 65 6e do.** this even
dd00: 20 69 66 20 74 68 65 20 6f 70 65 6e 20 66 61 69 if the open fai
dd10: 6c 73 2e 20 20 53 51 4c 69 74 65 20 65 78 70 65 ls. SQLite expe
dd20: 63 74 73 20 74 68 61 74 20 74 68 65 20 73 71 6c cts that the sql
dd30: 69 74 65 33 5f 66 69 6c 65 2e 70 4d 65 74 68 6f ite3_file.pMetho
dd40: 64 73 0a 2a 2a 20 65 6c 65 6d 65 6e 74 20 77 69 ds.** element wi
dd50: 6c 6c 20 62 65 20 76 61 6c 69 64 20 61 66 74 65 ll be valid afte
dd60: 72 20 78 4f 70 65 6e 20 72 65 74 75 72 6e 73 20 r xOpen returns
dd70: 72 65 67 61 72 64 6c 65 73 73 20 6f 66 20 74 68 regardless of th
dd80: 65 20 73 75 63 63 65 73 73 0a 2a 2a 20 6f 72 20 e success.** or
dd90: 66 61 69 6c 75 72 65 20 6f 66 20 74 68 65 20 78 failure of the x
dda0: 4f 70 65 6e 20 63 61 6c 6c 2e 0a 2a 2a 0a 2a 2a Open call..**.**
ddb0: 20 5b 5b 73 71 6c 69 74 65 33 5f 76 66 73 2e 78 [[sqlite3_vfs.x
ddc0: 41 63 63 65 73 73 5d 5d 0a 2a 2a 20 5e 54 68 65 Access]].** ^The
ddd0: 20 66 6c 61 67 73 20 61 72 67 75 6d 65 6e 74 20 flags argument
dde0: 74 6f 20 78 41 63 63 65 73 73 28 29 20 6d 61 79 to xAccess() may
ddf0: 20 62 65 20 5b 53 51 4c 49 54 45 5f 41 43 43 45 be [SQLITE_ACCE
de00: 53 53 5f 45 58 49 53 54 53 5d 0a 2a 2a 20 74 6f SS_EXISTS].** to
de10: 20 74 65 73 74 20 66 6f 72 20 74 68 65 20 65 78 test for the ex
de20: 69 73 74 65 6e 63 65 20 6f 66 20 61 20 66 69 6c istence of a fil
de30: 65 2c 20 6f 72 20 5b 53 51 4c 49 54 45 5f 41 43 e, or [SQLITE_AC
de40: 43 45 53 53 5f 52 45 41 44 57 52 49 54 45 5d 20 CESS_READWRITE]
de50: 74 6f 0a 2a 2a 20 74 65 73 74 20 77 68 65 74 68 to.** test wheth
de60: 65 72 20 61 20 66 69 6c 65 20 69 73 20 72 65 61 er a file is rea
de70: 64 61 62 6c 65 20 61 6e 64 20 77 72 69 74 61 62 dable and writab
de80: 6c 65 2c 20 6f 72 20 5b 53 51 4c 49 54 45 5f 41 le, or [SQLITE_A
de90: 43 43 45 53 53 5f 52 45 41 44 5d 0a 2a 2a 20 74 CCESS_READ].** t
dea0: 6f 20 74 65 73 74 20 77 68 65 74 68 65 72 20 61 o test whether a
deb0: 20 66 69 6c 65 20 69 73 20 61 74 20 6c 65 61 73 file is at leas
dec0: 74 20 72 65 61 64 61 62 6c 65 2e 20 20 20 54 68 t readable. Th
ded0: 65 20 66 69 6c 65 20 63 61 6e 20 62 65 20 61 0a e file can be a.
dee0: 2a 2a 20 64 69 72 65 63 74 6f 72 79 2e 0a 2a 2a ** directory..**
def0: 0a 2a 2a 20 5e 53 51 4c 69 74 65 20 77 69 6c 6c .** ^SQLite will
df00: 20 61 6c 77 61 79 73 20 61 6c 6c 6f 63 61 74 65 always allocate
df10: 20 61 74 20 6c 65 61 73 74 20 6d 78 50 61 74 68 at least mxPath
df20: 6e 61 6d 65 2b 31 20 62 79 74 65 73 20 66 6f 72 name+1 bytes for
df30: 20 74 68 65 0a 2a 2a 20 6f 75 74 70 75 74 20 62 the.** output b
df40: 75 66 66 65 72 20 78 46 75 6c 6c 50 61 74 68 6e uffer xFullPathn
df50: 61 6d 65 2e 20 20 54 68 65 20 65 78 61 63 74 20 ame. The exact
df60: 73 69 7a 65 20 6f 66 20 74 68 65 20 6f 75 74 70 size of the outp
df70: 75 74 20 62 75 66 66 65 72 0a 2a 2a 20 69 73 20 ut buffer.** is
df80: 61 6c 73 6f 20 70 61 73 73 65 64 20 61 73 20 61 also passed as a
df90: 20 70 61 72 61 6d 65 74 65 72 20 74 6f 20 62 6f parameter to bo
dfa0: 74 68 20 20 6d 65 74 68 6f 64 73 2e 20 49 66 20 th methods. If
dfb0: 74 68 65 20 6f 75 74 70 75 74 20 62 75 66 66 65 the output buffe
dfc0: 72 0a 2a 2a 20 69 73 20 6e 6f 74 20 6c 61 72 67 r.** is not larg
dfd0: 65 20 65 6e 6f 75 67 68 2c 20 5b 53 51 4c 49 54 e enough, [SQLIT
dfe0: 45 5f 43 41 4e 54 4f 50 45 4e 5d 20 73 68 6f 75 E_CANTOPEN] shou
dff0: 6c 64 20 62 65 20 72 65 74 75 72 6e 65 64 2e 20 ld be returned.
e000: 53 69 6e 63 65 20 74 68 69 73 20 69 73 0a 2a 2a Since this is.**
e010: 20 68 61 6e 64 6c 65 64 20 61 73 20 61 20 66 61 handled as a fa
e020: 74 61 6c 20 65 72 72 6f 72 20 62 79 20 53 51 4c tal error by SQL
e030: 69 74 65 2c 20 76 66 73 20 69 6d 70 6c 65 6d 65 ite, vfs impleme
e040: 6e 74 61 74 69 6f 6e 73 20 73 68 6f 75 6c 64 20 ntations should
e050: 65 6e 64 65 61 76 6f 72 0a 2a 2a 20 74 6f 20 70 endeavor.** to p
e060: 72 65 76 65 6e 74 20 74 68 69 73 20 62 79 20 73 revent this by s
e070: 65 74 74 69 6e 67 20 6d 78 50 61 74 68 6e 61 6d etting mxPathnam
e080: 65 20 74 6f 20 61 20 73 75 66 66 69 63 69 65 6e e to a sufficien
e090: 74 6c 79 20 6c 61 72 67 65 20 76 61 6c 75 65 2e tly large value.
e0a0: 0a 2a 2a 0a 2a 2a 20 54 68 65 20 78 52 61 6e 64 .**.** The xRand
e0b0: 6f 6d 6e 65 73 73 28 29 2c 20 78 53 6c 65 65 70 omness(), xSleep
e0c0: 28 29 2c 20 78 43 75 72 72 65 6e 74 54 69 6d 65 (), xCurrentTime
e0d0: 28 29 2c 20 61 6e 64 20 78 43 75 72 72 65 6e 74 (), and xCurrent
e0e0: 54 69 6d 65 49 6e 74 36 34 28 29 0a 2a 2a 20 69 TimeInt64().** i
e0f0: 6e 74 65 72 66 61 63 65 73 20 61 72 65 20 6e 6f nterfaces are no
e100: 74 20 73 74 72 69 63 74 6c 79 20 61 20 70 61 72 t strictly a par
e110: 74 20 6f 66 20 74 68 65 20 66 69 6c 65 73 79 73 t of the filesys
e120: 74 65 6d 2c 20 62 75 74 20 74 68 65 79 20 61 72 tem, but they ar
e130: 65 0a 2a 2a 20 69 6e 63 6c 75 64 65 64 20 69 6e e.** included in
e140: 20 74 68 65 20 56 46 53 20 73 74 72 75 63 74 75 the VFS structu
e150: 72 65 20 66 6f 72 20 63 6f 6d 70 6c 65 74 65 6e re for completen
e160: 65 73 73 2e 0a 2a 2a 20 54 68 65 20 78 52 61 6e ess..** The xRan
e170: 64 6f 6d 6e 65 73 73 28 29 20 66 75 6e 63 74 69 domness() functi
e180: 6f 6e 20 61 74 74 65 6d 70 74 73 20 74 6f 20 72 on attempts to r
e190: 65 74 75 72 6e 20 6e 42 79 74 65 73 20 62 79 74 eturn nBytes byt
e1a0: 65 73 0a 2a 2a 20 6f 66 20 67 6f 6f 64 2d 71 75 es.** of good-qu
e1b0: 61 6c 69 74 79 20 72 61 6e 64 6f 6d 6e 65 73 73 ality randomness
e1c0: 20 69 6e 74 6f 20 7a 4f 75 74 2e 20 20 54 68 65 into zOut. The
e1d0: 20 72 65 74 75 72 6e 20 76 61 6c 75 65 20 69 73 return value is
e1e0: 0a 2a 2a 20 74 68 65 20 61 63 74 75 61 6c 20 6e .** the actual n
e1f0: 75 6d 62 65 72 20 6f 66 20 62 79 74 65 73 20 6f umber of bytes o
e200: 66 20 72 61 6e 64 6f 6d 6e 65 73 73 20 6f 62 74 f randomness obt
e210: 61 69 6e 65 64 2e 0a 2a 2a 20 54 68 65 20 78 53 ained..** The xS
e220: 6c 65 65 70 28 29 20 6d 65 74 68 6f 64 20 63 61 leep() method ca
e230: 75 73 65 73 20 74 68 65 20 63 61 6c 6c 69 6e 67 uses the calling
e240: 20 74 68 72 65 61 64 20 74 6f 20 73 6c 65 65 70 thread to sleep
e250: 20 66 6f 72 20 61 74 0a 2a 2a 20 6c 65 61 73 74 for at.** least
e260: 20 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 6d the number of m
e270: 69 63 72 6f 73 65 63 6f 6e 64 73 20 67 69 76 65 icroseconds give
e280: 6e 2e 20 20 5e 54 68 65 20 78 43 75 72 72 65 6e n. ^The xCurren
e290: 74 54 69 6d 65 28 29 0a 2a 2a 20 6d 65 74 68 6f tTime().** metho
e2a0: 64 20 72 65 74 75 72 6e 73 20 61 20 4a 75 6c 69 d returns a Juli
e2b0: 61 6e 20 44 61 79 20 4e 75 6d 62 65 72 20 66 6f an Day Number fo
e2c0: 72 20 74 68 65 20 63 75 72 72 65 6e 74 20 64 61 r the current da
e2d0: 74 65 20 61 6e 64 20 74 69 6d 65 20 61 73 0a 2a te and time as.*
e2e0: 2a 20 61 20 66 6c 6f 61 74 69 6e 67 20 70 6f 69 * a floating poi
e2f0: 6e 74 20 76 61 6c 75 65 2e 0a 2a 2a 20 5e 54 68 nt value..** ^Th
e300: 65 20 78 43 75 72 72 65 6e 74 54 69 6d 65 49 6e e xCurrentTimeIn
e310: 74 36 34 28 29 20 6d 65 74 68 6f 64 20 72 65 74 t64() method ret
e320: 75 72 6e 73 2c 20 61 73 20 61 6e 20 69 6e 74 65 urns, as an inte
e330: 67 65 72 2c 20 74 68 65 20 4a 75 6c 69 61 6e 0a ger, the Julian.
e340: 2a 2a 20 44 61 79 20 4e 75 6d 62 65 72 20 6d 75 ** Day Number mu
e350: 6c 74 69 70 6c 69 65 64 20 62 79 20 38 36 34 30 ltiplied by 8640
e360: 30 30 30 30 20 28 74 68 65 20 6e 75 6d 62 65 72 0000 (the number
e370: 20 6f 66 20 6d 69 6c 6c 69 73 65 63 6f 6e 64 73 of milliseconds
e380: 20 69 6e 20 0a 2a 2a 20 61 20 32 34 2d 68 6f 75 in .** a 24-hou
e390: 72 20 64 61 79 29 2e 20 20 0a 2a 2a 20 5e 53 51 r day). .** ^SQ
e3a0: 4c 69 74 65 20 77 69 6c 6c 20 75 73 65 20 74 68 Lite will use th
e3b0: 65 20 78 43 75 72 72 65 6e 74 54 69 6d 65 49 6e e xCurrentTimeIn
e3c0: 74 36 34 28 29 20 6d 65 74 68 6f 64 20 74 6f 20 t64() method to
e3d0: 67 65 74 20 74 68 65 20 63 75 72 72 65 6e 74 0a get the current.
e3e0: 2a 2a 20 64 61 74 65 20 61 6e 64 20 74 69 6d 65 ** date and time
e3f0: 20 69 66 20 74 68 61 74 20 6d 65 74 68 6f 64 20 if that method
e400: 69 73 20 61 76 61 69 6c 61 62 6c 65 20 28 69 66 is available (if
e410: 20 69 56 65 72 73 69 6f 6e 20 69 73 20 32 20 6f iVersion is 2 o
e420: 72 20 0a 2a 2a 20 67 72 65 61 74 65 72 20 61 6e r .** greater an
e430: 64 20 74 68 65 20 66 75 6e 63 74 69 6f 6e 20 70 d the function p
e440: 6f 69 6e 74 65 72 20 69 73 20 6e 6f 74 20 4e 55 ointer is not NU
e450: 4c 4c 29 20 61 6e 64 20 77 69 6c 6c 20 66 61 6c LL) and will fal
e460: 6c 20 62 61 63 6b 0a 2a 2a 20 74 6f 20 78 43 75 l back.** to xCu
e470: 72 72 65 6e 74 54 69 6d 65 28 29 20 69 66 20 78 rrentTime() if x
e480: 43 75 72 72 65 6e 74 54 69 6d 65 49 6e 74 36 34 CurrentTimeInt64
e490: 28 29 20 69 73 20 75 6e 61 76 61 69 6c 61 62 6c () is unavailabl
e4a0: 65 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 78 53 e..**.** ^The xS
e4b0: 65 74 53 79 73 74 65 6d 43 61 6c 6c 28 29 2c 20 etSystemCall(),
e4c0: 78 47 65 74 53 79 73 74 65 6d 43 61 6c 6c 28 29 xGetSystemCall()
e4d0: 2c 20 61 6e 64 20 78 4e 65 73 74 53 79 73 74 65 , and xNestSyste
e4e0: 6d 43 61 6c 6c 28 29 20 69 6e 74 65 72 66 61 63 mCall() interfac
e4f0: 65 73 0a 2a 2a 20 61 72 65 20 6e 6f 74 20 75 73 es.** are not us
e500: 65 64 20 62 79 20 74 68 65 20 53 51 4c 69 74 65 ed by the SQLite
e510: 20 63 6f 72 65 2e 20 20 54 68 65 73 65 20 6f 70 core. These op
e520: 74 69 6f 6e 61 6c 20 69 6e 74 65 72 66 61 63 65 tional interface
e530: 73 20 61 72 65 20 70 72 6f 76 69 64 65 64 0a 2a s are provided.*
e540: 2a 20 62 79 20 73 6f 6d 65 20 56 46 53 65 73 20 * by some VFSes
e550: 74 6f 20 66 61 63 69 6c 69 74 61 74 65 20 74 65 to facilitate te
e560: 73 74 69 6e 67 20 6f 66 20 74 68 65 20 56 46 53 sting of the VFS
e570: 20 63 6f 64 65 2e 20 42 79 20 6f 76 65 72 72 69 code. By overri
e580: 64 69 6e 67 20 0a 2a 2a 20 73 79 73 74 65 6d 20 ding .** system
e590: 63 61 6c 6c 73 20 77 69 74 68 20 66 75 6e 63 74 calls with funct
e5a0: 69 6f 6e 73 20 75 6e 64 65 72 20 69 74 73 20 63 ions under its c
e5b0: 6f 6e 74 72 6f 6c 2c 20 61 20 74 65 73 74 20 70 ontrol, a test p
e5c0: 72 6f 67 72 61 6d 20 63 61 6e 0a 2a 2a 20 73 69 rogram can.** si
e5d0: 6d 75 6c 61 74 65 20 66 61 75 6c 74 73 20 61 6e mulate faults an
e5e0: 64 20 65 72 72 6f 72 20 63 6f 6e 64 69 74 69 6f d error conditio
e5f0: 6e 73 20 74 68 61 74 20 77 6f 75 6c 64 20 6f 74 ns that would ot
e600: 68 65 72 77 69 73 65 20 62 65 20 64 69 66 66 69 herwise be diffi
e610: 63 75 6c 74 0a 2a 2a 20 6f 72 20 69 6d 70 6f 73 cult.** or impos
e620: 73 69 62 6c 65 20 74 6f 20 69 6e 64 75 63 65 2e sible to induce.
e630: 20 20 54 68 65 20 73 65 74 20 6f 66 20 73 79 73 The set of sys
e640: 74 65 6d 20 63 61 6c 6c 73 20 74 68 61 74 20 63 tem calls that c
e650: 61 6e 20 62 65 20 6f 76 65 72 72 69 64 64 65 6e an be overridden
e660: 0a 2a 2a 20 76 61 72 69 65 73 20 66 72 6f 6d 20 .** varies from
e670: 6f 6e 65 20 56 46 53 20 74 6f 20 61 6e 6f 74 68 one VFS to anoth
e680: 65 72 2c 20 61 6e 64 20 66 72 6f 6d 20 6f 6e 65 er, and from one
e690: 20 76 65 72 73 69 6f 6e 20 6f 66 20 74 68 65 20 version of the
e6a0: 73 61 6d 65 20 56 46 53 20 74 6f 20 74 68 65 0a same VFS to the.
e6b0: 2a 2a 20 6e 65 78 74 2e 20 20 41 70 70 6c 69 63 ** next. Applic
e6c0: 61 74 69 6f 6e 73 20 74 68 61 74 20 75 73 65 20 ations that use
e6d0: 74 68 65 73 65 20 69 6e 74 65 72 66 61 63 65 73 these interfaces
e6e0: 20 6d 75 73 74 20 62 65 20 70 72 65 70 61 72 65 must be prepare
e6f0: 64 20 66 6f 72 20 61 6e 79 0a 2a 2a 20 6f 72 20 d for any.** or
e700: 61 6c 6c 20 6f 66 20 74 68 65 73 65 20 69 6e 74 all of these int
e710: 65 72 66 61 63 65 73 20 74 6f 20 62 65 20 4e 55 erfaces to be NU
e720: 4c 4c 20 6f 72 20 66 6f 72 20 74 68 65 69 72 20 LL or for their
e730: 62 65 68 61 76 69 6f 72 20 74 6f 20 63 68 61 6e behavior to chan
e740: 67 65 0a 2a 2a 20 66 72 6f 6d 20 6f 6e 65 20 72 ge.** from one r
e750: 65 6c 65 61 73 65 20 74 6f 20 74 68 65 20 6e 65 elease to the ne
e760: 78 74 2e 20 20 41 70 70 6c 69 63 61 74 69 6f 6e xt. Application
e770: 73 20 6d 75 73 74 20 6e 6f 74 20 61 74 74 65 6d s must not attem
e780: 70 74 20 74 6f 20 61 63 63 65 73 73 0a 2a 2a 20 pt to access.**
e790: 61 6e 79 20 6f 66 20 74 68 65 73 65 20 6d 65 74 any of these met
e7a0: 68 6f 64 73 20 69 66 20 74 68 65 20 69 56 65 72 hods if the iVer
e7b0: 73 69 6f 6e 20 6f 66 20 74 68 65 20 56 46 53 20 sion of the VFS
e7c0: 69 73 20 6c 65 73 73 20 74 68 61 6e 20 33 2e 0a is less than 3..
e7d0: 2a 2f 0a 74 79 70 65 64 65 66 20 73 74 72 75 63 */.typedef struc
e7e0: 74 20 73 71 6c 69 74 65 33 5f 76 66 73 20 73 71 t sqlite3_vfs sq
e7f0: 6c 69 74 65 33 5f 76 66 73 3b 0a 74 79 70 65 64 lite3_vfs;.typed
e800: 65 66 20 76 6f 69 64 20 28 2a 73 71 6c 69 74 65 ef void (*sqlite
e810: 33 5f 73 79 73 63 61 6c 6c 5f 70 74 72 29 28 76 3_syscall_ptr)(v
e820: 6f 69 64 29 3b 0a 73 74 72 75 63 74 20 73 71 6c oid);.struct sql
e830: 69 74 65 33 5f 76 66 73 20 7b 0a 20 20 69 6e 74 ite3_vfs {. int
e840: 20 69 56 65 72 73 69 6f 6e 3b 20 20 20 20 20 20 iVersion;
e850: 20 20 20 20 20 20 2f 2a 20 53 74 72 75 63 74 75 /* Structu
e860: 72 65 20 76 65 72 73 69 6f 6e 20 6e 75 6d 62 65 re version numbe
e870: 72 20 28 63 75 72 72 65 6e 74 6c 79 20 33 29 20 r (currently 3)
e880: 2a 2f 0a 20 20 69 6e 74 20 73 7a 4f 73 46 69 6c */. int szOsFil
e890: 65 3b 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a e; /*
e8a0: 20 53 69 7a 65 20 6f 66 20 73 75 62 63 6c 61 73 Size of subclas
e8b0: 73 65 64 20 73 71 6c 69 74 65 33 5f 66 69 6c 65 sed sqlite3_file
e8c0: 20 2a 2f 0a 20 20 69 6e 74 20 6d 78 50 61 74 68 */. int mxPath
e8d0: 6e 61 6d 65 3b 20 20 20 20 20 20 20 20 20 20 2f name; /
e8e0: 2a 20 4d 61 78 69 6d 75 6d 20 66 69 6c 65 20 70 * Maximum file p
e8f0: 61 74 68 6e 61 6d 65 20 6c 65 6e 67 74 68 20 2a athname length *
e900: 2f 0a 20 20 73 71 6c 69 74 65 33 5f 76 66 73 20 /. sqlite3_vfs
e910: 2a 70 4e 65 78 74 3b 20 20 20 20 20 20 2f 2a 20 *pNext; /*
e920: 4e 65 78 74 20 72 65 67 69 73 74 65 72 65 64 20 Next registered
e930: 56 46 53 20 2a 2f 0a 20 20 63 6f 6e 73 74 20 63 VFS */. const c
e940: 68 61 72 20 2a 7a 4e 61 6d 65 3b 20 20 20 20 20 har *zName;
e950: 20 20 2f 2a 20 4e 61 6d 65 20 6f 66 20 74 68 69 /* Name of thi
e960: 73 20 76 69 72 74 75 61 6c 20 66 69 6c 65 20 73 s virtual file s
e970: 79 73 74 65 6d 20 2a 2f 0a 20 20 76 6f 69 64 20 ystem */. void
e980: 2a 70 41 70 70 44 61 74 61 3b 20 20 20 20 20 20 *pAppData;
e990: 20 20 20 20 2f 2a 20 50 6f 69 6e 74 65 72 20 74 /* Pointer t
e9a0: 6f 20 61 70 70 6c 69 63 61 74 69 6f 6e 2d 73 70 o application-sp
e9b0: 65 63 69 66 69 63 20 64 61 74 61 20 2a 2f 0a 20 ecific data */.
e9c0: 20 69 6e 74 20 28 2a 78 4f 70 65 6e 29 28 73 71 int (*xOpen)(sq
e9d0: 6c 69 74 65 33 5f 76 66 73 2a 2c 20 63 6f 6e 73 lite3_vfs*, cons
e9e0: 74 20 63 68 61 72 20 2a 7a 4e 61 6d 65 2c 20 73 t char *zName, s
e9f0: 71 6c 69 74 65 33 5f 66 69 6c 65 2a 2c 0a 20 20 qlite3_file*,.
ea00: 20 20 20 20 20 20 20 20 20 20 20 20 20 69 6e 74 int
ea10: 20 66 6c 61 67 73 2c 20 69 6e 74 20 2a 70 4f 75 flags, int *pOu
ea20: 74 46 6c 61 67 73 29 3b 0a 20 20 69 6e 74 20 28 tFlags);. int (
ea30: 2a 78 44 65 6c 65 74 65 29 28 73 71 6c 69 74 65 *xDelete)(sqlite
ea40: 33 5f 76 66 73 2a 2c 20 63 6f 6e 73 74 20 63 68 3_vfs*, const ch
ea50: 61 72 20 2a 7a 4e 61 6d 65 2c 20 69 6e 74 20 73 ar *zName, int s
ea60: 79 6e 63 44 69 72 29 3b 0a 20 20 69 6e 74 20 28 yncDir);. int (
ea70: 2a 78 41 63 63 65 73 73 29 28 73 71 6c 69 74 65 *xAccess)(sqlite
ea80: 33 5f 76 66 73 2a 2c 20 63 6f 6e 73 74 20 63 68 3_vfs*, const ch
ea90: 61 72 20 2a 7a 4e 61 6d 65 2c 20 69 6e 74 20 66 ar *zName, int f
eaa0: 6c 61 67 73 2c 20 69 6e 74 20 2a 70 52 65 73 4f lags, int *pResO
eab0: 75 74 29 3b 0a 20 20 69 6e 74 20 28 2a 78 46 75 ut);. int (*xFu
eac0: 6c 6c 50 61 74 68 6e 61 6d 65 29 28 73 71 6c 69 llPathname)(sqli
ead0: 74 65 33 5f 76 66 73 2a 2c 20 63 6f 6e 73 74 20 te3_vfs*, const
eae0: 63 68 61 72 20 2a 7a 4e 61 6d 65 2c 20 69 6e 74 char *zName, int
eaf0: 20 6e 4f 75 74 2c 20 63 68 61 72 20 2a 7a 4f 75 nOut, char *zOu
eb00: 74 29 3b 0a 20 20 76 6f 69 64 20 2a 28 2a 78 44 t);. void *(*xD
eb10: 6c 4f 70 65 6e 29 28 73 71 6c 69 74 65 33 5f 76 lOpen)(sqlite3_v
eb20: 66 73 2a 2c 20 63 6f 6e 73 74 20 63 68 61 72 20 fs*, const char
eb30: 2a 7a 46 69 6c 65 6e 61 6d 65 29 3b 0a 20 20 76 *zFilename);. v
eb40: 6f 69 64 20 28 2a 78 44 6c 45 72 72 6f 72 29 28 oid (*xDlError)(
eb50: 73 71 6c 69 74 65 33 5f 76 66 73 2a 2c 20 69 6e sqlite3_vfs*, in
eb60: 74 20 6e 42 79 74 65 2c 20 63 68 61 72 20 2a 7a t nByte, char *z
eb70: 45 72 72 4d 73 67 29 3b 0a 20 20 76 6f 69 64 20 ErrMsg);. void
eb80: 28 2a 28 2a 78 44 6c 53 79 6d 29 28 73 71 6c 69 (*(*xDlSym)(sqli
eb90: 74 65 33 5f 76 66 73 2a 2c 76 6f 69 64 2a 2c 20 te3_vfs*,void*,
eba0: 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 53 79 6d const char *zSym
ebb0: 62 6f 6c 29 29 28 76 6f 69 64 29 3b 0a 20 20 76 bol))(void);. v
ebc0: 6f 69 64 20 28 2a 78 44 6c 43 6c 6f 73 65 29 28 oid (*xDlClose)(
ebd0: 73 71 6c 69 74 65 33 5f 76 66 73 2a 2c 20 76 6f sqlite3_vfs*, vo
ebe0: 69 64 2a 29 3b 0a 20 20 69 6e 74 20 28 2a 78 52 id*);. int (*xR
ebf0: 61 6e 64 6f 6d 6e 65 73 73 29 28 73 71 6c 69 74 andomness)(sqlit
ec00: 65 33 5f 76 66 73 2a 2c 20 69 6e 74 20 6e 42 79 e3_vfs*, int nBy
ec10: 74 65 2c 20 63 68 61 72 20 2a 7a 4f 75 74 29 3b te, char *zOut);
ec20: 0a 20 20 69 6e 74 20 28 2a 78 53 6c 65 65 70 29 . int (*xSleep)
ec30: 28 73 71 6c 69 74 65 33 5f 76 66 73 2a 2c 20 69 (sqlite3_vfs*, i
ec40: 6e 74 20 6d 69 63 72 6f 73 65 63 6f 6e 64 73 29 nt microseconds)
ec50: 3b 0a 20 20 69 6e 74 20 28 2a 78 43 75 72 72 65 ;. int (*xCurre
ec60: 6e 74 54 69 6d 65 29 28 73 71 6c 69 74 65 33 5f ntTime)(sqlite3_
ec70: 76 66 73 2a 2c 20 64 6f 75 62 6c 65 2a 29 3b 0a vfs*, double*);.
ec80: 20 20 69 6e 74 20 28 2a 78 47 65 74 4c 61 73 74 int (*xGetLast
ec90: 45 72 72 6f 72 29 28 73 71 6c 69 74 65 33 5f 76 Error)(sqlite3_v
eca0: 66 73 2a 2c 20 69 6e 74 2c 20 63 68 61 72 20 2a fs*, int, char *
ecb0: 29 3b 0a 20 20 2f 2a 0a 20 20 2a 2a 20 54 68 65 );. /*. ** The
ecc0: 20 6d 65 74 68 6f 64 73 20 61 62 6f 76 65 20 61 methods above a
ecd0: 72 65 20 69 6e 20 76 65 72 73 69 6f 6e 20 31 20 re in version 1
ece0: 6f 66 20 74 68 65 20 73 71 6c 69 74 65 5f 76 66 of the sqlite_vf
ecf0: 73 20 6f 62 6a 65 63 74 0a 20 20 2a 2a 20 64 65 s object. ** de
ed00: 66 69 6e 69 74 69 6f 6e 2e 20 20 54 68 6f 73 65 finition. Those
ed10: 20 74 68 61 74 20 66 6f 6c 6c 6f 77 20 61 72 65 that follow are
ed20: 20 61 64 64 65 64 20 69 6e 20 76 65 72 73 69 6f added in versio
ed30: 6e 20 32 20 6f 72 20 6c 61 74 65 72 0a 20 20 2a n 2 or later. *
ed40: 2f 0a 20 20 69 6e 74 20 28 2a 78 43 75 72 72 65 /. int (*xCurre
ed50: 6e 74 54 69 6d 65 49 6e 74 36 34 29 28 73 71 6c ntTimeInt64)(sql
ed60: 69 74 65 33 5f 76 66 73 2a 2c 20 73 71 6c 69 74 ite3_vfs*, sqlit
ed70: 65 33 5f 69 6e 74 36 34 2a 29 3b 0a 20 20 2f 2a e3_int64*);. /*
ed80: 0a 20 20 2a 2a 20 54 68 65 20 6d 65 74 68 6f 64 . ** The method
ed90: 73 20 61 62 6f 76 65 20 61 72 65 20 69 6e 20 76 s above are in v
eda0: 65 72 73 69 6f 6e 73 20 31 20 61 6e 64 20 32 20 ersions 1 and 2
edb0: 6f 66 20 74 68 65 20 73 71 6c 69 74 65 5f 76 66 of the sqlite_vf
edc0: 73 20 6f 62 6a 65 63 74 2e 0a 20 20 2a 2a 20 54 s object.. ** T
edd0: 68 6f 73 65 20 62 65 6c 6f 77 20 61 72 65 20 66 hose below are f
ede0: 6f 72 20 76 65 72 73 69 6f 6e 20 33 20 61 6e 64 or version 3 and
edf0: 20 67 72 65 61 74 65 72 2e 0a 20 20 2a 2f 0a 20 greater.. */.
ee00: 20 69 6e 74 20 28 2a 78 53 65 74 53 79 73 74 65 int (*xSetSyste
ee10: 6d 43 61 6c 6c 29 28 73 71 6c 69 74 65 33 5f 76 mCall)(sqlite3_v
ee20: 66 73 2a 2c 20 63 6f 6e 73 74 20 63 68 61 72 20 fs*, const char
ee30: 2a 7a 4e 61 6d 65 2c 20 73 71 6c 69 74 65 33 5f *zName, sqlite3_
ee40: 73 79 73 63 61 6c 6c 5f 70 74 72 29 3b 0a 20 20 syscall_ptr);.
ee50: 73 71 6c 69 74 65 33 5f 73 79 73 63 61 6c 6c 5f sqlite3_syscall_
ee60: 70 74 72 20 28 2a 78 47 65 74 53 79 73 74 65 6d ptr (*xGetSystem
ee70: 43 61 6c 6c 29 28 73 71 6c 69 74 65 33 5f 76 66 Call)(sqlite3_vf
ee80: 73 2a 2c 20 63 6f 6e 73 74 20 63 68 61 72 20 2a s*, const char *
ee90: 7a 4e 61 6d 65 29 3b 0a 20 20 63 6f 6e 73 74 20 zName);. const
eea0: 63 68 61 72 20 2a 28 2a 78 4e 65 78 74 53 79 73 char *(*xNextSys
eeb0: 74 65 6d 43 61 6c 6c 29 28 73 71 6c 69 74 65 33 temCall)(sqlite3
eec0: 5f 76 66 73 2a 2c 20 63 6f 6e 73 74 20 63 68 61 _vfs*, const cha
eed0: 72 20 2a 7a 4e 61 6d 65 29 3b 0a 20 20 2f 2a 0a r *zName);. /*.
eee0: 20 20 2a 2a 20 54 68 65 20 6d 65 74 68 6f 64 73 ** The methods
eef0: 20 61 62 6f 76 65 20 61 72 65 20 69 6e 20 76 65 above are in ve
ef00: 72 73 69 6f 6e 73 20 31 20 74 68 72 6f 75 67 68 rsions 1 through
ef10: 20 33 20 6f 66 20 74 68 65 20 73 71 6c 69 74 65 3 of the sqlite
ef20: 5f 76 66 73 20 6f 62 6a 65 63 74 2e 0a 20 20 2a _vfs object.. *
ef30: 2a 20 4e 65 77 20 66 69 65 6c 64 73 20 6d 61 79 * New fields may
ef40: 20 62 65 20 61 70 70 65 6e 64 65 64 20 69 6e 20 be appended in
ef50: 66 75 74 75 72 65 20 76 65 72 73 69 6f 6e 73 2e future versions.
ef60: 20 20 54 68 65 20 69 56 65 72 73 69 6f 6e 0a 20 The iVersion.
ef70: 20 2a 2a 20 76 61 6c 75 65 20 77 69 6c 6c 20 69 ** value will i
ef80: 6e 63 72 65 6d 65 6e 74 20 77 68 65 6e 65 76 65 ncrement wheneve
ef90: 72 20 74 68 69 73 20 68 61 70 70 65 6e 73 2e 20 r this happens.
efa0: 0a 20 20 2a 2f 0a 7d 3b 0a 0a 2f 2a 0a 2a 2a 20 . */.};../*.**
efb0: 43 41 50 49 33 52 45 46 3a 20 46 6c 61 67 73 20 CAPI3REF: Flags
efc0: 66 6f 72 20 74 68 65 20 78 41 63 63 65 73 73 20 for the xAccess
efd0: 56 46 53 20 6d 65 74 68 6f 64 0a 2a 2a 0a 2a 2a VFS method.**.**
efe0: 20 54 68 65 73 65 20 69 6e 74 65 67 65 72 20 63 These integer c
eff0: 6f 6e 73 74 61 6e 74 73 20 63 61 6e 20 62 65 20 onstants can be
f000: 75 73 65 64 20 61 73 20 74 68 65 20 74 68 69 72 used as the thir
f010: 64 20 70 61 72 61 6d 65 74 65 72 20 74 6f 0a 2a d parameter to.*
f020: 2a 20 74 68 65 20 78 41 63 63 65 73 73 20 6d 65 * the xAccess me
f030: 74 68 6f 64 20 6f 66 20 61 6e 20 5b 73 71 6c 69 thod of an [sqli
f040: 74 65 33 5f 76 66 73 5d 20 6f 62 6a 65 63 74 2e te3_vfs] object.
f050: 20 20 54 68 65 79 20 64 65 74 65 72 6d 69 6e 65 They determine
f060: 0a 2a 2a 20 77 68 61 74 20 6b 69 6e 64 20 6f 66 .** what kind of
f070: 20 70 65 72 6d 69 73 73 69 6f 6e 73 20 74 68 65 permissions the
f080: 20 78 41 63 63 65 73 73 20 6d 65 74 68 6f 64 20 xAccess method
f090: 69 73 20 6c 6f 6f 6b 69 6e 67 20 66 6f 72 2e 0a is looking for..
f0a0: 2a 2a 20 57 69 74 68 20 53 51 4c 49 54 45 5f 41 ** With SQLITE_A
f0b0: 43 43 45 53 53 5f 45 58 49 53 54 53 2c 20 74 68 CCESS_EXISTS, th
f0c0: 65 20 78 41 63 63 65 73 73 20 6d 65 74 68 6f 64 e xAccess method
f0d0: 0a 2a 2a 20 73 69 6d 70 6c 79 20 63 68 65 63 6b .** simply check
f0e0: 73 20 77 68 65 74 68 65 72 20 74 68 65 20 66 69 s whether the fi
f0f0: 6c 65 20 65 78 69 73 74 73 2e 0a 2a 2a 20 57 69 le exists..** Wi
f100: 74 68 20 53 51 4c 49 54 45 5f 41 43 43 45 53 53 th SQLITE_ACCESS
f110: 5f 52 45 41 44 57 52 49 54 45 2c 20 74 68 65 20 _READWRITE, the
f120: 78 41 63 63 65 73 73 20 6d 65 74 68 6f 64 0a 2a xAccess method.*
f130: 2a 20 63 68 65 63 6b 73 20 77 68 65 74 68 65 72 * checks whether
f140: 20 74 68 65 20 6e 61 6d 65 64 20 64 69 72 65 63 the named direc
f150: 74 6f 72 79 20 69 73 20 62 6f 74 68 20 72 65 61 tory is both rea
f160: 64 61 62 6c 65 20 61 6e 64 20 77 72 69 74 61 62 dable and writab
f170: 6c 65 0a 2a 2a 20 28 69 6e 20 6f 74 68 65 72 20 le.** (in other
f180: 77 6f 72 64 73 2c 20 69 66 20 66 69 6c 65 73 20 words, if files
f190: 63 61 6e 20 62 65 20 61 64 64 65 64 2c 20 72 65 can be added, re
f1a0: 6d 6f 76 65 64 2c 20 61 6e 64 20 72 65 6e 61 6d moved, and renam
f1b0: 65 64 20 77 69 74 68 69 6e 0a 2a 2a 20 74 68 65 ed within.** the
f1c0: 20 64 69 72 65 63 74 6f 72 79 29 2e 0a 2a 2a 20 directory)..**
f1d0: 54 68 65 20 53 51 4c 49 54 45 5f 41 43 43 45 53 The SQLITE_ACCES
f1e0: 53 5f 52 45 41 44 57 52 49 54 45 20 63 6f 6e 73 S_READWRITE cons
f1f0: 74 61 6e 74 20 69 73 20 63 75 72 72 65 6e 74 6c tant is currentl
f200: 79 20 75 73 65 64 20 6f 6e 6c 79 20 62 79 20 74 y used only by t
f210: 68 65 0a 2a 2a 20 5b 74 65 6d 70 5f 73 74 6f 72 he.** [temp_stor
f220: 65 5f 64 69 72 65 63 74 6f 72 79 20 70 72 61 67 e_directory prag
f230: 6d 61 5d 2c 20 74 68 6f 75 67 68 20 74 68 69 73 ma], though this
f240: 20 63 6f 75 6c 64 20 63 68 61 6e 67 65 20 69 6e could change in
f250: 20 61 20 66 75 74 75 72 65 0a 2a 2a 20 72 65 6c a future.** rel
f260: 65 61 73 65 20 6f 66 20 53 51 4c 69 74 65 2e 0a ease of SQLite..
f270: 2a 2a 20 57 69 74 68 20 53 51 4c 49 54 45 5f 41 ** With SQLITE_A
f280: 43 43 45 53 53 5f 52 45 41 44 2c 20 74 68 65 20 CCESS_READ, the
f290: 78 41 63 63 65 73 73 20 6d 65 74 68 6f 64 0a 2a xAccess method.*
f2a0: 2a 20 63 68 65 63 6b 73 20 77 68 65 74 68 65 72 * checks whether
f2b0: 20 74 68 65 20 66 69 6c 65 20 69 73 20 72 65 61 the file is rea
f2c0: 64 61 62 6c 65 2e 20 20 54 68 65 20 53 51 4c 49 dable. The SQLI
f2d0: 54 45 5f 41 43 43 45 53 53 5f 52 45 41 44 20 63 TE_ACCESS_READ c
f2e0: 6f 6e 73 74 61 6e 74 20 69 73 0a 2a 2a 20 63 75 onstant is.** cu
f2f0: 72 72 65 6e 74 6c 79 20 75 6e 75 73 65 64 2c 20 rrently unused,
f300: 74 68 6f 75 67 68 20 69 74 20 6d 69 67 68 74 20 though it might
f310: 62 65 20 75 73 65 64 20 69 6e 20 61 20 66 75 74 be used in a fut
f320: 75 72 65 20 72 65 6c 65 61 73 65 20 6f 66 0a 2a ure release of.*
f330: 2a 20 53 51 4c 69 74 65 2e 0a 2a 2f 0a 23 64 65 * SQLite..*/.#de
f340: 66 69 6e 65 20 53 51 4c 49 54 45 5f 41 43 43 45 fine SQLITE_ACCE
f350: 53 53 5f 45 58 49 53 54 53 20 20 20 20 30 0a 23 SS_EXISTS 0.#
f360: 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 41 43 define SQLITE_AC
f370: 43 45 53 53 5f 52 45 41 44 57 52 49 54 45 20 31 CESS_READWRITE 1
f380: 20 20 20 2f 2a 20 55 73 65 64 20 62 79 20 50 52 /* Used by PR
f390: 41 47 4d 41 20 74 65 6d 70 5f 73 74 6f 72 65 5f AGMA temp_store_
f3a0: 64 69 72 65 63 74 6f 72 79 20 2a 2f 0a 23 64 65 directory */.#de
f3b0: 66 69 6e 65 20 53 51 4c 49 54 45 5f 41 43 43 45 fine SQLITE_ACCE
f3c0: 53 53 5f 52 45 41 44 20 20 20 20 20 20 32 20 20 SS_READ 2
f3d0: 20 2f 2a 20 55 6e 75 73 65 64 20 2a 2f 0a 0a 2f /* Unused */../
f3e0: 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 46 *.** CAPI3REF: F
f3f0: 6c 61 67 73 20 66 6f 72 20 74 68 65 20 78 53 68 lags for the xSh
f400: 6d 4c 6f 63 6b 20 56 46 53 20 6d 65 74 68 6f 64 mLock VFS method
f410: 0a 2a 2a 0a 2a 2a 20 54 68 65 73 65 20 69 6e 74 .**.** These int
f420: 65 67 65 72 20 63 6f 6e 73 74 61 6e 74 73 20 64 eger constants d
f430: 65 66 69 6e 65 20 74 68 65 20 76 61 72 69 6f 75 efine the variou
f440: 73 20 6c 6f 63 6b 69 6e 67 20 6f 70 65 72 61 74 s locking operat
f450: 69 6f 6e 73 0a 2a 2a 20 61 6c 6c 6f 77 65 64 20 ions.** allowed
f460: 62 79 20 74 68 65 20 78 53 68 6d 4c 6f 63 6b 20 by the xShmLock
f470: 6d 65 74 68 6f 64 20 6f 66 20 5b 73 71 6c 69 74 method of [sqlit
f480: 65 33 5f 69 6f 5f 6d 65 74 68 6f 64 73 5d 2e 20 e3_io_methods].
f490: 20 54 68 65 0a 2a 2a 20 66 6f 6c 6c 6f 77 69 6e The.** followin
f4a0: 67 20 61 72 65 20 74 68 65 20 6f 6e 6c 79 20 6c g are the only l
f4b0: 65 67 61 6c 20 63 6f 6d 62 69 6e 61 74 69 6f 6e egal combination
f4c0: 73 20 6f 66 20 66 6c 61 67 73 20 74 6f 20 74 68 s of flags to th
f4d0: 65 0a 2a 2a 20 78 53 68 6d 4c 6f 63 6b 20 6d 65 e.** xShmLock me
f4e0: 74 68 6f 64 3a 0a 2a 2a 0a 2a 2a 20 3c 75 6c 3e thod:.**.** <ul>
f4f0: 0a 2a 2a 20 3c 6c 69 3e 20 20 53 51 4c 49 54 45 .** <li> SQLITE
f500: 5f 53 48 4d 5f 4c 4f 43 4b 20 7c 20 53 51 4c 49 _SHM_LOCK | SQLI
f510: 54 45 5f 53 48 4d 5f 53 48 41 52 45 44 0a 2a 2a TE_SHM_SHARED.**
f520: 20 3c 6c 69 3e 20 20 53 51 4c 49 54 45 5f 53 48 <li> SQLITE_SH
f530: 4d 5f 4c 4f 43 4b 20 7c 20 53 51 4c 49 54 45 5f M_LOCK | SQLITE_
f540: 53 48 4d 5f 45 58 43 4c 55 53 49 56 45 0a 2a 2a SHM_EXCLUSIVE.**
f550: 20 3c 6c 69 3e 20 20 53 51 4c 49 54 45 5f 53 48 <li> SQLITE_SH
f560: 4d 5f 55 4e 4c 4f 43 4b 20 7c 20 53 51 4c 49 54 M_UNLOCK | SQLIT
f570: 45 5f 53 48 4d 5f 53 48 41 52 45 44 0a 2a 2a 20 E_SHM_SHARED.**
f580: 3c 6c 69 3e 20 20 53 51 4c 49 54 45 5f 53 48 4d <li> SQLITE_SHM
f590: 5f 55 4e 4c 4f 43 4b 20 7c 20 53 51 4c 49 54 45 _UNLOCK | SQLITE
f5a0: 5f 53 48 4d 5f 45 58 43 4c 55 53 49 56 45 0a 2a _SHM_EXCLUSIVE.*
f5b0: 2a 20 3c 2f 75 6c 3e 0a 2a 2a 0a 2a 2a 20 57 68 * </ul>.**.** Wh
f5c0: 65 6e 20 75 6e 6c 6f 63 6b 69 6e 67 2c 20 74 68 en unlocking, th
f5d0: 65 20 73 61 6d 65 20 53 48 41 52 45 44 20 6f 72 e same SHARED or
f5e0: 20 45 58 43 4c 55 53 49 56 45 20 66 6c 61 67 20 EXCLUSIVE flag
f5f0: 6d 75 73 74 20 62 65 20 73 75 70 70 6c 69 65 64 must be supplied
f600: 20 61 73 0a 2a 2a 20 77 61 73 20 67 69 76 65 6e as.** was given
f610: 20 6f 6e 20 74 68 65 20 63 6f 72 72 65 73 70 6f on the correspo
f620: 6e 64 69 6e 67 20 6c 6f 63 6b 2e 20 20 0a 2a 2a nding lock. .**
f630: 0a 2a 2a 20 54 68 65 20 78 53 68 6d 4c 6f 63 6b .** The xShmLock
f640: 20 6d 65 74 68 6f 64 20 63 61 6e 20 74 72 61 6e method can tran
f650: 73 69 74 69 6f 6e 20 62 65 74 77 65 65 6e 20 75 sition between u
f660: 6e 6c 6f 63 6b 65 64 20 61 6e 64 20 53 48 41 52 nlocked and SHAR
f670: 45 44 20 6f 72 0a 2a 2a 20 62 65 74 77 65 65 6e ED or.** between
f680: 20 75 6e 6c 6f 63 6b 65 64 20 61 6e 64 20 45 58 unlocked and EX
f690: 43 4c 55 53 49 56 45 2e 20 20 49 74 20 63 61 6e CLUSIVE. It can
f6a0: 6e 6f 74 20 74 72 61 6e 73 69 74 69 6f 6e 20 62 not transition b
f6b0: 65 74 77 65 65 6e 20 53 48 41 52 45 44 0a 2a 2a etween SHARED.**
f6c0: 20 61 6e 64 20 45 58 43 4c 55 53 49 56 45 2e 0a and EXCLUSIVE..
f6d0: 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 */.#define SQLIT
f6e0: 45 5f 53 48 4d 5f 55 4e 4c 4f 43 4b 20 20 20 20 E_SHM_UNLOCK
f6f0: 20 20 20 31 0a 23 64 65 66 69 6e 65 20 53 51 4c 1.#define SQL
f700: 49 54 45 5f 53 48 4d 5f 4c 4f 43 4b 20 20 20 20 ITE_SHM_LOCK
f710: 20 20 20 20 20 32 0a 23 64 65 66 69 6e 65 20 53 2.#define S
f720: 51 4c 49 54 45 5f 53 48 4d 5f 53 48 41 52 45 44 QLITE_SHM_SHARED
f730: 20 20 20 20 20 20 20 34 0a 23 64 65 66 69 6e 65 4.#define
f740: 20 53 51 4c 49 54 45 5f 53 48 4d 5f 45 58 43 4c SQLITE_SHM_EXCL
f750: 55 53 49 56 45 20 20 20 20 38 0a 0a 2f 2a 0a 2a USIVE 8../*.*
f760: 2a 20 43 41 50 49 33 52 45 46 3a 20 4d 61 78 69 * CAPI3REF: Maxi
f770: 6d 75 6d 20 78 53 68 6d 4c 6f 63 6b 20 69 6e 64 mum xShmLock ind
f780: 65 78 0a 2a 2a 0a 2a 2a 20 54 68 65 20 78 53 68 ex.**.** The xSh
f790: 6d 4c 6f 63 6b 20 6d 65 74 68 6f 64 20 6f 6e 20 mLock method on
f7a0: 5b 73 71 6c 69 74 65 33 5f 69 6f 5f 6d 65 74 68 [sqlite3_io_meth
f7b0: 6f 64 73 5d 20 6d 61 79 20 75 73 65 20 76 61 6c ods] may use val
f7c0: 75 65 73 0a 2a 2a 20 62 65 74 77 65 65 6e 20 30 ues.** between 0
f7d0: 20 61 6e 64 20 74 68 69 73 20 75 70 70 65 72 20 and this upper
f7e0: 62 6f 75 6e 64 20 61 73 20 69 74 73 20 22 6f 66 bound as its "of
f7f0: 66 73 65 74 22 20 61 72 67 75 6d 65 6e 74 2e 0a fset" argument..
f800: 2a 2a 20 54 68 65 20 53 51 4c 69 74 65 20 63 6f ** The SQLite co
f810: 72 65 20 77 69 6c 6c 20 6e 65 76 65 72 20 61 74 re will never at
f820: 74 65 6d 70 74 20 74 6f 20 61 63 71 75 69 72 65 tempt to acquire
f830: 20 6f 72 20 72 65 6c 65 61 73 65 20 61 0a 2a 2a or release a.**
f840: 20 6c 6f 63 6b 20 6f 75 74 73 69 64 65 20 6f 66 lock outside of
f850: 20 74 68 69 73 20 72 61 6e 67 65 0a 2a 2f 0a 23 this range.*/.#
f860: 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 53 48 define SQLITE_SH
f870: 4d 5f 4e 4c 4f 43 4b 20 20 20 20 20 20 20 20 38 M_NLOCK 8
f880: 0a 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 .../*.** CAPI3RE
f890: 46 3a 20 49 6e 69 74 69 61 6c 69 7a 65 20 54 68 F: Initialize Th
f8a0: 65 20 53 51 4c 69 74 65 20 4c 69 62 72 61 72 79 e SQLite Library
f8b0: 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 6c 69 .**.** ^The sqli
f8c0: 74 65 33 5f 69 6e 69 74 69 61 6c 69 7a 65 28 29 te3_initialize()
f8d0: 20 72 6f 75 74 69 6e 65 20 69 6e 69 74 69 61 6c routine initial
f8e0: 69 7a 65 73 20 74 68 65 0a 2a 2a 20 53 51 4c 69 izes the.** SQLi
f8f0: 74 65 20 6c 69 62 72 61 72 79 2e 20 20 5e 54 68 te library. ^Th
f900: 65 20 73 71 6c 69 74 65 33 5f 73 68 75 74 64 6f e sqlite3_shutdo
f910: 77 6e 28 29 20 72 6f 75 74 69 6e 65 0a 2a 2a 20 wn() routine.**
f920: 64 65 61 6c 6c 6f 63 61 74 65 73 20 61 6e 79 20 deallocates any
f930: 72 65 73 6f 75 72 63 65 73 20 74 68 61 74 20 77 resources that w
f940: 65 72 65 20 61 6c 6c 6f 63 61 74 65 64 20 62 79 ere allocated by
f950: 20 73 71 6c 69 74 65 33 5f 69 6e 69 74 69 61 6c sqlite3_initial
f960: 69 7a 65 28 29 2e 0a 2a 2a 20 54 68 65 73 65 20 ize()..** These
f970: 72 6f 75 74 69 6e 65 73 20 61 72 65 20 64 65 73 routines are des
f980: 69 67 6e 65 64 20 74 6f 20 61 69 64 20 69 6e 20 igned to aid in
f990: 70 72 6f 63 65 73 73 20 69 6e 69 74 69 61 6c 69 process initiali
f9a0: 7a 61 74 69 6f 6e 20 61 6e 64 0a 2a 2a 20 73 68 zation and.** sh
f9b0: 75 74 64 6f 77 6e 20 6f 6e 20 65 6d 62 65 64 64 utdown on embedd
f9c0: 65 64 20 73 79 73 74 65 6d 73 2e 20 20 57 6f 72 ed systems. Wor
f9d0: 6b 73 74 61 74 69 6f 6e 20 61 70 70 6c 69 63 61 kstation applica
f9e0: 74 69 6f 6e 73 20 75 73 69 6e 67 0a 2a 2a 20 53 tions using.** S
f9f0: 51 4c 69 74 65 20 6e 6f 72 6d 61 6c 6c 79 20 64 QLite normally d
fa00: 6f 20 6e 6f 74 20 6e 65 65 64 20 74 6f 20 69 6e o not need to in
fa10: 76 6f 6b 65 20 65 69 74 68 65 72 20 6f 66 20 74 voke either of t
fa20: 68 65 73 65 20 72 6f 75 74 69 6e 65 73 2e 0a 2a hese routines..*
fa30: 2a 0a 2a 2a 20 41 20 63 61 6c 6c 20 74 6f 20 73 *.** A call to s
fa40: 71 6c 69 74 65 33 5f 69 6e 69 74 69 61 6c 69 7a qlite3_initializ
fa50: 65 28 29 20 69 73 20 61 6e 20 22 65 66 66 65 63 e() is an "effec
fa60: 74 69 76 65 22 20 63 61 6c 6c 20 69 66 20 69 74 tive" call if it
fa70: 20 69 73 0a 2a 2a 20 74 68 65 20 66 69 72 73 74 is.** the first
fa80: 20 74 69 6d 65 20 73 71 6c 69 74 65 33 5f 69 6e time sqlite3_in
fa90: 69 74 69 61 6c 69 7a 65 28 29 20 69 73 20 69 6e itialize() is in
faa0: 76 6f 6b 65 64 20 64 75 72 69 6e 67 20 74 68 65 voked during the
fab0: 20 6c 69 66 65 74 69 6d 65 20 6f 66 0a 2a 2a 20 lifetime of.**
fac0: 74 68 65 20 70 72 6f 63 65 73 73 2c 20 6f 72 20 the process, or
fad0: 69 66 20 69 74 20 69 73 20 74 68 65 20 66 69 72 if it is the fir
fae0: 73 74 20 74 69 6d 65 20 73 71 6c 69 74 65 33 5f st time sqlite3_
faf0: 69 6e 69 74 69 61 6c 69 7a 65 28 29 20 69 73 20 initialize() is
fb00: 69 6e 76 6f 6b 65 64 0a 2a 2a 20 66 6f 6c 6c 6f invoked.** follo
fb10: 77 69 6e 67 20 61 20 63 61 6c 6c 20 74 6f 20 73 wing a call to s
fb20: 71 6c 69 74 65 33 5f 73 68 75 74 64 6f 77 6e 28 qlite3_shutdown(
fb30: 29 2e 20 20 5e 28 4f 6e 6c 79 20 61 6e 20 65 66 ). ^(Only an ef
fb40: 66 65 63 74 69 76 65 20 63 61 6c 6c 0a 2a 2a 20 fective call.**
fb50: 6f 66 20 73 71 6c 69 74 65 33 5f 69 6e 69 74 69 of sqlite3_initi
fb60: 61 6c 69 7a 65 28 29 20 64 6f 65 73 20 61 6e 79 alize() does any
fb70: 20 69 6e 69 74 69 61 6c 69 7a 61 74 69 6f 6e 2e initialization.
fb80: 20 20 41 6c 6c 20 6f 74 68 65 72 20 63 61 6c 6c All other call
fb90: 73 0a 2a 2a 20 61 72 65 20 68 61 72 6d 6c 65 73 s.** are harmles
fba0: 73 20 6e 6f 2d 6f 70 73 2e 29 5e 0a 2a 2a 0a 2a s no-ops.)^.**.*
fbb0: 2a 20 41 20 63 61 6c 6c 20 74 6f 20 73 71 6c 69 * A call to sqli
fbc0: 74 65 33 5f 73 68 75 74 64 6f 77 6e 28 29 20 69 te3_shutdown() i
fbd0: 73 20 61 6e 20 22 65 66 66 65 63 74 69 76 65 22 s an "effective"
fbe0: 20 63 61 6c 6c 20 69 66 20 69 74 20 69 73 20 74 call if it is t
fbf0: 68 65 20 66 69 72 73 74 0a 2a 2a 20 63 61 6c 6c he first.** call
fc00: 20 74 6f 20 73 71 6c 69 74 65 33 5f 73 68 75 74 to sqlite3_shut
fc10: 64 6f 77 6e 28 29 20 73 69 6e 63 65 20 74 68 65 down() since the
fc20: 20 6c 61 73 74 20 73 71 6c 69 74 65 33 5f 69 6e last sqlite3_in
fc30: 69 74 69 61 6c 69 7a 65 28 29 2e 20 20 5e 28 4f itialize(). ^(O
fc40: 6e 6c 79 0a 2a 2a 20 61 6e 20 65 66 66 65 63 74 nly.** an effect
fc50: 69 76 65 20 63 61 6c 6c 20 74 6f 20 73 71 6c 69 ive call to sqli
fc60: 74 65 33 5f 73 68 75 74 64 6f 77 6e 28 29 20 64 te3_shutdown() d
fc70: 6f 65 73 20 61 6e 79 20 64 65 69 6e 69 74 69 61 oes any deinitia
fc80: 6c 69 7a 61 74 69 6f 6e 2e 0a 2a 2a 20 41 6c 6c lization..** All
fc90: 20 6f 74 68 65 72 20 76 61 6c 69 64 20 63 61 6c other valid cal
fca0: 6c 73 20 74 6f 20 73 71 6c 69 74 65 33 5f 73 68 ls to sqlite3_sh
fcb0: 75 74 64 6f 77 6e 28 29 20 61 72 65 20 68 61 72 utdown() are har
fcc0: 6d 6c 65 73 73 20 6e 6f 2d 6f 70 73 2e 29 5e 0a mless no-ops.)^.
fcd0: 2a 2a 0a 2a 2a 20 54 68 65 20 73 71 6c 69 74 65 **.** The sqlite
fce0: 33 5f 69 6e 69 74 69 61 6c 69 7a 65 28 29 20 69 3_initialize() i
fcf0: 6e 74 65 72 66 61 63 65 20 69 73 20 74 68 72 65 nterface is thre
fd00: 61 64 73 61 66 65 2c 20 62 75 74 20 73 71 6c 69 adsafe, but sqli
fd10: 74 65 33 5f 73 68 75 74 64 6f 77 6e 28 29 0a 2a te3_shutdown().*
fd20: 2a 20 69 73 20 6e 6f 74 2e 20 20 54 68 65 20 73 * is not. The s
fd30: 71 6c 69 74 65 33 5f 73 68 75 74 64 6f 77 6e 28 qlite3_shutdown(
fd40: 29 20 69 6e 74 65 72 66 61 63 65 20 6d 75 73 74 ) interface must
fd50: 20 6f 6e 6c 79 20 62 65 20 63 61 6c 6c 65 64 20 only be called
fd60: 66 72 6f 6d 20 61 0a 2a 2a 20 73 69 6e 67 6c 65 from a.** single
fd70: 20 74 68 72 65 61 64 2e 20 20 41 6c 6c 20 6f 70 thread. All op
fd80: 65 6e 20 5b 64 61 74 61 62 61 73 65 20 63 6f 6e en [database con
fd90: 6e 65 63 74 69 6f 6e 73 5d 20 6d 75 73 74 20 62 nections] must b
fda0: 65 20 63 6c 6f 73 65 64 20 61 6e 64 20 61 6c 6c e closed and all
fdb0: 0a 2a 2a 20 6f 74 68 65 72 20 53 51 4c 69 74 65 .** other SQLite
fdc0: 20 72 65 73 6f 75 72 63 65 73 20 6d 75 73 74 20 resources must
fdd0: 62 65 20 64 65 61 6c 6c 6f 63 61 74 65 64 20 70 be deallocated p
fde0: 72 69 6f 72 20 74 6f 20 69 6e 76 6f 6b 69 6e 67 rior to invoking
fdf0: 0a 2a 2a 20 73 71 6c 69 74 65 33 5f 73 68 75 74 .** sqlite3_shut
fe00: 64 6f 77 6e 28 29 2e 0a 2a 2a 0a 2a 2a 20 41 6d down()..**.** Am
fe10: 6f 6e 67 20 6f 74 68 65 72 20 74 68 69 6e 67 73 ong other things
fe20: 2c 20 5e 73 71 6c 69 74 65 33 5f 69 6e 69 74 69 , ^sqlite3_initi
fe30: 61 6c 69 7a 65 28 29 20 77 69 6c 6c 20 69 6e 76 alize() will inv
fe40: 6f 6b 65 0a 2a 2a 20 73 71 6c 69 74 65 33 5f 6f oke.** sqlite3_o
fe50: 73 5f 69 6e 69 74 28 29 2e 20 20 53 69 6d 69 6c s_init(). Simil
fe60: 61 72 6c 79 2c 20 5e 73 71 6c 69 74 65 33 5f 73 arly, ^sqlite3_s
fe70: 68 75 74 64 6f 77 6e 28 29 0a 2a 2a 20 77 69 6c hutdown().** wil
fe80: 6c 20 69 6e 76 6f 6b 65 20 73 71 6c 69 74 65 33 l invoke sqlite3
fe90: 5f 6f 73 5f 65 6e 64 28 29 2e 0a 2a 2a 0a 2a 2a _os_end()..**.**
fea0: 20 5e 54 68 65 20 73 71 6c 69 74 65 33 5f 69 6e ^The sqlite3_in
feb0: 69 74 69 61 6c 69 7a 65 28 29 20 72 6f 75 74 69 itialize() routi
fec0: 6e 65 20 72 65 74 75 72 6e 73 20 5b 53 51 4c 49 ne returns [SQLI
fed0: 54 45 5f 4f 4b 5d 20 6f 6e 20 73 75 63 63 65 73 TE_OK] on succes
fee0: 73 2e 0a 2a 2a 20 5e 49 66 20 66 6f 72 20 73 6f s..** ^If for so
fef0: 6d 65 20 72 65 61 73 6f 6e 2c 20 73 71 6c 69 74 me reason, sqlit
ff00: 65 33 5f 69 6e 69 74 69 61 6c 69 7a 65 28 29 20 e3_initialize()
ff10: 69 73 20 75 6e 61 62 6c 65 20 74 6f 20 69 6e 69 is unable to ini
ff20: 74 69 61 6c 69 7a 65 0a 2a 2a 20 74 68 65 20 6c tialize.** the l
ff30: 69 62 72 61 72 79 20 28 70 65 72 68 61 70 73 20 ibrary (perhaps
ff40: 69 74 20 69 73 20 75 6e 61 62 6c 65 20 74 6f 20 it is unable to
ff50: 61 6c 6c 6f 63 61 74 65 20 61 20 6e 65 65 64 65 allocate a neede
ff60: 64 20 72 65 73 6f 75 72 63 65 20 73 75 63 68 0a d resource such.
ff70: 2a 2a 20 61 73 20 61 20 6d 75 74 65 78 29 20 69 ** as a mutex) i
ff80: 74 20 72 65 74 75 72 6e 73 20 61 6e 20 5b 65 72 t returns an [er
ff90: 72 6f 72 20 63 6f 64 65 5d 20 6f 74 68 65 72 20 ror code] other
ffa0: 74 68 61 6e 20 5b 53 51 4c 49 54 45 5f 4f 4b 5d than [SQLITE_OK]
ffb0: 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 6c ..**.** ^The sql
ffc0: 69 74 65 33 5f 69 6e 69 74 69 61 6c 69 7a 65 28 ite3_initialize(
ffd0: 29 20 72 6f 75 74 69 6e 65 20 69 73 20 63 61 6c ) routine is cal
ffe0: 6c 65 64 20 69 6e 74 65 72 6e 61 6c 6c 79 20 62 led internally b
fff0: 79 20 6d 61 6e 79 20 6f 74 68 65 72 0a 2a 2a 20 y many other.**
10000 53 51 4c 69 74 65 20 69 6e 74 65 72 66 61 63 65 SQLite interface
10010 73 20 73 6f 20 74 68 61 74 20 61 6e 20 61 70 70 s so that an app
10020 6c 69 63 61 74 69 6f 6e 20 75 73 75 61 6c 6c 79 lication usually
10030 20 64 6f 65 73 20 6e 6f 74 20 6e 65 65 64 20 74 does not need t
10040 6f 0a 2a 2a 20 69 6e 76 6f 6b 65 20 73 71 6c 69 o.** invoke sqli
10050 74 65 33 5f 69 6e 69 74 69 61 6c 69 7a 65 28 29 te3_initialize()
10060 20 64 69 72 65 63 74 6c 79 2e 20 20 46 6f 72 20 directly. For
10070 65 78 61 6d 70 6c 65 2c 20 5b 73 71 6c 69 74 65 example, [sqlite
10080 33 5f 6f 70 65 6e 28 29 5d 0a 2a 2a 20 63 61 6c 3_open()].** cal
10090 6c 73 20 73 71 6c 69 74 65 33 5f 69 6e 69 74 69 ls sqlite3_initi
100a0 61 6c 69 7a 65 28 29 20 73 6f 20 74 68 65 20 53 alize() so the S
100b0 51 4c 69 74 65 20 6c 69 62 72 61 72 79 20 77 69 QLite library wi
100c0 6c 6c 20 62 65 20 61 75 74 6f 6d 61 74 69 63 61 ll be automatica
100d0 6c 6c 79 0a 2a 2a 20 69 6e 69 74 69 61 6c 69 7a lly.** initializ
100e0 65 64 20 77 68 65 6e 20 5b 73 71 6c 69 74 65 33 ed when [sqlite3
100f0 5f 6f 70 65 6e 28 29 5d 20 69 73 20 63 61 6c 6c _open()] is call
10100 65 64 20 69 66 20 69 74 20 68 61 73 20 6e 6f 74 ed if it has not
10110 20 62 65 20 69 6e 69 74 69 61 6c 69 7a 65 64 0a be initialized.
10120 2a 2a 20 61 6c 72 65 61 64 79 2e 20 20 5e 48 6f ** already. ^Ho
10130 77 65 76 65 72 2c 20 69 66 20 53 51 4c 69 74 65 wever, if SQLite
10140 20 69 73 20 63 6f 6d 70 69 6c 65 64 20 77 69 74 is compiled wit
10150 68 20 74 68 65 20 5b 53 51 4c 49 54 45 5f 4f 4d h the [SQLITE_OM
10160 49 54 5f 41 55 54 4f 49 4e 49 54 5d 0a 2a 2a 20 IT_AUTOINIT].**
10170 63 6f 6d 70 69 6c 65 2d 74 69 6d 65 20 6f 70 74 compile-time opt
10180 69 6f 6e 2c 20 74 68 65 6e 20 74 68 65 20 61 75 ion, then the au
10190 74 6f 6d 61 74 69 63 20 63 61 6c 6c 73 20 74 6f tomatic calls to
101a0 20 73 71 6c 69 74 65 33 5f 69 6e 69 74 69 61 6c sqlite3_initial
101b0 69 7a 65 28 29 0a 2a 2a 20 61 72 65 20 6f 6d 69 ize().** are omi
101c0 74 74 65 64 20 61 6e 64 20 74 68 65 20 61 70 70 tted and the app
101d0 6c 69 63 61 74 69 6f 6e 20 6d 75 73 74 20 63 61 lication must ca
101e0 6c 6c 20 73 71 6c 69 74 65 33 5f 69 6e 69 74 69 ll sqlite3_initi
101f0 61 6c 69 7a 65 28 29 20 64 69 72 65 63 74 6c 79 alize() directly
10200 0a 2a 2a 20 70 72 69 6f 72 20 74 6f 20 75 73 69 .** prior to usi
10210 6e 67 20 61 6e 79 20 6f 74 68 65 72 20 53 51 4c ng any other SQL
10220 69 74 65 20 69 6e 74 65 72 66 61 63 65 2e 20 20 ite interface.
10230 46 6f 72 20 6d 61 78 69 6d 75 6d 20 70 6f 72 74 For maximum port
10240 61 62 69 6c 69 74 79 2c 0a 2a 2a 20 69 74 20 69 ability,.** it i
10250 73 20 72 65 63 6f 6d 6d 65 6e 64 65 64 20 74 68 s recommended th
10260 61 74 20 61 70 70 6c 69 63 61 74 69 6f 6e 73 20 at applications
10270 61 6c 77 61 79 73 20 69 6e 76 6f 6b 65 20 73 71 always invoke sq
10280 6c 69 74 65 33 5f 69 6e 69 74 69 61 6c 69 7a 65 lite3_initialize
10290 28 29 0a 2a 2a 20 64 69 72 65 63 74 6c 79 20 70 ().** directly p
102a0 72 69 6f 72 20 74 6f 20 75 73 69 6e 67 20 61 6e rior to using an
102b0 79 20 6f 74 68 65 72 20 53 51 4c 69 74 65 20 69 y other SQLite i
102c0 6e 74 65 72 66 61 63 65 2e 20 20 46 75 74 75 72 nterface. Futur
102d0 65 20 72 65 6c 65 61 73 65 73 0a 2a 2a 20 6f 66 e releases.** of
102e0 20 53 51 4c 69 74 65 20 6d 61 79 20 72 65 71 75 SQLite may requ
102f0 69 72 65 20 74 68 69 73 2e 20 20 49 6e 20 6f 74 ire this. In ot
10300 68 65 72 20 77 6f 72 64 73 2c 20 74 68 65 20 62 her words, the b
10310 65 68 61 76 69 6f 72 20 65 78 68 69 62 69 74 65 ehavior exhibite
10320 64 0a 2a 2a 20 77 68 65 6e 20 53 51 4c 69 74 65 d.** when SQLite
10330 20 69 73 20 63 6f 6d 70 69 6c 65 64 20 77 69 74 is compiled wit
10340 68 20 5b 53 51 4c 49 54 45 5f 4f 4d 49 54 5f 41 h [SQLITE_OMIT_A
10350 55 54 4f 49 4e 49 54 5d 20 6d 69 67 68 74 20 62 UTOINIT] might b
10360 65 63 6f 6d 65 20 74 68 65 0a 2a 2a 20 64 65 66 ecome the.** def
10370 61 75 6c 74 20 62 65 68 61 76 69 6f 72 20 69 6e ault behavior in
10380 20 73 6f 6d 65 20 66 75 74 75 72 65 20 72 65 6c some future rel
10390 65 61 73 65 20 6f 66 20 53 51 4c 69 74 65 2e 0a ease of SQLite..
103a0 2a 2a 0a 2a 2a 20 54 68 65 20 73 71 6c 69 74 65 **.** The sqlite
103b0 33 5f 6f 73 5f 69 6e 69 74 28 29 20 72 6f 75 74 3_os_init() rout
103c0 69 6e 65 20 64 6f 65 73 20 6f 70 65 72 61 74 69 ine does operati
103d0 6e 67 2d 73 79 73 74 65 6d 20 73 70 65 63 69 66 ng-system specif
103e0 69 63 0a 2a 2a 20 69 6e 69 74 69 61 6c 69 7a 61 ic.** initializa
103f0 74 69 6f 6e 20 6f 66 20 74 68 65 20 53 51 4c 69 tion of the SQLi
10400 74 65 20 6c 69 62 72 61 72 79 2e 20 20 54 68 65 te library. The
10410 20 73 71 6c 69 74 65 33 5f 6f 73 5f 65 6e 64 28 sqlite3_os_end(
10420 29 0a 2a 2a 20 72 6f 75 74 69 6e 65 20 75 6e 64 ).** routine und
10430 6f 65 73 20 74 68 65 20 65 66 66 65 63 74 20 6f oes the effect o
10440 66 20 73 71 6c 69 74 65 33 5f 6f 73 5f 69 6e 69 f sqlite3_os_ini
10450 74 28 29 2e 20 20 54 79 70 69 63 61 6c 20 74 61 t(). Typical ta
10460 73 6b 73 0a 2a 2a 20 70 65 72 66 6f 72 6d 65 64 sks.** performed
10470 20 62 79 20 74 68 65 73 65 20 72 6f 75 74 69 6e by these routin
10480 65 73 20 69 6e 63 6c 75 64 65 20 61 6c 6c 6f 63 es include alloc
10490 61 74 69 6f 6e 20 6f 72 20 64 65 61 6c 6c 6f 63 ation or dealloc
104a0 61 74 69 6f 6e 0a 2a 2a 20 6f 66 20 73 74 61 74 ation.** of stat
104b0 69 63 20 72 65 73 6f 75 72 63 65 73 2c 20 69 6e ic resources, in
104c0 69 74 69 61 6c 69 7a 61 74 69 6f 6e 20 6f 66 20 itialization of
104d0 67 6c 6f 62 61 6c 20 76 61 72 69 61 62 6c 65 73 global variables
104e0 2c 0a 2a 2a 20 73 65 74 74 69 6e 67 20 75 70 20 ,.** setting up
104f0 61 20 64 65 66 61 75 6c 74 20 5b 73 71 6c 69 74 a default [sqlit
10500 65 33 5f 76 66 73 5d 20 6d 6f 64 75 6c 65 2c 20 e3_vfs] module,
10510 6f 72 20 73 65 74 74 69 6e 67 20 75 70 0a 2a 2a or setting up.**
10520 20 61 20 64 65 66 61 75 6c 74 20 63 6f 6e 66 69 a default confi
10530 67 75 72 61 74 69 6f 6e 20 75 73 69 6e 67 20 5b guration using [
10540 73 71 6c 69 74 65 33 5f 63 6f 6e 66 69 67 28 29 sqlite3_config()
10550 5d 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 61 70 70 ]..**.** The app
10560 6c 69 63 61 74 69 6f 6e 20 73 68 6f 75 6c 64 20 lication should
10570 6e 65 76 65 72 20 69 6e 76 6f 6b 65 20 65 69 74 never invoke eit
10580 68 65 72 20 73 71 6c 69 74 65 33 5f 6f 73 5f 69 her sqlite3_os_i
10590 6e 69 74 28 29 0a 2a 2a 20 6f 72 20 73 71 6c 69 nit().** or sqli
105a0 74 65 33 5f 6f 73 5f 65 6e 64 28 29 20 64 69 72 te3_os_end() dir
105b0 65 63 74 6c 79 2e 20 20 54 68 65 20 61 70 70 6c ectly. The appl
105c0 69 63 61 74 69 6f 6e 20 73 68 6f 75 6c 64 20 6f ication should o
105d0 6e 6c 79 20 69 6e 76 6f 6b 65 0a 2a 2a 20 73 71 nly invoke.** sq
105e0 6c 69 74 65 33 5f 69 6e 69 74 69 61 6c 69 7a 65 lite3_initialize
105f0 28 29 20 61 6e 64 20 73 71 6c 69 74 65 33 5f 73 () and sqlite3_s
10600 68 75 74 64 6f 77 6e 28 29 2e 20 20 54 68 65 20 hutdown(). The
10610 73 71 6c 69 74 65 33 5f 6f 73 5f 69 6e 69 74 28 sqlite3_os_init(
10620 29 0a 2a 2a 20 69 6e 74 65 72 66 61 63 65 20 69 ).** interface i
10630 73 20 63 61 6c 6c 65 64 20 61 75 74 6f 6d 61 74 s called automat
10640 69 63 61 6c 6c 79 20 62 79 20 73 71 6c 69 74 65 ically by sqlite
10650 33 5f 69 6e 69 74 69 61 6c 69 7a 65 28 29 20 61 3_initialize() a
10660 6e 64 0a 2a 2a 20 73 71 6c 69 74 65 33 5f 6f 73 nd.** sqlite3_os
10670 5f 65 6e 64 28 29 20 69 73 20 63 61 6c 6c 65 64 _end() is called
10680 20 62 79 20 73 71 6c 69 74 65 33 5f 73 68 75 74 by sqlite3_shut
10690 64 6f 77 6e 28 29 2e 20 20 41 70 70 72 6f 70 72 down(). Appropr
106a0 69 61 74 65 0a 2a 2a 20 69 6d 70 6c 65 6d 65 6e iate.** implemen
106b0 74 61 74 69 6f 6e 73 20 66 6f 72 20 73 71 6c 69 tations for sqli
106c0 74 65 33 5f 6f 73 5f 69 6e 69 74 28 29 20 61 6e te3_os_init() an
106d0 64 20 73 71 6c 69 74 65 33 5f 6f 73 5f 65 6e 64 d sqlite3_os_end
106e0 28 29 0a 2a 2a 20 61 72 65 20 62 75 69 6c 74 20 ().** are built
106f0 69 6e 74 6f 20 53 51 4c 69 74 65 20 77 68 65 6e into SQLite when
10700 20 69 74 20 69 73 20 63 6f 6d 70 69 6c 65 64 20 it is compiled
10710 66 6f 72 20 55 6e 69 78 2c 20 57 69 6e 64 6f 77 for Unix, Window
10720 73 2c 20 6f 72 20 4f 53 2f 32 2e 0a 2a 2a 20 57 s, or OS/2..** W
10730 68 65 6e 20 5b 63 75 73 74 6f 6d 20 62 75 69 6c hen [custom buil
10740 64 73 20 7c 20 62 75 69 6c 74 20 66 6f 72 20 6f ds | built for o
10750 74 68 65 72 20 70 6c 61 74 66 6f 72 6d 73 5d 0a ther platforms].
10760 2a 2a 20 28 75 73 69 6e 67 20 74 68 65 20 5b 53 ** (using the [S
10770 51 4c 49 54 45 5f 4f 53 5f 4f 54 48 45 52 3d 31 QLITE_OS_OTHER=1
10780 5d 20 63 6f 6d 70 69 6c 65 2d 74 69 6d 65 0a 2a ] compile-time.*
10790 2a 20 6f 70 74 69 6f 6e 29 20 74 68 65 20 61 70 * option) the ap
107a0 70 6c 69 63 61 74 69 6f 6e 20 6d 75 73 74 20 73 plication must s
107b0 75 70 70 6c 79 20 61 20 73 75 69 74 61 62 6c 65 upply a suitable
107c0 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 implementation
107d0 66 6f 72 0a 2a 2a 20 73 71 6c 69 74 65 33 5f 6f for.** sqlite3_o
107e0 73 5f 69 6e 69 74 28 29 20 61 6e 64 20 73 71 6c s_init() and sql
107f0 69 74 65 33 5f 6f 73 5f 65 6e 64 28 29 2e 20 20 ite3_os_end().
10800 41 6e 20 61 70 70 6c 69 63 61 74 69 6f 6e 2d 73 An application-s
10810 75 70 70 6c 69 65 64 0a 2a 2a 20 69 6d 70 6c 65 upplied.** imple
10820 6d 65 6e 74 61 74 69 6f 6e 20 6f 66 20 73 71 6c mentation of sql
10830 69 74 65 33 5f 6f 73 5f 69 6e 69 74 28 29 20 6f ite3_os_init() o
10840 72 20 73 71 6c 69 74 65 33 5f 6f 73 5f 65 6e 64 r sqlite3_os_end
10850 28 29 0a 2a 2a 20 6d 75 73 74 20 72 65 74 75 72 ().** must retur
10860 6e 20 5b 53 51 4c 49 54 45 5f 4f 4b 5d 20 6f 6e n [SQLITE_OK] on
10870 20 73 75 63 63 65 73 73 20 61 6e 64 20 73 6f 6d success and som
10880 65 20 6f 74 68 65 72 20 5b 65 72 72 6f 72 20 63 e other [error c
10890 6f 64 65 5d 20 75 70 6f 6e 0a 2a 2a 20 66 61 69 ode] upon.** fai
108a0 6c 75 72 65 2e 0a 2a 2f 0a 69 6e 74 20 73 71 6c lure..*/.int sql
108b0 69 74 65 33 5f 69 6e 69 74 69 61 6c 69 7a 65 28 ite3_initialize(
108c0 76 6f 69 64 29 3b 0a 69 6e 74 20 73 71 6c 69 74 void);.int sqlit
108d0 65 33 5f 73 68 75 74 64 6f 77 6e 28 76 6f 69 64 e3_shutdown(void
108e0 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f 6f );.int sqlite3_o
108f0 73 5f 69 6e 69 74 28 76 6f 69 64 29 3b 0a 69 6e s_init(void);.in
10900 74 20 73 71 6c 69 74 65 33 5f 6f 73 5f 65 6e 64 t sqlite3_os_end
10910 28 76 6f 69 64 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 (void);../*.** C
10920 41 50 49 33 52 45 46 3a 20 43 6f 6e 66 69 67 75 API3REF: Configu
10930 72 69 6e 67 20 54 68 65 20 53 51 4c 69 74 65 20 ring The SQLite
10940 4c 69 62 72 61 72 79 0a 2a 2a 0a 2a 2a 20 54 68 Library.**.** Th
10950 65 20 73 71 6c 69 74 65 33 5f 63 6f 6e 66 69 67 e sqlite3_config
10960 28 29 20 69 6e 74 65 72 66 61 63 65 20 69 73 20 () interface is
10970 75 73 65 64 20 74 6f 20 6d 61 6b 65 20 67 6c 6f used to make glo
10980 62 61 6c 20 63 6f 6e 66 69 67 75 72 61 74 69 6f bal configuratio
10990 6e 0a 2a 2a 20 63 68 61 6e 67 65 73 20 74 6f 20 n.** changes to
109a0 53 51 4c 69 74 65 20 69 6e 20 6f 72 64 65 72 20 SQLite in order
109b0 74 6f 20 74 75 6e 65 20 53 51 4c 69 74 65 20 74 to tune SQLite t
109c0 6f 20 74 68 65 20 73 70 65 63 69 66 69 63 20 6e o the specific n
109d0 65 65 64 73 20 6f 66 0a 2a 2a 20 74 68 65 20 61 eeds of.** the a
109e0 70 70 6c 69 63 61 74 69 6f 6e 2e 20 20 54 68 65 pplication. The
109f0 20 64 65 66 61 75 6c 74 20 63 6f 6e 66 69 67 75 default configu
10a00 72 61 74 69 6f 6e 20 69 73 20 72 65 63 6f 6d 6d ration is recomm
10a10 65 6e 64 65 64 20 66 6f 72 20 6d 6f 73 74 0a 2a ended for most.*
10a20 2a 20 61 70 70 6c 69 63 61 74 69 6f 6e 73 20 61 * applications a
10a30 6e 64 20 73 6f 20 74 68 69 73 20 72 6f 75 74 69 nd so this routi
10a40 6e 65 20 69 73 20 75 73 75 61 6c 6c 79 20 6e 6f ne is usually no
10a50 74 20 6e 65 63 65 73 73 61 72 79 2e 20 20 49 74 t necessary. It
10a60 20 69 73 0a 2a 2a 20 70 72 6f 76 69 64 65 64 20 is.** provided
10a70 74 6f 20 73 75 70 70 6f 72 74 20 72 61 72 65 20 to support rare
10a80 61 70 70 6c 69 63 61 74 69 6f 6e 73 20 77 69 74 applications wit
10a90 68 20 75 6e 75 73 75 61 6c 20 6e 65 65 64 73 2e h unusual needs.
10aa0 0a 2a 2a 0a 2a 2a 20 3c 62 3e 54 68 65 20 73 71 .**.** <b>The sq
10ab0 6c 69 74 65 33 5f 63 6f 6e 66 69 67 28 29 20 69 lite3_config() i
10ac0 6e 74 65 72 66 61 63 65 20 69 73 20 6e 6f 74 20 nterface is not
10ad0 74 68 72 65 61 64 73 61 66 65 2e 20 54 68 65 20 threadsafe. The
10ae0 61 70 70 6c 69 63 61 74 69 6f 6e 0a 2a 2a 20 6d application.** m
10af0 75 73 74 20 65 6e 73 75 72 65 20 74 68 61 74 20 ust ensure that
10b00 6e 6f 20 6f 74 68 65 72 20 53 51 4c 69 74 65 20 no other SQLite
10b10 69 6e 74 65 72 66 61 63 65 73 20 61 72 65 20 69 interfaces are i
10b20 6e 76 6f 6b 65 64 20 62 79 20 6f 74 68 65 72 0a nvoked by other.
10b30 2a 2a 20 74 68 72 65 61 64 73 20 77 68 69 6c 65 ** threads while
10b40 20 73 71 6c 69 74 65 33 5f 63 6f 6e 66 69 67 28 sqlite3_config(
10b50 29 20 69 73 20 72 75 6e 6e 69 6e 67 2e 3c 2f 62 ) is running.</b
10b60 3e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 73 71 6c 69 >.**.** The sqli
10b70 74 65 33 5f 63 6f 6e 66 69 67 28 29 20 69 6e 74 te3_config() int
10b80 65 72 66 61 63 65 0a 2a 2a 20 6d 61 79 20 6f 6e erface.** may on
10b90 6c 79 20 62 65 20 69 6e 76 6f 6b 65 64 20 70 72 ly be invoked pr
10ba0 69 6f 72 20 74 6f 20 6c 69 62 72 61 72 79 20 69 ior to library i
10bb0 6e 69 74 69 61 6c 69 7a 61 74 69 6f 6e 20 75 73 nitialization us
10bc0 69 6e 67 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f ing.** [sqlite3_
10bd0 69 6e 69 74 69 61 6c 69 7a 65 28 29 5d 20 6f 72 initialize()] or
10be0 20 61 66 74 65 72 20 73 68 75 74 64 6f 77 6e 20 after shutdown
10bf0 62 79 20 5b 73 71 6c 69 74 65 33 5f 73 68 75 74 by [sqlite3_shut
10c00 64 6f 77 6e 28 29 5d 2e 0a 2a 2a 20 5e 49 66 20 down()]..** ^If
10c10 73 71 6c 69 74 65 33 5f 63 6f 6e 66 69 67 28 29 sqlite3_config()
10c20 20 69 73 20 63 61 6c 6c 65 64 20 61 66 74 65 72 is called after
10c30 20 5b 73 71 6c 69 74 65 33 5f 69 6e 69 74 69 61 [sqlite3_initia
10c40 6c 69 7a 65 28 29 5d 20 61 6e 64 20 62 65 66 6f lize()] and befo
10c50 72 65 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 73 re.** [sqlite3_s
10c60 68 75 74 64 6f 77 6e 28 29 5d 20 74 68 65 6e 20 hutdown()] then
10c70 69 74 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 53 it will return S
10c80 51 4c 49 54 45 5f 4d 49 53 55 53 45 2e 0a 2a 2a QLITE_MISUSE..**
10c90 20 4e 6f 74 65 2c 20 68 6f 77 65 76 65 72 2c 20 Note, however,
10ca0 74 68 61 74 20 5e 73 71 6c 69 74 65 33 5f 63 6f that ^sqlite3_co
10cb0 6e 66 69 67 28 29 20 63 61 6e 20 62 65 20 63 61 nfig() can be ca
10cc0 6c 6c 65 64 20 61 73 20 70 61 72 74 20 6f 66 20 lled as part of
10cd0 74 68 65 0a 2a 2a 20 69 6d 70 6c 65 6d 65 6e 74 the.** implement
10ce0 61 74 69 6f 6e 20 6f 66 20 61 6e 20 61 70 70 6c ation of an appl
10cf0 69 63 61 74 69 6f 6e 2d 64 65 66 69 6e 65 64 20 ication-defined
10d00 5b 73 71 6c 69 74 65 33 5f 6f 73 5f 69 6e 69 74 [sqlite3_os_init
10d10 28 29 5d 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 66 ()]..**.** The f
10d20 69 72 73 74 20 61 72 67 75 6d 65 6e 74 20 74 6f irst argument to
10d30 20 73 71 6c 69 74 65 33 5f 63 6f 6e 66 69 67 28 sqlite3_config(
10d40 29 20 69 73 20 61 6e 20 69 6e 74 65 67 65 72 0a ) is an integer.
10d50 2a 2a 20 5b 63 6f 6e 66 69 67 75 72 61 74 69 6f ** [configuratio
10d60 6e 20 6f 70 74 69 6f 6e 5d 20 74 68 61 74 20 64 n option] that d
10d70 65 74 65 72 6d 69 6e 65 73 0a 2a 2a 20 77 68 61 etermines.** wha
10d80 74 20 70 72 6f 70 65 72 74 79 20 6f 66 20 53 51 t property of SQ
10d90 4c 69 74 65 20 69 73 20 74 6f 20 62 65 20 63 6f Lite is to be co
10da0 6e 66 69 67 75 72 65 64 2e 20 20 53 75 62 73 65 nfigured. Subse
10db0 71 75 65 6e 74 20 61 72 67 75 6d 65 6e 74 73 0a quent arguments.
10dc0 2a 2a 20 76 61 72 79 20 64 65 70 65 6e 64 69 6e ** vary dependin
10dd0 67 20 6f 6e 20 74 68 65 20 5b 63 6f 6e 66 69 67 g on the [config
10de0 75 72 61 74 69 6f 6e 20 6f 70 74 69 6f 6e 5d 0a uration option].
10df0 2a 2a 20 69 6e 20 74 68 65 20 66 69 72 73 74 20 ** in the first
10e00 61 72 67 75 6d 65 6e 74 2e 0a 2a 2a 0a 2a 2a 20 argument..**.**
10e10 5e 57 68 65 6e 20 61 20 63 6f 6e 66 69 67 75 72 ^When a configur
10e20 61 74 69 6f 6e 20 6f 70 74 69 6f 6e 20 69 73 20 ation option is
10e30 73 65 74 2c 20 73 71 6c 69 74 65 33 5f 63 6f 6e set, sqlite3_con
10e40 66 69 67 28 29 20 72 65 74 75 72 6e 73 20 5b 53 fig() returns [S
10e50 51 4c 49 54 45 5f 4f 4b 5d 2e 0a 2a 2a 20 5e 49 QLITE_OK]..** ^I
10e60 66 20 74 68 65 20 6f 70 74 69 6f 6e 20 69 73 20 f the option is
10e70 75 6e 6b 6e 6f 77 6e 20 6f 72 20 53 51 4c 69 74 unknown or SQLit
10e80 65 20 69 73 20 75 6e 61 62 6c 65 20 74 6f 20 73 e is unable to s
10e90 65 74 20 74 68 65 20 6f 70 74 69 6f 6e 0a 2a 2a et the option.**
10ea0 20 74 68 65 6e 20 74 68 69 73 20 72 6f 75 74 69 then this routi
10eb0 6e 65 20 72 65 74 75 72 6e 73 20 61 20 6e 6f 6e ne returns a non
10ec0 2d 7a 65 72 6f 20 5b 65 72 72 6f 72 20 63 6f 64 -zero [error cod
10ed0 65 5d 2e 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 e]..*/.int sqlit
10ee0 65 33 5f 63 6f 6e 66 69 67 28 69 6e 74 2c 20 2e e3_config(int, .
10ef0 2e 2e 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 ..);../*.** CAPI
10f00 33 52 45 46 3a 20 43 6f 6e 66 69 67 75 72 65 20 3REF: Configure
10f10 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 database connect
10f20 69 6f 6e 73 0a 2a 2a 20 4d 45 54 48 4f 44 3a 20 ions.** METHOD:
10f30 73 71 6c 69 74 65 33 0a 2a 2a 0a 2a 2a 20 54 68 sqlite3.**.** Th
10f40 65 20 73 71 6c 69 74 65 33 5f 64 62 5f 63 6f 6e e sqlite3_db_con
10f50 66 69 67 28 29 20 69 6e 74 65 72 66 61 63 65 20 fig() interface
10f60 69 73 20 75 73 65 64 20 74 6f 20 6d 61 6b 65 20 is used to make
10f70 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 0a 2a 2a configuration.**
10f80 20 63 68 61 6e 67 65 73 20 74 6f 20 61 20 5b 64 changes to a [d
10f90 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 atabase connecti
10fa0 6f 6e 5d 2e 20 20 54 68 65 20 69 6e 74 65 72 66 on]. The interf
10fb0 61 63 65 20 69 73 20 73 69 6d 69 6c 61 72 20 74 ace is similar t
10fc0 6f 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 63 6f o.** [sqlite3_co
10fd0 6e 66 69 67 28 29 5d 20 65 78 63 65 70 74 20 74 nfig()] except t
10fe0 68 61 74 20 74 68 65 20 63 68 61 6e 67 65 73 20 hat the changes
10ff0 61 70 70 6c 79 20 74 6f 20 61 20 73 69 6e 67 6c apply to a singl
11000 65 0a 2a 2a 20 5b 64 61 74 61 62 61 73 65 20 63 e.** [database c
11010 6f 6e 6e 65 63 74 69 6f 6e 5d 20 28 73 70 65 63 onnection] (spec
11020 69 66 69 65 64 20 69 6e 20 74 68 65 20 66 69 72 ified in the fir
11030 73 74 20 61 72 67 75 6d 65 6e 74 29 2e 0a 2a 2a st argument)..**
11040 0a 2a 2a 20 54 68 65 20 73 65 63 6f 6e 64 20 61 .** The second a
11050 72 67 75 6d 65 6e 74 20 74 6f 20 73 71 6c 69 74 rgument to sqlit
11060 65 33 5f 64 62 5f 63 6f 6e 66 69 67 28 44 2c 56 e3_db_config(D,V
11070 2c 2e 2e 2e 29 20 20 69 73 20 74 68 65 0a 2a 2a ,...) is the.**
11080 20 5b 53 51 4c 49 54 45 5f 44 42 43 4f 4e 46 49 [SQLITE_DBCONFI
11090 47 5f 4c 4f 4f 4b 41 53 49 44 45 20 7c 20 63 6f G_LOOKASIDE | co
110a0 6e 66 69 67 75 72 61 74 69 6f 6e 20 76 65 72 62 nfiguration verb
110b0 5d 20 2d 20 61 6e 20 69 6e 74 65 67 65 72 20 63 ] - an integer c
110c0 6f 64 65 20 0a 2a 2a 20 74 68 61 74 20 69 6e 64 ode .** that ind
110d0 69 63 61 74 65 73 20 77 68 61 74 20 61 73 70 65 icates what aspe
110e0 63 74 20 6f 66 20 74 68 65 20 5b 64 61 74 61 62 ct of the [datab
110f0 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 5d 20 ase connection]
11100 69 73 20 62 65 69 6e 67 20 63 6f 6e 66 69 67 75 is being configu
11110 72 65 64 2e 0a 2a 2a 20 53 75 62 73 65 71 75 65 red..** Subseque
11120 6e 74 20 61 72 67 75 6d 65 6e 74 73 20 76 61 72 nt arguments var
11130 79 20 64 65 70 65 6e 64 69 6e 67 20 6f 6e 20 74 y depending on t
11140 68 65 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e he configuration
11150 20 76 65 72 62 2e 0a 2a 2a 0a 2a 2a 20 5e 43 61 verb..**.** ^Ca
11160 6c 6c 73 20 74 6f 20 73 71 6c 69 74 65 33 5f 64 lls to sqlite3_d
11170 62 5f 63 6f 6e 66 69 67 28 29 20 72 65 74 75 72 b_config() retur
11180 6e 20 53 51 4c 49 54 45 5f 4f 4b 20 69 66 20 61 n SQLITE_OK if a
11190 6e 64 20 6f 6e 6c 79 20 69 66 0a 2a 2a 20 74 68 nd only if.** th
111a0 65 20 63 61 6c 6c 20 69 73 20 63 6f 6e 73 69 64 e call is consid
111b0 65 72 65 64 20 73 75 63 63 65 73 73 66 75 6c 2e ered successful.
111c0 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f .*/.int sqlite3_
111d0 64 62 5f 63 6f 6e 66 69 67 28 73 71 6c 69 74 65 db_config(sqlite
111e0 33 2a 2c 20 69 6e 74 20 6f 70 2c 20 2e 2e 2e 29 3*, int op, ...)
111f0 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 ;../*.** CAPI3RE
11200 46 3a 20 4d 65 6d 6f 72 79 20 41 6c 6c 6f 63 61 F: Memory Alloca
11210 74 69 6f 6e 20 52 6f 75 74 69 6e 65 73 0a 2a 2a tion Routines.**
11220 0a 2a 2a 20 41 6e 20 69 6e 73 74 61 6e 63 65 20 .** An instance
11230 6f 66 20 74 68 69 73 20 6f 62 6a 65 63 74 20 64 of this object d
11240 65 66 69 6e 65 73 20 74 68 65 20 69 6e 74 65 72 efines the inter
11250 66 61 63 65 20 62 65 74 77 65 65 6e 20 53 51 4c face between SQL
11260 69 74 65 0a 2a 2a 20 61 6e 64 20 6c 6f 77 2d 6c ite.** and low-l
11270 65 76 65 6c 20 6d 65 6d 6f 72 79 20 61 6c 6c 6f evel memory allo
11280 63 61 74 69 6f 6e 20 72 6f 75 74 69 6e 65 73 2e cation routines.
11290 0a 2a 2a 0a 2a 2a 20 54 68 69 73 20 6f 62 6a 65 .**.** This obje
112a0 63 74 20 69 73 20 75 73 65 64 20 69 6e 20 6f 6e ct is used in on
112b0 6c 79 20 6f 6e 65 20 70 6c 61 63 65 20 69 6e 20 ly one place in
112c0 74 68 65 20 53 51 4c 69 74 65 20 69 6e 74 65 72 the SQLite inter
112d0 66 61 63 65 2e 0a 2a 2a 20 41 20 70 6f 69 6e 74 face..** A point
112e0 65 72 20 74 6f 20 61 6e 20 69 6e 73 74 61 6e 63 er to an instanc
112f0 65 20 6f 66 20 74 68 69 73 20 6f 62 6a 65 63 74 e of this object
11300 20 69 73 20 74 68 65 20 61 72 67 75 6d 65 6e 74 is the argument
11310 20 74 6f 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f to.** [sqlite3_
11320 63 6f 6e 66 69 67 28 29 5d 20 77 68 65 6e 20 74 config()] when t
11330 68 65 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e he configuration
11340 20 6f 70 74 69 6f 6e 20 69 73 0a 2a 2a 20 5b 53 option is.** [S
11350 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 4d 41 4c QLITE_CONFIG_MAL
11360 4c 4f 43 5d 20 6f 72 20 5b 53 51 4c 49 54 45 5f LOC] or [SQLITE_
11370 43 4f 4e 46 49 47 5f 47 45 54 4d 41 4c 4c 4f 43 CONFIG_GETMALLOC
11380 5d 2e 20 20 0a 2a 2a 20 42 79 20 63 72 65 61 74 ]. .** By creat
11390 69 6e 67 20 61 6e 20 69 6e 73 74 61 6e 63 65 20 ing an instance
113a0 6f 66 20 74 68 69 73 20 6f 62 6a 65 63 74 0a 2a of this object.*
113b0 2a 20 61 6e 64 20 70 61 73 73 69 6e 67 20 69 74 * and passing it
113c0 20 74 6f 20 5b 73 71 6c 69 74 65 33 5f 63 6f 6e to [sqlite3_con
113d0 66 69 67 5d 28 5b 53 51 4c 49 54 45 5f 43 4f 4e fig]([SQLITE_CON
113e0 46 49 47 5f 4d 41 4c 4c 4f 43 5d 29 0a 2a 2a 20 FIG_MALLOC]).**
113f0 64 75 72 69 6e 67 20 63 6f 6e 66 69 67 75 72 61 during configura
11400 74 69 6f 6e 2c 20 61 6e 20 61 70 70 6c 69 63 61 tion, an applica
11410 74 69 6f 6e 20 63 61 6e 20 73 70 65 63 69 66 79 tion can specify
11420 20 61 6e 20 61 6c 74 65 72 6e 61 74 69 76 65 0a an alternative.
11430 2a 2a 20 6d 65 6d 6f 72 79 20 61 6c 6c 6f 63 61 ** memory alloca
11440 74 69 6f 6e 20 73 75 62 73 79 73 74 65 6d 20 66 tion subsystem f
11450 6f 72 20 53 51 4c 69 74 65 20 74 6f 20 75 73 65 or SQLite to use
11460 20 66 6f 72 20 61 6c 6c 20 6f 66 20 69 74 73 0a for all of its.
11470 2a 2a 20 64 79 6e 61 6d 69 63 20 6d 65 6d 6f 72 ** dynamic memor
11480 79 20 6e 65 65 64 73 2e 0a 2a 2a 0a 2a 2a 20 4e y needs..**.** N
11490 6f 74 65 20 74 68 61 74 20 53 51 4c 69 74 65 20 ote that SQLite
114a0 63 6f 6d 65 73 20 77 69 74 68 20 73 65 76 65 72 comes with sever
114b0 61 6c 20 5b 62 75 69 6c 74 2d 69 6e 20 6d 65 6d al [built-in mem
114c0 6f 72 79 20 61 6c 6c 6f 63 61 74 6f 72 73 5d 0a ory allocators].
114d0 2a 2a 20 74 68 61 74 20 61 72 65 20 70 65 72 66 ** that are perf
114e0 65 63 74 6c 79 20 61 64 65 71 75 61 74 65 20 66 ectly adequate f
114f0 6f 72 20 74 68 65 20 6f 76 65 72 77 68 65 6c 6d or the overwhelm
11500 69 6e 67 20 6d 61 6a 6f 72 69 74 79 20 6f 66 20 ing majority of
11510 61 70 70 6c 69 63 61 74 69 6f 6e 73 0a 2a 2a 20 applications.**
11520 61 6e 64 20 74 68 61 74 20 74 68 69 73 20 6f 62 and that this ob
11530 6a 65 63 74 20 69 73 20 6f 6e 6c 79 20 75 73 65 ject is only use
11540 66 75 6c 20 74 6f 20 61 20 74 69 6e 79 20 6d 69 ful to a tiny mi
11550 6e 6f 72 69 74 79 20 6f 66 20 61 70 70 6c 69 63 nority of applic
11560 61 74 69 6f 6e 73 0a 2a 2a 20 77 69 74 68 20 73 ations.** with s
11570 70 65 63 69 61 6c 69 7a 65 64 20 6d 65 6d 6f 72 pecialized memor
11580 79 20 61 6c 6c 6f 63 61 74 69 6f 6e 20 72 65 71 y allocation req
11590 75 69 72 65 6d 65 6e 74 73 2e 20 20 54 68 69 73 uirements. This
115a0 20 6f 62 6a 65 63 74 20 69 73 0a 2a 2a 20 61 6c object is.** al
115b0 73 6f 20 75 73 65 64 20 64 75 72 69 6e 67 20 74 so used during t
115c0 65 73 74 69 6e 67 20 6f 66 20 53 51 4c 69 74 65 esting of SQLite
115d0 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 73 70 65 in order to spe
115e0 63 69 66 79 20 61 6e 20 61 6c 74 65 72 6e 61 74 cify an alternat
115f0 69 76 65 0a 2a 2a 20 6d 65 6d 6f 72 79 20 61 6c ive.** memory al
11600 6c 6f 63 61 74 6f 72 20 74 68 61 74 20 73 69 6d locator that sim
11610 75 6c 61 74 65 73 20 6d 65 6d 6f 72 79 20 6f 75 ulates memory ou
11620 74 2d 6f 66 2d 6d 65 6d 6f 72 79 20 63 6f 6e 64 t-of-memory cond
11630 69 74 69 6f 6e 73 20 69 6e 0a 2a 2a 20 6f 72 64 itions in.** ord
11640 65 72 20 74 6f 20 76 65 72 69 66 79 20 74 68 61 er to verify tha
11650 74 20 53 51 4c 69 74 65 20 72 65 63 6f 76 65 72 t SQLite recover
11660 73 20 67 72 61 63 65 66 75 6c 6c 79 20 66 72 6f s gracefully fro
11670 6d 20 73 75 63 68 0a 2a 2a 20 63 6f 6e 64 69 74 m such.** condit
11680 69 6f 6e 73 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 ions..**.** The
11690 78 4d 61 6c 6c 6f 63 2c 20 78 52 65 61 6c 6c 6f xMalloc, xReallo
116a0 63 2c 20 61 6e 64 20 78 46 72 65 65 20 6d 65 74 c, and xFree met
116b0 68 6f 64 73 20 6d 75 73 74 20 77 6f 72 6b 20 6c hods must work l
116c0 69 6b 65 20 74 68 65 0a 2a 2a 20 6d 61 6c 6c 6f ike the.** mallo
116d0 63 28 29 2c 20 72 65 61 6c 6c 6f 63 28 29 20 61 c(), realloc() a
116e0 6e 64 20 66 72 65 65 28 29 20 66 75 6e 63 74 69 nd free() functi
116f0 6f 6e 73 20 66 72 6f 6d 20 74 68 65 20 73 74 61 ons from the sta
11700 6e 64 61 72 64 20 43 20 6c 69 62 72 61 72 79 2e ndard C library.
11710 0a 2a 2a 20 5e 53 51 4c 69 74 65 20 67 75 61 72 .** ^SQLite guar
11720 61 6e 74 65 65 73 20 74 68 61 74 20 74 68 65 20 antees that the
11730 73 65 63 6f 6e 64 20 61 72 67 75 6d 65 6e 74 20 second argument
11740 74 6f 0a 2a 2a 20 78 52 65 61 6c 6c 6f 63 20 69 to.** xRealloc i
11750 73 20 61 6c 77 61 79 73 20 61 20 76 61 6c 75 65 s always a value
11760 20 72 65 74 75 72 6e 65 64 20 62 79 20 61 20 70 returned by a p
11770 72 69 6f 72 20 63 61 6c 6c 20 74 6f 20 78 52 6f rior call to xRo
11780 75 6e 64 75 70 2e 0a 2a 2a 0a 2a 2a 20 78 53 69 undup..**.** xSi
11790 7a 65 20 73 68 6f 75 6c 64 20 72 65 74 75 72 6e ze should return
117a0 20 74 68 65 20 61 6c 6c 6f 63 61 74 65 64 20 73 the allocated s
117b0 69 7a 65 20 6f 66 20 61 20 6d 65 6d 6f 72 79 20 ize of a memory
117c0 61 6c 6c 6f 63 61 74 69 6f 6e 0a 2a 2a 20 70 72 allocation.** pr
117d0 65 76 69 6f 75 73 6c 79 20 6f 62 74 61 69 6e 65 eviously obtaine
117e0 64 20 66 72 6f 6d 20 78 4d 61 6c 6c 6f 63 20 6f d from xMalloc o
117f0 72 20 78 52 65 61 6c 6c 6f 63 2e 20 20 54 68 65 r xRealloc. The
11800 20 61 6c 6c 6f 63 61 74 65 64 20 73 69 7a 65 0a allocated size.
11810 2a 2a 20 69 73 20 61 6c 77 61 79 73 20 61 74 20 ** is always at
11820 6c 65 61 73 74 20 61 73 20 62 69 67 20 61 73 20 least as big as
11830 74 68 65 20 72 65 71 75 65 73 74 65 64 20 73 69 the requested si
11840 7a 65 20 62 75 74 20 6d 61 79 20 62 65 20 6c 61 ze but may be la
11850 72 67 65 72 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 rger..**.** The
11860 78 52 6f 75 6e 64 75 70 20 6d 65 74 68 6f 64 20 xRoundup method
11870 72 65 74 75 72 6e 73 20 77 68 61 74 20 77 6f 75 returns what wou
11880 6c 64 20 62 65 20 74 68 65 20 61 6c 6c 6f 63 61 ld be the alloca
11890 74 65 64 20 73 69 7a 65 20 6f 66 0a 2a 2a 20 61 ted size of.** a
118a0 20 6d 65 6d 6f 72 79 20 61 6c 6c 6f 63 61 74 69 memory allocati
118b0 6f 6e 20 67 69 76 65 6e 20 61 20 70 61 72 74 69 on given a parti
118c0 63 75 6c 61 72 20 72 65 71 75 65 73 74 65 64 20 cular requested
118d0 73 69 7a 65 2e 20 20 4d 6f 73 74 20 6d 65 6d 6f size. Most memo
118e0 72 79 0a 2a 2a 20 61 6c 6c 6f 63 61 74 6f 72 73 ry.** allocators
118f0 20 72 6f 75 6e 64 20 75 70 20 6d 65 6d 6f 72 79 round up memory
11900 20 61 6c 6c 6f 63 61 74 69 6f 6e 73 20 61 74 20 allocations at
11910 6c 65 61 73 74 20 74 6f 20 74 68 65 20 6e 65 78 least to the nex
11920 74 20 6d 75 6c 74 69 70 6c 65 0a 2a 2a 20 6f 66 t multiple.** of
11930 20 38 2e 20 20 53 6f 6d 65 20 61 6c 6c 6f 63 61 8. Some alloca
11940 74 6f 72 73 20 72 6f 75 6e 64 20 75 70 20 74 6f tors round up to
11950 20 61 20 6c 61 72 67 65 72 20 6d 75 6c 74 69 70 a larger multip
11960 6c 65 20 6f 72 20 74 6f 20 61 20 70 6f 77 65 72 le or to a power
11970 20 6f 66 20 32 2e 0a 2a 2a 20 45 76 65 72 79 20 of 2..** Every
11980 6d 65 6d 6f 72 79 20 61 6c 6c 6f 63 61 74 69 6f memory allocatio
11990 6e 20 72 65 71 75 65 73 74 20 63 6f 6d 69 6e 67 n request coming
119a0 20 69 6e 20 74 68 72 6f 75 67 68 20 5b 73 71 6c in through [sql
119b0 69 74 65 33 5f 6d 61 6c 6c 6f 63 28 29 5d 0a 2a ite3_malloc()].*
119c0 2a 20 6f 72 20 5b 73 71 6c 69 74 65 33 5f 72 65 * or [sqlite3_re
119d0 61 6c 6c 6f 63 28 29 5d 20 66 69 72 73 74 20 63 alloc()] first c
119e0 61 6c 6c 73 20 78 52 6f 75 6e 64 75 70 2e 20 20 alls xRoundup.
119f0 49 66 20 78 52 6f 75 6e 64 75 70 20 72 65 74 75 If xRoundup retu
11a00 72 6e 73 20 30 2c 20 0a 2a 2a 20 74 68 61 74 20 rns 0, .** that
11a10 63 61 75 73 65 73 20 74 68 65 20 63 6f 72 72 65 causes the corre
11a20 73 70 6f 6e 64 69 6e 67 20 6d 65 6d 6f 72 79 20 sponding memory
11a30 61 6c 6c 6f 63 61 74 69 6f 6e 20 74 6f 20 66 61 allocation to fa
11a40 69 6c 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 78 49 il..**.** The xI
11a50 6e 69 74 20 6d 65 74 68 6f 64 20 69 6e 69 74 69 nit method initi
11a60 61 6c 69 7a 65 73 20 74 68 65 20 6d 65 6d 6f 72 alizes the memor
11a70 79 20 61 6c 6c 6f 63 61 74 6f 72 2e 20 20 46 6f y allocator. Fo
11a80 72 20 65 78 61 6d 70 6c 65 2c 0a 2a 2a 20 69 74 r example,.** it
11a90 20 6d 69 67 68 74 20 61 6c 6c 6f 63 61 74 65 20 might allocate
11aa0 61 6e 79 20 72 65 71 75 69 72 65 20 6d 75 74 65 any require mute
11ab0 78 65 73 20 6f 72 20 69 6e 69 74 69 61 6c 69 7a xes or initializ
11ac0 65 20 69 6e 74 65 72 6e 61 6c 20 64 61 74 61 0a e internal data.
11ad0 2a 2a 20 73 74 72 75 63 74 75 72 65 73 2e 20 20 ** structures.
11ae0 54 68 65 20 78 53 68 75 74 64 6f 77 6e 20 6d 65 The xShutdown me
11af0 74 68 6f 64 20 69 73 20 69 6e 76 6f 6b 65 64 20 thod is invoked
11b00 28 69 6e 64 69 72 65 63 74 6c 79 29 20 62 79 0a (indirectly) by.
11b10 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 73 68 75 74 ** [sqlite3_shut
11b20 64 6f 77 6e 28 29 5d 20 61 6e 64 20 73 68 6f 75 down()] and shou
11b30 6c 64 20 64 65 61 6c 6c 6f 63 61 74 65 20 61 6e ld deallocate an
11b40 79 20 72 65 73 6f 75 72 63 65 73 20 61 63 71 75 y resources acqu
11b50 69 72 65 64 0a 2a 2a 20 62 79 20 78 49 6e 69 74 ired.** by xInit
11b60 2e 20 20 54 68 65 20 70 41 70 70 44 61 74 61 20 . The pAppData
11b70 70 6f 69 6e 74 65 72 20 69 73 20 75 73 65 64 20 pointer is used
11b80 61 73 20 74 68 65 20 6f 6e 6c 79 20 70 61 72 61 as the only para
11b90 6d 65 74 65 72 20 74 6f 0a 2a 2a 20 78 49 6e 69 meter to.** xIni
11ba0 74 20 61 6e 64 20 78 53 68 75 74 64 6f 77 6e 2e t and xShutdown.
11bb0 0a 2a 2a 0a 2a 2a 20 53 51 4c 69 74 65 20 68 6f .**.** SQLite ho
11bc0 6c 64 73 20 74 68 65 20 5b 53 51 4c 49 54 45 5f lds the [SQLITE_
11bd0 4d 55 54 45 58 5f 53 54 41 54 49 43 5f 4d 41 53 MUTEX_STATIC_MAS
11be0 54 45 52 5d 20 6d 75 74 65 78 20 77 68 65 6e 20 TER] mutex when
11bf0 69 74 20 69 6e 76 6f 6b 65 73 0a 2a 2a 20 74 68 it invokes.** th
11c00 65 20 78 49 6e 69 74 20 6d 65 74 68 6f 64 2c 20 e xInit method,
11c10 73 6f 20 74 68 65 20 78 49 6e 69 74 20 6d 65 74 so the xInit met
11c20 68 6f 64 20 6e 65 65 64 20 6e 6f 74 20 62 65 20 hod need not be
11c30 74 68 72 65 61 64 73 61 66 65 2e 20 20 54 68 65 threadsafe. The
11c40 0a 2a 2a 20 78 53 68 75 74 64 6f 77 6e 20 6d 65 .** xShutdown me
11c50 74 68 6f 64 20 69 73 20 6f 6e 6c 79 20 63 61 6c thod is only cal
11c60 6c 65 64 20 66 72 6f 6d 20 5b 73 71 6c 69 74 65 led from [sqlite
11c70 33 5f 73 68 75 74 64 6f 77 6e 28 29 5d 20 73 6f 3_shutdown()] so
11c80 20 69 74 20 64 6f 65 73 0a 2a 2a 20 6e 6f 74 20 it does.** not
11c90 6e 65 65 64 20 74 6f 20 62 65 20 74 68 72 65 61 need to be threa
11ca0 64 73 61 66 65 20 65 69 74 68 65 72 2e 20 20 46 dsafe either. F
11cb0 6f 72 20 61 6c 6c 20 6f 74 68 65 72 20 6d 65 74 or all other met
11cc0 68 6f 64 73 2c 20 53 51 4c 69 74 65 0a 2a 2a 20 hods, SQLite.**
11cd0 68 6f 6c 64 73 20 74 68 65 20 5b 53 51 4c 49 54 holds the [SQLIT
11ce0 45 5f 4d 55 54 45 58 5f 53 54 41 54 49 43 5f 4d E_MUTEX_STATIC_M
11cf0 45 4d 5d 20 6d 75 74 65 78 20 61 73 20 6c 6f 6e EM] mutex as lon
11d00 67 20 61 73 20 74 68 65 0a 2a 2a 20 5b 53 51 4c g as the.** [SQL
11d10 49 54 45 5f 43 4f 4e 46 49 47 5f 4d 45 4d 53 54 ITE_CONFIG_MEMST
11d20 41 54 55 53 5d 20 63 6f 6e 66 69 67 75 72 61 74 ATUS] configurat
11d30 69 6f 6e 20 6f 70 74 69 6f 6e 20 69 73 20 74 75 ion option is tu
11d40 72 6e 65 64 20 6f 6e 20 28 77 68 69 63 68 0a 2a rned on (which.*
11d50 2a 20 69 74 20 69 73 20 62 79 20 64 65 66 61 75 * it is by defau
11d60 6c 74 29 20 61 6e 64 20 73 6f 20 74 68 65 20 6d lt) and so the m
11d70 65 74 68 6f 64 73 20 61 72 65 20 61 75 74 6f 6d ethods are autom
11d80 61 74 69 63 61 6c 6c 79 20 73 65 72 69 61 6c 69 atically seriali
11d90 7a 65 64 2e 0a 2a 2a 20 48 6f 77 65 76 65 72 2c zed..** However,
11da0 20 69 66 20 5b 53 51 4c 49 54 45 5f 43 4f 4e 46 if [SQLITE_CONF
11db0 49 47 5f 4d 45 4d 53 54 41 54 55 53 5d 20 69 73 IG_MEMSTATUS] is
11dc0 20 64 69 73 61 62 6c 65 64 2c 20 74 68 65 6e 20 disabled, then
11dd0 74 68 65 20 6f 74 68 65 72 0a 2a 2a 20 6d 65 74 the other.** met
11de0 68 6f 64 73 20 6d 75 73 74 20 62 65 20 74 68 72 hods must be thr
11df0 65 61 64 73 61 66 65 20 6f 72 20 65 6c 73 65 20 eadsafe or else
11e00 6d 61 6b 65 20 74 68 65 69 72 20 6f 77 6e 20 61 make their own a
11e10 72 72 61 6e 67 65 6d 65 6e 74 73 20 66 6f 72 0a rrangements for.
11e20 2a 2a 20 73 65 72 69 61 6c 69 7a 61 74 69 6f 6e ** serialization
11e30 2e 0a 2a 2a 0a 2a 2a 20 53 51 4c 69 74 65 20 77 ..**.** SQLite w
11e40 69 6c 6c 20 6e 65 76 65 72 20 69 6e 76 6f 6b 65 ill never invoke
11e50 20 78 49 6e 69 74 28 29 20 6d 6f 72 65 20 74 68 xInit() more th
11e60 61 6e 20 6f 6e 63 65 20 77 69 74 68 6f 75 74 20 an once without
11e70 61 6e 20 69 6e 74 65 72 76 65 6e 69 6e 67 0a 2a an intervening.*
11e80 2a 20 63 61 6c 6c 20 74 6f 20 78 53 68 75 74 64 * call to xShutd
11e90 6f 77 6e 28 29 2e 0a 2a 2f 0a 74 79 70 65 64 65 own()..*/.typede
11ea0 66 20 73 74 72 75 63 74 20 73 71 6c 69 74 65 33 f struct sqlite3
11eb0 5f 6d 65 6d 5f 6d 65 74 68 6f 64 73 20 73 71 6c _mem_methods sql
11ec0 69 74 65 33 5f 6d 65 6d 5f 6d 65 74 68 6f 64 73 ite3_mem_methods
11ed0 3b 0a 73 74 72 75 63 74 20 73 71 6c 69 74 65 33 ;.struct sqlite3
11ee0 5f 6d 65 6d 5f 6d 65 74 68 6f 64 73 20 7b 0a 20 _mem_methods {.
11ef0 20 76 6f 69 64 20 2a 28 2a 78 4d 61 6c 6c 6f 63 void *(*xMalloc
11f00 29 28 69 6e 74 29 3b 20 20 20 20 20 20 20 20 20 )(int);
11f10 2f 2a 20 4d 65 6d 6f 72 79 20 61 6c 6c 6f 63 61 /* Memory alloca
11f20 74 69 6f 6e 20 66 75 6e 63 74 69 6f 6e 20 2a 2f tion function */
11f30 0a 20 20 76 6f 69 64 20 28 2a 78 46 72 65 65 29 . void (*xFree)
11f40 28 76 6f 69 64 2a 29 3b 20 20 20 20 20 20 20 20 (void*);
11f50 20 20 2f 2a 20 46 72 65 65 20 61 20 70 72 69 6f /* Free a prio
11f60 72 20 61 6c 6c 6f 63 61 74 69 6f 6e 20 2a 2f 0a r allocation */.
11f70 20 20 76 6f 69 64 20 2a 28 2a 78 52 65 61 6c 6c void *(*xReall
11f80 6f 63 29 28 76 6f 69 64 2a 2c 69 6e 74 29 3b 20 oc)(void*,int);
11f90 20 2f 2a 20 52 65 73 69 7a 65 20 61 6e 20 61 6c /* Resize an al
11fa0 6c 6f 63 61 74 69 6f 6e 20 2a 2f 0a 20 20 69 6e location */. in
11fb0 74 20 28 2a 78 53 69 7a 65 29 28 76 6f 69 64 2a t (*xSize)(void*
11fc0 29 3b 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 ); /*
11fd0 52 65 74 75 72 6e 20 74 68 65 20 73 69 7a 65 20 Return the size
11fe0 6f 66 20 61 6e 20 61 6c 6c 6f 63 61 74 69 6f 6e of an allocation
11ff0 20 2a 2f 0a 20 20 69 6e 74 20 28 2a 78 52 6f 75 */. int (*xRou
12000 6e 64 75 70 29 28 69 6e 74 29 3b 20 20 20 20 20 ndup)(int);
12010 20 20 20 20 20 2f 2a 20 52 6f 75 6e 64 20 75 70 /* Round up
12020 20 72 65 71 75 65 73 74 20 73 69 7a 65 20 74 6f request size to
12030 20 61 6c 6c 6f 63 61 74 69 6f 6e 20 73 69 7a 65 allocation size
12040 20 2a 2f 0a 20 20 69 6e 74 20 28 2a 78 49 6e 69 */. int (*xIni
12050 74 29 28 76 6f 69 64 2a 29 3b 20 20 20 20 20 20 t)(void*);
12060 20 20 20 20 20 2f 2a 20 49 6e 69 74 69 61 6c 69 /* Initiali
12070 7a 65 20 74 68 65 20 6d 65 6d 6f 72 79 20 61 6c ze the memory al
12080 6c 6f 63 61 74 6f 72 20 2a 2f 0a 20 20 76 6f 69 locator */. voi
12090 64 20 28 2a 78 53 68 75 74 64 6f 77 6e 29 28 76 d (*xShutdown)(v
120a0 6f 69 64 2a 29 3b 20 20 20 20 20 20 2f 2a 20 44 oid*); /* D
120b0 65 69 6e 69 74 69 61 6c 69 7a 65 20 74 68 65 20 einitialize the
120c0 6d 65 6d 6f 72 79 20 61 6c 6c 6f 63 61 74 6f 72 memory allocator
120d0 20 2a 2f 0a 20 20 76 6f 69 64 20 2a 70 41 70 70 */. void *pApp
120e0 44 61 74 61 3b 20 20 20 20 20 20 20 20 20 20 20 Data;
120f0 20 20 20 20 20 2f 2a 20 41 72 67 75 6d 65 6e 74 /* Argument
12100 20 74 6f 20 78 49 6e 69 74 28 29 20 61 6e 64 20 to xInit() and
12110 78 53 68 75 74 64 6f 77 6e 28 29 20 2a 2f 0a 7d xShutdown() */.}
12120 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 ;../*.** CAPI3RE
12130 46 3a 20 43 6f 6e 66 69 67 75 72 61 74 69 6f 6e F: Configuration
12140 20 4f 70 74 69 6f 6e 73 0a 2a 2a 20 4b 45 59 57 Options.** KEYW
12150 4f 52 44 53 3a 20 7b 63 6f 6e 66 69 67 75 72 61 ORDS: {configura
12160 74 69 6f 6e 20 6f 70 74 69 6f 6e 7d 0a 2a 2a 0a tion option}.**.
12170 2a 2a 20 54 68 65 73 65 20 63 6f 6e 73 74 61 6e ** These constan
12180 74 73 20 61 72 65 20 74 68 65 20 61 76 61 69 6c ts are the avail
12190 61 62 6c 65 20 69 6e 74 65 67 65 72 20 63 6f 6e able integer con
121a0 66 69 67 75 72 61 74 69 6f 6e 20 6f 70 74 69 6f figuration optio
121b0 6e 73 20 74 68 61 74 0a 2a 2a 20 63 61 6e 20 62 ns that.** can b
121c0 65 20 70 61 73 73 65 64 20 61 73 20 74 68 65 20 e passed as the
121d0 66 69 72 73 74 20 61 72 67 75 6d 65 6e 74 20 74 first argument t
121e0 6f 20 74 68 65 20 5b 73 71 6c 69 74 65 33 5f 63 o the [sqlite3_c
121f0 6f 6e 66 69 67 28 29 5d 20 69 6e 74 65 72 66 61 onfig()] interfa
12200 63 65 2e 0a 2a 2a 0a 2a 2a 20 4e 65 77 20 63 6f ce..**.** New co
12210 6e 66 69 67 75 72 61 74 69 6f 6e 20 6f 70 74 69 nfiguration opti
12220 6f 6e 73 20 6d 61 79 20 62 65 20 61 64 64 65 64 ons may be added
12230 20 69 6e 20 66 75 74 75 72 65 20 72 65 6c 65 61 in future relea
12240 73 65 73 20 6f 66 20 53 51 4c 69 74 65 2e 0a 2a ses of SQLite..*
12250 2a 20 45 78 69 73 74 69 6e 67 20 63 6f 6e 66 69 * Existing confi
12260 67 75 72 61 74 69 6f 6e 20 6f 70 74 69 6f 6e 73 guration options
12270 20 6d 69 67 68 74 20 62 65 20 64 69 73 63 6f 6e might be discon
12280 74 69 6e 75 65 64 2e 20 20 41 70 70 6c 69 63 61 tinued. Applica
12290 74 69 6f 6e 73 0a 2a 2a 20 73 68 6f 75 6c 64 20 tions.** should
122a0 63 68 65 63 6b 20 74 68 65 20 72 65 74 75 72 6e check the return
122b0 20 63 6f 64 65 20 66 72 6f 6d 20 5b 73 71 6c 69 code from [sqli
122c0 74 65 33 5f 63 6f 6e 66 69 67 28 29 5d 20 74 6f te3_config()] to
122d0 20 6d 61 6b 65 20 73 75 72 65 20 74 68 61 74 0a make sure that.
122e0 2a 2a 20 74 68 65 20 63 61 6c 6c 20 77 6f 72 6b ** the call work
122f0 65 64 2e 20 20 54 68 65 20 5b 73 71 6c 69 74 65 ed. The [sqlite
12300 33 5f 63 6f 6e 66 69 67 28 29 5d 20 69 6e 74 65 3_config()] inte
12310 72 66 61 63 65 20 77 69 6c 6c 20 72 65 74 75 72 rface will retur
12320 6e 20 61 0a 2a 2a 20 6e 6f 6e 2d 7a 65 72 6f 20 n a.** non-zero
12330 5b 65 72 72 6f 72 20 63 6f 64 65 5d 20 69 66 20 [error code] if
12340 61 20 64 69 73 63 6f 6e 74 69 6e 75 65 64 20 6f a discontinued o
12350 72 20 75 6e 73 75 70 70 6f 72 74 65 64 20 63 6f r unsupported co
12360 6e 66 69 67 75 72 61 74 69 6f 6e 20 6f 70 74 69 nfiguration opti
12370 6f 6e 0a 2a 2a 20 69 73 20 69 6e 76 6f 6b 65 64 on.** is invoked
12380 2e 0a 2a 2a 0a 2a 2a 20 3c 64 6c 3e 0a 2a 2a 20 ..**.** <dl>.**
12390 5b 5b 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f [[SQLITE_CONFIG_
123a0 53 49 4e 47 4c 45 54 48 52 45 41 44 5d 5d 20 3c SINGLETHREAD]] <
123b0 64 74 3e 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 dt>SQLITE_CONFIG
123c0 5f 53 49 4e 47 4c 45 54 48 52 45 41 44 3c 2f 64 _SINGLETHREAD</d
123d0 74 3e 0a 2a 2a 20 3c 64 64 3e 54 68 65 72 65 20 t>.** <dd>There
123e0 61 72 65 20 6e 6f 20 61 72 67 75 6d 65 6e 74 73 are no arguments
123f0 20 74 6f 20 74 68 69 73 20 6f 70 74 69 6f 6e 2e to this option.
12400 20 20 5e 54 68 69 73 20 6f 70 74 69 6f 6e 20 73 ^This option s
12410 65 74 73 20 74 68 65 0a 2a 2a 20 5b 74 68 72 65 ets the.** [thre
12420 61 64 69 6e 67 20 6d 6f 64 65 5d 20 74 6f 20 53 ading mode] to S
12430 69 6e 67 6c 65 2d 74 68 72 65 61 64 2e 20 20 49 ingle-thread. I
12440 6e 20 6f 74 68 65 72 20 77 6f 72 64 73 2c 20 69 n other words, i
12450 74 20 64 69 73 61 62 6c 65 73 0a 2a 2a 20 61 6c t disables.** al
12460 6c 20 6d 75 74 65 78 69 6e 67 20 61 6e 64 20 70 l mutexing and p
12470 75 74 73 20 53 51 4c 69 74 65 20 69 6e 74 6f 20 uts SQLite into
12480 61 20 6d 6f 64 65 20 77 68 65 72 65 20 69 74 20 a mode where it
12490 63 61 6e 20 6f 6e 6c 79 20 62 65 20 75 73 65 64 can only be used
124a0 0a 2a 2a 20 62 79 20 61 20 73 69 6e 67 6c 65 20 .** by a single
124b0 74 68 72 65 61 64 2e 20 20 20 5e 49 66 20 53 51 thread. ^If SQ
124c0 4c 69 74 65 20 69 73 20 63 6f 6d 70 69 6c 65 64 Lite is compiled
124d0 20 77 69 74 68 0a 2a 2a 20 74 68 65 20 5b 53 51 with.** the [SQ
124e0 4c 49 54 45 5f 54 48 52 45 41 44 53 41 46 45 20 LITE_THREADSAFE
124f0 7c 20 53 51 4c 49 54 45 5f 54 48 52 45 41 44 53 | SQLITE_THREADS
12500 41 46 45 3d 30 5d 20 63 6f 6d 70 69 6c 65 2d 74 AFE=0] compile-t
12510 69 6d 65 20 6f 70 74 69 6f 6e 20 74 68 65 6e 0a ime option then.
12520 2a 2a 20 69 74 20 69 73 20 6e 6f 74 20 70 6f 73 ** it is not pos
12530 73 69 62 6c 65 20 74 6f 20 63 68 61 6e 67 65 20 sible to change
12540 74 68 65 20 5b 74 68 72 65 61 64 69 6e 67 20 6d the [threading m
12550 6f 64 65 5d 20 66 72 6f 6d 20 69 74 73 20 64 65 ode] from its de
12560 66 61 75 6c 74 0a 2a 2a 20 76 61 6c 75 65 20 6f fault.** value o
12570 66 20 53 69 6e 67 6c 65 2d 74 68 72 65 61 64 20 f Single-thread
12580 61 6e 64 20 73 6f 20 5b 73 71 6c 69 74 65 33 5f and so [sqlite3_
12590 63 6f 6e 66 69 67 28 29 5d 20 77 69 6c 6c 20 72 config()] will r
125a0 65 74 75 72 6e 20 0a 2a 2a 20 5b 53 51 4c 49 54 eturn .** [SQLIT
125b0 45 5f 45 52 52 4f 52 5d 20 69 66 20 63 61 6c 6c E_ERROR] if call
125c0 65 64 20 77 69 74 68 20 74 68 65 20 53 51 4c 49 ed with the SQLI
125d0 54 45 5f 43 4f 4e 46 49 47 5f 53 49 4e 47 4c 45 TE_CONFIG_SINGLE
125e0 54 48 52 45 41 44 0a 2a 2a 20 63 6f 6e 66 69 67 THREAD.** config
125f0 75 72 61 74 69 6f 6e 20 6f 70 74 69 6f 6e 2e 3c uration option.<
12600 2f 64 64 3e 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 4c /dd>.**.** [[SQL
12610 49 54 45 5f 43 4f 4e 46 49 47 5f 4d 55 4c 54 49 ITE_CONFIG_MULTI
12620 54 48 52 45 41 44 5d 5d 20 3c 64 74 3e 53 51 4c THREAD]] <dt>SQL
12630 49 54 45 5f 43 4f 4e 46 49 47 5f 4d 55 4c 54 49 ITE_CONFIG_MULTI
12640 54 48 52 45 41 44 3c 2f 64 74 3e 0a 2a 2a 20 3c THREAD</dt>.** <
12650 64 64 3e 54 68 65 72 65 20 61 72 65 20 6e 6f 20 dd>There are no
12660 61 72 67 75 6d 65 6e 74 73 20 74 6f 20 74 68 69 arguments to thi
12670 73 20 6f 70 74 69 6f 6e 2e 20 20 5e 54 68 69 73 s option. ^This
12680 20 6f 70 74 69 6f 6e 20 73 65 74 73 20 74 68 65 option sets the
12690 0a 2a 2a 20 5b 74 68 72 65 61 64 69 6e 67 20 6d .** [threading m
126a0 6f 64 65 5d 20 74 6f 20 4d 75 6c 74 69 2d 74 68 ode] to Multi-th
126b0 72 65 61 64 2e 20 20 49 6e 20 6f 74 68 65 72 20 read. In other
126c0 77 6f 72 64 73 2c 20 69 74 20 64 69 73 61 62 6c words, it disabl
126d0 65 73 0a 2a 2a 20 6d 75 74 65 78 69 6e 67 20 6f es.** mutexing o
126e0 6e 20 5b 64 61 74 61 62 61 73 65 20 63 6f 6e 6e n [database conn
126f0 65 63 74 69 6f 6e 5d 20 61 6e 64 20 5b 70 72 65 ection] and [pre
12700 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 5d pared statement]
12710 20 6f 62 6a 65 63 74 73 2e 0a 2a 2a 20 54 68 65 objects..** The
12720 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 69 73 20 application is
12730 72 65 73 70 6f 6e 73 69 62 6c 65 20 66 6f 72 20 responsible for
12740 73 65 72 69 61 6c 69 7a 69 6e 67 20 61 63 63 65 serializing acce
12750 73 73 20 74 6f 0a 2a 2a 20 5b 64 61 74 61 62 61 ss to.** [databa
12760 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 73 5d 20 se connections]
12770 61 6e 64 20 5b 70 72 65 70 61 72 65 64 20 73 74 and [prepared st
12780 61 74 65 6d 65 6e 74 73 5d 2e 20 20 42 75 74 20 atements]. But
12790 6f 74 68 65 72 20 6d 75 74 65 78 65 73 0a 2a 2a other mutexes.**
127a0 20 61 72 65 20 65 6e 61 62 6c 65 64 20 73 6f 20 are enabled so
127b0 74 68 61 74 20 53 51 4c 69 74 65 20 77 69 6c 6c that SQLite will
127c0 20 62 65 20 73 61 66 65 20 74 6f 20 75 73 65 20 be safe to use
127d0 69 6e 20 61 20 6d 75 6c 74 69 2d 74 68 72 65 61 in a multi-threa
127e0 64 65 64 0a 2a 2a 20 65 6e 76 69 72 6f 6e 6d 65 ded.** environme
127f0 6e 74 20 61 73 20 6c 6f 6e 67 20 61 73 20 6e 6f nt as long as no
12800 20 74 77 6f 20 74 68 72 65 61 64 73 20 61 74 74 two threads att
12810 65 6d 70 74 20 74 6f 20 75 73 65 20 74 68 65 20 empt to use the
12820 73 61 6d 65 0a 2a 2a 20 5b 64 61 74 61 62 61 73 same.** [databas
12830 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 5d 20 61 74 e connection] at
12840 20 74 68 65 20 73 61 6d 65 20 74 69 6d 65 2e 20 the same time.
12850 20 5e 49 66 20 53 51 4c 69 74 65 20 69 73 20 63 ^If SQLite is c
12860 6f 6d 70 69 6c 65 64 20 77 69 74 68 0a 2a 2a 20 ompiled with.**
12870 74 68 65 20 5b 53 51 4c 49 54 45 5f 54 48 52 45 the [SQLITE_THRE
12880 41 44 53 41 46 45 20 7c 20 53 51 4c 49 54 45 5f ADSAFE | SQLITE_
12890 54 48 52 45 41 44 53 41 46 45 3d 30 5d 20 63 6f THREADSAFE=0] co
128a0 6d 70 69 6c 65 2d 74 69 6d 65 20 6f 70 74 69 6f mpile-time optio
128b0 6e 20 74 68 65 6e 0a 2a 2a 20 69 74 20 69 73 20 n then.** it is
128c0 6e 6f 74 20 70 6f 73 73 69 62 6c 65 20 74 6f 20 not possible to
128d0 73 65 74 20 74 68 65 20 4d 75 6c 74 69 2d 74 68 set the Multi-th
128e0 72 65 61 64 20 5b 74 68 72 65 61 64 69 6e 67 20 read [threading
128f0 6d 6f 64 65 5d 20 61 6e 64 0a 2a 2a 20 5b 73 71 mode] and.** [sq
12900 6c 69 74 65 33 5f 63 6f 6e 66 69 67 28 29 5d 20 lite3_config()]
12910 77 69 6c 6c 20 72 65 74 75 72 6e 20 5b 53 51 4c will return [SQL
12920 49 54 45 5f 45 52 52 4f 52 5d 20 69 66 20 63 61 ITE_ERROR] if ca
12930 6c 6c 65 64 20 77 69 74 68 20 74 68 65 0a 2a 2a lled with the.**
12940 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 4d SQLITE_CONFIG_M
12950 55 4c 54 49 54 48 52 45 41 44 20 63 6f 6e 66 69 ULTITHREAD confi
12960 67 75 72 61 74 69 6f 6e 20 6f 70 74 69 6f 6e 2e guration option.
12970 3c 2f 64 64 3e 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 </dd>.**.** [[SQ
12980 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 53 45 52 49 LITE_CONFIG_SERI
12990 41 4c 49 5a 45 44 5d 5d 20 3c 64 74 3e 53 51 4c ALIZED]] <dt>SQL
129a0 49 54 45 5f 43 4f 4e 46 49 47 5f 53 45 52 49 41 ITE_CONFIG_SERIA
129b0 4c 49 5a 45 44 3c 2f 64 74 3e 0a 2a 2a 20 3c 64 LIZED</dt>.** <d
129c0 64 3e 54 68 65 72 65 20 61 72 65 20 6e 6f 20 61 d>There are no a
129d0 72 67 75 6d 65 6e 74 73 20 74 6f 20 74 68 69 73 rguments to this
129e0 20 6f 70 74 69 6f 6e 2e 20 20 5e 54 68 69 73 20 option. ^This
129f0 6f 70 74 69 6f 6e 20 73 65 74 73 20 74 68 65 0a option sets the.
12a00 2a 2a 20 5b 74 68 72 65 61 64 69 6e 67 20 6d 6f ** [threading mo
12a10 64 65 5d 20 74 6f 20 53 65 72 69 61 6c 69 7a 65 de] to Serialize
12a20 64 2e 20 49 6e 20 6f 74 68 65 72 20 77 6f 72 64 d. In other word
12a30 73 2c 20 74 68 69 73 20 6f 70 74 69 6f 6e 20 65 s, this option e
12a40 6e 61 62 6c 65 73 0a 2a 2a 20 61 6c 6c 20 6d 75 nables.** all mu
12a50 74 65 78 65 73 20 69 6e 63 6c 75 64 69 6e 67 20 texes including
12a60 74 68 65 20 72 65 63 75 72 73 69 76 65 0a 2a 2a the recursive.**
12a70 20 6d 75 74 65 78 65 73 20 6f 6e 20 5b 64 61 74 mutexes on [dat
12a80 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e abase connection
12a90 5d 20 61 6e 64 20 5b 70 72 65 70 61 72 65 64 20 ] and [prepared
12aa0 73 74 61 74 65 6d 65 6e 74 5d 20 6f 62 6a 65 63 statement] objec
12ab0 74 73 2e 0a 2a 2a 20 49 6e 20 74 68 69 73 20 6d ts..** In this m
12ac0 6f 64 65 20 28 77 68 69 63 68 20 69 73 20 74 68 ode (which is th
12ad0 65 20 64 65 66 61 75 6c 74 20 77 68 65 6e 20 53 e default when S
12ae0 51 4c 69 74 65 20 69 73 20 63 6f 6d 70 69 6c 65 QLite is compile
12af0 64 20 77 69 74 68 0a 2a 2a 20 5b 53 51 4c 49 54 d with.** [SQLIT
12b00 45 5f 54 48 52 45 41 44 53 41 46 45 3d 31 5d 29 E_THREADSAFE=1])
12b10 20 74 68 65 20 53 51 4c 69 74 65 20 6c 69 62 72 the SQLite libr
12b20 61 72 79 20 77 69 6c 6c 20 69 74 73 65 6c 66 20 ary will itself
12b30 73 65 72 69 61 6c 69 7a 65 20 61 63 63 65 73 73 serialize access
12b40 0a 2a 2a 20 74 6f 20 5b 64 61 74 61 62 61 73 65 .** to [database
12b50 20 63 6f 6e 6e 65 63 74 69 6f 6e 73 5d 20 61 6e connections] an
12b60 64 20 5b 70 72 65 70 61 72 65 64 20 73 74 61 74 d [prepared stat
12b70 65 6d 65 6e 74 73 5d 20 73 6f 20 74 68 61 74 20 ements] so that
12b80 74 68 65 0a 2a 2a 20 61 70 70 6c 69 63 61 74 69 the.** applicati
12b90 6f 6e 20 69 73 20 66 72 65 65 20 74 6f 20 75 73 on is free to us
12ba0 65 20 74 68 65 20 73 61 6d 65 20 5b 64 61 74 61 e the same [data
12bb0 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 5d base connection]
12bc0 20 6f 72 20 74 68 65 0a 2a 2a 20 73 61 6d 65 20 or the.** same
12bd0 5b 70 72 65 70 61 72 65 64 20 73 74 61 74 65 6d [prepared statem
12be0 65 6e 74 5d 20 69 6e 20 64 69 66 66 65 72 65 6e ent] in differen
12bf0 74 20 74 68 72 65 61 64 73 20 61 74 20 74 68 65 t threads at the
12c00 20 73 61 6d 65 20 74 69 6d 65 2e 0a 2a 2a 20 5e same time..** ^
12c10 49 66 20 53 51 4c 69 74 65 20 69 73 20 63 6f 6d If SQLite is com
12c20 70 69 6c 65 64 20 77 69 74 68 0a 2a 2a 20 74 68 piled with.** th
12c30 65 20 5b 53 51 4c 49 54 45 5f 54 48 52 45 41 44 e [SQLITE_THREAD
12c40 53 41 46 45 20 7c 20 53 51 4c 49 54 45 5f 54 48 SAFE | SQLITE_TH
12c50 52 45 41 44 53 41 46 45 3d 30 5d 20 63 6f 6d 70 READSAFE=0] comp
12c60 69 6c 65 2d 74 69 6d 65 20 6f 70 74 69 6f 6e 20 ile-time option
12c70 74 68 65 6e 0a 2a 2a 20 69 74 20 69 73 20 6e 6f then.** it is no
12c80 74 20 70 6f 73 73 69 62 6c 65 20 74 6f 20 73 65 t possible to se
12c90 74 20 74 68 65 20 53 65 72 69 61 6c 69 7a 65 64 t the Serialized
12ca0 20 5b 74 68 72 65 61 64 69 6e 67 20 6d 6f 64 65 [threading mode
12cb0 5d 20 61 6e 64 0a 2a 2a 20 5b 73 71 6c 69 74 65 ] and.** [sqlite
12cc0 33 5f 63 6f 6e 66 69 67 28 29 5d 20 77 69 6c 6c 3_config()] will
12cd0 20 72 65 74 75 72 6e 20 5b 53 51 4c 49 54 45 5f return [SQLITE_
12ce0 45 52 52 4f 52 5d 20 69 66 20 63 61 6c 6c 65 64 ERROR] if called
12cf0 20 77 69 74 68 20 74 68 65 0a 2a 2a 20 53 51 4c with the.** SQL
12d00 49 54 45 5f 43 4f 4e 46 49 47 5f 53 45 52 49 41 ITE_CONFIG_SERIA
12d10 4c 49 5a 45 44 20 63 6f 6e 66 69 67 75 72 61 74 LIZED configurat
12d20 69 6f 6e 20 6f 70 74 69 6f 6e 2e 3c 2f 64 64 3e ion option.</dd>
12d30 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 4c 49 54 45 5f .**.** [[SQLITE_
12d40 43 4f 4e 46 49 47 5f 4d 41 4c 4c 4f 43 5d 5d 20 CONFIG_MALLOC]]
12d50 3c 64 74 3e 53 51 4c 49 54 45 5f 43 4f 4e 46 49 <dt>SQLITE_CONFI
12d60 47 5f 4d 41 4c 4c 4f 43 3c 2f 64 74 3e 0a 2a 2a G_MALLOC</dt>.**
12d70 20 3c 64 64 3e 20 5e 28 54 68 65 20 53 51 4c 49 <dd> ^(The SQLI
12d80 54 45 5f 43 4f 4e 46 49 47 5f 4d 41 4c 4c 4f 43 TE_CONFIG_MALLOC
12d90 20 6f 70 74 69 6f 6e 20 74 61 6b 65 73 20 61 20 option takes a
12da0 73 69 6e 67 6c 65 20 61 72 67 75 6d 65 6e 74 20 single argument
12db0 77 68 69 63 68 20 69 73 20 0a 2a 2a 20 61 20 70 which is .** a p
12dc0 6f 69 6e 74 65 72 20 74 6f 20 61 6e 20 69 6e 73 ointer to an ins
12dd0 74 61 6e 63 65 20 6f 66 20 74 68 65 20 5b 73 71 tance of the [sq
12de0 6c 69 74 65 33 5f 6d 65 6d 5f 6d 65 74 68 6f 64 lite3_mem_method
12df0 73 5d 20 73 74 72 75 63 74 75 72 65 2e 0a 2a 2a s] structure..**
12e00 20 54 68 65 20 61 72 67 75 6d 65 6e 74 20 73 70 The argument sp
12e10 65 63 69 66 69 65 73 0a 2a 2a 20 61 6c 74 65 72 ecifies.** alter
12e20 6e 61 74 69 76 65 20 6c 6f 77 2d 6c 65 76 65 6c native low-level
12e30 20 6d 65 6d 6f 72 79 20 61 6c 6c 6f 63 61 74 69 memory allocati
12e40 6f 6e 20 72 6f 75 74 69 6e 65 73 20 74 6f 20 62 on routines to b
12e50 65 20 75 73 65 64 20 69 6e 20 70 6c 61 63 65 20 e used in place
12e60 6f 66 0a 2a 2a 20 74 68 65 20 6d 65 6d 6f 72 79 of.** the memory
12e70 20 61 6c 6c 6f 63 61 74 69 6f 6e 20 72 6f 75 74 allocation rout
12e80 69 6e 65 73 20 62 75 69 6c 74 20 69 6e 74 6f 20 ines built into
12e90 53 51 4c 69 74 65 2e 29 5e 20 5e 53 51 4c 69 74 SQLite.)^ ^SQLit
12ea0 65 20 6d 61 6b 65 73 0a 2a 2a 20 69 74 73 20 6f e makes.** its o
12eb0 77 6e 20 70 72 69 76 61 74 65 20 63 6f 70 79 20 wn private copy
12ec0 6f 66 20 74 68 65 20 63 6f 6e 74 65 6e 74 20 6f of the content o
12ed0 66 20 74 68 65 20 5b 73 71 6c 69 74 65 33 5f 6d f the [sqlite3_m
12ee0 65 6d 5f 6d 65 74 68 6f 64 73 5d 20 73 74 72 75 em_methods] stru
12ef0 63 74 75 72 65 0a 2a 2a 20 62 65 66 6f 72 65 20 cture.** before
12f00 74 68 65 20 5b 73 71 6c 69 74 65 33 5f 63 6f 6e the [sqlite3_con
12f10 66 69 67 28 29 5d 20 63 61 6c 6c 20 72 65 74 75 fig()] call retu
12f20 72 6e 73 2e 3c 2f 64 64 3e 0a 2a 2a 0a 2a 2a 20 rns.</dd>.**.**
12f30 5b 5b 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f [[SQLITE_CONFIG_
12f40 47 45 54 4d 41 4c 4c 4f 43 5d 5d 20 3c 64 74 3e GETMALLOC]] <dt>
12f50 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 47 45 SQLITE_CONFIG_GE
12f60 54 4d 41 4c 4c 4f 43 3c 2f 64 74 3e 0a 2a 2a 20 TMALLOC</dt>.**
12f70 3c 64 64 3e 20 5e 28 54 68 65 20 53 51 4c 49 54 <dd> ^(The SQLIT
12f80 45 5f 43 4f 4e 46 49 47 5f 47 45 54 4d 41 4c 4c E_CONFIG_GETMALL
12f90 4f 43 20 6f 70 74 69 6f 6e 20 74 61 6b 65 73 20 OC option takes
12fa0 61 20 73 69 6e 67 6c 65 20 61 72 67 75 6d 65 6e a single argumen
12fb0 74 20 77 68 69 63 68 0a 2a 2a 20 69 73 20 61 20 t which.** is a
12fc0 70 6f 69 6e 74 65 72 20 74 6f 20 61 6e 20 69 6e pointer to an in
12fd0 73 74 61 6e 63 65 20 6f 66 20 74 68 65 20 5b 73 stance of the [s
12fe0 71 6c 69 74 65 33 5f 6d 65 6d 5f 6d 65 74 68 6f qlite3_mem_metho
12ff0 64 73 5d 20 73 74 72 75 63 74 75 72 65 2e 0a 2a ds] structure..*
13000 2a 20 54 68 65 20 5b 73 71 6c 69 74 65 33 5f 6d * The [sqlite3_m
13010 65 6d 5f 6d 65 74 68 6f 64 73 5d 0a 2a 2a 20 73 em_methods].** s
13020 74 72 75 63 74 75 72 65 20 69 73 20 66 69 6c 6c tructure is fill
13030 65 64 20 77 69 74 68 20 74 68 65 20 63 75 72 72 ed with the curr
13040 65 6e 74 6c 79 20 64 65 66 69 6e 65 64 20 6d 65 ently defined me
13050 6d 6f 72 79 20 61 6c 6c 6f 63 61 74 69 6f 6e 20 mory allocation
13060 72 6f 75 74 69 6e 65 73 2e 29 5e 0a 2a 2a 20 54 routines.)^.** T
13070 68 69 73 20 6f 70 74 69 6f 6e 20 63 61 6e 20 62 his option can b
13080 65 20 75 73 65 64 20 74 6f 20 6f 76 65 72 6c 6f e used to overlo
13090 61 64 20 74 68 65 20 64 65 66 61 75 6c 74 20 6d ad the default m
130a0 65 6d 6f 72 79 20 61 6c 6c 6f 63 61 74 69 6f 6e emory allocation
130b0 0a 2a 2a 20 72 6f 75 74 69 6e 65 73 20 77 69 74 .** routines wit
130c0 68 20 61 20 77 72 61 70 70 65 72 20 74 68 61 74 h a wrapper that
130d0 20 73 69 6d 75 6c 61 74 69 6f 6e 73 20 6d 65 6d simulations mem
130e0 6f 72 79 20 61 6c 6c 6f 63 61 74 69 6f 6e 20 66 ory allocation f
130f0 61 69 6c 75 72 65 20 6f 72 0a 2a 2a 20 74 72 61 ailure or.** tra
13100 63 6b 73 20 6d 65 6d 6f 72 79 20 75 73 61 67 65 cks memory usage
13110 2c 20 66 6f 72 20 65 78 61 6d 70 6c 65 2e 20 3c , for example. <
13120 2f 64 64 3e 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 4c /dd>.**.** [[SQL
13130 49 54 45 5f 43 4f 4e 46 49 47 5f 4d 45 4d 53 54 ITE_CONFIG_MEMST
13140 41 54 55 53 5d 5d 20 3c 64 74 3e 53 51 4c 49 54 ATUS]] <dt>SQLIT
13150 45 5f 43 4f 4e 46 49 47 5f 4d 45 4d 53 54 41 54 E_CONFIG_MEMSTAT
13160 55 53 3c 2f 64 74 3e 0a 2a 2a 20 3c 64 64 3e 20 US</dt>.** <dd>
13170 5e 54 68 65 20 53 51 4c 49 54 45 5f 43 4f 4e 46 ^The SQLITE_CONF
13180 49 47 5f 4d 45 4d 53 54 41 54 55 53 20 6f 70 74 IG_MEMSTATUS opt
13190 69 6f 6e 20 74 61 6b 65 73 20 73 69 6e 67 6c 65 ion takes single
131a0 20 61 72 67 75 6d 65 6e 74 20 6f 66 20 74 79 70 argument of typ
131b0 65 20 69 6e 74 2c 0a 2a 2a 20 69 6e 74 65 72 70 e int,.** interp
131c0 72 65 74 65 64 20 61 73 20 61 20 62 6f 6f 6c 65 reted as a boole
131d0 61 6e 2c 20 77 68 69 63 68 20 65 6e 61 62 6c 65 an, which enable
131e0 73 20 6f 72 20 64 69 73 61 62 6c 65 73 20 74 68 s or disables th
131f0 65 20 63 6f 6c 6c 65 63 74 69 6f 6e 20 6f 66 0a e collection of.
13200 2a 2a 20 6d 65 6d 6f 72 79 20 61 6c 6c 6f 63 61 ** memory alloca
13210 74 69 6f 6e 20 73 74 61 74 69 73 74 69 63 73 2e tion statistics.
13220 20 5e 28 57 68 65 6e 20 6d 65 6d 6f 72 79 20 61 ^(When memory a
13230 6c 6c 6f 63 61 74 69 6f 6e 20 73 74 61 74 69 73 llocation statis
13240 74 69 63 73 20 61 72 65 0a 2a 2a 20 64 69 73 61 tics are.** disa
13250 62 6c 65 64 2c 20 74 68 65 20 66 6f 6c 6c 6f 77 bled, the follow
13260 69 6e 67 20 53 51 4c 69 74 65 20 69 6e 74 65 72 ing SQLite inter
13270 66 61 63 65 73 20 62 65 63 6f 6d 65 20 6e 6f 6e faces become non
13280 2d 6f 70 65 72 61 74 69 6f 6e 61 6c 3a 0a 2a 2a -operational:.**
13290 20 20 20 3c 75 6c 3e 0a 2a 2a 20 20 20 3c 6c 69 <ul>.** <li
132a0 3e 20 5b 73 71 6c 69 74 65 33 5f 6d 65 6d 6f 72 > [sqlite3_memor
132b0 79 5f 75 73 65 64 28 29 5d 0a 2a 2a 20 20 20 3c y_used()].** <
132c0 6c 69 3e 20 5b 73 71 6c 69 74 65 33 5f 6d 65 6d li> [sqlite3_mem
132d0 6f 72 79 5f 68 69 67 68 77 61 74 65 72 28 29 5d ory_highwater()]
132e0 0a 2a 2a 20 20 20 3c 6c 69 3e 20 5b 73 71 6c 69 .** <li> [sqli
132f0 74 65 33 5f 73 6f 66 74 5f 68 65 61 70 5f 6c 69 te3_soft_heap_li
13300 6d 69 74 36 34 28 29 5d 0a 2a 2a 20 20 20 3c 6c mit64()].** <l
13310 69 3e 20 5b 73 71 6c 69 74 65 33 5f 73 74 61 74 i> [sqlite3_stat
13320 75 73 36 34 28 29 5d 0a 2a 2a 20 20 20 3c 2f 75 us64()].** </u
13330 6c 3e 29 5e 0a 2a 2a 20 5e 4d 65 6d 6f 72 79 20 l>)^.** ^Memory
13340 61 6c 6c 6f 63 61 74 69 6f 6e 20 73 74 61 74 69 allocation stati
13350 73 74 69 63 73 20 61 72 65 20 65 6e 61 62 6c 65 stics are enable
13360 64 20 62 79 20 64 65 66 61 75 6c 74 20 75 6e 6c d by default unl
13370 65 73 73 20 53 51 4c 69 74 65 20 69 73 0a 2a 2a ess SQLite is.**
13380 20 63 6f 6d 70 69 6c 65 64 20 77 69 74 68 20 5b compiled with [
13390 53 51 4c 49 54 45 5f 44 45 46 41 55 4c 54 5f 4d SQLITE_DEFAULT_M
133a0 45 4d 53 54 41 54 55 53 5d 3d 30 20 69 6e 20 77 EMSTATUS]=0 in w
133b0 68 69 63 68 20 63 61 73 65 20 6d 65 6d 6f 72 79 hich case memory
133c0 0a 2a 2a 20 61 6c 6c 6f 63 61 74 69 6f 6e 20 73 .** allocation s
133d0 74 61 74 69 73 74 69 63 73 20 61 72 65 20 64 69 tatistics are di
133e0 73 61 62 6c 65 64 20 62 79 20 64 65 66 61 75 6c sabled by defaul
133f0 74 2e 0a 2a 2a 20 3c 2f 64 64 3e 0a 2a 2a 0a 2a t..** </dd>.**.*
13400 2a 20 5b 5b 53 51 4c 49 54 45 5f 43 4f 4e 46 49 * [[SQLITE_CONFI
13410 47 5f 53 43 52 41 54 43 48 5d 5d 20 3c 64 74 3e G_SCRATCH]] <dt>
13420 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 53 43 SQLITE_CONFIG_SC
13430 52 41 54 43 48 3c 2f 64 74 3e 0a 2a 2a 20 3c 64 RATCH</dt>.** <d
13440 64 3e 20 5e 54 68 65 20 53 51 4c 49 54 45 5f 43 d> ^The SQLITE_C
13450 4f 4e 46 49 47 5f 53 43 52 41 54 43 48 20 6f 70 ONFIG_SCRATCH op
13460 74 69 6f 6e 20 73 70 65 63 69 66 69 65 73 20 61 tion specifies a
13470 20 73 74 61 74 69 63 20 6d 65 6d 6f 72 79 20 62 static memory b
13480 75 66 66 65 72 0a 2a 2a 20 74 68 61 74 20 53 51 uffer.** that SQ
13490 4c 69 74 65 20 63 61 6e 20 75 73 65 20 66 6f 72 Lite can use for
134a0 20 73 63 72 61 74 63 68 20 6d 65 6d 6f 72 79 2e scratch memory.
134b0 20 20 5e 28 54 68 65 72 65 20 61 72 65 20 74 68 ^(There are th
134c0 72 65 65 20 61 72 67 75 6d 65 6e 74 73 0a 2a 2a ree arguments.**
134d0 20 74 6f 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 to SQLITE_CONFI
134e0 47 5f 53 43 52 41 54 43 48 3a 20 20 41 20 70 6f G_SCRATCH: A po
134f0 69 6e 74 65 72 20 61 6e 20 38 2d 62 79 74 65 0a inter an 8-byte.
13500 2a 2a 20 61 6c 69 67 6e 65 64 20 6d 65 6d 6f 72 ** aligned memor
13510 79 20 62 75 66 66 65 72 20 66 72 6f 6d 20 77 68 y buffer from wh
13520 69 63 68 20 74 68 65 20 73 63 72 61 74 63 68 20 ich the scratch
13530 61 6c 6c 6f 63 61 74 69 6f 6e 73 20 77 69 6c 6c allocations will
13540 20 62 65 0a 2a 2a 20 64 72 61 77 6e 2c 20 74 68 be.** drawn, th
13550 65 20 73 69 7a 65 20 6f 66 20 65 61 63 68 20 73 e size of each s
13560 63 72 61 74 63 68 20 61 6c 6c 6f 63 61 74 69 6f cratch allocatio
13570 6e 20 28 73 7a 29 2c 0a 2a 2a 20 61 6e 64 20 74 n (sz),.** and t
13580 68 65 20 6d 61 78 69 6d 75 6d 20 6e 75 6d 62 65 he maximum numbe
13590 72 20 6f 66 20 73 63 72 61 74 63 68 20 61 6c 6c r of scratch all
135a0 6f 63 61 74 69 6f 6e 73 20 28 4e 29 2e 29 5e 0a ocations (N).)^.
135b0 2a 2a 20 54 68 65 20 66 69 72 73 74 20 61 72 67 ** The first arg
135c0 75 6d 65 6e 74 20 6d 75 73 74 20 62 65 20 61 20 ument must be a
135d0 70 6f 69 6e 74 65 72 20 74 6f 20 61 6e 20 38 2d pointer to an 8-
135e0 62 79 74 65 20 61 6c 69 67 6e 65 64 20 62 75 66 byte aligned buf
135f0 66 65 72 0a 2a 2a 20 6f 66 20 61 74 20 6c 65 61 fer.** of at lea
13600 73 74 20 73 7a 2a 4e 20 62 79 74 65 73 20 6f 66 st sz*N bytes of
13610 20 6d 65 6d 6f 72 79 2e 0a 2a 2a 20 5e 53 51 4c memory..** ^SQL
13620 69 74 65 20 77 69 6c 6c 20 6e 6f 74 20 75 73 65 ite will not use
13630 20 6d 6f 72 65 20 74 68 61 6e 20 6f 6e 65 20 73 more than one s
13640 63 72 61 74 63 68 20 62 75 66 66 65 72 73 20 70 cratch buffers p
13650 65 72 20 74 68 72 65 61 64 2e 0a 2a 2a 20 5e 53 er thread..** ^S
13660 51 4c 69 74 65 20 77 69 6c 6c 20 6e 65 76 65 72 QLite will never
13670 20 72 65 71 75 65 73 74 20 61 20 73 63 72 61 74 request a scrat
13680 63 68 20 62 75 66 66 65 72 20 74 68 61 74 20 69 ch buffer that i
13690 73 20 6d 6f 72 65 20 74 68 61 6e 20 36 0a 2a 2a s more than 6.**
136a0 20 74 69 6d 65 73 20 74 68 65 20 64 61 74 61 62 times the datab
136b0 61 73 65 20 70 61 67 65 20 73 69 7a 65 2e 0a 2a ase page size..*
136c0 2a 20 5e 49 66 20 53 51 4c 69 74 65 20 6e 65 65 * ^If SQLite nee
136d0 64 73 20 6e 65 65 64 73 20 61 64 64 69 74 69 6f ds needs additio
136e0 6e 61 6c 0a 2a 2a 20 73 63 72 61 74 63 68 20 6d nal.** scratch m
136f0 65 6d 6f 72 79 20 62 65 79 6f 6e 64 20 77 68 61 emory beyond wha
13700 74 20 69 73 20 70 72 6f 76 69 64 65 64 20 62 79 t is provided by
13710 20 74 68 69 73 20 63 6f 6e 66 69 67 75 72 61 74 this configurat
13720 69 6f 6e 20 6f 70 74 69 6f 6e 2c 20 74 68 65 6e ion option, then
13730 20 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 6d 61 .** [sqlite3_ma
13740 6c 6c 6f 63 28 29 5d 20 77 69 6c 6c 20 62 65 20 lloc()] will be
13750 75 73 65 64 20 74 6f 20 6f 62 74 61 69 6e 20 74 used to obtain t
13760 68 65 20 6d 65 6d 6f 72 79 20 6e 65 65 64 65 64 he memory needed
13770 2e 3c 70 3e 0a 2a 2a 20 5e 57 68 65 6e 20 74 68 .<p>.** ^When th
13780 65 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 70 72 e application pr
13790 6f 76 69 64 65 73 20 61 6e 79 20 61 6d 6f 75 6e ovides any amoun
137a0 74 20 6f 66 20 73 63 72 61 74 63 68 20 6d 65 6d t of scratch mem
137b0 6f 72 79 20 75 73 69 6e 67 0a 2a 2a 20 53 51 4c ory using.** SQL
137c0 49 54 45 5f 43 4f 4e 46 49 47 5f 53 43 52 41 54 ITE_CONFIG_SCRAT
137d0 43 48 2c 20 53 51 4c 69 74 65 20 61 76 6f 69 64 CH, SQLite avoid
137e0 73 20 75 6e 6e 65 63 65 73 73 61 72 79 20 6c 61 s unnecessary la
137f0 72 67 65 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f rge.** [sqlite3_
13800 6d 61 6c 6c 6f 63 7c 68 65 61 70 20 61 6c 6c 6f malloc|heap allo
13810 63 61 74 69 6f 6e 73 5d 2e 0a 2a 2a 20 54 68 69 cations]..** Thi
13820 73 20 63 61 6e 20 68 65 6c 70 20 5b 52 6f 62 73 s can help [Robs
13830 6f 6e 20 70 72 6f 6f 66 7c 70 72 65 76 65 6e 74 on proof|prevent
13840 20 6d 65 6d 6f 72 79 20 61 6c 6c 6f 63 61 74 69 memory allocati
13850 6f 6e 20 66 61 69 6c 75 72 65 73 5d 20 64 75 65 on failures] due
13860 20 74 6f 20 68 65 61 70 0a 2a 2a 20 66 72 61 67 to heap.** frag
13870 6d 65 6e 74 61 74 69 6f 6e 20 69 6e 20 6c 6f 77 mentation in low
13880 2d 6d 65 6d 6f 72 79 20 65 6d 62 65 64 64 65 64 -memory embedded
13890 20 73 79 73 74 65 6d 73 2e 0a 2a 2a 20 3c 2f 64 systems..** </d
138a0 64 3e 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 4c 49 54 d>.**.** [[SQLIT
138b0 45 5f 43 4f 4e 46 49 47 5f 50 41 47 45 43 41 43 E_CONFIG_PAGECAC
138c0 48 45 5d 5d 20 3c 64 74 3e 53 51 4c 49 54 45 5f HE]] <dt>SQLITE_
138d0 43 4f 4e 46 49 47 5f 50 41 47 45 43 41 43 48 45 CONFIG_PAGECACHE
138e0 3c 2f 64 74 3e 0a 2a 2a 20 3c 64 64 3e 20 5e 54 </dt>.** <dd> ^T
138f0 68 65 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 he SQLITE_CONFIG
13900 5f 50 41 47 45 43 41 43 48 45 20 6f 70 74 69 6f _PAGECACHE optio
13910 6e 20 73 70 65 63 69 66 69 65 73 20 61 20 6d 65 n specifies a me
13920 6d 6f 72 79 20 70 6f 6f 6c 0a 2a 2a 20 74 68 61 mory pool.** tha
13930 74 20 53 51 4c 69 74 65 20 63 61 6e 20 75 73 65 t SQLite can use
13940 20 66 6f 72 20 74 68 65 20 64 61 74 61 62 61 73 for the databas
13950 65 20 70 61 67 65 20 63 61 63 68 65 20 77 69 74 e page cache wit
13960 68 20 74 68 65 20 64 65 66 61 75 6c 74 20 70 61 h the default pa
13970 67 65 0a 2a 2a 20 63 61 63 68 65 20 69 6d 70 6c ge.** cache impl
13980 65 6d 65 6e 74 61 74 69 6f 6e 2e 20 20 0a 2a 2a ementation. .**
13990 20 54 68 69 73 20 63 6f 6e 66 69 67 75 72 61 74 This configurat
139a0 69 6f 6e 20 6f 70 74 69 6f 6e 20 69 73 20 61 20 ion option is a
139b0 6e 6f 2d 6f 70 20 69 66 20 61 6e 20 61 70 70 6c no-op if an appl
139c0 69 63 61 74 69 6f 6e 2d 64 65 66 69 6e 65 20 70 ication-define p
139d0 61 67 65 0a 2a 2a 20 63 61 63 68 65 20 69 6d 70 age.** cache imp
139e0 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 69 73 20 6c lementation is l
139f0 6f 61 64 65 64 20 75 73 69 6e 67 20 74 68 65 20 oaded using the
13a00 5b 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 50 [SQLITE_CONFIG_P
13a10 43 41 43 48 45 32 5d 2e 0a 2a 2a 20 5e 54 68 65 CACHE2]..** ^The
13a20 72 65 20 61 72 65 20 74 68 72 65 65 20 61 72 67 re are three arg
13a30 75 6d 65 6e 74 73 20 74 6f 20 53 51 4c 49 54 45 uments to SQLITE
13a40 5f 43 4f 4e 46 49 47 5f 50 41 47 45 43 41 43 48 _CONFIG_PAGECACH
13a50 45 3a 20 41 20 70 6f 69 6e 74 65 72 20 74 6f 0a E: A pointer to.
13a60 2a 2a 20 38 2d 62 79 74 65 20 61 6c 69 67 6e 65 ** 8-byte aligne
13a70 64 20 6d 65 6d 6f 72 79 20 28 70 4d 65 6d 29 2c d memory (pMem),
13a80 20 74 68 65 20 73 69 7a 65 20 6f 66 20 65 61 63 the size of eac
13a90 68 20 70 61 67 65 20 63 61 63 68 65 20 6c 69 6e h page cache lin
13aa0 65 20 28 73 7a 29 2c 0a 2a 2a 20 61 6e 64 20 74 e (sz),.** and t
13ab0 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 63 61 63 he number of cac
13ac0 68 65 20 6c 69 6e 65 73 20 28 4e 29 2e 0a 2a 2a he lines (N)..**
13ad0 20 54 68 65 20 73 7a 20 61 72 67 75 6d 65 6e 74 The sz argument
13ae0 20 73 68 6f 75 6c 64 20 62 65 20 74 68 65 20 73 should be the s
13af0 69 7a 65 20 6f 66 20 74 68 65 20 6c 61 72 67 65 ize of the large
13b00 73 74 20 64 61 74 61 62 61 73 65 20 70 61 67 65 st database page
13b10 0a 2a 2a 20 28 61 20 70 6f 77 65 72 20 6f 66 20 .** (a power of
13b20 74 77 6f 20 62 65 74 77 65 65 6e 20 35 31 32 20 two between 512
13b30 61 6e 64 20 36 35 35 33 36 29 20 70 6c 75 73 20 and 65536) plus
13b40 73 6f 6d 65 20 65 78 74 72 61 20 62 79 74 65 73 some extra bytes
13b50 20 66 6f 72 20 65 61 63 68 0a 2a 2a 20 70 61 67 for each.** pag
13b60 65 20 68 65 61 64 65 72 2e 20 20 5e 54 68 65 20 e header. ^The
13b70 6e 75 6d 62 65 72 20 6f 66 20 65 78 74 72 61 20 number of extra
13b80 62 79 74 65 73 20 6e 65 65 64 65 64 20 62 79 20 bytes needed by
13b90 74 68 65 20 70 61 67 65 20 68 65 61 64 65 72 0a the page header.
13ba0 2a 2a 20 63 61 6e 20 62 65 20 64 65 74 65 72 6d ** can be determ
13bb0 69 6e 65 64 20 75 73 69 6e 67 20 5b 53 51 4c 49 ined using [SQLI
13bc0 54 45 5f 43 4f 4e 46 49 47 5f 50 43 41 43 48 45 TE_CONFIG_PCACHE
13bd0 5f 48 44 52 53 5a 5d 2e 0a 2a 2a 20 5e 49 74 20 _HDRSZ]..** ^It
13be0 69 73 20 68 61 72 6d 6c 65 73 73 2c 20 61 70 61 is harmless, apa
13bf0 72 74 20 66 72 6f 6d 20 74 68 65 20 77 61 73 74 rt from the wast
13c00 65 64 20 6d 65 6d 6f 72 79 2c 0a 2a 2a 20 66 6f ed memory,.** fo
13c10 72 20 74 68 65 20 73 7a 20 70 61 72 61 6d 65 74 r the sz paramet
13c20 65 72 20 74 6f 20 62 65 20 6c 61 72 67 65 72 20 er to be larger
13c30 74 68 61 6e 20 6e 65 63 65 73 73 61 72 79 2e 20 than necessary.
13c40 20 54 68 65 20 70 4d 65 6d 0a 2a 2a 20 61 72 67 The pMem.** arg
13c50 75 6d 65 6e 74 20 6d 75 73 74 20 62 65 20 65 69 ument must be ei
13c60 74 68 65 72 20 61 20 4e 55 4c 4c 20 70 6f 69 6e ther a NULL poin
13c70 74 65 72 20 6f 72 20 61 20 70 6f 69 6e 74 65 72 ter or a pointer
13c80 20 74 6f 20 61 6e 20 38 2d 62 79 74 65 0a 2a 2a to an 8-byte.**
13c90 20 61 6c 69 67 6e 65 64 20 62 6c 6f 63 6b 20 6f aligned block o
13ca0 66 20 6d 65 6d 6f 72 79 20 6f 66 20 61 74 20 6c f memory of at l
13cb0 65 61 73 74 20 73 7a 2a 4e 20 62 79 74 65 73 2c east sz*N bytes,
13cc0 20 6f 74 68 65 72 77 69 73 65 0a 2a 2a 20 73 75 otherwise.** su
13cd0 62 73 65 71 75 65 6e 74 20 62 65 68 61 76 69 6f bsequent behavio
13ce0 72 20 69 73 20 75 6e 64 65 66 69 6e 65 64 2e 0a r is undefined..
13cf0 2a 2a 20 5e 57 68 65 6e 20 70 4d 65 6d 20 69 73 ** ^When pMem is
13d00 20 6e 6f 74 20 4e 55 4c 4c 2c 20 53 51 4c 69 74 not NULL, SQLit
13d10 65 20 77 69 6c 6c 20 73 74 72 69 76 65 20 74 6f e will strive to
13d20 20 75 73 65 20 74 68 65 20 6d 65 6d 6f 72 79 20 use the memory
13d30 70 72 6f 76 69 64 65 64 0a 2a 2a 20 74 6f 20 73 provided.** to s
13d40 61 74 69 73 66 79 20 70 61 67 65 20 63 61 63 68 atisfy page cach
13d50 65 20 6e 65 65 64 73 2c 20 66 61 6c 6c 69 6e 67 e needs, falling
13d60 20 62 61 63 6b 20 74 6f 20 5b 73 71 6c 69 74 65 back to [sqlite
13d70 33 5f 6d 61 6c 6c 6f 63 28 29 5d 20 69 66 0a 2a 3_malloc()] if.*
13d80 2a 20 61 20 70 61 67 65 20 63 61 63 68 65 20 6c * a page cache l
13d90 69 6e 65 20 69 73 20 6c 61 72 67 65 72 20 74 68 ine is larger th
13da0 61 6e 20 73 7a 20 62 79 74 65 73 20 6f 72 20 69 an sz bytes or i
13db0 66 20 61 6c 6c 20 6f 66 20 74 68 65 20 70 4d 65 f all of the pMe
13dc0 6d 20 62 75 66 66 65 72 0a 2a 2a 20 69 73 20 65 m buffer.** is e
13dd0 78 68 61 75 73 74 65 64 2e 0a 2a 2a 20 5e 49 66 xhausted..** ^If
13de0 20 70 4d 65 6d 20 69 73 20 4e 55 4c 4c 20 61 6e pMem is NULL an
13df0 64 20 4e 20 69 73 20 6e 6f 6e 2d 7a 65 72 6f 2c d N is non-zero,
13e00 20 74 68 65 6e 20 65 61 63 68 20 64 61 74 61 62 then each datab
13e10 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 0a 2a ase connection.*
13e20 2a 20 64 6f 65 73 20 61 6e 20 69 6e 69 74 69 61 * does an initia
13e30 6c 20 62 75 6c 6b 20 61 6c 6c 6f 63 61 74 69 6f l bulk allocatio
13e40 6e 20 66 6f 72 20 70 61 67 65 20 63 61 63 68 65 n for page cache
13e50 20 6d 65 6d 6f 72 79 0a 2a 2a 20 66 72 6f 6d 20 memory.** from
13e60 5b 73 71 6c 69 74 65 33 5f 6d 61 6c 6c 6f 63 28 [sqlite3_malloc(
13e70 29 5d 20 73 75 66 66 69 63 69 65 6e 74 20 66 6f )] sufficient fo
13e80 72 20 4e 20 63 61 63 68 65 20 6c 69 6e 65 73 20 r N cache lines
13e90 69 66 20 4e 20 69 73 20 70 6f 73 69 74 69 76 65 if N is positive
13ea0 20 6f 72 0a 2a 2a 20 6f 66 20 2d 31 30 32 34 2a or.** of -1024*
13eb0 4e 20 62 79 74 65 73 20 69 66 20 4e 20 69 73 20 N bytes if N is
13ec0 6e 65 67 61 74 69 76 65 2c 20 2e 20 5e 49 66 20 negative, . ^If
13ed0 61 64 64 69 74 69 6f 6e 61 6c 0a 2a 2a 20 70 61 additional.** pa
13ee0 67 65 20 63 61 63 68 65 20 6d 65 6d 6f 72 79 20 ge cache memory
13ef0 69 73 20 6e 65 65 64 65 64 20 62 65 79 6f 6e 64 is needed beyond
13f00 20 77 68 61 74 20 69 73 20 70 72 6f 76 69 64 65 what is provide
13f10 64 20 62 79 20 74 68 65 20 69 6e 69 74 69 61 6c d by the initial
13f20 0a 2a 2a 20 61 6c 6c 6f 63 61 74 69 6f 6e 2c 20 .** allocation,
13f30 74 68 65 6e 20 53 51 4c 69 74 65 20 67 6f 65 73 then SQLite goes
13f40 20 74 6f 20 5b 73 71 6c 69 74 65 33 5f 6d 61 6c to [sqlite3_mal
13f50 6c 6f 63 28 29 5d 20 73 65 70 61 72 61 74 65 6c loc()] separatel
13f60 79 20 66 6f 72 20 65 61 63 68 0a 2a 2a 20 61 64 y for each.** ad
13f70 64 69 74 69 6f 6e 61 6c 20 63 61 63 68 65 20 6c ditional cache l
13f80 69 6e 65 2e 20 3c 2f 64 64 3e 0a 2a 2a 0a 2a 2a ine. </dd>.**.**
13f90 20 5b 5b 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 [[SQLITE_CONFIG
13fa0 5f 48 45 41 50 5d 5d 20 3c 64 74 3e 53 51 4c 49 _HEAP]] <dt>SQLI
13fb0 54 45 5f 43 4f 4e 46 49 47 5f 48 45 41 50 3c 2f TE_CONFIG_HEAP</
13fc0 64 74 3e 0a 2a 2a 20 3c 64 64 3e 20 5e 54 68 65 dt>.** <dd> ^The
13fd0 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 48 SQLITE_CONFIG_H
13fe0 45 41 50 20 6f 70 74 69 6f 6e 20 73 70 65 63 69 EAP option speci
13ff0 66 69 65 73 20 61 20 73 74 61 74 69 63 20 6d 65 fies a static me
14000 6d 6f 72 79 20 62 75 66 66 65 72 20 0a 2a 2a 20 mory buffer .**
14010 74 68 61 74 20 53 51 4c 69 74 65 20 77 69 6c 6c that SQLite will
14020 20 75 73 65 20 66 6f 72 20 61 6c 6c 20 6f 66 20 use for all of
14030 69 74 73 20 64 79 6e 61 6d 69 63 20 6d 65 6d 6f its dynamic memo
14040 72 79 20 61 6c 6c 6f 63 61 74 69 6f 6e 20 6e 65 ry allocation ne
14050 65 64 73 0a 2a 2a 20 62 65 79 6f 6e 64 20 74 68 eds.** beyond th
14060 6f 73 65 20 70 72 6f 76 69 64 65 64 20 66 6f 72 ose provided for
14070 20 62 79 20 5b 53 51 4c 49 54 45 5f 43 4f 4e 46 by [SQLITE_CONF
14080 49 47 5f 53 43 52 41 54 43 48 5d 20 61 6e 64 0a IG_SCRATCH] and.
14090 2a 2a 20 5b 53 51 4c 49 54 45 5f 43 4f 4e 46 49 ** [SQLITE_CONFI
140a0 47 5f 50 41 47 45 43 41 43 48 45 5d 2e 0a 2a 2a G_PAGECACHE]..**
140b0 20 5e 54 68 65 20 53 51 4c 49 54 45 5f 43 4f 4e ^The SQLITE_CON
140c0 46 49 47 5f 48 45 41 50 20 6f 70 74 69 6f 6e 20 FIG_HEAP option
140d0 69 73 20 6f 6e 6c 79 20 61 76 61 69 6c 61 62 6c is only availabl
140e0 65 20 69 66 20 53 51 4c 69 74 65 20 69 73 20 63 e if SQLite is c
140f0 6f 6d 70 69 6c 65 64 0a 2a 2a 20 77 69 74 68 20 ompiled.** with
14100 65 69 74 68 65 72 20 5b 53 51 4c 49 54 45 5f 45 either [SQLITE_E
14110 4e 41 42 4c 45 5f 4d 45 4d 53 59 53 33 5d 20 6f NABLE_MEMSYS3] o
14120 72 20 5b 53 51 4c 49 54 45 5f 45 4e 41 42 4c 45 r [SQLITE_ENABLE
14130 5f 4d 45 4d 53 59 53 35 5d 20 61 6e 64 20 72 65 _MEMSYS5] and re
14140 74 75 72 6e 73 0a 2a 2a 20 5b 53 51 4c 49 54 45 turns.** [SQLITE
14150 5f 45 52 52 4f 52 5d 20 69 66 20 69 6e 76 6f 6b _ERROR] if invok
14160 65 64 20 6f 74 68 65 72 77 69 73 65 2e 0a 2a 2a ed otherwise..**
14170 20 5e 54 68 65 72 65 20 61 72 65 20 74 68 72 65 ^There are thre
14180 65 20 61 72 67 75 6d 65 6e 74 73 20 74 6f 20 53 e arguments to S
14190 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 48 45 41 QLITE_CONFIG_HEA
141a0 50 3a 0a 2a 2a 20 41 6e 20 38 2d 62 79 74 65 20 P:.** An 8-byte
141b0 61 6c 69 67 6e 65 64 20 70 6f 69 6e 74 65 72 20 aligned pointer
141c0 74 6f 20 74 68 65 20 6d 65 6d 6f 72 79 2c 0a 2a to the memory,.*
141d0 2a 20 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 * the number of
141e0 62 79 74 65 73 20 69 6e 20 74 68 65 20 6d 65 6d bytes in the mem
141f0 6f 72 79 20 62 75 66 66 65 72 2c 20 61 6e 64 20 ory buffer, and
14200 74 68 65 20 6d 69 6e 69 6d 75 6d 20 61 6c 6c 6f the minimum allo
14210 63 61 74 69 6f 6e 20 73 69 7a 65 2e 0a 2a 2a 20 cation size..**
14220 5e 49 66 20 74 68 65 20 66 69 72 73 74 20 70 6f ^If the first po
14230 69 6e 74 65 72 20 28 74 68 65 20 6d 65 6d 6f 72 inter (the memor
14240 79 20 70 6f 69 6e 74 65 72 29 20 69 73 20 4e 55 y pointer) is NU
14250 4c 4c 2c 20 74 68 65 6e 20 53 51 4c 69 74 65 20 LL, then SQLite
14260 72 65 76 65 72 74 73 0a 2a 2a 20 74 6f 20 75 73 reverts.** to us
14270 69 6e 67 20 69 74 73 20 64 65 66 61 75 6c 74 20 ing its default
14280 6d 65 6d 6f 72 79 20 61 6c 6c 6f 63 61 74 6f 72 memory allocator
14290 20 28 74 68 65 20 73 79 73 74 65 6d 20 6d 61 6c (the system mal
142a0 6c 6f 63 28 29 20 69 6d 70 6c 65 6d 65 6e 74 61 loc() implementa
142b0 74 69 6f 6e 29 2c 0a 2a 2a 20 75 6e 64 6f 69 6e tion),.** undoin
142c0 67 20 61 6e 79 20 70 72 69 6f 72 20 69 6e 76 6f g any prior invo
142d0 63 61 74 69 6f 6e 20 6f 66 20 5b 53 51 4c 49 54 cation of [SQLIT
142e0 45 5f 43 4f 4e 46 49 47 5f 4d 41 4c 4c 4f 43 5d E_CONFIG_MALLOC]
142f0 2e 20 20 5e 49 66 20 74 68 65 0a 2a 2a 20 6d 65 . ^If the.** me
14300 6d 6f 72 79 20 70 6f 69 6e 74 65 72 20 69 73 20 mory pointer is
14310 6e 6f 74 20 4e 55 4c 4c 20 74 68 65 6e 20 74 68 not NULL then th
14320 65 20 61 6c 74 65 72 6e 61 74 69 76 65 20 6d 65 e alternative me
14330 6d 6f 72 79 0a 2a 2a 20 61 6c 6c 6f 63 61 74 6f mory.** allocato
14340 72 20 69 73 20 65 6e 67 61 67 65 64 20 74 6f 20 r is engaged to
14350 68 61 6e 64 6c 65 20 61 6c 6c 20 6f 66 20 53 51 handle all of SQ
14360 4c 69 74 65 73 20 6d 65 6d 6f 72 79 20 61 6c 6c Lites memory all
14370 6f 63 61 74 69 6f 6e 20 6e 65 65 64 73 2e 0a 2a ocation needs..*
14380 2a 20 54 68 65 20 66 69 72 73 74 20 70 6f 69 6e * The first poin
14390 74 65 72 20 28 74 68 65 20 6d 65 6d 6f 72 79 20 ter (the memory
143a0 70 6f 69 6e 74 65 72 29 20 6d 75 73 74 20 62 65 pointer) must be
143b0 20 61 6c 69 67 6e 65 64 20 74 6f 20 61 6e 20 38 aligned to an 8
143c0 2d 62 79 74 65 0a 2a 2a 20 62 6f 75 6e 64 61 72 -byte.** boundar
143d0 79 20 6f 72 20 73 75 62 73 65 71 75 65 6e 74 20 y or subsequent
143e0 62 65 68 61 76 69 6f 72 20 6f 66 20 53 51 4c 69 behavior of SQLi
143f0 74 65 20 77 69 6c 6c 20 62 65 20 75 6e 64 65 66 te will be undef
14400 69 6e 65 64 2e 0a 2a 2a 20 54 68 65 20 6d 69 6e ined..** The min
14410 69 6d 75 6d 20 61 6c 6c 6f 63 61 74 69 6f 6e 20 imum allocation
14420 73 69 7a 65 20 69 73 20 63 61 70 70 65 64 20 61 size is capped a
14430 74 20 32 2a 2a 31 32 2e 20 52 65 61 73 6f 6e 61 t 2**12. Reasona
14440 62 6c 65 20 76 61 6c 75 65 73 0a 2a 2a 20 66 6f ble values.** fo
14450 72 20 74 68 65 20 6d 69 6e 69 6d 75 6d 20 61 6c r the minimum al
14460 6c 6f 63 61 74 69 6f 6e 20 73 69 7a 65 20 61 72 location size ar
14470 65 20 32 2a 2a 35 20 74 68 72 6f 75 67 68 20 32 e 2**5 through 2
14480 2a 2a 38 2e 3c 2f 64 64 3e 0a 2a 2a 0a 2a 2a 20 **8.</dd>.**.**
14490 5b 5b 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f [[SQLITE_CONFIG_
144a0 4d 55 54 45 58 5d 5d 20 3c 64 74 3e 53 51 4c 49 MUTEX]] <dt>SQLI
144b0 54 45 5f 43 4f 4e 46 49 47 5f 4d 55 54 45 58 3c TE_CONFIG_MUTEX<
144c0 2f 64 74 3e 0a 2a 2a 20 3c 64 64 3e 20 5e 28 54 /dt>.** <dd> ^(T
144d0 68 65 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 he SQLITE_CONFIG
144e0 5f 4d 55 54 45 58 20 6f 70 74 69 6f 6e 20 74 61 _MUTEX option ta
144f0 6b 65 73 20 61 20 73 69 6e 67 6c 65 20 61 72 67 kes a single arg
14500 75 6d 65 6e 74 20 77 68 69 63 68 20 69 73 20 61 ument which is a
14510 0a 2a 2a 20 70 6f 69 6e 74 65 72 20 74 6f 20 61 .** pointer to a
14520 6e 20 69 6e 73 74 61 6e 63 65 20 6f 66 20 74 68 n instance of th
14530 65 20 5b 73 71 6c 69 74 65 33 5f 6d 75 74 65 78 e [sqlite3_mutex
14540 5f 6d 65 74 68 6f 64 73 5d 20 73 74 72 75 63 74 _methods] struct
14550 75 72 65 2e 0a 2a 2a 20 54 68 65 20 61 72 67 75 ure..** The argu
14560 6d 65 6e 74 20 73 70 65 63 69 66 69 65 73 20 61 ment specifies a
14570 6c 74 65 72 6e 61 74 69 76 65 20 6c 6f 77 2d 6c lternative low-l
14580 65 76 65 6c 20 6d 75 74 65 78 20 72 6f 75 74 69 evel mutex routi
14590 6e 65 73 20 74 6f 20 62 65 20 75 73 65 64 0a 2a nes to be used.*
145a0 2a 20 69 6e 20 70 6c 61 63 65 20 74 68 65 20 6d * in place the m
145b0 75 74 65 78 20 72 6f 75 74 69 6e 65 73 20 62 75 utex routines bu
145c0 69 6c 74 20 69 6e 74 6f 20 53 51 4c 69 74 65 2e ilt into SQLite.
145d0 29 5e 20 20 5e 53 51 4c 69 74 65 20 6d 61 6b 65 )^ ^SQLite make
145e0 73 20 61 20 63 6f 70 79 20 6f 66 0a 2a 2a 20 74 s a copy of.** t
145f0 68 65 20 63 6f 6e 74 65 6e 74 20 6f 66 20 74 68 he content of th
14600 65 20 5b 73 71 6c 69 74 65 33 5f 6d 75 74 65 78 e [sqlite3_mutex
14610 5f 6d 65 74 68 6f 64 73 5d 20 73 74 72 75 63 74 _methods] struct
14620 75 72 65 20 62 65 66 6f 72 65 20 74 68 65 20 63 ure before the c
14630 61 6c 6c 20 74 6f 0a 2a 2a 20 5b 73 71 6c 69 74 all to.** [sqlit
14640 65 33 5f 63 6f 6e 66 69 67 28 29 5d 20 72 65 74 e3_config()] ret
14650 75 72 6e 73 2e 20 5e 49 66 20 53 51 4c 69 74 65 urns. ^If SQLite
14660 20 69 73 20 63 6f 6d 70 69 6c 65 64 20 77 69 74 is compiled wit
14670 68 0a 2a 2a 20 74 68 65 20 5b 53 51 4c 49 54 45 h.** the [SQLITE
14680 5f 54 48 52 45 41 44 53 41 46 45 20 7c 20 53 51 _THREADSAFE | SQ
14690 4c 49 54 45 5f 54 48 52 45 41 44 53 41 46 45 3d LITE_THREADSAFE=
146a0 30 5d 20 63 6f 6d 70 69 6c 65 2d 74 69 6d 65 20 0] compile-time
146b0 6f 70 74 69 6f 6e 20 74 68 65 6e 0a 2a 2a 20 74 option then.** t
146c0 68 65 20 65 6e 74 69 72 65 20 6d 75 74 65 78 69 he entire mutexi
146d0 6e 67 20 73 75 62 73 79 73 74 65 6d 20 69 73 20 ng subsystem is
146e0 6f 6d 69 74 74 65 64 20 66 72 6f 6d 20 74 68 65 omitted from the
146f0 20 62 75 69 6c 64 20 61 6e 64 20 68 65 6e 63 65 build and hence
14700 20 63 61 6c 6c 73 20 74 6f 0a 2a 2a 20 5b 73 71 calls to.** [sq
14710 6c 69 74 65 33 5f 63 6f 6e 66 69 67 28 29 5d 20 lite3_config()]
14720 77 69 74 68 20 74 68 65 20 53 51 4c 49 54 45 5f with the SQLITE_
14730 43 4f 4e 46 49 47 5f 4d 55 54 45 58 20 63 6f 6e CONFIG_MUTEX con
14740 66 69 67 75 72 61 74 69 6f 6e 20 6f 70 74 69 6f figuration optio
14750 6e 20 77 69 6c 6c 0a 2a 2a 20 72 65 74 75 72 6e n will.** return
14760 20 5b 53 51 4c 49 54 45 5f 45 52 52 4f 52 5d 2e [SQLITE_ERROR].
14770 3c 2f 64 64 3e 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 </dd>.**.** [[SQ
14780 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 47 45 54 4d LITE_CONFIG_GETM
14790 55 54 45 58 5d 5d 20 3c 64 74 3e 53 51 4c 49 54 UTEX]] <dt>SQLIT
147a0 45 5f 43 4f 4e 46 49 47 5f 47 45 54 4d 55 54 45 E_CONFIG_GETMUTE
147b0 58 3c 2f 64 74 3e 0a 2a 2a 20 3c 64 64 3e 20 5e X</dt>.** <dd> ^
147c0 28 54 68 65 20 53 51 4c 49 54 45 5f 43 4f 4e 46 (The SQLITE_CONF
147d0 49 47 5f 47 45 54 4d 55 54 45 58 20 6f 70 74 69 IG_GETMUTEX opti
147e0 6f 6e 20 74 61 6b 65 73 20 61 20 73 69 6e 67 6c on takes a singl
147f0 65 20 61 72 67 75 6d 65 6e 74 20 77 68 69 63 68 e argument which
14800 0a 2a 2a 20 69 73 20 61 20 70 6f 69 6e 74 65 72 .** is a pointer
14810 20 74 6f 20 61 6e 20 69 6e 73 74 61 6e 63 65 20 to an instance
14820 6f 66 20 74 68 65 20 5b 73 71 6c 69 74 65 33 5f of the [sqlite3_
14830 6d 75 74 65 78 5f 6d 65 74 68 6f 64 73 5d 20 73 mutex_methods] s
14840 74 72 75 63 74 75 72 65 2e 20 20 54 68 65 0a 2a tructure. The.*
14850 2a 20 5b 73 71 6c 69 74 65 33 5f 6d 75 74 65 78 * [sqlite3_mutex
14860 5f 6d 65 74 68 6f 64 73 5d 0a 2a 2a 20 73 74 72 _methods].** str
14870 75 63 74 75 72 65 20 69 73 20 66 69 6c 6c 65 64 ucture is filled
14880 20 77 69 74 68 20 74 68 65 20 63 75 72 72 65 6e with the curren
14890 74 6c 79 20 64 65 66 69 6e 65 64 20 6d 75 74 65 tly defined mute
148a0 78 20 72 6f 75 74 69 6e 65 73 2e 29 5e 0a 2a 2a x routines.)^.**
148b0 20 54 68 69 73 20 6f 70 74 69 6f 6e 20 63 61 6e This option can
148c0 20 62 65 20 75 73 65 64 20 74 6f 20 6f 76 65 72 be used to over
148d0 6c 6f 61 64 20 74 68 65 20 64 65 66 61 75 6c 74 load the default
148e0 20 6d 75 74 65 78 20 61 6c 6c 6f 63 61 74 69 6f mutex allocatio
148f0 6e 0a 2a 2a 20 72 6f 75 74 69 6e 65 73 20 77 69 n.** routines wi
14900 74 68 20 61 20 77 72 61 70 70 65 72 20 75 73 65 th a wrapper use
14910 64 20 74 6f 20 74 72 61 63 6b 20 6d 75 74 65 78 d to track mutex
14920 20 75 73 61 67 65 20 66 6f 72 20 70 65 72 66 6f usage for perfo
14930 72 6d 61 6e 63 65 0a 2a 2a 20 70 72 6f 66 69 6c rmance.** profil
14940 69 6e 67 20 6f 72 20 74 65 73 74 69 6e 67 2c 20 ing or testing,
14950 66 6f 72 20 65 78 61 6d 70 6c 65 2e 20 20 20 5e for example. ^
14960 49 66 20 53 51 4c 69 74 65 20 69 73 20 63 6f 6d If SQLite is com
14970 70 69 6c 65 64 20 77 69 74 68 0a 2a 2a 20 74 68 piled with.** th
14980 65 20 5b 53 51 4c 49 54 45 5f 54 48 52 45 41 44 e [SQLITE_THREAD
14990 53 41 46 45 20 7c 20 53 51 4c 49 54 45 5f 54 48 SAFE | SQLITE_TH
149a0 52 45 41 44 53 41 46 45 3d 30 5d 20 63 6f 6d 70 READSAFE=0] comp
149b0 69 6c 65 2d 74 69 6d 65 20 6f 70 74 69 6f 6e 20 ile-time option
149c0 74 68 65 6e 0a 2a 2a 20 74 68 65 20 65 6e 74 69 then.** the enti
149d0 72 65 20 6d 75 74 65 78 69 6e 67 20 73 75 62 73 re mutexing subs
149e0 79 73 74 65 6d 20 69 73 20 6f 6d 69 74 74 65 64 ystem is omitted
149f0 20 66 72 6f 6d 20 74 68 65 20 62 75 69 6c 64 20 from the build
14a00 61 6e 64 20 68 65 6e 63 65 20 63 61 6c 6c 73 20 and hence calls
14a10 74 6f 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 63 to.** [sqlite3_c
14a20 6f 6e 66 69 67 28 29 5d 20 77 69 74 68 20 74 68 onfig()] with th
14a30 65 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f e SQLITE_CONFIG_
14a40 47 45 54 4d 55 54 45 58 20 63 6f 6e 66 69 67 75 GETMUTEX configu
14a50 72 61 74 69 6f 6e 20 6f 70 74 69 6f 6e 20 77 69 ration option wi
14a60 6c 6c 0a 2a 2a 20 72 65 74 75 72 6e 20 5b 53 51 ll.** return [SQ
14a70 4c 49 54 45 5f 45 52 52 4f 52 5d 2e 3c 2f 64 64 LITE_ERROR].</dd
14a80 3e 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 4c 49 54 45 >.**.** [[SQLITE
14a90 5f 43 4f 4e 46 49 47 5f 4c 4f 4f 4b 41 53 49 44 _CONFIG_LOOKASID
14aa0 45 5d 5d 20 3c 64 74 3e 53 51 4c 49 54 45 5f 43 E]] <dt>SQLITE_C
14ab0 4f 4e 46 49 47 5f 4c 4f 4f 4b 41 53 49 44 45 3c ONFIG_LOOKASIDE<
14ac0 2f 64 74 3e 0a 2a 2a 20 3c 64 64 3e 20 5e 28 54 /dt>.** <dd> ^(T
14ad0 68 65 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 he SQLITE_CONFIG
14ae0 5f 4c 4f 4f 4b 41 53 49 44 45 20 6f 70 74 69 6f _LOOKASIDE optio
14af0 6e 20 74 61 6b 65 73 20 74 77 6f 20 61 72 67 75 n takes two argu
14b00 6d 65 6e 74 73 20 74 68 61 74 20 64 65 74 65 72 ments that deter
14b10 6d 69 6e 65 0a 2a 2a 20 74 68 65 20 64 65 66 61 mine.** the defa
14b20 75 6c 74 20 73 69 7a 65 20 6f 66 20 6c 6f 6f 6b ult size of look
14b30 61 73 69 64 65 20 6d 65 6d 6f 72 79 20 6f 6e 20 aside memory on
14b40 65 61 63 68 20 5b 64 61 74 61 62 61 73 65 20 63 each [database c
14b50 6f 6e 6e 65 63 74 69 6f 6e 5d 2e 0a 2a 2a 20 54 onnection]..** T
14b60 68 65 20 66 69 72 73 74 20 61 72 67 75 6d 65 6e he first argumen
14b70 74 20 69 73 20 74 68 65 0a 2a 2a 20 73 69 7a 65 t is the.** size
14b80 20 6f 66 20 65 61 63 68 20 6c 6f 6f 6b 61 73 69 of each lookasi
14b90 64 65 20 62 75 66 66 65 72 20 73 6c 6f 74 20 61 de buffer slot a
14ba0 6e 64 20 74 68 65 20 73 65 63 6f 6e 64 20 69 73 nd the second is
14bb0 20 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 0a 2a the number of.*
14bc0 2a 20 73 6c 6f 74 73 20 61 6c 6c 6f 63 61 74 65 * slots allocate
14bd0 64 20 74 6f 20 65 61 63 68 20 64 61 74 61 62 61 d to each databa
14be0 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 2e 29 5e se connection.)^
14bf0 20 20 5e 28 53 51 4c 49 54 45 5f 43 4f 4e 46 49 ^(SQLITE_CONFI
14c00 47 5f 4c 4f 4f 4b 41 53 49 44 45 0a 2a 2a 20 73 G_LOOKASIDE.** s
14c10 65 74 73 20 74 68 65 20 3c 69 3e 64 65 66 61 75 ets the <i>defau
14c20 6c 74 3c 2f 69 3e 20 6c 6f 6f 6b 61 73 69 64 65 lt</i> lookaside
14c30 20 73 69 7a 65 2e 20 54 68 65 20 5b 53 51 4c 49 size. The [SQLI
14c40 54 45 5f 44 42 43 4f 4e 46 49 47 5f 4c 4f 4f 4b TE_DBCONFIG_LOOK
14c50 41 53 49 44 45 5d 0a 2a 2a 20 6f 70 74 69 6f 6e ASIDE].** option
14c60 20 74 6f 20 5b 73 71 6c 69 74 65 33 5f 64 62 5f to [sqlite3_db_
14c70 63 6f 6e 66 69 67 28 29 5d 20 63 61 6e 20 62 65 config()] can be
14c80 20 75 73 65 64 20 74 6f 20 63 68 61 6e 67 65 20 used to change
14c90 74 68 65 20 6c 6f 6f 6b 61 73 69 64 65 0a 2a 2a the lookaside.**
14ca0 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 6f configuration o
14cb0 6e 20 69 6e 64 69 76 69 64 75 61 6c 20 63 6f 6e n individual con
14cc0 6e 65 63 74 69 6f 6e 73 2e 29 5e 20 3c 2f 64 64 nections.)^ </dd
14cd0 3e 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 4c 49 54 45 >.**.** [[SQLITE
14ce0 5f 43 4f 4e 46 49 47 5f 50 43 41 43 48 45 32 5d _CONFIG_PCACHE2]
14cf0 5d 20 3c 64 74 3e 53 51 4c 49 54 45 5f 43 4f 4e ] <dt>SQLITE_CON
14d00 46 49 47 5f 50 43 41 43 48 45 32 3c 2f 64 74 3e FIG_PCACHE2</dt>
14d10 0a 2a 2a 20 3c 64 64 3e 20 5e 28 54 68 65 20 53 .** <dd> ^(The S
14d20 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 50 43 41 QLITE_CONFIG_PCA
14d30 43 48 45 32 20 6f 70 74 69 6f 6e 20 74 61 6b 65 CHE2 option take
14d40 73 20 61 20 73 69 6e 67 6c 65 20 61 72 67 75 6d s a single argum
14d50 65 6e 74 20 77 68 69 63 68 20 69 73 20 0a 2a 2a ent which is .**
14d60 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 61 6e a pointer to an
14d70 20 5b 73 71 6c 69 74 65 33 5f 70 63 61 63 68 65 [sqlite3_pcache
14d80 5f 6d 65 74 68 6f 64 73 32 5d 20 6f 62 6a 65 63 _methods2] objec
14d90 74 2e 20 20 54 68 69 73 20 6f 62 6a 65 63 74 20 t. This object
14da0 73 70 65 63 69 66 69 65 73 0a 2a 2a 20 74 68 65 specifies.** the
14db0 20 69 6e 74 65 72 66 61 63 65 20 74 6f 20 61 20 interface to a
14dc0 63 75 73 74 6f 6d 20 70 61 67 65 20 63 61 63 68 custom page cach
14dd0 65 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e e implementation
14de0 2e 29 5e 0a 2a 2a 20 5e 53 51 4c 69 74 65 20 6d .)^.** ^SQLite m
14df0 61 6b 65 73 20 61 20 63 6f 70 79 20 6f 66 20 74 akes a copy of t
14e00 68 65 20 5b 73 71 6c 69 74 65 33 5f 70 63 61 63 he [sqlite3_pcac
14e10 68 65 5f 6d 65 74 68 6f 64 73 32 5d 20 6f 62 6a he_methods2] obj
14e20 65 63 74 2e 3c 2f 64 64 3e 0a 2a 2a 0a 2a 2a 20 ect.</dd>.**.**
14e30 5b 5b 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f [[SQLITE_CONFIG_
14e40 47 45 54 50 43 41 43 48 45 32 5d 5d 20 3c 64 74 GETPCACHE2]] <dt
14e50 3e 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 47 >SQLITE_CONFIG_G
14e60 45 54 50 43 41 43 48 45 32 3c 2f 64 74 3e 0a 2a ETPCACHE2</dt>.*
14e70 2a 20 3c 64 64 3e 20 5e 28 54 68 65 20 53 51 4c * <dd> ^(The SQL
14e80 49 54 45 5f 43 4f 4e 46 49 47 5f 47 45 54 50 43 ITE_CONFIG_GETPC
14e90 41 43 48 45 32 20 6f 70 74 69 6f 6e 20 74 61 6b ACHE2 option tak
14ea0 65 73 20 61 20 73 69 6e 67 6c 65 20 61 72 67 75 es a single argu
14eb0 6d 65 6e 74 20 77 68 69 63 68 0a 2a 2a 20 69 73 ment which.** is
14ec0 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 61 6e a pointer to an
14ed0 20 5b 73 71 6c 69 74 65 33 5f 70 63 61 63 68 65 [sqlite3_pcache
14ee0 5f 6d 65 74 68 6f 64 73 32 5d 20 6f 62 6a 65 63 _methods2] objec
14ef0 74 2e 20 20 53 51 4c 69 74 65 20 63 6f 70 69 65 t. SQLite copie
14f00 73 20 6f 66 0a 2a 2a 20 74 68 65 20 63 75 72 72 s of.** the curr
14f10 65 6e 74 20 70 61 67 65 20 63 61 63 68 65 20 69 ent page cache i
14f20 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 69 6e mplementation in
14f30 74 6f 20 74 68 61 74 20 6f 62 6a 65 63 74 2e 29 to that object.)
14f40 5e 20 3c 2f 64 64 3e 0a 2a 2a 0a 2a 2a 20 5b 5b ^ </dd>.**.** [[
14f50 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 4c 4f SQLITE_CONFIG_LO
14f60 47 5d 5d 20 3c 64 74 3e 53 51 4c 49 54 45 5f 43 G]] <dt>SQLITE_C
14f70 4f 4e 46 49 47 5f 4c 4f 47 3c 2f 64 74 3e 0a 2a ONFIG_LOG</dt>.*
14f80 2a 20 3c 64 64 3e 20 54 68 65 20 53 51 4c 49 54 * <dd> The SQLIT
14f90 45 5f 43 4f 4e 46 49 47 5f 4c 4f 47 20 6f 70 74 E_CONFIG_LOG opt
14fa0 69 6f 6e 20 69 73 20 75 73 65 64 20 74 6f 20 63 ion is used to c
14fb0 6f 6e 66 69 67 75 72 65 20 74 68 65 20 53 51 4c onfigure the SQL
14fc0 69 74 65 0a 2a 2a 20 67 6c 6f 62 61 6c 20 5b 65 ite.** global [e
14fd0 72 72 6f 72 20 6c 6f 67 5d 2e 0a 2a 2a 20 28 5e rror log]..** (^
14fe0 54 68 65 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 The SQLITE_CONFI
14ff0 47 5f 4c 4f 47 20 6f 70 74 69 6f 6e 20 74 61 6b G_LOG option tak
15000 65 73 20 74 77 6f 20 61 72 67 75 6d 65 6e 74 73 es two arguments
15010 3a 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 61 : a pointer to a
15020 0a 2a 2a 20 66 75 6e 63 74 69 6f 6e 20 77 69 74 .** function wit
15030 68 20 61 20 63 61 6c 6c 20 73 69 67 6e 61 74 75 h a call signatu
15040 72 65 20 6f 66 20 76 6f 69 64 28 2a 29 28 76 6f re of void(*)(vo
15050 69 64 2a 2c 69 6e 74 2c 63 6f 6e 73 74 20 63 68 id*,int,const ch
15060 61 72 2a 29 2c 20 0a 2a 2a 20 61 6e 64 20 61 20 ar*), .** and a
15070 70 6f 69 6e 74 65 72 20 74 6f 20 76 6f 69 64 2e pointer to void.
15080 20 5e 49 66 20 74 68 65 20 66 75 6e 63 74 69 6f ^If the functio
15090 6e 20 70 6f 69 6e 74 65 72 20 69 73 20 6e 6f 74 n pointer is not
150a0 20 4e 55 4c 4c 2c 20 69 74 20 69 73 0a 2a 2a 20 NULL, it is.**
150b0 69 6e 76 6f 6b 65 64 20 62 79 20 5b 73 71 6c 69 invoked by [sqli
150c0 74 65 33 5f 6c 6f 67 28 29 5d 20 74 6f 20 70 72 te3_log()] to pr
150d0 6f 63 65 73 73 20 65 61 63 68 20 6c 6f 67 67 69 ocess each loggi
150e0 6e 67 20 65 76 65 6e 74 2e 20 20 5e 49 66 20 74 ng event. ^If t
150f0 68 65 0a 2a 2a 20 66 75 6e 63 74 69 6f 6e 20 70 he.** function p
15100 6f 69 6e 74 65 72 20 69 73 20 4e 55 4c 4c 2c 20 ointer is NULL,
15110 74 68 65 20 5b 73 71 6c 69 74 65 33 5f 6c 6f 67 the [sqlite3_log
15120 28 29 5d 20 69 6e 74 65 72 66 61 63 65 20 62 65 ()] interface be
15130 63 6f 6d 65 73 20 61 20 6e 6f 2d 6f 70 2e 0a 2a comes a no-op..*
15140 2a 20 5e 54 68 65 20 76 6f 69 64 20 70 6f 69 6e * ^The void poin
15150 74 65 72 20 74 68 61 74 20 69 73 20 74 68 65 20 ter that is the
15160 73 65 63 6f 6e 64 20 61 72 67 75 6d 65 6e 74 20 second argument
15170 74 6f 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 to SQLITE_CONFIG
15180 5f 4c 4f 47 20 69 73 0a 2a 2a 20 70 61 73 73 65 _LOG is.** passe
15190 64 20 74 68 72 6f 75 67 68 20 61 73 20 74 68 65 d through as the
151a0 20 66 69 72 73 74 20 70 61 72 61 6d 65 74 65 72 first parameter
151b0 20 74 6f 20 74 68 65 20 61 70 70 6c 69 63 61 74 to the applicat
151c0 69 6f 6e 2d 64 65 66 69 6e 65 64 20 6c 6f 67 67 ion-defined logg
151d0 65 72 0a 2a 2a 20 66 75 6e 63 74 69 6f 6e 20 77 er.** function w
151e0 68 65 6e 65 76 65 72 20 74 68 61 74 20 66 75 6e henever that fun
151f0 63 74 69 6f 6e 20 69 73 20 69 6e 76 6f 6b 65 64 ction is invoked
15200 2e 20 20 5e 54 68 65 20 73 65 63 6f 6e 64 20 70 . ^The second p
15210 61 72 61 6d 65 74 65 72 20 74 6f 0a 2a 2a 20 74 arameter to.** t
15220 68 65 20 6c 6f 67 67 65 72 20 66 75 6e 63 74 69 he logger functi
15230 6f 6e 20 69 73 20 61 20 63 6f 70 79 20 6f 66 20 on is a copy of
15240 74 68 65 20 66 69 72 73 74 20 70 61 72 61 6d 65 the first parame
15250 74 65 72 20 74 6f 20 74 68 65 20 63 6f 72 72 65 ter to the corre
15260 73 70 6f 6e 64 69 6e 67 0a 2a 2a 20 5b 73 71 6c sponding.** [sql
15270 69 74 65 33 5f 6c 6f 67 28 29 5d 20 63 61 6c 6c ite3_log()] call
15280 20 61 6e 64 20 69 73 20 69 6e 74 65 6e 64 65 64 and is intended
15290 20 74 6f 20 62 65 20 61 20 5b 72 65 73 75 6c 74 to be a [result
152a0 20 63 6f 64 65 5d 20 6f 72 20 61 6e 0a 2a 2a 20 code] or an.**
152b0 5b 65 78 74 65 6e 64 65 64 20 72 65 73 75 6c 74 [extended result
152c0 20 63 6f 64 65 5d 2e 20 20 5e 54 68 65 20 74 68 code]. ^The th
152d0 69 72 64 20 70 61 72 61 6d 65 74 65 72 20 70 61 ird parameter pa
152e0 73 73 65 64 20 74 6f 20 74 68 65 20 6c 6f 67 67 ssed to the logg
152f0 65 72 20 69 73 0a 2a 2a 20 6c 6f 67 20 6d 65 73 er is.** log mes
15300 73 61 67 65 20 61 66 74 65 72 20 66 6f 72 6d 61 sage after forma
15310 74 74 69 6e 67 20 76 69 61 20 5b 73 71 6c 69 74 tting via [sqlit
15320 65 33 5f 73 6e 70 72 69 6e 74 66 28 29 5d 2e 0a e3_snprintf()]..
15330 2a 2a 20 54 68 65 20 53 51 4c 69 74 65 20 6c 6f ** The SQLite lo
15340 67 67 69 6e 67 20 69 6e 74 65 72 66 61 63 65 20 gging interface
15350 69 73 20 6e 6f 74 20 72 65 65 6e 74 72 61 6e 74 is not reentrant
15360 3b 20 74 68 65 20 6c 6f 67 67 65 72 20 66 75 6e ; the logger fun
15370 63 74 69 6f 6e 0a 2a 2a 20 73 75 70 70 6c 69 65 ction.** supplie
15380 64 20 62 79 20 74 68 65 20 61 70 70 6c 69 63 61 d by the applica
15390 74 69 6f 6e 20 6d 75 73 74 20 6e 6f 74 20 69 6e tion must not in
153a0 76 6f 6b 65 20 61 6e 79 20 53 51 4c 69 74 65 20 voke any SQLite
153b0 69 6e 74 65 72 66 61 63 65 2e 0a 2a 2a 20 49 6e interface..** In
153c0 20 61 20 6d 75 6c 74 69 2d 74 68 72 65 61 64 65 a multi-threade
153d0 64 20 61 70 70 6c 69 63 61 74 69 6f 6e 2c 20 74 d application, t
153e0 68 65 20 61 70 70 6c 69 63 61 74 69 6f 6e 2d 64 he application-d
153f0 65 66 69 6e 65 64 20 6c 6f 67 67 65 72 0a 2a 2a efined logger.**
15400 20 66 75 6e 63 74 69 6f 6e 20 6d 75 73 74 20 62 function must b
15410 65 20 74 68 72 65 61 64 73 61 66 65 2e 20 3c 2f e threadsafe. </
15420 64 64 3e 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 4c 49 dd>.**.** [[SQLI
15430 54 45 5f 43 4f 4e 46 49 47 5f 55 52 49 5d 5d 20 TE_CONFIG_URI]]
15440 3c 64 74 3e 53 51 4c 49 54 45 5f 43 4f 4e 46 49 <dt>SQLITE_CONFI
15450 47 5f 55 52 49 0a 2a 2a 20 3c 64 64 3e 5e 28 54 G_URI.** <dd>^(T
15460 68 65 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 he SQLITE_CONFIG
15470 5f 55 52 49 20 6f 70 74 69 6f 6e 20 74 61 6b 65 _URI option take
15480 73 20 61 20 73 69 6e 67 6c 65 20 61 72 67 75 6d s a single argum
15490 65 6e 74 20 6f 66 20 74 79 70 65 20 69 6e 74 2e ent of type int.
154a0 0a 2a 2a 20 49 66 20 6e 6f 6e 2d 7a 65 72 6f 2c .** If non-zero,
154b0 20 74 68 65 6e 20 55 52 49 20 68 61 6e 64 6c 69 then URI handli
154c0 6e 67 20 69 73 20 67 6c 6f 62 61 6c 6c 79 20 65 ng is globally e
154d0 6e 61 62 6c 65 64 2e 20 49 66 20 74 68 65 20 70 nabled. If the p
154e0 61 72 61 6d 65 74 65 72 20 69 73 20 7a 65 72 6f arameter is zero
154f0 2c 0a 2a 2a 20 74 68 65 6e 20 55 52 49 20 68 61 ,.** then URI ha
15500 6e 64 6c 69 6e 67 20 69 73 20 67 6c 6f 62 61 6c ndling is global
15510 6c 79 20 64 69 73 61 62 6c 65 64 2e 29 5e 20 5e ly disabled.)^ ^
15520 49 66 20 55 52 49 20 68 61 6e 64 6c 69 6e 67 20 If URI handling
15530 69 73 20 67 6c 6f 62 61 6c 6c 79 0a 2a 2a 20 65 is globally.** e
15540 6e 61 62 6c 65 64 2c 20 61 6c 6c 20 66 69 6c 65 nabled, all file
15550 6e 61 6d 65 73 20 70 61 73 73 65 64 20 74 6f 20 names passed to
15560 5b 73 71 6c 69 74 65 33 5f 6f 70 65 6e 28 29 5d [sqlite3_open()]
15570 2c 20 5b 73 71 6c 69 74 65 33 5f 6f 70 65 6e 5f , [sqlite3_open_
15580 76 32 28 29 5d 2c 0a 2a 2a 20 5b 73 71 6c 69 74 v2()],.** [sqlit
15590 65 33 5f 6f 70 65 6e 31 36 28 29 5d 20 6f 72 0a e3_open16()] or.
155a0 2a 2a 20 73 70 65 63 69 66 69 65 64 20 61 73 20 ** specified as
155b0 70 61 72 74 20 6f 66 20 5b 41 54 54 41 43 48 5d part of [ATTACH]
155c0 20 63 6f 6d 6d 61 6e 64 73 20 61 72 65 20 69 6e commands are in
155d0 74 65 72 70 72 65 74 65 64 20 61 73 20 55 52 49 terpreted as URI
155e0 73 2c 20 72 65 67 61 72 64 6c 65 73 73 0a 2a 2a s, regardless.**
155f0 20 6f 66 20 77 68 65 74 68 65 72 20 6f 72 20 6e of whether or n
15600 6f 74 20 74 68 65 20 5b 53 51 4c 49 54 45 5f 4f ot the [SQLITE_O
15610 50 45 4e 5f 55 52 49 5d 20 66 6c 61 67 20 69 73 PEN_URI] flag is
15620 20 73 65 74 20 77 68 65 6e 20 74 68 65 20 64 61 set when the da
15630 74 61 62 61 73 65 0a 2a 2a 20 63 6f 6e 6e 65 63 tabase.** connec
15640 74 69 6f 6e 20 69 73 20 6f 70 65 6e 65 64 2e 20 tion is opened.
15650 5e 49 66 20 69 74 20 69 73 20 67 6c 6f 62 61 6c ^If it is global
15660 6c 79 20 64 69 73 61 62 6c 65 64 2c 20 66 69 6c ly disabled, fil
15670 65 6e 61 6d 65 73 20 61 72 65 0a 2a 2a 20 6f 6e enames are.** on
15680 6c 79 20 69 6e 74 65 72 70 72 65 74 65 64 20 61 ly interpreted a
15690 73 20 55 52 49 73 20 69 66 20 74 68 65 20 53 51 s URIs if the SQ
156a0 4c 49 54 45 5f 4f 50 45 4e 5f 55 52 49 20 66 6c LITE_OPEN_URI fl
156b0 61 67 20 69 73 20 73 65 74 20 77 68 65 6e 20 74 ag is set when t
156c0 68 65 0a 2a 2a 20 64 61 74 61 62 61 73 65 20 63 he.** database c
156d0 6f 6e 6e 65 63 74 69 6f 6e 20 69 73 20 6f 70 65 onnection is ope
156e0 6e 65 64 2e 20 5e 28 42 79 20 64 65 66 61 75 6c ned. ^(By defaul
156f0 74 2c 20 55 52 49 20 68 61 6e 64 6c 69 6e 67 20 t, URI handling
15700 69 73 20 67 6c 6f 62 61 6c 6c 79 0a 2a 2a 20 64 is globally.** d
15710 69 73 61 62 6c 65 64 2e 20 54 68 65 20 64 65 66 isabled. The def
15720 61 75 6c 74 20 76 61 6c 75 65 20 6d 61 79 20 62 ault value may b
15730 65 20 63 68 61 6e 67 65 64 20 62 79 20 63 6f 6d e changed by com
15740 70 69 6c 69 6e 67 20 77 69 74 68 20 74 68 65 0a piling with the.
15750 2a 2a 20 5b 53 51 4c 49 54 45 5f 55 53 45 5f 55 ** [SQLITE_USE_U
15760 52 49 5d 20 73 79 6d 62 6f 6c 20 64 65 66 69 6e RI] symbol defin
15770 65 64 2e 29 5e 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 ed.)^.**.** [[SQ
15780 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 43 4f 56 45 LITE_CONFIG_COVE
15790 52 49 4e 47 5f 49 4e 44 45 58 5f 53 43 41 4e 5d RING_INDEX_SCAN]
157a0 5d 20 3c 64 74 3e 53 51 4c 49 54 45 5f 43 4f 4e ] <dt>SQLITE_CON
157b0 46 49 47 5f 43 4f 56 45 52 49 4e 47 5f 49 4e 44 FIG_COVERING_IND
157c0 45 58 5f 53 43 41 4e 0a 2a 2a 20 3c 64 64 3e 5e EX_SCAN.** <dd>^
157d0 54 68 65 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 The SQLITE_CONFI
157e0 47 5f 43 4f 56 45 52 49 4e 47 5f 49 4e 44 45 58 G_COVERING_INDEX
157f0 5f 53 43 41 4e 20 6f 70 74 69 6f 6e 20 74 61 6b _SCAN option tak
15800 65 73 20 61 20 73 69 6e 67 6c 65 20 69 6e 74 65 es a single inte
15810 67 65 72 0a 2a 2a 20 61 72 67 75 6d 65 6e 74 20 ger.** argument
15820 77 68 69 63 68 20 69 73 20 69 6e 74 65 72 70 72 which is interpr
15830 65 74 65 64 20 61 73 20 61 20 62 6f 6f 6c 65 61 eted as a boolea
15840 6e 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 65 6e n in order to en
15850 61 62 6c 65 20 6f 72 20 64 69 73 61 62 6c 65 0a able or disable.
15860 2a 2a 20 74 68 65 20 75 73 65 20 6f 66 20 63 6f ** the use of co
15870 76 65 72 69 6e 67 20 69 6e 64 69 63 65 73 20 66 vering indices f
15880 6f 72 20 66 75 6c 6c 20 74 61 62 6c 65 20 73 63 or full table sc
15890 61 6e 73 20 69 6e 20 74 68 65 20 71 75 65 72 79 ans in the query
158a0 20 6f 70 74 69 6d 69 7a 65 72 2e 0a 2a 2a 20 5e optimizer..** ^
158b0 54 68 65 20 64 65 66 61 75 6c 74 20 73 65 74 74 The default sett
158c0 69 6e 67 20 69 73 20 64 65 74 65 72 6d 69 6e 65 ing is determine
158d0 64 0a 2a 2a 20 62 79 20 74 68 65 20 5b 53 51 4c d.** by the [SQL
158e0 49 54 45 5f 41 4c 4c 4f 57 5f 43 4f 56 45 52 49 ITE_ALLOW_COVERI
158f0 4e 47 5f 49 4e 44 45 58 5f 53 43 41 4e 5d 20 63 NG_INDEX_SCAN] c
15900 6f 6d 70 69 6c 65 2d 74 69 6d 65 20 6f 70 74 69 ompile-time opti
15910 6f 6e 2c 20 6f 72 20 69 73 20 22 6f 6e 22 0a 2a on, or is "on".*
15920 2a 20 69 66 20 74 68 61 74 20 63 6f 6d 70 69 6c * if that compil
15930 65 2d 74 69 6d 65 20 6f 70 74 69 6f 6e 20 69 73 e-time option is
15940 20 6f 6d 69 74 74 65 64 2e 0a 2a 2a 20 54 68 65 omitted..** The
15950 20 61 62 69 6c 69 74 79 20 74 6f 20 64 69 73 61 ability to disa
15960 62 6c 65 20 74 68 65 20 75 73 65 20 6f 66 20 63 ble the use of c
15970 6f 76 65 72 69 6e 67 20 69 6e 64 69 63 65 73 20 overing indices
15980 66 6f 72 20 66 75 6c 6c 20 74 61 62 6c 65 20 73 for full table s
15990 63 61 6e 73 0a 2a 2a 20 69 73 20 62 65 63 61 75 cans.** is becau
159a0 73 65 20 73 6f 6d 65 20 69 6e 63 6f 72 72 65 63 se some incorrec
159b0 74 6c 79 20 63 6f 64 65 64 20 6c 65 67 61 63 79 tly coded legacy
159c0 20 61 70 70 6c 69 63 61 74 69 6f 6e 73 20 6d 69 applications mi
159d0 67 68 74 20 6d 61 6c 66 75 6e 63 74 69 6f 6e 0a ght malfunction.
159e0 2a 2a 20 77 68 65 6e 20 74 68 65 20 6f 70 74 69 ** when the opti
159f0 6d 69 7a 61 74 69 6f 6e 20 69 73 20 65 6e 61 62 mization is enab
15a00 6c 65 64 2e 20 20 50 72 6f 76 69 64 69 6e 67 20 led. Providing
15a10 74 68 65 20 61 62 69 6c 69 74 79 20 74 6f 0a 2a the ability to.*
15a20 2a 20 64 69 73 61 62 6c 65 20 74 68 65 20 6f 70 * disable the op
15a30 74 69 6d 69 7a 61 74 69 6f 6e 20 61 6c 6c 6f 77 timization allow
15a40 73 20 74 68 65 20 6f 6c 64 65 72 2c 20 62 75 67 s the older, bug
15a50 67 79 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 63 gy application c
15a60 6f 64 65 20 74 6f 20 77 6f 72 6b 0a 2a 2a 20 77 ode to work.** w
15a70 69 74 68 6f 75 74 20 63 68 61 6e 67 65 20 65 76 ithout change ev
15a80 65 6e 20 77 69 74 68 20 6e 65 77 65 72 20 76 65 en with newer ve
15a90 72 73 69 6f 6e 73 20 6f 66 20 53 51 4c 69 74 65 rsions of SQLite
15aa0 2e 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 4c 49 54 45 ..**.** [[SQLITE
15ab0 5f 43 4f 4e 46 49 47 5f 50 43 41 43 48 45 5d 5d _CONFIG_PCACHE]]
15ac0 20 5b 5b 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 [[SQLITE_CONFIG
15ad0 5f 47 45 54 50 43 41 43 48 45 5d 5d 0a 2a 2a 20 _GETPCACHE]].**
15ae0 3c 64 74 3e 53 51 4c 49 54 45 5f 43 4f 4e 46 49 <dt>SQLITE_CONFI
15af0 47 5f 50 43 41 43 48 45 20 61 6e 64 20 53 51 4c G_PCACHE and SQL
15b00 49 54 45 5f 43 4f 4e 46 49 47 5f 47 45 54 50 43 ITE_CONFIG_GETPC
15b10 41 43 48 45 0a 2a 2a 20 3c 64 64 3e 20 54 68 65 ACHE.** <dd> The
15b20 73 65 20 6f 70 74 69 6f 6e 73 20 61 72 65 20 6f se options are o
15b30 62 73 6f 6c 65 74 65 20 61 6e 64 20 73 68 6f 75 bsolete and shou
15b40 6c 64 20 6e 6f 74 20 62 65 20 75 73 65 64 20 62 ld not be used b
15b50 79 20 6e 65 77 20 63 6f 64 65 2e 0a 2a 2a 20 54 y new code..** T
15b60 68 65 79 20 61 72 65 20 72 65 74 61 69 6e 65 64 hey are retained
15b70 20 66 6f 72 20 62 61 63 6b 77 61 72 64 73 20 63 for backwards c
15b80 6f 6d 70 61 74 69 62 69 6c 69 74 79 20 62 75 74 ompatibility but
15b90 20 61 72 65 20 6e 6f 77 20 6e 6f 2d 6f 70 73 2e are now no-ops.
15ba0 0a 2a 2a 20 3c 2f 64 64 3e 0a 2a 2a 0a 2a 2a 20 .** </dd>.**.**
15bb0 5b 5b 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f [[SQLITE_CONFIG_
15bc0 53 51 4c 4c 4f 47 5d 5d 0a 2a 2a 20 3c 64 74 3e SQLLOG]].** <dt>
15bd0 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 53 51 SQLITE_CONFIG_SQ
15be0 4c 4c 4f 47 0a 2a 2a 20 3c 64 64 3e 54 68 69 73 LLOG.** <dd>This
15bf0 20 6f 70 74 69 6f 6e 20 69 73 20 6f 6e 6c 79 20 option is only
15c00 61 76 61 69 6c 61 62 6c 65 20 69 66 20 73 71 6c available if sql
15c10 69 74 65 20 69 73 20 63 6f 6d 70 69 6c 65 64 20 ite is compiled
15c20 77 69 74 68 20 74 68 65 0a 2a 2a 20 5b 53 51 4c with the.** [SQL
15c30 49 54 45 5f 45 4e 41 42 4c 45 5f 53 51 4c 4c 4f ITE_ENABLE_SQLLO
15c40 47 5d 20 70 72 65 2d 70 72 6f 63 65 73 73 6f 72 G] pre-processor
15c50 20 6d 61 63 72 6f 20 64 65 66 69 6e 65 64 2e 20 macro defined.
15c60 54 68 65 20 66 69 72 73 74 20 61 72 67 75 6d 65 The first argume
15c70 6e 74 20 73 68 6f 75 6c 64 0a 2a 2a 20 62 65 20 nt should.** be
15c80 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 61 20 66 a pointer to a f
15c90 75 6e 63 74 69 6f 6e 20 6f 66 20 74 79 70 65 20 unction of type
15ca0 76 6f 69 64 28 2a 29 28 76 6f 69 64 2a 2c 73 71 void(*)(void*,sq
15cb0 6c 69 74 65 33 2a 2c 63 6f 6e 73 74 20 63 68 61 lite3*,const cha
15cc0 72 2a 2c 20 69 6e 74 29 2e 0a 2a 2a 20 54 68 65 r*, int)..** The
15cd0 20 73 65 63 6f 6e 64 20 73 68 6f 75 6c 64 20 62 second should b
15ce0 65 20 6f 66 20 74 79 70 65 20 28 76 6f 69 64 2a e of type (void*
15cf0 29 2e 20 54 68 65 20 63 61 6c 6c 62 61 63 6b 20 ). The callback
15d00 69 73 20 69 6e 76 6f 6b 65 64 20 62 79 20 74 68 is invoked by th
15d10 65 20 6c 69 62 72 61 72 79 0a 2a 2a 20 69 6e 20 e library.** in
15d20 74 68 72 65 65 20 73 65 70 61 72 61 74 65 20 63 three separate c
15d30 69 72 63 75 6d 73 74 61 6e 63 65 73 2c 20 69 64 ircumstances, id
15d40 65 6e 74 69 66 69 65 64 20 62 79 20 74 68 65 20 entified by the
15d50 76 61 6c 75 65 20 70 61 73 73 65 64 20 61 73 20 value passed as
15d60 74 68 65 0a 2a 2a 20 66 6f 75 72 74 68 20 70 61 the.** fourth pa
15d70 72 61 6d 65 74 65 72 2e 20 49 66 20 74 68 65 20 rameter. If the
15d80 66 6f 75 72 74 68 20 70 61 72 61 6d 65 74 65 72 fourth parameter
15d90 20 69 73 20 30 2c 20 74 68 65 6e 20 74 68 65 20 is 0, then the
15da0 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 database connect
15db0 69 6f 6e 0a 2a 2a 20 70 61 73 73 65 64 20 61 73 ion.** passed as
15dc0 20 74 68 65 20 73 65 63 6f 6e 64 20 61 72 67 75 the second argu
15dd0 6d 65 6e 74 20 68 61 73 20 6a 75 73 74 20 62 65 ment has just be
15de0 65 6e 20 6f 70 65 6e 65 64 2e 20 54 68 65 20 74 en opened. The t
15df0 68 69 72 64 20 61 72 67 75 6d 65 6e 74 0a 2a 2a hird argument.**
15e00 20 70 6f 69 6e 74 73 20 74 6f 20 61 20 62 75 66 points to a buf
15e10 66 65 72 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 fer containing t
15e20 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 6d he name of the m
15e30 61 69 6e 20 64 61 74 61 62 61 73 65 20 66 69 6c ain database fil
15e40 65 2e 20 49 66 20 74 68 65 0a 2a 2a 20 66 6f 75 e. If the.** fou
15e50 72 74 68 20 70 61 72 61 6d 65 74 65 72 20 69 73 rth parameter is
15e60 20 31 2c 20 74 68 65 6e 20 74 68 65 20 53 51 4c 1, then the SQL
15e70 20 73 74 61 74 65 6d 65 6e 74 20 74 68 61 74 20 statement that
15e80 74 68 65 20 74 68 69 72 64 20 70 61 72 61 6d 65 the third parame
15e90 74 65 72 0a 2a 2a 20 70 6f 69 6e 74 73 20 74 6f ter.** points to
15ea0 20 68 61 73 20 6a 75 73 74 20 62 65 65 6e 20 65 has just been e
15eb0 78 65 63 75 74 65 64 2e 20 4f 72 2c 20 69 66 20 xecuted. Or, if
15ec0 74 68 65 20 66 6f 75 72 74 68 20 70 61 72 61 6d the fourth param
15ed0 65 74 65 72 20 69 73 20 32 2c 20 74 68 65 6e 0a eter is 2, then.
15ee0 2a 2a 20 74 68 65 20 63 6f 6e 6e 65 63 74 69 6f ** the connectio
15ef0 6e 20 62 65 69 6e 67 20 70 61 73 73 65 64 20 61 n being passed a
15f00 73 20 74 68 65 20 73 65 63 6f 6e 64 20 70 61 72 s the second par
15f10 61 6d 65 74 65 72 20 69 73 20 62 65 69 6e 67 20 ameter is being
15f20 63 6c 6f 73 65 64 2e 20 54 68 65 0a 2a 2a 20 74 closed. The.** t
15f30 68 69 72 64 20 70 61 72 61 6d 65 74 65 72 20 69 hird parameter i
15f40 73 20 70 61 73 73 65 64 20 4e 55 4c 4c 20 49 6e s passed NULL In
15f50 20 74 68 69 73 20 63 61 73 65 2e 20 20 41 6e 20 this case. An
15f60 65 78 61 6d 70 6c 65 20 6f 66 20 75 73 69 6e 67 example of using
15f70 20 74 68 69 73 0a 2a 2a 20 63 6f 6e 66 69 67 75 this.** configu
15f80 72 61 74 69 6f 6e 20 6f 70 74 69 6f 6e 20 63 61 ration option ca
15f90 6e 20 62 65 20 73 65 65 6e 20 69 6e 20 74 68 65 n be seen in the
15fa0 20 22 74 65 73 74 5f 73 71 6c 6c 6f 67 2e 63 22 "test_sqllog.c"
15fb0 20 73 6f 75 72 63 65 20 66 69 6c 65 20 69 6e 0a source file in.
15fc0 2a 2a 20 74 68 65 20 63 61 6e 6f 6e 69 63 61 6c ** the canonical
15fd0 20 53 51 4c 69 74 65 20 73 6f 75 72 63 65 20 74 SQLite source t
15fe0 72 65 65 2e 3c 2f 64 64 3e 0a 2a 2a 0a 2a 2a 20 ree.</dd>.**.**
15ff0 5b 5b 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f [[SQLITE_CONFIG_
16000 4d 4d 41 50 5f 53 49 5a 45 5d 5d 0a 2a 2a 20 3c MMAP_SIZE]].** <
16010 64 74 3e 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 dt>SQLITE_CONFIG
16020 5f 4d 4d 41 50 5f 53 49 5a 45 0a 2a 2a 20 3c 64 _MMAP_SIZE.** <d
16030 64 3e 5e 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 d>^SQLITE_CONFIG
16040 5f 4d 4d 41 50 5f 53 49 5a 45 20 74 61 6b 65 73 _MMAP_SIZE takes
16050 20 74 77 6f 20 36 34 2d 62 69 74 20 69 6e 74 65 two 64-bit inte
16060 67 65 72 20 28 73 71 6c 69 74 65 33 5f 69 6e 74 ger (sqlite3_int
16070 36 34 29 20 76 61 6c 75 65 73 0a 2a 2a 20 74 68 64) values.** th
16080 61 74 20 61 72 65 20 74 68 65 20 64 65 66 61 75 at are the defau
16090 6c 74 20 6d 6d 61 70 20 73 69 7a 65 20 6c 69 6d lt mmap size lim
160a0 69 74 20 28 74 68 65 20 64 65 66 61 75 6c 74 20 it (the default
160b0 73 65 74 74 69 6e 67 20 66 6f 72 0a 2a 2a 20 5b setting for.** [
160c0 50 52 41 47 4d 41 20 6d 6d 61 70 5f 73 69 7a 65 PRAGMA mmap_size
160d0 5d 29 20 61 6e 64 20 74 68 65 20 6d 61 78 69 6d ]) and the maxim
160e0 75 6d 20 61 6c 6c 6f 77 65 64 20 6d 6d 61 70 20 um allowed mmap
160f0 73 69 7a 65 20 6c 69 6d 69 74 2e 0a 2a 2a 20 5e size limit..** ^
16100 54 68 65 20 64 65 66 61 75 6c 74 20 73 65 74 74 The default sett
16110 69 6e 67 20 63 61 6e 20 62 65 20 6f 76 65 72 72 ing can be overr
16120 69 64 64 65 6e 20 62 79 20 65 61 63 68 20 64 61 idden by each da
16130 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f tabase connectio
16140 6e 20 75 73 69 6e 67 0a 2a 2a 20 65 69 74 68 65 n using.** eithe
16150 72 20 74 68 65 20 5b 50 52 41 47 4d 41 20 6d 6d r the [PRAGMA mm
16160 61 70 5f 73 69 7a 65 5d 20 63 6f 6d 6d 61 6e 64 ap_size] command
16170 2c 20 6f 72 20 62 79 20 75 73 69 6e 67 20 74 68 , or by using th
16180 65 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f 46 43 4e e.** [SQLITE_FCN
16190 54 4c 5f 4d 4d 41 50 5f 53 49 5a 45 5d 20 66 69 TL_MMAP_SIZE] fi
161a0 6c 65 20 63 6f 6e 74 72 6f 6c 2e 20 20 5e 28 54 le control. ^(T
161b0 68 65 20 6d 61 78 69 6d 75 6d 20 61 6c 6c 6f 77 he maximum allow
161c0 65 64 20 6d 6d 61 70 20 73 69 7a 65 0a 2a 2a 20 ed mmap size.**
161d0 77 69 6c 6c 20 62 65 20 73 69 6c 65 6e 74 6c 79 will be silently
161e0 20 74 72 75 6e 63 61 74 65 64 20 69 66 20 6e 65 truncated if ne
161f0 63 65 73 73 61 72 79 20 73 6f 20 74 68 61 74 20 cessary so that
16200 69 74 20 64 6f 65 73 20 6e 6f 74 20 65 78 63 65 it does not exce
16210 65 64 20 74 68 65 0a 2a 2a 20 63 6f 6d 70 69 6c ed the.** compil
16220 65 2d 74 69 6d 65 20 6d 61 78 69 6d 75 6d 20 6d e-time maximum m
16230 6d 61 70 20 73 69 7a 65 20 73 65 74 20 62 79 20 map size set by
16240 74 68 65 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f 4d the.** [SQLITE_M
16250 41 58 5f 4d 4d 41 50 5f 53 49 5a 45 5d 20 63 6f AX_MMAP_SIZE] co
16260 6d 70 69 6c 65 2d 74 69 6d 65 20 6f 70 74 69 6f mpile-time optio
16270 6e 2e 29 5e 0a 2a 2a 20 5e 49 66 20 65 69 74 68 n.)^.** ^If eith
16280 65 72 20 61 72 67 75 6d 65 6e 74 20 74 6f 20 74 er argument to t
16290 68 69 73 20 6f 70 74 69 6f 6e 20 69 73 20 6e 65 his option is ne
162a0 67 61 74 69 76 65 2c 20 74 68 65 6e 20 74 68 61 gative, then tha
162b0 74 20 61 72 67 75 6d 65 6e 74 20 69 73 0a 2a 2a t argument is.**
162c0 20 63 68 61 6e 67 65 64 20 74 6f 20 69 74 73 20 changed to its
162d0 63 6f 6d 70 69 6c 65 2d 74 69 6d 65 20 64 65 66 compile-time def
162e0 61 75 6c 74 2e 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 ault..**.** [[SQ
162f0 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 57 49 4e 33 LITE_CONFIG_WIN3
16300 32 5f 48 45 41 50 53 49 5a 45 5d 5d 0a 2a 2a 20 2_HEAPSIZE]].**
16310 3c 64 74 3e 53 51 4c 49 54 45 5f 43 4f 4e 46 49 <dt>SQLITE_CONFI
16320 47 5f 57 49 4e 33 32 5f 48 45 41 50 53 49 5a 45 G_WIN32_HEAPSIZE
16330 0a 2a 2a 20 3c 64 64 3e 5e 54 68 65 20 53 51 4c .** <dd>^The SQL
16340 49 54 45 5f 43 4f 4e 46 49 47 5f 57 49 4e 33 32 ITE_CONFIG_WIN32
16350 5f 48 45 41 50 53 49 5a 45 20 6f 70 74 69 6f 6e _HEAPSIZE option
16360 20 69 73 20 6f 6e 6c 79 20 61 76 61 69 6c 61 62 is only availab
16370 6c 65 20 69 66 20 53 51 4c 69 74 65 20 69 73 0a le if SQLite is.
16380 2a 2a 20 63 6f 6d 70 69 6c 65 64 20 66 6f 72 20 ** compiled for
16390 57 69 6e 64 6f 77 73 20 77 69 74 68 20 74 68 65 Windows with the
163a0 20 5b 53 51 4c 49 54 45 5f 57 49 4e 33 32 5f 4d [SQLITE_WIN32_M
163b0 41 4c 4c 4f 43 5d 20 70 72 65 2d 70 72 6f 63 65 ALLOC] pre-proce
163c0 73 73 6f 72 20 6d 61 63 72 6f 0a 2a 2a 20 64 65 ssor macro.** de
163d0 66 69 6e 65 64 2e 20 5e 53 51 4c 49 54 45 5f 43 fined. ^SQLITE_C
163e0 4f 4e 46 49 47 5f 57 49 4e 33 32 5f 48 45 41 50 ONFIG_WIN32_HEAP
163f0 53 49 5a 45 20 74 61 6b 65 73 20 61 20 33 32 2d SIZE takes a 32-
16400 62 69 74 20 75 6e 73 69 67 6e 65 64 20 69 6e 74 bit unsigned int
16410 65 67 65 72 20 76 61 6c 75 65 0a 2a 2a 20 74 68 eger value.** th
16420 61 74 20 73 70 65 63 69 66 69 65 73 20 74 68 65 at specifies the
16430 20 6d 61 78 69 6d 75 6d 20 73 69 7a 65 20 6f 66 maximum size of
16440 20 74 68 65 20 63 72 65 61 74 65 64 20 68 65 61 the created hea
16450 70 2e 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 4c 49 54 p..**.** [[SQLIT
16460 45 5f 43 4f 4e 46 49 47 5f 50 43 41 43 48 45 5f E_CONFIG_PCACHE_
16470 48 44 52 53 5a 5d 5d 0a 2a 2a 20 3c 64 74 3e 53 HDRSZ]].** <dt>S
16480 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 50 43 41 QLITE_CONFIG_PCA
16490 43 48 45 5f 48 44 52 53 5a 0a 2a 2a 20 3c 64 64 CHE_HDRSZ.** <dd
164a0 3e 5e 54 68 65 20 53 51 4c 49 54 45 5f 43 4f 4e >^The SQLITE_CON
164b0 46 49 47 5f 50 43 41 43 48 45 5f 48 44 52 53 5a FIG_PCACHE_HDRSZ
164c0 20 6f 70 74 69 6f 6e 20 74 61 6b 65 73 20 61 20 option takes a
164d0 73 69 6e 67 6c 65 20 70 61 72 61 6d 65 74 65 72 single parameter
164e0 20 77 68 69 63 68 0a 2a 2a 20 69 73 20 61 20 70 which.** is a p
164f0 6f 69 6e 74 65 72 20 74 6f 20 61 6e 20 69 6e 74 ointer to an int
16500 65 67 65 72 20 61 6e 64 20 77 72 69 74 65 73 20 eger and writes
16510 69 6e 74 6f 20 74 68 61 74 20 69 6e 74 65 67 65 into that intege
16520 72 20 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 r the number of
16530 65 78 74 72 61 0a 2a 2a 20 62 79 74 65 73 20 70 extra.** bytes p
16540 65 72 20 70 61 67 65 20 72 65 71 75 69 72 65 64 er page required
16550 20 66 6f 72 20 65 61 63 68 20 70 61 67 65 20 69 for each page i
16560 6e 20 5b 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 n [SQLITE_CONFIG
16570 5f 50 41 47 45 43 41 43 48 45 5d 2e 0a 2a 2a 20 _PAGECACHE]..**
16580 54 68 65 20 61 6d 6f 75 6e 74 20 6f 66 20 65 78 The amount of ex
16590 74 72 61 20 73 70 61 63 65 20 72 65 71 75 69 72 tra space requir
165a0 65 64 20 63 61 6e 20 63 68 61 6e 67 65 20 64 65 ed can change de
165b0 70 65 6e 64 69 6e 67 20 6f 6e 20 74 68 65 20 63 pending on the c
165c0 6f 6d 70 69 6c 65 72 2c 0a 2a 2a 20 74 61 72 67 ompiler,.** targ
165d0 65 74 20 70 6c 61 74 66 6f 72 6d 2c 20 61 6e 64 et platform, and
165e0 20 53 51 4c 69 74 65 20 76 65 72 73 69 6f 6e 2e SQLite version.
165f0 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 4c 49 54 45 5f .**.** [[SQLITE_
16600 43 4f 4e 46 49 47 5f 50 4d 41 53 5a 5d 5d 0a 2a CONFIG_PMASZ]].*
16610 2a 20 3c 64 74 3e 53 51 4c 49 54 45 5f 43 4f 4e * <dt>SQLITE_CON
16620 46 49 47 5f 50 4d 41 53 5a 0a 2a 2a 20 3c 64 64 FIG_PMASZ.** <dd
16630 3e 5e 54 68 65 20 53 51 4c 49 54 45 5f 43 4f 4e >^The SQLITE_CON
16640 46 49 47 5f 50 4d 41 53 5a 20 6f 70 74 69 6f 6e FIG_PMASZ option
16650 20 74 61 6b 65 73 20 61 20 73 69 6e 67 6c 65 20 takes a single
16660 70 61 72 61 6d 65 74 65 72 20 77 68 69 63 68 0a parameter which.
16670 2a 2a 20 69 73 20 61 6e 20 75 6e 73 69 67 6e 65 ** is an unsigne
16680 64 20 69 6e 74 65 67 65 72 20 61 6e 64 20 73 65 d integer and se
16690 74 73 20 74 68 65 20 22 4d 69 6e 69 6d 75 6d 20 ts the "Minimum
166a0 50 4d 41 20 53 69 7a 65 22 20 66 6f 72 20 74 68 PMA Size" for th
166b0 65 20 6d 75 6c 74 69 74 68 72 65 61 64 65 64 0a e multithreaded.
166c0 2a 2a 20 73 6f 72 74 65 72 20 74 6f 20 74 68 61 ** sorter to tha
166d0 74 20 69 6e 74 65 67 65 72 2e 20 20 54 68 65 20 t integer. The
166e0 64 65 66 61 75 6c 74 20 6d 69 6e 69 6d 75 6d 20 default minimum
166f0 50 4d 41 20 53 69 7a 65 20 69 73 20 73 65 74 20 PMA Size is set
16700 62 79 20 74 68 65 0a 2a 2a 20 5b 53 51 4c 49 54 by the.** [SQLIT
16710 45 5f 53 4f 52 54 45 52 5f 50 4d 41 53 5a 5d 20 E_SORTER_PMASZ]
16720 63 6f 6d 70 69 6c 65 2d 74 69 6d 65 20 6f 70 74 compile-time opt
16730 69 6f 6e 2e 20 20 4e 65 77 20 74 68 72 65 61 64 ion. New thread
16740 73 20 61 72 65 20 6c 61 75 6e 63 68 65 64 0a 2a s are launched.*
16750 2a 20 74 6f 20 68 65 6c 70 20 77 69 74 68 20 73 * to help with s
16760 6f 72 74 20 6f 70 65 72 61 74 69 6f 6e 73 20 77 ort operations w
16770 68 65 6e 20 6d 75 6c 74 69 74 68 72 65 61 64 65 hen multithreade
16780 64 20 73 6f 72 74 69 6e 67 0a 2a 2a 20 69 73 20 d sorting.** is
16790 65 6e 61 62 6c 65 64 20 28 75 73 69 6e 67 20 74 enabled (using t
167a0 68 65 20 5b 50 52 41 47 4d 41 20 74 68 72 65 61 he [PRAGMA threa
167b0 64 73 5d 20 63 6f 6d 6d 61 6e 64 29 20 61 6e 64 ds] command) and
167c0 20 74 68 65 20 61 6d 6f 75 6e 74 20 6f 66 20 63 the amount of c
167d0 6f 6e 74 65 6e 74 0a 2a 2a 20 74 6f 20 62 65 20 ontent.** to be
167e0 73 6f 72 74 65 64 20 65 78 63 65 65 64 73 20 74 sorted exceeds t
167f0 68 65 20 70 61 67 65 20 73 69 7a 65 20 74 69 6d he page size tim
16800 65 73 20 74 68 65 20 6d 69 6e 69 6d 75 6d 20 6f es the minimum o
16810 66 20 74 68 65 0a 2a 2a 20 5b 50 52 41 47 4d 41 f the.** [PRAGMA
16820 20 63 61 63 68 65 5f 73 69 7a 65 5d 20 73 65 74 cache_size] set
16830 74 69 6e 67 20 61 6e 64 20 74 68 69 73 20 76 61 ting and this va
16840 6c 75 65 2e 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 4c lue..**.** [[SQL
16850 49 54 45 5f 43 4f 4e 46 49 47 5f 53 54 4d 54 4a ITE_CONFIG_STMTJ
16860 52 4e 4c 5f 53 50 49 4c 4c 5d 5d 0a 2a 2a 20 3c RNL_SPILL]].** <
16870 64 74 3e 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 dt>SQLITE_CONFIG
16880 5f 53 54 4d 54 4a 52 4e 4c 5f 53 50 49 4c 4c 0a _STMTJRNL_SPILL.
16890 2a 2a 20 3c 64 64 3e 5e 54 68 65 20 53 51 4c 49 ** <dd>^The SQLI
168a0 54 45 5f 43 4f 4e 46 49 47 5f 53 54 4d 54 4a 52 TE_CONFIG_STMTJR
168b0 4e 4c 5f 53 50 49 4c 4c 20 6f 70 74 69 6f 6e 20 NL_SPILL option
168c0 74 61 6b 65 73 20 61 20 73 69 6e 67 6c 65 20 70 takes a single p
168d0 61 72 61 6d 65 74 65 72 20 77 68 69 63 68 0a 2a arameter which.*
168e0 2a 20 62 65 63 6f 6d 65 73 20 74 68 65 20 5b 73 * becomes the [s
168f0 74 61 74 65 6d 65 6e 74 20 6a 6f 75 72 6e 61 6c tatement journal
16900 5d 20 73 70 69 6c 6c 2d 74 6f 2d 64 69 73 6b 20 ] spill-to-disk
16910 74 68 72 65 73 68 6f 6c 64 2e 20 20 0a 2a 2a 20 threshold. .**
16920 5b 53 74 61 74 65 6d 65 6e 74 20 6a 6f 75 72 6e [Statement journ
16930 61 6c 73 5d 20 61 72 65 20 68 65 6c 64 20 69 6e als] are held in
16940 20 6d 65 6d 6f 72 79 20 75 6e 74 69 6c 20 74 68 memory until th
16950 65 69 72 20 73 69 7a 65 20 28 69 6e 20 62 79 74 eir size (in byt
16960 65 73 29 0a 2a 2a 20 65 78 63 65 65 64 73 20 74 es).** exceeds t
16970 68 69 73 20 74 68 72 65 73 68 6f 6c 64 2c 20 61 his threshold, a
16980 74 20 77 68 69 63 68 20 70 6f 69 6e 74 20 74 68 t which point th
16990 65 79 20 61 72 65 20 77 72 69 74 74 65 6e 20 74 ey are written t
169a0 6f 20 64 69 73 6b 2e 0a 2a 2a 20 4f 72 20 69 66 o disk..** Or if
169b0 20 74 68 65 20 74 68 72 65 73 68 6f 6c 64 20 69 the threshold i
169c0 73 20 2d 31 2c 20 73 74 61 74 65 6d 65 6e 74 20 s -1, statement
169d0 6a 6f 75 72 6e 61 6c 73 20 61 72 65 20 61 6c 77 journals are alw
169e0 61 79 73 20 68 65 6c 64 0a 2a 2a 20 65 78 63 6c ays held.** excl
169f0 75 73 69 76 65 6c 79 20 69 6e 20 6d 65 6d 6f 72 usively in memor
16a00 79 2e 0a 2a 2a 20 53 69 6e 63 65 20 6d 61 6e 79 y..** Since many
16a10 20 73 74 61 74 65 6d 65 6e 74 20 6a 6f 75 72 6e statement journ
16a20 61 6c 73 20 6e 65 76 65 72 20 62 65 63 6f 6d 65 als never become
16a30 20 6c 61 72 67 65 2c 20 73 65 74 74 69 6e 67 20 large, setting
16a40 74 68 65 20 73 70 69 6c 6c 0a 2a 2a 20 74 68 72 the spill.** thr
16a50 65 73 68 6f 6c 64 20 74 6f 20 61 20 76 61 6c 75 eshold to a valu
16a60 65 20 73 75 63 68 20 61 73 20 36 34 4b 69 42 20 e such as 64KiB
16a70 63 61 6e 20 67 72 65 61 74 6c 79 20 72 65 64 75 can greatly redu
16a80 63 65 20 74 68 65 20 61 6d 6f 75 6e 74 20 6f 66 ce the amount of
16a90 0a 2a 2a 20 49 2f 4f 20 72 65 71 75 69 72 65 64 .** I/O required
16aa0 20 74 6f 20 73 75 70 70 6f 72 74 20 73 74 61 74 to support stat
16ab0 65 6d 65 6e 74 20 72 6f 6c 6c 62 61 63 6b 2e 0a ement rollback..
16ac0 2a 2a 20 54 68 65 20 64 65 66 61 75 6c 74 20 76 ** The default v
16ad0 61 6c 75 65 20 66 6f 72 20 74 68 69 73 20 73 65 alue for this se
16ae0 74 74 69 6e 67 20 69 73 20 63 6f 6e 74 72 6f 6c tting is control
16af0 6c 65 64 20 62 79 20 74 68 65 0a 2a 2a 20 5b 53 led by the.** [S
16b00 51 4c 49 54 45 5f 53 54 4d 54 4a 52 4e 4c 5f 53 QLITE_STMTJRNL_S
16b10 50 49 4c 4c 5d 20 63 6f 6d 70 69 6c 65 2d 74 69 PILL] compile-ti
16b20 6d 65 20 6f 70 74 69 6f 6e 2e 0a 2a 2a 20 3c 2f me option..** </
16b30 64 6c 3e 0a 2a 2f 0a 23 64 65 66 69 6e 65 20 53 dl>.*/.#define S
16b40 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 53 49 4e QLITE_CONFIG_SIN
16b50 47 4c 45 54 48 52 45 41 44 20 20 31 20 20 2f 2a GLETHREAD 1 /*
16b60 20 6e 69 6c 20 2a 2f 0a 23 64 65 66 69 6e 65 20 nil */.#define
16b70 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 4d 55 SQLITE_CONFIG_MU
16b80 4c 54 49 54 48 52 45 41 44 20 20 20 32 20 20 2f LTITHREAD 2 /
16b90 2a 20 6e 69 6c 20 2a 2f 0a 23 64 65 66 69 6e 65 * nil */.#define
16ba0 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 53 SQLITE_CONFIG_S
16bb0 45 52 49 41 4c 49 5a 45 44 20 20 20 20 33 20 20 ERIALIZED 3
16bc0 2f 2a 20 6e 69 6c 20 2a 2f 0a 23 64 65 66 69 6e /* nil */.#defin
16bd0 65 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f e SQLITE_CONFIG_
16be0 4d 41 4c 4c 4f 43 20 20 20 20 20 20 20 20 34 20 MALLOC 4
16bf0 20 2f 2a 20 73 71 6c 69 74 65 33 5f 6d 65 6d 5f /* sqlite3_mem_
16c00 6d 65 74 68 6f 64 73 2a 20 2a 2f 0a 23 64 65 66 methods* */.#def
16c10 69 6e 65 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 ine SQLITE_CONFI
16c20 47 5f 47 45 54 4d 41 4c 4c 4f 43 20 20 20 20 20 G_GETMALLOC
16c30 35 20 20 2f 2a 20 73 71 6c 69 74 65 33 5f 6d 65 5 /* sqlite3_me
16c40 6d 5f 6d 65 74 68 6f 64 73 2a 20 2a 2f 0a 23 64 m_methods* */.#d
16c50 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 43 4f 4e efine SQLITE_CON
16c60 46 49 47 5f 53 43 52 41 54 43 48 20 20 20 20 20 FIG_SCRATCH
16c70 20 20 36 20 20 2f 2a 20 76 6f 69 64 2a 2c 20 69 6 /* void*, i
16c80 6e 74 20 73 7a 2c 20 69 6e 74 20 4e 20 2a 2f 0a nt sz, int N */.
16c90 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 43 #define SQLITE_C
16ca0 4f 4e 46 49 47 5f 50 41 47 45 43 41 43 48 45 20 ONFIG_PAGECACHE
16cb0 20 20 20 20 37 20 20 2f 2a 20 76 6f 69 64 2a 2c 7 /* void*,
16cc0 20 69 6e 74 20 73 7a 2c 20 69 6e 74 20 4e 20 2a int sz, int N *
16cd0 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 /.#define SQLITE
16ce0 5f 43 4f 4e 46 49 47 5f 48 45 41 50 20 20 20 20 _CONFIG_HEAP
16cf0 20 20 20 20 20 20 38 20 20 2f 2a 20 76 6f 69 64 8 /* void
16d00 2a 2c 20 69 6e 74 20 6e 42 79 74 65 2c 20 69 6e *, int nByte, in
16d10 74 20 6d 69 6e 20 2a 2f 0a 23 64 65 66 69 6e 65 t min */.#define
16d20 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 4d SQLITE_CONFIG_M
16d30 45 4d 53 54 41 54 55 53 20 20 20 20 20 39 20 20 EMSTATUS 9
16d40 2f 2a 20 62 6f 6f 6c 65 61 6e 20 2a 2f 0a 23 64 /* boolean */.#d
16d50 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 43 4f 4e efine SQLITE_CON
16d60 46 49 47 5f 4d 55 54 45 58 20 20 20 20 20 20 20 FIG_MUTEX
16d70 20 31 30 20 20 2f 2a 20 73 71 6c 69 74 65 33 5f 10 /* sqlite3_
16d80 6d 75 74 65 78 5f 6d 65 74 68 6f 64 73 2a 20 2a mutex_methods* *
16d90 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 /.#define SQLITE
16da0 5f 43 4f 4e 46 49 47 5f 47 45 54 4d 55 54 45 58 _CONFIG_GETMUTEX
16db0 20 20 20 20 20 31 31 20 20 2f 2a 20 73 71 6c 69 11 /* sqli
16dc0 74 65 33 5f 6d 75 74 65 78 5f 6d 65 74 68 6f 64 te3_mutex_method
16dd0 73 2a 20 2a 2f 0a 2f 2a 20 70 72 65 76 69 6f 75 s* */./* previou
16de0 73 6c 79 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 sly SQLITE_CONFI
16df0 47 5f 43 48 55 4e 4b 41 4c 4c 4f 43 20 31 32 20 G_CHUNKALLOC 12
16e00 77 68 69 63 68 20 69 73 20 6e 6f 77 20 75 6e 75 which is now unu
16e10 73 65 64 2e 20 2a 2f 20 0a 23 64 65 66 69 6e 65 sed. */ .#define
16e20 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 4c SQLITE_CONFIG_L
16e30 4f 4f 4b 41 53 49 44 45 20 20 20 20 31 33 20 20 OOKASIDE 13
16e40 2f 2a 20 69 6e 74 20 69 6e 74 20 2a 2f 0a 23 64 /* int int */.#d
16e50 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 43 4f 4e efine SQLITE_CON
16e60 46 49 47 5f 50 43 41 43 48 45 20 20 20 20 20 20 FIG_PCACHE
16e70 20 31 34 20 20 2f 2a 20 6e 6f 2d 6f 70 20 2a 2f 14 /* no-op */
16e80 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f .#define SQLITE_
16e90 43 4f 4e 46 49 47 5f 47 45 54 50 43 41 43 48 45 CONFIG_GETPCACHE
16ea0 20 20 20 20 31 35 20 20 2f 2a 20 6e 6f 2d 6f 70 15 /* no-op
16eb0 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 */.#define SQLI
16ec0 54 45 5f 43 4f 4e 46 49 47 5f 4c 4f 47 20 20 20 TE_CONFIG_LOG
16ed0 20 20 20 20 20 20 20 31 36 20 20 2f 2a 20 78 46 16 /* xF
16ee0 75 6e 63 2c 20 76 6f 69 64 2a 20 2a 2f 0a 23 64 unc, void* */.#d
16ef0 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 43 4f 4e efine SQLITE_CON
16f00 46 49 47 5f 55 52 49 20 20 20 20 20 20 20 20 20 FIG_URI
16f10 20 31 37 20 20 2f 2a 20 69 6e 74 20 2a 2f 0a 23 17 /* int */.#
16f20 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 43 4f define SQLITE_CO
16f30 4e 46 49 47 5f 50 43 41 43 48 45 32 20 20 20 20 NFIG_PCACHE2
16f40 20 20 31 38 20 20 2f 2a 20 73 71 6c 69 74 65 33 18 /* sqlite3
16f50 5f 70 63 61 63 68 65 5f 6d 65 74 68 6f 64 73 32 _pcache_methods2
16f60 2a 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c * */.#define SQL
16f70 49 54 45 5f 43 4f 4e 46 49 47 5f 47 45 54 50 43 ITE_CONFIG_GETPC
16f80 41 43 48 45 32 20 20 20 31 39 20 20 2f 2a 20 73 ACHE2 19 /* s
16f90 71 6c 69 74 65 33 5f 70 63 61 63 68 65 5f 6d 65 qlite3_pcache_me
16fa0 74 68 6f 64 73 32 2a 20 2a 2f 0a 23 64 65 66 69 thods2* */.#defi
16fb0 6e 65 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 ne SQLITE_CONFIG
16fc0 5f 43 4f 56 45 52 49 4e 47 5f 49 4e 44 45 58 5f _COVERING_INDEX_
16fd0 53 43 41 4e 20 32 30 20 20 2f 2a 20 69 6e 74 20 SCAN 20 /* int
16fe0 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 */.#define SQLIT
16ff0 45 5f 43 4f 4e 46 49 47 5f 53 51 4c 4c 4f 47 20 E_CONFIG_SQLLOG
17000 20 20 20 20 20 20 32 31 20 20 2f 2a 20 78 53 71 21 /* xSq
17010 6c 6c 6f 67 2c 20 76 6f 69 64 2a 20 2a 2f 0a 23 llog, void* */.#
17020 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 43 4f define SQLITE_CO
17030 4e 46 49 47 5f 4d 4d 41 50 5f 53 49 5a 45 20 20 NFIG_MMAP_SIZE
17040 20 20 32 32 20 20 2f 2a 20 73 71 6c 69 74 65 33 22 /* sqlite3
17050 5f 69 6e 74 36 34 2c 20 73 71 6c 69 74 65 33 5f _int64, sqlite3_
17060 69 6e 74 36 34 20 2a 2f 0a 23 64 65 66 69 6e 65 int64 */.#define
17070 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 57 SQLITE_CONFIG_W
17080 49 4e 33 32 5f 48 45 41 50 53 49 5a 45 20 20 20 IN32_HEAPSIZE
17090 20 20 20 32 33 20 20 2f 2a 20 69 6e 74 20 6e 42 23 /* int nB
170a0 79 74 65 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 yte */.#define S
170b0 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 50 43 41 QLITE_CONFIG_PCA
170c0 43 48 45 5f 48 44 52 53 5a 20 20 20 20 20 20 20 CHE_HDRSZ
170d0 20 32 34 20 20 2f 2a 20 69 6e 74 20 2a 70 73 7a 24 /* int *psz
170e0 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 */.#define SQLI
170f0 54 45 5f 43 4f 4e 46 49 47 5f 50 4d 41 53 5a 20 TE_CONFIG_PMASZ
17100 20 20 20 20 20 20 20 20 20 20 20 20 20 20 32 35 25
17110 20 20 2f 2a 20 75 6e 73 69 67 6e 65 64 20 69 6e /* unsigned in
17120 74 20 73 7a 50 6d 61 20 2a 2f 0a 23 64 65 66 69 t szPma */.#defi
17130 6e 65 20 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 ne SQLITE_CONFIG
17140 5f 53 54 4d 54 4a 52 4e 4c 5f 53 50 49 4c 4c 20 _STMTJRNL_SPILL
17150 20 20 20 20 20 32 36 20 20 2f 2a 20 69 6e 74 20 26 /* int
17160 6e 42 79 74 65 20 2a 2f 0a 0a 2f 2a 0a 2a 2a 20 nByte */../*.**
17170 43 41 50 49 33 52 45 46 3a 20 44 61 74 61 62 61 CAPI3REF: Databa
17180 73 65 20 43 6f 6e 6e 65 63 74 69 6f 6e 20 43 6f se Connection Co
17190 6e 66 69 67 75 72 61 74 69 6f 6e 20 4f 70 74 69 nfiguration Opti
171a0 6f 6e 73 0a 2a 2a 0a 2a 2a 20 54 68 65 73 65 20 ons.**.** These
171b0 63 6f 6e 73 74 61 6e 74 73 20 61 72 65 20 74 68 constants are th
171c0 65 20 61 76 61 69 6c 61 62 6c 65 20 69 6e 74 65 e available inte
171d0 67 65 72 20 63 6f 6e 66 69 67 75 72 61 74 69 6f ger configuratio
171e0 6e 20 6f 70 74 69 6f 6e 73 20 74 68 61 74 0a 2a n options that.*
171f0 2a 20 63 61 6e 20 62 65 20 70 61 73 73 65 64 20 * can be passed
17200 61 73 20 74 68 65 20 73 65 63 6f 6e 64 20 61 72 as the second ar
17210 67 75 6d 65 6e 74 20 74 6f 20 74 68 65 20 5b 73 gument to the [s
17220 71 6c 69 74 65 33 5f 64 62 5f 63 6f 6e 66 69 67 qlite3_db_config
17230 28 29 5d 20 69 6e 74 65 72 66 61 63 65 2e 0a 2a ()] interface..*
17240 2a 0a 2a 2a 20 4e 65 77 20 63 6f 6e 66 69 67 75 *.** New configu
17250 72 61 74 69 6f 6e 20 6f 70 74 69 6f 6e 73 20 6d ration options m
17260 61 79 20 62 65 20 61 64 64 65 64 20 69 6e 20 66 ay be added in f
17270 75 74 75 72 65 20 72 65 6c 65 61 73 65 73 20 6f uture releases o
17280 66 20 53 51 4c 69 74 65 2e 0a 2a 2a 20 45 78 69 f SQLite..** Exi
17290 73 74 69 6e 67 20 63 6f 6e 66 69 67 75 72 61 74 sting configurat
172a0 69 6f 6e 20 6f 70 74 69 6f 6e 73 20 6d 69 67 68 ion options migh
172b0 74 20 62 65 20 64 69 73 63 6f 6e 74 69 6e 75 65 t be discontinue
172c0 64 2e 20 20 41 70 70 6c 69 63 61 74 69 6f 6e 73 d. Applications
172d0 0a 2a 2a 20 73 68 6f 75 6c 64 20 63 68 65 63 6b .** should check
172e0 20 74 68 65 20 72 65 74 75 72 6e 20 63 6f 64 65 the return code
172f0 20 66 72 6f 6d 20 5b 73 71 6c 69 74 65 33 5f 64 from [sqlite3_d
17300 62 5f 63 6f 6e 66 69 67 28 29 5d 20 74 6f 20 6d b_config()] to m
17310 61 6b 65 20 73 75 72 65 20 74 68 61 74 0a 2a 2a ake sure that.**
17320 20 74 68 65 20 63 61 6c 6c 20 77 6f 72 6b 65 64 the call worked
17330 2e 20 20 5e 54 68 65 20 5b 73 71 6c 69 74 65 33 . ^The [sqlite3
17340 5f 64 62 5f 63 6f 6e 66 69 67 28 29 5d 20 69 6e _db_config()] in
17350 74 65 72 66 61 63 65 20 77 69 6c 6c 20 72 65 74 terface will ret
17360 75 72 6e 20 61 0a 2a 2a 20 6e 6f 6e 2d 7a 65 72 urn a.** non-zer
17370 6f 20 5b 65 72 72 6f 72 20 63 6f 64 65 5d 20 69 o [error code] i
17380 66 20 61 20 64 69 73 63 6f 6e 74 69 6e 75 65 64 f a discontinued
17390 20 6f 72 20 75 6e 73 75 70 70 6f 72 74 65 64 20 or unsupported
173a0 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 6f 70 configuration op
173b0 74 69 6f 6e 0a 2a 2a 20 69 73 20 69 6e 76 6f 6b tion.** is invok
173c0 65 64 2e 0a 2a 2a 0a 2a 2a 20 3c 64 6c 3e 0a 2a ed..**.** <dl>.*
173d0 2a 20 3c 64 74 3e 53 51 4c 49 54 45 5f 44 42 43 * <dt>SQLITE_DBC
173e0 4f 4e 46 49 47 5f 4c 4f 4f 4b 41 53 49 44 45 3c ONFIG_LOOKASIDE<
173f0 2f 64 74 3e 0a 2a 2a 20 3c 64 64 3e 20 5e 54 68 /dt>.** <dd> ^Th
17400 69 73 20 6f 70 74 69 6f 6e 20 74 61 6b 65 73 20 is option takes
17410 74 68 72 65 65 20 61 64 64 69 74 69 6f 6e 61 6c three additional
17420 20 61 72 67 75 6d 65 6e 74 73 20 74 68 61 74 20 arguments that
17430 64 65 74 65 72 6d 69 6e 65 20 74 68 65 20 0a 2a determine the .*
17440 2a 20 5b 6c 6f 6f 6b 61 73 69 64 65 20 6d 65 6d * [lookaside mem
17450 6f 72 79 20 61 6c 6c 6f 63 61 74 6f 72 5d 20 63 ory allocator] c
17460 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 66 6f 72 onfiguration for
17470 20 74 68 65 20 5b 64 61 74 61 62 61 73 65 20 63 the [database c
17480 6f 6e 6e 65 63 74 69 6f 6e 5d 2e 0a 2a 2a 20 5e onnection]..** ^
17490 54 68 65 20 66 69 72 73 74 20 61 72 67 75 6d 65 The first argume
174a0 6e 74 20 28 74 68 65 20 74 68 69 72 64 20 70 61 nt (the third pa
174b0 72 61 6d 65 74 65 72 20 74 6f 20 5b 73 71 6c 69 rameter to [sqli
174c0 74 65 33 5f 64 62 5f 63 6f 6e 66 69 67 28 29 5d te3_db_config()]
174d0 20 69 73 20 61 0a 2a 2a 20 70 6f 69 6e 74 65 72 is a.** pointer
174e0 20 74 6f 20 61 20 6d 65 6d 6f 72 79 20 62 75 66 to a memory buf
174f0 66 65 72 20 74 6f 20 75 73 65 20 66 6f 72 20 6c fer to use for l
17500 6f 6f 6b 61 73 69 64 65 20 6d 65 6d 6f 72 79 2e ookaside memory.
17510 0a 2a 2a 20 5e 54 68 65 20 66 69 72 73 74 20 61 .** ^The first a
17520 72 67 75 6d 65 6e 74 20 61 66 74 65 72 20 74 68 rgument after th
17530 65 20 53 51 4c 49 54 45 5f 44 42 43 4f 4e 46 49 e SQLITE_DBCONFI
17540 47 5f 4c 4f 4f 4b 41 53 49 44 45 20 76 65 72 62 G_LOOKASIDE verb
17550 0a 2a 2a 20 6d 61 79 20 62 65 20 4e 55 4c 4c 20 .** may be NULL
17560 69 6e 20 77 68 69 63 68 20 63 61 73 65 20 53 51 in which case SQ
17570 4c 69 74 65 20 77 69 6c 6c 20 61 6c 6c 6f 63 61 Lite will alloca
17580 74 65 20 74 68 65 0a 2a 2a 20 6c 6f 6f 6b 61 73 te the.** lookas
17590 69 64 65 20 62 75 66 66 65 72 20 69 74 73 65 6c ide buffer itsel
175a0 66 20 75 73 69 6e 67 20 5b 73 71 6c 69 74 65 33 f using [sqlite3
175b0 5f 6d 61 6c 6c 6f 63 28 29 5d 2e 20 5e 54 68 65 _malloc()]. ^The
175c0 20 73 65 63 6f 6e 64 20 61 72 67 75 6d 65 6e 74 second argument
175d0 20 69 73 20 74 68 65 0a 2a 2a 20 73 69 7a 65 20 is the.** size
175e0 6f 66 20 65 61 63 68 20 6c 6f 6f 6b 61 73 69 64 of each lookasid
175f0 65 20 62 75 66 66 65 72 20 73 6c 6f 74 2e 20 20 e buffer slot.
17600 5e 54 68 65 20 74 68 69 72 64 20 61 72 67 75 6d ^The third argum
17610 65 6e 74 20 69 73 20 74 68 65 20 6e 75 6d 62 65 ent is the numbe
17620 72 20 6f 66 0a 2a 2a 20 73 6c 6f 74 73 2e 20 20 r of.** slots.
17630 54 68 65 20 73 69 7a 65 20 6f 66 20 74 68 65 20 The size of the
17640 62 75 66 66 65 72 20 69 6e 20 74 68 65 20 66 69 buffer in the fi
17650 72 73 74 20 61 72 67 75 6d 65 6e 74 20 6d 75 73 rst argument mus
17660 74 20 62 65 20 67 72 65 61 74 65 72 20 74 68 61 t be greater tha
17670 6e 0a 2a 2a 20 6f 72 20 65 71 75 61 6c 20 74 6f n.** or equal to
17680 20 74 68 65 20 70 72 6f 64 75 63 74 20 6f 66 20 the product of
17690 74 68 65 20 73 65 63 6f 6e 64 20 61 6e 64 20 74 the second and t
176a0 68 69 72 64 20 61 72 67 75 6d 65 6e 74 73 2e 20 hird arguments.
176b0 20 54 68 65 20 62 75 66 66 65 72 0a 2a 2a 20 6d The buffer.** m
176c0 75 73 74 20 62 65 20 61 6c 69 67 6e 65 64 20 74 ust be aligned t
176d0 6f 20 61 6e 20 38 2d 62 79 74 65 20 62 6f 75 6e o an 8-byte boun
176e0 64 61 72 79 2e 20 20 5e 49 66 20 74 68 65 20 73 dary. ^If the s
176f0 65 63 6f 6e 64 20 61 72 67 75 6d 65 6e 74 20 74 econd argument t
17700 6f 0a 2a 2a 20 53 51 4c 49 54 45 5f 44 42 43 4f o.** SQLITE_DBCO
17710 4e 46 49 47 5f 4c 4f 4f 4b 41 53 49 44 45 20 69 NFIG_LOOKASIDE i
17720 73 20 6e 6f 74 20 61 20 6d 75 6c 74 69 70 6c 65 s not a multiple
17730 20 6f 66 20 38 2c 20 69 74 20 69 73 20 69 6e 74 of 8, it is int
17740 65 72 6e 61 6c 6c 79 0a 2a 2a 20 72 6f 75 6e 64 ernally.** round
17750 65 64 20 64 6f 77 6e 20 74 6f 20 74 68 65 20 6e ed down to the n
17760 65 78 74 20 73 6d 61 6c 6c 65 72 20 6d 75 6c 74 ext smaller mult
17770 69 70 6c 65 20 6f 66 20 38 2e 20 20 5e 28 54 68 iple of 8. ^(Th
17780 65 20 6c 6f 6f 6b 61 73 69 64 65 20 6d 65 6d 6f e lookaside memo
17790 72 79 0a 2a 2a 20 63 6f 6e 66 69 67 75 72 61 74 ry.** configurat
177a0 69 6f 6e 20 66 6f 72 20 61 20 64 61 74 61 62 61 ion for a databa
177b0 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 63 61 se connection ca
177c0 6e 20 6f 6e 6c 79 20 62 65 20 63 68 61 6e 67 65 n only be change
177d0 64 20 77 68 65 6e 20 74 68 61 74 0a 2a 2a 20 63 d when that.** c
177e0 6f 6e 6e 65 63 74 69 6f 6e 20 69 73 20 6e 6f 74 onnection is not
177f0 20 63 75 72 72 65 6e 74 6c 79 20 75 73 69 6e 67 currently using
17800 20 6c 6f 6f 6b 61 73 69 64 65 20 6d 65 6d 6f 72 lookaside memor
17810 79 2c 20 6f 72 20 69 6e 20 6f 74 68 65 72 20 77 y, or in other w
17820 6f 72 64 73 0a 2a 2a 20 77 68 65 6e 20 74 68 65 ords.** when the
17830 20 22 63 75 72 72 65 6e 74 20 76 61 6c 75 65 22 "current value"
17840 20 72 65 74 75 72 6e 65 64 20 62 79 0a 2a 2a 20 returned by.**
17850 5b 73 71 6c 69 74 65 33 5f 64 62 5f 73 74 61 74 [sqlite3_db_stat
17860 75 73 5d 28 44 2c 5b 53 51 4c 49 54 45 5f 43 4f us](D,[SQLITE_CO
17870 4e 46 49 47 5f 4c 4f 4f 4b 41 53 49 44 45 5d 2c NFIG_LOOKASIDE],
17880 2e 2e 2e 29 20 69 73 20 7a 65 72 6f 2e 0a 2a 2a ...) is zero..**
17890 20 41 6e 79 20 61 74 74 65 6d 70 74 20 74 6f 20 Any attempt to
178a0 63 68 61 6e 67 65 20 74 68 65 20 6c 6f 6f 6b 61 change the looka
178b0 73 69 64 65 20 6d 65 6d 6f 72 79 20 63 6f 6e 66 side memory conf
178c0 69 67 75 72 61 74 69 6f 6e 20 77 68 65 6e 20 6c iguration when l
178d0 6f 6f 6b 61 73 69 64 65 0a 2a 2a 20 6d 65 6d 6f ookaside.** memo
178e0 72 79 20 69 73 20 69 6e 20 75 73 65 20 6c 65 61 ry is in use lea
178f0 76 65 73 20 74 68 65 20 63 6f 6e 66 69 67 75 72 ves the configur
17900 61 74 69 6f 6e 20 75 6e 63 68 61 6e 67 65 64 20 ation unchanged
17910 61 6e 64 20 72 65 74 75 72 6e 73 20 0a 2a 2a 20 and returns .**
17920 5b 53 51 4c 49 54 45 5f 42 55 53 59 5d 2e 29 5e [SQLITE_BUSY].)^
17930 3c 2f 64 64 3e 0a 2a 2a 0a 2a 2a 20 3c 64 74 3e </dd>.**.** <dt>
17940 53 51 4c 49 54 45 5f 44 42 43 4f 4e 46 49 47 5f SQLITE_DBCONFIG_
17950 45 4e 41 42 4c 45 5f 46 4b 45 59 3c 2f 64 74 3e ENABLE_FKEY</dt>
17960 0a 2a 2a 20 3c 64 64 3e 20 5e 54 68 69 73 20 6f .** <dd> ^This o
17970 70 74 69 6f 6e 20 69 73 20 75 73 65 64 20 74 6f ption is used to
17980 20 65 6e 61 62 6c 65 20 6f 72 20 64 69 73 61 62 enable or disab
17990 6c 65 20 74 68 65 20 65 6e 66 6f 72 63 65 6d 65 le the enforceme
179a0 6e 74 20 6f 66 0a 2a 2a 20 5b 66 6f 72 65 69 67 nt of.** [foreig
179b0 6e 20 6b 65 79 20 63 6f 6e 73 74 72 61 69 6e 74 n key constraint
179c0 73 5d 2e 20 20 54 68 65 72 65 20 73 68 6f 75 6c s]. There shoul
179d0 64 20 62 65 20 74 77 6f 20 61 64 64 69 74 69 6f d be two additio
179e0 6e 61 6c 20 61 72 67 75 6d 65 6e 74 73 2e 0a 2a nal arguments..*
179f0 2a 20 54 68 65 20 66 69 72 73 74 20 61 72 67 75 * The first argu
17a00 6d 65 6e 74 20 69 73 20 61 6e 20 69 6e 74 65 67 ment is an integ
17a10 65 72 20 77 68 69 63 68 20 69 73 20 30 20 74 6f er which is 0 to
17a20 20 64 69 73 61 62 6c 65 20 46 4b 20 65 6e 66 6f disable FK enfo
17a30 72 63 65 6d 65 6e 74 2c 0a 2a 2a 20 70 6f 73 69 rcement,.** posi
17a40 74 69 76 65 20 74 6f 20 65 6e 61 62 6c 65 20 46 tive to enable F
17a50 4b 20 65 6e 66 6f 72 63 65 6d 65 6e 74 20 6f 72 K enforcement or
17a60 20 6e 65 67 61 74 69 76 65 20 74 6f 20 6c 65 61 negative to lea
17a70 76 65 20 46 4b 20 65 6e 66 6f 72 63 65 6d 65 6e ve FK enforcemen
17a80 74 0a 2a 2a 20 75 6e 63 68 61 6e 67 65 64 2e 20 t.** unchanged.
17a90 20 54 68 65 20 73 65 63 6f 6e 64 20 70 61 72 61 The second para
17aa0 6d 65 74 65 72 20 69 73 20 61 20 70 6f 69 6e 74 meter is a point
17ab0 65 72 20 74 6f 20 61 6e 20 69 6e 74 65 67 65 72 er to an integer
17ac0 20 69 6e 74 6f 20 77 68 69 63 68 0a 2a 2a 20 69 into which.** i
17ad0 73 20 77 72 69 74 74 65 6e 20 30 20 6f 72 20 31 s written 0 or 1
17ae0 20 74 6f 20 69 6e 64 69 63 61 74 65 20 77 68 65 to indicate whe
17af0 74 68 65 72 20 46 4b 20 65 6e 66 6f 72 63 65 6d ther FK enforcem
17b00 65 6e 74 20 69 73 20 6f 66 66 20 6f 72 20 6f 6e ent is off or on
17b10 0a 2a 2a 20 66 6f 6c 6c 6f 77 69 6e 67 20 74 68 .** following th
17b20 69 73 20 63 61 6c 6c 2e 20 20 54 68 65 20 73 65 is call. The se
17b30 63 6f 6e 64 20 70 61 72 61 6d 65 74 65 72 20 6d cond parameter m
17b40 61 79 20 62 65 20 61 20 4e 55 4c 4c 20 70 6f 69 ay be a NULL poi
17b50 6e 74 65 72 2c 20 69 6e 0a 2a 2a 20 77 68 69 63 nter, in.** whic
17b60 68 20 63 61 73 65 20 74 68 65 20 46 4b 20 65 6e h case the FK en
17b70 66 6f 72 63 65 6d 65 6e 74 20 73 65 74 74 69 6e forcement settin
17b80 67 20 69 73 20 6e 6f 74 20 72 65 70 6f 72 74 65 g is not reporte
17b90 64 20 62 61 63 6b 2e 20 3c 2f 64 64 3e 0a 2a 2a d back. </dd>.**
17ba0 0a 2a 2a 20 3c 64 74 3e 53 51 4c 49 54 45 5f 44 .** <dt>SQLITE_D
17bb0 42 43 4f 4e 46 49 47 5f 45 4e 41 42 4c 45 5f 54 BCONFIG_ENABLE_T
17bc0 52 49 47 47 45 52 3c 2f 64 74 3e 0a 2a 2a 20 3c RIGGER</dt>.** <
17bd0 64 64 3e 20 5e 54 68 69 73 20 6f 70 74 69 6f 6e dd> ^This option
17be0 20 69 73 20 75 73 65 64 20 74 6f 20 65 6e 61 62 is used to enab
17bf0 6c 65 20 6f 72 20 64 69 73 61 62 6c 65 20 5b 43 le or disable [C
17c00 52 45 41 54 45 20 54 52 49 47 47 45 52 20 7c 20 REATE TRIGGER |
17c10 74 72 69 67 67 65 72 73 5d 2e 0a 2a 2a 20 54 68 triggers]..** Th
17c20 65 72 65 20 73 68 6f 75 6c 64 20 62 65 20 74 77 ere should be tw
17c30 6f 20 61 64 64 69 74 69 6f 6e 61 6c 20 61 72 67 o additional arg
17c40 75 6d 65 6e 74 73 2e 0a 2a 2a 20 54 68 65 20 66 uments..** The f
17c50 69 72 73 74 20 61 72 67 75 6d 65 6e 74 20 69 73 irst argument is
17c60 20 61 6e 20 69 6e 74 65 67 65 72 20 77 68 69 63 an integer whic
17c70 68 20 69 73 20 30 20 74 6f 20 64 69 73 61 62 6c h is 0 to disabl
17c80 65 20 74 72 69 67 67 65 72 73 2c 0a 2a 2a 20 70 e triggers,.** p
17c90 6f 73 69 74 69 76 65 20 74 6f 20 65 6e 61 62 6c ositive to enabl
17ca0 65 20 74 72 69 67 67 65 72 73 20 6f 72 20 6e 65 e triggers or ne
17cb0 67 61 74 69 76 65 20 74 6f 20 6c 65 61 76 65 20 gative to leave
17cc0 74 68 65 20 73 65 74 74 69 6e 67 20 75 6e 63 68 the setting unch
17cd0 61 6e 67 65 64 2e 0a 2a 2a 20 54 68 65 20 73 65 anged..** The se
17ce0 63 6f 6e 64 20 70 61 72 61 6d 65 74 65 72 20 69 cond parameter i
17cf0 73 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 61 s a pointer to a
17d00 6e 20 69 6e 74 65 67 65 72 20 69 6e 74 6f 20 77 n integer into w
17d10 68 69 63 68 0a 2a 2a 20 69 73 20 77 72 69 74 74 hich.** is writt
17d20 65 6e 20 30 20 6f 72 20 31 20 74 6f 20 69 6e 64 en 0 or 1 to ind
17d30 69 63 61 74 65 20 77 68 65 74 68 65 72 20 74 72 icate whether tr
17d40 69 67 67 65 72 73 20 61 72 65 20 64 69 73 61 62 iggers are disab
17d50 6c 65 64 20 6f 72 20 65 6e 61 62 6c 65 64 0a 2a led or enabled.*
17d60 2a 20 66 6f 6c 6c 6f 77 69 6e 67 20 74 68 69 73 * following this
17d70 20 63 61 6c 6c 2e 20 20 54 68 65 20 73 65 63 6f call. The seco
17d80 6e 64 20 70 61 72 61 6d 65 74 65 72 20 6d 61 79 nd parameter may
17d90 20 62 65 20 61 20 4e 55 4c 4c 20 70 6f 69 6e 74 be a NULL point
17da0 65 72 2c 20 69 6e 0a 2a 2a 20 77 68 69 63 68 20 er, in.** which
17db0 63 61 73 65 20 74 68 65 20 74 72 69 67 67 65 72 case the trigger
17dc0 20 73 65 74 74 69 6e 67 20 69 73 20 6e 6f 74 20 setting is not
17dd0 72 65 70 6f 72 74 65 64 20 62 61 63 6b 2e 20 3c reported back. <
17de0 2f 64 64 3e 0a 2a 2a 0a 2a 2a 20 3c 64 74 3e 53 /dd>.**.** <dt>S
17df0 51 4c 49 54 45 5f 44 42 43 4f 4e 46 49 47 5f 45 QLITE_DBCONFIG_E
17e00 4e 41 42 4c 45 5f 46 54 53 33 5f 54 4f 4b 45 4e NABLE_FTS3_TOKEN
17e10 49 5a 45 52 3c 2f 64 74 3e 0a 2a 2a 20 3c 64 64 IZER</dt>.** <dd
17e20 3e 20 5e 54 68 69 73 20 6f 70 74 69 6f 6e 20 69 > ^This option i
17e30 73 20 75 73 65 64 20 74 6f 20 65 6e 61 62 6c 65 s used to enable
17e40 20 6f 72 20 64 69 73 61 62 6c 65 20 74 68 65 20 or disable the
17e50 74 77 6f 2d 61 72 67 75 6d 65 6e 74 0a 2a 2a 20 two-argument.**
17e60 76 65 72 73 69 6f 6e 20 6f 66 20 74 68 65 20 5b version of the [
17e70 66 74 73 33 5f 74 6f 6b 65 6e 69 7a 65 72 28 29 fts3_tokenizer()
17e80 5d 20 66 75 6e 63 74 69 6f 6e 20 77 68 69 63 68 ] function which
17e90 20 69 73 20 70 61 72 74 20 6f 66 20 74 68 65 0a is part of the.
17ea0 2a 2a 20 5b 46 54 53 33 5d 20 66 75 6c 6c 2d 74 ** [FTS3] full-t
17eb0 65 78 74 20 73 65 61 72 63 68 20 65 6e 67 69 6e ext search engin
17ec0 65 20 65 78 74 65 6e 73 69 6f 6e 2e 0a 2a 2a 20 e extension..**
17ed0 54 68 65 72 65 20 73 68 6f 75 6c 64 20 62 65 20 There should be
17ee0 74 77 6f 20 61 64 64 69 74 69 6f 6e 61 6c 20 61 two additional a
17ef0 72 67 75 6d 65 6e 74 73 2e 0a 2a 2a 20 54 68 65 rguments..** The
17f00 20 66 69 72 73 74 20 61 72 67 75 6d 65 6e 74 20 first argument
17f10 69 73 20 61 6e 20 69 6e 74 65 67 65 72 20 77 68 is an integer wh
17f20 69 63 68 20 69 73 20 30 20 74 6f 20 64 69 73 61 ich is 0 to disa
17f30 62 6c 65 20 66 74 73 33 5f 74 6f 6b 65 6e 69 7a ble fts3_tokeniz
17f40 65 72 28 29 20 6f 72 0a 2a 2a 20 70 6f 73 69 74 er() or.** posit
17f50 69 76 65 20 74 6f 20 65 6e 61 62 6c 65 20 66 74 ive to enable ft
17f60 73 33 5f 74 6f 6b 65 6e 69 7a 65 72 28 29 20 6f s3_tokenizer() o
17f70 72 20 6e 65 67 61 74 69 76 65 20 74 6f 20 6c 65 r negative to le
17f80 61 76 65 20 74 68 65 20 73 65 74 74 69 6e 67 0a ave the setting.
17f90 2a 2a 20 75 6e 63 68 61 6e 67 65 64 2e 0a 2a 2a ** unchanged..**
17fa0 20 54 68 65 20 73 65 63 6f 6e 64 20 70 61 72 61 The second para
17fb0 6d 65 74 65 72 20 69 73 20 61 20 70 6f 69 6e 74 meter is a point
17fc0 65 72 20 74 6f 20 61 6e 20 69 6e 74 65 67 65 72 er to an integer
17fd0 20 69 6e 74 6f 20 77 68 69 63 68 0a 2a 2a 20 69 into which.** i
17fe0 73 20 77 72 69 74 74 65 6e 20 30 20 6f 72 20 31 s written 0 or 1
17ff0 20 74 6f 20 69 6e 64 69 63 61 74 65 20 77 68 65 to indicate whe
18000 74 68 65 72 20 66 74 73 33 5f 74 6f 6b 65 6e 69 ther fts3_tokeni
18010 7a 65 72 20 69 73 20 64 69 73 61 62 6c 65 64 20 zer is disabled
18020 6f 72 20 65 6e 61 62 6c 65 64 0a 2a 2a 20 66 6f or enabled.** fo
18030 6c 6c 6f 77 69 6e 67 20 74 68 69 73 20 63 61 6c llowing this cal
18040 6c 2e 20 20 54 68 65 20 73 65 63 6f 6e 64 20 70 l. The second p
18050 61 72 61 6d 65 74 65 72 20 6d 61 79 20 62 65 20 arameter may be
18060 61 20 4e 55 4c 4c 20 70 6f 69 6e 74 65 72 2c 20 a NULL pointer,
18070 69 6e 0a 2a 2a 20 77 68 69 63 68 20 63 61 73 65 in.** which case
18080 20 74 68 65 20 6e 65 77 20 73 65 74 74 69 6e 67 the new setting
18090 20 69 73 20 6e 6f 74 20 72 65 70 6f 72 74 65 64 is not reported
180a0 20 62 61 63 6b 2e 20 3c 2f 64 64 3e 0a 2a 2a 0a back. </dd>.**.
180b0 2a 2a 20 3c 64 74 3e 53 51 4c 49 54 45 5f 44 42 ** <dt>SQLITE_DB
180c0 43 4f 4e 46 49 47 5f 45 4e 41 42 4c 45 5f 4c 4f CONFIG_ENABLE_LO
180d0 41 44 5f 45 58 54 45 4e 53 49 4f 4e 3c 2f 64 74 AD_EXTENSION</dt
180e0 3e 0a 2a 2a 20 3c 64 64 3e 20 5e 54 68 69 73 20 >.** <dd> ^This
180f0 6f 70 74 69 6f 6e 20 69 73 20 75 73 65 64 20 74 option is used t
18100 6f 20 65 6e 61 62 6c 65 20 6f 72 20 64 69 73 61 o enable or disa
18110 62 6c 65 20 74 68 65 20 5b 73 71 6c 69 74 65 33 ble the [sqlite3
18120 5f 6c 6f 61 64 5f 65 78 74 65 6e 73 69 6f 6e 28 _load_extension(
18130 29 5d 0a 2a 2a 20 69 6e 74 65 72 66 61 63 65 20 )].** interface
18140 69 6e 64 65 70 65 6e 64 65 6e 74 6c 79 20 6f 66 independently of
18150 20 74 68 65 20 5b 6c 6f 61 64 5f 65 78 74 65 6e the [load_exten
18160 73 69 6f 6e 28 29 5d 20 53 51 4c 20 66 75 6e 63 sion()] SQL func
18170 74 69 6f 6e 2e 0a 2a 2a 20 54 68 65 20 5b 73 71 tion..** The [sq
18180 6c 69 74 65 33 5f 65 6e 61 62 6c 65 5f 6c 6f 61 lite3_enable_loa
18190 64 5f 65 78 74 65 6e 73 69 6f 6e 28 29 5d 20 41 d_extension()] A
181a0 50 49 20 65 6e 61 62 6c 65 73 20 6f 72 20 64 69 PI enables or di
181b0 73 61 62 6c 65 73 20 62 6f 74 68 20 74 68 65 0a sables both the.
181c0 2a 2a 20 43 2d 41 50 49 20 5b 73 71 6c 69 74 65 ** C-API [sqlite
181d0 33 5f 6c 6f 61 64 5f 65 78 74 65 6e 73 69 6f 6e 3_load_extension
181e0 28 29 5d 20 61 6e 64 20 74 68 65 20 53 51 4c 20 ()] and the SQL
181f0 66 75 6e 63 74 69 6f 6e 20 5b 6c 6f 61 64 5f 65 function [load_e
18200 78 74 65 6e 73 69 6f 6e 28 29 5d 2e 0a 2a 2a 20 xtension()]..**
18210 54 68 65 72 65 20 73 68 6f 75 6c 64 20 62 65 20 There should be
18220 74 77 6f 20 61 64 64 69 74 69 6f 6e 61 6c 20 61 two additional a
18230 72 67 75 6d 65 6e 74 73 2e 0a 2a 2a 20 57 68 65 rguments..** Whe
18240 6e 20 74 68 65 20 66 69 72 73 74 20 61 72 67 75 n the first argu
18250 6d 65 6e 74 20 74 6f 20 74 68 69 73 20 69 6e 74 ment to this int
18260 65 72 66 61 63 65 20 69 73 20 31 2c 20 74 68 65 erface is 1, the
18270 6e 20 6f 6e 6c 79 20 74 68 65 20 43 2d 41 50 49 n only the C-API
18280 20 69 73 0a 2a 2a 20 65 6e 61 62 6c 65 64 20 61 is.** enabled a
18290 6e 64 20 74 68 65 20 53 51 4c 20 66 75 6e 63 74 nd the SQL funct
182a0 69 6f 6e 20 72 65 6d 61 69 6e 73 20 64 69 73 61 ion remains disa
182b0 62 6c 65 64 2e 20 20 49 66 20 74 68 65 20 66 69 bled. If the fi
182c0 72 73 74 20 61 72 67 75 6d 65 6e 74 20 74 6f 0a rst argument to.
182d0 2a 2a 20 74 68 69 73 20 69 6e 74 65 72 66 61 63 ** this interfac
182e0 65 20 69 73 20 30 2c 20 74 68 65 6e 20 62 6f 74 e is 0, then bot
182f0 68 20 74 68 65 20 43 2d 41 50 49 20 61 6e 64 20 h the C-API and
18300 74 68 65 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e the SQL function
18310 20 61 72 65 20 64 69 73 61 62 6c 65 64 2e 0a 2a are disabled..*
18320 2a 20 49 66 20 74 68 65 20 66 69 72 73 74 20 61 * If the first a
18330 72 67 75 6d 65 6e 74 20 69 73 20 2d 31 2c 20 74 rgument is -1, t
18340 68 65 6e 20 6e 6f 20 63 68 61 6e 67 65 73 20 61 hen no changes a
18350 72 65 20 6d 61 64 65 20 74 6f 20 73 74 61 74 65 re made to state
18360 20 6f 66 20 65 69 74 68 65 72 20 74 68 65 0a 2a of either the.*
18370 2a 20 43 2d 41 50 49 20 6f 72 20 74 68 65 20 53 * C-API or the S
18380 51 4c 20 66 75 6e 63 74 69 6f 6e 2e 0a 2a 2a 20 QL function..**
18390 54 68 65 20 73 65 63 6f 6e 64 20 70 61 72 61 6d The second param
183a0 65 74 65 72 20 69 73 20 61 20 70 6f 69 6e 74 65 eter is a pointe
183b0 72 20 74 6f 20 61 6e 20 69 6e 74 65 67 65 72 20 r to an integer
183c0 69 6e 74 6f 20 77 68 69 63 68 0a 2a 2a 20 69 73 into which.** is
183d0 20 77 72 69 74 74 65 6e 20 30 20 6f 72 20 31 20 written 0 or 1
183e0 74 6f 20 69 6e 64 69 63 61 74 65 20 77 68 65 74 to indicate whet
183f0 68 65 72 20 5b 73 71 6c 69 74 65 33 5f 6c 6f 61 her [sqlite3_loa
18400 64 5f 65 78 74 65 6e 73 69 6f 6e 28 29 5d 20 69 d_extension()] i
18410 6e 74 65 72 66 61 63 65 0a 2a 2a 20 69 73 20 64 nterface.** is d
18420 69 73 61 62 6c 65 64 20 6f 72 20 65 6e 61 62 6c isabled or enabl
18430 65 64 20 66 6f 6c 6c 6f 77 69 6e 67 20 74 68 69 ed following thi
18440 73 20 63 61 6c 6c 2e 20 20 54 68 65 20 73 65 63 s call. The sec
18450 6f 6e 64 20 70 61 72 61 6d 65 74 65 72 20 6d 61 ond parameter ma
18460 79 0a 2a 2a 20 62 65 20 61 20 4e 55 4c 4c 20 70 y.** be a NULL p
18470 6f 69 6e 74 65 72 2c 20 69 6e 20 77 68 69 63 68 ointer, in which
18480 20 63 61 73 65 20 74 68 65 20 6e 65 77 20 73 65 case the new se
18490 74 74 69 6e 67 20 69 73 20 6e 6f 74 20 72 65 70 tting is not rep
184a0 6f 72 74 65 64 20 62 61 63 6b 2e 0a 2a 2a 20 3c orted back..** <
184b0 2f 64 64 3e 0a 2a 2a 0a 2a 2a 20 3c 64 74 3e 53 /dd>.**.** <dt>S
184c0 51 4c 49 54 45 5f 44 42 43 4f 4e 46 49 47 5f 4d QLITE_DBCONFIG_M
184d0 41 49 4e 44 42 4e 41 4d 45 3c 2f 64 74 3e 0a 2a AINDBNAME</dt>.*
184e0 2a 20 3c 64 64 3e 20 5e 54 68 69 73 20 6f 70 74 * <dd> ^This opt
184f0 69 6f 6e 20 69 73 20 75 73 65 64 20 74 6f 20 63 ion is used to c
18500 68 61 6e 67 65 20 74 68 65 20 6e 61 6d 65 20 6f hange the name o
18510 66 20 74 68 65 20 22 6d 61 69 6e 22 20 64 61 74 f the "main" dat
18520 61 62 61 73 65 0a 2a 2a 20 73 63 68 65 6d 61 2e abase.** schema.
18530 20 20 5e 54 68 65 20 73 6f 6c 65 20 61 72 67 75 ^The sole argu
18540 6d 65 6e 74 20 69 73 20 61 20 70 6f 69 6e 74 65 ment is a pointe
18550 72 20 74 6f 20 61 20 63 6f 6e 73 74 61 6e 74 20 r to a constant
18560 55 54 46 38 20 73 74 72 69 6e 67 0a 2a 2a 20 77 UTF8 string.** w
18570 68 69 63 68 20 77 69 6c 6c 20 62 65 63 6f 6d 65 hich will become
18580 20 74 68 65 20 6e 65 77 20 73 63 68 65 6d 61 20 the new schema
18590 6e 61 6d 65 20 69 6e 20 70 6c 61 63 65 20 6f 66 name in place of
185a0 20 22 6d 61 69 6e 22 2e 20 20 5e 53 51 4c 69 74 "main". ^SQLit
185b0 65 0a 2a 2a 20 64 6f 65 73 20 6e 6f 74 20 6d 61 e.** does not ma
185c0 6b 65 20 61 20 63 6f 70 79 20 6f 66 20 74 68 65 ke a copy of the
185d0 20 6e 65 77 20 6d 61 69 6e 20 73 63 68 65 6d 61 new main schema
185e0 20 6e 61 6d 65 20 73 74 72 69 6e 67 2c 20 73 6f name string, so
185f0 20 74 68 65 20 61 70 70 6c 69 63 61 74 69 6f 6e the application
18600 0a 2a 2a 20 6d 75 73 74 20 65 6e 73 75 72 65 20 .** must ensure
18610 74 68 61 74 20 74 68 65 20 61 72 67 75 6d 65 6e that the argumen
18620 74 20 70 61 73 73 65 64 20 69 6e 74 6f 20 74 68 t passed into th
18630 69 73 20 44 42 43 4f 4e 46 49 47 20 6f 70 74 69 is DBCONFIG opti
18640 6f 6e 20 69 73 20 75 6e 63 68 61 6e 67 65 64 0a on is unchanged.
18650 2a 2a 20 75 6e 74 69 6c 20 61 66 74 65 72 20 74 ** until after t
18660 68 65 20 64 61 74 61 62 61 73 65 20 63 6f 6e 6e he database conn
18670 65 63 74 69 6f 6e 20 63 6c 6f 73 65 73 2e 0a 2a ection closes..*
18680 2a 20 3c 2f 64 64 3e 0a 2a 2a 0a 2a 2a 20 3c 64 * </dd>.**.** <d
18690 74 3e 53 51 4c 49 54 45 5f 44 42 43 4f 4e 46 49 t>SQLITE_DBCONFI
186a0 47 5f 4e 4f 5f 43 4b 50 54 5f 4f 4e 5f 43 4c 4f G_NO_CKPT_ON_CLO
186b0 53 45 3c 2f 64 74 3e 0a 2a 2a 20 3c 64 64 3e 20 SE</dt>.** <dd>
186c0 55 73 75 61 6c 6c 79 2c 20 77 68 65 6e 20 61 20 Usually, when a
186d0 64 61 74 61 62 61 73 65 20 69 6e 20 77 61 6c 20 database in wal
186e0 6d 6f 64 65 20 69 73 20 63 6c 6f 73 65 64 20 6f mode is closed o
186f0 72 20 64 65 74 61 63 68 65 64 20 66 72 6f 6d 20 r detached from
18700 61 20 0a 2a 2a 20 64 61 74 61 62 61 73 65 20 68 a .** database h
18710 61 6e 64 6c 65 2c 20 53 51 4c 69 74 65 20 63 68 andle, SQLite ch
18720 65 63 6b 73 20 69 66 20 74 68 69 73 20 77 69 6c ecks if this wil
18730 6c 20 6d 65 61 6e 20 74 68 61 74 20 74 68 65 72 l mean that ther
18740 65 20 61 72 65 20 6e 6f 77 20 6e 6f 20 0a 2a 2a e are now no .**
18750 20 63 6f 6e 6e 65 63 74 69 6f 6e 73 20 61 74 20 connections at
18760 61 6c 6c 20 74 6f 20 74 68 65 20 64 61 74 61 62 all to the datab
18770 61 73 65 2e 20 49 66 20 73 6f 2c 20 69 74 20 70 ase. If so, it p
18780 65 72 66 6f 72 6d 73 20 61 20 63 68 65 63 6b 70 erforms a checkp
18790 6f 69 6e 74 20 0a 2a 2a 20 6f 70 65 72 61 74 69 oint .** operati
187a0 6f 6e 20 62 65 66 6f 72 65 20 63 6c 6f 73 69 6e on before closin
187b0 67 20 74 68 65 20 63 6f 6e 6e 65 63 74 69 6f 6e g the connection
187c0 2e 20 54 68 69 73 20 6f 70 74 69 6f 6e 20 6d 61 . This option ma
187d0 79 20 62 65 20 75 73 65 64 20 74 6f 0a 2a 2a 20 y be used to.**
187e0 6f 76 65 72 72 69 64 65 20 74 68 69 73 20 62 65 override this be
187f0 68 61 76 69 6f 75 72 2e 20 54 68 65 20 66 69 72 haviour. The fir
18800 73 74 20 70 61 72 61 6d 65 74 65 72 20 70 61 73 st parameter pas
18810 73 65 64 20 74 6f 20 74 68 69 73 20 6f 70 65 72 sed to this oper
18820 61 74 69 6f 6e 0a 2a 2a 20 69 73 20 61 6e 20 69 ation.** is an i
18830 6e 74 65 67 65 72 20 2d 20 6e 6f 6e 2d 7a 65 72 nteger - non-zer
18840 6f 20 74 6f 20 64 69 73 61 62 6c 65 20 63 68 65 o to disable che
18850 63 6b 70 6f 69 6e 74 73 2d 6f 6e 2d 63 6c 6f 73 ckpoints-on-clos
18860 65 2c 20 6f 72 20 7a 65 72 6f 20 28 74 68 65 0a e, or zero (the.
18870 2a 2a 20 64 65 66 61 75 6c 74 29 20 74 6f 20 65 ** default) to e
18880 6e 61 62 6c 65 20 74 68 65 6d 2e 20 54 68 65 20 nable them. The
18890 73 65 63 6f 6e 64 20 70 61 72 61 6d 65 74 65 72 second parameter
188a0 20 69 73 20 61 20 70 6f 69 6e 74 65 72 20 74 6f is a pointer to
188b0 20 61 6e 20 69 6e 74 65 67 65 72 0a 2a 2a 20 69 an integer.** i
188c0 6e 74 6f 20 77 68 69 63 68 20 69 73 20 77 72 69 nto which is wri
188d0 74 74 65 6e 20 30 20 6f 72 20 31 20 74 6f 20 69 tten 0 or 1 to i
188e0 6e 64 69 63 61 74 65 20 77 68 65 74 68 65 72 20 ndicate whether
188f0 63 68 65 63 6b 70 6f 69 6e 74 73 2d 6f 6e 2d 63 checkpoints-on-c
18900 6c 6f 73 65 0a 2a 2a 20 68 61 76 65 20 62 65 65 lose.** have bee
18910 6e 20 64 69 73 61 62 6c 65 64 20 2d 20 30 20 69 n disabled - 0 i
18920 66 20 74 68 65 79 20 61 72 65 20 6e 6f 74 20 64 f they are not d
18930 69 73 61 62 6c 65 64 2c 20 31 20 69 66 20 74 68 isabled, 1 if th
18940 65 79 20 61 72 65 2e 0a 2a 2a 20 3c 2f 64 64 3e ey are..** </dd>
18950 0a 2a 2a 0a 2a 2a 20 3c 2f 64 6c 3e 0a 2a 2f 0a .**.** </dl>.*/.
18960 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 44 #define SQLITE_D
18970 42 43 4f 4e 46 49 47 5f 4d 41 49 4e 44 42 4e 41 BCONFIG_MAINDBNA
18980 4d 45 20 20 20 20 20 20 20 20 20 20 20 20 31 30 ME 10
18990 30 30 20 2f 2a 20 63 6f 6e 73 74 20 63 68 61 72 00 /* const char
189a0 2a 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c * */.#define SQL
189b0 49 54 45 5f 44 42 43 4f 4e 46 49 47 5f 4c 4f 4f ITE_DBCONFIG_LOO
189c0 4b 41 53 49 44 45 20 20 20 20 20 20 20 20 20 20 KASIDE
189d0 20 20 20 31 30 30 31 20 2f 2a 20 76 6f 69 64 2a 1001 /* void*
189e0 20 69 6e 74 20 69 6e 74 20 2a 2f 0a 23 64 65 66 int int */.#def
189f0 69 6e 65 20 53 51 4c 49 54 45 5f 44 42 43 4f 4e ine SQLITE_DBCON
18a00 46 49 47 5f 45 4e 41 42 4c 45 5f 46 4b 45 59 20 FIG_ENABLE_FKEY
18a10 20 20 20 20 20 20 20 20 20 20 31 30 30 32 20 2f 1002 /
18a20 2a 20 69 6e 74 20 69 6e 74 2a 20 2a 2f 0a 23 64 * int int* */.#d
18a30 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 44 42 43 efine SQLITE_DBC
18a40 4f 4e 46 49 47 5f 45 4e 41 42 4c 45 5f 54 52 49 ONFIG_ENABLE_TRI
18a50 47 47 45 52 20 20 20 20 20 20 20 20 31 30 30 33 GGER 1003
18a60 20 2f 2a 20 69 6e 74 20 69 6e 74 2a 20 2a 2f 0a /* int int* */.
18a70 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 44 #define SQLITE_D
18a80 42 43 4f 4e 46 49 47 5f 45 4e 41 42 4c 45 5f 46 BCONFIG_ENABLE_F
18a90 54 53 33 5f 54 4f 4b 45 4e 49 5a 45 52 20 31 30 TS3_TOKENIZER 10
18aa0 30 34 20 2f 2a 20 69 6e 74 20 69 6e 74 2a 20 2a 04 /* int int* *
18ab0 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 /.#define SQLITE
18ac0 5f 44 42 43 4f 4e 46 49 47 5f 45 4e 41 42 4c 45 _DBCONFIG_ENABLE
18ad0 5f 4c 4f 41 44 5f 45 58 54 45 4e 53 49 4f 4e 20 _LOAD_EXTENSION
18ae0 31 30 30 35 20 2f 2a 20 69 6e 74 20 69 6e 74 2a 1005 /* int int*
18af0 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 */.#define SQLI
18b00 54 45 5f 44 42 43 4f 4e 46 49 47 5f 4e 4f 5f 43 TE_DBCONFIG_NO_C
18b10 4b 50 54 5f 4f 4e 5f 43 4c 4f 53 45 20 20 20 20 KPT_ON_CLOSE
18b20 20 20 31 30 30 36 20 2f 2a 20 69 6e 74 20 69 6e 1006 /* int in
18b30 74 2a 20 2a 2f 0a 0a 0a 2f 2a 0a 2a 2a 20 43 41 t* */.../*.** CA
18b40 50 49 33 52 45 46 3a 20 45 6e 61 62 6c 65 20 4f PI3REF: Enable O
18b50 72 20 44 69 73 61 62 6c 65 20 45 78 74 65 6e 64 r Disable Extend
18b60 65 64 20 52 65 73 75 6c 74 20 43 6f 64 65 73 0a ed Result Codes.
18b70 2a 2a 20 4d 45 54 48 4f 44 3a 20 73 71 6c 69 74 ** METHOD: sqlit
18b80 65 33 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 e3.**.** ^The sq
18b90 6c 69 74 65 33 5f 65 78 74 65 6e 64 65 64 5f 72 lite3_extended_r
18ba0 65 73 75 6c 74 5f 63 6f 64 65 73 28 29 20 72 6f esult_codes() ro
18bb0 75 74 69 6e 65 20 65 6e 61 62 6c 65 73 20 6f 72 utine enables or
18bc0 20 64 69 73 61 62 6c 65 73 20 74 68 65 0a 2a 2a disables the.**
18bd0 20 5b 65 78 74 65 6e 64 65 64 20 72 65 73 75 6c [extended resul
18be0 74 20 63 6f 64 65 73 5d 20 66 65 61 74 75 72 65 t codes] feature
18bf0 20 6f 66 20 53 51 4c 69 74 65 2e 20 5e 54 68 65 of SQLite. ^The
18c00 20 65 78 74 65 6e 64 65 64 20 72 65 73 75 6c 74 extended result
18c10 0a 2a 2a 20 63 6f 64 65 73 20 61 72 65 20 64 69 .** codes are di
18c20 73 61 62 6c 65 64 20 62 79 20 64 65 66 61 75 6c sabled by defaul
18c30 74 20 66 6f 72 20 68 69 73 74 6f 72 69 63 61 6c t for historical
18c40 20 63 6f 6d 70 61 74 69 62 69 6c 69 74 79 2e 0a compatibility..
18c50 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f 65 */.int sqlite3_e
18c60 78 74 65 6e 64 65 64 5f 72 65 73 75 6c 74 5f 63 xtended_result_c
18c70 6f 64 65 73 28 73 71 6c 69 74 65 33 2a 2c 20 69 odes(sqlite3*, i
18c80 6e 74 20 6f 6e 6f 66 66 29 3b 0a 0a 2f 2a 0a 2a nt onoff);../*.*
18c90 2a 20 43 41 50 49 33 52 45 46 3a 20 4c 61 73 74 * CAPI3REF: Last
18ca0 20 49 6e 73 65 72 74 20 52 6f 77 69 64 0a 2a 2a Insert Rowid.**
18cb0 20 4d 45 54 48 4f 44 3a 20 73 71 6c 69 74 65 33 METHOD: sqlite3
18cc0 0a 2a 2a 0a 2a 2a 20 5e 45 61 63 68 20 65 6e 74 .**.** ^Each ent
18cd0 72 79 20 69 6e 20 6d 6f 73 74 20 53 51 4c 69 74 ry in most SQLit
18ce0 65 20 74 61 62 6c 65 73 20 28 65 78 63 65 70 74 e tables (except
18cf0 20 66 6f 72 20 5b 57 49 54 48 4f 55 54 20 52 4f for [WITHOUT RO
18d00 57 49 44 5d 20 74 61 62 6c 65 73 29 0a 2a 2a 20 WID] tables).**
18d10 68 61 73 20 61 20 75 6e 69 71 75 65 20 36 34 2d has a unique 64-
18d20 62 69 74 20 73 69 67 6e 65 64 0a 2a 2a 20 69 6e bit signed.** in
18d30 74 65 67 65 72 20 6b 65 79 20 63 61 6c 6c 65 64 teger key called
18d40 20 74 68 65 20 5b 52 4f 57 49 44 20 7c 20 22 72 the [ROWID | "r
18d50 6f 77 69 64 22 5d 2e 20 5e 54 68 65 20 72 6f 77 owid"]. ^The row
18d60 69 64 20 69 73 20 61 6c 77 61 79 73 20 61 76 61 id is always ava
18d70 69 6c 61 62 6c 65 0a 2a 2a 20 61 73 20 61 6e 20 ilable.** as an
18d80 75 6e 64 65 63 6c 61 72 65 64 20 63 6f 6c 75 6d undeclared colum
18d90 6e 20 6e 61 6d 65 64 20 52 4f 57 49 44 2c 20 4f n named ROWID, O
18da0 49 44 2c 20 6f 72 20 5f 52 4f 57 49 44 5f 20 61 ID, or _ROWID_ a
18db0 73 20 6c 6f 6e 67 20 61 73 20 74 68 6f 73 65 0a s long as those.
18dc0 2a 2a 20 6e 61 6d 65 73 20 61 72 65 20 6e 6f 74 ** names are not
18dd0 20 61 6c 73 6f 20 75 73 65 64 20 62 79 20 65 78 also used by ex
18de0 70 6c 69 63 69 74 6c 79 20 64 65 63 6c 61 72 65 plicitly declare
18df0 64 20 63 6f 6c 75 6d 6e 73 2e 20 5e 49 66 0a 2a d columns. ^If.*
18e00 2a 20 74 68 65 20 74 61 62 6c 65 20 68 61 73 20 * the table has
18e10 61 20 63 6f 6c 75 6d 6e 20 6f 66 20 74 79 70 65 a column of type
18e20 20 5b 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 [INTEGER PRIMAR
18e30 59 20 4b 45 59 5d 20 74 68 65 6e 20 74 68 61 74 Y KEY] then that
18e40 20 63 6f 6c 75 6d 6e 0a 2a 2a 20 69 73 20 61 6e column.** is an
18e50 6f 74 68 65 72 20 61 6c 69 61 73 20 66 6f 72 20 other alias for
18e60 74 68 65 20 72 6f 77 69 64 2e 0a 2a 2a 0a 2a 2a the rowid..**.**
18e70 20 5e 54 68 65 20 73 71 6c 69 74 65 33 5f 6c 61 ^The sqlite3_la
18e80 73 74 5f 69 6e 73 65 72 74 5f 72 6f 77 69 64 28 st_insert_rowid(
18e90 44 29 20 69 6e 74 65 72 66 61 63 65 20 72 65 74 D) interface ret
18ea0 75 72 6e 73 20 74 68 65 20 5b 72 6f 77 69 64 5d urns the [rowid]
18eb0 20 6f 66 20 74 68 65 20 0a 2a 2a 20 6d 6f 73 74 of the .** most
18ec0 20 72 65 63 65 6e 74 20 73 75 63 63 65 73 73 66 recent successf
18ed0 75 6c 20 5b 49 4e 53 45 52 54 5d 20 69 6e 74 6f ul [INSERT] into
18ee0 20 61 20 72 6f 77 69 64 20 74 61 62 6c 65 20 6f a rowid table o
18ef0 72 20 5b 76 69 72 74 75 61 6c 20 74 61 62 6c 65 r [virtual table
18f00 5d 0a 2a 2a 20 6f 6e 20 64 61 74 61 62 61 73 65 ].** on database
18f10 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 44 2e 0a 2a connection D..*
18f20 2a 20 5e 49 6e 73 65 72 74 73 20 69 6e 74 6f 20 * ^Inserts into
18f30 5b 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5d 20 [WITHOUT ROWID]
18f40 74 61 62 6c 65 73 20 61 72 65 20 6e 6f 74 20 72 tables are not r
18f50 65 63 6f 72 64 65 64 2e 0a 2a 2a 20 5e 49 66 20 ecorded..** ^If
18f60 6e 6f 20 73 75 63 63 65 73 73 66 75 6c 20 5b 49 no successful [I
18f70 4e 53 45 52 54 5d 73 20 69 6e 74 6f 20 72 6f 77 NSERT]s into row
18f80 69 64 20 74 61 62 6c 65 73 0a 2a 2a 20 68 61 76 id tables.** hav
18f90 65 20 65 76 65 72 20 6f 63 63 75 72 72 65 64 20 e ever occurred
18fa0 6f 6e 20 74 68 65 20 64 61 74 61 62 61 73 65 20 on the database
18fb0 63 6f 6e 6e 65 63 74 69 6f 6e 20 44 2c 20 0a 2a connection D, .*
18fc0 2a 20 74 68 65 6e 20 73 71 6c 69 74 65 33 5f 6c * then sqlite3_l
18fd0 61 73 74 5f 69 6e 73 65 72 74 5f 72 6f 77 69 64 ast_insert_rowid
18fe0 28 44 29 20 72 65 74 75 72 6e 73 20 7a 65 72 6f (D) returns zero
18ff0 2e 0a 2a 2a 0a 2a 2a 20 5e 28 49 66 20 61 6e 20 ..**.** ^(If an
19000 5b 49 4e 53 45 52 54 5d 20 6f 63 63 75 72 73 20 [INSERT] occurs
19010 77 69 74 68 69 6e 20 61 20 74 72 69 67 67 65 72 within a trigger
19020 20 6f 72 20 77 69 74 68 69 6e 20 61 20 5b 76 69 or within a [vi
19030 72 74 75 61 6c 20 74 61 62 6c 65 5d 0a 2a 2a 20 rtual table].**
19040 6d 65 74 68 6f 64 2c 20 74 68 65 6e 20 74 68 69 method, then thi
19050 73 20 72 6f 75 74 69 6e 65 20 77 69 6c 6c 20 72 s routine will r
19060 65 74 75 72 6e 20 74 68 65 20 5b 72 6f 77 69 64 eturn the [rowid
19070 5d 20 6f 66 20 74 68 65 20 69 6e 73 65 72 74 65 ] of the inserte
19080 64 0a 2a 2a 20 72 6f 77 20 61 73 20 6c 6f 6e 67 d.** row as long
19090 20 61 73 20 74 68 65 20 74 72 69 67 67 65 72 20 as the trigger
190a0 6f 72 20 76 69 72 74 75 61 6c 20 74 61 62 6c 65 or virtual table
190b0 20 6d 65 74 68 6f 64 20 69 73 20 72 75 6e 6e 69 method is runni
190c0 6e 67 2e 0a 2a 2a 20 42 75 74 20 6f 6e 63 65 20 ng..** But once
190d0 74 68 65 20 74 72 69 67 67 65 72 20 6f 72 20 76 the trigger or v
190e0 69 72 74 75 61 6c 20 74 61 62 6c 65 20 6d 65 74 irtual table met
190f0 68 6f 64 20 65 6e 64 73 2c 20 74 68 65 20 76 61 hod ends, the va
19100 6c 75 65 20 72 65 74 75 72 6e 65 64 20 0a 2a 2a lue returned .**
19110 20 62 79 20 74 68 69 73 20 72 6f 75 74 69 6e 65 by this routine
19120 20 72 65 76 65 72 74 73 20 74 6f 20 77 68 61 74 reverts to what
19130 20 69 74 20 77 61 73 20 62 65 66 6f 72 65 20 74 it was before t
19140 68 65 20 74 72 69 67 67 65 72 20 6f 72 20 76 69 he trigger or vi
19150 72 74 75 61 6c 0a 2a 2a 20 74 61 62 6c 65 20 6d rtual.** table m
19160 65 74 68 6f 64 20 62 65 67 61 6e 2e 29 5e 0a 2a ethod began.)^.*
19170 2a 0a 2a 2a 20 5e 41 6e 20 5b 49 4e 53 45 52 54 *.** ^An [INSERT
19180 5d 20 74 68 61 74 20 66 61 69 6c 73 20 64 75 65 ] that fails due
19190 20 74 6f 20 61 20 63 6f 6e 73 74 72 61 69 6e 74 to a constraint
191a0 20 76 69 6f 6c 61 74 69 6f 6e 20 69 73 20 6e 6f violation is no
191b0 74 20 61 0a 2a 2a 20 73 75 63 63 65 73 73 66 75 t a.** successfu
191c0 6c 20 5b 49 4e 53 45 52 54 5d 20 61 6e 64 20 64 l [INSERT] and d
191d0 6f 65 73 20 6e 6f 74 20 63 68 61 6e 67 65 20 74 oes not change t
191e0 68 65 20 76 61 6c 75 65 20 72 65 74 75 72 6e 65 he value returne
191f0 64 20 62 79 20 74 68 69 73 0a 2a 2a 20 72 6f 75 d by this.** rou
19200 74 69 6e 65 2e 20 20 5e 54 68 75 73 20 49 4e 53 tine. ^Thus INS
19210 45 52 54 20 4f 52 20 46 41 49 4c 2c 20 49 4e 53 ERT OR FAIL, INS
19220 45 52 54 20 4f 52 20 49 47 4e 4f 52 45 2c 20 49 ERT OR IGNORE, I
19230 4e 53 45 52 54 20 4f 52 20 52 4f 4c 4c 42 41 43 NSERT OR ROLLBAC
19240 4b 2c 0a 2a 2a 20 61 6e 64 20 49 4e 53 45 52 54 K,.** and INSERT
19250 20 4f 52 20 41 42 4f 52 54 20 6d 61 6b 65 20 6e OR ABORT make n
19260 6f 20 63 68 61 6e 67 65 73 20 74 6f 20 74 68 65 o changes to the
19270 20 72 65 74 75 72 6e 20 76 61 6c 75 65 20 6f 66 return value of
19280 20 74 68 69 73 0a 2a 2a 20 72 6f 75 74 69 6e 65 this.** routine
19290 20 77 68 65 6e 20 74 68 65 69 72 20 69 6e 73 65 when their inse
192a0 72 74 69 6f 6e 20 66 61 69 6c 73 2e 20 20 5e 28 rtion fails. ^(
192b0 57 68 65 6e 20 49 4e 53 45 52 54 20 4f 52 20 52 When INSERT OR R
192c0 45 50 4c 41 43 45 0a 2a 2a 20 65 6e 63 6f 75 6e EPLACE.** encoun
192d0 74 65 72 73 20 61 20 63 6f 6e 73 74 72 61 69 6e ters a constrain
192e0 74 20 76 69 6f 6c 61 74 69 6f 6e 2c 20 69 74 20 t violation, it
192f0 64 6f 65 73 20 6e 6f 74 20 66 61 69 6c 2e 20 20 does not fail.
19300 54 68 65 0a 2a 2a 20 49 4e 53 45 52 54 20 63 6f The.** INSERT co
19310 6e 74 69 6e 75 65 73 20 74 6f 20 63 6f 6d 70 6c ntinues to compl
19320 65 74 69 6f 6e 20 61 66 74 65 72 20 64 65 6c 65 etion after dele
19330 74 69 6e 67 20 72 6f 77 73 20 74 68 61 74 20 63 ting rows that c
19340 61 75 73 65 64 0a 2a 2a 20 74 68 65 20 63 6f 6e aused.** the con
19350 73 74 72 61 69 6e 74 20 70 72 6f 62 6c 65 6d 20 straint problem
19360 73 6f 20 49 4e 53 45 52 54 20 4f 52 20 52 45 50 so INSERT OR REP
19370 4c 41 43 45 20 77 69 6c 6c 20 61 6c 77 61 79 73 LACE will always
19380 20 63 68 61 6e 67 65 0a 2a 2a 20 74 68 65 20 72 change.** the r
19390 65 74 75 72 6e 20 76 61 6c 75 65 20 6f 66 20 74 eturn value of t
193a0 68 69 73 20 69 6e 74 65 72 66 61 63 65 2e 29 5e his interface.)^
193b0 0a 2a 2a 0a 2a 2a 20 5e 46 6f 72 20 74 68 65 20 .**.** ^For the
193c0 70 75 72 70 6f 73 65 73 20 6f 66 20 74 68 69 73 purposes of this
193d0 20 72 6f 75 74 69 6e 65 2c 20 61 6e 20 5b 49 4e routine, an [IN
193e0 53 45 52 54 5d 20 69 73 20 63 6f 6e 73 69 64 65 SERT] is conside
193f0 72 65 64 20 74 6f 0a 2a 2a 20 62 65 20 73 75 63 red to.** be suc
19400 63 65 73 73 66 75 6c 20 65 76 65 6e 20 69 66 20 cessful even if
19410 69 74 20 69 73 20 73 75 62 73 65 71 75 65 6e 74 it is subsequent
19420 6c 79 20 72 6f 6c 6c 65 64 20 62 61 63 6b 2e 0a ly rolled back..
19430 2a 2a 0a 2a 2a 20 54 68 69 73 20 66 75 6e 63 74 **.** This funct
19440 69 6f 6e 20 69 73 20 61 63 63 65 73 73 69 62 6c ion is accessibl
19450 65 20 74 6f 20 53 51 4c 20 73 74 61 74 65 6d 65 e to SQL stateme
19460 6e 74 73 20 76 69 61 20 74 68 65 0a 2a 2a 20 5b nts via the.** [
19470 6c 61 73 74 5f 69 6e 73 65 72 74 5f 72 6f 77 69 last_insert_rowi
19480 64 28 29 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e d() SQL function
19490 5d 2e 0a 2a 2a 0a 2a 2a 20 49 66 20 61 20 73 65 ]..**.** If a se
194a0 70 61 72 61 74 65 20 74 68 72 65 61 64 20 70 65 parate thread pe
194b0 72 66 6f 72 6d 73 20 61 20 6e 65 77 20 5b 49 4e rforms a new [IN
194c0 53 45 52 54 5d 20 6f 6e 20 74 68 65 20 73 61 6d SERT] on the sam
194d0 65 0a 2a 2a 20 64 61 74 61 62 61 73 65 20 63 6f e.** database co
194e0 6e 6e 65 63 74 69 6f 6e 20 77 68 69 6c 65 20 74 nnection while t
194f0 68 65 20 5b 73 71 6c 69 74 65 33 5f 6c 61 73 74 he [sqlite3_last
19500 5f 69 6e 73 65 72 74 5f 72 6f 77 69 64 28 29 5d _insert_rowid()]
19510 0a 2a 2a 20 66 75 6e 63 74 69 6f 6e 20 69 73 20 .** function is
19520 72 75 6e 6e 69 6e 67 20 61 6e 64 20 74 68 75 73 running and thus
19530 20 63 68 61 6e 67 65 73 20 74 68 65 20 6c 61 73 changes the las
19540 74 20 69 6e 73 65 72 74 20 5b 72 6f 77 69 64 5d t insert [rowid]
19550 2c 0a 2a 2a 20 74 68 65 6e 20 74 68 65 20 76 61 ,.** then the va
19560 6c 75 65 20 72 65 74 75 72 6e 65 64 20 62 79 20 lue returned by
19570 5b 73 71 6c 69 74 65 33 5f 6c 61 73 74 5f 69 6e [sqlite3_last_in
19580 73 65 72 74 5f 72 6f 77 69 64 28 29 5d 20 69 73 sert_rowid()] is
19590 0a 2a 2a 20 75 6e 70 72 65 64 69 63 74 61 62 6c .** unpredictabl
195a0 65 20 61 6e 64 20 6d 69 67 68 74 20 6e 6f 74 20 e and might not
195b0 65 71 75 61 6c 20 65 69 74 68 65 72 20 74 68 65 equal either the
195c0 20 6f 6c 64 20 6f 72 20 74 68 65 20 6e 65 77 0a old or the new.
195d0 2a 2a 20 6c 61 73 74 20 69 6e 73 65 72 74 20 5b ** last insert [
195e0 72 6f 77 69 64 5d 2e 0a 2a 2f 0a 73 71 6c 69 74 rowid]..*/.sqlit
195f0 65 33 5f 69 6e 74 36 34 20 73 71 6c 69 74 65 33 e3_int64 sqlite3
19600 5f 6c 61 73 74 5f 69 6e 73 65 72 74 5f 72 6f 77 _last_insert_row
19610 69 64 28 73 71 6c 69 74 65 33 2a 29 3b 0a 0a 2f id(sqlite3*);../
19620 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 43 *.** CAPI3REF: C
19630 6f 75 6e 74 20 54 68 65 20 4e 75 6d 62 65 72 20 ount The Number
19640 4f 66 20 52 6f 77 73 20 4d 6f 64 69 66 69 65 64 Of Rows Modified
19650 0a 2a 2a 20 4d 45 54 48 4f 44 3a 20 73 71 6c 69 .** METHOD: sqli
19660 74 65 33 0a 2a 2a 0a 2a 2a 20 5e 54 68 69 73 20 te3.**.** ^This
19670 66 75 6e 63 74 69 6f 6e 20 72 65 74 75 72 6e 73 function returns
19680 20 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 72 the number of r
19690 6f 77 73 20 6d 6f 64 69 66 69 65 64 2c 20 69 6e ows modified, in
196a0 73 65 72 74 65 64 20 6f 72 0a 2a 2a 20 64 65 6c serted or.** del
196b0 65 74 65 64 20 62 79 20 74 68 65 20 6d 6f 73 74 eted by the most
196c0 20 72 65 63 65 6e 74 6c 79 20 63 6f 6d 70 6c 65 recently comple
196d0 74 65 64 20 49 4e 53 45 52 54 2c 20 55 50 44 41 ted INSERT, UPDA
196e0 54 45 20 6f 72 20 44 45 4c 45 54 45 0a 2a 2a 20 TE or DELETE.**
196f0 73 74 61 74 65 6d 65 6e 74 20 6f 6e 20 74 68 65 statement on the
19700 20 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 database connec
19710 74 69 6f 6e 20 73 70 65 63 69 66 69 65 64 20 62 tion specified b
19720 79 20 74 68 65 20 6f 6e 6c 79 20 70 61 72 61 6d y the only param
19730 65 74 65 72 2e 0a 2a 2a 20 5e 45 78 65 63 75 74 eter..** ^Execut
19740 69 6e 67 20 61 6e 79 20 6f 74 68 65 72 20 74 79 ing any other ty
19750 70 65 20 6f 66 20 53 51 4c 20 73 74 61 74 65 6d pe of SQL statem
19760 65 6e 74 20 64 6f 65 73 20 6e 6f 74 20 6d 6f 64 ent does not mod
19770 69 66 79 20 74 68 65 20 76 61 6c 75 65 0a 2a 2a ify the value.**
19780 20 72 65 74 75 72 6e 65 64 20 62 79 20 74 68 69 returned by thi
19790 73 20 66 75 6e 63 74 69 6f 6e 2e 0a 2a 2a 0a 2a s function..**.*
197a0 2a 20 5e 4f 6e 6c 79 20 63 68 61 6e 67 65 73 20 * ^Only changes
197b0 6d 61 64 65 20 64 69 72 65 63 74 6c 79 20 62 79 made directly by
197c0 20 74 68 65 20 49 4e 53 45 52 54 2c 20 55 50 44 the INSERT, UPD
197d0 41 54 45 20 6f 72 20 44 45 4c 45 54 45 20 73 74 ATE or DELETE st
197e0 61 74 65 6d 65 6e 74 20 61 72 65 0a 2a 2a 20 63 atement are.** c
197f0 6f 6e 73 69 64 65 72 65 64 20 2d 20 61 75 78 69 onsidered - auxi
19800 6c 69 61 72 79 20 63 68 61 6e 67 65 73 20 63 61 liary changes ca
19810 75 73 65 64 20 62 79 20 5b 43 52 45 41 54 45 20 used by [CREATE
19820 54 52 49 47 47 45 52 20 7c 20 74 72 69 67 67 65 TRIGGER | trigge
19830 72 73 5d 2c 20 0a 2a 2a 20 5b 66 6f 72 65 69 67 rs], .** [foreig
19840 6e 20 6b 65 79 20 61 63 74 69 6f 6e 73 5d 20 6f n key actions] o
19850 72 20 5b 52 45 50 4c 41 43 45 5d 20 63 6f 6e 73 r [REPLACE] cons
19860 74 72 61 69 6e 74 20 72 65 73 6f 6c 75 74 69 6f traint resolutio
19870 6e 20 61 72 65 20 6e 6f 74 20 63 6f 75 6e 74 65 n are not counte
19880 64 2e 0a 2a 2a 20 0a 2a 2a 20 43 68 61 6e 67 65 d..** .** Change
19890 73 20 74 6f 20 61 20 76 69 65 77 20 74 68 61 74 s to a view that
198a0 20 61 72 65 20 69 6e 74 65 72 63 65 70 74 65 64 are intercepted
198b0 20 62 79 20 0a 2a 2a 20 5b 49 4e 53 54 45 41 44 by .** [INSTEAD
198c0 20 4f 46 20 74 72 69 67 67 65 72 20 7c 20 49 4e OF trigger | IN
198d0 53 54 45 41 44 20 4f 46 20 74 72 69 67 67 65 72 STEAD OF trigger
198e0 73 5d 20 61 72 65 20 6e 6f 74 20 63 6f 75 6e 74 s] are not count
198f0 65 64 2e 20 5e 54 68 65 20 76 61 6c 75 65 20 0a ed. ^The value .
19900 2a 2a 20 72 65 74 75 72 6e 65 64 20 62 79 20 73 ** returned by s
19910 71 6c 69 74 65 33 5f 63 68 61 6e 67 65 73 28 29 qlite3_changes()
19920 20 69 6d 6d 65 64 69 61 74 65 6c 79 20 61 66 74 immediately aft
19930 65 72 20 61 6e 20 49 4e 53 45 52 54 2c 20 55 50 er an INSERT, UP
19940 44 41 54 45 20 6f 72 20 0a 2a 2a 20 44 45 4c 45 DATE or .** DELE
19950 54 45 20 73 74 61 74 65 6d 65 6e 74 20 72 75 6e TE statement run
19960 20 6f 6e 20 61 20 76 69 65 77 20 69 73 20 61 6c on a view is al
19970 77 61 79 73 20 7a 65 72 6f 2e 20 4f 6e 6c 79 20 ways zero. Only
19980 63 68 61 6e 67 65 73 20 6d 61 64 65 20 74 6f 20 changes made to
19990 72 65 61 6c 20 0a 2a 2a 20 74 61 62 6c 65 73 20 real .** tables
199a0 61 72 65 20 63 6f 75 6e 74 65 64 2e 0a 2a 2a 0a are counted..**.
199b0 2a 2a 20 54 68 69 6e 67 73 20 61 72 65 20 6d 6f ** Things are mo
199c0 72 65 20 63 6f 6d 70 6c 69 63 61 74 65 64 20 69 re complicated i
199d0 66 20 74 68 65 20 73 71 6c 69 74 65 33 5f 63 68 f the sqlite3_ch
199e0 61 6e 67 65 73 28 29 20 66 75 6e 63 74 69 6f 6e anges() function
199f0 20 69 73 0a 2a 2a 20 65 78 65 63 75 74 65 64 20 is.** executed
19a00 77 68 69 6c 65 20 61 20 74 72 69 67 67 65 72 20 while a trigger
19a10 70 72 6f 67 72 61 6d 20 69 73 20 72 75 6e 6e 69 program is runni
19a20 6e 67 2e 20 54 68 69 73 20 6d 61 79 20 68 61 70 ng. This may hap
19a30 70 65 6e 20 69 66 20 74 68 65 0a 2a 2a 20 70 72 pen if the.** pr
19a40 6f 67 72 61 6d 20 75 73 65 73 20 74 68 65 20 5b ogram uses the [
19a50 63 68 61 6e 67 65 73 28 29 20 53 51 4c 20 66 75 changes() SQL fu
19a60 6e 63 74 69 6f 6e 5d 2c 20 6f 72 20 69 66 20 73 nction], or if s
19a70 6f 6d 65 20 6f 74 68 65 72 20 63 61 6c 6c 62 61 ome other callba
19a80 63 6b 0a 2a 2a 20 66 75 6e 63 74 69 6f 6e 20 69 ck.** function i
19a90 6e 76 6f 6b 65 73 20 73 71 6c 69 74 65 33 5f 63 nvokes sqlite3_c
19aa0 68 61 6e 67 65 73 28 29 20 64 69 72 65 63 74 6c hanges() directl
19ab0 79 2e 20 45 73 73 65 6e 74 69 61 6c 6c 79 3a 0a y. Essentially:.
19ac0 2a 2a 20 0a 2a 2a 20 3c 75 6c 3e 0a 2a 2a 20 20 ** .** <ul>.**
19ad0 20 3c 6c 69 3e 20 5e 28 42 65 66 6f 72 65 20 65 <li> ^(Before e
19ae0 6e 74 65 72 69 6e 67 20 61 20 74 72 69 67 67 65 ntering a trigge
19af0 72 20 70 72 6f 67 72 61 6d 20 74 68 65 20 76 61 r program the va
19b00 6c 75 65 20 72 65 74 75 72 6e 65 64 20 62 79 0a lue returned by.
19b10 2a 2a 20 20 20 20 20 20 20 20 73 71 6c 69 74 65 ** sqlite
19b20 33 5f 63 68 61 6e 67 65 73 28 29 20 66 75 6e 63 3_changes() func
19b30 74 69 6f 6e 20 69 73 20 73 61 76 65 64 2e 20 41 tion is saved. A
19b40 66 74 65 72 20 74 68 65 20 74 72 69 67 67 65 72 fter the trigger
19b50 20 70 72 6f 67 72 61 6d 20 0a 2a 2a 20 20 20 20 program .**
19b60 20 20 20 20 68 61 73 20 66 69 6e 69 73 68 65 64 has finished
19b70 2c 20 74 68 65 20 6f 72 69 67 69 6e 61 6c 20 76 , the original v
19b80 61 6c 75 65 20 69 73 20 72 65 73 74 6f 72 65 64 alue is restored
19b90 2e 29 5e 0a 2a 2a 20 0a 2a 2a 20 20 20 3c 6c 69 .)^.** .** <li
19ba0 3e 20 5e 28 57 69 74 68 69 6e 20 61 20 74 72 69 > ^(Within a tri
19bb0 67 67 65 72 20 70 72 6f 67 72 61 6d 20 65 61 63 gger program eac
19bc0 68 20 49 4e 53 45 52 54 2c 20 55 50 44 41 54 45 h INSERT, UPDATE
19bd0 20 61 6e 64 20 44 45 4c 45 54 45 20 0a 2a 2a 20 and DELETE .**
19be0 20 20 20 20 20 20 20 73 74 61 74 65 6d 65 6e 74 statement
19bf0 20 73 65 74 73 20 74 68 65 20 76 61 6c 75 65 20 sets the value
19c00 72 65 74 75 72 6e 65 64 20 62 79 20 73 71 6c 69 returned by sqli
19c10 74 65 33 5f 63 68 61 6e 67 65 73 28 29 20 0a 2a te3_changes() .*
19c20 2a 20 20 20 20 20 20 20 20 75 70 6f 6e 20 63 6f * upon co
19c30 6d 70 6c 65 74 69 6f 6e 20 61 73 20 6e 6f 72 6d mpletion as norm
19c40 61 6c 2e 20 4f 66 20 63 6f 75 72 73 65 2c 20 74 al. Of course, t
19c50 68 69 73 20 76 61 6c 75 65 20 77 69 6c 6c 20 6e his value will n
19c60 6f 74 20 69 6e 63 6c 75 64 65 20 0a 2a 2a 20 20 ot include .**
19c70 20 20 20 20 20 20 61 6e 79 20 63 68 61 6e 67 65 any change
19c80 73 20 70 65 72 66 6f 72 6d 65 64 20 62 79 20 73 s performed by s
19c90 75 62 2d 74 72 69 67 67 65 72 73 2c 20 61 73 20 ub-triggers, as
19ca0 74 68 65 20 73 71 6c 69 74 65 33 5f 63 68 61 6e the sqlite3_chan
19cb0 67 65 73 28 29 20 0a 2a 2a 20 20 20 20 20 20 20 ges() .**
19cc0 20 76 61 6c 75 65 20 77 69 6c 6c 20 62 65 20 73 value will be s
19cd0 61 76 65 64 20 61 6e 64 20 72 65 73 74 6f 72 65 aved and restore
19ce0 64 20 61 66 74 65 72 20 65 61 63 68 20 73 75 62 d after each sub
19cf0 2d 74 72 69 67 67 65 72 20 68 61 73 20 72 75 6e -trigger has run
19d00 2e 29 5e 0a 2a 2a 20 3c 2f 75 6c 3e 0a 2a 2a 20 .)^.** </ul>.**
19d10 0a 2a 2a 20 5e 54 68 69 73 20 6d 65 61 6e 73 20 .** ^This means
19d20 74 68 61 74 20 69 66 20 74 68 65 20 63 68 61 6e that if the chan
19d30 67 65 73 28 29 20 53 51 4c 20 66 75 6e 63 74 69 ges() SQL functi
19d40 6f 6e 20 28 6f 72 20 73 69 6d 69 6c 61 72 29 20 on (or similar)
19d50 69 73 20 75 73 65 64 0a 2a 2a 20 62 79 20 74 68 is used.** by th
19d60 65 20 66 69 72 73 74 20 49 4e 53 45 52 54 2c 20 e first INSERT,
19d70 55 50 44 41 54 45 20 6f 72 20 44 45 4c 45 54 45 UPDATE or DELETE
19d80 20 73 74 61 74 65 6d 65 6e 74 20 77 69 74 68 69 statement withi
19d90 6e 20 61 20 74 72 69 67 67 65 72 2c 20 69 74 20 n a trigger, it
19da0 0a 2a 2a 20 72 65 74 75 72 6e 73 20 74 68 65 20 .** returns the
19db0 76 61 6c 75 65 20 61 73 20 73 65 74 20 77 68 65 value as set whe
19dc0 6e 20 74 68 65 20 63 61 6c 6c 69 6e 67 20 73 74 n the calling st
19dd0 61 74 65 6d 65 6e 74 20 62 65 67 61 6e 20 65 78 atement began ex
19de0 65 63 75 74 69 6e 67 2e 0a 2a 2a 20 5e 49 66 20 ecuting..** ^If
19df0 69 74 20 69 73 20 75 73 65 64 20 62 79 20 74 68 it is used by th
19e00 65 20 73 65 63 6f 6e 64 20 6f 72 20 73 75 62 73 e second or subs
19e10 65 71 75 65 6e 74 20 73 75 63 68 20 73 74 61 74 equent such stat
19e20 65 6d 65 6e 74 20 77 69 74 68 69 6e 20 61 20 74 ement within a t
19e30 72 69 67 67 65 72 20 0a 2a 2a 20 70 72 6f 67 72 rigger .** progr
19e40 61 6d 2c 20 74 68 65 20 76 61 6c 75 65 20 72 65 am, the value re
19e50 74 75 72 6e 65 64 20 72 65 66 6c 65 63 74 73 20 turned reflects
19e60 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 72 6f the number of ro
19e70 77 73 20 6d 6f 64 69 66 69 65 64 20 62 79 20 74 ws modified by t
19e80 68 65 20 0a 2a 2a 20 70 72 65 76 69 6f 75 73 20 he .** previous
19e90 49 4e 53 45 52 54 2c 20 55 50 44 41 54 45 20 6f INSERT, UPDATE o
19ea0 72 20 44 45 4c 45 54 45 20 73 74 61 74 65 6d 65 r DELETE stateme
19eb0 6e 74 20 77 69 74 68 69 6e 20 74 68 65 20 73 61 nt within the sa
19ec0 6d 65 20 74 72 69 67 67 65 72 2e 0a 2a 2a 0a 2a me trigger..**.*
19ed0 2a 20 53 65 65 20 61 6c 73 6f 20 74 68 65 20 5b * See also the [
19ee0 73 71 6c 69 74 65 33 5f 74 6f 74 61 6c 5f 63 68 sqlite3_total_ch
19ef0 61 6e 67 65 73 28 29 5d 20 69 6e 74 65 72 66 61 anges()] interfa
19f00 63 65 2c 20 74 68 65 0a 2a 2a 20 5b 63 6f 75 6e ce, the.** [coun
19f10 74 5f 63 68 61 6e 67 65 73 20 70 72 61 67 6d 61 t_changes pragma
19f20 5d 2c 20 61 6e 64 20 74 68 65 20 5b 63 68 61 6e ], and the [chan
19f30 67 65 73 28 29 20 53 51 4c 20 66 75 6e 63 74 69 ges() SQL functi
19f40 6f 6e 5d 2e 0a 2a 2a 0a 2a 2a 20 49 66 20 61 20 on]..**.** If a
19f50 73 65 70 61 72 61 74 65 20 74 68 72 65 61 64 20 separate thread
19f60 6d 61 6b 65 73 20 63 68 61 6e 67 65 73 20 6f 6e makes changes on
19f70 20 74 68 65 20 73 61 6d 65 20 64 61 74 61 62 61 the same databa
19f80 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 0a 2a 2a se connection.**
19f90 20 77 68 69 6c 65 20 5b 73 71 6c 69 74 65 33 5f while [sqlite3_
19fa0 63 68 61 6e 67 65 73 28 29 5d 20 69 73 20 72 75 changes()] is ru
19fb0 6e 6e 69 6e 67 20 74 68 65 6e 20 74 68 65 20 76 nning then the v
19fc0 61 6c 75 65 20 72 65 74 75 72 6e 65 64 0a 2a 2a alue returned.**
19fd0 20 69 73 20 75 6e 70 72 65 64 69 63 74 61 62 6c is unpredictabl
19fe0 65 20 61 6e 64 20 6e 6f 74 20 6d 65 61 6e 69 6e e and not meanin
19ff0 67 66 75 6c 2e 0a 2a 2f 0a 69 6e 74 20 73 71 6c gful..*/.int sql
1a000 69 74 65 33 5f 63 68 61 6e 67 65 73 28 73 71 6c ite3_changes(sql
1a010 69 74 65 33 2a 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 ite3*);../*.** C
1a020 41 50 49 33 52 45 46 3a 20 54 6f 74 61 6c 20 4e API3REF: Total N
1a030 75 6d 62 65 72 20 4f 66 20 52 6f 77 73 20 4d 6f umber Of Rows Mo
1a040 64 69 66 69 65 64 0a 2a 2a 20 4d 45 54 48 4f 44 dified.** METHOD
1a050 3a 20 73 71 6c 69 74 65 33 0a 2a 2a 0a 2a 2a 20 : sqlite3.**.**
1a060 5e 54 68 69 73 20 66 75 6e 63 74 69 6f 6e 20 72 ^This function r
1a070 65 74 75 72 6e 73 20 74 68 65 20 74 6f 74 61 6c eturns the total
1a080 20 6e 75 6d 62 65 72 20 6f 66 20 72 6f 77 73 20 number of rows
1a090 69 6e 73 65 72 74 65 64 2c 20 6d 6f 64 69 66 69 inserted, modifi
1a0a0 65 64 20 6f 72 0a 2a 2a 20 64 65 6c 65 74 65 64 ed or.** deleted
1a0b0 20 62 79 20 61 6c 6c 20 5b 49 4e 53 45 52 54 5d by all [INSERT]
1a0c0 2c 20 5b 55 50 44 41 54 45 5d 20 6f 72 20 5b 44 , [UPDATE] or [D
1a0d0 45 4c 45 54 45 5d 20 73 74 61 74 65 6d 65 6e 74 ELETE] statement
1a0e0 73 20 63 6f 6d 70 6c 65 74 65 64 0a 2a 2a 20 73 s completed.** s
1a0f0 69 6e 63 65 20 74 68 65 20 64 61 74 61 62 61 73 ince the databas
1a100 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 77 61 73 e connection was
1a110 20 6f 70 65 6e 65 64 2c 20 69 6e 63 6c 75 64 69 opened, includi
1a120 6e 67 20 74 68 6f 73 65 20 65 78 65 63 75 74 65 ng those execute
1a130 64 20 61 73 0a 2a 2a 20 70 61 72 74 20 6f 66 20 d as.** part of
1a140 74 72 69 67 67 65 72 20 70 72 6f 67 72 61 6d 73 trigger programs
1a150 2e 20 5e 45 78 65 63 75 74 69 6e 67 20 61 6e 79 . ^Executing any
1a160 20 6f 74 68 65 72 20 74 79 70 65 20 6f 66 20 53 other type of S
1a170 51 4c 20 73 74 61 74 65 6d 65 6e 74 0a 2a 2a 20 QL statement.**
1a180 64 6f 65 73 20 6e 6f 74 20 61 66 66 65 63 74 20 does not affect
1a190 74 68 65 20 76 61 6c 75 65 20 72 65 74 75 72 6e the value return
1a1a0 65 64 20 62 79 20 73 71 6c 69 74 65 33 5f 74 6f ed by sqlite3_to
1a1b0 74 61 6c 5f 63 68 61 6e 67 65 73 28 29 2e 0a 2a tal_changes()..*
1a1c0 2a 20 0a 2a 2a 20 5e 43 68 61 6e 67 65 73 20 6d * .** ^Changes m
1a1d0 61 64 65 20 61 73 20 70 61 72 74 20 6f 66 20 5b ade as part of [
1a1e0 66 6f 72 65 69 67 6e 20 6b 65 79 20 61 63 74 69 foreign key acti
1a1f0 6f 6e 73 5d 20 61 72 65 20 69 6e 63 6c 75 64 65 ons] are include
1a200 64 20 69 6e 20 74 68 65 0a 2a 2a 20 63 6f 75 6e d in the.** coun
1a210 74 2c 20 62 75 74 20 74 68 6f 73 65 20 6d 61 64 t, but those mad
1a220 65 20 61 73 20 70 61 72 74 20 6f 66 20 52 45 50 e as part of REP
1a230 4c 41 43 45 20 63 6f 6e 73 74 72 61 69 6e 74 20 LACE constraint
1a240 72 65 73 6f 6c 75 74 69 6f 6e 20 61 72 65 0a 2a resolution are.*
1a250 2a 20 6e 6f 74 2e 20 5e 43 68 61 6e 67 65 73 20 * not. ^Changes
1a260 74 6f 20 61 20 76 69 65 77 20 74 68 61 74 20 61 to a view that a
1a270 72 65 20 69 6e 74 65 72 63 65 70 74 65 64 20 62 re intercepted b
1a280 79 20 49 4e 53 54 45 41 44 20 4f 46 20 74 72 69 y INSTEAD OF tri
1a290 67 67 65 72 73 20 0a 2a 2a 20 61 72 65 20 6e 6f ggers .** are no
1a2a0 74 20 63 6f 75 6e 74 65 64 2e 0a 2a 2a 20 0a 2a t counted..** .*
1a2b0 2a 20 53 65 65 20 61 6c 73 6f 20 74 68 65 20 5b * See also the [
1a2c0 73 71 6c 69 74 65 33 5f 63 68 61 6e 67 65 73 28 sqlite3_changes(
1a2d0 29 5d 20 69 6e 74 65 72 66 61 63 65 2c 20 74 68 )] interface, th
1a2e0 65 0a 2a 2a 20 5b 63 6f 75 6e 74 5f 63 68 61 6e e.** [count_chan
1a2f0 67 65 73 20 70 72 61 67 6d 61 5d 2c 20 61 6e 64 ges pragma], and
1a300 20 74 68 65 20 5b 74 6f 74 61 6c 5f 63 68 61 6e the [total_chan
1a310 67 65 73 28 29 20 53 51 4c 20 66 75 6e 63 74 69 ges() SQL functi
1a320 6f 6e 5d 2e 0a 2a 2a 0a 2a 2a 20 49 66 20 61 20 on]..**.** If a
1a330 73 65 70 61 72 61 74 65 20 74 68 72 65 61 64 20 separate thread
1a340 6d 61 6b 65 73 20 63 68 61 6e 67 65 73 20 6f 6e makes changes on
1a350 20 74 68 65 20 73 61 6d 65 20 64 61 74 61 62 61 the same databa
1a360 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 0a 2a 2a se connection.**
1a370 20 77 68 69 6c 65 20 5b 73 71 6c 69 74 65 33 5f while [sqlite3_
1a380 74 6f 74 61 6c 5f 63 68 61 6e 67 65 73 28 29 5d total_changes()]
1a390 20 69 73 20 72 75 6e 6e 69 6e 67 20 74 68 65 6e is running then
1a3a0 20 74 68 65 20 76 61 6c 75 65 0a 2a 2a 20 72 65 the value.** re
1a3b0 74 75 72 6e 65 64 20 69 73 20 75 6e 70 72 65 64 turned is unpred
1a3c0 69 63 74 61 62 6c 65 20 61 6e 64 20 6e 6f 74 20 ictable and not
1a3d0 6d 65 61 6e 69 6e 67 66 75 6c 2e 0a 2a 2f 0a 69 meaningful..*/.i
1a3e0 6e 74 20 73 71 6c 69 74 65 33 5f 74 6f 74 61 6c nt sqlite3_total
1a3f0 5f 63 68 61 6e 67 65 73 28 73 71 6c 69 74 65 33 _changes(sqlite3
1a400 2a 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 *);../*.** CAPI3
1a410 52 45 46 3a 20 49 6e 74 65 72 72 75 70 74 20 41 REF: Interrupt A
1a420 20 4c 6f 6e 67 2d 52 75 6e 6e 69 6e 67 20 51 75 Long-Running Qu
1a430 65 72 79 0a 2a 2a 20 4d 45 54 48 4f 44 3a 20 73 ery.** METHOD: s
1a440 71 6c 69 74 65 33 0a 2a 2a 0a 2a 2a 20 5e 54 68 qlite3.**.** ^Th
1a450 69 73 20 66 75 6e 63 74 69 6f 6e 20 63 61 75 73 is function caus
1a460 65 73 20 61 6e 79 20 70 65 6e 64 69 6e 67 20 64 es any pending d
1a470 61 74 61 62 61 73 65 20 6f 70 65 72 61 74 69 6f atabase operatio
1a480 6e 20 74 6f 20 61 62 6f 72 74 20 61 6e 64 0a 2a n to abort and.*
1a490 2a 20 72 65 74 75 72 6e 20 61 74 20 69 74 73 20 * return at its
1a4a0 65 61 72 6c 69 65 73 74 20 6f 70 70 6f 72 74 75 earliest opportu
1a4b0 6e 69 74 79 2e 20 54 68 69 73 20 72 6f 75 74 69 nity. This routi
1a4c0 6e 65 20 69 73 20 74 79 70 69 63 61 6c 6c 79 0a ne is typically.
1a4d0 2a 2a 20 63 61 6c 6c 65 64 20 69 6e 20 72 65 73 ** called in res
1a4e0 70 6f 6e 73 65 20 74 6f 20 61 20 75 73 65 72 20 ponse to a user
1a4f0 61 63 74 69 6f 6e 20 73 75 63 68 20 61 73 20 70 action such as p
1a500 72 65 73 73 69 6e 67 20 22 43 61 6e 63 65 6c 22 ressing "Cancel"
1a510 0a 2a 2a 20 6f 72 20 43 74 72 6c 2d 43 20 77 68 .** or Ctrl-C wh
1a520 65 72 65 20 74 68 65 20 75 73 65 72 20 77 61 6e ere the user wan
1a530 74 73 20 61 20 6c 6f 6e 67 20 71 75 65 72 79 20 ts a long query
1a540 6f 70 65 72 61 74 69 6f 6e 20 74 6f 20 68 61 6c operation to hal
1a550 74 0a 2a 2a 20 69 6d 6d 65 64 69 61 74 65 6c 79 t.** immediately
1a560 2e 0a 2a 2a 0a 2a 2a 20 5e 49 74 20 69 73 20 73 ..**.** ^It is s
1a570 61 66 65 20 74 6f 20 63 61 6c 6c 20 74 68 69 73 afe to call this
1a580 20 72 6f 75 74 69 6e 65 20 66 72 6f 6d 20 61 20 routine from a
1a590 74 68 72 65 61 64 20 64 69 66 66 65 72 65 6e 74 thread different
1a5a0 20 66 72 6f 6d 20 74 68 65 0a 2a 2a 20 74 68 72 from the.** thr
1a5b0 65 61 64 20 74 68 61 74 20 69 73 20 63 75 72 72 ead that is curr
1a5c0 65 6e 74 6c 79 20 72 75 6e 6e 69 6e 67 20 74 68 ently running th
1a5d0 65 20 64 61 74 61 62 61 73 65 20 6f 70 65 72 61 e database opera
1a5e0 74 69 6f 6e 2e 20 20 42 75 74 20 69 74 0a 2a 2a tion. But it.**
1a5f0 20 69 73 20 6e 6f 74 20 73 61 66 65 20 74 6f 20 is not safe to
1a600 63 61 6c 6c 20 74 68 69 73 20 72 6f 75 74 69 6e call this routin
1a610 65 20 77 69 74 68 20 61 20 5b 64 61 74 61 62 61 e with a [databa
1a620 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 5d 20 74 se connection] t
1a630 68 61 74 0a 2a 2a 20 69 73 20 63 6c 6f 73 65 64 hat.** is closed
1a640 20 6f 72 20 6d 69 67 68 74 20 63 6c 6f 73 65 20 or might close
1a650 62 65 66 6f 72 65 20 73 71 6c 69 74 65 33 5f 69 before sqlite3_i
1a660 6e 74 65 72 72 75 70 74 28 29 20 72 65 74 75 72 nterrupt() retur
1a670 6e 73 2e 0a 2a 2a 0a 2a 2a 20 5e 49 66 20 61 6e ns..**.** ^If an
1a680 20 53 51 4c 20 6f 70 65 72 61 74 69 6f 6e 20 69 SQL operation i
1a690 73 20 76 65 72 79 20 6e 65 61 72 6c 79 20 66 69 s very nearly fi
1a6a0 6e 69 73 68 65 64 20 61 74 20 74 68 65 20 74 69 nished at the ti
1a6b0 6d 65 20 77 68 65 6e 0a 2a 2a 20 73 71 6c 69 74 me when.** sqlit
1a6c0 65 33 5f 69 6e 74 65 72 72 75 70 74 28 29 20 69 e3_interrupt() i
1a6d0 73 20 63 61 6c 6c 65 64 2c 20 74 68 65 6e 20 69 s called, then i
1a6e0 74 20 6d 69 67 68 74 20 6e 6f 74 20 68 61 76 65 t might not have
1a6f0 20 61 6e 20 6f 70 70 6f 72 74 75 6e 69 74 79 0a an opportunity.
1a700 2a 2a 20 74 6f 20 62 65 20 69 6e 74 65 72 72 75 ** to be interru
1a710 70 74 65 64 20 61 6e 64 20 6d 69 67 68 74 20 63 pted and might c
1a720 6f 6e 74 69 6e 75 65 20 74 6f 20 63 6f 6d 70 6c ontinue to compl
1a730 65 74 69 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 5e 41 6e etion..**.** ^An
1a740 20 53 51 4c 20 6f 70 65 72 61 74 69 6f 6e 20 74 SQL operation t
1a750 68 61 74 20 69 73 20 69 6e 74 65 72 72 75 70 74 hat is interrupt
1a760 65 64 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 5b ed will return [
1a770 53 51 4c 49 54 45 5f 49 4e 54 45 52 52 55 50 54 SQLITE_INTERRUPT
1a780 5d 2e 0a 2a 2a 20 5e 49 66 20 74 68 65 20 69 6e ]..** ^If the in
1a790 74 65 72 72 75 70 74 65 64 20 53 51 4c 20 6f 70 terrupted SQL op
1a7a0 65 72 61 74 69 6f 6e 20 69 73 20 61 6e 20 49 4e eration is an IN
1a7b0 53 45 52 54 2c 20 55 50 44 41 54 45 2c 20 6f 72 SERT, UPDATE, or
1a7c0 20 44 45 4c 45 54 45 0a 2a 2a 20 74 68 61 74 20 DELETE.** that
1a7d0 69 73 20 69 6e 73 69 64 65 20 61 6e 20 65 78 70 is inside an exp
1a7e0 6c 69 63 69 74 20 74 72 61 6e 73 61 63 74 69 6f licit transactio
1a7f0 6e 2c 20 74 68 65 6e 20 74 68 65 20 65 6e 74 69 n, then the enti
1a800 72 65 20 74 72 61 6e 73 61 63 74 69 6f 6e 0a 2a re transaction.*
1a810 2a 20 77 69 6c 6c 20 62 65 20 72 6f 6c 6c 65 64 * will be rolled
1a820 20 62 61 63 6b 20 61 75 74 6f 6d 61 74 69 63 61 back automatica
1a830 6c 6c 79 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 lly..**.** ^The
1a840 73 71 6c 69 74 65 33 5f 69 6e 74 65 72 72 75 70 sqlite3_interrup
1a850 74 28 44 29 20 63 61 6c 6c 20 69 73 20 69 6e 20 t(D) call is in
1a860 65 66 66 65 63 74 20 75 6e 74 69 6c 20 61 6c 6c effect until all
1a870 20 63 75 72 72 65 6e 74 6c 79 20 72 75 6e 6e 69 currently runni
1a880 6e 67 0a 2a 2a 20 53 51 4c 20 73 74 61 74 65 6d ng.** SQL statem
1a890 65 6e 74 73 20 6f 6e 20 5b 64 61 74 61 62 61 73 ents on [databas
1a8a0 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 5d 20 44 20 e connection] D
1a8b0 63 6f 6d 70 6c 65 74 65 2e 20 20 5e 41 6e 79 20 complete. ^Any
1a8c0 6e 65 77 20 53 51 4c 20 73 74 61 74 65 6d 65 6e new SQL statemen
1a8d0 74 73 0a 2a 2a 20 74 68 61 74 20 61 72 65 20 73 ts.** that are s
1a8e0 74 61 72 74 65 64 20 61 66 74 65 72 20 74 68 65 tarted after the
1a8f0 20 73 71 6c 69 74 65 33 5f 69 6e 74 65 72 72 75 sqlite3_interru
1a900 70 74 28 29 20 63 61 6c 6c 20 61 6e 64 20 62 65 pt() call and be
1a910 66 6f 72 65 20 74 68 65 20 0a 2a 2a 20 72 75 6e fore the .** run
1a920 6e 69 6e 67 20 73 74 61 74 65 6d 65 6e 74 73 20 ning statements
1a930 72 65 61 63 68 65 73 20 7a 65 72 6f 20 61 72 65 reaches zero are
1a940 20 69 6e 74 65 72 72 75 70 74 65 64 20 61 73 20 interrupted as
1a950 69 66 20 74 68 65 79 20 68 61 64 20 62 65 65 6e if they had been
1a960 0a 2a 2a 20 72 75 6e 6e 69 6e 67 20 70 72 69 6f .** running prio
1a970 72 20 74 6f 20 74 68 65 20 73 71 6c 69 74 65 33 r to the sqlite3
1a980 5f 69 6e 74 65 72 72 75 70 74 28 29 20 63 61 6c _interrupt() cal
1a990 6c 2e 20 20 5e 4e 65 77 20 53 51 4c 20 73 74 61 l. ^New SQL sta
1a9a0 74 65 6d 65 6e 74 73 0a 2a 2a 20 74 68 61 74 20 tements.** that
1a9b0 61 72 65 20 73 74 61 72 74 65 64 20 61 66 74 65 are started afte
1a9c0 72 20 74 68 65 20 72 75 6e 6e 69 6e 67 20 73 74 r the running st
1a9d0 61 74 65 6d 65 6e 74 20 63 6f 75 6e 74 20 72 65 atement count re
1a9e0 61 63 68 65 73 20 7a 65 72 6f 20 61 72 65 0a 2a aches zero are.*
1a9f0 2a 20 6e 6f 74 20 65 66 66 65 63 74 65 64 20 62 * not effected b
1aa00 79 20 74 68 65 20 73 71 6c 69 74 65 33 5f 69 6e y the sqlite3_in
1aa10 74 65 72 72 75 70 74 28 29 2e 0a 2a 2a 20 5e 41 terrupt()..** ^A
1aa20 20 63 61 6c 6c 20 74 6f 20 73 71 6c 69 74 65 33 call to sqlite3
1aa30 5f 69 6e 74 65 72 72 75 70 74 28 44 29 20 74 68 _interrupt(D) th
1aa40 61 74 20 6f 63 63 75 72 73 20 77 68 65 6e 20 74 at occurs when t
1aa50 68 65 72 65 20 61 72 65 20 6e 6f 20 72 75 6e 6e here are no runn
1aa60 69 6e 67 0a 2a 2a 20 53 51 4c 20 73 74 61 74 65 ing.** SQL state
1aa70 6d 65 6e 74 73 20 69 73 20 61 20 6e 6f 2d 6f 70 ments is a no-op
1aa80 20 61 6e 64 20 68 61 73 20 6e 6f 20 65 66 66 65 and has no effe
1aa90 63 74 20 6f 6e 20 53 51 4c 20 73 74 61 74 65 6d ct on SQL statem
1aaa0 65 6e 74 73 0a 2a 2a 20 74 68 61 74 20 61 72 65 ents.** that are
1aab0 20 73 74 61 72 74 65 64 20 61 66 74 65 72 20 74 started after t
1aac0 68 65 20 73 71 6c 69 74 65 33 5f 69 6e 74 65 72 he sqlite3_inter
1aad0 72 75 70 74 28 29 20 63 61 6c 6c 20 72 65 74 75 rupt() call retu
1aae0 72 6e 73 2e 0a 2a 2a 0a 2a 2a 20 49 66 20 74 68 rns..**.** If th
1aaf0 65 20 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 e database conne
1ab00 63 74 69 6f 6e 20 63 6c 6f 73 65 73 20 77 68 69 ction closes whi
1ab10 6c 65 20 5b 73 71 6c 69 74 65 33 5f 69 6e 74 65 le [sqlite3_inte
1ab20 72 72 75 70 74 28 29 5d 0a 2a 2a 20 69 73 20 72 rrupt()].** is r
1ab30 75 6e 6e 69 6e 67 20 74 68 65 6e 20 62 61 64 20 unning then bad
1ab40 74 68 69 6e 67 73 20 77 69 6c 6c 20 6c 69 6b 65 things will like
1ab50 6c 79 20 68 61 70 70 65 6e 2e 0a 2a 2f 0a 76 6f ly happen..*/.vo
1ab60 69 64 20 73 71 6c 69 74 65 33 5f 69 6e 74 65 72 id sqlite3_inter
1ab70 72 75 70 74 28 73 71 6c 69 74 65 33 2a 29 3b 0a rupt(sqlite3*);.
1ab80 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a ./*.** CAPI3REF:
1ab90 20 44 65 74 65 72 6d 69 6e 65 20 49 66 20 41 6e Determine If An
1aba0 20 53 51 4c 20 53 74 61 74 65 6d 65 6e 74 20 49 SQL Statement I
1abb0 73 20 43 6f 6d 70 6c 65 74 65 0a 2a 2a 0a 2a 2a s Complete.**.**
1abc0 20 54 68 65 73 65 20 72 6f 75 74 69 6e 65 73 20 These routines
1abd0 61 72 65 20 75 73 65 66 75 6c 20 64 75 72 69 6e are useful durin
1abe0 67 20 63 6f 6d 6d 61 6e 64 2d 6c 69 6e 65 20 69 g command-line i
1abf0 6e 70 75 74 20 74 6f 20 64 65 74 65 72 6d 69 6e nput to determin
1ac00 65 20 69 66 20 74 68 65 0a 2a 2a 20 63 75 72 72 e if the.** curr
1ac10 65 6e 74 6c 79 20 65 6e 74 65 72 65 64 20 74 65 ently entered te
1ac20 78 74 20 73 65 65 6d 73 20 74 6f 20 66 6f 72 6d xt seems to form
1ac30 20 61 20 63 6f 6d 70 6c 65 74 65 20 53 51 4c 20 a complete SQL
1ac40 73 74 61 74 65 6d 65 6e 74 20 6f 72 0a 2a 2a 20 statement or.**
1ac50 69 66 20 61 64 64 69 74 69 6f 6e 61 6c 20 69 6e if additional in
1ac60 70 75 74 20 69 73 20 6e 65 65 64 65 64 20 62 65 put is needed be
1ac70 66 6f 72 65 20 73 65 6e 64 69 6e 67 20 74 68 65 fore sending the
1ac80 20 74 65 78 74 20 69 6e 74 6f 0a 2a 2a 20 53 51 text into.** SQ
1ac90 4c 69 74 65 20 66 6f 72 20 70 61 72 73 69 6e 67 Lite for parsing
1aca0 2e 20 20 5e 54 68 65 73 65 20 72 6f 75 74 69 6e . ^These routin
1acb0 65 73 20 72 65 74 75 72 6e 20 31 20 69 66 20 74 es return 1 if t
1acc0 68 65 20 69 6e 70 75 74 20 73 74 72 69 6e 67 0a he input string.
1acd0 2a 2a 20 61 70 70 65 61 72 73 20 74 6f 20 62 65 ** appears to be
1ace0 20 61 20 63 6f 6d 70 6c 65 74 65 20 53 51 4c 20 a complete SQL
1acf0 73 74 61 74 65 6d 65 6e 74 2e 20 20 5e 41 20 73 statement. ^A s
1ad00 74 61 74 65 6d 65 6e 74 20 69 73 20 6a 75 64 67 tatement is judg
1ad10 65 64 20 74 6f 20 62 65 0a 2a 2a 20 63 6f 6d 70 ed to be.** comp
1ad20 6c 65 74 65 20 69 66 20 69 74 20 65 6e 64 73 20 lete if it ends
1ad30 77 69 74 68 20 61 20 73 65 6d 69 63 6f 6c 6f 6e with a semicolon
1ad40 20 74 6f 6b 65 6e 20 61 6e 64 20 69 73 20 6e 6f token and is no
1ad50 74 20 61 20 70 72 65 66 69 78 20 6f 66 20 61 0a t a prefix of a.
1ad60 2a 2a 20 77 65 6c 6c 2d 66 6f 72 6d 65 64 20 43 ** well-formed C
1ad70 52 45 41 54 45 20 54 52 49 47 47 45 52 20 73 74 REATE TRIGGER st
1ad80 61 74 65 6d 65 6e 74 2e 20 20 5e 53 65 6d 69 63 atement. ^Semic
1ad90 6f 6c 6f 6e 73 20 74 68 61 74 20 61 72 65 20 65 olons that are e
1ada0 6d 62 65 64 64 65 64 20 77 69 74 68 69 6e 0a 2a mbedded within.*
1adb0 2a 20 73 74 72 69 6e 67 20 6c 69 74 65 72 61 6c * string literal
1adc0 73 20 6f 72 20 71 75 6f 74 65 64 20 69 64 65 6e s or quoted iden
1add0 74 69 66 69 65 72 20 6e 61 6d 65 73 20 6f 72 20 tifier names or
1ade0 63 6f 6d 6d 65 6e 74 73 20 61 72 65 20 6e 6f 74 comments are not
1adf0 0a 2a 2a 20 69 6e 64 65 70 65 6e 64 65 6e 74 20 .** independent
1ae00 74 6f 6b 65 6e 73 20 28 74 68 65 79 20 61 72 65 tokens (they are
1ae10 20 70 61 72 74 20 6f 66 20 74 68 65 20 74 6f 6b part of the tok
1ae20 65 6e 20 69 6e 20 77 68 69 63 68 20 74 68 65 79 en in which they
1ae30 20 61 72 65 0a 2a 2a 20 65 6d 62 65 64 64 65 64 are.** embedded
1ae40 29 20 61 6e 64 20 74 68 75 73 20 64 6f 20 6e 6f ) and thus do no
1ae50 74 20 63 6f 75 6e 74 20 61 73 20 61 20 73 74 61 t count as a sta
1ae60 74 65 6d 65 6e 74 20 74 65 72 6d 69 6e 61 74 6f tement terminato
1ae70 72 2e 20 20 5e 57 68 69 74 65 73 70 61 63 65 0a r. ^Whitespace.
1ae80 2a 2a 20 61 6e 64 20 63 6f 6d 6d 65 6e 74 73 20 ** and comments
1ae90 74 68 61 74 20 66 6f 6c 6c 6f 77 20 74 68 65 20 that follow the
1aea0 66 69 6e 61 6c 20 73 65 6d 69 63 6f 6c 6f 6e 20 final semicolon
1aeb0 61 72 65 20 69 67 6e 6f 72 65 64 2e 0a 2a 2a 0a are ignored..**.
1aec0 2a 2a 20 5e 54 68 65 73 65 20 72 6f 75 74 69 6e ** ^These routin
1aed0 65 73 20 72 65 74 75 72 6e 20 30 20 69 66 20 74 es return 0 if t
1aee0 68 65 20 73 74 61 74 65 6d 65 6e 74 20 69 73 20 he statement is
1aef0 69 6e 63 6f 6d 70 6c 65 74 65 2e 20 20 5e 49 66 incomplete. ^If
1af00 20 61 0a 2a 2a 20 6d 65 6d 6f 72 79 20 61 6c 6c a.** memory all
1af10 6f 63 61 74 69 6f 6e 20 66 61 69 6c 73 2c 20 74 ocation fails, t
1af20 68 65 6e 20 53 51 4c 49 54 45 5f 4e 4f 4d 45 4d hen SQLITE_NOMEM
1af30 20 69 73 20 72 65 74 75 72 6e 65 64 2e 0a 2a 2a is returned..**
1af40 0a 2a 2a 20 5e 54 68 65 73 65 20 72 6f 75 74 69 .** ^These routi
1af50 6e 65 73 20 64 6f 20 6e 6f 74 20 70 61 72 73 65 nes do not parse
1af60 20 74 68 65 20 53 51 4c 20 73 74 61 74 65 6d 65 the SQL stateme
1af70 6e 74 73 20 74 68 75 73 0a 2a 2a 20 77 69 6c 6c nts thus.** will
1af80 20 6e 6f 74 20 64 65 74 65 63 74 20 73 79 6e 74 not detect synt
1af90 61 63 74 69 63 61 6c 6c 79 20 69 6e 63 6f 72 72 actically incorr
1afa0 65 63 74 20 53 51 4c 2e 0a 2a 2a 0a 2a 2a 20 5e ect SQL..**.** ^
1afb0 28 49 66 20 53 51 4c 69 74 65 20 68 61 73 20 6e (If SQLite has n
1afc0 6f 74 20 62 65 65 6e 20 69 6e 69 74 69 61 6c 69 ot been initiali
1afd0 7a 65 64 20 75 73 69 6e 67 20 5b 73 71 6c 69 74 zed using [sqlit
1afe0 65 33 5f 69 6e 69 74 69 61 6c 69 7a 65 28 29 5d e3_initialize()]
1aff0 20 70 72 69 6f 72 20 0a 2a 2a 20 74 6f 20 69 6e prior .** to in
1b000 76 6f 6b 69 6e 67 20 73 71 6c 69 74 65 33 5f 63 voking sqlite3_c
1b010 6f 6d 70 6c 65 74 65 31 36 28 29 20 74 68 65 6e omplete16() then
1b020 20 73 71 6c 69 74 65 33 5f 69 6e 69 74 69 61 6c sqlite3_initial
1b030 69 7a 65 28 29 20 69 73 20 69 6e 76 6f 6b 65 64 ize() is invoked
1b040 0a 2a 2a 20 61 75 74 6f 6d 61 74 69 63 61 6c 6c .** automaticall
1b050 79 20 62 79 20 73 71 6c 69 74 65 33 5f 63 6f 6d y by sqlite3_com
1b060 70 6c 65 74 65 31 36 28 29 2e 20 20 49 66 20 74 plete16(). If t
1b070 68 61 74 20 69 6e 69 74 69 61 6c 69 7a 61 74 69 hat initializati
1b080 6f 6e 20 66 61 69 6c 73 2c 0a 2a 2a 20 74 68 65 on fails,.** the
1b090 6e 20 74 68 65 20 72 65 74 75 72 6e 20 76 61 6c n the return val
1b0a0 75 65 20 66 72 6f 6d 20 73 71 6c 69 74 65 33 5f ue from sqlite3_
1b0b0 63 6f 6d 70 6c 65 74 65 31 36 28 29 20 77 69 6c complete16() wil
1b0c0 6c 20 62 65 20 6e 6f 6e 2d 7a 65 72 6f 0a 2a 2a l be non-zero.**
1b0d0 20 72 65 67 61 72 64 6c 65 73 73 20 6f 66 20 77 regardless of w
1b0e0 68 65 74 68 65 72 20 6f 72 20 6e 6f 74 20 74 68 hether or not th
1b0f0 65 20 69 6e 70 75 74 20 53 51 4c 20 69 73 20 63 e input SQL is c
1b100 6f 6d 70 6c 65 74 65 2e 29 5e 0a 2a 2a 0a 2a 2a omplete.)^.**.**
1b110 20 54 68 65 20 69 6e 70 75 74 20 74 6f 20 5b 73 The input to [s
1b120 71 6c 69 74 65 33 5f 63 6f 6d 70 6c 65 74 65 28 qlite3_complete(
1b130 29 5d 20 6d 75 73 74 20 62 65 20 61 20 7a 65 72 )] must be a zer
1b140 6f 2d 74 65 72 6d 69 6e 61 74 65 64 0a 2a 2a 20 o-terminated.**
1b150 55 54 46 2d 38 20 73 74 72 69 6e 67 2e 0a 2a 2a UTF-8 string..**
1b160 0a 2a 2a 20 54 68 65 20 69 6e 70 75 74 20 74 6f .** The input to
1b170 20 5b 73 71 6c 69 74 65 33 5f 63 6f 6d 70 6c 65 [sqlite3_comple
1b180 74 65 31 36 28 29 5d 20 6d 75 73 74 20 62 65 20 te16()] must be
1b190 61 20 7a 65 72 6f 2d 74 65 72 6d 69 6e 61 74 65 a zero-terminate
1b1a0 64 0a 2a 2a 20 55 54 46 2d 31 36 20 73 74 72 69 d.** UTF-16 stri
1b1b0 6e 67 20 69 6e 20 6e 61 74 69 76 65 20 62 79 74 ng in native byt
1b1c0 65 20 6f 72 64 65 72 2e 0a 2a 2f 0a 69 6e 74 20 e order..*/.int
1b1d0 73 71 6c 69 74 65 33 5f 63 6f 6d 70 6c 65 74 65 sqlite3_complete
1b1e0 28 63 6f 6e 73 74 20 63 68 61 72 20 2a 73 71 6c (const char *sql
1b1f0 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f 63 );.int sqlite3_c
1b200 6f 6d 70 6c 65 74 65 31 36 28 63 6f 6e 73 74 20 omplete16(const
1b210 76 6f 69 64 20 2a 73 71 6c 29 3b 0a 0a 2f 2a 0a void *sql);../*.
1b220 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 52 65 67 ** CAPI3REF: Reg
1b230 69 73 74 65 72 20 41 20 43 61 6c 6c 62 61 63 6b ister A Callback
1b240 20 54 6f 20 48 61 6e 64 6c 65 20 53 51 4c 49 54 To Handle SQLIT
1b250 45 5f 42 55 53 59 20 45 72 72 6f 72 73 0a 2a 2a E_BUSY Errors.**
1b260 20 4b 45 59 57 4f 52 44 53 3a 20 7b 62 75 73 79 KEYWORDS: {busy
1b270 2d 68 61 6e 64 6c 65 72 20 63 61 6c 6c 62 61 63 -handler callbac
1b280 6b 7d 20 7b 62 75 73 79 20 68 61 6e 64 6c 65 72 k} {busy handler
1b290 7d 0a 2a 2a 20 4d 45 54 48 4f 44 3a 20 73 71 6c }.** METHOD: sql
1b2a0 69 74 65 33 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 ite3.**.** ^The
1b2b0 73 71 6c 69 74 65 33 5f 62 75 73 79 5f 68 61 6e sqlite3_busy_han
1b2c0 64 6c 65 72 28 44 2c 58 2c 50 29 20 72 6f 75 74 dler(D,X,P) rout
1b2d0 69 6e 65 20 73 65 74 73 20 61 20 63 61 6c 6c 62 ine sets a callb
1b2e0 61 63 6b 20 66 75 6e 63 74 69 6f 6e 20 58 0a 2a ack function X.*
1b2f0 2a 20 74 68 61 74 20 6d 69 67 68 74 20 62 65 20 * that might be
1b300 69 6e 76 6f 6b 65 64 20 77 69 74 68 20 61 72 67 invoked with arg
1b310 75 6d 65 6e 74 20 50 20 77 68 65 6e 65 76 65 72 ument P whenever
1b320 0a 2a 2a 20 61 6e 20 61 74 74 65 6d 70 74 20 69 .** an attempt i
1b330 73 20 6d 61 64 65 20 74 6f 20 61 63 63 65 73 73 s made to access
1b340 20 61 20 64 61 74 61 62 61 73 65 20 74 61 62 6c a database tabl
1b350 65 20 61 73 73 6f 63 69 61 74 65 64 20 77 69 74 e associated wit
1b360 68 0a 2a 2a 20 5b 64 61 74 61 62 61 73 65 20 63 h.** [database c
1b370 6f 6e 6e 65 63 74 69 6f 6e 5d 20 44 20 77 68 65 onnection] D whe
1b380 6e 20 61 6e 6f 74 68 65 72 20 74 68 72 65 61 64 n another thread
1b390 0a 2a 2a 20 6f 72 20 70 72 6f 63 65 73 73 20 68 .** or process h
1b3a0 61 73 20 74 68 65 20 74 61 62 6c 65 20 6c 6f 63 as the table loc
1b3b0 6b 65 64 2e 0a 2a 2a 20 54 68 65 20 73 71 6c 69 ked..** The sqli
1b3c0 74 65 33 5f 62 75 73 79 5f 68 61 6e 64 6c 65 72 te3_busy_handler
1b3d0 28 29 20 69 6e 74 65 72 66 61 63 65 20 69 73 20 () interface is
1b3e0 75 73 65 64 20 74 6f 20 69 6d 70 6c 65 6d 65 6e used to implemen
1b3f0 74 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 62 75 t.** [sqlite3_bu
1b400 73 79 5f 74 69 6d 65 6f 75 74 28 29 5d 20 61 6e sy_timeout()] an
1b410 64 20 5b 50 52 41 47 4d 41 20 62 75 73 79 5f 74 d [PRAGMA busy_t
1b420 69 6d 65 6f 75 74 5d 2e 0a 2a 2a 0a 2a 2a 20 5e imeout]..**.** ^
1b430 49 66 20 74 68 65 20 62 75 73 79 20 63 61 6c 6c If the busy call
1b440 62 61 63 6b 20 69 73 20 4e 55 4c 4c 2c 20 74 68 back is NULL, th
1b450 65 6e 20 5b 53 51 4c 49 54 45 5f 42 55 53 59 5d en [SQLITE_BUSY]
1b460 0a 2a 2a 20 69 73 20 72 65 74 75 72 6e 65 64 20 .** is returned
1b470 69 6d 6d 65 64 69 61 74 65 6c 79 20 75 70 6f 6e immediately upon
1b480 20 65 6e 63 6f 75 6e 74 65 72 69 6e 67 20 74 68 encountering th
1b490 65 20 6c 6f 63 6b 2e 20 20 5e 49 66 20 74 68 65 e lock. ^If the
1b4a0 20 62 75 73 79 20 63 61 6c 6c 62 61 63 6b 0a 2a busy callback.*
1b4b0 2a 20 69 73 20 6e 6f 74 20 4e 55 4c 4c 2c 20 74 * is not NULL, t
1b4c0 68 65 6e 20 74 68 65 20 63 61 6c 6c 62 61 63 6b hen the callback
1b4d0 20 6d 69 67 68 74 20 62 65 20 69 6e 76 6f 6b 65 might be invoke
1b4e0 64 20 77 69 74 68 20 74 77 6f 20 61 72 67 75 6d d with two argum
1b4f0 65 6e 74 73 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 ents..**.** ^The
1b500 20 66 69 72 73 74 20 61 72 67 75 6d 65 6e 74 20 first argument
1b510 74 6f 20 74 68 65 20 62 75 73 79 20 68 61 6e 64 to the busy hand
1b520 6c 65 72 20 69 73 20 61 20 63 6f 70 79 20 6f 66 ler is a copy of
1b530 20 74 68 65 20 76 6f 69 64 2a 20 70 6f 69 6e 74 the void* point
1b540 65 72 20 77 68 69 63 68 0a 2a 2a 20 69 73 20 74 er which.** is t
1b550 68 65 20 74 68 69 72 64 20 61 72 67 75 6d 65 6e he third argumen
1b560 74 20 74 6f 20 73 71 6c 69 74 65 33 5f 62 75 73 t to sqlite3_bus
1b570 79 5f 68 61 6e 64 6c 65 72 28 29 2e 20 20 5e 54 y_handler(). ^T
1b580 68 65 20 73 65 63 6f 6e 64 20 61 72 67 75 6d 65 he second argume
1b590 6e 74 20 74 6f 0a 2a 2a 20 74 68 65 20 62 75 73 nt to.** the bus
1b5a0 79 20 68 61 6e 64 6c 65 72 20 63 61 6c 6c 62 61 y handler callba
1b5b0 63 6b 20 69 73 20 74 68 65 20 6e 75 6d 62 65 72 ck is the number
1b5c0 20 6f 66 20 74 69 6d 65 73 20 74 68 61 74 20 74 of times that t
1b5d0 68 65 20 62 75 73 79 20 68 61 6e 64 6c 65 72 20 he busy handler
1b5e0 68 61 73 0a 2a 2a 20 62 65 65 6e 20 69 6e 76 6f has.** been invo
1b5f0 6b 65 64 20 70 72 65 76 69 6f 75 73 6c 79 20 66 ked previously f
1b600 6f 72 20 74 68 65 20 73 61 6d 65 20 6c 6f 63 6b or the same lock
1b610 69 6e 67 20 65 76 65 6e 74 2e 20 20 5e 49 66 20 ing event. ^If
1b620 74 68 65 0a 2a 2a 20 62 75 73 79 20 63 61 6c 6c the.** busy call
1b630 62 61 63 6b 20 72 65 74 75 72 6e 73 20 30 2c 20 back returns 0,
1b640 74 68 65 6e 20 6e 6f 20 61 64 64 69 74 69 6f 6e then no addition
1b650 61 6c 20 61 74 74 65 6d 70 74 73 20 61 72 65 20 al attempts are
1b660 6d 61 64 65 20 74 6f 0a 2a 2a 20 61 63 63 65 73 made to.** acces
1b670 73 20 74 68 65 20 64 61 74 61 62 61 73 65 20 61 s the database a
1b680 6e 64 20 5b 53 51 4c 49 54 45 5f 42 55 53 59 5d nd [SQLITE_BUSY]
1b690 20 69 73 20 72 65 74 75 72 6e 65 64 0a 2a 2a 20 is returned.**
1b6a0 74 6f 20 74 68 65 20 61 70 70 6c 69 63 61 74 69 to the applicati
1b6b0 6f 6e 2e 0a 2a 2a 20 5e 49 66 20 74 68 65 20 63 on..** ^If the c
1b6c0 61 6c 6c 62 61 63 6b 20 72 65 74 75 72 6e 73 20 allback returns
1b6d0 6e 6f 6e 2d 7a 65 72 6f 2c 20 74 68 65 6e 20 61 non-zero, then a
1b6e0 6e 6f 74 68 65 72 20 61 74 74 65 6d 70 74 0a 2a nother attempt.*
1b6f0 2a 20 69 73 20 6d 61 64 65 20 74 6f 20 61 63 63 * is made to acc
1b700 65 73 73 20 74 68 65 20 64 61 74 61 62 61 73 65 ess the database
1b710 20 61 6e 64 20 74 68 65 20 63 79 63 6c 65 20 72 and the cycle r
1b720 65 70 65 61 74 73 2e 0a 2a 2a 0a 2a 2a 20 54 68 epeats..**.** Th
1b730 65 20 70 72 65 73 65 6e 63 65 20 6f 66 20 61 20 e presence of a
1b740 62 75 73 79 20 68 61 6e 64 6c 65 72 20 64 6f 65 busy handler doe
1b750 73 20 6e 6f 74 20 67 75 61 72 61 6e 74 65 65 20 s not guarantee
1b760 74 68 61 74 20 69 74 20 77 69 6c 6c 20 62 65 20 that it will be
1b770 69 6e 76 6f 6b 65 64 0a 2a 2a 20 77 68 65 6e 20 invoked.** when
1b780 74 68 65 72 65 20 69 73 20 6c 6f 63 6b 20 63 6f there is lock co
1b790 6e 74 65 6e 74 69 6f 6e 2e 20 5e 49 66 20 53 51 ntention. ^If SQ
1b7a0 4c 69 74 65 20 64 65 74 65 72 6d 69 6e 65 73 20 Lite determines
1b7b0 74 68 61 74 20 69 6e 76 6f 6b 69 6e 67 20 74 68 that invoking th
1b7c0 65 20 62 75 73 79 0a 2a 2a 20 68 61 6e 64 6c 65 e busy.** handle
1b7d0 72 20 63 6f 75 6c 64 20 72 65 73 75 6c 74 20 69 r could result i
1b7e0 6e 20 61 20 64 65 61 64 6c 6f 63 6b 2c 20 69 74 n a deadlock, it
1b7f0 20 77 69 6c 6c 20 67 6f 20 61 68 65 61 64 20 61 will go ahead a
1b800 6e 64 20 72 65 74 75 72 6e 20 5b 53 51 4c 49 54 nd return [SQLIT
1b810 45 5f 42 55 53 59 5d 0a 2a 2a 20 74 6f 20 74 68 E_BUSY].** to th
1b820 65 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 69 6e e application in
1b830 73 74 65 61 64 20 6f 66 20 69 6e 76 6f 6b 69 6e stead of invokin
1b840 67 20 74 68 65 20 0a 2a 2a 20 62 75 73 79 20 68 g the .** busy h
1b850 61 6e 64 6c 65 72 2e 0a 2a 2a 20 43 6f 6e 73 69 andler..** Consi
1b860 64 65 72 20 61 20 73 63 65 6e 61 72 69 6f 20 77 der a scenario w
1b870 68 65 72 65 20 6f 6e 65 20 70 72 6f 63 65 73 73 here one process
1b880 20 69 73 20 68 6f 6c 64 69 6e 67 20 61 20 72 65 is holding a re
1b890 61 64 20 6c 6f 63 6b 20 74 68 61 74 0a 2a 2a 20 ad lock that.**
1b8a0 69 74 20 69 73 20 74 72 79 69 6e 67 20 74 6f 20 it is trying to
1b8b0 70 72 6f 6d 6f 74 65 20 74 6f 20 61 20 72 65 73 promote to a res
1b8c0 65 72 76 65 64 20 6c 6f 63 6b 20 61 6e 64 0a 2a erved lock and.*
1b8d0 2a 20 61 20 73 65 63 6f 6e 64 20 70 72 6f 63 65 * a second proce
1b8e0 73 73 20 69 73 20 68 6f 6c 64 69 6e 67 20 61 20 ss is holding a
1b8f0 72 65 73 65 72 76 65 64 20 6c 6f 63 6b 20 74 68 reserved lock th
1b900 61 74 20 69 74 20 69 73 20 74 72 79 69 6e 67 0a at it is trying.
1b910 2a 2a 20 74 6f 20 70 72 6f 6d 6f 74 65 20 74 6f ** to promote to
1b920 20 61 6e 20 65 78 63 6c 75 73 69 76 65 20 6c 6f an exclusive lo
1b930 63 6b 2e 20 20 54 68 65 20 66 69 72 73 74 20 70 ck. The first p
1b940 72 6f 63 65 73 73 20 63 61 6e 6e 6f 74 20 70 72 rocess cannot pr
1b950 6f 63 65 65 64 0a 2a 2a 20 62 65 63 61 75 73 65 oceed.** because
1b960 20 69 74 20 69 73 20 62 6c 6f 63 6b 65 64 20 62 it is blocked b
1b970 79 20 74 68 65 20 73 65 63 6f 6e 64 20 61 6e 64 y the second and
1b980 20 74 68 65 20 73 65 63 6f 6e 64 20 70 72 6f 63 the second proc
1b990 65 73 73 20 63 61 6e 6e 6f 74 0a 2a 2a 20 70 72 ess cannot.** pr
1b9a0 6f 63 65 65 64 20 62 65 63 61 75 73 65 20 69 74 oceed because it
1b9b0 20 69 73 20 62 6c 6f 63 6b 65 64 20 62 79 20 74 is blocked by t
1b9c0 68 65 20 66 69 72 73 74 2e 20 20 49 66 20 62 6f he first. If bo
1b9d0 74 68 20 70 72 6f 63 65 73 73 65 73 0a 2a 2a 20 th processes.**
1b9e0 69 6e 76 6f 6b 65 20 74 68 65 20 62 75 73 79 20 invoke the busy
1b9f0 68 61 6e 64 6c 65 72 73 2c 20 6e 65 69 74 68 65 handlers, neithe
1ba00 72 20 77 69 6c 6c 20 6d 61 6b 65 20 61 6e 79 20 r will make any
1ba10 70 72 6f 67 72 65 73 73 2e 20 20 54 68 65 72 65 progress. There
1ba20 66 6f 72 65 2c 0a 2a 2a 20 53 51 4c 69 74 65 20 fore,.** SQLite
1ba30 72 65 74 75 72 6e 73 20 5b 53 51 4c 49 54 45 5f returns [SQLITE_
1ba40 42 55 53 59 5d 20 66 6f 72 20 74 68 65 20 66 69 BUSY] for the fi
1ba50 72 73 74 20 70 72 6f 63 65 73 73 2c 20 68 6f 70 rst process, hop
1ba60 69 6e 67 20 74 68 61 74 20 74 68 69 73 0a 2a 2a ing that this.**
1ba70 20 77 69 6c 6c 20 69 6e 64 75 63 65 20 74 68 65 will induce the
1ba80 20 66 69 72 73 74 20 70 72 6f 63 65 73 73 20 74 first process t
1ba90 6f 20 72 65 6c 65 61 73 65 20 69 74 73 20 72 65 o release its re
1baa0 61 64 20 6c 6f 63 6b 20 61 6e 64 20 61 6c 6c 6f ad lock and allo
1bab0 77 0a 2a 2a 20 74 68 65 20 73 65 63 6f 6e 64 20 w.** the second
1bac0 70 72 6f 63 65 73 73 20 74 6f 20 70 72 6f 63 65 process to proce
1bad0 65 64 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 64 ed..**.** ^The d
1bae0 65 66 61 75 6c 74 20 62 75 73 79 20 63 61 6c 6c efault busy call
1baf0 62 61 63 6b 20 69 73 20 4e 55 4c 4c 2e 0a 2a 2a back is NULL..**
1bb00 0a 2a 2a 20 5e 28 54 68 65 72 65 20 63 61 6e 20 .** ^(There can
1bb10 6f 6e 6c 79 20 62 65 20 61 20 73 69 6e 67 6c 65 only be a single
1bb20 20 62 75 73 79 20 68 61 6e 64 6c 65 72 20 64 65 busy handler de
1bb30 66 69 6e 65 64 20 66 6f 72 20 65 61 63 68 0a 2a fined for each.*
1bb40 2a 20 5b 64 61 74 61 62 61 73 65 20 63 6f 6e 6e * [database conn
1bb50 65 63 74 69 6f 6e 5d 2e 20 20 53 65 74 74 69 6e ection]. Settin
1bb60 67 20 61 20 6e 65 77 20 62 75 73 79 20 68 61 6e g a new busy han
1bb70 64 6c 65 72 20 63 6c 65 61 72 73 20 61 6e 79 0a dler clears any.
1bb80 2a 2a 20 70 72 65 76 69 6f 75 73 6c 79 20 73 65 ** previously se
1bb90 74 20 68 61 6e 64 6c 65 72 2e 29 5e 20 20 5e 4e t handler.)^ ^N
1bba0 6f 74 65 20 74 68 61 74 20 63 61 6c 6c 69 6e 67 ote that calling
1bbb0 20 5b 73 71 6c 69 74 65 33 5f 62 75 73 79 5f 74 [sqlite3_busy_t
1bbc0 69 6d 65 6f 75 74 28 29 5d 0a 2a 2a 20 6f 72 20 imeout()].** or
1bbd0 65 76 61 6c 75 61 74 69 6e 67 20 5b 50 52 41 47 evaluating [PRAG
1bbe0 4d 41 20 62 75 73 79 5f 74 69 6d 65 6f 75 74 3d MA busy_timeout=
1bbf0 4e 5d 20 77 69 6c 6c 20 63 68 61 6e 67 65 20 74 N] will change t
1bc00 68 65 0a 2a 2a 20 62 75 73 79 20 68 61 6e 64 6c he.** busy handl
1bc10 65 72 20 61 6e 64 20 74 68 75 73 20 63 6c 65 61 er and thus clea
1bc20 72 20 61 6e 79 20 70 72 65 76 69 6f 75 73 6c 79 r any previously
1bc30 20 73 65 74 20 62 75 73 79 20 68 61 6e 64 6c 65 set busy handle
1bc40 72 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 62 75 73 r..**.** The bus
1bc50 79 20 63 61 6c 6c 62 61 63 6b 20 73 68 6f 75 6c y callback shoul
1bc60 64 20 6e 6f 74 20 74 61 6b 65 20 61 6e 79 20 61 d not take any a
1bc70 63 74 69 6f 6e 73 20 77 68 69 63 68 20 6d 6f 64 ctions which mod
1bc80 69 66 79 20 74 68 65 0a 2a 2a 20 64 61 74 61 62 ify the.** datab
1bc90 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 74 ase connection t
1bca0 68 61 74 20 69 6e 76 6f 6b 65 64 20 74 68 65 20 hat invoked the
1bcb0 62 75 73 79 20 68 61 6e 64 6c 65 72 2e 20 20 49 busy handler. I
1bcc0 6e 20 6f 74 68 65 72 20 77 6f 72 64 73 2c 0a 2a n other words,.*
1bcd0 2a 20 74 68 65 20 62 75 73 79 20 68 61 6e 64 6c * the busy handl
1bce0 65 72 20 69 73 20 6e 6f 74 20 72 65 65 6e 74 72 er is not reentr
1bcf0 61 6e 74 2e 20 20 41 6e 79 20 73 75 63 68 20 61 ant. Any such a
1bd00 63 74 69 6f 6e 73 0a 2a 2a 20 72 65 73 75 6c 74 ctions.** result
1bd10 20 69 6e 20 75 6e 64 65 66 69 6e 65 64 20 62 65 in undefined be
1bd20 68 61 76 69 6f 72 2e 0a 2a 2a 20 0a 2a 2a 20 41 havior..** .** A
1bd30 20 62 75 73 79 20 68 61 6e 64 6c 65 72 20 6d 75 busy handler mu
1bd40 73 74 20 6e 6f 74 20 63 6c 6f 73 65 20 74 68 65 st not close the
1bd50 20 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 database connec
1bd60 74 69 6f 6e 0a 2a 2a 20 6f 72 20 5b 70 72 65 70 tion.** or [prep
1bd70 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 5d 20 ared statement]
1bd80 74 68 61 74 20 69 6e 76 6f 6b 65 64 20 74 68 65 that invoked the
1bd90 20 62 75 73 79 20 68 61 6e 64 6c 65 72 2e 0a 2a busy handler..*
1bda0 2f 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f 62 75 /.int sqlite3_bu
1bdb0 73 79 5f 68 61 6e 64 6c 65 72 28 73 71 6c 69 74 sy_handler(sqlit
1bdc0 65 33 2a 2c 69 6e 74 28 2a 29 28 76 6f 69 64 2a e3*,int(*)(void*
1bdd0 2c 69 6e 74 29 2c 76 6f 69 64 2a 29 3b 0a 0a 2f ,int),void*);../
1bde0 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 53 *.** CAPI3REF: S
1bdf0 65 74 20 41 20 42 75 73 79 20 54 69 6d 65 6f 75 et A Busy Timeou
1be00 74 0a 2a 2a 20 4d 45 54 48 4f 44 3a 20 73 71 6c t.** METHOD: sql
1be10 69 74 65 33 0a 2a 2a 0a 2a 2a 20 5e 54 68 69 73 ite3.**.** ^This
1be20 20 72 6f 75 74 69 6e 65 20 73 65 74 73 20 61 20 routine sets a
1be30 5b 73 71 6c 69 74 65 33 5f 62 75 73 79 5f 68 61 [sqlite3_busy_ha
1be40 6e 64 6c 65 72 20 7c 20 62 75 73 79 20 68 61 6e ndler | busy han
1be50 64 6c 65 72 5d 20 74 68 61 74 20 73 6c 65 65 70 dler] that sleep
1be60 73 0a 2a 2a 20 66 6f 72 20 61 20 73 70 65 63 69 s.** for a speci
1be70 66 69 65 64 20 61 6d 6f 75 6e 74 20 6f 66 20 74 fied amount of t
1be80 69 6d 65 20 77 68 65 6e 20 61 20 74 61 62 6c 65 ime when a table
1be90 20 69 73 20 6c 6f 63 6b 65 64 2e 20 20 5e 54 68 is locked. ^Th
1bea0 65 20 68 61 6e 64 6c 65 72 0a 2a 2a 20 77 69 6c e handler.** wil
1beb0 6c 20 73 6c 65 65 70 20 6d 75 6c 74 69 70 6c 65 l sleep multiple
1bec0 20 74 69 6d 65 73 20 75 6e 74 69 6c 20 61 74 20 times until at
1bed0 6c 65 61 73 74 20 22 6d 73 22 20 6d 69 6c 6c 69 least "ms" milli
1bee0 73 65 63 6f 6e 64 73 20 6f 66 20 73 6c 65 65 70 seconds of sleep
1bef0 69 6e 67 0a 2a 2a 20 68 61 76 65 20 61 63 63 75 ing.** have accu
1bf00 6d 75 6c 61 74 65 64 2e 20 20 5e 41 66 74 65 72 mulated. ^After
1bf10 20 61 74 20 6c 65 61 73 74 20 22 6d 73 22 20 6d at least "ms" m
1bf20 69 6c 6c 69 73 65 63 6f 6e 64 73 20 6f 66 20 73 illiseconds of s
1bf30 6c 65 65 70 69 6e 67 2c 0a 2a 2a 20 74 68 65 20 leeping,.** the
1bf40 68 61 6e 64 6c 65 72 20 72 65 74 75 72 6e 73 20 handler returns
1bf50 30 20 77 68 69 63 68 20 63 61 75 73 65 73 20 5b 0 which causes [
1bf60 73 71 6c 69 74 65 33 5f 73 74 65 70 28 29 5d 20 sqlite3_step()]
1bf70 74 6f 20 72 65 74 75 72 6e 0a 2a 2a 20 5b 53 51 to return.** [SQ
1bf80 4c 49 54 45 5f 42 55 53 59 5d 2e 0a 2a 2a 0a 2a LITE_BUSY]..**.*
1bf90 2a 20 5e 43 61 6c 6c 69 6e 67 20 74 68 69 73 20 * ^Calling this
1bfa0 72 6f 75 74 69 6e 65 20 77 69 74 68 20 61 6e 20 routine with an
1bfb0 61 72 67 75 6d 65 6e 74 20 6c 65 73 73 20 74 68 argument less th
1bfc0 61 6e 20 6f 72 20 65 71 75 61 6c 20 74 6f 20 7a an or equal to z
1bfd0 65 72 6f 0a 2a 2a 20 74 75 72 6e 73 20 6f 66 66 ero.** turns off
1bfe0 20 61 6c 6c 20 62 75 73 79 20 68 61 6e 64 6c 65 all busy handle
1bff0 72 73 2e 0a 2a 2a 0a 2a 2a 20 5e 28 54 68 65 72 rs..**.** ^(Ther
1c000 65 20 63 61 6e 20 6f 6e 6c 79 20 62 65 20 61 20 e can only be a
1c010 73 69 6e 67 6c 65 20 62 75 73 79 20 68 61 6e 64 single busy hand
1c020 6c 65 72 20 66 6f 72 20 61 20 70 61 72 74 69 63 ler for a partic
1c030 75 6c 61 72 0a 2a 2a 20 5b 64 61 74 61 62 61 73 ular.** [databas
1c040 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 5d 20 61 74 e connection] at
1c050 20 61 6e 79 20 67 69 76 65 6e 20 6d 6f 6d 65 6e any given momen
1c060 74 2e 20 20 49 66 20 61 6e 6f 74 68 65 72 20 62 t. If another b
1c070 75 73 79 20 68 61 6e 64 6c 65 72 0a 2a 2a 20 77 usy handler.** w
1c080 61 73 20 64 65 66 69 6e 65 64 20 20 28 75 73 69 as defined (usi
1c090 6e 67 20 5b 73 71 6c 69 74 65 33 5f 62 75 73 79 ng [sqlite3_busy
1c0a0 5f 68 61 6e 64 6c 65 72 28 29 5d 29 20 70 72 69 _handler()]) pri
1c0b0 6f 72 20 74 6f 20 63 61 6c 6c 69 6e 67 0a 2a 2a or to calling.**
1c0c0 20 74 68 69 73 20 72 6f 75 74 69 6e 65 2c 20 74 this routine, t
1c0d0 68 61 74 20 6f 74 68 65 72 20 62 75 73 79 20 68 hat other busy h
1c0e0 61 6e 64 6c 65 72 20 69 73 20 63 6c 65 61 72 65 andler is cleare
1c0f0 64 2e 29 5e 0a 2a 2a 0a 2a 2a 20 53 65 65 20 61 d.)^.**.** See a
1c100 6c 73 6f 3a 20 20 5b 50 52 41 47 4d 41 20 62 75 lso: [PRAGMA bu
1c110 73 79 5f 74 69 6d 65 6f 75 74 5d 0a 2a 2f 0a 69 sy_timeout].*/.i
1c120 6e 74 20 73 71 6c 69 74 65 33 5f 62 75 73 79 5f nt sqlite3_busy_
1c130 74 69 6d 65 6f 75 74 28 73 71 6c 69 74 65 33 2a timeout(sqlite3*
1c140 2c 20 69 6e 74 20 6d 73 29 3b 0a 0a 2f 2a 0a 2a , int ms);../*.*
1c150 2a 20 43 41 50 49 33 52 45 46 3a 20 43 6f 6e 76 * CAPI3REF: Conv
1c160 65 6e 69 65 6e 63 65 20 52 6f 75 74 69 6e 65 73 enience Routines
1c170 20 46 6f 72 20 52 75 6e 6e 69 6e 67 20 51 75 65 For Running Que
1c180 72 69 65 73 0a 2a 2a 20 4d 45 54 48 4f 44 3a 20 ries.** METHOD:
1c190 73 71 6c 69 74 65 33 0a 2a 2a 0a 2a 2a 20 54 68 sqlite3.**.** Th
1c1a0 69 73 20 69 73 20 61 20 6c 65 67 61 63 79 20 69 is is a legacy i
1c1b0 6e 74 65 72 66 61 63 65 20 74 68 61 74 20 69 73 nterface that is
1c1c0 20 70 72 65 73 65 72 76 65 64 20 66 6f 72 20 62 preserved for b
1c1d0 61 63 6b 77 61 72 64 73 20 63 6f 6d 70 61 74 69 ackwards compati
1c1e0 62 69 6c 69 74 79 2e 0a 2a 2a 20 55 73 65 20 6f bility..** Use o
1c1f0 66 20 74 68 69 73 20 69 6e 74 65 72 66 61 63 65 f this interface
1c200 20 69 73 20 6e 6f 74 20 72 65 63 6f 6d 6d 65 6e is not recommen
1c210 64 65 64 2e 0a 2a 2a 0a 2a 2a 20 44 65 66 69 6e ded..**.** Defin
1c220 69 74 69 6f 6e 3a 20 41 20 3c 62 3e 72 65 73 75 ition: A <b>resu
1c230 6c 74 20 74 61 62 6c 65 3c 2f 62 3e 20 69 73 20 lt table</b> is
1c240 6d 65 6d 6f 72 79 20 64 61 74 61 20 73 74 72 75 memory data stru
1c250 63 74 75 72 65 20 63 72 65 61 74 65 64 20 62 79 cture created by
1c260 20 74 68 65 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 the.** [sqlite3
1c270 5f 67 65 74 5f 74 61 62 6c 65 28 29 5d 20 69 6e _get_table()] in
1c280 74 65 72 66 61 63 65 2e 20 20 41 20 72 65 73 75 terface. A resu
1c290 6c 74 20 74 61 62 6c 65 20 72 65 63 6f 72 64 73 lt table records
1c2a0 20 74 68 65 0a 2a 2a 20 63 6f 6d 70 6c 65 74 65 the.** complete
1c2b0 20 71 75 65 72 79 20 72 65 73 75 6c 74 73 20 66 query results f
1c2c0 72 6f 6d 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 20 rom one or more
1c2d0 71 75 65 72 69 65 73 2e 0a 2a 2a 0a 2a 2a 20 54 queries..**.** T
1c2e0 68 65 20 74 61 62 6c 65 20 63 6f 6e 63 65 70 74 he table concept
1c2f0 75 61 6c 6c 79 20 68 61 73 20 61 20 6e 75 6d 62 ually has a numb
1c300 65 72 20 6f 66 20 72 6f 77 73 20 61 6e 64 20 63 er of rows and c
1c310 6f 6c 75 6d 6e 73 2e 20 20 42 75 74 0a 2a 2a 20 olumns. But.**
1c320 74 68 65 73 65 20 6e 75 6d 62 65 72 73 20 61 72 these numbers ar
1c330 65 20 6e 6f 74 20 70 61 72 74 20 6f 66 20 74 68 e not part of th
1c340 65 20 72 65 73 75 6c 74 20 74 61 62 6c 65 20 69 e result table i
1c350 74 73 65 6c 66 2e 20 20 54 68 65 73 65 0a 2a 2a tself. These.**
1c360 20 6e 75 6d 62 65 72 73 20 61 72 65 20 6f 62 74 numbers are obt
1c370 61 69 6e 65 64 20 73 65 70 61 72 61 74 65 6c 79 ained separately
1c380 2e 20 20 4c 65 74 20 4e 20 62 65 20 74 68 65 20 . Let N be the
1c390 6e 75 6d 62 65 72 20 6f 66 20 72 6f 77 73 0a 2a number of rows.*
1c3a0 2a 20 61 6e 64 20 4d 20 62 65 20 74 68 65 20 6e * and M be the n
1c3b0 75 6d 62 65 72 20 6f 66 20 63 6f 6c 75 6d 6e 73 umber of columns
1c3c0 2e 0a 2a 2a 0a 2a 2a 20 41 20 72 65 73 75 6c 74 ..**.** A result
1c3d0 20 74 61 62 6c 65 20 69 73 20 61 6e 20 61 72 72 table is an arr
1c3e0 61 79 20 6f 66 20 70 6f 69 6e 74 65 72 73 20 74 ay of pointers t
1c3f0 6f 20 7a 65 72 6f 2d 74 65 72 6d 69 6e 61 74 65 o zero-terminate
1c400 64 20 55 54 46 2d 38 20 73 74 72 69 6e 67 73 2e d UTF-8 strings.
1c410 0a 2a 2a 20 54 68 65 72 65 20 61 72 65 20 28 4e .** There are (N
1c420 2b 31 29 2a 4d 20 65 6c 65 6d 65 6e 74 73 20 69 +1)*M elements i
1c430 6e 20 74 68 65 20 61 72 72 61 79 2e 20 20 54 68 n the array. Th
1c440 65 20 66 69 72 73 74 20 4d 20 70 6f 69 6e 74 65 e first M pointe
1c450 72 73 20 70 6f 69 6e 74 0a 2a 2a 20 74 6f 20 7a rs point.** to z
1c460 65 72 6f 2d 74 65 72 6d 69 6e 61 74 65 64 20 73 ero-terminated s
1c470 74 72 69 6e 67 73 20 74 68 61 74 20 20 63 6f 6e trings that con
1c480 74 61 69 6e 20 74 68 65 20 6e 61 6d 65 73 20 6f tain the names o
1c490 66 20 74 68 65 20 63 6f 6c 75 6d 6e 73 2e 0a 2a f the columns..*
1c4a0 2a 20 54 68 65 20 72 65 6d 61 69 6e 69 6e 67 20 * The remaining
1c4b0 65 6e 74 72 69 65 73 20 61 6c 6c 20 70 6f 69 6e entries all poin
1c4c0 74 20 74 6f 20 71 75 65 72 79 20 72 65 73 75 6c t to query resul
1c4d0 74 73 2e 20 20 4e 55 4c 4c 20 76 61 6c 75 65 73 ts. NULL values
1c4e0 20 72 65 73 75 6c 74 0a 2a 2a 20 69 6e 20 4e 55 result.** in NU
1c4f0 4c 4c 20 70 6f 69 6e 74 65 72 73 2e 20 20 41 6c LL pointers. Al
1c500 6c 20 6f 74 68 65 72 20 76 61 6c 75 65 73 20 61 l other values a
1c510 72 65 20 69 6e 20 74 68 65 69 72 20 55 54 46 2d re in their UTF-
1c520 38 20 7a 65 72 6f 2d 74 65 72 6d 69 6e 61 74 65 8 zero-terminate
1c530 64 0a 2a 2a 20 73 74 72 69 6e 67 20 72 65 70 72 d.** string repr
1c540 65 73 65 6e 74 61 74 69 6f 6e 20 61 73 20 72 65 esentation as re
1c550 74 75 72 6e 65 64 20 62 79 20 5b 73 71 6c 69 74 turned by [sqlit
1c560 65 33 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 29 e3_column_text()
1c570 5d 2e 0a 2a 2a 0a 2a 2a 20 41 20 72 65 73 75 6c ]..**.** A resul
1c580 74 20 74 61 62 6c 65 20 6d 69 67 68 74 20 63 6f t table might co
1c590 6e 73 69 73 74 20 6f 66 20 6f 6e 65 20 6f 72 20 nsist of one or
1c5a0 6d 6f 72 65 20 6d 65 6d 6f 72 79 20 61 6c 6c 6f more memory allo
1c5b0 63 61 74 69 6f 6e 73 2e 0a 2a 2a 20 49 74 20 69 cations..** It i
1c5c0 73 20 6e 6f 74 20 73 61 66 65 20 74 6f 20 70 61 s not safe to pa
1c5d0 73 73 20 61 20 72 65 73 75 6c 74 20 74 61 62 6c ss a result tabl
1c5e0 65 20 64 69 72 65 63 74 6c 79 20 74 6f 20 5b 73 e directly to [s
1c5f0 71 6c 69 74 65 33 5f 66 72 65 65 28 29 5d 2e 0a qlite3_free()]..
1c600 2a 2a 20 41 20 72 65 73 75 6c 74 20 74 61 62 6c ** A result tabl
1c610 65 20 73 68 6f 75 6c 64 20 62 65 20 64 65 61 6c e should be deal
1c620 6c 6f 63 61 74 65 64 20 75 73 69 6e 67 20 5b 73 located using [s
1c630 71 6c 69 74 65 33 5f 66 72 65 65 5f 74 61 62 6c qlite3_free_tabl
1c640 65 28 29 5d 2e 0a 2a 2a 0a 2a 2a 20 5e 28 41 73 e()]..**.** ^(As
1c650 20 61 6e 20 65 78 61 6d 70 6c 65 20 6f 66 20 74 an example of t
1c660 68 65 20 72 65 73 75 6c 74 20 74 61 62 6c 65 20 he result table
1c670 66 6f 72 6d 61 74 2c 20 73 75 70 70 6f 73 65 20 format, suppose
1c680 61 20 71 75 65 72 79 20 72 65 73 75 6c 74 0a 2a a query result.*
1c690 2a 20 69 73 20 61 73 20 66 6f 6c 6c 6f 77 73 3a * is as follows:
1c6a0 0a 2a 2a 0a 2a 2a 20 3c 62 6c 6f 63 6b 71 75 6f .**.** <blockquo
1c6b0 74 65 3e 3c 70 72 65 3e 0a 2a 2a 20 20 20 20 20 te><pre>.**
1c6c0 20 20 20 4e 61 6d 65 20 20 20 20 20 20 20 20 7c Name |
1c6d0 20 41 67 65 0a 2a 2a 20 20 20 20 20 20 20 20 2d Age.** -
1c6e0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1c6f0 2d 2d 2d 2d 2d 2d 0a 2a 2a 20 20 20 20 20 20 20 ------.**
1c700 20 41 6c 69 63 65 20 20 20 20 20 20 20 7c 20 34 Alice | 4
1c710 33 0a 2a 2a 20 20 20 20 20 20 20 20 42 6f 62 20 3.** Bob
1c720 20 20 20 20 20 20 20 20 7c 20 32 38 0a 2a 2a 20 | 28.**
1c730 20 20 20 20 20 20 20 43 69 6e 64 79 20 20 20 20 Cindy
1c740 20 20 20 7c 20 32 31 0a 2a 2a 20 3c 2f 70 72 65 | 21.** </pre
1c750 3e 3c 2f 62 6c 6f 63 6b 71 75 6f 74 65 3e 0a 2a ></blockquote>.*
1c760 2a 0a 2a 2a 20 54 68 65 72 65 20 61 72 65 20 74 *.** There are t
1c770 77 6f 20 63 6f 6c 75 6d 6e 20 28 4d 3d 3d 32 29 wo column (M==2)
1c780 20 61 6e 64 20 74 68 72 65 65 20 72 6f 77 73 20 and three rows
1c790 28 4e 3d 3d 33 29 2e 20 20 54 68 75 73 20 74 68 (N==3). Thus th
1c7a0 65 0a 2a 2a 20 72 65 73 75 6c 74 20 74 61 62 6c e.** result tabl
1c7b0 65 20 68 61 73 20 38 20 65 6e 74 72 69 65 73 2e e has 8 entries.
1c7c0 20 20 53 75 70 70 6f 73 65 20 74 68 65 20 72 65 Suppose the re
1c7d0 73 75 6c 74 20 74 61 62 6c 65 20 69 73 20 73 74 sult table is st
1c7e0 6f 72 65 64 0a 2a 2a 20 69 6e 20 61 6e 20 61 72 ored.** in an ar
1c7f0 72 61 79 20 6e 61 6d 65 73 20 61 7a 52 65 73 75 ray names azResu
1c800 6c 74 2e 20 20 54 68 65 6e 20 61 7a 52 65 73 75 lt. Then azResu
1c810 6c 74 20 68 6f 6c 64 73 20 74 68 69 73 20 63 6f lt holds this co
1c820 6e 74 65 6e 74 3a 0a 2a 2a 0a 2a 2a 20 3c 62 6c ntent:.**.** <bl
1c830 6f 63 6b 71 75 6f 74 65 3e 3c 70 72 65 3e 0a 2a ockquote><pre>.*
1c840 2a 20 20 20 20 20 20 20 20 61 7a 52 65 73 75 6c * azResul
1c850 74 26 23 39 31 3b 30 5d 20 3d 20 22 4e 61 6d 65 t[0] = "Name
1c860 22 3b 0a 2a 2a 20 20 20 20 20 20 20 20 61 7a 52 ";.** azR
1c870 65 73 75 6c 74 26 23 39 31 3b 31 5d 20 3d 20 22 esult[1] = "
1c880 41 67 65 22 3b 0a 2a 2a 20 20 20 20 20 20 20 20 Age";.**
1c890 61 7a 52 65 73 75 6c 74 26 23 39 31 3b 32 5d 20 azResult[2]
1c8a0 3d 20 22 41 6c 69 63 65 22 3b 0a 2a 2a 20 20 20 = "Alice";.**
1c8b0 20 20 20 20 20 61 7a 52 65 73 75 6c 74 26 23 39 azResult	
1c8c0 31 3b 33 5d 20 3d 20 22 34 33 22 3b 0a 2a 2a 20 1;3] = "43";.**
1c8d0 20 20 20 20 20 20 20 61 7a 52 65 73 75 6c 74 26 azResult&
1c8e0 23 39 31 3b 34 5d 20 3d 20 22 42 6f 62 22 3b 0a #91;4] = "Bob";.
1c8f0 2a 2a 20 20 20 20 20 20 20 20 61 7a 52 65 73 75 ** azResu
1c900 6c 74 26 23 39 31 3b 35 5d 20 3d 20 22 32 38 22 lt[5] = "28"
1c910 3b 0a 2a 2a 20 20 20 20 20 20 20 20 61 7a 52 65 ;.** azRe
1c920 73 75 6c 74 26 23 39 31 3b 36 5d 20 3d 20 22 43 sult[6] = "C
1c930 69 6e 64 79 22 3b 0a 2a 2a 20 20 20 20 20 20 20 indy";.**
1c940 20 61 7a 52 65 73 75 6c 74 26 23 39 31 3b 37 5d azResult[7]
1c950 20 3d 20 22 32 31 22 3b 0a 2a 2a 20 3c 2f 70 72 = "21";.** </pr
1c960 65 3e 3c 2f 62 6c 6f 63 6b 71 75 6f 74 65 3e 29 e></blockquote>)
1c970 5e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 6c ^.**.** ^The sql
1c980 69 74 65 33 5f 67 65 74 5f 74 61 62 6c 65 28 29 ite3_get_table()
1c990 20 66 75 6e 63 74 69 6f 6e 20 65 76 61 6c 75 61 function evalua
1c9a0 74 65 73 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 0a tes one or more.
1c9b0 2a 2a 20 73 65 6d 69 63 6f 6c 6f 6e 2d 73 65 70 ** semicolon-sep
1c9c0 61 72 61 74 65 64 20 53 51 4c 20 73 74 61 74 65 arated SQL state
1c9d0 6d 65 6e 74 73 20 69 6e 20 74 68 65 20 7a 65 72 ments in the zer
1c9e0 6f 2d 74 65 72 6d 69 6e 61 74 65 64 20 55 54 46 o-terminated UTF
1c9f0 2d 38 0a 2a 2a 20 73 74 72 69 6e 67 20 6f 66 20 -8.** string of
1ca00 69 74 73 20 32 6e 64 20 70 61 72 61 6d 65 74 65 its 2nd paramete
1ca10 72 20 61 6e 64 20 72 65 74 75 72 6e 73 20 61 20 r and returns a
1ca20 72 65 73 75 6c 74 20 74 61 62 6c 65 20 74 6f 20 result table to
1ca30 74 68 65 0a 2a 2a 20 70 6f 69 6e 74 65 72 20 67 the.** pointer g
1ca40 69 76 65 6e 20 69 6e 20 69 74 73 20 33 72 64 20 iven in its 3rd
1ca50 70 61 72 61 6d 65 74 65 72 2e 0a 2a 2a 0a 2a 2a parameter..**.**
1ca60 20 41 66 74 65 72 20 74 68 65 20 61 70 70 6c 69 After the appli
1ca70 63 61 74 69 6f 6e 20 68 61 73 20 66 69 6e 69 73 cation has finis
1ca80 68 65 64 20 77 69 74 68 20 74 68 65 20 72 65 73 hed with the res
1ca90 75 6c 74 20 66 72 6f 6d 20 73 71 6c 69 74 65 33 ult from sqlite3
1caa0 5f 67 65 74 5f 74 61 62 6c 65 28 29 2c 0a 2a 2a _get_table(),.**
1cab0 20 69 74 20 6d 75 73 74 20 70 61 73 73 20 74 68 it must pass th
1cac0 65 20 72 65 73 75 6c 74 20 74 61 62 6c 65 20 70 e result table p
1cad0 6f 69 6e 74 65 72 20 74 6f 20 73 71 6c 69 74 65 ointer to sqlite
1cae0 33 5f 66 72 65 65 5f 74 61 62 6c 65 28 29 20 69 3_free_table() i
1caf0 6e 20 6f 72 64 65 72 20 74 6f 0a 2a 2a 20 72 65 n order to.** re
1cb00 6c 65 61 73 65 20 74 68 65 20 6d 65 6d 6f 72 79 lease the memory
1cb10 20 74 68 61 74 20 77 61 73 20 6d 61 6c 6c 6f 63 that was malloc
1cb20 65 64 2e 20 20 42 65 63 61 75 73 65 20 6f 66 20 ed. Because of
1cb30 74 68 65 20 77 61 79 20 74 68 65 0a 2a 2a 20 5b the way the.** [
1cb40 73 71 6c 69 74 65 33 5f 6d 61 6c 6c 6f 63 28 29 sqlite3_malloc()
1cb50 5d 20 68 61 70 70 65 6e 73 20 77 69 74 68 69 6e ] happens within
1cb60 20 73 71 6c 69 74 65 33 5f 67 65 74 5f 74 61 62 sqlite3_get_tab
1cb70 6c 65 28 29 2c 20 74 68 65 20 63 61 6c 6c 69 6e le(), the callin
1cb80 67 0a 2a 2a 20 66 75 6e 63 74 69 6f 6e 20 6d 75 g.** function mu
1cb90 73 74 20 6e 6f 74 20 74 72 79 20 74 6f 20 63 61 st not try to ca
1cba0 6c 6c 20 5b 73 71 6c 69 74 65 33 5f 66 72 65 65 ll [sqlite3_free
1cbb0 28 29 5d 20 64 69 72 65 63 74 6c 79 2e 20 20 4f ()] directly. O
1cbc0 6e 6c 79 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f nly.** [sqlite3_
1cbd0 66 72 65 65 5f 74 61 62 6c 65 28 29 5d 20 69 73 free_table()] is
1cbe0 20 61 62 6c 65 20 74 6f 20 72 65 6c 65 61 73 65 able to release
1cbf0 20 74 68 65 20 6d 65 6d 6f 72 79 20 70 72 6f 70 the memory prop
1cc00 65 72 6c 79 20 61 6e 64 20 73 61 66 65 6c 79 2e erly and safely.
1cc10 0a 2a 2a 0a 2a 2a 20 54 68 65 20 73 71 6c 69 74 .**.** The sqlit
1cc20 65 33 5f 67 65 74 5f 74 61 62 6c 65 28 29 20 69 e3_get_table() i
1cc30 6e 74 65 72 66 61 63 65 20 69 73 20 69 6d 70 6c nterface is impl
1cc40 65 6d 65 6e 74 65 64 20 61 73 20 61 20 77 72 61 emented as a wra
1cc50 70 70 65 72 20 61 72 6f 75 6e 64 0a 2a 2a 20 5b pper around.** [
1cc60 73 71 6c 69 74 65 33 5f 65 78 65 63 28 29 5d 2e sqlite3_exec()].
1cc70 20 20 54 68 65 20 73 71 6c 69 74 65 33 5f 67 65 The sqlite3_ge
1cc80 74 5f 74 61 62 6c 65 28 29 20 72 6f 75 74 69 6e t_table() routin
1cc90 65 20 64 6f 65 73 20 6e 6f 74 20 68 61 76 65 20 e does not have
1cca0 61 63 63 65 73 73 0a 2a 2a 20 74 6f 20 61 6e 79 access.** to any
1ccb0 20 69 6e 74 65 72 6e 61 6c 20 64 61 74 61 20 73 internal data s
1ccc0 74 72 75 63 74 75 72 65 73 20 6f 66 20 53 51 4c tructures of SQL
1ccd0 69 74 65 2e 20 20 49 74 20 75 73 65 73 20 6f 6e ite. It uses on
1cce0 6c 79 20 74 68 65 20 70 75 62 6c 69 63 0a 2a 2a ly the public.**
1ccf0 20 69 6e 74 65 72 66 61 63 65 20 64 65 66 69 6e interface defin
1cd00 65 64 20 68 65 72 65 2e 20 20 41 73 20 61 20 63 ed here. As a c
1cd10 6f 6e 73 65 71 75 65 6e 63 65 2c 20 65 72 72 6f onsequence, erro
1cd20 72 73 20 74 68 61 74 20 6f 63 63 75 72 20 69 6e rs that occur in
1cd30 20 74 68 65 0a 2a 2a 20 77 72 61 70 70 65 72 20 the.** wrapper
1cd40 6c 61 79 65 72 20 6f 75 74 73 69 64 65 20 6f 66 layer outside of
1cd50 20 74 68 65 20 69 6e 74 65 72 6e 61 6c 20 5b 73 the internal [s
1cd60 71 6c 69 74 65 33 5f 65 78 65 63 28 29 5d 20 63 qlite3_exec()] c
1cd70 61 6c 6c 20 61 72 65 20 6e 6f 74 0a 2a 2a 20 72 all are not.** r
1cd80 65 66 6c 65 63 74 65 64 20 69 6e 20 73 75 62 73 eflected in subs
1cd90 65 71 75 65 6e 74 20 63 61 6c 6c 73 20 74 6f 20 equent calls to
1cda0 5b 73 71 6c 69 74 65 33 5f 65 72 72 63 6f 64 65 [sqlite3_errcode
1cdb0 28 29 5d 20 6f 72 0a 2a 2a 20 5b 73 71 6c 69 74 ()] or.** [sqlit
1cdc0 65 33 5f 65 72 72 6d 73 67 28 29 5d 2e 0a 2a 2f e3_errmsg()]..*/
1cdd0 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f 67 65 74 .int sqlite3_get
1cde0 5f 74 61 62 6c 65 28 0a 20 20 73 71 6c 69 74 65 _table(. sqlite
1cdf0 33 20 2a 64 62 2c 20 20 20 20 20 20 20 20 20 20 3 *db,
1ce00 2f 2a 20 41 6e 20 6f 70 65 6e 20 64 61 74 61 62 /* An open datab
1ce10 61 73 65 20 2a 2f 0a 20 20 63 6f 6e 73 74 20 63 ase */. const c
1ce20 68 61 72 20 2a 7a 53 71 6c 2c 20 20 20 20 20 2f har *zSql, /
1ce30 2a 20 53 51 4c 20 74 6f 20 62 65 20 65 76 61 6c * SQL to be eval
1ce40 75 61 74 65 64 20 2a 2f 0a 20 20 63 68 61 72 20 uated */. char
1ce50 2a 2a 2a 70 61 7a 52 65 73 75 6c 74 2c 20 20 20 ***pazResult,
1ce60 20 2f 2a 20 52 65 73 75 6c 74 73 20 6f 66 20 74 /* Results of t
1ce70 68 65 20 71 75 65 72 79 20 2a 2f 0a 20 20 69 6e he query */. in
1ce80 74 20 2a 70 6e 52 6f 77 2c 20 20 20 20 20 20 20 t *pnRow,
1ce90 20 20 20 20 2f 2a 20 4e 75 6d 62 65 72 20 6f 66 /* Number of
1cea0 20 72 65 73 75 6c 74 20 72 6f 77 73 20 77 72 69 result rows wri
1ceb0 74 74 65 6e 20 68 65 72 65 20 2a 2f 0a 20 20 69 tten here */. i
1cec0 6e 74 20 2a 70 6e 43 6f 6c 75 6d 6e 2c 20 20 20 nt *pnColumn,
1ced0 20 20 20 20 20 2f 2a 20 4e 75 6d 62 65 72 20 6f /* Number o
1cee0 66 20 72 65 73 75 6c 74 20 63 6f 6c 75 6d 6e 73 f result columns
1cef0 20 77 72 69 74 74 65 6e 20 68 65 72 65 20 2a 2f written here */
1cf00 0a 20 20 63 68 61 72 20 2a 2a 70 7a 45 72 72 6d . char **pzErrm
1cf10 73 67 20 20 20 20 20 20 20 2f 2a 20 45 72 72 6f sg /* Erro
1cf20 72 20 6d 73 67 20 77 72 69 74 74 65 6e 20 68 65 r msg written he
1cf30 72 65 20 2a 2f 0a 29 3b 0a 76 6f 69 64 20 73 71 re */.);.void sq
1cf40 6c 69 74 65 33 5f 66 72 65 65 5f 74 61 62 6c 65 lite3_free_table
1cf50 28 63 68 61 72 20 2a 2a 72 65 73 75 6c 74 29 3b (char **result);
1cf60 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 ../*.** CAPI3REF
1cf70 3a 20 46 6f 72 6d 61 74 74 65 64 20 53 74 72 69 : Formatted Stri
1cf80 6e 67 20 50 72 69 6e 74 69 6e 67 20 46 75 6e 63 ng Printing Func
1cf90 74 69 6f 6e 73 0a 2a 2a 0a 2a 2a 20 54 68 65 73 tions.**.** Thes
1cfa0 65 20 72 6f 75 74 69 6e 65 73 20 61 72 65 20 77 e routines are w
1cfb0 6f 72 6b 2d 61 6c 69 6b 65 73 20 6f 66 20 74 68 ork-alikes of th
1cfc0 65 20 22 70 72 69 6e 74 66 28 29 22 20 66 61 6d e "printf()" fam
1cfd0 69 6c 79 20 6f 66 20 66 75 6e 63 74 69 6f 6e 73 ily of functions
1cfe0 0a 2a 2a 20 66 72 6f 6d 20 74 68 65 20 73 74 61 .** from the sta
1cff0 6e 64 61 72 64 20 43 20 6c 69 62 72 61 72 79 2e ndard C library.
1d000 0a 2a 2a 20 54 68 65 73 65 20 72 6f 75 74 69 6e .** These routin
1d010 65 73 20 75 6e 64 65 72 73 74 61 6e 64 20 6d 6f es understand mo
1d020 73 74 20 6f 66 20 74 68 65 20 63 6f 6d 6d 6f 6e st of the common
1d030 20 4b 26 52 20 66 6f 72 6d 61 74 74 69 6e 67 20 K&R formatting
1d040 6f 70 74 69 6f 6e 73 2c 0a 2a 2a 20 70 6c 75 73 options,.** plus
1d050 20 73 6f 6d 65 20 61 64 64 69 74 69 6f 6e 61 6c some additional
1d060 20 6e 6f 6e 2d 73 74 61 6e 64 61 72 64 20 66 6f non-standard fo
1d070 72 6d 61 74 73 2c 20 64 65 74 61 69 6c 65 64 20 rmats, detailed
1d080 62 65 6c 6f 77 2e 0a 2a 2a 20 4e 6f 74 65 20 74 below..** Note t
1d090 68 61 74 20 73 6f 6d 65 20 6f 66 20 74 68 65 20 hat some of the
1d0a0 6d 6f 72 65 20 6f 62 73 63 75 72 65 20 66 6f 72 more obscure for
1d0b0 6d 61 74 74 69 6e 67 20 6f 70 74 69 6f 6e 73 20 matting options
1d0c0 66 72 6f 6d 20 72 65 63 65 6e 74 0a 2a 2a 20 43 from recent.** C
1d0d0 2d 6c 69 62 72 61 72 79 20 73 74 61 6e 64 61 72 -library standar
1d0e0 64 73 20 61 72 65 20 6f 6d 69 74 74 65 64 20 66 ds are omitted f
1d0f0 72 6f 6d 20 74 68 69 73 20 69 6d 70 6c 65 6d 65 rom this impleme
1d100 6e 74 61 74 69 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 5e ntation..**.** ^
1d110 54 68 65 20 73 71 6c 69 74 65 33 5f 6d 70 72 69 The sqlite3_mpri
1d120 6e 74 66 28 29 20 61 6e 64 20 73 71 6c 69 74 65 ntf() and sqlite
1d130 33 5f 76 6d 70 72 69 6e 74 66 28 29 20 72 6f 75 3_vmprintf() rou
1d140 74 69 6e 65 73 20 77 72 69 74 65 20 74 68 65 69 tines write thei
1d150 72 0a 2a 2a 20 72 65 73 75 6c 74 73 20 69 6e 74 r.** results int
1d160 6f 20 6d 65 6d 6f 72 79 20 6f 62 74 61 69 6e 65 o memory obtaine
1d170 64 20 66 72 6f 6d 20 5b 73 71 6c 69 74 65 33 5f d from [sqlite3_
1d180 6d 61 6c 6c 6f 63 28 29 5d 2e 0a 2a 2a 20 54 68 malloc()]..** Th
1d190 65 20 73 74 72 69 6e 67 73 20 72 65 74 75 72 6e e strings return
1d1a0 65 64 20 62 79 20 74 68 65 73 65 20 74 77 6f 20 ed by these two
1d1b0 72 6f 75 74 69 6e 65 73 20 73 68 6f 75 6c 64 20 routines should
1d1c0 62 65 0a 2a 2a 20 72 65 6c 65 61 73 65 64 20 62 be.** released b
1d1d0 79 20 5b 73 71 6c 69 74 65 33 5f 66 72 65 65 28 y [sqlite3_free(
1d1e0 29 5d 2e 20 20 5e 42 6f 74 68 20 72 6f 75 74 69 )]. ^Both routi
1d1f0 6e 65 73 20 72 65 74 75 72 6e 20 61 0a 2a 2a 20 nes return a.**
1d200 4e 55 4c 4c 20 70 6f 69 6e 74 65 72 20 69 66 20 NULL pointer if
1d210 5b 73 71 6c 69 74 65 33 5f 6d 61 6c 6c 6f 63 28 [sqlite3_malloc(
1d220 29 5d 20 69 73 20 75 6e 61 62 6c 65 20 74 6f 20 )] is unable to
1d230 61 6c 6c 6f 63 61 74 65 20 65 6e 6f 75 67 68 0a allocate enough.
1d240 2a 2a 20 6d 65 6d 6f 72 79 20 74 6f 20 68 6f 6c ** memory to hol
1d250 64 20 74 68 65 20 72 65 73 75 6c 74 69 6e 67 20 d the resulting
1d260 73 74 72 69 6e 67 2e 0a 2a 2a 0a 2a 2a 20 5e 28 string..**.** ^(
1d270 54 68 65 20 73 71 6c 69 74 65 33 5f 73 6e 70 72 The sqlite3_snpr
1d280 69 6e 74 66 28 29 20 72 6f 75 74 69 6e 65 20 69 intf() routine i
1d290 73 20 73 69 6d 69 6c 61 72 20 74 6f 20 22 73 6e s similar to "sn
1d2a0 70 72 69 6e 74 66 28 29 22 20 66 72 6f 6d 0a 2a printf()" from.*
1d2b0 2a 20 74 68 65 20 73 74 61 6e 64 61 72 64 20 43 * the standard C
1d2c0 20 6c 69 62 72 61 72 79 2e 20 20 54 68 65 20 72 library. The r
1d2d0 65 73 75 6c 74 20 69 73 20 77 72 69 74 74 65 6e esult is written
1d2e0 20 69 6e 74 6f 20 74 68 65 0a 2a 2a 20 62 75 66 into the.** buf
1d2f0 66 65 72 20 73 75 70 70 6c 69 65 64 20 61 73 20 fer supplied as
1d300 74 68 65 20 73 65 63 6f 6e 64 20 70 61 72 61 6d the second param
1d310 65 74 65 72 20 77 68 6f 73 65 20 73 69 7a 65 20 eter whose size
1d320 69 73 20 67 69 76 65 6e 20 62 79 0a 2a 2a 20 74 is given by.** t
1d330 68 65 20 66 69 72 73 74 20 70 61 72 61 6d 65 74 he first paramet
1d340 65 72 2e 20 4e 6f 74 65 20 74 68 61 74 20 74 68 er. Note that th
1d350 65 20 6f 72 64 65 72 20 6f 66 20 74 68 65 0a 2a e order of the.*
1d360 2a 20 66 69 72 73 74 20 74 77 6f 20 70 61 72 61 * first two para
1d370 6d 65 74 65 72 73 20 69 73 20 72 65 76 65 72 73 meters is revers
1d380 65 64 20 66 72 6f 6d 20 73 6e 70 72 69 6e 74 66 ed from snprintf
1d390 28 29 2e 29 5e 20 20 54 68 69 73 20 69 73 20 61 ().)^ This is a
1d3a0 6e 0a 2a 2a 20 68 69 73 74 6f 72 69 63 61 6c 20 n.** historical
1d3b0 61 63 63 69 64 65 6e 74 20 74 68 61 74 20 63 61 accident that ca
1d3c0 6e 6e 6f 74 20 62 65 20 66 69 78 65 64 20 77 69 nnot be fixed wi
1d3d0 74 68 6f 75 74 20 62 72 65 61 6b 69 6e 67 0a 2a thout breaking.*
1d3e0 2a 20 62 61 63 6b 77 61 72 64 73 20 63 6f 6d 70 * backwards comp
1d3f0 61 74 69 62 69 6c 69 74 79 2e 20 20 5e 28 4e 6f atibility. ^(No
1d400 74 65 20 61 6c 73 6f 20 74 68 61 74 20 73 71 6c te also that sql
1d410 69 74 65 33 5f 73 6e 70 72 69 6e 74 66 28 29 0a ite3_snprintf().
1d420 2a 2a 20 72 65 74 75 72 6e 73 20 61 20 70 6f 69 ** returns a poi
1d430 6e 74 65 72 20 74 6f 20 69 74 73 20 62 75 66 66 nter to its buff
1d440 65 72 20 69 6e 73 74 65 61 64 20 6f 66 20 74 68 er instead of th
1d450 65 20 6e 75 6d 62 65 72 20 6f 66 0a 2a 2a 20 63 e number of.** c
1d460 68 61 72 61 63 74 65 72 73 20 61 63 74 75 61 6c haracters actual
1d470 6c 79 20 77 72 69 74 74 65 6e 20 69 6e 74 6f 20 ly written into
1d480 74 68 65 20 62 75 66 66 65 72 2e 29 5e 20 20 57 the buffer.)^ W
1d490 65 20 61 64 6d 69 74 20 74 68 61 74 0a 2a 2a 20 e admit that.**
1d4a0 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 63 68 the number of ch
1d4b0 61 72 61 63 74 65 72 73 20 77 72 69 74 74 65 6e aracters written
1d4c0 20 77 6f 75 6c 64 20 62 65 20 61 20 6d 6f 72 65 would be a more
1d4d0 20 75 73 65 66 75 6c 20 72 65 74 75 72 6e 0a 2a useful return.*
1d4e0 2a 20 76 61 6c 75 65 20 62 75 74 20 77 65 20 63 * value but we c
1d4f0 61 6e 6e 6f 74 20 63 68 61 6e 67 65 20 74 68 65 annot change the
1d500 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 implementation
1d510 6f 66 20 73 71 6c 69 74 65 33 5f 73 6e 70 72 69 of sqlite3_snpri
1d520 6e 74 66 28 29 0a 2a 2a 20 6e 6f 77 20 77 69 74 ntf().** now wit
1d530 68 6f 75 74 20 62 72 65 61 6b 69 6e 67 20 63 6f hout breaking co
1d540 6d 70 61 74 69 62 69 6c 69 74 79 2e 0a 2a 2a 0a mpatibility..**.
1d550 2a 2a 20 5e 41 73 20 6c 6f 6e 67 20 61 73 20 74 ** ^As long as t
1d560 68 65 20 62 75 66 66 65 72 20 73 69 7a 65 20 69 he buffer size i
1d570 73 20 67 72 65 61 74 65 72 20 74 68 61 6e 20 7a s greater than z
1d580 65 72 6f 2c 20 73 71 6c 69 74 65 33 5f 73 6e 70 ero, sqlite3_snp
1d590 72 69 6e 74 66 28 29 0a 2a 2a 20 67 75 61 72 61 rintf().** guara
1d5a0 6e 74 65 65 73 20 74 68 61 74 20 74 68 65 20 62 ntees that the b
1d5b0 75 66 66 65 72 20 69 73 20 61 6c 77 61 79 73 20 uffer is always
1d5c0 7a 65 72 6f 2d 74 65 72 6d 69 6e 61 74 65 64 2e zero-terminated.
1d5d0 20 20 5e 54 68 65 20 66 69 72 73 74 0a 2a 2a 20 ^The first.**
1d5e0 70 61 72 61 6d 65 74 65 72 20 22 6e 22 20 69 73 parameter "n" is
1d5f0 20 74 68 65 20 74 6f 74 61 6c 20 73 69 7a 65 20 the total size
1d600 6f 66 20 74 68 65 20 62 75 66 66 65 72 2c 20 69 of the buffer, i
1d610 6e 63 6c 75 64 69 6e 67 20 73 70 61 63 65 20 66 ncluding space f
1d620 6f 72 0a 2a 2a 20 74 68 65 20 7a 65 72 6f 20 74 or.** the zero t
1d630 65 72 6d 69 6e 61 74 6f 72 2e 20 20 53 6f 20 74 erminator. So t
1d640 68 65 20 6c 6f 6e 67 65 73 74 20 73 74 72 69 6e he longest strin
1d650 67 20 74 68 61 74 20 63 61 6e 20 62 65 20 63 6f g that can be co
1d660 6d 70 6c 65 74 65 6c 79 0a 2a 2a 20 77 72 69 74 mpletely.** writ
1d670 74 65 6e 20 77 69 6c 6c 20 62 65 20 6e 2d 31 20 ten will be n-1
1d680 63 68 61 72 61 63 74 65 72 73 2e 0a 2a 2a 0a 2a characters..**.*
1d690 2a 20 5e 54 68 65 20 73 71 6c 69 74 65 33 5f 76 * ^The sqlite3_v
1d6a0 73 6e 70 72 69 6e 74 66 28 29 20 72 6f 75 74 69 snprintf() routi
1d6b0 6e 65 20 69 73 20 61 20 76 61 72 61 72 67 73 20 ne is a varargs
1d6c0 76 65 72 73 69 6f 6e 20 6f 66 20 73 71 6c 69 74 version of sqlit
1d6d0 65 33 5f 73 6e 70 72 69 6e 74 66 28 29 2e 0a 2a e3_snprintf()..*
1d6e0 2a 0a 2a 2a 20 54 68 65 73 65 20 72 6f 75 74 69 *.** These routi
1d6f0 6e 65 73 20 61 6c 6c 20 69 6d 70 6c 65 6d 65 6e nes all implemen
1d700 74 20 73 6f 6d 65 20 61 64 64 69 74 69 6f 6e 61 t some additiona
1d710 6c 20 66 6f 72 6d 61 74 74 69 6e 67 0a 2a 2a 20 l formatting.**
1d720 6f 70 74 69 6f 6e 73 20 74 68 61 74 20 61 72 65 options that are
1d730 20 75 73 65 66 75 6c 20 66 6f 72 20 63 6f 6e 73 useful for cons
1d740 74 72 75 63 74 69 6e 67 20 53 51 4c 20 73 74 61 tructing SQL sta
1d750 74 65 6d 65 6e 74 73 2e 0a 2a 2a 20 41 6c 6c 20 tements..** All
1d760 6f 66 20 74 68 65 20 75 73 75 61 6c 20 70 72 69 of the usual pri
1d770 6e 74 66 28 29 20 66 6f 72 6d 61 74 74 69 6e 67 ntf() formatting
1d780 20 6f 70 74 69 6f 6e 73 20 61 70 70 6c 79 2e 20 options apply.
1d790 20 49 6e 20 61 64 64 69 74 69 6f 6e 2c 20 74 68 In addition, th
1d7a0 65 72 65 0a 2a 2a 20 69 73 20 61 72 65 20 22 25 ere.** is are "%
1d7b0 71 22 2c 20 22 25 51 22 2c 20 22 25 77 22 20 61 q", "%Q", "%w" a
1d7c0 6e 64 20 22 25 7a 22 20 6f 70 74 69 6f 6e 73 2e nd "%z" options.
1d7d0 0a 2a 2a 0a 2a 2a 20 5e 28 54 68 65 20 25 71 20 .**.** ^(The %q
1d7e0 6f 70 74 69 6f 6e 20 77 6f 72 6b 73 20 6c 69 6b option works lik
1d7f0 65 20 25 73 20 69 6e 20 74 68 61 74 20 69 74 20 e %s in that it
1d800 73 75 62 73 74 69 74 75 74 65 73 20 61 20 6e 75 substitutes a nu
1d810 6c 2d 74 65 72 6d 69 6e 61 74 65 64 0a 2a 2a 20 l-terminated.**
1d820 73 74 72 69 6e 67 20 66 72 6f 6d 20 74 68 65 20 string from the
1d830 61 72 67 75 6d 65 6e 74 20 6c 69 73 74 2e 20 20 argument list.
1d840 42 75 74 20 25 71 20 61 6c 73 6f 20 64 6f 75 62 But %q also doub
1d850 6c 65 73 20 65 76 65 72 79 20 27 5c 27 27 20 63 les every '\'' c
1d860 68 61 72 61 63 74 65 72 2e 0a 2a 2a 20 25 71 20 haracter..** %q
1d870 69 73 20 64 65 73 69 67 6e 65 64 20 66 6f 72 20 is designed for
1d880 75 73 65 20 69 6e 73 69 64 65 20 61 20 73 74 72 use inside a str
1d890 69 6e 67 20 6c 69 74 65 72 61 6c 2e 29 5e 20 20 ing literal.)^
1d8a0 42 79 20 64 6f 75 62 6c 69 6e 67 20 65 61 63 68 By doubling each
1d8b0 20 27 5c 27 27 0a 2a 2a 20 63 68 61 72 61 63 74 '\''.** charact
1d8c0 65 72 20 69 74 20 65 73 63 61 70 65 73 20 74 68 er it escapes th
1d8d0 61 74 20 63 68 61 72 61 63 74 65 72 20 61 6e 64 at character and
1d8e0 20 61 6c 6c 6f 77 73 20 69 74 20 74 6f 20 62 65 allows it to be
1d8f0 20 69 6e 73 65 72 74 65 64 20 69 6e 74 6f 0a 2a inserted into.*
1d900 2a 20 74 68 65 20 73 74 72 69 6e 67 2e 0a 2a 2a * the string..**
1d910 0a 2a 2a 20 46 6f 72 20 65 78 61 6d 70 6c 65 2c .** For example,
1d920 20 61 73 73 75 6d 65 20 74 68 65 20 73 74 72 69 assume the stri
1d930 6e 67 20 76 61 72 69 61 62 6c 65 20 7a 54 65 78 ng variable zTex
1d940 74 20 63 6f 6e 74 61 69 6e 73 20 74 65 78 74 20 t contains text
1d950 61 73 20 66 6f 6c 6c 6f 77 73 3a 0a 2a 2a 0a 2a as follows:.**.*
1d960 2a 20 3c 62 6c 6f 63 6b 71 75 6f 74 65 3e 3c 70 * <blockquote><p
1d970 72 65 3e 0a 2a 2a 20 20 63 68 61 72 20 2a 7a 54 re>.** char *zT
1d980 65 78 74 20 3d 20 22 49 74 27 73 20 61 20 68 61 ext = "It's a ha
1d990 70 70 79 20 64 61 79 21 22 3b 0a 2a 2a 20 3c 2f ppy day!";.** </
1d9a0 70 72 65 3e 3c 2f 62 6c 6f 63 6b 71 75 6f 74 65 pre></blockquote
1d9b0 3e 0a 2a 2a 0a 2a 2a 20 4f 6e 65 20 63 61 6e 20 >.**.** One can
1d9c0 75 73 65 20 74 68 69 73 20 74 65 78 74 20 69 6e use this text in
1d9d0 20 61 6e 20 53 51 4c 20 73 74 61 74 65 6d 65 6e an SQL statemen
1d9e0 74 20 61 73 20 66 6f 6c 6c 6f 77 73 3a 0a 2a 2a t as follows:.**
1d9f0 0a 2a 2a 20 3c 62 6c 6f 63 6b 71 75 6f 74 65 3e .** <blockquote>
1da00 3c 70 72 65 3e 0a 2a 2a 20 20 63 68 61 72 20 2a <pre>.** char *
1da10 7a 53 51 4c 20 3d 20 73 71 6c 69 74 65 33 5f 6d zSQL = sqlite3_m
1da20 70 72 69 6e 74 66 28 22 49 4e 53 45 52 54 20 49 printf("INSERT I
1da30 4e 54 4f 20 74 61 62 6c 65 20 56 41 4c 55 45 53 NTO table VALUES
1da40 28 27 25 71 27 29 22 2c 20 7a 54 65 78 74 29 3b ('%q')", zText);
1da50 0a 2a 2a 20 20 73 71 6c 69 74 65 33 5f 65 78 65 .** sqlite3_exe
1da60 63 28 64 62 2c 20 7a 53 51 4c 2c 20 30 2c 20 30 c(db, zSQL, 0, 0
1da70 2c 20 30 29 3b 0a 2a 2a 20 20 73 71 6c 69 74 65 , 0);.** sqlite
1da80 33 5f 66 72 65 65 28 7a 53 51 4c 29 3b 0a 2a 2a 3_free(zSQL);.**
1da90 20 3c 2f 70 72 65 3e 3c 2f 62 6c 6f 63 6b 71 75 </pre></blockqu
1daa0 6f 74 65 3e 0a 2a 2a 0a 2a 2a 20 42 65 63 61 75 ote>.**.** Becau
1dab0 73 65 20 74 68 65 20 25 71 20 66 6f 72 6d 61 74 se the %q format
1dac0 20 73 74 72 69 6e 67 20 69 73 20 75 73 65 64 2c string is used,
1dad0 20 74 68 65 20 27 5c 27 27 20 63 68 61 72 61 63 the '\'' charac
1dae0 74 65 72 20 69 6e 20 7a 54 65 78 74 0a 2a 2a 20 ter in zText.**
1daf0 69 73 20 65 73 63 61 70 65 64 20 61 6e 64 20 74 is escaped and t
1db00 68 65 20 53 51 4c 20 67 65 6e 65 72 61 74 65 64 he SQL generated
1db10 20 69 73 20 61 73 20 66 6f 6c 6c 6f 77 73 3a 0a is as follows:.
1db20 2a 2a 0a 2a 2a 20 3c 62 6c 6f 63 6b 71 75 6f 74 **.** <blockquot
1db30 65 3e 3c 70 72 65 3e 0a 2a 2a 20 20 49 4e 53 45 e><pre>.** INSE
1db40 52 54 20 49 4e 54 4f 20 74 61 62 6c 65 31 20 56 RT INTO table1 V
1db50 41 4c 55 45 53 28 27 49 74 27 27 73 20 61 20 68 ALUES('It''s a h
1db60 61 70 70 79 20 64 61 79 21 27 29 0a 2a 2a 20 3c appy day!').** <
1db70 2f 70 72 65 3e 3c 2f 62 6c 6f 63 6b 71 75 6f 74 /pre></blockquot
1db80 65 3e 0a 2a 2a 0a 2a 2a 20 54 68 69 73 20 69 73 e>.**.** This is
1db90 20 63 6f 72 72 65 63 74 2e 20 20 48 61 64 20 77 correct. Had w
1dba0 65 20 75 73 65 64 20 25 73 20 69 6e 73 74 65 61 e used %s instea
1dbb0 64 20 6f 66 20 25 71 2c 20 74 68 65 20 67 65 6e d of %q, the gen
1dbc0 65 72 61 74 65 64 20 53 51 4c 0a 2a 2a 20 77 6f erated SQL.** wo
1dbd0 75 6c 64 20 68 61 76 65 20 6c 6f 6f 6b 65 64 20 uld have looked
1dbe0 6c 69 6b 65 20 74 68 69 73 3a 0a 2a 2a 0a 2a 2a like this:.**.**
1dbf0 20 3c 62 6c 6f 63 6b 71 75 6f 74 65 3e 3c 70 72 <blockquote><pr
1dc00 65 3e 0a 2a 2a 20 20 49 4e 53 45 52 54 20 49 4e e>.** INSERT IN
1dc10 54 4f 20 74 61 62 6c 65 31 20 56 41 4c 55 45 53 TO table1 VALUES
1dc20 28 27 49 74 27 73 20 61 20 68 61 70 70 79 20 64 ('It's a happy d
1dc30 61 79 21 27 29 3b 0a 2a 2a 20 3c 2f 70 72 65 3e ay!');.** </pre>
1dc40 3c 2f 62 6c 6f 63 6b 71 75 6f 74 65 3e 0a 2a 2a </blockquote>.**
1dc50 0a 2a 2a 20 54 68 69 73 20 73 65 63 6f 6e 64 20 .** This second
1dc60 65 78 61 6d 70 6c 65 20 69 73 20 61 6e 20 53 51 example is an SQ
1dc70 4c 20 73 79 6e 74 61 78 20 65 72 72 6f 72 2e 20 L syntax error.
1dc80 20 41 73 20 61 20 67 65 6e 65 72 61 6c 20 72 75 As a general ru
1dc90 6c 65 20 79 6f 75 20 73 68 6f 75 6c 64 0a 2a 2a le you should.**
1dca0 20 61 6c 77 61 79 73 20 75 73 65 20 25 71 20 69 always use %q i
1dcb0 6e 73 74 65 61 64 20 6f 66 20 25 73 20 77 68 65 nstead of %s whe
1dcc0 6e 20 69 6e 73 65 72 74 69 6e 67 20 74 65 78 74 n inserting text
1dcd0 20 69 6e 74 6f 20 61 20 73 74 72 69 6e 67 20 6c into a string l
1dce0 69 74 65 72 61 6c 2e 0a 2a 2a 0a 2a 2a 20 5e 28 iteral..**.** ^(
1dcf0 54 68 65 20 25 51 20 6f 70 74 69 6f 6e 20 77 6f The %Q option wo
1dd00 72 6b 73 20 6c 69 6b 65 20 25 71 20 65 78 63 65 rks like %q exce
1dd10 70 74 20 69 74 20 61 6c 73 6f 20 61 64 64 73 20 pt it also adds
1dd20 73 69 6e 67 6c 65 20 71 75 6f 74 65 73 20 61 72 single quotes ar
1dd30 6f 75 6e 64 0a 2a 2a 20 74 68 65 20 6f 75 74 73 ound.** the outs
1dd40 69 64 65 20 6f 66 20 74 68 65 20 74 6f 74 61 6c ide of the total
1dd50 20 73 74 72 69 6e 67 2e 20 20 41 64 64 69 74 69 string. Additi
1dd60 6f 6e 61 6c 6c 79 2c 20 69 66 20 74 68 65 20 70 onally, if the p
1dd70 61 72 61 6d 65 74 65 72 20 69 6e 20 74 68 65 0a arameter in the.
1dd80 2a 2a 20 61 72 67 75 6d 65 6e 74 20 6c 69 73 74 ** argument list
1dd90 20 69 73 20 61 20 4e 55 4c 4c 20 70 6f 69 6e 74 is a NULL point
1dda0 65 72 2c 20 25 51 20 73 75 62 73 74 69 74 75 74 er, %Q substitut
1ddb0 65 73 20 74 68 65 20 74 65 78 74 20 22 4e 55 4c es the text "NUL
1ddc0 4c 22 20 28 77 69 74 68 6f 75 74 0a 2a 2a 20 73 L" (without.** s
1ddd0 69 6e 67 6c 65 20 71 75 6f 74 65 73 29 2e 29 5e ingle quotes).)^
1dde0 20 20 53 6f 2c 20 66 6f 72 20 65 78 61 6d 70 6c So, for exampl
1ddf0 65 2c 20 6f 6e 65 20 63 6f 75 6c 64 20 73 61 79 e, one could say
1de00 3a 0a 2a 2a 0a 2a 2a 20 3c 62 6c 6f 63 6b 71 75 :.**.** <blockqu
1de10 6f 74 65 3e 3c 70 72 65 3e 0a 2a 2a 20 20 63 68 ote><pre>.** ch
1de20 61 72 20 2a 7a 53 51 4c 20 3d 20 73 71 6c 69 74 ar *zSQL = sqlit
1de30 65 33 5f 6d 70 72 69 6e 74 66 28 22 49 4e 53 45 e3_mprintf("INSE
1de40 52 54 20 49 4e 54 4f 20 74 61 62 6c 65 20 56 41 RT INTO table VA
1de50 4c 55 45 53 28 25 51 29 22 2c 20 7a 54 65 78 74 LUES(%Q)", zText
1de60 29 3b 0a 2a 2a 20 20 73 71 6c 69 74 65 33 5f 65 );.** sqlite3_e
1de70 78 65 63 28 64 62 2c 20 7a 53 51 4c 2c 20 30 2c xec(db, zSQL, 0,
1de80 20 30 2c 20 30 29 3b 0a 2a 2a 20 20 73 71 6c 69 0, 0);.** sqli
1de90 74 65 33 5f 66 72 65 65 28 7a 53 51 4c 29 3b 0a te3_free(zSQL);.
1dea0 2a 2a 20 3c 2f 70 72 65 3e 3c 2f 62 6c 6f 63 6b ** </pre></block
1deb0 71 75 6f 74 65 3e 0a 2a 2a 0a 2a 2a 20 54 68 65 quote>.**.** The
1dec0 20 63 6f 64 65 20 61 62 6f 76 65 20 77 69 6c 6c code above will
1ded0 20 72 65 6e 64 65 72 20 61 20 63 6f 72 72 65 63 render a correc
1dee0 74 20 53 51 4c 20 73 74 61 74 65 6d 65 6e 74 20 t SQL statement
1def0 69 6e 20 74 68 65 20 7a 53 51 4c 0a 2a 2a 20 76 in the zSQL.** v
1df00 61 72 69 61 62 6c 65 20 65 76 65 6e 20 69 66 20 ariable even if
1df10 74 68 65 20 7a 54 65 78 74 20 76 61 72 69 61 62 the zText variab
1df20 6c 65 20 69 73 20 61 20 4e 55 4c 4c 20 70 6f 69 le is a NULL poi
1df30 6e 74 65 72 2e 0a 2a 2a 0a 2a 2a 20 5e 28 54 68 nter..**.** ^(Th
1df40 65 20 22 25 77 22 20 66 6f 72 6d 61 74 74 69 6e e "%w" formattin
1df50 67 20 6f 70 74 69 6f 6e 20 69 73 20 6c 69 6b 65 g option is like
1df60 20 22 25 71 22 20 65 78 63 65 70 74 20 74 68 61 "%q" except tha
1df70 74 20 69 74 20 65 78 70 65 63 74 73 20 74 6f 0a t it expects to.
1df80 2a 2a 20 62 65 20 63 6f 6e 74 61 69 6e 65 64 20 ** be contained
1df90 77 69 74 68 69 6e 20 64 6f 75 62 6c 65 2d 71 75 within double-qu
1dfa0 6f 74 65 73 20 69 6e 73 74 65 61 64 20 6f 66 20 otes instead of
1dfb0 73 69 6e 67 6c 65 20 71 75 6f 74 65 73 2c 20 61 single quotes, a
1dfc0 6e 64 20 69 74 0a 2a 2a 20 65 73 63 61 70 65 73 nd it.** escapes
1dfd0 20 74 68 65 20 64 6f 75 62 6c 65 2d 71 75 6f 74 the double-quot
1dfe0 65 20 63 68 61 72 61 63 74 65 72 20 69 6e 73 74 e character inst
1dff0 65 61 64 20 6f 66 20 74 68 65 20 73 69 6e 67 6c ead of the singl
1e000 65 2d 71 75 6f 74 65 0a 2a 2a 20 63 68 61 72 61 e-quote.** chara
1e010 63 74 65 72 2e 29 5e 20 20 54 68 65 20 22 25 77 cter.)^ The "%w
1e020 22 20 66 6f 72 6d 61 74 74 69 6e 67 20 6f 70 74 " formatting opt
1e030 69 6f 6e 20 69 73 20 69 6e 74 65 6e 64 65 64 20 ion is intended
1e040 66 6f 72 20 73 61 66 65 6c 79 20 69 6e 73 65 72 for safely inser
1e050 74 69 6e 67 0a 2a 2a 20 74 61 62 6c 65 20 61 6e ting.** table an
1e060 64 20 63 6f 6c 75 6d 6e 20 6e 61 6d 65 73 20 69 d column names i
1e070 6e 74 6f 20 61 20 63 6f 6e 73 74 72 75 63 74 65 nto a constructe
1e080 64 20 53 51 4c 20 73 74 61 74 65 6d 65 6e 74 2e d SQL statement.
1e090 0a 2a 2a 0a 2a 2a 20 5e 28 54 68 65 20 22 25 7a .**.** ^(The "%z
1e0a0 22 20 66 6f 72 6d 61 74 74 69 6e 67 20 6f 70 74 " formatting opt
1e0b0 69 6f 6e 20 77 6f 72 6b 73 20 6c 69 6b 65 20 22 ion works like "
1e0c0 25 73 22 20 62 75 74 20 77 69 74 68 20 74 68 65 %s" but with the
1e0d0 0a 2a 2a 20 61 64 64 69 74 69 6f 6e 20 74 68 61 .** addition tha
1e0e0 74 20 61 66 74 65 72 20 74 68 65 20 73 74 72 69 t after the stri
1e0f0 6e 67 20 68 61 73 20 62 65 65 6e 20 72 65 61 64 ng has been read
1e100 20 61 6e 64 20 63 6f 70 69 65 64 20 69 6e 74 6f and copied into
1e110 0a 2a 2a 20 74 68 65 20 72 65 73 75 6c 74 2c 20 .** the result,
1e120 5b 73 71 6c 69 74 65 33 5f 66 72 65 65 28 29 5d [sqlite3_free()]
1e130 20 69 73 20 63 61 6c 6c 65 64 20 6f 6e 20 74 68 is called on th
1e140 65 20 69 6e 70 75 74 20 73 74 72 69 6e 67 2e 29 e input string.)
1e150 5e 0a 2a 2f 0a 63 68 61 72 20 2a 73 71 6c 69 74 ^.*/.char *sqlit
1e160 65 33 5f 6d 70 72 69 6e 74 66 28 63 6f 6e 73 74 e3_mprintf(const
1e170 20 63 68 61 72 2a 2c 2e 2e 2e 29 3b 0a 63 68 61 char*,...);.cha
1e180 72 20 2a 73 71 6c 69 74 65 33 5f 76 6d 70 72 69 r *sqlite3_vmpri
1e190 6e 74 66 28 63 6f 6e 73 74 20 63 68 61 72 2a 2c ntf(const char*,
1e1a0 20 76 61 5f 6c 69 73 74 29 3b 0a 63 68 61 72 20 va_list);.char
1e1b0 2a 73 71 6c 69 74 65 33 5f 73 6e 70 72 69 6e 74 *sqlite3_snprint
1e1c0 66 28 69 6e 74 2c 63 68 61 72 2a 2c 63 6f 6e 73 f(int,char*,cons
1e1d0 74 20 63 68 61 72 2a 2c 20 2e 2e 2e 29 3b 0a 63 t char*, ...);.c
1e1e0 68 61 72 20 2a 73 71 6c 69 74 65 33 5f 76 73 6e har *sqlite3_vsn
1e1f0 70 72 69 6e 74 66 28 69 6e 74 2c 63 68 61 72 2a printf(int,char*
1e200 2c 63 6f 6e 73 74 20 63 68 61 72 2a 2c 20 76 61 ,const char*, va
1e210 5f 6c 69 73 74 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 _list);../*.** C
1e220 41 50 49 33 52 45 46 3a 20 4d 65 6d 6f 72 79 20 API3REF: Memory
1e230 41 6c 6c 6f 63 61 74 69 6f 6e 20 53 75 62 73 79 Allocation Subsy
1e240 73 74 65 6d 0a 2a 2a 0a 2a 2a 20 54 68 65 20 53 stem.**.** The S
1e250 51 4c 69 74 65 20 63 6f 72 65 20 75 73 65 73 20 QLite core uses
1e260 74 68 65 73 65 20 74 68 72 65 65 20 72 6f 75 74 these three rout
1e270 69 6e 65 73 20 66 6f 72 20 61 6c 6c 20 6f 66 20 ines for all of
1e280 69 74 73 20 6f 77 6e 0a 2a 2a 20 69 6e 74 65 72 its own.** inter
1e290 6e 61 6c 20 6d 65 6d 6f 72 79 20 61 6c 6c 6f 63 nal memory alloc
1e2a0 61 74 69 6f 6e 20 6e 65 65 64 73 2e 20 22 43 6f ation needs. "Co
1e2b0 72 65 22 20 69 6e 20 74 68 65 20 70 72 65 76 69 re" in the previ
1e2c0 6f 75 73 20 73 65 6e 74 65 6e 63 65 0a 2a 2a 20 ous sentence.**
1e2d0 64 6f 65 73 20 6e 6f 74 20 69 6e 63 6c 75 64 65 does not include
1e2e0 20 6f 70 65 72 61 74 69 6e 67 2d 73 79 73 74 65 operating-syste
1e2f0 6d 20 73 70 65 63 69 66 69 63 20 56 46 53 20 69 m specific VFS i
1e300 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 2e 20 20 mplementation.
1e310 54 68 65 0a 2a 2a 20 57 69 6e 64 6f 77 73 20 56 The.** Windows V
1e320 46 53 20 75 73 65 73 20 6e 61 74 69 76 65 20 6d FS uses native m
1e330 61 6c 6c 6f 63 28 29 20 61 6e 64 20 66 72 65 65 alloc() and free
1e340 28 29 20 66 6f 72 20 73 6f 6d 65 20 6f 70 65 72 () for some oper
1e350 61 74 69 6f 6e 73 2e 0a 2a 2a 0a 2a 2a 20 5e 54 ations..**.** ^T
1e360 68 65 20 73 71 6c 69 74 65 33 5f 6d 61 6c 6c 6f he sqlite3_mallo
1e370 63 28 29 20 72 6f 75 74 69 6e 65 20 72 65 74 75 c() routine retu
1e380 72 6e 73 20 61 20 70 6f 69 6e 74 65 72 20 74 6f rns a pointer to
1e390 20 61 20 62 6c 6f 63 6b 0a 2a 2a 20 6f 66 20 6d a block.** of m
1e3a0 65 6d 6f 72 79 20 61 74 20 6c 65 61 73 74 20 4e emory at least N
1e3b0 20 62 79 74 65 73 20 69 6e 20 6c 65 6e 67 74 68 bytes in length
1e3c0 2c 20 77 68 65 72 65 20 4e 20 69 73 20 74 68 65 , where N is the
1e3d0 20 70 61 72 61 6d 65 74 65 72 2e 0a 2a 2a 20 5e parameter..** ^
1e3e0 49 66 20 73 71 6c 69 74 65 33 5f 6d 61 6c 6c 6f If sqlite3_mallo
1e3f0 63 28 29 20 69 73 20 75 6e 61 62 6c 65 20 74 6f c() is unable to
1e400 20 6f 62 74 61 69 6e 20 73 75 66 66 69 63 69 65 obtain sufficie
1e410 6e 74 20 66 72 65 65 0a 2a 2a 20 6d 65 6d 6f 72 nt free.** memor
1e420 79 2c 20 69 74 20 72 65 74 75 72 6e 73 20 61 20 y, it returns a
1e430 4e 55 4c 4c 20 70 6f 69 6e 74 65 72 2e 20 20 5e NULL pointer. ^
1e440 49 66 20 74 68 65 20 70 61 72 61 6d 65 74 65 72 If the parameter
1e450 20 4e 20 74 6f 0a 2a 2a 20 73 71 6c 69 74 65 33 N to.** sqlite3
1e460 5f 6d 61 6c 6c 6f 63 28 29 20 69 73 20 7a 65 72 _malloc() is zer
1e470 6f 20 6f 72 20 6e 65 67 61 74 69 76 65 20 74 68 o or negative th
1e480 65 6e 20 73 71 6c 69 74 65 33 5f 6d 61 6c 6c 6f en sqlite3_mallo
1e490 63 28 29 20 72 65 74 75 72 6e 73 0a 2a 2a 20 61 c() returns.** a
1e4a0 20 4e 55 4c 4c 20 70 6f 69 6e 74 65 72 2e 0a 2a NULL pointer..*
1e4b0 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 6c 69 74 65 *.** ^The sqlite
1e4c0 33 5f 6d 61 6c 6c 6f 63 36 34 28 4e 29 20 72 6f 3_malloc64(N) ro
1e4d0 75 74 69 6e 65 20 77 6f 72 6b 73 20 6a 75 73 74 utine works just
1e4e0 20 6c 69 6b 65 0a 2a 2a 20 73 71 6c 69 74 65 33 like.** sqlite3
1e4f0 5f 6d 61 6c 6c 6f 63 28 4e 29 20 65 78 63 65 70 _malloc(N) excep
1e500 74 20 74 68 61 74 20 4e 20 69 73 20 61 6e 20 75 t that N is an u
1e510 6e 73 69 67 6e 65 64 20 36 34 2d 62 69 74 20 69 nsigned 64-bit i
1e520 6e 74 65 67 65 72 20 69 6e 73 74 65 61 64 0a 2a nteger instead.*
1e530 2a 20 6f 66 20 61 20 73 69 67 6e 65 64 20 33 32 * of a signed 32
1e540 2d 62 69 74 20 69 6e 74 65 67 65 72 2e 0a 2a 2a -bit integer..**
1e550 0a 2a 2a 20 5e 43 61 6c 6c 69 6e 67 20 73 71 6c .** ^Calling sql
1e560 69 74 65 33 5f 66 72 65 65 28 29 20 77 69 74 68 ite3_free() with
1e570 20 61 20 70 6f 69 6e 74 65 72 20 70 72 65 76 69 a pointer previ
1e580 6f 75 73 6c 79 20 72 65 74 75 72 6e 65 64 0a 2a ously returned.*
1e590 2a 20 62 79 20 73 71 6c 69 74 65 33 5f 6d 61 6c * by sqlite3_mal
1e5a0 6c 6f 63 28 29 20 6f 72 20 73 71 6c 69 74 65 33 loc() or sqlite3
1e5b0 5f 72 65 61 6c 6c 6f 63 28 29 20 72 65 6c 65 61 _realloc() relea
1e5c0 73 65 73 20 74 68 61 74 20 6d 65 6d 6f 72 79 20 ses that memory
1e5d0 73 6f 0a 2a 2a 20 74 68 61 74 20 69 74 20 6d 69 so.** that it mi
1e5e0 67 68 74 20 62 65 20 72 65 75 73 65 64 2e 20 20 ght be reused.
1e5f0 5e 54 68 65 20 73 71 6c 69 74 65 33 5f 66 72 65 ^The sqlite3_fre
1e600 65 28 29 20 72 6f 75 74 69 6e 65 20 69 73 0a 2a e() routine is.*
1e610 2a 20 61 20 6e 6f 2d 6f 70 20 69 66 20 69 73 20 * a no-op if is
1e620 63 61 6c 6c 65 64 20 77 69 74 68 20 61 20 4e 55 called with a NU
1e630 4c 4c 20 70 6f 69 6e 74 65 72 2e 20 20 50 61 73 LL pointer. Pas
1e640 73 69 6e 67 20 61 20 4e 55 4c 4c 20 70 6f 69 6e sing a NULL poin
1e650 74 65 72 0a 2a 2a 20 74 6f 20 73 71 6c 69 74 65 ter.** to sqlite
1e660 33 5f 66 72 65 65 28 29 20 69 73 20 68 61 72 6d 3_free() is harm
1e670 6c 65 73 73 2e 20 20 41 66 74 65 72 20 62 65 69 less. After bei
1e680 6e 67 20 66 72 65 65 64 2c 20 6d 65 6d 6f 72 79 ng freed, memory
1e690 0a 2a 2a 20 73 68 6f 75 6c 64 20 6e 65 69 74 68 .** should neith
1e6a0 65 72 20 62 65 20 72 65 61 64 20 6e 6f 72 20 77 er be read nor w
1e6b0 72 69 74 74 65 6e 2e 20 20 45 76 65 6e 20 72 65 ritten. Even re
1e6c0 61 64 69 6e 67 20 70 72 65 76 69 6f 75 73 6c 79 ading previously
1e6d0 20 66 72 65 65 64 0a 2a 2a 20 6d 65 6d 6f 72 79 freed.** memory
1e6e0 20 6d 69 67 68 74 20 72 65 73 75 6c 74 20 69 6e might result in
1e6f0 20 61 20 73 65 67 6d 65 6e 74 61 74 69 6f 6e 20 a segmentation
1e700 66 61 75 6c 74 20 6f 72 20 6f 74 68 65 72 20 73 fault or other s
1e710 65 76 65 72 65 20 65 72 72 6f 72 2e 0a 2a 2a 20 evere error..**
1e720 4d 65 6d 6f 72 79 20 63 6f 72 72 75 70 74 69 6f Memory corruptio
1e730 6e 2c 20 61 20 73 65 67 6d 65 6e 74 61 74 69 6f n, a segmentatio
1e740 6e 20 66 61 75 6c 74 2c 20 6f 72 20 6f 74 68 65 n fault, or othe
1e750 72 20 73 65 76 65 72 65 20 65 72 72 6f 72 0a 2a r severe error.*
1e760 2a 20 6d 69 67 68 74 20 72 65 73 75 6c 74 20 69 * might result i
1e770 66 20 73 71 6c 69 74 65 33 5f 66 72 65 65 28 29 f sqlite3_free()
1e780 20 69 73 20 63 61 6c 6c 65 64 20 77 69 74 68 20 is called with
1e790 61 20 6e 6f 6e 2d 4e 55 4c 4c 20 70 6f 69 6e 74 a non-NULL point
1e7a0 65 72 20 74 68 61 74 0a 2a 2a 20 77 61 73 20 6e er that.** was n
1e7b0 6f 74 20 6f 62 74 61 69 6e 65 64 20 66 72 6f 6d ot obtained from
1e7c0 20 73 71 6c 69 74 65 33 5f 6d 61 6c 6c 6f 63 28 sqlite3_malloc(
1e7d0 29 20 6f 72 20 73 71 6c 69 74 65 33 5f 72 65 61 ) or sqlite3_rea
1e7e0 6c 6c 6f 63 28 29 2e 0a 2a 2a 0a 2a 2a 20 5e 54 lloc()..**.** ^T
1e7f0 68 65 20 73 71 6c 69 74 65 33 5f 72 65 61 6c 6c he sqlite3_reall
1e800 6f 63 28 58 2c 4e 29 20 69 6e 74 65 72 66 61 63 oc(X,N) interfac
1e810 65 20 61 74 74 65 6d 70 74 73 20 74 6f 20 72 65 e attempts to re
1e820 73 69 7a 65 20 61 0a 2a 2a 20 70 72 69 6f 72 20 size a.** prior
1e830 6d 65 6d 6f 72 79 20 61 6c 6c 6f 63 61 74 69 6f memory allocatio
1e840 6e 20 58 20 74 6f 20 62 65 20 61 74 20 6c 65 61 n X to be at lea
1e850 73 74 20 4e 20 62 79 74 65 73 2e 0a 2a 2a 20 5e st N bytes..** ^
1e860 49 66 20 74 68 65 20 58 20 70 61 72 61 6d 65 74 If the X paramet
1e870 65 72 20 74 6f 20 73 71 6c 69 74 65 33 5f 72 65 er to sqlite3_re
1e880 61 6c 6c 6f 63 28 58 2c 4e 29 0a 2a 2a 20 69 73 alloc(X,N).** is
1e890 20 61 20 4e 55 4c 4c 20 70 6f 69 6e 74 65 72 20 a NULL pointer
1e8a0 74 68 65 6e 20 69 74 73 20 62 65 68 61 76 69 6f then its behavio
1e8b0 72 20 69 73 20 69 64 65 6e 74 69 63 61 6c 20 74 r is identical t
1e8c0 6f 20 63 61 6c 6c 69 6e 67 0a 2a 2a 20 73 71 6c o calling.** sql
1e8d0 69 74 65 33 5f 6d 61 6c 6c 6f 63 28 4e 29 2e 0a ite3_malloc(N)..
1e8e0 2a 2a 20 5e 49 66 20 74 68 65 20 4e 20 70 61 72 ** ^If the N par
1e8f0 61 6d 65 74 65 72 20 74 6f 20 73 71 6c 69 74 65 ameter to sqlite
1e900 33 5f 72 65 61 6c 6c 6f 63 28 58 2c 4e 29 20 69 3_realloc(X,N) i
1e910 73 20 7a 65 72 6f 20 6f 72 0a 2a 2a 20 6e 65 67 s zero or.** neg
1e920 61 74 69 76 65 20 74 68 65 6e 20 74 68 65 20 62 ative then the b
1e930 65 68 61 76 69 6f 72 20 69 73 20 65 78 61 63 74 ehavior is exact
1e940 6c 79 20 74 68 65 20 73 61 6d 65 20 61 73 20 63 ly the same as c
1e950 61 6c 6c 69 6e 67 0a 2a 2a 20 73 71 6c 69 74 65 alling.** sqlite
1e960 33 5f 66 72 65 65 28 58 29 2e 0a 2a 2a 20 5e 73 3_free(X)..** ^s
1e970 71 6c 69 74 65 33 5f 72 65 61 6c 6c 6f 63 28 58 qlite3_realloc(X
1e980 2c 4e 29 20 72 65 74 75 72 6e 73 20 61 20 70 6f ,N) returns a po
1e990 69 6e 74 65 72 20 74 6f 20 61 20 6d 65 6d 6f 72 inter to a memor
1e9a0 79 20 61 6c 6c 6f 63 61 74 69 6f 6e 0a 2a 2a 20 y allocation.**
1e9b0 6f 66 20 61 74 20 6c 65 61 73 74 20 4e 20 62 79 of at least N by
1e9c0 74 65 73 20 69 6e 20 73 69 7a 65 20 6f 72 20 4e tes in size or N
1e9d0 55 4c 4c 20 69 66 20 69 6e 73 75 66 66 69 63 69 ULL if insuffici
1e9e0 65 6e 74 20 6d 65 6d 6f 72 79 20 69 73 20 61 76 ent memory is av
1e9f0 61 69 6c 61 62 6c 65 2e 0a 2a 2a 20 5e 49 66 20 ailable..** ^If
1ea00 4d 20 69 73 20 74 68 65 20 73 69 7a 65 20 6f 66 M is the size of
1ea10 20 74 68 65 20 70 72 69 6f 72 20 61 6c 6c 6f 63 the prior alloc
1ea20 61 74 69 6f 6e 2c 20 74 68 65 6e 20 6d 69 6e 28 ation, then min(
1ea30 4e 2c 4d 29 20 62 79 74 65 73 0a 2a 2a 20 6f 66 N,M) bytes.** of
1ea40 20 74 68 65 20 70 72 69 6f 72 20 61 6c 6c 6f 63 the prior alloc
1ea50 61 74 69 6f 6e 20 61 72 65 20 63 6f 70 69 65 64 ation are copied
1ea60 20 69 6e 74 6f 20 74 68 65 20 62 65 67 69 6e 6e into the beginn
1ea70 69 6e 67 20 6f 66 20 62 75 66 66 65 72 20 72 65 ing of buffer re
1ea80 74 75 72 6e 65 64 0a 2a 2a 20 62 79 20 73 71 6c turned.** by sql
1ea90 69 74 65 33 5f 72 65 61 6c 6c 6f 63 28 58 2c 4e ite3_realloc(X,N
1eaa0 29 20 61 6e 64 20 74 68 65 20 70 72 69 6f 72 20 ) and the prior
1eab0 61 6c 6c 6f 63 61 74 69 6f 6e 20 69 73 20 66 72 allocation is fr
1eac0 65 65 64 2e 0a 2a 2a 20 5e 49 66 20 73 71 6c 69 eed..** ^If sqli
1ead0 74 65 33 5f 72 65 61 6c 6c 6f 63 28 58 2c 4e 29 te3_realloc(X,N)
1eae0 20 72 65 74 75 72 6e 73 20 4e 55 4c 4c 20 61 6e returns NULL an
1eaf0 64 20 4e 20 69 73 20 70 6f 73 69 74 69 76 65 2c d N is positive,
1eb00 20 74 68 65 6e 20 74 68 65 0a 2a 2a 20 70 72 69 then the.** pri
1eb10 6f 72 20 61 6c 6c 6f 63 61 74 69 6f 6e 20 69 73 or allocation is
1eb20 20 6e 6f 74 20 66 72 65 65 64 2e 0a 2a 2a 0a 2a not freed..**.*
1eb30 2a 20 5e 54 68 65 20 73 71 6c 69 74 65 33 5f 72 * ^The sqlite3_r
1eb40 65 61 6c 6c 6f 63 36 34 28 58 2c 4e 29 20 69 6e ealloc64(X,N) in
1eb50 74 65 72 66 61 63 65 73 20 77 6f 72 6b 73 20 74 terfaces works t
1eb60 68 65 20 73 61 6d 65 20 61 73 0a 2a 2a 20 73 71 he same as.** sq
1eb70 6c 69 74 65 33 5f 72 65 61 6c 6c 6f 63 28 58 2c lite3_realloc(X,
1eb80 4e 29 20 65 78 63 65 70 74 20 74 68 61 74 20 4e N) except that N
1eb90 20 69 73 20 61 20 36 34 2d 62 69 74 20 75 6e 73 is a 64-bit uns
1eba0 69 67 6e 65 64 20 69 6e 74 65 67 65 72 20 69 6e igned integer in
1ebb0 73 74 65 61 64 0a 2a 2a 20 6f 66 20 61 20 33 32 stead.** of a 32
1ebc0 2d 62 69 74 20 73 69 67 6e 65 64 20 69 6e 74 65 -bit signed inte
1ebd0 67 65 72 2e 0a 2a 2a 0a 2a 2a 20 5e 49 66 20 58 ger..**.** ^If X
1ebe0 20 69 73 20 61 20 6d 65 6d 6f 72 79 20 61 6c 6c is a memory all
1ebf0 6f 63 61 74 69 6f 6e 20 70 72 65 76 69 6f 75 73 ocation previous
1ec00 6c 79 20 6f 62 74 61 69 6e 65 64 20 66 72 6f 6d ly obtained from
1ec10 20 73 71 6c 69 74 65 33 5f 6d 61 6c 6c 6f 63 28 sqlite3_malloc(
1ec20 29 2c 0a 2a 2a 20 73 71 6c 69 74 65 33 5f 6d 61 ),.** sqlite3_ma
1ec30 6c 6c 6f 63 36 34 28 29 2c 20 73 71 6c 69 74 65 lloc64(), sqlite
1ec40 33 5f 72 65 61 6c 6c 6f 63 28 29 2c 20 6f 72 20 3_realloc(), or
1ec50 73 71 6c 69 74 65 33 5f 72 65 61 6c 6c 6f 63 36 sqlite3_realloc6
1ec60 34 28 29 2c 20 74 68 65 6e 0a 2a 2a 20 73 71 6c 4(), then.** sql
1ec70 69 74 65 33 5f 6d 73 69 7a 65 28 58 29 20 72 65 ite3_msize(X) re
1ec80 74 75 72 6e 73 20 74 68 65 20 73 69 7a 65 20 6f turns the size o
1ec90 66 20 74 68 61 74 20 6d 65 6d 6f 72 79 20 61 6c f that memory al
1eca0 6c 6f 63 61 74 69 6f 6e 20 69 6e 20 62 79 74 65 location in byte
1ecb0 73 2e 0a 2a 2a 20 5e 54 68 65 20 76 61 6c 75 65 s..** ^The value
1ecc0 20 72 65 74 75 72 6e 65 64 20 62 79 20 73 71 6c returned by sql
1ecd0 69 74 65 33 5f 6d 73 69 7a 65 28 58 29 20 6d 69 ite3_msize(X) mi
1ece0 67 68 74 20 62 65 20 6c 61 72 67 65 72 20 74 68 ght be larger th
1ecf0 61 6e 20 74 68 65 20 6e 75 6d 62 65 72 0a 2a 2a an the number.**
1ed00 20 6f 66 20 62 79 74 65 73 20 72 65 71 75 65 73 of bytes reques
1ed10 74 65 64 20 77 68 65 6e 20 58 20 77 61 73 20 61 ted when X was a
1ed20 6c 6c 6f 63 61 74 65 64 2e 20 20 5e 49 66 20 58 llocated. ^If X
1ed30 20 69 73 20 61 20 4e 55 4c 4c 20 70 6f 69 6e 74 is a NULL point
1ed40 65 72 20 74 68 65 6e 0a 2a 2a 20 73 71 6c 69 74 er then.** sqlit
1ed50 65 33 5f 6d 73 69 7a 65 28 58 29 20 72 65 74 75 e3_msize(X) retu
1ed60 72 6e 73 20 7a 65 72 6f 2e 20 20 49 66 20 58 20 rns zero. If X
1ed70 70 6f 69 6e 74 73 20 74 6f 20 73 6f 6d 65 74 68 points to someth
1ed80 69 6e 67 20 74 68 61 74 20 69 73 20 6e 6f 74 0a ing that is not.
1ed90 2a 2a 20 74 68 65 20 62 65 67 69 6e 6e 69 6e 67 ** the beginning
1eda0 20 6f 66 20 6d 65 6d 6f 72 79 20 61 6c 6c 6f 63 of memory alloc
1edb0 61 74 69 6f 6e 2c 20 6f 72 20 69 66 20 69 74 20 ation, or if it
1edc0 70 6f 69 6e 74 73 20 74 6f 20 61 20 66 6f 72 6d points to a form
1edd0 65 72 6c 79 0a 2a 2a 20 76 61 6c 69 64 20 6d 65 erly.** valid me
1ede0 6d 6f 72 79 20 61 6c 6c 6f 63 61 74 69 6f 6e 20 mory allocation
1edf0 74 68 61 74 20 68 61 73 20 6e 6f 77 20 62 65 65 that has now bee
1ee00 6e 20 66 72 65 65 64 2c 20 74 68 65 6e 20 74 68 n freed, then th
1ee10 65 20 62 65 68 61 76 69 6f 72 0a 2a 2a 20 6f 66 e behavior.** of
1ee20 20 73 71 6c 69 74 65 33 5f 6d 73 69 7a 65 28 58 sqlite3_msize(X
1ee30 29 20 69 73 20 75 6e 64 65 66 69 6e 65 64 20 61 ) is undefined a
1ee40 6e 64 20 70 6f 73 73 69 62 6c 79 20 68 61 72 6d nd possibly harm
1ee50 66 75 6c 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 ful..**.** ^The
1ee60 6d 65 6d 6f 72 79 20 72 65 74 75 72 6e 65 64 20 memory returned
1ee70 62 79 20 73 71 6c 69 74 65 33 5f 6d 61 6c 6c 6f by sqlite3_mallo
1ee80 63 28 29 2c 20 73 71 6c 69 74 65 33 5f 72 65 61 c(), sqlite3_rea
1ee90 6c 6c 6f 63 28 29 2c 0a 2a 2a 20 73 71 6c 69 74 lloc(),.** sqlit
1eea0 65 33 5f 6d 61 6c 6c 6f 63 36 34 28 29 2c 20 61 e3_malloc64(), a
1eeb0 6e 64 20 73 71 6c 69 74 65 33 5f 72 65 61 6c 6c nd sqlite3_reall
1eec0 6f 63 36 34 28 29 0a 2a 2a 20 69 73 20 61 6c 77 oc64().** is alw
1eed0 61 79 73 20 61 6c 69 67 6e 65 64 20 74 6f 20 61 ays aligned to a
1eee0 74 20 6c 65 61 73 74 20 61 6e 20 38 20 62 79 74 t least an 8 byt
1eef0 65 20 62 6f 75 6e 64 61 72 79 2c 20 6f 72 20 74 e boundary, or t
1ef00 6f 20 61 0a 2a 2a 20 34 20 62 79 74 65 20 62 6f o a.** 4 byte bo
1ef10 75 6e 64 61 72 79 20 69 66 20 74 68 65 20 5b 53 undary if the [S
1ef20 51 4c 49 54 45 5f 34 5f 42 59 54 45 5f 41 4c 49 QLITE_4_BYTE_ALI
1ef30 47 4e 45 44 5f 4d 41 4c 4c 4f 43 5d 20 63 6f 6d GNED_MALLOC] com
1ef40 70 69 6c 65 2d 74 69 6d 65 0a 2a 2a 20 6f 70 74 pile-time.** opt
1ef50 69 6f 6e 20 69 73 20 75 73 65 64 2e 0a 2a 2a 0a ion is used..**.
1ef60 2a 2a 20 49 6e 20 53 51 4c 69 74 65 20 76 65 72 ** In SQLite ver
1ef70 73 69 6f 6e 20 33 2e 35 2e 30 20 61 6e 64 20 33 sion 3.5.0 and 3
1ef80 2e 35 2e 31 2c 20 69 74 20 77 61 73 20 70 6f 73 .5.1, it was pos
1ef90 73 69 62 6c 65 20 74 6f 20 64 65 66 69 6e 65 0a sible to define.
1efa0 2a 2a 20 74 68 65 20 53 51 4c 49 54 45 5f 4f 4d ** the SQLITE_OM
1efb0 49 54 5f 4d 45 4d 4f 52 59 5f 41 4c 4c 4f 43 41 IT_MEMORY_ALLOCA
1efc0 54 49 4f 4e 20 77 68 69 63 68 20 77 6f 75 6c 64 TION which would
1efd0 20 63 61 75 73 65 20 74 68 65 20 62 75 69 6c 74 cause the built
1efe0 2d 69 6e 0a 2a 2a 20 69 6d 70 6c 65 6d 65 6e 74 -in.** implement
1eff0 61 74 69 6f 6e 20 6f 66 20 74 68 65 73 65 20 72 ation of these r
1f000 6f 75 74 69 6e 65 73 20 74 6f 20 62 65 20 6f 6d outines to be om
1f010 69 74 74 65 64 2e 20 20 54 68 61 74 20 63 61 70 itted. That cap
1f020 61 62 69 6c 69 74 79 0a 2a 2a 20 69 73 20 6e 6f ability.** is no
1f030 20 6c 6f 6e 67 65 72 20 70 72 6f 76 69 64 65 64 longer provided
1f040 2e 20 20 4f 6e 6c 79 20 62 75 69 6c 74 2d 69 6e . Only built-in
1f050 20 6d 65 6d 6f 72 79 20 61 6c 6c 6f 63 61 74 6f memory allocato
1f060 72 73 20 63 61 6e 20 62 65 20 75 73 65 64 2e 0a rs can be used..
1f070 2a 2a 0a 2a 2a 20 50 72 69 6f 72 20 74 6f 20 53 **.** Prior to S
1f080 51 4c 69 74 65 20 76 65 72 73 69 6f 6e 20 33 2e QLite version 3.
1f090 37 2e 31 30 2c 20 74 68 65 20 57 69 6e 64 6f 77 7.10, the Window
1f0a0 73 20 4f 53 20 69 6e 74 65 72 66 61 63 65 20 6c s OS interface l
1f0b0 61 79 65 72 20 63 61 6c 6c 65 64 0a 2a 2a 20 74 ayer called.** t
1f0c0 68 65 20 73 79 73 74 65 6d 20 6d 61 6c 6c 6f 63 he system malloc
1f0d0 28 29 20 61 6e 64 20 66 72 65 65 28 29 20 64 69 () and free() di
1f0e0 72 65 63 74 6c 79 20 77 68 65 6e 20 63 6f 6e 76 rectly when conv
1f0f0 65 72 74 69 6e 67 0a 2a 2a 20 66 69 6c 65 6e 61 erting.** filena
1f100 6d 65 73 20 62 65 74 77 65 65 6e 20 74 68 65 20 mes between the
1f110 55 54 46 2d 38 20 65 6e 63 6f 64 69 6e 67 20 75 UTF-8 encoding u
1f120 73 65 64 20 62 79 20 53 51 4c 69 74 65 0a 2a 2a sed by SQLite.**
1f130 20 61 6e 64 20 77 68 61 74 65 76 65 72 20 66 69 and whatever fi
1f140 6c 65 6e 61 6d 65 20 65 6e 63 6f 64 69 6e 67 20 lename encoding
1f150 69 73 20 75 73 65 64 20 62 79 20 74 68 65 20 70 is used by the p
1f160 61 72 74 69 63 75 6c 61 72 20 57 69 6e 64 6f 77 articular Window
1f170 73 0a 2a 2a 20 69 6e 73 74 61 6c 6c 61 74 69 6f s.** installatio
1f180 6e 2e 20 20 4d 65 6d 6f 72 79 20 61 6c 6c 6f 63 n. Memory alloc
1f190 61 74 69 6f 6e 20 65 72 72 6f 72 73 20 77 65 72 ation errors wer
1f1a0 65 20 64 65 74 65 63 74 65 64 2c 20 62 75 74 0a e detected, but.
1f1b0 2a 2a 20 74 68 65 79 20 77 65 72 65 20 72 65 70 ** they were rep
1f1c0 6f 72 74 65 64 20 62 61 63 6b 20 61 73 20 5b 53 orted back as [S
1f1d0 51 4c 49 54 45 5f 43 41 4e 54 4f 50 45 4e 5d 20 QLITE_CANTOPEN]
1f1e0 6f 72 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f 49 4f or.** [SQLITE_IO
1f1f0 45 52 52 5d 20 72 61 74 68 65 72 20 74 68 61 6e ERR] rather than
1f200 20 5b 53 51 4c 49 54 45 5f 4e 4f 4d 45 4d 5d 2e [SQLITE_NOMEM].
1f210 0a 2a 2a 0a 2a 2a 20 54 68 65 20 70 6f 69 6e 74 .**.** The point
1f220 65 72 20 61 72 67 75 6d 65 6e 74 73 20 74 6f 20 er arguments to
1f230 5b 73 71 6c 69 74 65 33 5f 66 72 65 65 28 29 5d [sqlite3_free()]
1f240 20 61 6e 64 20 5b 73 71 6c 69 74 65 33 5f 72 65 and [sqlite3_re
1f250 61 6c 6c 6f 63 28 29 5d 0a 2a 2a 20 6d 75 73 74 alloc()].** must
1f260 20 62 65 20 65 69 74 68 65 72 20 4e 55 4c 4c 20 be either NULL
1f270 6f 72 20 65 6c 73 65 20 70 6f 69 6e 74 65 72 73 or else pointers
1f280 20 6f 62 74 61 69 6e 65 64 20 66 72 6f 6d 20 61 obtained from a
1f290 20 70 72 69 6f 72 0a 2a 2a 20 69 6e 76 6f 63 61 prior.** invoca
1f2a0 74 69 6f 6e 20 6f 66 20 5b 73 71 6c 69 74 65 33 tion of [sqlite3
1f2b0 5f 6d 61 6c 6c 6f 63 28 29 5d 20 6f 72 20 5b 73 _malloc()] or [s
1f2c0 71 6c 69 74 65 33 5f 72 65 61 6c 6c 6f 63 28 29 qlite3_realloc()
1f2d0 5d 20 74 68 61 74 20 68 61 76 65 0a 2a 2a 20 6e ] that have.** n
1f2e0 6f 74 20 79 65 74 20 62 65 65 6e 20 72 65 6c 65 ot yet been rele
1f2f0 61 73 65 64 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 ased..**.** The
1f300 61 70 70 6c 69 63 61 74 69 6f 6e 20 6d 75 73 74 application must
1f310 20 6e 6f 74 20 72 65 61 64 20 6f 72 20 77 72 69 not read or wri
1f320 74 65 20 61 6e 79 20 70 61 72 74 20 6f 66 0a 2a te any part of.*
1f330 2a 20 61 20 62 6c 6f 63 6b 20 6f 66 20 6d 65 6d * a block of mem
1f340 6f 72 79 20 61 66 74 65 72 20 69 74 20 68 61 73 ory after it has
1f350 20 62 65 65 6e 20 72 65 6c 65 61 73 65 64 20 75 been released u
1f360 73 69 6e 67 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 sing.** [sqlite3
1f370 5f 66 72 65 65 28 29 5d 20 6f 72 20 5b 73 71 6c _free()] or [sql
1f380 69 74 65 33 5f 72 65 61 6c 6c 6f 63 28 29 5d 2e ite3_realloc()].
1f390 0a 2a 2f 0a 76 6f 69 64 20 2a 73 71 6c 69 74 65 .*/.void *sqlite
1f3a0 33 5f 6d 61 6c 6c 6f 63 28 69 6e 74 29 3b 0a 76 3_malloc(int);.v
1f3b0 6f 69 64 20 2a 73 71 6c 69 74 65 33 5f 6d 61 6c oid *sqlite3_mal
1f3c0 6c 6f 63 36 34 28 73 71 6c 69 74 65 33 5f 75 69 loc64(sqlite3_ui
1f3d0 6e 74 36 34 29 3b 0a 76 6f 69 64 20 2a 73 71 6c nt64);.void *sql
1f3e0 69 74 65 33 5f 72 65 61 6c 6c 6f 63 28 76 6f 69 ite3_realloc(voi
1f3f0 64 2a 2c 20 69 6e 74 29 3b 0a 76 6f 69 64 20 2a d*, int);.void *
1f400 73 71 6c 69 74 65 33 5f 72 65 61 6c 6c 6f 63 36 sqlite3_realloc6
1f410 34 28 76 6f 69 64 2a 2c 20 73 71 6c 69 74 65 33 4(void*, sqlite3
1f420 5f 75 69 6e 74 36 34 29 3b 0a 76 6f 69 64 20 73 _uint64);.void s
1f430 71 6c 69 74 65 33 5f 66 72 65 65 28 76 6f 69 64 qlite3_free(void
1f440 2a 29 3b 0a 73 71 6c 69 74 65 33 5f 75 69 6e 74 *);.sqlite3_uint
1f450 36 34 20 73 71 6c 69 74 65 33 5f 6d 73 69 7a 65 64 sqlite3_msize
1f460 28 76 6f 69 64 2a 29 3b 0a 0a 2f 2a 0a 2a 2a 20 (void*);../*.**
1f470 43 41 50 49 33 52 45 46 3a 20 4d 65 6d 6f 72 79 CAPI3REF: Memory
1f480 20 41 6c 6c 6f 63 61 74 6f 72 20 53 74 61 74 69 Allocator Stati
1f490 73 74 69 63 73 0a 2a 2a 0a 2a 2a 20 53 51 4c 69 stics.**.** SQLi
1f4a0 74 65 20 70 72 6f 76 69 64 65 73 20 74 68 65 73 te provides thes
1f4b0 65 20 74 77 6f 20 69 6e 74 65 72 66 61 63 65 73 e two interfaces
1f4c0 20 66 6f 72 20 72 65 70 6f 72 74 69 6e 67 20 6f for reporting o
1f4d0 6e 20 74 68 65 20 73 74 61 74 75 73 0a 2a 2a 20 n the status.**
1f4e0 6f 66 20 74 68 65 20 5b 73 71 6c 69 74 65 33 5f of the [sqlite3_
1f4f0 6d 61 6c 6c 6f 63 28 29 5d 2c 20 5b 73 71 6c 69 malloc()], [sqli
1f500 74 65 33 5f 66 72 65 65 28 29 5d 2c 20 61 6e 64 te3_free()], and
1f510 20 5b 73 71 6c 69 74 65 33 5f 72 65 61 6c 6c 6f [sqlite3_reallo
1f520 63 28 29 5d 0a 2a 2a 20 72 6f 75 74 69 6e 65 73 c()].** routines
1f530 2c 20 77 68 69 63 68 20 66 6f 72 6d 20 74 68 65 , which form the
1f540 20 62 75 69 6c 74 2d 69 6e 20 6d 65 6d 6f 72 79 built-in memory
1f550 20 61 6c 6c 6f 63 61 74 69 6f 6e 20 73 75 62 73 allocation subs
1f560 79 73 74 65 6d 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 ystem..**.** ^Th
1f570 65 20 5b 73 71 6c 69 74 65 33 5f 6d 65 6d 6f 72 e [sqlite3_memor
1f580 79 5f 75 73 65 64 28 29 5d 20 72 6f 75 74 69 6e y_used()] routin
1f590 65 20 72 65 74 75 72 6e 73 20 74 68 65 20 6e 75 e returns the nu
1f5a0 6d 62 65 72 20 6f 66 20 62 79 74 65 73 0a 2a 2a mber of bytes.**
1f5b0 20 6f 66 20 6d 65 6d 6f 72 79 20 63 75 72 72 65 of memory curre
1f5c0 6e 74 6c 79 20 6f 75 74 73 74 61 6e 64 69 6e 67 ntly outstanding
1f5d0 20 28 6d 61 6c 6c 6f 63 65 64 20 62 75 74 20 6e (malloced but n
1f5e0 6f 74 20 66 72 65 65 64 29 2e 0a 2a 2a 20 5e 54 ot freed)..** ^T
1f5f0 68 65 20 5b 73 71 6c 69 74 65 33 5f 6d 65 6d 6f he [sqlite3_memo
1f600 72 79 5f 68 69 67 68 77 61 74 65 72 28 29 5d 20 ry_highwater()]
1f610 72 6f 75 74 69 6e 65 20 72 65 74 75 72 6e 73 20 routine returns
1f620 74 68 65 20 6d 61 78 69 6d 75 6d 0a 2a 2a 20 76 the maximum.** v
1f630 61 6c 75 65 20 6f 66 20 5b 73 71 6c 69 74 65 33 alue of [sqlite3
1f640 5f 6d 65 6d 6f 72 79 5f 75 73 65 64 28 29 5d 20 _memory_used()]
1f650 73 69 6e 63 65 20 74 68 65 20 68 69 67 68 2d 77 since the high-w
1f660 61 74 65 72 20 6d 61 72 6b 0a 2a 2a 20 77 61 73 ater mark.** was
1f670 20 6c 61 73 74 20 72 65 73 65 74 2e 20 20 5e 54 last reset. ^T
1f680 68 65 20 76 61 6c 75 65 73 20 72 65 74 75 72 6e he values return
1f690 65 64 20 62 79 20 5b 73 71 6c 69 74 65 33 5f 6d ed by [sqlite3_m
1f6a0 65 6d 6f 72 79 5f 75 73 65 64 28 29 5d 20 61 6e emory_used()] an
1f6b0 64 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 6d 65 d.** [sqlite3_me
1f6c0 6d 6f 72 79 5f 68 69 67 68 77 61 74 65 72 28 29 mory_highwater()
1f6d0 5d 20 69 6e 63 6c 75 64 65 20 61 6e 79 20 6f 76 ] include any ov
1f6e0 65 72 68 65 61 64 0a 2a 2a 20 61 64 64 65 64 20 erhead.** added
1f6f0 62 79 20 53 51 4c 69 74 65 20 69 6e 20 69 74 73 by SQLite in its
1f700 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 implementation
1f710 6f 66 20 5b 73 71 6c 69 74 65 33 5f 6d 61 6c 6c of [sqlite3_mall
1f720 6f 63 28 29 5d 2c 0a 2a 2a 20 62 75 74 20 6e 6f oc()],.** but no
1f730 74 20 6f 76 65 72 68 65 61 64 20 61 64 64 65 64 t overhead added
1f740 20 62 79 20 74 68 65 20 61 6e 79 20 75 6e 64 65 by the any unde
1f750 72 6c 79 69 6e 67 20 73 79 73 74 65 6d 20 6c 69 rlying system li
1f760 62 72 61 72 79 0a 2a 2a 20 72 6f 75 74 69 6e 65 brary.** routine
1f770 73 20 74 68 61 74 20 5b 73 71 6c 69 74 65 33 5f s that [sqlite3_
1f780 6d 61 6c 6c 6f 63 28 29 5d 20 6d 61 79 20 63 61 malloc()] may ca
1f790 6c 6c 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 6d ll..**.** ^The m
1f7a0 65 6d 6f 72 79 20 68 69 67 68 2d 77 61 74 65 72 emory high-water
1f7b0 20 6d 61 72 6b 20 69 73 20 72 65 73 65 74 20 74 mark is reset t
1f7c0 6f 20 74 68 65 20 63 75 72 72 65 6e 74 20 76 61 o the current va
1f7d0 6c 75 65 20 6f 66 0a 2a 2a 20 5b 73 71 6c 69 74 lue of.** [sqlit
1f7e0 65 33 5f 6d 65 6d 6f 72 79 5f 75 73 65 64 28 29 e3_memory_used()
1f7f0 5d 20 69 66 20 61 6e 64 20 6f 6e 6c 79 20 69 66 ] if and only if
1f800 20 74 68 65 20 70 61 72 61 6d 65 74 65 72 20 74 the parameter t
1f810 6f 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 6d 65 o.** [sqlite3_me
1f820 6d 6f 72 79 5f 68 69 67 68 77 61 74 65 72 28 29 mory_highwater()
1f830 5d 20 69 73 20 74 72 75 65 2e 20 20 5e 54 68 65 ] is true. ^The
1f840 20 76 61 6c 75 65 20 72 65 74 75 72 6e 65 64 0a value returned.
1f850 2a 2a 20 62 79 20 5b 73 71 6c 69 74 65 33 5f 6d ** by [sqlite3_m
1f860 65 6d 6f 72 79 5f 68 69 67 68 77 61 74 65 72 28 emory_highwater(
1f870 31 29 5d 20 69 73 20 74 68 65 20 68 69 67 68 2d 1)] is the high-
1f880 77 61 74 65 72 20 6d 61 72 6b 0a 2a 2a 20 70 72 water mark.** pr
1f890 69 6f 72 20 74 6f 20 74 68 65 20 72 65 73 65 74 ior to the reset
1f8a0 2e 0a 2a 2f 0a 73 71 6c 69 74 65 33 5f 69 6e 74 ..*/.sqlite3_int
1f8b0 36 34 20 73 71 6c 69 74 65 33 5f 6d 65 6d 6f 72 64 sqlite3_memor
1f8c0 79 5f 75 73 65 64 28 76 6f 69 64 29 3b 0a 73 71 y_used(void);.sq
1f8d0 6c 69 74 65 33 5f 69 6e 74 36 34 20 73 71 6c 69 lite3_int64 sqli
1f8e0 74 65 33 5f 6d 65 6d 6f 72 79 5f 68 69 67 68 77 te3_memory_highw
1f8f0 61 74 65 72 28 69 6e 74 20 72 65 73 65 74 46 6c ater(int resetFl
1f900 61 67 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 ag);../*.** CAPI
1f910 33 52 45 46 3a 20 50 73 65 75 64 6f 2d 52 61 6e 3REF: Pseudo-Ran
1f920 64 6f 6d 20 4e 75 6d 62 65 72 20 47 65 6e 65 72 dom Number Gener
1f930 61 74 6f 72 0a 2a 2a 0a 2a 2a 20 53 51 4c 69 74 ator.**.** SQLit
1f940 65 20 63 6f 6e 74 61 69 6e 73 20 61 20 68 69 67 e contains a hig
1f950 68 2d 71 75 61 6c 69 74 79 20 70 73 65 75 64 6f h-quality pseudo
1f960 2d 72 61 6e 64 6f 6d 20 6e 75 6d 62 65 72 20 67 -random number g
1f970 65 6e 65 72 61 74 6f 72 20 28 50 52 4e 47 29 20 enerator (PRNG)
1f980 75 73 65 64 20 74 6f 0a 2a 2a 20 73 65 6c 65 63 used to.** selec
1f990 74 20 72 61 6e 64 6f 6d 20 5b 52 4f 57 49 44 20 t random [ROWID
1f9a0 7c 20 52 4f 57 49 44 73 5d 20 77 68 65 6e 20 69 | ROWIDs] when i
1f9b0 6e 73 65 72 74 69 6e 67 20 6e 65 77 20 72 65 63 nserting new rec
1f9c0 6f 72 64 73 20 69 6e 74 6f 20 61 20 74 61 62 6c ords into a tabl
1f9d0 65 20 74 68 61 74 0a 2a 2a 20 61 6c 72 65 61 64 e that.** alread
1f9e0 79 20 75 73 65 73 20 74 68 65 20 6c 61 72 67 65 y uses the large
1f9f0 73 74 20 70 6f 73 73 69 62 6c 65 20 5b 52 4f 57 st possible [ROW
1fa00 49 44 5d 2e 20 20 54 68 65 20 50 52 4e 47 20 69 ID]. The PRNG i
1fa10 73 20 61 6c 73 6f 20 75 73 65 64 20 66 6f 72 0a s also used for.
1fa20 2a 2a 20 74 68 65 20 62 75 69 6c 64 2d 69 6e 20 ** the build-in
1fa30 72 61 6e 64 6f 6d 28 29 20 61 6e 64 20 72 61 6e random() and ran
1fa40 64 6f 6d 62 6c 6f 62 28 29 20 53 51 4c 20 66 75 domblob() SQL fu
1fa50 6e 63 74 69 6f 6e 73 2e 20 20 54 68 69 73 20 69 nctions. This i
1fa60 6e 74 65 72 66 61 63 65 20 61 6c 6c 6f 77 73 0a nterface allows.
1fa70 2a 2a 20 61 70 70 6c 69 63 61 74 69 6f 6e 73 20 ** applications
1fa80 74 6f 20 61 63 63 65 73 73 20 74 68 65 20 73 61 to access the sa
1fa90 6d 65 20 50 52 4e 47 20 66 6f 72 20 6f 74 68 65 me PRNG for othe
1faa0 72 20 70 75 72 70 6f 73 65 73 2e 0a 2a 2a 0a 2a r purposes..**.*
1fab0 2a 20 5e 41 20 63 61 6c 6c 20 74 6f 20 74 68 69 * ^A call to thi
1fac0 73 20 72 6f 75 74 69 6e 65 20 73 74 6f 72 65 73 s routine stores
1fad0 20 4e 20 62 79 74 65 73 20 6f 66 20 72 61 6e 64 N bytes of rand
1fae0 6f 6d 6e 65 73 73 20 69 6e 74 6f 20 62 75 66 66 omness into buff
1faf0 65 72 20 50 2e 0a 2a 2a 20 5e 54 68 65 20 50 20 er P..** ^The P
1fb00 70 61 72 61 6d 65 74 65 72 20 63 61 6e 20 62 65 parameter can be
1fb10 20 61 20 4e 55 4c 4c 20 70 6f 69 6e 74 65 72 2e a NULL pointer.
1fb20 0a 2a 2a 0a 2a 2a 20 5e 49 66 20 74 68 69 73 20 .**.** ^If this
1fb30 72 6f 75 74 69 6e 65 20 68 61 73 20 6e 6f 74 20 routine has not
1fb40 62 65 65 6e 20 70 72 65 76 69 6f 75 73 6c 79 20 been previously
1fb50 63 61 6c 6c 65 64 20 6f 72 20 69 66 20 74 68 65 called or if the
1fb60 20 70 72 65 76 69 6f 75 73 0a 2a 2a 20 63 61 6c previous.** cal
1fb70 6c 20 68 61 64 20 4e 20 6c 65 73 73 20 74 68 61 l had N less tha
1fb80 6e 20 6f 6e 65 20 6f 72 20 61 20 4e 55 4c 4c 20 n one or a NULL
1fb90 70 6f 69 6e 74 65 72 20 66 6f 72 20 50 2c 20 74 pointer for P, t
1fba0 68 65 6e 20 74 68 65 20 50 52 4e 47 20 69 73 0a hen the PRNG is.
1fbb0 2a 2a 20 73 65 65 64 65 64 20 75 73 69 6e 67 20 ** seeded using
1fbc0 72 61 6e 64 6f 6d 6e 65 73 73 20 6f 62 74 61 69 randomness obtai
1fbd0 6e 65 64 20 66 72 6f 6d 20 74 68 65 20 78 52 61 ned from the xRa
1fbe0 6e 64 6f 6d 6e 65 73 73 20 6d 65 74 68 6f 64 20 ndomness method
1fbf0 6f 66 0a 2a 2a 20 74 68 65 20 64 65 66 61 75 6c of.** the defaul
1fc00 74 20 5b 73 71 6c 69 74 65 33 5f 76 66 73 5d 20 t [sqlite3_vfs]
1fc10 6f 62 6a 65 63 74 2e 0a 2a 2a 20 5e 49 66 20 74 object..** ^If t
1fc20 68 65 20 70 72 65 76 69 6f 75 73 20 63 61 6c 6c he previous call
1fc30 20 74 6f 20 74 68 69 73 20 72 6f 75 74 69 6e 65 to this routine
1fc40 20 68 61 64 20 61 6e 20 4e 20 6f 66 20 31 20 6f had an N of 1 o
1fc50 72 20 6d 6f 72 65 20 61 6e 64 20 61 0a 2a 2a 20 r more and a.**
1fc60 6e 6f 6e 2d 4e 55 4c 4c 20 50 20 74 68 65 6e 20 non-NULL P then
1fc70 74 68 65 20 70 73 65 75 64 6f 2d 72 61 6e 64 6f the pseudo-rando
1fc80 6d 6e 65 73 73 20 69 73 20 67 65 6e 65 72 61 74 mness is generat
1fc90 65 64 0a 2a 2a 20 69 6e 74 65 72 6e 61 6c 6c 79 ed.** internally
1fca0 20 61 6e 64 20 77 69 74 68 6f 75 74 20 72 65 63 and without rec
1fcb0 6f 75 72 73 65 20 74 6f 20 74 68 65 20 5b 73 71 ourse to the [sq
1fcc0 6c 69 74 65 33 5f 76 66 73 5d 20 78 52 61 6e 64 lite3_vfs] xRand
1fcd0 6f 6d 6e 65 73 73 0a 2a 2a 20 6d 65 74 68 6f 64 omness.** method
1fce0 2e 0a 2a 2f 0a 76 6f 69 64 20 73 71 6c 69 74 65 ..*/.void sqlite
1fcf0 33 5f 72 61 6e 64 6f 6d 6e 65 73 73 28 69 6e 74 3_randomness(int
1fd00 20 4e 2c 20 76 6f 69 64 20 2a 50 29 3b 0a 0a 2f N, void *P);../
1fd10 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 43 *.** CAPI3REF: C
1fd20 6f 6d 70 69 6c 65 2d 54 69 6d 65 20 41 75 74 68 ompile-Time Auth
1fd30 6f 72 69 7a 61 74 69 6f 6e 20 43 61 6c 6c 62 61 orization Callba
1fd40 63 6b 73 0a 2a 2a 20 4d 45 54 48 4f 44 3a 20 73 cks.** METHOD: s
1fd50 71 6c 69 74 65 33 0a 2a 2a 0a 2a 2a 20 5e 54 68 qlite3.**.** ^Th
1fd60 69 73 20 72 6f 75 74 69 6e 65 20 72 65 67 69 73 is routine regis
1fd70 74 65 72 73 20 61 6e 20 61 75 74 68 6f 72 69 7a ters an authoriz
1fd80 65 72 20 63 61 6c 6c 62 61 63 6b 20 77 69 74 68 er callback with
1fd90 20 61 20 70 61 72 74 69 63 75 6c 61 72 0a 2a 2a a particular.**
1fda0 20 5b 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 [database conne
1fdb0 63 74 69 6f 6e 5d 2c 20 73 75 70 70 6c 69 65 64 ction], supplied
1fdc0 20 69 6e 20 74 68 65 20 66 69 72 73 74 20 61 72 in the first ar
1fdd0 67 75 6d 65 6e 74 2e 0a 2a 2a 20 5e 54 68 65 20 gument..** ^The
1fde0 61 75 74 68 6f 72 69 7a 65 72 20 63 61 6c 6c 62 authorizer callb
1fdf0 61 63 6b 20 69 73 20 69 6e 76 6f 6b 65 64 20 61 ack is invoked a
1fe00 73 20 53 51 4c 20 73 74 61 74 65 6d 65 6e 74 73 s SQL statements
1fe10 20 61 72 65 20 62 65 69 6e 67 20 63 6f 6d 70 69 are being compi
1fe20 6c 65 64 0a 2a 2a 20 62 79 20 5b 73 71 6c 69 74 led.** by [sqlit
1fe30 65 33 5f 70 72 65 70 61 72 65 28 29 5d 20 6f 72 e3_prepare()] or
1fe40 20 69 74 73 20 76 61 72 69 61 6e 74 73 20 5b 73 its variants [s
1fe50 71 6c 69 74 65 33 5f 70 72 65 70 61 72 65 5f 76 qlite3_prepare_v
1fe60 32 28 29 5d 2c 0a 2a 2a 20 5b 73 71 6c 69 74 65 2()],.** [sqlite
1fe70 33 5f 70 72 65 70 61 72 65 31 36 28 29 5d 20 61 3_prepare16()] a
1fe80 6e 64 20 5b 73 71 6c 69 74 65 33 5f 70 72 65 70 nd [sqlite3_prep
1fe90 61 72 65 31 36 5f 76 32 28 29 5d 2e 20 20 5e 41 are16_v2()]. ^A
1fea0 74 20 76 61 72 69 6f 75 73 0a 2a 2a 20 70 6f 69 t various.** poi
1feb0 6e 74 73 20 64 75 72 69 6e 67 20 74 68 65 20 63 nts during the c
1fec0 6f 6d 70 69 6c 61 74 69 6f 6e 20 70 72 6f 63 65 ompilation proce
1fed0 73 73 2c 20 61 73 20 6c 6f 67 69 63 20 69 73 20 ss, as logic is
1fee0 62 65 69 6e 67 20 63 72 65 61 74 65 64 0a 2a 2a being created.**
1fef0 20 74 6f 20 70 65 72 66 6f 72 6d 20 76 61 72 69 to perform vari
1ff00 6f 75 73 20 61 63 74 69 6f 6e 73 2c 20 74 68 65 ous actions, the
1ff10 20 61 75 74 68 6f 72 69 7a 65 72 20 63 61 6c 6c authorizer call
1ff20 62 61 63 6b 20 69 73 20 69 6e 76 6f 6b 65 64 20 back is invoked
1ff30 74 6f 0a 2a 2a 20 73 65 65 20 69 66 20 74 68 6f to.** see if tho
1ff40 73 65 20 61 63 74 69 6f 6e 73 20 61 72 65 20 61 se actions are a
1ff50 6c 6c 6f 77 65 64 2e 20 20 5e 54 68 65 20 61 75 llowed. ^The au
1ff60 74 68 6f 72 69 7a 65 72 20 63 61 6c 6c 62 61 63 thorizer callbac
1ff70 6b 20 73 68 6f 75 6c 64 0a 2a 2a 20 72 65 74 75 k should.** retu
1ff80 72 6e 20 5b 53 51 4c 49 54 45 5f 4f 4b 5d 20 74 rn [SQLITE_OK] t
1ff90 6f 20 61 6c 6c 6f 77 20 74 68 65 20 61 63 74 69 o allow the acti
1ffa0 6f 6e 2c 20 5b 53 51 4c 49 54 45 5f 49 47 4e 4f on, [SQLITE_IGNO
1ffb0 52 45 5d 20 74 6f 20 64 69 73 61 6c 6c 6f 77 20 RE] to disallow
1ffc0 74 68 65 0a 2a 2a 20 73 70 65 63 69 66 69 63 20 the.** specific
1ffd0 61 63 74 69 6f 6e 20 62 75 74 20 61 6c 6c 6f 77 action but allow
1ffe0 20 74 68 65 20 53 51 4c 20 73 74 61 74 65 6d 65 the SQL stateme
1fff0 6e 74 20 74 6f 20 63 6f 6e 74 69 6e 75 65 20 74 nt to continue t
20000 6f 20 62 65 0a 2a 2a 20 63 6f 6d 70 69 6c 65 64 o be.** compiled
20010 2c 20 6f 72 20 5b 53 51 4c 49 54 45 5f 44 45 4e , or [SQLITE_DEN
20020 59 5d 20 74 6f 20 63 61 75 73 65 20 74 68 65 20 Y] to cause the
20030 65 6e 74 69 72 65 20 53 51 4c 20 73 74 61 74 65 entire SQL state
20040 6d 65 6e 74 20 74 6f 20 62 65 0a 2a 2a 20 72 65 ment to be.** re
20050 6a 65 63 74 65 64 20 77 69 74 68 20 61 6e 20 65 jected with an e
20060 72 72 6f 72 2e 20 20 5e 49 66 20 74 68 65 20 61 rror. ^If the a
20070 75 74 68 6f 72 69 7a 65 72 20 63 61 6c 6c 62 61 uthorizer callba
20080 63 6b 20 72 65 74 75 72 6e 73 0a 2a 2a 20 61 6e ck returns.** an
20090 79 20 76 61 6c 75 65 20 6f 74 68 65 72 20 74 68 y value other th
200a0 61 6e 20 5b 53 51 4c 49 54 45 5f 49 47 4e 4f 52 an [SQLITE_IGNOR
200b0 45 5d 2c 20 5b 53 51 4c 49 54 45 5f 4f 4b 5d 2c E], [SQLITE_OK],
200c0 20 6f 72 20 5b 53 51 4c 49 54 45 5f 44 45 4e 59 or [SQLITE_DENY
200d0 5d 0a 2a 2a 20 74 68 65 6e 20 74 68 65 20 5b 73 ].** then the [s
200e0 71 6c 69 74 65 33 5f 70 72 65 70 61 72 65 5f 76 qlite3_prepare_v
200f0 32 28 29 5d 20 6f 72 20 65 71 75 69 76 61 6c 65 2()] or equivale
20100 6e 74 20 63 61 6c 6c 20 74 68 61 74 20 74 72 69 nt call that tri
20110 67 67 65 72 65 64 0a 2a 2a 20 74 68 65 20 61 75 ggered.** the au
20120 74 68 6f 72 69 7a 65 72 20 77 69 6c 6c 20 66 61 thorizer will fa
20130 69 6c 20 77 69 74 68 20 61 6e 20 65 72 72 6f 72 il with an error
20140 20 6d 65 73 73 61 67 65 2e 0a 2a 2a 0a 2a 2a 20 message..**.**
20150 57 68 65 6e 20 74 68 65 20 63 61 6c 6c 62 61 63 When the callbac
20160 6b 20 72 65 74 75 72 6e 73 20 5b 53 51 4c 49 54 k returns [SQLIT
20170 45 5f 4f 4b 5d 2c 20 74 68 61 74 20 6d 65 61 6e E_OK], that mean
20180 73 20 74 68 65 20 6f 70 65 72 61 74 69 6f 6e 0a s the operation.
20190 2a 2a 20 72 65 71 75 65 73 74 65 64 20 69 73 20 ** requested is
201a0 6f 6b 2e 20 20 5e 57 68 65 6e 20 74 68 65 20 63 ok. ^When the c
201b0 61 6c 6c 62 61 63 6b 20 72 65 74 75 72 6e 73 20 allback returns
201c0 5b 53 51 4c 49 54 45 5f 44 45 4e 59 5d 2c 20 74 [SQLITE_DENY], t
201d0 68 65 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 70 he.** [sqlite3_p
201e0 72 65 70 61 72 65 5f 76 32 28 29 5d 20 6f 72 20 repare_v2()] or
201f0 65 71 75 69 76 61 6c 65 6e 74 20 63 61 6c 6c 20 equivalent call
20200 74 68 61 74 20 74 72 69 67 67 65 72 65 64 20 74 that triggered t
20210 68 65 0a 2a 2a 20 61 75 74 68 6f 72 69 7a 65 72 he.** authorizer
20220 20 77 69 6c 6c 20 66 61 69 6c 20 77 69 74 68 20 will fail with
20230 61 6e 20 65 72 72 6f 72 20 6d 65 73 73 61 67 65 an error message
20240 20 65 78 70 6c 61 69 6e 69 6e 67 20 74 68 61 74 explaining that
20250 0a 2a 2a 20 61 63 63 65 73 73 20 69 73 20 64 65 .** access is de
20260 6e 69 65 64 2e 20 0a 2a 2a 0a 2a 2a 20 5e 54 68 nied. .**.** ^Th
20270 65 20 66 69 72 73 74 20 70 61 72 61 6d 65 74 65 e first paramete
20280 72 20 74 6f 20 74 68 65 20 61 75 74 68 6f 72 69 r to the authori
20290 7a 65 72 20 63 61 6c 6c 62 61 63 6b 20 69 73 20 zer callback is
202a0 61 20 63 6f 70 79 20 6f 66 20 74 68 65 20 74 68 a copy of the th
202b0 69 72 64 0a 2a 2a 20 70 61 72 61 6d 65 74 65 72 ird.** parameter
202c0 20 74 6f 20 74 68 65 20 73 71 6c 69 74 65 33 5f to the sqlite3_
202d0 73 65 74 5f 61 75 74 68 6f 72 69 7a 65 72 28 29 set_authorizer()
202e0 20 69 6e 74 65 72 66 61 63 65 2e 20 5e 54 68 65 interface. ^The
202f0 20 73 65 63 6f 6e 64 20 70 61 72 61 6d 65 74 65 second paramete
20300 72 0a 2a 2a 20 74 6f 20 74 68 65 20 63 61 6c 6c r.** to the call
20310 62 61 63 6b 20 69 73 20 61 6e 20 69 6e 74 65 67 back is an integ
20320 65 72 20 5b 53 51 4c 49 54 45 5f 43 4f 50 59 20 er [SQLITE_COPY
20330 7c 20 61 63 74 69 6f 6e 20 63 6f 64 65 5d 20 74 | action code] t
20340 68 61 74 20 73 70 65 63 69 66 69 65 73 0a 2a 2a hat specifies.**
20350 20 74 68 65 20 70 61 72 74 69 63 75 6c 61 72 20 the particular
20360 61 63 74 69 6f 6e 20 74 6f 20 62 65 20 61 75 74 action to be aut
20370 68 6f 72 69 7a 65 64 2e 20 5e 54 68 65 20 74 68 horized. ^The th
20380 69 72 64 20 74 68 72 6f 75 67 68 20 73 69 78 74 ird through sixt
20390 68 20 70 61 72 61 6d 65 74 65 72 73 0a 2a 2a 20 h parameters.**
203a0 74 6f 20 74 68 65 20 63 61 6c 6c 62 61 63 6b 20 to the callback
203b0 61 72 65 20 7a 65 72 6f 2d 74 65 72 6d 69 6e 61 are zero-termina
203c0 74 65 64 20 73 74 72 69 6e 67 73 20 74 68 61 74 ted strings that
203d0 20 63 6f 6e 74 61 69 6e 20 61 64 64 69 74 69 6f contain additio
203e0 6e 61 6c 0a 2a 2a 20 64 65 74 61 69 6c 73 20 61 nal.** details a
203f0 62 6f 75 74 20 74 68 65 20 61 63 74 69 6f 6e 20 bout the action
20400 74 6f 20 62 65 20 61 75 74 68 6f 72 69 7a 65 64 to be authorized
20410 2e 0a 2a 2a 0a 2a 2a 20 5e 49 66 20 74 68 65 20 ..**.** ^If the
20420 61 63 74 69 6f 6e 20 63 6f 64 65 20 69 73 20 5b action code is [
20430 53 51 4c 49 54 45 5f 52 45 41 44 5d 0a 2a 2a 20 SQLITE_READ].**
20440 61 6e 64 20 74 68 65 20 63 61 6c 6c 62 61 63 6b and the callback
20450 20 72 65 74 75 72 6e 73 20 5b 53 51 4c 49 54 45 returns [SQLITE
20460 5f 49 47 4e 4f 52 45 5d 20 74 68 65 6e 20 74 68 _IGNORE] then th
20470 65 0a 2a 2a 20 5b 70 72 65 70 61 72 65 64 20 73 e.** [prepared s
20480 74 61 74 65 6d 65 6e 74 5d 20 73 74 61 74 65 6d tatement] statem
20490 65 6e 74 20 69 73 20 63 6f 6e 73 74 72 75 63 74 ent is construct
204a0 65 64 20 74 6f 20 73 75 62 73 74 69 74 75 74 65 ed to substitute
204b0 0a 2a 2a 20 61 20 4e 55 4c 4c 20 76 61 6c 75 65 .** a NULL value
204c0 20 69 6e 20 70 6c 61 63 65 20 6f 66 20 74 68 65 in place of the
204d0 20 74 61 62 6c 65 20 63 6f 6c 75 6d 6e 20 74 68 table column th
204e0 61 74 20 77 6f 75 6c 64 20 68 61 76 65 0a 2a 2a at would have.**
204f0 20 62 65 65 6e 20 72 65 61 64 20 69 66 20 5b 53 been read if [S
20500 51 4c 49 54 45 5f 4f 4b 5d 20 68 61 64 20 62 65 QLITE_OK] had be
20510 65 6e 20 72 65 74 75 72 6e 65 64 2e 20 20 54 68 en returned. Th
20520 65 20 5b 53 51 4c 49 54 45 5f 49 47 4e 4f 52 45 e [SQLITE_IGNORE
20530 5d 0a 2a 2a 20 72 65 74 75 72 6e 20 63 61 6e 20 ].** return can
20540 62 65 20 75 73 65 64 20 74 6f 20 64 65 6e 79 20 be used to deny
20550 61 6e 20 75 6e 74 72 75 73 74 65 64 20 75 73 65 an untrusted use
20560 72 20 61 63 63 65 73 73 20 74 6f 20 69 6e 64 69 r access to indi
20570 76 69 64 75 61 6c 0a 2a 2a 20 63 6f 6c 75 6d 6e vidual.** column
20580 73 20 6f 66 20 61 20 74 61 62 6c 65 2e 0a 2a 2a s of a table..**
20590 20 5e 49 66 20 74 68 65 20 61 63 74 69 6f 6e 20 ^If the action
205a0 63 6f 64 65 20 69 73 20 5b 53 51 4c 49 54 45 5f code is [SQLITE_
205b0 44 45 4c 45 54 45 5d 20 61 6e 64 20 74 68 65 20 DELETE] and the
205c0 63 61 6c 6c 62 61 63 6b 20 72 65 74 75 72 6e 73 callback returns
205d0 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f 49 47 4e 4f .** [SQLITE_IGNO
205e0 52 45 5d 20 74 68 65 6e 20 74 68 65 20 5b 44 45 RE] then the [DE
205f0 4c 45 54 45 5d 20 6f 70 65 72 61 74 69 6f 6e 20 LETE] operation
20600 70 72 6f 63 65 65 64 73 20 62 75 74 20 74 68 65 proceeds but the
20610 0a 2a 2a 20 5b 74 72 75 6e 63 61 74 65 20 6f 70 .** [truncate op
20620 74 69 6d 69 7a 61 74 69 6f 6e 5d 20 69 73 20 64 timization] is d
20630 69 73 61 62 6c 65 64 20 61 6e 64 20 61 6c 6c 20 isabled and all
20640 72 6f 77 73 20 61 72 65 20 64 65 6c 65 74 65 64 rows are deleted
20650 20 69 6e 64 69 76 69 64 75 61 6c 6c 79 2e 0a 2a individually..*
20660 2a 0a 2a 2a 20 41 6e 20 61 75 74 68 6f 72 69 7a *.** An authoriz
20670 65 72 20 69 73 20 75 73 65 64 20 77 68 65 6e 20 er is used when
20680 5b 73 71 6c 69 74 65 33 5f 70 72 65 70 61 72 65 [sqlite3_prepare
20690 20 7c 20 70 72 65 70 61 72 69 6e 67 5d 0a 2a 2a | preparing].**
206a0 20 53 51 4c 20 73 74 61 74 65 6d 65 6e 74 73 20 SQL statements
206b0 66 72 6f 6d 20 61 6e 20 75 6e 74 72 75 73 74 65 from an untruste
206c0 64 20 73 6f 75 72 63 65 2c 20 74 6f 20 65 6e 73 d source, to ens
206d0 75 72 65 20 74 68 61 74 20 74 68 65 20 53 51 4c ure that the SQL
206e0 20 73 74 61 74 65 6d 65 6e 74 73 0a 2a 2a 20 64 statements.** d
206f0 6f 20 6e 6f 74 20 74 72 79 20 74 6f 20 61 63 63 o not try to acc
20700 65 73 73 20 64 61 74 61 20 74 68 65 79 20 61 72 ess data they ar
20710 65 20 6e 6f 74 20 61 6c 6c 6f 77 65 64 20 74 6f e not allowed to
20720 20 73 65 65 2c 20 6f 72 20 74 68 61 74 20 74 68 see, or that th
20730 65 79 20 64 6f 20 6e 6f 74 0a 2a 2a 20 74 72 79 ey do not.** try
20740 20 74 6f 20 65 78 65 63 75 74 65 20 6d 61 6c 69 to execute mali
20750 63 69 6f 75 73 20 73 74 61 74 65 6d 65 6e 74 73 cious statements
20760 20 74 68 61 74 20 64 61 6d 61 67 65 20 74 68 65 that damage the
20770 20 64 61 74 61 62 61 73 65 2e 20 20 46 6f 72 0a database. For.
20780 2a 2a 20 65 78 61 6d 70 6c 65 2c 20 61 6e 20 61 ** example, an a
20790 70 70 6c 69 63 61 74 69 6f 6e 20 6d 61 79 20 61 pplication may a
207a0 6c 6c 6f 77 20 61 20 75 73 65 72 20 74 6f 20 65 llow a user to e
207b0 6e 74 65 72 20 61 72 62 69 74 72 61 72 79 0a 2a nter arbitrary.*
207c0 2a 20 53 51 4c 20 71 75 65 72 69 65 73 20 66 6f * SQL queries fo
207d0 72 20 65 76 61 6c 75 61 74 69 6f 6e 20 62 79 20 r evaluation by
207e0 61 20 64 61 74 61 62 61 73 65 2e 20 20 42 75 74 a database. But
207f0 20 74 68 65 20 61 70 70 6c 69 63 61 74 69 6f 6e the application
20800 20 64 6f 65 73 0a 2a 2a 20 6e 6f 74 20 77 61 6e does.** not wan
20810 74 20 74 68 65 20 75 73 65 72 20 74 6f 20 62 65 t the user to be
20820 20 61 62 6c 65 20 74 6f 20 6d 61 6b 65 20 61 72 able to make ar
20830 62 69 74 72 61 72 79 20 63 68 61 6e 67 65 73 20 bitrary changes
20840 74 6f 20 74 68 65 0a 2a 2a 20 64 61 74 61 62 61 to the.** databa
20850 73 65 2e 20 20 41 6e 20 61 75 74 68 6f 72 69 7a se. An authoriz
20860 65 72 20 63 6f 75 6c 64 20 74 68 65 6e 20 62 65 er could then be
20870 20 70 75 74 20 69 6e 20 70 6c 61 63 65 20 77 68 put in place wh
20880 69 6c 65 20 74 68 65 0a 2a 2a 20 75 73 65 72 2d ile the.** user-
20890 65 6e 74 65 72 65 64 20 53 51 4c 20 69 73 20 62 entered SQL is b
208a0 65 69 6e 67 20 5b 73 71 6c 69 74 65 33 5f 70 72 eing [sqlite3_pr
208b0 65 70 61 72 65 20 7c 20 70 72 65 70 61 72 65 64 epare | prepared
208c0 5d 20 74 68 61 74 0a 2a 2a 20 64 69 73 61 6c 6c ] that.** disall
208d0 6f 77 73 20 65 76 65 72 79 74 68 69 6e 67 20 65 ows everything e
208e0 78 63 65 70 74 20 5b 53 45 4c 45 43 54 5d 20 73 xcept [SELECT] s
208f0 74 61 74 65 6d 65 6e 74 73 2e 0a 2a 2a 0a 2a 2a tatements..**.**
20900 20 41 70 70 6c 69 63 61 74 69 6f 6e 73 20 74 68 Applications th
20910 61 74 20 6e 65 65 64 20 74 6f 20 70 72 6f 63 65 at need to proce
20920 73 73 20 53 51 4c 20 66 72 6f 6d 20 75 6e 74 72 ss SQL from untr
20930 75 73 74 65 64 20 73 6f 75 72 63 65 73 0a 2a 2a usted sources.**
20940 20 6d 69 67 68 74 20 61 6c 73 6f 20 63 6f 6e 73 might also cons
20950 69 64 65 72 20 6c 6f 77 65 72 69 6e 67 20 72 65 ider lowering re
20960 73 6f 75 72 63 65 20 6c 69 6d 69 74 73 20 75 73 source limits us
20970 69 6e 67 20 5b 73 71 6c 69 74 65 33 5f 6c 69 6d ing [sqlite3_lim
20980 69 74 28 29 5d 0a 2a 2a 20 61 6e 64 20 6c 69 6d it()].** and lim
20990 69 74 69 6e 67 20 64 61 74 61 62 61 73 65 20 73 iting database s
209a0 69 7a 65 20 75 73 69 6e 67 20 74 68 65 20 5b 6d ize using the [m
209b0 61 78 5f 70 61 67 65 5f 63 6f 75 6e 74 5d 20 5b ax_page_count] [
209c0 50 52 41 47 4d 41 5d 0a 2a 2a 20 69 6e 20 61 64 PRAGMA].** in ad
209d0 64 69 74 69 6f 6e 20 74 6f 20 75 73 69 6e 67 20 dition to using
209e0 61 6e 20 61 75 74 68 6f 72 69 7a 65 72 2e 0a 2a an authorizer..*
209f0 2a 0a 2a 2a 20 5e 28 4f 6e 6c 79 20 61 20 73 69 *.** ^(Only a si
20a00 6e 67 6c 65 20 61 75 74 68 6f 72 69 7a 65 72 20 ngle authorizer
20a10 63 61 6e 20 62 65 20 69 6e 20 70 6c 61 63 65 20 can be in place
20a20 6f 6e 20 61 20 64 61 74 61 62 61 73 65 20 63 6f on a database co
20a30 6e 6e 65 63 74 69 6f 6e 0a 2a 2a 20 61 74 20 61 nnection.** at a
20a40 20 74 69 6d 65 2e 20 20 45 61 63 68 20 63 61 6c time. Each cal
20a50 6c 20 74 6f 20 73 71 6c 69 74 65 33 5f 73 65 74 l to sqlite3_set
20a60 5f 61 75 74 68 6f 72 69 7a 65 72 20 6f 76 65 72 _authorizer over
20a70 72 69 64 65 73 20 74 68 65 0a 2a 2a 20 70 72 65 rides the.** pre
20a80 76 69 6f 75 73 20 63 61 6c 6c 2e 29 5e 20 20 5e vious call.)^ ^
20a90 44 69 73 61 62 6c 65 20 74 68 65 20 61 75 74 68 Disable the auth
20aa0 6f 72 69 7a 65 72 20 62 79 20 69 6e 73 74 61 6c orizer by instal
20ab0 6c 69 6e 67 20 61 20 4e 55 4c 4c 20 63 61 6c 6c ling a NULL call
20ac0 62 61 63 6b 2e 0a 2a 2a 20 54 68 65 20 61 75 74 back..** The aut
20ad0 68 6f 72 69 7a 65 72 20 69 73 20 64 69 73 61 62 horizer is disab
20ae0 6c 65 64 20 62 79 20 64 65 66 61 75 6c 74 2e 0a led by default..
20af0 2a 2a 0a 2a 2a 20 54 68 65 20 61 75 74 68 6f 72 **.** The author
20b00 69 7a 65 72 20 63 61 6c 6c 62 61 63 6b 20 6d 75 izer callback mu
20b10 73 74 20 6e 6f 74 20 64 6f 20 61 6e 79 74 68 69 st not do anythi
20b20 6e 67 20 74 68 61 74 20 77 69 6c 6c 20 6d 6f 64 ng that will mod
20b30 69 66 79 0a 2a 2a 20 74 68 65 20 64 61 74 61 62 ify.** the datab
20b40 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 74 ase connection t
20b50 68 61 74 20 69 6e 76 6f 6b 65 64 20 74 68 65 20 hat invoked the
20b60 61 75 74 68 6f 72 69 7a 65 72 20 63 61 6c 6c 62 authorizer callb
20b70 61 63 6b 2e 0a 2a 2a 20 4e 6f 74 65 20 74 68 61 ack..** Note tha
20b80 74 20 5b 73 71 6c 69 74 65 33 5f 70 72 65 70 61 t [sqlite3_prepa
20b90 72 65 5f 76 32 28 29 5d 20 61 6e 64 20 5b 73 71 re_v2()] and [sq
20ba0 6c 69 74 65 33 5f 73 74 65 70 28 29 5d 20 62 6f lite3_step()] bo
20bb0 74 68 20 6d 6f 64 69 66 79 20 74 68 65 69 72 0a th modify their.
20bc0 2a 2a 20 64 61 74 61 62 61 73 65 20 63 6f 6e 6e ** database conn
20bd0 65 63 74 69 6f 6e 73 20 66 6f 72 20 74 68 65 20 ections for the
20be0 6d 65 61 6e 69 6e 67 20 6f 66 20 22 6d 6f 64 69 meaning of "modi
20bf0 66 79 22 20 69 6e 20 74 68 69 73 20 70 61 72 61 fy" in this para
20c00 67 72 61 70 68 2e 0a 2a 2a 0a 2a 2a 20 5e 57 68 graph..**.** ^Wh
20c10 65 6e 20 5b 73 71 6c 69 74 65 33 5f 70 72 65 70 en [sqlite3_prep
20c20 61 72 65 5f 76 32 28 29 5d 20 69 73 20 75 73 65 are_v2()] is use
20c30 64 20 74 6f 20 70 72 65 70 61 72 65 20 61 20 73 d to prepare a s
20c40 74 61 74 65 6d 65 6e 74 2c 20 74 68 65 0a 2a 2a tatement, the.**
20c50 20 73 74 61 74 65 6d 65 6e 74 20 6d 69 67 68 74 statement might
20c60 20 62 65 20 72 65 2d 70 72 65 70 61 72 65 64 20 be re-prepared
20c70 64 75 72 69 6e 67 20 5b 73 71 6c 69 74 65 33 5f during [sqlite3_
20c80 73 74 65 70 28 29 5d 20 64 75 65 20 74 6f 20 61 step()] due to a
20c90 20 0a 2a 2a 20 73 63 68 65 6d 61 20 63 68 61 6e .** schema chan
20ca0 67 65 2e 20 20 48 65 6e 63 65 2c 20 74 68 65 20 ge. Hence, the
20cb0 61 70 70 6c 69 63 61 74 69 6f 6e 20 73 68 6f 75 application shou
20cc0 6c 64 20 65 6e 73 75 72 65 20 74 68 61 74 20 74 ld ensure that t
20cd0 68 65 0a 2a 2a 20 63 6f 72 72 65 63 74 20 61 75 he.** correct au
20ce0 74 68 6f 72 69 7a 65 72 20 63 61 6c 6c 62 61 63 thorizer callbac
20cf0 6b 20 72 65 6d 61 69 6e 73 20 69 6e 20 70 6c 61 k remains in pla
20d00 63 65 20 64 75 72 69 6e 67 20 74 68 65 20 5b 73 ce during the [s
20d10 71 6c 69 74 65 33 5f 73 74 65 70 28 29 5d 2e 0a qlite3_step()]..
20d20 2a 2a 0a 2a 2a 20 5e 4e 6f 74 65 20 74 68 61 74 **.** ^Note that
20d30 20 74 68 65 20 61 75 74 68 6f 72 69 7a 65 72 20 the authorizer
20d40 63 61 6c 6c 62 61 63 6b 20 69 73 20 69 6e 76 6f callback is invo
20d50 6b 65 64 20 6f 6e 6c 79 20 64 75 72 69 6e 67 0a ked only during.
20d60 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 70 72 65 70 ** [sqlite3_prep
20d70 61 72 65 28 29 5d 20 6f 72 20 69 74 73 20 76 61 are()] or its va
20d80 72 69 61 6e 74 73 2e 20 20 41 75 74 68 6f 72 69 riants. Authori
20d90 7a 61 74 69 6f 6e 20 69 73 20 6e 6f 74 0a 2a 2a zation is not.**
20da0 20 70 65 72 66 6f 72 6d 65 64 20 64 75 72 69 6e performed durin
20db0 67 20 73 74 61 74 65 6d 65 6e 74 20 65 76 61 6c g statement eval
20dc0 75 61 74 69 6f 6e 20 69 6e 20 5b 73 71 6c 69 74 uation in [sqlit
20dd0 65 33 5f 73 74 65 70 28 29 5d 2c 20 75 6e 6c 65 e3_step()], unle
20de0 73 73 0a 2a 2a 20 61 73 20 73 74 61 74 65 64 20 ss.** as stated
20df0 69 6e 20 74 68 65 20 70 72 65 76 69 6f 75 73 20 in the previous
20e00 70 61 72 61 67 72 61 70 68 2c 20 73 71 6c 69 74 paragraph, sqlit
20e10 65 33 5f 73 74 65 70 28 29 20 69 6e 76 6f 6b 65 e3_step() invoke
20e20 73 0a 2a 2a 20 73 71 6c 69 74 65 33 5f 70 72 65 s.** sqlite3_pre
20e30 70 61 72 65 5f 76 32 28 29 20 74 6f 20 72 65 70 pare_v2() to rep
20e40 72 65 70 61 72 65 20 61 20 73 74 61 74 65 6d 65 repare a stateme
20e50 6e 74 20 61 66 74 65 72 20 61 20 73 63 68 65 6d nt after a schem
20e60 61 20 63 68 61 6e 67 65 2e 0a 2a 2f 0a 69 6e 74 a change..*/.int
20e70 20 73 71 6c 69 74 65 33 5f 73 65 74 5f 61 75 74 sqlite3_set_aut
20e80 68 6f 72 69 7a 65 72 28 0a 20 20 73 71 6c 69 74 horizer(. sqlit
20e90 65 33 2a 2c 0a 20 20 69 6e 74 20 28 2a 78 41 75 e3*,. int (*xAu
20ea0 74 68 29 28 76 6f 69 64 2a 2c 69 6e 74 2c 63 6f th)(void*,int,co
20eb0 6e 73 74 20 63 68 61 72 2a 2c 63 6f 6e 73 74 20 nst char*,const
20ec0 63 68 61 72 2a 2c 63 6f 6e 73 74 20 63 68 61 72 char*,const char
20ed0 2a 2c 63 6f 6e 73 74 20 63 68 61 72 2a 29 2c 0a *,const char*),.
20ee0 20 20 76 6f 69 64 20 2a 70 55 73 65 72 44 61 74 void *pUserDat
20ef0 61 0a 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 a.);../*.** CAPI
20f00 33 52 45 46 3a 20 41 75 74 68 6f 72 69 7a 65 72 3REF: Authorizer
20f10 20 52 65 74 75 72 6e 20 43 6f 64 65 73 0a 2a 2a Return Codes.**
20f20 0a 2a 2a 20 54 68 65 20 5b 73 71 6c 69 74 65 33 .** The [sqlite3
20f30 5f 73 65 74 5f 61 75 74 68 6f 72 69 7a 65 72 20 _set_authorizer
20f40 7c 20 61 75 74 68 6f 72 69 7a 65 72 20 63 61 6c | authorizer cal
20f50 6c 62 61 63 6b 20 66 75 6e 63 74 69 6f 6e 5d 20 lback function]
20f60 6d 75 73 74 0a 2a 2a 20 72 65 74 75 72 6e 20 65 must.** return e
20f70 69 74 68 65 72 20 5b 53 51 4c 49 54 45 5f 4f 4b ither [SQLITE_OK
20f80 5d 20 6f 72 20 6f 6e 65 20 6f 66 20 74 68 65 73 ] or one of thes
20f90 65 20 74 77 6f 20 63 6f 6e 73 74 61 6e 74 73 20 e two constants
20fa0 69 6e 20 6f 72 64 65 72 0a 2a 2a 20 74 6f 20 73 in order.** to s
20fb0 69 67 6e 61 6c 20 53 51 4c 69 74 65 20 77 68 65 ignal SQLite whe
20fc0 74 68 65 72 20 6f 72 20 6e 6f 74 20 74 68 65 20 ther or not the
20fd0 61 63 74 69 6f 6e 20 69 73 20 70 65 72 6d 69 74 action is permit
20fe0 74 65 64 2e 20 20 53 65 65 20 74 68 65 0a 2a 2a ted. See the.**
20ff0 20 5b 73 71 6c 69 74 65 33 5f 73 65 74 5f 61 75 [sqlite3_set_au
21000 74 68 6f 72 69 7a 65 72 20 7c 20 61 75 74 68 6f thorizer | autho
21010 72 69 7a 65 72 20 64 6f 63 75 6d 65 6e 74 61 74 rizer documentat
21020 69 6f 6e 5d 20 66 6f 72 20 61 64 64 69 74 69 6f ion] for additio
21030 6e 61 6c 0a 2a 2a 20 69 6e 66 6f 72 6d 61 74 69 nal.** informati
21040 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 4e 6f 74 65 20 74 on..**.** Note t
21050 68 61 74 20 53 51 4c 49 54 45 5f 49 47 4e 4f 52 hat SQLITE_IGNOR
21060 45 20 69 73 20 61 6c 73 6f 20 75 73 65 64 20 61 E is also used a
21070 73 20 61 20 5b 63 6f 6e 66 6c 69 63 74 20 72 65 s a [conflict re
21080 73 6f 6c 75 74 69 6f 6e 20 6d 6f 64 65 5d 0a 2a solution mode].*
21090 2a 20 72 65 74 75 72 6e 65 64 20 66 72 6f 6d 20 * returned from
210a0 74 68 65 20 5b 73 71 6c 69 74 65 33 5f 76 74 61 the [sqlite3_vta
210b0 62 5f 6f 6e 5f 63 6f 6e 66 6c 69 63 74 28 29 5d b_on_conflict()]
210c0 20 69 6e 74 65 72 66 61 63 65 2e 0a 2a 2f 0a 23 interface..*/.#
210d0 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 44 45 define SQLITE_DE
210e0 4e 59 20 20 20 31 20 20 20 2f 2a 20 41 62 6f 72 NY 1 /* Abor
210f0 74 20 74 68 65 20 53 51 4c 20 73 74 61 74 65 6d t the SQL statem
21100 65 6e 74 20 77 69 74 68 20 61 6e 20 65 72 72 6f ent with an erro
21110 72 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c r */.#define SQL
21120 49 54 45 5f 49 47 4e 4f 52 45 20 32 20 20 20 2f ITE_IGNORE 2 /
21130 2a 20 44 6f 6e 27 74 20 61 6c 6c 6f 77 20 61 63 * Don't allow ac
21140 63 65 73 73 2c 20 62 75 74 20 64 6f 6e 27 74 20 cess, but don't
21150 67 65 6e 65 72 61 74 65 20 61 6e 20 65 72 72 6f generate an erro
21160 72 20 2a 2f 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 r */../*.** CAPI
21170 33 52 45 46 3a 20 41 75 74 68 6f 72 69 7a 65 72 3REF: Authorizer
21180 20 41 63 74 69 6f 6e 20 43 6f 64 65 73 0a 2a 2a Action Codes.**
21190 0a 2a 2a 20 54 68 65 20 5b 73 71 6c 69 74 65 33 .** The [sqlite3
211a0 5f 73 65 74 5f 61 75 74 68 6f 72 69 7a 65 72 28 _set_authorizer(
211b0 29 5d 20 69 6e 74 65 72 66 61 63 65 20 72 65 67 )] interface reg
211c0 69 73 74 65 72 73 20 61 20 63 61 6c 6c 62 61 63 isters a callbac
211d0 6b 20 66 75 6e 63 74 69 6f 6e 0a 2a 2a 20 74 68 k function.** th
211e0 61 74 20 69 73 20 69 6e 76 6f 6b 65 64 20 74 6f at is invoked to
211f0 20 61 75 74 68 6f 72 69 7a 65 20 63 65 72 74 61 authorize certa
21200 69 6e 20 53 51 4c 20 73 74 61 74 65 6d 65 6e 74 in SQL statement
21210 20 61 63 74 69 6f 6e 73 2e 20 20 54 68 65 0a 2a actions. The.*
21220 2a 20 73 65 63 6f 6e 64 20 70 61 72 61 6d 65 74 * second paramet
21230 65 72 20 74 6f 20 74 68 65 20 63 61 6c 6c 62 61 er to the callba
21240 63 6b 20 69 73 20 61 6e 20 69 6e 74 65 67 65 72 ck is an integer
21250 20 63 6f 64 65 20 74 68 61 74 20 73 70 65 63 69 code that speci
21260 66 69 65 73 0a 2a 2a 20 77 68 61 74 20 61 63 74 fies.** what act
21270 69 6f 6e 20 69 73 20 62 65 69 6e 67 20 61 75 74 ion is being aut
21280 68 6f 72 69 7a 65 64 2e 20 20 54 68 65 73 65 20 horized. These
21290 61 72 65 20 74 68 65 20 69 6e 74 65 67 65 72 20 are the integer
212a0 61 63 74 69 6f 6e 20 63 6f 64 65 73 20 74 68 61 action codes tha
212b0 74 0a 2a 2a 20 74 68 65 20 61 75 74 68 6f 72 69 t.** the authori
212c0 7a 65 72 20 63 61 6c 6c 62 61 63 6b 20 6d 61 79 zer callback may
212d0 20 62 65 20 70 61 73 73 65 64 2e 0a 2a 2a 0a 2a be passed..**.*
212e0 2a 20 54 68 65 73 65 20 61 63 74 69 6f 6e 20 63 * These action c
212f0 6f 64 65 20 76 61 6c 75 65 73 20 73 69 67 6e 69 ode values signi
21300 66 79 20 77 68 61 74 20 6b 69 6e 64 20 6f 66 20 fy what kind of
21310 6f 70 65 72 61 74 69 6f 6e 20 69 73 20 74 6f 20 operation is to
21320 62 65 0a 2a 2a 20 61 75 74 68 6f 72 69 7a 65 64 be.** authorized
21330 2e 20 20 54 68 65 20 33 72 64 20 61 6e 64 20 34 . The 3rd and 4
21340 74 68 20 70 61 72 61 6d 65 74 65 72 73 20 74 6f th parameters to
21350 20 74 68 65 20 61 75 74 68 6f 72 69 7a 61 74 69 the authorizati
21360 6f 6e 0a 2a 2a 20 63 61 6c 6c 62 61 63 6b 20 66 on.** callback f
21370 75 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 62 65 20 unction will be
21380 70 61 72 61 6d 65 74 65 72 73 20 6f 72 20 4e 55 parameters or NU
21390 4c 4c 20 64 65 70 65 6e 64 69 6e 67 20 6f 6e 20 LL depending on
213a0 77 68 69 63 68 20 6f 66 20 74 68 65 73 65 0a 2a which of these.*
213b0 2a 20 63 6f 64 65 73 20 69 73 20 75 73 65 64 20 * codes is used
213c0 61 73 20 74 68 65 20 73 65 63 6f 6e 64 20 70 61 as the second pa
213d0 72 61 6d 65 74 65 72 2e 20 20 5e 28 54 68 65 20 rameter. ^(The
213e0 35 74 68 20 70 61 72 61 6d 65 74 65 72 20 74 6f 5th parameter to
213f0 20 74 68 65 0a 2a 2a 20 61 75 74 68 6f 72 69 7a the.** authoriz
21400 65 72 20 63 61 6c 6c 62 61 63 6b 20 69 73 20 74 er callback is t
21410 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 64 he name of the d
21420 61 74 61 62 61 73 65 20 28 22 6d 61 69 6e 22 2c atabase ("main",
21430 20 22 74 65 6d 70 22 2c 0a 2a 2a 20 65 74 63 2e "temp",.** etc.
21440 29 20 69 66 20 61 70 70 6c 69 63 61 62 6c 65 2e ) if applicable.
21450 29 5e 20 20 5e 54 68 65 20 36 74 68 20 70 61 72 )^ ^The 6th par
21460 61 6d 65 74 65 72 20 74 6f 20 74 68 65 20 61 75 ameter to the au
21470 74 68 6f 72 69 7a 65 72 20 63 61 6c 6c 62 61 63 thorizer callbac
21480 6b 0a 2a 2a 20 69 73 20 74 68 65 20 6e 61 6d 65 k.** is the name
21490 20 6f 66 20 74 68 65 20 69 6e 6e 65 72 2d 6d 6f of the inner-mo
214a0 73 74 20 74 72 69 67 67 65 72 20 6f 72 20 76 69 st trigger or vi
214b0 65 77 20 74 68 61 74 20 69 73 20 72 65 73 70 6f ew that is respo
214c0 6e 73 69 62 6c 65 20 66 6f 72 0a 2a 2a 20 74 68 nsible for.** th
214d0 65 20 61 63 63 65 73 73 20 61 74 74 65 6d 70 74 e access attempt
214e0 20 6f 72 20 4e 55 4c 4c 20 69 66 20 74 68 69 73 or NULL if this
214f0 20 61 63 63 65 73 73 20 61 74 74 65 6d 70 74 20 access attempt
21500 69 73 20 64 69 72 65 63 74 6c 79 20 66 72 6f 6d is directly from
21510 0a 2a 2a 20 74 6f 70 2d 6c 65 76 65 6c 20 53 51 .** top-level SQ
21520 4c 20 63 6f 64 65 2e 0a 2a 2f 0a 2f 2a 2a 2a 2a L code..*/./****
21530 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
21540 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
21550 2a 2a 2a 2a 2a 2a 2a 20 33 72 64 20 2a 2a 2a 2a ******* 3rd ****
21560 2a 2a 2a 2a 2a 2a 2a 2a 20 34 74 68 20 2a 2a 2a ******** 4th ***
21570 2a 2a 2a 2a 2a 2a 2a 2a 2f 0a 23 64 65 66 69 6e ********/.#defin
21580 65 20 53 51 4c 49 54 45 5f 43 52 45 41 54 45 5f e SQLITE_CREATE_
21590 49 4e 44 45 58 20 20 20 20 20 20 20 20 20 20 31 INDEX 1
215a0 20 20 20 2f 2a 20 49 6e 64 65 78 20 4e 61 6d 65 /* Index Name
215b0 20 20 20 20 20 20 54 61 62 6c 65 20 4e 61 6d 65 Table Name
215c0 20 20 20 20 20 20 2a 2f 0a 23 64 65 66 69 6e 65 */.#define
215d0 20 53 51 4c 49 54 45 5f 43 52 45 41 54 45 5f 54 SQLITE_CREATE_T
215e0 41 42 4c 45 20 20 20 20 20 20 20 20 20 20 32 20 ABLE 2
215f0 20 20 2f 2a 20 54 61 62 6c 65 20 4e 61 6d 65 20 /* Table Name
21600 20 20 20 20 20 4e 55 4c 4c 20 20 20 20 20 20 20 NULL
21610 20 20 20 20 20 2a 2f 0a 23 64 65 66 69 6e 65 20 */.#define
21620 53 51 4c 49 54 45 5f 43 52 45 41 54 45 5f 54 45 SQLITE_CREATE_TE
21630 4d 50 5f 49 4e 44 45 58 20 20 20 20 20 33 20 20 MP_INDEX 3
21640 20 2f 2a 20 49 6e 64 65 78 20 4e 61 6d 65 20 20 /* Index Name
21650 20 20 20 20 54 61 62 6c 65 20 4e 61 6d 65 20 20 Table Name
21660 20 20 20 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 */.#define S
21670 51 4c 49 54 45 5f 43 52 45 41 54 45 5f 54 45 4d QLITE_CREATE_TEM
21680 50 5f 54 41 42 4c 45 20 20 20 20 20 34 20 20 20 P_TABLE 4
21690 2f 2a 20 54 61 62 6c 65 20 4e 61 6d 65 20 20 20 /* Table Name
216a0 20 20 20 4e 55 4c 4c 20 20 20 20 20 20 20 20 20 NULL
216b0 20 20 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 */.#define SQ
216c0 4c 49 54 45 5f 43 52 45 41 54 45 5f 54 45 4d 50 LITE_CREATE_TEMP
216d0 5f 54 52 49 47 47 45 52 20 20 20 35 20 20 20 2f _TRIGGER 5 /
216e0 2a 20 54 72 69 67 67 65 72 20 4e 61 6d 65 20 20 * Trigger Name
216f0 20 20 54 61 62 6c 65 20 4e 61 6d 65 20 20 20 20 Table Name
21700 20 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c */.#define SQL
21710 49 54 45 5f 43 52 45 41 54 45 5f 54 45 4d 50 5f ITE_CREATE_TEMP_
21720 56 49 45 57 20 20 20 20 20 20 36 20 20 20 2f 2a VIEW 6 /*
21730 20 56 69 65 77 20 4e 61 6d 65 20 20 20 20 20 20 View Name
21740 20 4e 55 4c 4c 20 20 20 20 20 20 20 20 20 20 20 NULL
21750 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 */.#define SQLI
21760 54 45 5f 43 52 45 41 54 45 5f 54 52 49 47 47 45 TE_CREATE_TRIGGE
21770 52 20 20 20 20 20 20 20 20 37 20 20 20 2f 2a 20 R 7 /*
21780 54 72 69 67 67 65 72 20 4e 61 6d 65 20 20 20 20 Trigger Name
21790 54 61 62 6c 65 20 4e 61 6d 65 20 20 20 20 20 20 Table Name
217a0 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 */.#define SQLIT
217b0 45 5f 43 52 45 41 54 45 5f 56 49 45 57 20 20 20 E_CREATE_VIEW
217c0 20 20 20 20 20 20 20 20 38 20 20 20 2f 2a 20 56 8 /* V
217d0 69 65 77 20 4e 61 6d 65 20 20 20 20 20 20 20 4e iew Name N
217e0 55 4c 4c 20 20 20 20 20 20 20 20 20 20 20 20 2a ULL *
217f0 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 /.#define SQLITE
21800 5f 44 45 4c 45 54 45 20 20 20 20 20 20 20 20 20 _DELETE
21810 20 20 20 20 20 20 20 39 20 20 20 2f 2a 20 54 61 9 /* Ta
21820 62 6c 65 20 4e 61 6d 65 20 20 20 20 20 20 4e 55 ble Name NU
21830 4c 4c 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f LL */
21840 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f .#define SQLITE_
21850 44 52 4f 50 5f 49 4e 44 45 58 20 20 20 20 20 20 DROP_INDEX
21860 20 20 20 20 20 31 30 20 20 20 2f 2a 20 49 6e 64 10 /* Ind
21870 65 78 20 4e 61 6d 65 20 20 20 20 20 20 54 61 62 ex Name Tab
21880 6c 65 20 4e 61 6d 65 20 20 20 20 20 20 2a 2f 0a le Name */.
21890 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 44 #define SQLITE_D
218a0 52 4f 50 5f 54 41 42 4c 45 20 20 20 20 20 20 20 ROP_TABLE
218b0 20 20 20 20 31 31 20 20 20 2f 2a 20 54 61 62 6c 11 /* Tabl
218c0 65 20 4e 61 6d 65 20 20 20 20 20 20 4e 55 4c 4c e Name NULL
218d0 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 23 */.#
218e0 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 44 52 define SQLITE_DR
218f0 4f 50 5f 54 45 4d 50 5f 49 4e 44 45 58 20 20 20 OP_TEMP_INDEX
21900 20 20 20 31 32 20 20 20 2f 2a 20 49 6e 64 65 78 12 /* Index
21910 20 4e 61 6d 65 20 20 20 20 20 20 54 61 62 6c 65 Name Table
21920 20 4e 61 6d 65 20 20 20 20 20 20 2a 2f 0a 23 64 Name */.#d
21930 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 44 52 4f efine SQLITE_DRO
21940 50 5f 54 45 4d 50 5f 54 41 42 4c 45 20 20 20 20 P_TEMP_TABLE
21950 20 20 31 33 20 20 20 2f 2a 20 54 61 62 6c 65 20 13 /* Table
21960 4e 61 6d 65 20 20 20 20 20 20 4e 55 4c 4c 20 20 Name NULL
21970 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 23 64 65 */.#de
21980 66 69 6e 65 20 53 51 4c 49 54 45 5f 44 52 4f 50 fine SQLITE_DROP
21990 5f 54 45 4d 50 5f 54 52 49 47 47 45 52 20 20 20 _TEMP_TRIGGER
219a0 20 31 34 20 20 20 2f 2a 20 54 72 69 67 67 65 72 14 /* Trigger
219b0 20 4e 61 6d 65 20 20 20 20 54 61 62 6c 65 20 4e Name Table N
219c0 61 6d 65 20 20 20 20 20 20 2a 2f 0a 23 64 65 66 ame */.#def
219d0 69 6e 65 20 53 51 4c 49 54 45 5f 44 52 4f 50 5f ine SQLITE_DROP_
219e0 54 45 4d 50 5f 56 49 45 57 20 20 20 20 20 20 20 TEMP_VIEW
219f0 31 35 20 20 20 2f 2a 20 56 69 65 77 20 4e 61 6d 15 /* View Nam
21a00 65 20 20 20 20 20 20 20 4e 55 4c 4c 20 20 20 20 e NULL
21a10 20 20 20 20 20 20 20 20 2a 2f 0a 23 64 65 66 69 */.#defi
21a20 6e 65 20 53 51 4c 49 54 45 5f 44 52 4f 50 5f 54 ne SQLITE_DROP_T
21a30 52 49 47 47 45 52 20 20 20 20 20 20 20 20 20 31 RIGGER 1
21a40 36 20 20 20 2f 2a 20 54 72 69 67 67 65 72 20 4e 6 /* Trigger N
21a50 61 6d 65 20 20 20 20 54 61 62 6c 65 20 4e 61 6d ame Table Nam
21a60 65 20 20 20 20 20 20 2a 2f 0a 23 64 65 66 69 6e e */.#defin
21a70 65 20 53 51 4c 49 54 45 5f 44 52 4f 50 5f 56 49 e SQLITE_DROP_VI
21a80 45 57 20 20 20 20 20 20 20 20 20 20 20 20 31 37 EW 17
21a90 20 20 20 2f 2a 20 56 69 65 77 20 4e 61 6d 65 20 /* View Name
21aa0 20 20 20 20 20 20 4e 55 4c 4c 20 20 20 20 20 20 NULL
21ab0 20 20 20 20 20 20 2a 2f 0a 23 64 65 66 69 6e 65 */.#define
21ac0 20 53 51 4c 49 54 45 5f 49 4e 53 45 52 54 20 20 SQLITE_INSERT
21ad0 20 20 20 20 20 20 20 20 20 20 20 20 20 31 38 20 18
21ae0 20 20 2f 2a 20 54 61 62 6c 65 20 4e 61 6d 65 20 /* Table Name
21af0 20 20 20 20 20 4e 55 4c 4c 20 20 20 20 20 20 20 NULL
21b00 20 20 20 20 20 2a 2f 0a 23 64 65 66 69 6e 65 20 */.#define
21b10 53 51 4c 49 54 45 5f 50 52 41 47 4d 41 20 20 20 SQLITE_PRAGMA
21b20 20 20 20 20 20 20 20 20 20 20 20 20 31 39 20 20 19
21b30 20 2f 2a 20 50 72 61 67 6d 61 20 4e 61 6d 65 20 /* Pragma Name
21b40 20 20 20 20 31 73 74 20 61 72 67 20 6f 72 20 4e 1st arg or N
21b50 55 4c 4c 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 ULL */.#define S
21b60 51 4c 49 54 45 5f 52 45 41 44 20 20 20 20 20 20 QLITE_READ
21b70 20 20 20 20 20 20 20 20 20 20 20 32 30 20 20 20 20
21b80 2f 2a 20 54 61 62 6c 65 20 4e 61 6d 65 20 20 20 /* Table Name
21b90 20 20 20 43 6f 6c 75 6d 6e 20 4e 61 6d 65 20 20 Column Name
21ba0 20 20 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 */.#define SQ
21bb0 4c 49 54 45 5f 53 45 4c 45 43 54 20 20 20 20 20 LITE_SELECT
21bc0 20 20 20 20 20 20 20 20 20 20 32 31 20 20 20 2f 21 /
21bd0 2a 20 4e 55 4c 4c 20 20 20 20 20 20 20 20 20 20 * NULL
21be0 20 20 4e 55 4c 4c 20 20 20 20 20 20 20 20 20 20 NULL
21bf0 20 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c */.#define SQL
21c00 49 54 45 5f 54 52 41 4e 53 41 43 54 49 4f 4e 20 ITE_TRANSACTION
21c10 20 20 20 20 20 20 20 20 20 32 32 20 20 20 2f 2a 22 /*
21c20 20 4f 70 65 72 61 74 69 6f 6e 20 20 20 20 20 20 Operation
21c30 20 4e 55 4c 4c 20 20 20 20 20 20 20 20 20 20 20 NULL
21c40 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 */.#define SQLI
21c50 54 45 5f 55 50 44 41 54 45 20 20 20 20 20 20 20 TE_UPDATE
21c60 20 20 20 20 20 20 20 20 32 33 20 20 20 2f 2a 20 23 /*
21c70 54 61 62 6c 65 20 4e 61 6d 65 20 20 20 20 20 20 Table Name
21c80 43 6f 6c 75 6d 6e 20 4e 61 6d 65 20 20 20 20 20 Column Name
21c90 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 */.#define SQLIT
21ca0 45 5f 41 54 54 41 43 48 20 20 20 20 20 20 20 20 E_ATTACH
21cb0 20 20 20 20 20 20 20 32 34 20 20 20 2f 2a 20 46 24 /* F
21cc0 69 6c 65 6e 61 6d 65 20 20 20 20 20 20 20 20 4e ilename N
21cd0 55 4c 4c 20 20 20 20 20 20 20 20 20 20 20 20 2a ULL *
21ce0 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 /.#define SQLITE
21cf0 5f 44 45 54 41 43 48 20 20 20 20 20 20 20 20 20 _DETACH
21d00 20 20 20 20 20 20 32 35 20 20 20 2f 2a 20 44 61 25 /* Da
21d10 74 61 62 61 73 65 20 4e 61 6d 65 20 20 20 4e 55 tabase Name NU
21d20 4c 4c 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f LL */
21d30 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f .#define SQLITE_
21d40 41 4c 54 45 52 5f 54 41 42 4c 45 20 20 20 20 20 ALTER_TABLE
21d50 20 20 20 20 20 32 36 20 20 20 2f 2a 20 44 61 74 26 /* Dat
21d60 61 62 61 73 65 20 4e 61 6d 65 20 20 20 54 61 62 abase Name Tab
21d70 6c 65 20 4e 61 6d 65 20 20 20 20 20 20 2a 2f 0a le Name */.
21d80 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 52 #define SQLITE_R
21d90 45 49 4e 44 45 58 20 20 20 20 20 20 20 20 20 20 EINDEX
21da0 20 20 20 20 32 37 20 20 20 2f 2a 20 49 6e 64 65 27 /* Inde
21db0 78 20 4e 61 6d 65 20 20 20 20 20 20 4e 55 4c 4c x Name NULL
21dc0 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 23 */.#
21dd0 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 41 4e define SQLITE_AN
21de0 41 4c 59 5a 45 20 20 20 20 20 20 20 20 20 20 20 ALYZE
21df0 20 20 20 32 38 20 20 20 2f 2a 20 54 61 62 6c 65 28 /* Table
21e00 20 4e 61 6d 65 20 20 20 20 20 20 4e 55 4c 4c 20 Name NULL
21e10 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 23 64 */.#d
21e20 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 43 52 45 efine SQLITE_CRE
21e30 41 54 45 5f 56 54 41 42 4c 45 20 20 20 20 20 20 ATE_VTABLE
21e40 20 20 32 39 20 20 20 2f 2a 20 54 61 62 6c 65 20 29 /* Table
21e50 4e 61 6d 65 20 20 20 20 20 20 4d 6f 64 75 6c 65 Name Module
21e60 20 4e 61 6d 65 20 20 20 20 20 2a 2f 0a 23 64 65 Name */.#de
21e70 66 69 6e 65 20 53 51 4c 49 54 45 5f 44 52 4f 50 fine SQLITE_DROP
21e80 5f 56 54 41 42 4c 45 20 20 20 20 20 20 20 20 20 _VTABLE
21e90 20 33 30 20 20 20 2f 2a 20 54 61 62 6c 65 20 4e 30 /* Table N
21ea0 61 6d 65 20 20 20 20 20 20 4d 6f 64 75 6c 65 20 ame Module
21eb0 4e 61 6d 65 20 20 20 20 20 2a 2f 0a 23 64 65 66 Name */.#def
21ec0 69 6e 65 20 53 51 4c 49 54 45 5f 46 55 4e 43 54 ine SQLITE_FUNCT
21ed0 49 4f 4e 20 20 20 20 20 20 20 20 20 20 20 20 20 ION
21ee0 33 31 20 20 20 2f 2a 20 4e 55 4c 4c 20 20 20 20 31 /* NULL
21ef0 20 20 20 20 20 20 20 20 46 75 6e 63 74 69 6f 6e Function
21f00 20 4e 61 6d 65 20 20 20 2a 2f 0a 23 64 65 66 69 Name */.#defi
21f10 6e 65 20 53 51 4c 49 54 45 5f 53 41 56 45 50 4f ne SQLITE_SAVEPO
21f20 49 4e 54 20 20 20 20 20 20 20 20 20 20 20 20 33 INT 3
21f30 32 20 20 20 2f 2a 20 4f 70 65 72 61 74 69 6f 6e 2 /* Operation
21f40 20 20 20 20 20 20 20 53 61 76 65 70 6f 69 6e 74 Savepoint
21f50 20 4e 61 6d 65 20 20 2a 2f 0a 23 64 65 66 69 6e Name */.#defin
21f60 65 20 53 51 4c 49 54 45 5f 43 4f 50 59 20 20 20 e SQLITE_COPY
21f70 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 30 0
21f80 20 20 20 2f 2a 20 4e 6f 20 6c 6f 6e 67 65 72 20 /* No longer
21f90 75 73 65 64 20 2a 2f 0a 23 64 65 66 69 6e 65 20 used */.#define
21fa0 53 51 4c 49 54 45 5f 52 45 43 55 52 53 49 56 45 SQLITE_RECURSIVE
21fb0 20 20 20 20 20 20 20 20 20 20 20 20 33 33 20 20 33
21fc0 20 2f 2a 20 4e 55 4c 4c 20 20 20 20 20 20 20 20 /* NULL
21fd0 20 20 20 20 4e 55 4c 4c 20 20 20 20 20 20 20 20 NULL
21fe0 20 20 20 20 2a 2f 0a 0a 2f 2a 0a 2a 2a 20 43 41 */../*.** CA
21ff0 50 49 33 52 45 46 3a 20 54 72 61 63 69 6e 67 20 PI3REF: Tracing
22000 41 6e 64 20 50 72 6f 66 69 6c 69 6e 67 20 46 75 And Profiling Fu
22010 6e 63 74 69 6f 6e 73 0a 2a 2a 20 4d 45 54 48 4f nctions.** METHO
22020 44 3a 20 73 71 6c 69 74 65 33 0a 2a 2a 0a 2a 2a D: sqlite3.**.**
22030 20 54 68 65 73 65 20 72 6f 75 74 69 6e 65 73 20 These routines
22040 61 72 65 20 64 65 70 72 65 63 61 74 65 64 2e 20 are deprecated.
22050 55 73 65 20 74 68 65 20 5b 73 71 6c 69 74 65 33 Use the [sqlite3
22060 5f 74 72 61 63 65 5f 76 32 28 29 5d 20 69 6e 74 _trace_v2()] int
22070 65 72 66 61 63 65 0a 2a 2a 20 69 6e 73 74 65 61 erface.** instea
22080 64 20 6f 66 20 74 68 65 20 72 6f 75 74 69 6e 65 d of the routine
22090 73 20 64 65 73 63 72 69 62 65 64 20 68 65 72 65 s described here
220a0 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 73 65 20 72 6f ..**.** These ro
220b0 75 74 69 6e 65 73 20 72 65 67 69 73 74 65 72 20 utines register
220c0 63 61 6c 6c 62 61 63 6b 20 66 75 6e 63 74 69 6f callback functio
220d0 6e 73 20 74 68 61 74 20 63 61 6e 20 62 65 20 75 ns that can be u
220e0 73 65 64 20 66 6f 72 0a 2a 2a 20 74 72 61 63 69 sed for.** traci
220f0 6e 67 20 61 6e 64 20 70 72 6f 66 69 6c 69 6e 67 ng and profiling
22100 20 74 68 65 20 65 78 65 63 75 74 69 6f 6e 20 6f the execution o
22110 66 20 53 51 4c 20 73 74 61 74 65 6d 65 6e 74 73 f SQL statements
22120 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 63 61 6c ..**.** ^The cal
22130 6c 62 61 63 6b 20 66 75 6e 63 74 69 6f 6e 20 72 lback function r
22140 65 67 69 73 74 65 72 65 64 20 62 79 20 73 71 6c egistered by sql
22150 69 74 65 33 5f 74 72 61 63 65 28 29 20 69 73 20 ite3_trace() is
22160 69 6e 76 6f 6b 65 64 20 61 74 0a 2a 2a 20 76 61 invoked at.** va
22170 72 69 6f 75 73 20 74 69 6d 65 73 20 77 68 65 6e rious times when
22180 20 61 6e 20 53 51 4c 20 73 74 61 74 65 6d 65 6e an SQL statemen
22190 74 20 69 73 20 62 65 69 6e 67 20 72 75 6e 20 62 t is being run b
221a0 79 20 5b 73 71 6c 69 74 65 33 5f 73 74 65 70 28 y [sqlite3_step(
221b0 29 5d 2e 0a 2a 2a 20 5e 54 68 65 20 73 71 6c 69 )]..** ^The sqli
221c0 74 65 33 5f 74 72 61 63 65 28 29 20 63 61 6c 6c te3_trace() call
221d0 62 61 63 6b 20 69 73 20 69 6e 76 6f 6b 65 64 20 back is invoked
221e0 77 69 74 68 20 61 20 55 54 46 2d 38 20 72 65 6e with a UTF-8 ren
221f0 64 65 72 69 6e 67 20 6f 66 20 74 68 65 0a 2a 2a dering of the.**
22200 20 53 51 4c 20 73 74 61 74 65 6d 65 6e 74 20 74 SQL statement t
22210 65 78 74 20 61 73 20 74 68 65 20 73 74 61 74 65 ext as the state
22220 6d 65 6e 74 20 66 69 72 73 74 20 62 65 67 69 6e ment first begin
22230 73 20 65 78 65 63 75 74 69 6e 67 2e 0a 2a 2a 20 s executing..**
22240 5e 28 41 64 64 69 74 69 6f 6e 61 6c 20 73 71 6c ^(Additional sql
22250 69 74 65 33 5f 74 72 61 63 65 28 29 20 63 61 6c ite3_trace() cal
22260 6c 62 61 63 6b 73 20 6d 69 67 68 74 20 6f 63 63 lbacks might occ
22270 75 72 0a 2a 2a 20 61 73 20 65 61 63 68 20 74 72 ur.** as each tr
22280 69 67 67 65 72 65 64 20 73 75 62 70 72 6f 67 72 iggered subprogr
22290 61 6d 20 69 73 20 65 6e 74 65 72 65 64 2e 20 20 am is entered.
222a0 54 68 65 20 63 61 6c 6c 62 61 63 6b 73 20 66 6f The callbacks fo
222b0 72 20 74 72 69 67 67 65 72 73 0a 2a 2a 20 63 6f r triggers.** co
222c0 6e 74 61 69 6e 20 61 20 55 54 46 2d 38 20 53 51 ntain a UTF-8 SQ
222d0 4c 20 63 6f 6d 6d 65 6e 74 20 74 68 61 74 20 69 L comment that i
222e0 64 65 6e 74 69 66 69 65 73 20 74 68 65 20 74 72 dentifies the tr
222f0 69 67 67 65 72 2e 29 5e 0a 2a 2a 0a 2a 2a 20 54 igger.)^.**.** T
22300 68 65 20 5b 53 51 4c 49 54 45 5f 54 52 41 43 45 he [SQLITE_TRACE
22310 5f 53 49 5a 45 5f 4c 49 4d 49 54 5d 20 63 6f 6d _SIZE_LIMIT] com
22320 70 69 6c 65 2d 74 69 6d 65 20 6f 70 74 69 6f 6e pile-time option
22330 20 63 61 6e 20 62 65 20 75 73 65 64 20 74 6f 20 can be used to
22340 6c 69 6d 69 74 0a 2a 2a 20 74 68 65 20 6c 65 6e limit.** the len
22350 67 74 68 20 6f 66 20 5b 62 6f 75 6e 64 20 70 61 gth of [bound pa
22360 72 61 6d 65 74 65 72 5d 20 65 78 70 61 6e 73 69 rameter] expansi
22370 6f 6e 20 69 6e 20 74 68 65 20 6f 75 74 70 75 74 on in the output
22380 20 6f 66 20 73 71 6c 69 74 65 33 5f 74 72 61 63 of sqlite3_trac
22390 65 28 29 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 e()..**.** ^The
223a0 63 61 6c 6c 62 61 63 6b 20 66 75 6e 63 74 69 6f callback functio
223b0 6e 20 72 65 67 69 73 74 65 72 65 64 20 62 79 20 n registered by
223c0 73 71 6c 69 74 65 33 5f 70 72 6f 66 69 6c 65 28 sqlite3_profile(
223d0 29 20 69 73 20 69 6e 76 6f 6b 65 64 0a 2a 2a 20 ) is invoked.**
223e0 61 73 20 65 61 63 68 20 53 51 4c 20 73 74 61 74 as each SQL stat
223f0 65 6d 65 6e 74 20 66 69 6e 69 73 68 65 73 2e 20 ement finishes.
22400 20 5e 54 68 65 20 70 72 6f 66 69 6c 65 20 63 61 ^The profile ca
22410 6c 6c 62 61 63 6b 20 63 6f 6e 74 61 69 6e 73 0a llback contains.
22420 2a 2a 20 74 68 65 20 6f 72 69 67 69 6e 61 6c 20 ** the original
22430 73 74 61 74 65 6d 65 6e 74 20 74 65 78 74 20 61 statement text a
22440 6e 64 20 61 6e 20 65 73 74 69 6d 61 74 65 20 6f nd an estimate o
22450 66 20 77 61 6c 6c 2d 63 6c 6f 63 6b 20 74 69 6d f wall-clock tim
22460 65 0a 2a 2a 20 6f 66 20 68 6f 77 20 6c 6f 6e 67 e.** of how long
22470 20 74 68 61 74 20 73 74 61 74 65 6d 65 6e 74 20 that statement
22480 74 6f 6f 6b 20 74 6f 20 72 75 6e 2e 20 20 5e 54 took to run. ^T
22490 68 65 20 70 72 6f 66 69 6c 65 20 63 61 6c 6c 62 he profile callb
224a0 61 63 6b 0a 2a 2a 20 74 69 6d 65 20 69 73 20 69 ack.** time is i
224b0 6e 20 75 6e 69 74 73 20 6f 66 20 6e 61 6e 6f 73 n units of nanos
224c0 65 63 6f 6e 64 73 2c 20 68 6f 77 65 76 65 72 20 econds, however
224d0 74 68 65 20 63 75 72 72 65 6e 74 20 69 6d 70 6c the current impl
224e0 65 6d 65 6e 74 61 74 69 6f 6e 0a 2a 2a 20 69 73 ementation.** is
224f0 20 6f 6e 6c 79 20 63 61 70 61 62 6c 65 20 6f 66 only capable of
22500 20 6d 69 6c 6c 69 73 65 63 6f 6e 64 20 72 65 73 millisecond res
22510 6f 6c 75 74 69 6f 6e 20 73 6f 20 74 68 65 20 73 olution so the s
22520 69 78 20 6c 65 61 73 74 20 73 69 67 6e 69 66 69 ix least signifi
22530 63 61 6e 74 0a 2a 2a 20 64 69 67 69 74 73 20 69 cant.** digits i
22540 6e 20 74 68 65 20 74 69 6d 65 20 61 72 65 20 6d n the time are m
22550 65 61 6e 69 6e 67 6c 65 73 73 2e 20 20 46 75 74 eaningless. Fut
22560 75 72 65 20 76 65 72 73 69 6f 6e 73 20 6f 66 20 ure versions of
22570 53 51 4c 69 74 65 0a 2a 2a 20 6d 69 67 68 74 20 SQLite.** might
22580 70 72 6f 76 69 64 65 20 67 72 65 61 74 65 72 20 provide greater
22590 72 65 73 6f 6c 75 74 69 6f 6e 20 6f 6e 20 74 68 resolution on th
225a0 65 20 70 72 6f 66 69 6c 65 72 20 63 61 6c 6c 62 e profiler callb
225b0 61 63 6b 2e 20 20 54 68 65 0a 2a 2a 20 73 71 6c ack. The.** sql
225c0 69 74 65 33 5f 70 72 6f 66 69 6c 65 28 29 20 66 ite3_profile() f
225d0 75 6e 63 74 69 6f 6e 20 69 73 20 63 6f 6e 73 69 unction is consi
225e0 64 65 72 65 64 20 65 78 70 65 72 69 6d 65 6e 74 dered experiment
225f0 61 6c 20 61 6e 64 20 69 73 0a 2a 2a 20 73 75 62 al and is.** sub
22600 6a 65 63 74 20 74 6f 20 63 68 61 6e 67 65 20 69 ject to change i
22610 6e 20 66 75 74 75 72 65 20 76 65 72 73 69 6f 6e n future version
22620 73 20 6f 66 20 53 51 4c 69 74 65 2e 0a 2a 2f 0a s of SQLite..*/.
22630 53 51 4c 49 54 45 5f 44 45 50 52 45 43 41 54 45 SQLITE_DEPRECATE
22640 44 20 76 6f 69 64 20 2a 73 71 6c 69 74 65 33 5f D void *sqlite3_
22650 74 72 61 63 65 28 73 71 6c 69 74 65 33 2a 2c 0a trace(sqlite3*,.
22660 20 20 20 76 6f 69 64 28 2a 78 54 72 61 63 65 29 void(*xTrace)
22670 28 76 6f 69 64 2a 2c 63 6f 6e 73 74 20 63 68 61 (void*,const cha
22680 72 2a 29 2c 20 76 6f 69 64 2a 29 3b 0a 53 51 4c r*), void*);.SQL
22690 49 54 45 5f 44 45 50 52 45 43 41 54 45 44 20 76 ITE_DEPRECATED v
226a0 6f 69 64 20 2a 73 71 6c 69 74 65 33 5f 70 72 6f oid *sqlite3_pro
226b0 66 69 6c 65 28 73 71 6c 69 74 65 33 2a 2c 0a 20 file(sqlite3*,.
226c0 20 20 76 6f 69 64 28 2a 78 50 72 6f 66 69 6c 65 void(*xProfile
226d0 29 28 76 6f 69 64 2a 2c 63 6f 6e 73 74 20 63 68 )(void*,const ch
226e0 61 72 2a 2c 73 71 6c 69 74 65 33 5f 75 69 6e 74 ar*,sqlite3_uint
226f0 36 34 29 2c 20 76 6f 69 64 2a 29 3b 0a 0a 2f 2a 64), void*);../*
22700 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 53 51 .** CAPI3REF: SQ
22710 4c 20 54 72 61 63 65 20 45 76 65 6e 74 20 43 6f L Trace Event Co
22720 64 65 73 0a 2a 2a 20 4b 45 59 57 4f 52 44 53 3a des.** KEYWORDS:
22730 20 53 51 4c 49 54 45 5f 54 52 41 43 45 0a 2a 2a SQLITE_TRACE.**
22740 0a 2a 2a 20 54 68 65 73 65 20 63 6f 6e 73 74 61 .** These consta
22750 6e 74 73 20 69 64 65 6e 74 69 66 79 20 63 6c 61 nts identify cla
22760 73 73 65 73 20 6f 66 20 65 76 65 6e 74 73 20 74 sses of events t
22770 68 61 74 20 63 61 6e 20 62 65 20 6d 6f 6e 69 74 hat can be monit
22780 6f 72 65 64 0a 2a 2a 20 75 73 69 6e 67 20 74 68 ored.** using th
22790 65 20 5b 73 71 6c 69 74 65 33 5f 74 72 61 63 65 e [sqlite3_trace
227a0 5f 76 32 28 29 5d 20 74 72 61 63 69 6e 67 20 6c _v2()] tracing l
227b0 6f 67 69 63 2e 20 20 54 68 65 20 74 68 69 72 64 ogic. The third
227c0 20 61 72 67 75 6d 65 6e 74 0a 2a 2a 20 74 6f 20 argument.** to
227d0 5b 73 71 6c 69 74 65 33 5f 74 72 61 63 65 5f 76 [sqlite3_trace_v
227e0 32 28 29 5d 20 69 73 20 61 6e 20 4f 52 2d 65 64 2()] is an OR-ed
227f0 20 63 6f 6d 62 69 6e 61 74 69 6f 6e 20 6f 66 20 combination of
22800 6f 6e 65 20 6f 72 20 6d 6f 72 65 20 6f 66 0a 2a one or more of.*
22810 2a 20 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 * the following
22820 63 6f 6e 73 74 61 6e 74 73 2e 20 20 5e 54 68 65 constants. ^The
22830 20 66 69 72 73 74 20 61 72 67 75 6d 65 6e 74 20 first argument
22840 74 6f 20 74 68 65 20 74 72 61 63 65 20 63 61 6c to the trace cal
22850 6c 62 61 63 6b 0a 2a 2a 20 69 73 20 6f 6e 65 20 lback.** is one
22860 6f 66 20 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 of the following
22870 20 63 6f 6e 73 74 61 6e 74 73 2e 0a 2a 2a 0a 2a constants..**.*
22880 2a 20 4e 65 77 20 74 72 61 63 69 6e 67 20 63 6f * New tracing co
22890 6e 73 74 61 6e 74 73 20 6d 61 79 20 62 65 20 61 nstants may be a
228a0 64 64 65 64 20 69 6e 20 66 75 74 75 72 65 20 72 dded in future r
228b0 65 6c 65 61 73 65 73 2e 0a 2a 2a 0a 2a 2a 20 5e eleases..**.** ^
228c0 41 20 74 72 61 63 65 20 63 61 6c 6c 62 61 63 6b A trace callback
228d0 20 68 61 73 20 66 6f 75 72 20 61 72 67 75 6d 65 has four argume
228e0 6e 74 73 3a 20 78 43 61 6c 6c 62 61 63 6b 28 54 nts: xCallback(T
228f0 2c 43 2c 50 2c 58 29 2e 0a 2a 2a 20 5e 54 68 65 ,C,P,X)..** ^The
22900 20 54 20 61 72 67 75 6d 65 6e 74 20 69 73 20 6f T argument is o
22910 6e 65 20 6f 66 20 74 68 65 20 69 6e 74 65 67 65 ne of the intege
22920 72 20 74 79 70 65 20 63 6f 64 65 73 20 61 62 6f r type codes abo
22930 76 65 2e 0a 2a 2a 20 5e 54 68 65 20 43 20 61 72 ve..** ^The C ar
22940 67 75 6d 65 6e 74 20 69 73 20 61 20 63 6f 70 79 gument is a copy
22950 20 6f 66 20 74 68 65 20 63 6f 6e 74 65 78 74 20 of the context
22960 70 6f 69 6e 74 65 72 20 70 61 73 73 65 64 20 69 pointer passed i
22970 6e 20 61 73 20 74 68 65 0a 2a 2a 20 66 6f 75 72 n as the.** four
22980 74 68 20 61 72 67 75 6d 65 6e 74 20 74 6f 20 5b th argument to [
22990 73 71 6c 69 74 65 33 5f 74 72 61 63 65 5f 76 32 sqlite3_trace_v2
229a0 28 29 5d 2e 0a 2a 2a 20 54 68 65 20 50 20 61 6e ()]..** The P an
229b0 64 20 58 20 61 72 67 75 6d 65 6e 74 73 20 61 72 d X arguments ar
229c0 65 20 70 6f 69 6e 74 65 72 73 20 77 68 6f 73 65 e pointers whose
229d0 20 6d 65 61 6e 69 6e 67 73 20 64 65 70 65 6e 64 meanings depend
229e0 20 6f 6e 20 54 2e 0a 2a 2a 0a 2a 2a 20 3c 64 6c on T..**.** <dl
229f0 3e 0a 2a 2a 20 5b 5b 53 51 4c 49 54 45 5f 54 52 >.** [[SQLITE_TR
22a00 41 43 45 5f 53 54 4d 54 5d 5d 20 3c 64 74 3e 53 ACE_STMT]] <dt>S
22a10 51 4c 49 54 45 5f 54 52 41 43 45 5f 53 54 4d 54 QLITE_TRACE_STMT
22a20 3c 2f 64 74 3e 0a 2a 2a 20 3c 64 64 3e 5e 41 6e </dt>.** <dd>^An
22a30 20 53 51 4c 49 54 45 5f 54 52 41 43 45 5f 53 54 SQLITE_TRACE_ST
22a40 4d 54 20 63 61 6c 6c 62 61 63 6b 20 69 73 20 69 MT callback is i
22a50 6e 76 6f 6b 65 64 20 77 68 65 6e 20 61 20 70 72 nvoked when a pr
22a60 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 epared statement
22a70 0a 2a 2a 20 66 69 72 73 74 20 62 65 67 69 6e 73 .** first begins
22a80 20 72 75 6e 6e 69 6e 67 20 61 6e 64 20 70 6f 73 running and pos
22a90 73 69 62 6c 79 20 61 74 20 6f 74 68 65 72 20 74 sibly at other t
22aa0 69 6d 65 73 20 64 75 72 69 6e 67 20 74 68 65 0a imes during the.
22ab0 2a 2a 20 65 78 65 63 75 74 69 6f 6e 20 6f 66 20 ** execution of
22ac0 74 68 65 20 70 72 65 70 61 72 65 64 20 73 74 61 the prepared sta
22ad0 74 65 6d 65 6e 74 2c 20 73 75 63 68 20 61 73 20 tement, such as
22ae0 61 74 20 74 68 65 20 73 74 61 72 74 20 6f 66 20 at the start of
22af0 65 61 63 68 0a 2a 2a 20 74 72 69 67 67 65 72 20 each.** trigger
22b00 73 75 62 70 72 6f 67 72 61 6d 2e 20 5e 54 68 65 subprogram. ^The
22b10 20 50 20 61 72 67 75 6d 65 6e 74 20 69 73 20 61 P argument is a
22b20 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 68 65 0a pointer to the.
22b30 2a 2a 20 5b 70 72 65 70 61 72 65 64 20 73 74 61 ** [prepared sta
22b40 74 65 6d 65 6e 74 5d 2e 20 5e 54 68 65 20 58 20 tement]. ^The X
22b50 61 72 67 75 6d 65 6e 74 20 69 73 20 61 20 70 6f argument is a po
22b60 69 6e 74 65 72 20 74 6f 20 61 20 73 74 72 69 6e inter to a strin
22b70 67 20 77 68 69 63 68 0a 2a 2a 20 69 73 20 74 68 g which.** is th
22b80 65 20 75 6e 65 78 70 61 6e 64 65 64 20 53 51 4c e unexpanded SQL
22b90 20 74 65 78 74 20 6f 66 20 74 68 65 20 70 72 65 text of the pre
22ba0 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 20 pared statement
22bb0 6f 72 20 61 6e 20 53 51 4c 20 63 6f 6d 6d 65 6e or an SQL commen
22bc0 74 20 0a 2a 2a 20 74 68 61 74 20 69 6e 64 69 63 t .** that indic
22bd0 61 74 65 73 20 74 68 65 20 69 6e 76 6f 63 61 74 ates the invocat
22be0 69 6f 6e 20 6f 66 20 61 20 74 72 69 67 67 65 72 ion of a trigger
22bf0 2e 20 20 5e 54 68 65 20 63 61 6c 6c 62 61 63 6b . ^The callback
22c00 20 63 61 6e 20 63 6f 6d 70 75 74 65 0a 2a 2a 20 can compute.**
22c10 74 68 65 20 73 61 6d 65 20 74 65 78 74 20 74 68 the same text th
22c20 61 74 20 77 6f 75 6c 64 20 68 61 76 65 20 62 65 at would have be
22c30 65 6e 20 72 65 74 75 72 6e 65 64 20 62 79 20 74 en returned by t
22c40 68 65 20 6c 65 67 61 63 79 20 5b 73 71 6c 69 74 he legacy [sqlit
22c50 65 33 5f 74 72 61 63 65 28 29 5d 0a 2a 2a 20 69 e3_trace()].** i
22c60 6e 74 65 72 66 61 63 65 20 62 79 20 75 73 69 6e nterface by usin
22c70 67 20 74 68 65 20 58 20 61 72 67 75 6d 65 6e 74 g the X argument
22c80 20 77 68 65 6e 20 58 20 62 65 67 69 6e 73 20 77 when X begins w
22c90 69 74 68 20 22 2d 2d 22 20 61 6e 64 20 69 6e 76 ith "--" and inv
22ca0 6f 6b 69 6e 67 0a 2a 2a 20 5b 73 71 6c 69 74 65 oking.** [sqlite
22cb0 33 5f 65 78 70 61 6e 64 65 64 5f 73 71 6c 28 50 3_expanded_sql(P
22cc0 29 5d 20 6f 74 68 65 72 77 69 73 65 2e 0a 2a 2a )] otherwise..**
22cd0 0a 2a 2a 20 5b 5b 53 51 4c 49 54 45 5f 54 52 41 .** [[SQLITE_TRA
22ce0 43 45 5f 50 52 4f 46 49 4c 45 5d 5d 20 3c 64 74 CE_PROFILE]] <dt
22cf0 3e 53 51 4c 49 54 45 5f 54 52 41 43 45 5f 50 52 >SQLITE_TRACE_PR
22d00 4f 46 49 4c 45 3c 2f 64 74 3e 0a 2a 2a 20 3c 64 OFILE</dt>.** <d
22d10 64 3e 5e 41 6e 20 53 51 4c 49 54 45 5f 54 52 41 d>^An SQLITE_TRA
22d20 43 45 5f 50 52 4f 46 49 4c 45 20 63 61 6c 6c 62 CE_PROFILE callb
22d30 61 63 6b 20 70 72 6f 76 69 64 65 73 20 61 70 70 ack provides app
22d40 72 6f 78 69 6d 61 74 65 6c 79 20 74 68 65 20 73 roximately the s
22d50 61 6d 65 0a 2a 2a 20 69 6e 66 6f 72 6d 61 74 69 ame.** informati
22d60 6f 6e 20 61 73 20 69 73 20 70 72 6f 76 69 64 65 on as is provide
22d70 64 20 62 79 20 74 68 65 20 5b 73 71 6c 69 74 65 d by the [sqlite
22d80 33 5f 70 72 6f 66 69 6c 65 28 29 5d 20 63 61 6c 3_profile()] cal
22d90 6c 62 61 63 6b 2e 0a 2a 2a 20 5e 54 68 65 20 50 lback..** ^The P
22da0 20 61 72 67 75 6d 65 6e 74 20 69 73 20 61 20 70 argument is a p
22db0 6f 69 6e 74 65 72 20 74 6f 20 74 68 65 20 5b 70 ointer to the [p
22dc0 72 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e repared statemen
22dd0 74 5d 20 61 6e 64 20 74 68 65 0a 2a 2a 20 58 20 t] and the.** X
22de0 61 72 67 75 6d 65 6e 74 20 70 6f 69 6e 74 73 20 argument points
22df0 74 6f 20 61 20 36 34 2d 62 69 74 20 69 6e 74 65 to a 64-bit inte
22e00 67 65 72 20 77 68 69 63 68 20 69 73 20 74 68 65 ger which is the
22e10 20 65 73 74 69 6d 61 74 65 64 20 6f 66 0a 2a 2a estimated of.**
22e20 20 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 6e the number of n
22e30 61 6e 6f 73 65 63 6f 6e 64 20 74 68 61 74 20 74 anosecond that t
22e40 68 65 20 70 72 65 70 61 72 65 64 20 73 74 61 74 he prepared stat
22e50 65 6d 65 6e 74 20 74 6f 6f 6b 20 74 6f 20 72 75 ement took to ru
22e60 6e 2e 0a 2a 2a 20 5e 54 68 65 20 53 51 4c 49 54 n..** ^The SQLIT
22e70 45 5f 54 52 41 43 45 5f 50 52 4f 46 49 4c 45 20 E_TRACE_PROFILE
22e80 63 61 6c 6c 62 61 63 6b 20 69 73 20 69 6e 76 6f callback is invo
22e90 6b 65 64 20 77 68 65 6e 20 74 68 65 20 73 74 61 ked when the sta
22ea0 74 65 6d 65 6e 74 20 66 69 6e 69 73 68 65 73 2e tement finishes.
22eb0 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 4c 49 54 45 5f .**.** [[SQLITE_
22ec0 54 52 41 43 45 5f 52 4f 57 5d 5d 20 3c 64 74 3e TRACE_ROW]] <dt>
22ed0 53 51 4c 49 54 45 5f 54 52 41 43 45 5f 52 4f 57 SQLITE_TRACE_ROW
22ee0 3c 2f 64 74 3e 0a 2a 2a 20 3c 64 64 3e 5e 41 6e </dt>.** <dd>^An
22ef0 20 53 51 4c 49 54 45 5f 54 52 41 43 45 5f 52 4f SQLITE_TRACE_RO
22f00 57 20 63 61 6c 6c 62 61 63 6b 20 69 73 20 69 6e W callback is in
22f10 76 6f 6b 65 64 20 77 68 65 6e 65 76 65 72 20 61 voked whenever a
22f20 20 70 72 65 70 61 72 65 64 0a 2a 2a 20 73 74 61 prepared.** sta
22f30 74 65 6d 65 6e 74 20 67 65 6e 65 72 61 74 65 73 tement generates
22f40 20 61 20 73 69 6e 67 6c 65 20 72 6f 77 20 6f 66 a single row of
22f50 20 72 65 73 75 6c 74 2e 20 20 0a 2a 2a 20 5e 54 result. .** ^T
22f60 68 65 20 50 20 61 72 67 75 6d 65 6e 74 20 69 73 he P argument is
22f70 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 68 a pointer to th
22f80 65 20 5b 70 72 65 70 61 72 65 64 20 73 74 61 74 e [prepared stat
22f90 65 6d 65 6e 74 5d 20 61 6e 64 20 74 68 65 0a 2a ement] and the.*
22fa0 2a 20 58 20 61 72 67 75 6d 65 6e 74 20 69 73 20 * X argument is
22fb0 75 6e 75 73 65 64 2e 0a 2a 2a 0a 2a 2a 20 5b 5b unused..**.** [[
22fc0 53 51 4c 49 54 45 5f 54 52 41 43 45 5f 43 4c 4f SQLITE_TRACE_CLO
22fd0 53 45 5d 5d 20 3c 64 74 3e 53 51 4c 49 54 45 5f SE]] <dt>SQLITE_
22fe0 54 52 41 43 45 5f 43 4c 4f 53 45 3c 2f 64 74 3e TRACE_CLOSE</dt>
22ff0 0a 2a 2a 20 3c 64 64 3e 5e 41 6e 20 53 51 4c 49 .** <dd>^An SQLI
23000 54 45 5f 54 52 41 43 45 5f 43 4c 4f 53 45 20 63 TE_TRACE_CLOSE c
23010 61 6c 6c 62 61 63 6b 20 69 73 20 69 6e 76 6f 6b allback is invok
23020 65 64 20 77 68 65 6e 20 61 20 64 61 74 61 62 61 ed when a databa
23030 73 65 0a 2a 2a 20 63 6f 6e 6e 65 63 74 69 6f 6e se.** connection
23040 20 63 6c 6f 73 65 73 2e 0a 2a 2a 20 5e 54 68 65 closes..** ^The
23050 20 50 20 61 72 67 75 6d 65 6e 74 20 69 73 20 61 P argument is a
23060 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 68 65 20 pointer to the
23070 5b 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 [database connec
23080 74 69 6f 6e 5d 20 6f 62 6a 65 63 74 0a 2a 2a 20 tion] object.**
23090 61 6e 64 20 74 68 65 20 58 20 61 72 67 75 6d 65 and the X argume
230a0 6e 74 20 69 73 20 75 6e 75 73 65 64 2e 0a 2a 2a nt is unused..**
230b0 20 3c 2f 64 6c 3e 0a 2a 2f 0a 23 64 65 66 69 6e </dl>.*/.#defin
230c0 65 20 53 51 4c 49 54 45 5f 54 52 41 43 45 5f 53 e SQLITE_TRACE_S
230d0 54 4d 54 20 20 20 20 20 20 20 30 78 30 31 0a 23 TMT 0x01.#
230e0 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 54 52 define SQLITE_TR
230f0 41 43 45 5f 50 52 4f 46 49 4c 45 20 20 20 20 30 ACE_PROFILE 0
23100 78 30 32 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 x02.#define SQLI
23110 54 45 5f 54 52 41 43 45 5f 52 4f 57 20 20 20 20 TE_TRACE_ROW
23120 20 20 20 20 30 78 30 34 0a 23 64 65 66 69 6e 65 0x04.#define
23130 20 53 51 4c 49 54 45 5f 54 52 41 43 45 5f 43 4c SQLITE_TRACE_CL
23140 4f 53 45 20 20 20 20 20 20 30 78 30 38 0a 0a 2f OSE 0x08../
23150 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 53 *.** CAPI3REF: S
23160 51 4c 20 54 72 61 63 65 20 48 6f 6f 6b 0a 2a 2a QL Trace Hook.**
23170 20 4d 45 54 48 4f 44 3a 20 73 71 6c 69 74 65 33 METHOD: sqlite3
23180 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 6c 69 .**.** ^The sqli
23190 74 65 33 5f 74 72 61 63 65 5f 76 32 28 44 2c 4d te3_trace_v2(D,M
231a0 2c 58 2c 50 29 20 69 6e 74 65 72 66 61 63 65 20 ,X,P) interface
231b0 72 65 67 69 73 74 65 72 73 20 61 20 74 72 61 63 registers a trac
231c0 65 20 63 61 6c 6c 62 61 63 6b 0a 2a 2a 20 66 75 e callback.** fu
231d0 6e 63 74 69 6f 6e 20 58 20 61 67 61 69 6e 73 74 nction X against
231e0 20 5b 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 [database conne
231f0 63 74 69 6f 6e 5d 20 44 2c 20 75 73 69 6e 67 20 ction] D, using
23200 70 72 6f 70 65 72 74 79 20 6d 61 73 6b 20 4d 0a property mask M.
23210 2a 2a 20 61 6e 64 20 63 6f 6e 74 65 78 74 20 70 ** and context p
23220 6f 69 6e 74 65 72 20 50 2e 20 20 5e 49 66 20 74 ointer P. ^If t
23230 68 65 20 58 20 63 61 6c 6c 62 61 63 6b 20 69 73 he X callback is
23240 0a 2a 2a 20 4e 55 4c 4c 20 6f 72 20 69 66 20 74 .** NULL or if t
23250 68 65 20 4d 20 6d 61 73 6b 20 69 73 20 7a 65 72 he M mask is zer
23260 6f 2c 20 74 68 65 6e 20 74 72 61 63 69 6e 67 20 o, then tracing
23270 69 73 20 64 69 73 61 62 6c 65 64 2e 20 20 54 68 is disabled. Th
23280 65 0a 2a 2a 20 4d 20 61 72 67 75 6d 65 6e 74 20 e.** M argument
23290 73 68 6f 75 6c 64 20 62 65 20 74 68 65 20 62 69 should be the bi
232a0 74 77 69 73 65 20 4f 52 2d 65 64 20 63 6f 6d 62 twise OR-ed comb
232b0 69 6e 61 74 69 6f 6e 20 6f 66 0a 2a 2a 20 7a 65 ination of.** ze
232c0 72 6f 20 6f 72 20 6d 6f 72 65 20 5b 53 51 4c 49 ro or more [SQLI
232d0 54 45 5f 54 52 41 43 45 5d 20 63 6f 6e 73 74 61 TE_TRACE] consta
232e0 6e 74 73 2e 0a 2a 2a 0a 2a 2a 20 5e 45 61 63 68 nts..**.** ^Each
232f0 20 63 61 6c 6c 20 74 6f 20 65 69 74 68 65 72 20 call to either
23300 73 71 6c 69 74 65 33 5f 74 72 61 63 65 28 29 20 sqlite3_trace()
23310 6f 72 20 73 71 6c 69 74 65 33 5f 74 72 61 63 65 or sqlite3_trace
23320 5f 76 32 28 29 20 6f 76 65 72 72 69 64 65 73 20 _v2() overrides
23330 0a 2a 2a 20 28 63 61 6e 63 65 6c 73 29 20 61 6e .** (cancels) an
23340 79 20 70 72 69 6f 72 20 63 61 6c 6c 73 20 74 6f y prior calls to
23350 20 73 71 6c 69 74 65 33 5f 74 72 61 63 65 28 29 sqlite3_trace()
23360 20 6f 72 20 73 71 6c 69 74 65 33 5f 74 72 61 63 or sqlite3_trac
23370 65 5f 76 32 28 29 2e 0a 2a 2a 0a 2a 2a 20 5e 54 e_v2()..**.** ^T
23380 68 65 20 58 20 63 61 6c 6c 62 61 63 6b 20 69 73 he X callback is
23390 20 69 6e 76 6f 6b 65 64 20 77 68 65 6e 65 76 65 invoked wheneve
233a0 72 20 61 6e 79 20 6f 66 20 74 68 65 20 65 76 65 r any of the eve
233b0 6e 74 73 20 69 64 65 6e 74 69 66 69 65 64 20 62 nts identified b
233c0 79 20 0a 2a 2a 20 6d 61 73 6b 20 4d 20 6f 63 63 y .** mask M occ
233d0 75 72 2e 20 20 5e 54 68 65 20 69 6e 74 65 67 65 ur. ^The intege
233e0 72 20 72 65 74 75 72 6e 20 76 61 6c 75 65 20 66 r return value f
233f0 72 6f 6d 20 74 68 65 20 63 61 6c 6c 62 61 63 6b rom the callback
23400 20 69 73 20 63 75 72 72 65 6e 74 6c 79 0a 2a 2a is currently.**
23410 20 69 67 6e 6f 72 65 64 2c 20 74 68 6f 75 67 68 ignored, though
23420 20 74 68 69 73 20 6d 61 79 20 63 68 61 6e 67 65 this may change
23430 20 69 6e 20 66 75 74 75 72 65 20 72 65 6c 65 61 in future relea
23440 73 65 73 2e 20 20 43 61 6c 6c 62 61 63 6b 0a 2a ses. Callback.*
23450 2a 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e * implementation
23460 73 20 73 68 6f 75 6c 64 20 72 65 74 75 72 6e 20 s should return
23470 7a 65 72 6f 20 74 6f 20 65 6e 73 75 72 65 20 66 zero to ensure f
23480 75 74 75 72 65 20 63 6f 6d 70 61 74 69 62 69 6c uture compatibil
23490 69 74 79 2e 0a 2a 2a 0a 2a 2a 20 5e 41 20 74 72 ity..**.** ^A tr
234a0 61 63 65 20 63 61 6c 6c 62 61 63 6b 20 69 73 20 ace callback is
234b0 69 6e 76 6f 6b 65 64 20 77 69 74 68 20 66 6f 75 invoked with fou
234c0 72 20 61 72 67 75 6d 65 6e 74 73 3a 20 63 61 6c r arguments: cal
234d0 6c 62 61 63 6b 28 54 2c 43 2c 50 2c 58 29 2e 0a lback(T,C,P,X)..
234e0 2a 2a 20 5e 54 68 65 20 54 20 61 72 67 75 6d 65 ** ^The T argume
234f0 6e 74 20 69 73 20 6f 6e 65 20 6f 66 20 74 68 65 nt is one of the
23500 20 5b 53 51 4c 49 54 45 5f 54 52 41 43 45 5d 0a [SQLITE_TRACE].
23510 2a 2a 20 63 6f 6e 73 74 61 6e 74 73 20 74 6f 20 ** constants to
23520 69 6e 64 69 63 61 74 65 20 77 68 79 20 74 68 65 indicate why the
23530 20 63 61 6c 6c 62 61 63 6b 20 77 61 73 20 69 6e callback was in
23540 76 6f 6b 65 64 2e 0a 2a 2a 20 5e 54 68 65 20 43 voked..** ^The C
23550 20 61 72 67 75 6d 65 6e 74 20 69 73 20 61 20 63 argument is a c
23560 6f 70 79 20 6f 66 20 74 68 65 20 63 6f 6e 74 65 opy of the conte
23570 78 74 20 70 6f 69 6e 74 65 72 2e 0a 2a 2a 20 54 xt pointer..** T
23580 68 65 20 50 20 61 6e 64 20 58 20 61 72 67 75 6d he P and X argum
23590 65 6e 74 73 20 61 72 65 20 70 6f 69 6e 74 65 72 ents are pointer
235a0 73 20 77 68 6f 73 65 20 6d 65 61 6e 69 6e 67 73 s whose meanings
235b0 20 64 65 70 65 6e 64 20 6f 6e 20 54 2e 0a 2a 2a depend on T..**
235c0 0a 2a 2a 20 54 68 65 20 73 71 6c 69 74 65 33 5f .** The sqlite3_
235d0 74 72 61 63 65 5f 76 32 28 29 20 69 6e 74 65 72 trace_v2() inter
235e0 66 61 63 65 20 69 73 20 69 6e 74 65 6e 64 65 64 face is intended
235f0 20 74 6f 20 72 65 70 6c 61 63 65 20 74 68 65 20 to replace the
23600 6c 65 67 61 63 79 0a 2a 2a 20 69 6e 74 65 72 66 legacy.** interf
23610 61 63 65 73 20 5b 73 71 6c 69 74 65 33 5f 74 72 aces [sqlite3_tr
23620 61 63 65 28 29 5d 20 61 6e 64 20 5b 73 71 6c 69 ace()] and [sqli
23630 74 65 33 5f 70 72 6f 66 69 6c 65 28 29 5d 2c 20 te3_profile()],
23640 62 6f 74 68 20 6f 66 20 77 68 69 63 68 0a 2a 2a both of which.**
23650 20 61 72 65 20 64 65 70 72 65 63 61 74 65 64 2e are deprecated.
23660 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f .*/.int sqlite3_
23670 74 72 61 63 65 5f 76 32 28 0a 20 20 73 71 6c 69 trace_v2(. sqli
23680 74 65 33 2a 2c 0a 20 20 75 6e 73 69 67 6e 65 64 te3*,. unsigned
23690 20 75 4d 61 73 6b 2c 0a 20 20 69 6e 74 28 2a 78 uMask,. int(*x
236a0 43 61 6c 6c 62 61 63 6b 29 28 75 6e 73 69 67 6e Callback)(unsign
236b0 65 64 2c 76 6f 69 64 2a 2c 76 6f 69 64 2a 2c 76 ed,void*,void*,v
236c0 6f 69 64 2a 29 2c 0a 20 20 76 6f 69 64 20 2a 70 oid*),. void *p
236d0 43 74 78 0a 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 Ctx.);../*.** CA
236e0 50 49 33 52 45 46 3a 20 51 75 65 72 79 20 50 72 PI3REF: Query Pr
236f0 6f 67 72 65 73 73 20 43 61 6c 6c 62 61 63 6b 73 ogress Callbacks
23700 0a 2a 2a 20 4d 45 54 48 4f 44 3a 20 73 71 6c 69 .** METHOD: sqli
23710 74 65 33 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 te3.**.** ^The s
23720 71 6c 69 74 65 33 5f 70 72 6f 67 72 65 73 73 5f qlite3_progress_
23730 68 61 6e 64 6c 65 72 28 44 2c 4e 2c 58 2c 50 29 handler(D,N,X,P)
23740 20 69 6e 74 65 72 66 61 63 65 20 63 61 75 73 65 interface cause
23750 73 20 74 68 65 20 63 61 6c 6c 62 61 63 6b 0a 2a s the callback.*
23760 2a 20 66 75 6e 63 74 69 6f 6e 20 58 20 74 6f 20 * function X to
23770 62 65 20 69 6e 76 6f 6b 65 64 20 70 65 72 69 6f be invoked perio
23780 64 69 63 61 6c 6c 79 20 64 75 72 69 6e 67 20 6c dically during l
23790 6f 6e 67 20 72 75 6e 6e 69 6e 67 20 63 61 6c 6c ong running call
237a0 73 20 74 6f 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 s to.** [sqlite3
237b0 5f 65 78 65 63 28 29 5d 2c 20 5b 73 71 6c 69 74 _exec()], [sqlit
237c0 65 33 5f 73 74 65 70 28 29 5d 20 61 6e 64 20 5b e3_step()] and [
237d0 73 71 6c 69 74 65 33 5f 67 65 74 5f 74 61 62 6c sqlite3_get_tabl
237e0 65 28 29 5d 20 66 6f 72 0a 2a 2a 20 64 61 74 61 e()] for.** data
237f0 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 base connection
23800 44 2e 20 20 41 6e 20 65 78 61 6d 70 6c 65 20 75 D. An example u
23810 73 65 20 66 6f 72 20 74 68 69 73 0a 2a 2a 20 69 se for this.** i
23820 6e 74 65 72 66 61 63 65 20 69 73 20 74 6f 20 6b nterface is to k
23830 65 65 70 20 61 20 47 55 49 20 75 70 64 61 74 65 eep a GUI update
23840 64 20 64 75 72 69 6e 67 20 61 20 6c 61 72 67 65 d during a large
23850 20 71 75 65 72 79 2e 0a 2a 2a 0a 2a 2a 20 5e 54 query..**.** ^T
23860 68 65 20 70 61 72 61 6d 65 74 65 72 20 50 20 69 he parameter P i
23870 73 20 70 61 73 73 65 64 20 74 68 72 6f 75 67 68 s passed through
23880 20 61 73 20 74 68 65 20 6f 6e 6c 79 20 70 61 72 as the only par
23890 61 6d 65 74 65 72 20 74 6f 20 74 68 65 20 0a 2a ameter to the .*
238a0 2a 20 63 61 6c 6c 62 61 63 6b 20 66 75 6e 63 74 * callback funct
238b0 69 6f 6e 20 58 2e 20 20 5e 54 68 65 20 70 61 72 ion X. ^The par
238c0 61 6d 65 74 65 72 20 4e 20 69 73 20 74 68 65 20 ameter N is the
238d0 61 70 70 72 6f 78 69 6d 61 74 65 20 6e 75 6d 62 approximate numb
238e0 65 72 20 6f 66 20 0a 2a 2a 20 5b 76 69 72 74 75 er of .** [virtu
238f0 61 6c 20 6d 61 63 68 69 6e 65 20 69 6e 73 74 72 al machine instr
23900 75 63 74 69 6f 6e 73 5d 20 74 68 61 74 20 61 72 uctions] that ar
23910 65 20 65 76 61 6c 75 61 74 65 64 20 62 65 74 77 e evaluated betw
23920 65 65 6e 20 73 75 63 63 65 73 73 69 76 65 0a 2a een successive.*
23930 2a 20 69 6e 76 6f 63 61 74 69 6f 6e 73 20 6f 66 * invocations of
23940 20 74 68 65 20 63 61 6c 6c 62 61 63 6b 20 58 2e the callback X.
23950 20 20 5e 49 66 20 4e 20 69 73 20 6c 65 73 73 20 ^If N is less
23960 74 68 61 6e 20 6f 6e 65 20 74 68 65 6e 20 74 68 than one then th
23970 65 20 70 72 6f 67 72 65 73 73 0a 2a 2a 20 68 61 e progress.** ha
23980 6e 64 6c 65 72 20 69 73 20 64 69 73 61 62 6c 65 ndler is disable
23990 64 2e 0a 2a 2a 0a 2a 2a 20 5e 4f 6e 6c 79 20 61 d..**.** ^Only a
239a0 20 73 69 6e 67 6c 65 20 70 72 6f 67 72 65 73 73 single progress
239b0 20 68 61 6e 64 6c 65 72 20 6d 61 79 20 62 65 20 handler may be
239c0 64 65 66 69 6e 65 64 20 61 74 20 6f 6e 65 20 74 defined at one t
239d0 69 6d 65 20 70 65 72 0a 2a 2a 20 5b 64 61 74 61 ime per.** [data
239e0 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 5d base connection]
239f0 3b 20 73 65 74 74 69 6e 67 20 61 20 6e 65 77 20 ; setting a new
23a00 70 72 6f 67 72 65 73 73 20 68 61 6e 64 6c 65 72 progress handler
23a10 20 63 61 6e 63 65 6c 73 20 74 68 65 0a 2a 2a 20 cancels the.**
23a20 6f 6c 64 20 6f 6e 65 2e 20 20 5e 53 65 74 74 69 old one. ^Setti
23a30 6e 67 20 70 61 72 61 6d 65 74 65 72 20 58 20 74 ng parameter X t
23a40 6f 20 4e 55 4c 4c 20 64 69 73 61 62 6c 65 73 20 o NULL disables
23a50 74 68 65 20 70 72 6f 67 72 65 73 73 20 68 61 6e the progress han
23a60 64 6c 65 72 2e 0a 2a 2a 20 5e 54 68 65 20 70 72 dler..** ^The pr
23a70 6f 67 72 65 73 73 20 68 61 6e 64 6c 65 72 20 69 ogress handler i
23a80 73 20 61 6c 73 6f 20 64 69 73 61 62 6c 65 64 20 s also disabled
23a90 62 79 20 73 65 74 74 69 6e 67 20 4e 20 74 6f 20 by setting N to
23aa0 61 20 76 61 6c 75 65 20 6c 65 73 73 0a 2a 2a 20 a value less.**
23ab0 74 68 61 6e 20 31 2e 0a 2a 2a 0a 2a 2a 20 5e 49 than 1..**.** ^I
23ac0 66 20 74 68 65 20 70 72 6f 67 72 65 73 73 20 63 f the progress c
23ad0 61 6c 6c 62 61 63 6b 20 72 65 74 75 72 6e 73 20 allback returns
23ae0 6e 6f 6e 2d 7a 65 72 6f 2c 20 74 68 65 20 6f 70 non-zero, the op
23af0 65 72 61 74 69 6f 6e 20 69 73 0a 2a 2a 20 69 6e eration is.** in
23b00 74 65 72 72 75 70 74 65 64 2e 20 20 54 68 69 73 terrupted. This
23b10 20 66 65 61 74 75 72 65 20 63 61 6e 20 62 65 20 feature can be
23b20 75 73 65 64 20 74 6f 20 69 6d 70 6c 65 6d 65 6e used to implemen
23b30 74 20 61 0a 2a 2a 20 22 43 61 6e 63 65 6c 22 20 t a.** "Cancel"
23b40 62 75 74 74 6f 6e 20 6f 6e 20 61 20 47 55 49 20 button on a GUI
23b50 70 72 6f 67 72 65 73 73 20 64 69 61 6c 6f 67 20 progress dialog
23b60 62 6f 78 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 70 box..**.** The p
23b70 72 6f 67 72 65 73 73 20 68 61 6e 64 6c 65 72 20 rogress handler
23b80 63 61 6c 6c 62 61 63 6b 20 6d 75 73 74 20 6e 6f callback must no
23b90 74 20 64 6f 20 61 6e 79 74 68 69 6e 67 20 74 68 t do anything th
23ba0 61 74 20 77 69 6c 6c 20 6d 6f 64 69 66 79 0a 2a at will modify.*
23bb0 2a 20 74 68 65 20 64 61 74 61 62 61 73 65 20 63 * the database c
23bc0 6f 6e 6e 65 63 74 69 6f 6e 20 74 68 61 74 20 69 onnection that i
23bd0 6e 76 6f 6b 65 64 20 74 68 65 20 70 72 6f 67 72 nvoked the progr
23be0 65 73 73 20 68 61 6e 64 6c 65 72 2e 0a 2a 2a 20 ess handler..**
23bf0 4e 6f 74 65 20 74 68 61 74 20 5b 73 71 6c 69 74 Note that [sqlit
23c00 65 33 5f 70 72 65 70 61 72 65 5f 76 32 28 29 5d e3_prepare_v2()]
23c10 20 61 6e 64 20 5b 73 71 6c 69 74 65 33 5f 73 74 and [sqlite3_st
23c20 65 70 28 29 5d 20 62 6f 74 68 20 6d 6f 64 69 66 ep()] both modif
23c30 79 20 74 68 65 69 72 0a 2a 2a 20 64 61 74 61 62 y their.** datab
23c40 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 73 20 ase connections
23c50 66 6f 72 20 74 68 65 20 6d 65 61 6e 69 6e 67 20 for the meaning
23c60 6f 66 20 22 6d 6f 64 69 66 79 22 20 69 6e 20 74 of "modify" in t
23c70 68 69 73 20 70 61 72 61 67 72 61 70 68 2e 0a 2a his paragraph..*
23c80 2a 0a 2a 2f 0a 76 6f 69 64 20 73 71 6c 69 74 65 *.*/.void sqlite
23c90 33 5f 70 72 6f 67 72 65 73 73 5f 68 61 6e 64 6c 3_progress_handl
23ca0 65 72 28 73 71 6c 69 74 65 33 2a 2c 20 69 6e 74 er(sqlite3*, int
23cb0 2c 20 69 6e 74 28 2a 29 28 76 6f 69 64 2a 29 2c , int(*)(void*),
23cc0 20 76 6f 69 64 2a 29 3b 0a 0a 2f 2a 0a 2a 2a 20 void*);../*.**
23cd0 43 41 50 49 33 52 45 46 3a 20 4f 70 65 6e 69 6e CAPI3REF: Openin
23ce0 67 20 41 20 4e 65 77 20 44 61 74 61 62 61 73 65 g A New Database
23cf0 20 43 6f 6e 6e 65 63 74 69 6f 6e 0a 2a 2a 20 43 Connection.** C
23d00 4f 4e 53 54 52 55 43 54 4f 52 3a 20 73 71 6c 69 ONSTRUCTOR: sqli
23d10 74 65 33 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 73 65 te3.**.** ^These
23d20 20 72 6f 75 74 69 6e 65 73 20 6f 70 65 6e 20 61 routines open a
23d30 6e 20 53 51 4c 69 74 65 20 64 61 74 61 62 61 73 n SQLite databas
23d40 65 20 66 69 6c 65 20 61 73 20 73 70 65 63 69 66 e file as specif
23d50 69 65 64 20 62 79 20 74 68 65 20 0a 2a 2a 20 66 ied by the .** f
23d60 69 6c 65 6e 61 6d 65 20 61 72 67 75 6d 65 6e 74 ilename argument
23d70 2e 20 5e 54 68 65 20 66 69 6c 65 6e 61 6d 65 20 . ^The filename
23d80 61 72 67 75 6d 65 6e 74 20 69 73 20 69 6e 74 65 argument is inte
23d90 72 70 72 65 74 65 64 20 61 73 20 55 54 46 2d 38 rpreted as UTF-8
23da0 20 66 6f 72 0a 2a 2a 20 73 71 6c 69 74 65 33 5f for.** sqlite3_
23db0 6f 70 65 6e 28 29 20 61 6e 64 20 73 71 6c 69 74 open() and sqlit
23dc0 65 33 5f 6f 70 65 6e 5f 76 32 28 29 20 61 6e 64 e3_open_v2() and
23dd0 20 61 73 20 55 54 46 2d 31 36 20 69 6e 20 74 68 as UTF-16 in th
23de0 65 20 6e 61 74 69 76 65 20 62 79 74 65 0a 2a 2a e native byte.**
23df0 20 6f 72 64 65 72 20 66 6f 72 20 73 71 6c 69 74 order for sqlit
23e00 65 33 5f 6f 70 65 6e 31 36 28 29 2e 20 5e 28 41 e3_open16(). ^(A
23e10 20 5b 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 [database conne
23e20 63 74 69 6f 6e 5d 20 68 61 6e 64 6c 65 20 69 73 ction] handle is
23e30 20 75 73 75 61 6c 6c 79 0a 2a 2a 20 72 65 74 75 usually.** retu
23e40 72 6e 65 64 20 69 6e 20 2a 70 70 44 62 2c 20 65 rned in *ppDb, e
23e50 76 65 6e 20 69 66 20 61 6e 20 65 72 72 6f 72 20 ven if an error
23e60 6f 63 63 75 72 73 2e 20 20 54 68 65 20 6f 6e 6c occurs. The onl
23e70 79 20 65 78 63 65 70 74 69 6f 6e 20 69 73 20 74 y exception is t
23e80 68 61 74 0a 2a 2a 20 69 66 20 53 51 4c 69 74 65 hat.** if SQLite
23e90 20 69 73 20 75 6e 61 62 6c 65 20 74 6f 20 61 6c is unable to al
23ea0 6c 6f 63 61 74 65 20 6d 65 6d 6f 72 79 20 74 6f locate memory to
23eb0 20 68 6f 6c 64 20 74 68 65 20 5b 73 71 6c 69 74 hold the [sqlit
23ec0 65 33 5d 20 6f 62 6a 65 63 74 2c 0a 2a 2a 20 61 e3] object,.** a
23ed0 20 4e 55 4c 4c 20 77 69 6c 6c 20 62 65 20 77 72 NULL will be wr
23ee0 69 74 74 65 6e 20 69 6e 74 6f 20 2a 70 70 44 62 itten into *ppDb
23ef0 20 69 6e 73 74 65 61 64 20 6f 66 20 61 20 70 6f instead of a po
23f00 69 6e 74 65 72 20 74 6f 20 74 68 65 20 5b 73 71 inter to the [sq
23f10 6c 69 74 65 33 5d 0a 2a 2a 20 6f 62 6a 65 63 74 lite3].** object
23f20 2e 29 5e 20 5e 28 49 66 20 74 68 65 20 64 61 74 .)^ ^(If the dat
23f30 61 62 61 73 65 20 69 73 20 6f 70 65 6e 65 64 20 abase is opened
23f40 28 61 6e 64 2f 6f 72 20 63 72 65 61 74 65 64 29 (and/or created)
23f50 20 73 75 63 63 65 73 73 66 75 6c 6c 79 2c 20 74 successfully, t
23f60 68 65 6e 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f 4f hen.** [SQLITE_O
23f70 4b 5d 20 69 73 20 72 65 74 75 72 6e 65 64 2e 20 K] is returned.
23f80 20 4f 74 68 65 72 77 69 73 65 20 61 6e 20 5b 65 Otherwise an [e
23f90 72 72 6f 72 20 63 6f 64 65 5d 20 69 73 20 72 65 rror code] is re
23fa0 74 75 72 6e 65 64 2e 29 5e 20 5e 54 68 65 0a 2a turned.)^ ^The.*
23fb0 2a 20 5b 73 71 6c 69 74 65 33 5f 65 72 72 6d 73 * [sqlite3_errms
23fc0 67 28 29 5d 20 6f 72 20 5b 73 71 6c 69 74 65 33 g()] or [sqlite3
23fd0 5f 65 72 72 6d 73 67 31 36 28 29 5d 20 72 6f 75 _errmsg16()] rou
23fe0 74 69 6e 65 73 20 63 61 6e 20 62 65 20 75 73 65 tines can be use
23ff0 64 20 74 6f 20 6f 62 74 61 69 6e 0a 2a 2a 20 61 d to obtain.** a
24000 6e 20 45 6e 67 6c 69 73 68 20 6c 61 6e 67 75 61 n English langua
24010 67 65 20 64 65 73 63 72 69 70 74 69 6f 6e 20 6f ge description o
24020 66 20 74 68 65 20 65 72 72 6f 72 20 66 6f 6c 6c f the error foll
24030 6f 77 69 6e 67 20 61 20 66 61 69 6c 75 72 65 20 owing a failure
24040 6f 66 20 61 6e 79 0a 2a 2a 20 6f 66 20 74 68 65 of any.** of the
24050 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e 28 29 20 sqlite3_open()
24060 72 6f 75 74 69 6e 65 73 2e 0a 2a 2a 0a 2a 2a 20 routines..**.**
24070 5e 54 68 65 20 64 65 66 61 75 6c 74 20 65 6e 63 ^The default enc
24080 6f 64 69 6e 67 20 77 69 6c 6c 20 62 65 20 55 54 oding will be UT
24090 46 2d 38 20 66 6f 72 20 64 61 74 61 62 61 73 65 F-8 for database
240a0 73 20 63 72 65 61 74 65 64 20 75 73 69 6e 67 0a s created using.
240b0 2a 2a 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e 28 ** sqlite3_open(
240c0 29 20 6f 72 20 73 71 6c 69 74 65 33 5f 6f 70 65 ) or sqlite3_ope
240d0 6e 5f 76 32 28 29 2e 20 20 5e 54 68 65 20 64 65 n_v2(). ^The de
240e0 66 61 75 6c 74 20 65 6e 63 6f 64 69 6e 67 20 66 fault encoding f
240f0 6f 72 20 64 61 74 61 62 61 73 65 73 0a 2a 2a 20 or databases.**
24100 63 72 65 61 74 65 64 20 75 73 69 6e 67 20 73 71 created using sq
24110 6c 69 74 65 33 5f 6f 70 65 6e 31 36 28 29 20 77 lite3_open16() w
24120 69 6c 6c 20 62 65 20 55 54 46 2d 31 36 20 69 6e ill be UTF-16 in
24130 20 74 68 65 20 6e 61 74 69 76 65 20 62 79 74 65 the native byte
24140 20 6f 72 64 65 72 2e 0a 2a 2a 0a 2a 2a 20 57 68 order..**.** Wh
24150 65 74 68 65 72 20 6f 72 20 6e 6f 74 20 61 6e 20 ether or not an
24160 65 72 72 6f 72 20 6f 63 63 75 72 73 20 77 68 65 error occurs whe
24170 6e 20 69 74 20 69 73 20 6f 70 65 6e 65 64 2c 20 n it is opened,
24180 72 65 73 6f 75 72 63 65 73 0a 2a 2a 20 61 73 73 resources.** ass
24190 6f 63 69 61 74 65 64 20 77 69 74 68 20 74 68 65 ociated with the
241a0 20 5b 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 [database conne
241b0 63 74 69 6f 6e 5d 20 68 61 6e 64 6c 65 20 73 68 ction] handle sh
241c0 6f 75 6c 64 20 62 65 20 72 65 6c 65 61 73 65 64 ould be released
241d0 20 62 79 0a 2a 2a 20 70 61 73 73 69 6e 67 20 69 by.** passing i
241e0 74 20 74 6f 20 5b 73 71 6c 69 74 65 33 5f 63 6c t to [sqlite3_cl
241f0 6f 73 65 28 29 5d 20 77 68 65 6e 20 69 74 20 69 ose()] when it i
24200 73 20 6e 6f 20 6c 6f 6e 67 65 72 20 72 65 71 75 s no longer requ
24210 69 72 65 64 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 ired..**.** The
24220 73 71 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 32 28 sqlite3_open_v2(
24230 29 20 69 6e 74 65 72 66 61 63 65 20 77 6f 72 6b ) interface work
24240 73 20 6c 69 6b 65 20 73 71 6c 69 74 65 33 5f 6f s like sqlite3_o
24250 70 65 6e 28 29 0a 2a 2a 20 65 78 63 65 70 74 20 pen().** except
24260 74 68 61 74 20 69 74 20 61 63 63 65 70 74 73 20 that it accepts
24270 74 77 6f 20 61 64 64 69 74 69 6f 6e 61 6c 20 70 two additional p
24280 61 72 61 6d 65 74 65 72 73 20 66 6f 72 20 61 64 arameters for ad
24290 64 69 74 69 6f 6e 61 6c 20 63 6f 6e 74 72 6f 6c ditional control
242a0 0a 2a 2a 20 6f 76 65 72 20 74 68 65 20 6e 65 77 .** over the new
242b0 20 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 database connec
242c0 74 69 6f 6e 2e 20 20 5e 28 54 68 65 20 66 6c 61 tion. ^(The fla
242d0 67 73 20 70 61 72 61 6d 65 74 65 72 20 74 6f 0a gs parameter to.
242e0 2a 2a 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e 5f ** sqlite3_open_
242f0 76 32 28 29 20 63 61 6e 20 74 61 6b 65 20 6f 6e v2() can take on
24300 65 20 6f 66 0a 2a 2a 20 74 68 65 20 66 6f 6c 6c e of.** the foll
24310 6f 77 69 6e 67 20 74 68 72 65 65 20 76 61 6c 75 owing three valu
24320 65 73 2c 20 6f 70 74 69 6f 6e 61 6c 6c 79 20 63 es, optionally c
24330 6f 6d 62 69 6e 65 64 20 77 69 74 68 20 74 68 65 ombined with the
24340 20 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f 4f 50 45 .** [SQLITE_OPE
24350 4e 5f 4e 4f 4d 55 54 45 58 5d 2c 20 5b 53 51 4c N_NOMUTEX], [SQL
24360 49 54 45 5f 4f 50 45 4e 5f 46 55 4c 4c 4d 55 54 ITE_OPEN_FULLMUT
24370 45 58 5d 2c 20 5b 53 51 4c 49 54 45 5f 4f 50 45 EX], [SQLITE_OPE
24380 4e 5f 53 48 41 52 45 44 43 41 43 48 45 5d 2c 0a N_SHAREDCACHE],.
24390 2a 2a 20 5b 53 51 4c 49 54 45 5f 4f 50 45 4e 5f ** [SQLITE_OPEN_
243a0 50 52 49 56 41 54 45 43 41 43 48 45 5d 2c 20 61 PRIVATECACHE], a
243b0 6e 64 2f 6f 72 20 5b 53 51 4c 49 54 45 5f 4f 50 nd/or [SQLITE_OP
243c0 45 4e 5f 55 52 49 5d 20 66 6c 61 67 73 3a 29 5e EN_URI] flags:)^
243d0 0a 2a 2a 0a 2a 2a 20 3c 64 6c 3e 0a 2a 2a 20 5e .**.** <dl>.** ^
243e0 28 3c 64 74 3e 5b 53 51 4c 49 54 45 5f 4f 50 45 (<dt>[SQLITE_OPE
243f0 4e 5f 52 45 41 44 4f 4e 4c 59 5d 3c 2f 64 74 3e N_READONLY]</dt>
24400 0a 2a 2a 20 3c 64 64 3e 54 68 65 20 64 61 74 61 .** <dd>The data
24410 62 61 73 65 20 69 73 20 6f 70 65 6e 65 64 20 69 base is opened i
24420 6e 20 72 65 61 64 2d 6f 6e 6c 79 20 6d 6f 64 65 n read-only mode
24430 2e 20 20 49 66 20 74 68 65 20 64 61 74 61 62 61 . If the databa
24440 73 65 20 64 6f 65 73 20 6e 6f 74 0a 2a 2a 20 61 se does not.** a
24450 6c 72 65 61 64 79 20 65 78 69 73 74 2c 20 61 6e lready exist, an
24460 20 65 72 72 6f 72 20 69 73 20 72 65 74 75 72 6e error is return
24470 65 64 2e 3c 2f 64 64 3e 29 5e 0a 2a 2a 0a 2a 2a ed.</dd>)^.**.**
24480 20 5e 28 3c 64 74 3e 5b 53 51 4c 49 54 45 5f 4f ^(<dt>[SQLITE_O
24490 50 45 4e 5f 52 45 41 44 57 52 49 54 45 5d 3c 2f PEN_READWRITE]</
244a0 64 74 3e 0a 2a 2a 20 3c 64 64 3e 54 68 65 20 64 dt>.** <dd>The d
244b0 61 74 61 62 61 73 65 20 69 73 20 6f 70 65 6e 65 atabase is opene
244c0 64 20 66 6f 72 20 72 65 61 64 69 6e 67 20 61 6e d for reading an
244d0 64 20 77 72 69 74 69 6e 67 20 69 66 20 70 6f 73 d writing if pos
244e0 73 69 62 6c 65 2c 20 6f 72 20 72 65 61 64 69 6e sible, or readin
244f0 67 0a 2a 2a 20 6f 6e 6c 79 20 69 66 20 74 68 65 g.** only if the
24500 20 66 69 6c 65 20 69 73 20 77 72 69 74 65 20 70 file is write p
24510 72 6f 74 65 63 74 65 64 20 62 79 20 74 68 65 20 rotected by the
24520 6f 70 65 72 61 74 69 6e 67 20 73 79 73 74 65 6d operating system
24530 2e 20 20 49 6e 20 65 69 74 68 65 72 0a 2a 2a 20 . In either.**
24540 63 61 73 65 20 74 68 65 20 64 61 74 61 62 61 73 case the databas
24550 65 20 6d 75 73 74 20 61 6c 72 65 61 64 79 20 65 e must already e
24560 78 69 73 74 2c 20 6f 74 68 65 72 77 69 73 65 20 xist, otherwise
24570 61 6e 20 65 72 72 6f 72 20 69 73 20 72 65 74 75 an error is retu
24580 72 6e 65 64 2e 3c 2f 64 64 3e 29 5e 0a 2a 2a 0a rned.</dd>)^.**.
24590 2a 2a 20 5e 28 3c 64 74 3e 5b 53 51 4c 49 54 45 ** ^(<dt>[SQLITE
245a0 5f 4f 50 45 4e 5f 52 45 41 44 57 52 49 54 45 5d _OPEN_READWRITE]
245b0 20 7c 20 5b 53 51 4c 49 54 45 5f 4f 50 45 4e 5f | [SQLITE_OPEN_
245c0 43 52 45 41 54 45 5d 3c 2f 64 74 3e 0a 2a 2a 20 CREATE]</dt>.**
245d0 3c 64 64 3e 54 68 65 20 64 61 74 61 62 61 73 65 <dd>The database
245e0 20 69 73 20 6f 70 65 6e 65 64 20 66 6f 72 20 72 is opened for r
245f0 65 61 64 69 6e 67 20 61 6e 64 20 77 72 69 74 69 eading and writi
24600 6e 67 2c 20 61 6e 64 20 69 73 20 63 72 65 61 74 ng, and is creat
24610 65 64 20 69 66 0a 2a 2a 20 69 74 20 64 6f 65 73 ed if.** it does
24620 20 6e 6f 74 20 61 6c 72 65 61 64 79 20 65 78 69 not already exi
24630 73 74 2e 20 54 68 69 73 20 69 73 20 74 68 65 20 st. This is the
24640 62 65 68 61 76 69 6f 72 20 74 68 61 74 20 69 73 behavior that is
24650 20 61 6c 77 61 79 73 20 75 73 65 64 20 66 6f 72 always used for
24660 0a 2a 2a 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e .** sqlite3_open
24670 28 29 20 61 6e 64 20 73 71 6c 69 74 65 33 5f 6f () and sqlite3_o
24680 70 65 6e 31 36 28 29 2e 3c 2f 64 64 3e 29 5e 0a pen16().</dd>)^.
24690 2a 2a 20 3c 2f 64 6c 3e 0a 2a 2a 0a 2a 2a 20 49 ** </dl>.**.** I
246a0 66 20 74 68 65 20 33 72 64 20 70 61 72 61 6d 65 f the 3rd parame
246b0 74 65 72 20 74 6f 20 73 71 6c 69 74 65 33 5f 6f ter to sqlite3_o
246c0 70 65 6e 5f 76 32 28 29 20 69 73 20 6e 6f 74 20 pen_v2() is not
246d0 6f 6e 65 20 6f 66 20 74 68 65 0a 2a 2a 20 63 6f one of the.** co
246e0 6d 62 69 6e 61 74 69 6f 6e 73 20 73 68 6f 77 6e mbinations shown
246f0 20 61 62 6f 76 65 20 6f 70 74 69 6f 6e 61 6c 6c above optionall
24700 79 20 63 6f 6d 62 69 6e 65 64 20 77 69 74 68 20 y combined with
24710 6f 74 68 65 72 0a 2a 2a 20 5b 53 51 4c 49 54 45 other.** [SQLITE
24720 5f 4f 50 45 4e 5f 52 45 41 44 4f 4e 4c 59 20 7c _OPEN_READONLY |
24730 20 53 51 4c 49 54 45 5f 4f 50 45 4e 5f 2a 20 62 SQLITE_OPEN_* b
24740 69 74 73 5d 0a 2a 2a 20 74 68 65 6e 20 74 68 65 its].** then the
24750 20 62 65 68 61 76 69 6f 72 20 69 73 20 75 6e 64 behavior is und
24760 65 66 69 6e 65 64 2e 0a 2a 2a 0a 2a 2a 20 5e 49 efined..**.** ^I
24770 66 20 74 68 65 20 5b 53 51 4c 49 54 45 5f 4f 50 f the [SQLITE_OP
24780 45 4e 5f 4e 4f 4d 55 54 45 58 5d 20 66 6c 61 67 EN_NOMUTEX] flag
24790 20 69 73 20 73 65 74 2c 20 74 68 65 6e 20 74 68 is set, then th
247a0 65 20 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 e database conne
247b0 63 74 69 6f 6e 0a 2a 2a 20 6f 70 65 6e 73 20 69 ction.** opens i
247c0 6e 20 74 68 65 20 6d 75 6c 74 69 2d 74 68 72 65 n the multi-thre
247d0 61 64 20 5b 74 68 72 65 61 64 69 6e 67 20 6d 6f ad [threading mo
247e0 64 65 5d 20 61 73 20 6c 6f 6e 67 20 61 73 20 74 de] as long as t
247f0 68 65 20 73 69 6e 67 6c 65 2d 74 68 72 65 61 64 he single-thread
24800 0a 2a 2a 20 6d 6f 64 65 20 68 61 73 20 6e 6f 74 .** mode has not
24810 20 62 65 65 6e 20 73 65 74 20 61 74 20 63 6f 6d been set at com
24820 70 69 6c 65 2d 74 69 6d 65 20 6f 72 20 73 74 61 pile-time or sta
24830 72 74 2d 74 69 6d 65 2e 20 20 5e 49 66 20 74 68 rt-time. ^If th
24840 65 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f 4f 50 45 e.** [SQLITE_OPE
24850 4e 5f 46 55 4c 4c 4d 55 54 45 58 5d 20 66 6c 61 N_FULLMUTEX] fla
24860 67 20 69 73 20 73 65 74 20 74 68 65 6e 20 74 68 g is set then th
24870 65 20 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 e database conne
24880 63 74 69 6f 6e 20 6f 70 65 6e 73 0a 2a 2a 20 69 ction opens.** i
24890 6e 20 74 68 65 20 73 65 72 69 61 6c 69 7a 65 64 n the serialized
248a0 20 5b 74 68 72 65 61 64 69 6e 67 20 6d 6f 64 65 [threading mode
248b0 5d 20 75 6e 6c 65 73 73 20 73 69 6e 67 6c 65 2d ] unless single-
248c0 74 68 72 65 61 64 20 77 61 73 0a 2a 2a 20 70 72 thread was.** pr
248d0 65 76 69 6f 75 73 6c 79 20 73 65 6c 65 63 74 65 eviously selecte
248e0 64 20 61 74 20 63 6f 6d 70 69 6c 65 2d 74 69 6d d at compile-tim
248f0 65 20 6f 72 20 73 74 61 72 74 2d 74 69 6d 65 2e e or start-time.
24900 0a 2a 2a 20 5e 54 68 65 20 5b 53 51 4c 49 54 45 .** ^The [SQLITE
24910 5f 4f 50 45 4e 5f 53 48 41 52 45 44 43 41 43 48 _OPEN_SHAREDCACH
24920 45 5d 20 66 6c 61 67 20 63 61 75 73 65 73 20 74 E] flag causes t
24930 68 65 20 64 61 74 61 62 61 73 65 20 63 6f 6e 6e he database conn
24940 65 63 74 69 6f 6e 20 74 6f 20 62 65 0a 2a 2a 20 ection to be.**
24950 65 6c 69 67 69 62 6c 65 20 74 6f 20 75 73 65 20 eligible to use
24960 5b 73 68 61 72 65 64 20 63 61 63 68 65 20 6d 6f [shared cache mo
24970 64 65 5d 2c 20 72 65 67 61 72 64 6c 65 73 73 20 de], regardless
24980 6f 66 20 77 68 65 74 68 65 72 20 6f 72 20 6e 6f of whether or no
24990 74 20 73 68 61 72 65 64 0a 2a 2a 20 63 61 63 68 t shared.** cach
249a0 65 20 69 73 20 65 6e 61 62 6c 65 64 20 75 73 69 e is enabled usi
249b0 6e 67 20 5b 73 71 6c 69 74 65 33 5f 65 6e 61 62 ng [sqlite3_enab
249c0 6c 65 5f 73 68 61 72 65 64 5f 63 61 63 68 65 28 le_shared_cache(
249d0 29 5d 2e 20 20 5e 54 68 65 0a 2a 2a 20 5b 53 51 )]. ^The.** [SQ
249e0 4c 49 54 45 5f 4f 50 45 4e 5f 50 52 49 56 41 54 LITE_OPEN_PRIVAT
249f0 45 43 41 43 48 45 5d 20 66 6c 61 67 20 63 61 75 ECACHE] flag cau
24a00 73 65 73 20 74 68 65 20 64 61 74 61 62 61 73 65 ses the database
24a10 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 74 6f 20 6e connection to n
24a20 6f 74 0a 2a 2a 20 70 61 72 74 69 63 69 70 61 74 ot.** participat
24a30 65 20 69 6e 20 5b 73 68 61 72 65 64 20 63 61 63 e in [shared cac
24a40 68 65 20 6d 6f 64 65 5d 20 65 76 65 6e 20 69 66 he mode] even if
24a50 20 69 74 20 69 73 20 65 6e 61 62 6c 65 64 2e 0a it is enabled..
24a60 2a 2a 0a 2a 2a 20 5e 54 68 65 20 66 6f 75 72 74 **.** ^The fourt
24a70 68 20 70 61 72 61 6d 65 74 65 72 20 74 6f 20 73 h parameter to s
24a80 71 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 32 28 29 qlite3_open_v2()
24a90 20 69 73 20 74 68 65 20 6e 61 6d 65 20 6f 66 20 is the name of
24aa0 74 68 65 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f the.** [sqlite3_
24ab0 76 66 73 5d 20 6f 62 6a 65 63 74 20 74 68 61 74 vfs] object that
24ac0 20 64 65 66 69 6e 65 73 20 74 68 65 20 6f 70 65 defines the ope
24ad0 72 61 74 69 6e 67 20 73 79 73 74 65 6d 20 69 6e rating system in
24ae0 74 65 72 66 61 63 65 20 74 68 61 74 0a 2a 2a 20 terface that.**
24af0 74 68 65 20 6e 65 77 20 64 61 74 61 62 61 73 65 the new database
24b00 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 73 68 6f 75 connection shou
24b10 6c 64 20 75 73 65 2e 20 20 5e 49 66 20 74 68 65 ld use. ^If the
24b20 20 66 6f 75 72 74 68 20 70 61 72 61 6d 65 74 65 fourth paramete
24b30 72 20 69 73 0a 2a 2a 20 61 20 4e 55 4c 4c 20 70 r is.** a NULL p
24b40 6f 69 6e 74 65 72 20 74 68 65 6e 20 74 68 65 20 ointer then the
24b50 64 65 66 61 75 6c 74 20 5b 73 71 6c 69 74 65 33 default [sqlite3
24b60 5f 76 66 73 5d 20 6f 62 6a 65 63 74 20 69 73 20 _vfs] object is
24b70 75 73 65 64 2e 0a 2a 2a 0a 2a 2a 20 5e 49 66 20 used..**.** ^If
24b80 74 68 65 20 66 69 6c 65 6e 61 6d 65 20 69 73 20 the filename is
24b90 22 3a 6d 65 6d 6f 72 79 3a 22 2c 20 74 68 65 6e ":memory:", then
24ba0 20 61 20 70 72 69 76 61 74 65 2c 20 74 65 6d 70 a private, temp
24bb0 6f 72 61 72 79 20 69 6e 2d 6d 65 6d 6f 72 79 20 orary in-memory
24bc0 64 61 74 61 62 61 73 65 0a 2a 2a 20 69 73 20 63 database.** is c
24bd0 72 65 61 74 65 64 20 66 6f 72 20 74 68 65 20 63 reated for the c
24be0 6f 6e 6e 65 63 74 69 6f 6e 2e 20 20 5e 54 68 69 onnection. ^Thi
24bf0 73 20 69 6e 2d 6d 65 6d 6f 72 79 20 64 61 74 61 s in-memory data
24c00 62 61 73 65 20 77 69 6c 6c 20 76 61 6e 69 73 68 base will vanish
24c10 20 77 68 65 6e 0a 2a 2a 20 74 68 65 20 64 61 74 when.** the dat
24c20 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e abase connection
24c30 20 69 73 20 63 6c 6f 73 65 64 2e 20 20 46 75 74 is closed. Fut
24c40 75 72 65 20 76 65 72 73 69 6f 6e 73 20 6f 66 20 ure versions of
24c50 53 51 4c 69 74 65 20 6d 69 67 68 74 0a 2a 2a 20 SQLite might.**
24c60 6d 61 6b 65 20 75 73 65 20 6f 66 20 61 64 64 69 make use of addi
24c70 74 69 6f 6e 61 6c 20 73 70 65 63 69 61 6c 20 66 tional special f
24c80 69 6c 65 6e 61 6d 65 73 20 74 68 61 74 20 62 65 ilenames that be
24c90 67 69 6e 20 77 69 74 68 20 74 68 65 20 22 3a 22 gin with the ":"
24ca0 20 63 68 61 72 61 63 74 65 72 2e 0a 2a 2a 20 49 character..** I
24cb0 74 20 69 73 20 72 65 63 6f 6d 6d 65 6e 64 65 64 t is recommended
24cc0 20 74 68 61 74 20 77 68 65 6e 20 61 20 64 61 74 that when a dat
24cd0 61 62 61 73 65 20 66 69 6c 65 6e 61 6d 65 20 61 abase filename a
24ce0 63 74 75 61 6c 6c 79 20 64 6f 65 73 20 62 65 67 ctually does beg
24cf0 69 6e 20 77 69 74 68 0a 2a 2a 20 61 20 22 3a 22 in with.** a ":"
24d00 20 63 68 61 72 61 63 74 65 72 20 79 6f 75 20 73 character you s
24d10 68 6f 75 6c 64 20 70 72 65 66 69 78 20 74 68 65 hould prefix the
24d20 20 66 69 6c 65 6e 61 6d 65 20 77 69 74 68 20 61 filename with a
24d30 20 70 61 74 68 6e 61 6d 65 20 73 75 63 68 20 61 pathname such a
24d40 73 0a 2a 2a 20 22 2e 2f 22 20 74 6f 20 61 76 6f s.** "./" to avo
24d50 69 64 20 61 6d 62 69 67 75 69 74 79 2e 0a 2a 2a id ambiguity..**
24d60 0a 2a 2a 20 5e 49 66 20 74 68 65 20 66 69 6c 65 .** ^If the file
24d70 6e 61 6d 65 20 69 73 20 61 6e 20 65 6d 70 74 79 name is an empty
24d80 20 73 74 72 69 6e 67 2c 20 74 68 65 6e 20 61 20 string, then a
24d90 70 72 69 76 61 74 65 2c 20 74 65 6d 70 6f 72 61 private, tempora
24da0 72 79 0a 2a 2a 20 6f 6e 2d 64 69 73 6b 20 64 61 ry.** on-disk da
24db0 74 61 62 61 73 65 20 77 69 6c 6c 20 62 65 20 63 tabase will be c
24dc0 72 65 61 74 65 64 2e 20 20 5e 54 68 69 73 20 70 reated. ^This p
24dd0 72 69 76 61 74 65 20 64 61 74 61 62 61 73 65 20 rivate database
24de0 77 69 6c 6c 20 62 65 0a 2a 2a 20 61 75 74 6f 6d will be.** autom
24df0 61 74 69 63 61 6c 6c 79 20 64 65 6c 65 74 65 64 atically deleted
24e00 20 61 73 20 73 6f 6f 6e 20 61 73 20 74 68 65 20 as soon as the
24e10 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 database connect
24e20 69 6f 6e 20 69 73 20 63 6c 6f 73 65 64 2e 0a 2a ion is closed..*
24e30 2a 0a 2a 2a 20 5b 5b 55 52 49 20 66 69 6c 65 6e *.** [[URI filen
24e40 61 6d 65 73 20 69 6e 20 73 71 6c 69 74 65 33 5f ames in sqlite3_
24e50 6f 70 65 6e 28 29 5d 5d 20 3c 68 33 3e 55 52 49 open()]] <h3>URI
24e60 20 46 69 6c 65 6e 61 6d 65 73 3c 2f 68 33 3e 0a Filenames</h3>.
24e70 2a 2a 0a 2a 2a 20 5e 49 66 20 5b 55 52 49 20 66 **.** ^If [URI f
24e80 69 6c 65 6e 61 6d 65 5d 20 69 6e 74 65 72 70 72 ilename] interpr
24e90 65 74 61 74 69 6f 6e 20 69 73 20 65 6e 61 62 6c etation is enabl
24ea0 65 64 2c 20 61 6e 64 20 74 68 65 20 66 69 6c 65 ed, and the file
24eb0 6e 61 6d 65 20 61 72 67 75 6d 65 6e 74 0a 2a 2a name argument.**
24ec0 20 62 65 67 69 6e 73 20 77 69 74 68 20 22 66 69 begins with "fi
24ed0 6c 65 3a 22 2c 20 74 68 65 6e 20 74 68 65 20 66 le:", then the f
24ee0 69 6c 65 6e 61 6d 65 20 69 73 20 69 6e 74 65 72 ilename is inter
24ef0 70 72 65 74 65 64 20 61 73 20 61 20 55 52 49 2e preted as a URI.
24f00 20 5e 55 52 49 0a 2a 2a 20 66 69 6c 65 6e 61 6d ^URI.** filenam
24f10 65 20 69 6e 74 65 72 70 72 65 74 61 74 69 6f 6e e interpretation
24f20 20 69 73 20 65 6e 61 62 6c 65 64 20 69 66 20 74 is enabled if t
24f30 68 65 20 5b 53 51 4c 49 54 45 5f 4f 50 45 4e 5f he [SQLITE_OPEN_
24f40 55 52 49 5d 20 66 6c 61 67 20 69 73 0a 2a 2a 20 URI] flag is.**
24f50 73 65 74 20 69 6e 20 74 68 65 20 66 6f 75 72 74 set in the fourt
24f60 68 20 61 72 67 75 6d 65 6e 74 20 74 6f 20 73 71 h argument to sq
24f70 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 32 28 29 2c lite3_open_v2(),
24f80 20 6f 72 20 69 66 20 69 74 20 68 61 73 0a 2a 2a or if it has.**
24f90 20 62 65 65 6e 20 65 6e 61 62 6c 65 64 20 67 6c been enabled gl
24fa0 6f 62 61 6c 6c 79 20 75 73 69 6e 67 20 74 68 65 obally using the
24fb0 20 5b 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f [SQLITE_CONFIG_
24fc0 55 52 49 5d 20 6f 70 74 69 6f 6e 20 77 69 74 68 URI] option with
24fd0 20 74 68 65 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 the.** [sqlite3
24fe0 5f 63 6f 6e 66 69 67 28 29 5d 20 6d 65 74 68 6f _config()] metho
24ff0 64 20 6f 72 20 62 79 20 74 68 65 20 5b 53 51 4c d or by the [SQL
25000 49 54 45 5f 55 53 45 5f 55 52 49 5d 20 63 6f 6d ITE_USE_URI] com
25010 70 69 6c 65 2d 74 69 6d 65 20 6f 70 74 69 6f 6e pile-time option
25020 2e 0a 2a 2a 20 41 73 20 6f 66 20 53 51 4c 69 74 ..** As of SQLit
25030 65 20 76 65 72 73 69 6f 6e 20 33 2e 37 2e 37 2c e version 3.7.7,
25040 20 55 52 49 20 66 69 6c 65 6e 61 6d 65 20 69 6e URI filename in
25050 74 65 72 70 72 65 74 61 74 69 6f 6e 20 69 73 20 terpretation is
25060 74 75 72 6e 65 64 20 6f 66 66 0a 2a 2a 20 62 79 turned off.** by
25070 20 64 65 66 61 75 6c 74 2c 20 62 75 74 20 66 75 default, but fu
25080 74 75 72 65 20 72 65 6c 65 61 73 65 73 20 6f 66 ture releases of
25090 20 53 51 4c 69 74 65 20 6d 69 67 68 74 20 65 6e SQLite might en
250a0 61 62 6c 65 20 55 52 49 20 66 69 6c 65 6e 61 6d able URI filenam
250b0 65 0a 2a 2a 20 69 6e 74 65 72 70 72 65 74 61 74 e.** interpretat
250c0 69 6f 6e 20 62 79 20 64 65 66 61 75 6c 74 2e 20 ion by default.
250d0 20 53 65 65 20 22 5b 55 52 49 20 66 69 6c 65 6e See "[URI filen
250e0 61 6d 65 73 5d 22 20 66 6f 72 20 61 64 64 69 74 ames]" for addit
250f0 69 6f 6e 61 6c 0a 2a 2a 20 69 6e 66 6f 72 6d 61 ional.** informa
25100 74 69 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 55 52 49 20 tion..**.** URI
25110 66 69 6c 65 6e 61 6d 65 73 20 61 72 65 20 70 61 filenames are pa
25120 72 73 65 64 20 61 63 63 6f 72 64 69 6e 67 20 74 rsed according t
25130 6f 20 52 46 43 20 33 39 38 36 2e 20 5e 49 66 20 o RFC 3986. ^If
25140 74 68 65 20 55 52 49 20 63 6f 6e 74 61 69 6e 73 the URI contains
25150 20 61 6e 0a 2a 2a 20 61 75 74 68 6f 72 69 74 79 an.** authority
25160 2c 20 74 68 65 6e 20 69 74 20 6d 75 73 74 20 62 , then it must b
25170 65 20 65 69 74 68 65 72 20 61 6e 20 65 6d 70 74 e either an empt
25180 79 20 73 74 72 69 6e 67 20 6f 72 20 74 68 65 20 y string or the
25190 73 74 72 69 6e 67 20 0a 2a 2a 20 22 6c 6f 63 61 string .** "loca
251a0 6c 68 6f 73 74 22 2e 20 5e 49 66 20 74 68 65 20 lhost". ^If the
251b0 61 75 74 68 6f 72 69 74 79 20 69 73 20 6e 6f 74 authority is not
251c0 20 61 6e 20 65 6d 70 74 79 20 73 74 72 69 6e 67 an empty string
251d0 20 6f 72 20 22 6c 6f 63 61 6c 68 6f 73 74 22 2c or "localhost",
251e0 20 61 6e 20 0a 2a 2a 20 65 72 72 6f 72 20 69 73 an .** error is
251f0 20 72 65 74 75 72 6e 65 64 20 74 6f 20 74 68 65 returned to the
25200 20 63 61 6c 6c 65 72 2e 20 5e 54 68 65 20 66 72 caller. ^The fr
25210 61 67 6d 65 6e 74 20 63 6f 6d 70 6f 6e 65 6e 74 agment component
25220 20 6f 66 20 61 20 55 52 49 2c 20 69 66 20 0a 2a of a URI, if .*
25230 2a 20 70 72 65 73 65 6e 74 2c 20 69 73 20 69 67 * present, is ig
25240 6e 6f 72 65 64 2e 0a 2a 2a 0a 2a 2a 20 5e 53 51 nored..**.** ^SQ
25250 4c 69 74 65 20 75 73 65 73 20 74 68 65 20 70 61 Lite uses the pa
25260 74 68 20 63 6f 6d 70 6f 6e 65 6e 74 20 6f 66 20 th component of
25270 74 68 65 20 55 52 49 20 61 73 20 74 68 65 20 6e the URI as the n
25280 61 6d 65 20 6f 66 20 74 68 65 20 64 69 73 6b 20 ame of the disk
25290 66 69 6c 65 0a 2a 2a 20 77 68 69 63 68 20 63 6f file.** which co
252a0 6e 74 61 69 6e 73 20 74 68 65 20 64 61 74 61 62 ntains the datab
252b0 61 73 65 2e 20 5e 49 66 20 74 68 65 20 70 61 74 ase. ^If the pat
252c0 68 20 62 65 67 69 6e 73 20 77 69 74 68 20 61 20 h begins with a
252d0 27 2f 27 20 63 68 61 72 61 63 74 65 72 2c 20 0a '/' character, .
252e0 2a 2a 20 74 68 65 6e 20 69 74 20 69 73 20 69 6e ** then it is in
252f0 74 65 72 70 72 65 74 65 64 20 61 73 20 61 6e 20 terpreted as an
25300 61 62 73 6f 6c 75 74 65 20 70 61 74 68 2e 20 5e absolute path. ^
25310 49 66 20 74 68 65 20 70 61 74 68 20 64 6f 65 73 If the path does
25320 20 6e 6f 74 20 62 65 67 69 6e 20 0a 2a 2a 20 77 not begin .** w
25330 69 74 68 20 61 20 27 2f 27 20 28 6d 65 61 6e 69 ith a '/' (meani
25340 6e 67 20 74 68 61 74 20 74 68 65 20 61 75 74 68 ng that the auth
25350 6f 72 69 74 79 20 73 65 63 74 69 6f 6e 20 69 73 ority section is
25360 20 6f 6d 69 74 74 65 64 20 66 72 6f 6d 20 74 68 omitted from th
25370 65 20 55 52 49 29 0a 2a 2a 20 74 68 65 6e 20 74 e URI).** then t
25380 68 65 20 70 61 74 68 20 69 73 20 69 6e 74 65 72 he path is inter
25390 70 72 65 74 65 64 20 61 73 20 61 20 72 65 6c 61 preted as a rela
253a0 74 69 76 65 20 70 61 74 68 2e 20 0a 2a 2a 20 5e tive path. .** ^
253b0 28 4f 6e 20 77 69 6e 64 6f 77 73 2c 20 74 68 65 (On windows, the
253c0 20 66 69 72 73 74 20 63 6f 6d 70 6f 6e 65 6e 74 first component
253d0 20 6f 66 20 61 6e 20 61 62 73 6f 6c 75 74 65 20 of an absolute
253e0 70 61 74 68 20 0a 2a 2a 20 69 73 20 61 20 64 72 path .** is a dr
253f0 69 76 65 20 73 70 65 63 69 66 69 63 61 74 69 6f ive specificatio
25400 6e 20 28 65 2e 67 2e 20 22 43 3a 22 29 2e 29 5e n (e.g. "C:").)^
25410 0a 2a 2a 0a 2a 2a 20 5b 5b 63 6f 72 65 20 55 52 .**.** [[core UR
25420 49 20 71 75 65 72 79 20 70 61 72 61 6d 65 74 65 I query paramete
25430 72 73 5d 5d 0a 2a 2a 20 54 68 65 20 71 75 65 72 rs]].** The quer
25440 79 20 63 6f 6d 70 6f 6e 65 6e 74 20 6f 66 20 61 y component of a
25450 20 55 52 49 20 6d 61 79 20 63 6f 6e 74 61 69 6e URI may contain
25460 20 70 61 72 61 6d 65 74 65 72 73 20 74 68 61 74 parameters that
25470 20 61 72 65 20 69 6e 74 65 72 70 72 65 74 65 64 are interpreted
25480 0a 2a 2a 20 65 69 74 68 65 72 20 62 79 20 53 51 .** either by SQ
25490 4c 69 74 65 20 69 74 73 65 6c 66 2c 20 6f 72 20 Lite itself, or
254a0 62 79 20 61 20 5b 56 46 53 20 7c 20 63 75 73 74 by a [VFS | cust
254b0 6f 6d 20 56 46 53 20 69 6d 70 6c 65 6d 65 6e 74 om VFS implement
254c0 61 74 69 6f 6e 5d 2e 0a 2a 2a 20 53 51 4c 69 74 ation]..** SQLit
254d0 65 20 61 6e 64 20 69 74 73 20 62 75 69 6c 74 2d e and its built-
254e0 69 6e 20 5b 56 46 53 65 73 5d 20 69 6e 74 65 72 in [VFSes] inter
254f0 70 72 65 74 20 74 68 65 0a 2a 2a 20 66 6f 6c 6c pret the.** foll
25500 6f 77 69 6e 67 20 71 75 65 72 79 20 70 61 72 61 owing query para
25510 6d 65 74 65 72 73 3a 0a 2a 2a 0a 2a 2a 20 3c 75 meters:.**.** <u
25520 6c 3e 0a 2a 2a 20 20 20 3c 6c 69 3e 20 3c 62 3e l>.** <li> <b>
25530 76 66 73 3c 2f 62 3e 3a 20 5e 54 68 65 20 22 76 vfs</b>: ^The "v
25540 66 73 22 20 70 61 72 61 6d 65 74 65 72 20 6d 61 fs" parameter ma
25550 79 20 62 65 20 75 73 65 64 20 74 6f 20 73 70 65 y be used to spe
25560 63 69 66 79 20 74 68 65 20 6e 61 6d 65 20 6f 66 cify the name of
25570 0a 2a 2a 20 20 20 20 20 61 20 56 46 53 20 6f 62 .** a VFS ob
25580 6a 65 63 74 20 74 68 61 74 20 70 72 6f 76 69 64 ject that provid
25590 65 73 20 74 68 65 20 6f 70 65 72 61 74 69 6e 67 es the operating
255a0 20 73 79 73 74 65 6d 20 69 6e 74 65 72 66 61 63 system interfac
255b0 65 20 74 68 61 74 20 73 68 6f 75 6c 64 0a 2a 2a e that should.**
255c0 20 20 20 20 20 62 65 20 75 73 65 64 20 74 6f 20 be used to
255d0 61 63 63 65 73 73 20 74 68 65 20 64 61 74 61 62 access the datab
255e0 61 73 65 20 66 69 6c 65 20 6f 6e 20 64 69 73 6b ase file on disk
255f0 2e 20 5e 49 66 20 74 68 69 73 20 6f 70 74 69 6f . ^If this optio
25600 6e 20 69 73 20 73 65 74 20 74 6f 0a 2a 2a 20 20 n is set to.**
25610 20 20 20 61 6e 20 65 6d 70 74 79 20 73 74 72 69 an empty stri
25620 6e 67 20 74 68 65 20 64 65 66 61 75 6c 74 20 56 ng the default V
25630 46 53 20 6f 62 6a 65 63 74 20 69 73 20 75 73 65 FS object is use
25640 64 2e 20 5e 53 70 65 63 69 66 79 69 6e 67 20 61 d. ^Specifying a
25650 6e 20 75 6e 6b 6e 6f 77 6e 0a 2a 2a 20 20 20 20 n unknown.**
25660 20 56 46 53 20 69 73 20 61 6e 20 65 72 72 6f 72 VFS is an error
25670 2e 20 5e 49 66 20 73 71 6c 69 74 65 33 5f 6f 70 . ^If sqlite3_op
25680 65 6e 5f 76 32 28 29 20 69 73 20 75 73 65 64 20 en_v2() is used
25690 61 6e 64 20 74 68 65 20 76 66 73 20 6f 70 74 69 and the vfs opti
256a0 6f 6e 20 69 73 0a 2a 2a 20 20 20 20 20 70 72 65 on is.** pre
256b0 73 65 6e 74 2c 20 74 68 65 6e 20 74 68 65 20 56 sent, then the V
256c0 46 53 20 73 70 65 63 69 66 69 65 64 20 62 79 20 FS specified by
256d0 74 68 65 20 6f 70 74 69 6f 6e 20 74 61 6b 65 73 the option takes
256e0 20 70 72 65 63 65 64 65 6e 63 65 20 6f 76 65 72 precedence over
256f0 0a 2a 2a 20 20 20 20 20 74 68 65 20 76 61 6c 75 .** the valu
25700 65 20 70 61 73 73 65 64 20 61 73 20 74 68 65 20 e passed as the
25710 66 6f 75 72 74 68 20 70 61 72 61 6d 65 74 65 72 fourth parameter
25720 20 74 6f 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e to sqlite3_open
25730 5f 76 32 28 29 2e 0a 2a 2a 0a 2a 2a 20 20 20 3c _v2()..**.** <
25740 6c 69 3e 20 3c 62 3e 6d 6f 64 65 3c 2f 62 3e 3a li> <b>mode</b>:
25750 20 5e 28 54 68 65 20 6d 6f 64 65 20 70 61 72 61 ^(The mode para
25760 6d 65 74 65 72 20 6d 61 79 20 62 65 20 73 65 74 meter may be set
25770 20 74 6f 20 65 69 74 68 65 72 20 22 72 6f 22 2c to either "ro",
25780 20 22 72 77 22 2c 0a 2a 2a 20 20 20 20 20 22 72 "rw",.** "r
25790 77 63 22 2c 20 6f 72 20 22 6d 65 6d 6f 72 79 22 wc", or "memory"
257a0 2e 20 41 74 74 65 6d 70 74 69 6e 67 20 74 6f 20 . Attempting to
257b0 73 65 74 20 69 74 20 74 6f 20 61 6e 79 20 6f 74 set it to any ot
257c0 68 65 72 20 76 61 6c 75 65 20 69 73 0a 2a 2a 20 her value is.**
257d0 20 20 20 20 61 6e 20 65 72 72 6f 72 29 5e 2e 20 an error)^.
257e0 0a 2a 2a 20 20 20 20 20 5e 49 66 20 22 72 6f 22 .** ^If "ro"
257f0 20 69 73 20 73 70 65 63 69 66 69 65 64 2c 20 74 is specified, t
25800 68 65 6e 20 74 68 65 20 64 61 74 61 62 61 73 65 hen the database
25810 20 69 73 20 6f 70 65 6e 65 64 20 66 6f 72 20 72 is opened for r
25820 65 61 64 2d 6f 6e 6c 79 20 0a 2a 2a 20 20 20 20 ead-only .**
25830 20 61 63 63 65 73 73 2c 20 6a 75 73 74 20 61 73 access, just as
25840 20 69 66 20 74 68 65 20 5b 53 51 4c 49 54 45 5f if the [SQLITE_
25850 4f 50 45 4e 5f 52 45 41 44 4f 4e 4c 59 5d 20 66 OPEN_READONLY] f
25860 6c 61 67 20 68 61 64 20 62 65 65 6e 20 73 65 74 lag had been set
25870 20 69 6e 20 74 68 65 20 0a 2a 2a 20 20 20 20 20 in the .**
25880 74 68 69 72 64 20 61 72 67 75 6d 65 6e 74 20 74 third argument t
25890 6f 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 o sqlite3_open_v
258a0 32 28 29 2e 20 5e 49 66 20 74 68 65 20 6d 6f 64 2(). ^If the mod
258b0 65 20 6f 70 74 69 6f 6e 20 69 73 20 73 65 74 20 e option is set
258c0 74 6f 20 0a 2a 2a 20 20 20 20 20 22 72 77 22 2c to .** "rw",
258d0 20 74 68 65 6e 20 74 68 65 20 64 61 74 61 62 61 then the databa
258e0 73 65 20 69 73 20 6f 70 65 6e 65 64 20 66 6f 72 se is opened for
258f0 20 72 65 61 64 2d 77 72 69 74 65 20 28 62 75 74 read-write (but
25900 20 6e 6f 74 20 63 72 65 61 74 65 29 20 0a 2a 2a not create) .**
25910 20 20 20 20 20 61 63 63 65 73 73 2c 20 61 73 20 access, as
25920 69 66 20 53 51 4c 49 54 45 5f 4f 50 45 4e 5f 52 if SQLITE_OPEN_R
25930 45 41 44 57 52 49 54 45 20 28 62 75 74 20 6e 6f EADWRITE (but no
25940 74 20 53 51 4c 49 54 45 5f 4f 50 45 4e 5f 43 52 t SQLITE_OPEN_CR
25950 45 41 54 45 29 20 68 61 64 20 0a 2a 2a 20 20 20 EATE) had .**
25960 20 20 62 65 65 6e 20 73 65 74 2e 20 5e 56 61 6c been set. ^Val
25970 75 65 20 22 72 77 63 22 20 69 73 20 65 71 75 69 ue "rwc" is equi
25980 76 61 6c 65 6e 74 20 74 6f 20 73 65 74 74 69 6e valent to settin
25990 67 20 62 6f 74 68 20 0a 2a 2a 20 20 20 20 20 53 g both .** S
259a0 51 4c 49 54 45 5f 4f 50 45 4e 5f 52 45 41 44 57 QLITE_OPEN_READW
259b0 52 49 54 45 20 61 6e 64 20 53 51 4c 49 54 45 5f RITE and SQLITE_
259c0 4f 50 45 4e 5f 43 52 45 41 54 45 2e 20 20 5e 49 OPEN_CREATE. ^I
259d0 66 20 74 68 65 20 6d 6f 64 65 20 6f 70 74 69 6f f the mode optio
259e0 6e 20 69 73 0a 2a 2a 20 20 20 20 20 73 65 74 20 n is.** set
259f0 74 6f 20 22 6d 65 6d 6f 72 79 22 20 74 68 65 6e to "memory" then
25a00 20 61 20 70 75 72 65 20 5b 69 6e 2d 6d 65 6d 6f a pure [in-memo
25a10 72 79 20 64 61 74 61 62 61 73 65 5d 20 74 68 61 ry database] tha
25a20 74 20 6e 65 76 65 72 20 72 65 61 64 73 0a 2a 2a t never reads.**
25a30 20 20 20 20 20 6f 72 20 77 72 69 74 65 73 20 66 or writes f
25a40 72 6f 6d 20 64 69 73 6b 20 69 73 20 75 73 65 64 rom disk is used
25a50 2e 20 5e 49 74 20 69 73 20 61 6e 20 65 72 72 6f . ^It is an erro
25a60 72 20 74 6f 20 73 70 65 63 69 66 79 20 61 20 76 r to specify a v
25a70 61 6c 75 65 20 66 6f 72 0a 2a 2a 20 20 20 20 20 alue for.**
25a80 74 68 65 20 6d 6f 64 65 20 70 61 72 61 6d 65 74 the mode paramet
25a90 65 72 20 74 68 61 74 20 69 73 20 6c 65 73 73 20 er that is less
25aa0 72 65 73 74 72 69 63 74 69 76 65 20 74 68 61 6e restrictive than
25ab0 20 74 68 61 74 20 73 70 65 63 69 66 69 65 64 20 that specified
25ac0 62 79 0a 2a 2a 20 20 20 20 20 74 68 65 20 66 6c by.** the fl
25ad0 61 67 73 20 70 61 73 73 65 64 20 69 6e 20 74 68 ags passed in th
25ae0 65 20 74 68 69 72 64 20 70 61 72 61 6d 65 74 65 e third paramete
25af0 72 20 74 6f 20 73 71 6c 69 74 65 33 5f 6f 70 65 r to sqlite3_ope
25b00 6e 5f 76 32 28 29 2e 0a 2a 2a 0a 2a 2a 20 20 20 n_v2()..**.**
25b10 3c 6c 69 3e 20 3c 62 3e 63 61 63 68 65 3c 2f 62 <li> <b>cache</b
25b20 3e 3a 20 5e 54 68 65 20 63 61 63 68 65 20 70 61 >: ^The cache pa
25b30 72 61 6d 65 74 65 72 20 6d 61 79 20 62 65 20 73 rameter may be s
25b40 65 74 20 74 6f 20 65 69 74 68 65 72 20 22 73 68 et to either "sh
25b50 61 72 65 64 22 20 6f 72 0a 2a 2a 20 20 20 20 20 ared" or.**
25b60 22 70 72 69 76 61 74 65 22 2e 20 5e 53 65 74 74 "private". ^Sett
25b70 69 6e 67 20 69 74 20 74 6f 20 22 73 68 61 72 65 ing it to "share
25b80 64 22 20 69 73 20 65 71 75 69 76 61 6c 65 6e 74 d" is equivalent
25b90 20 74 6f 20 73 65 74 74 69 6e 67 20 74 68 65 0a to setting the.
25ba0 2a 2a 20 20 20 20 20 53 51 4c 49 54 45 5f 4f 50 ** SQLITE_OP
25bb0 45 4e 5f 53 48 41 52 45 44 43 41 43 48 45 20 62 EN_SHAREDCACHE b
25bc0 69 74 20 69 6e 20 74 68 65 20 66 6c 61 67 73 20 it in the flags
25bd0 61 72 67 75 6d 65 6e 74 20 70 61 73 73 65 64 20 argument passed
25be0 74 6f 0a 2a 2a 20 20 20 20 20 73 71 6c 69 74 65 to.** sqlite
25bf0 33 5f 6f 70 65 6e 5f 76 32 28 29 2e 20 5e 53 65 3_open_v2(). ^Se
25c00 74 74 69 6e 67 20 74 68 65 20 63 61 63 68 65 20 tting the cache
25c10 70 61 72 61 6d 65 74 65 72 20 74 6f 20 22 70 72 parameter to "pr
25c20 69 76 61 74 65 22 20 69 73 20 0a 2a 2a 20 20 20 ivate" is .**
25c30 20 20 65 71 75 69 76 61 6c 65 6e 74 20 74 6f 20 equivalent to
25c40 73 65 74 74 69 6e 67 20 74 68 65 20 53 51 4c 49 setting the SQLI
25c50 54 45 5f 4f 50 45 4e 5f 50 52 49 56 41 54 45 43 TE_OPEN_PRIVATEC
25c60 41 43 48 45 20 62 69 74 2e 0a 2a 2a 20 20 20 20 ACHE bit..**
25c70 20 5e 49 66 20 73 71 6c 69 74 65 33 5f 6f 70 65 ^If sqlite3_ope
25c80 6e 5f 76 32 28 29 20 69 73 20 75 73 65 64 20 61 n_v2() is used a
25c90 6e 64 20 74 68 65 20 22 63 61 63 68 65 22 20 70 nd the "cache" p
25ca0 61 72 61 6d 65 74 65 72 20 69 73 20 70 72 65 73 arameter is pres
25cb0 65 6e 74 20 69 6e 0a 2a 2a 20 20 20 20 20 61 20 ent in.** a
25cc0 55 52 49 20 66 69 6c 65 6e 61 6d 65 2c 20 69 74 URI filename, it
25cd0 73 20 76 61 6c 75 65 20 6f 76 65 72 72 69 64 65 s value override
25ce0 73 20 61 6e 79 20 62 65 68 61 76 69 6f 72 20 72 s any behavior r
25cf0 65 71 75 65 73 74 65 64 20 62 79 20 73 65 74 74 equested by sett
25d00 69 6e 67 0a 2a 2a 20 20 20 20 20 53 51 4c 49 54 ing.** SQLIT
25d10 45 5f 4f 50 45 4e 5f 50 52 49 56 41 54 45 43 41 E_OPEN_PRIVATECA
25d20 43 48 45 20 6f 72 20 53 51 4c 49 54 45 5f 4f 50 CHE or SQLITE_OP
25d30 45 4e 5f 53 48 41 52 45 44 43 41 43 48 45 20 66 EN_SHAREDCACHE f
25d40 6c 61 67 2e 0a 2a 2a 0a 2a 2a 20 20 3c 6c 69 3e lag..**.** <li>
25d50 20 3c 62 3e 70 73 6f 77 3c 2f 62 3e 3a 20 5e 54 <b>psow</b>: ^T
25d60 68 65 20 70 73 6f 77 20 70 61 72 61 6d 65 74 65 he psow paramete
25d70 72 20 69 6e 64 69 63 61 74 65 73 20 77 68 65 74 r indicates whet
25d80 68 65 72 20 6f 72 20 6e 6f 74 20 74 68 65 0a 2a her or not the.*
25d90 2a 20 20 20 20 20 5b 70 6f 77 65 72 73 61 66 65 * [powersafe
25da0 20 6f 76 65 72 77 72 69 74 65 5d 20 70 72 6f 70 overwrite] prop
25db0 65 72 74 79 20 64 6f 65 73 20 6f 72 20 64 6f 65 erty does or doe
25dc0 73 20 6e 6f 74 20 61 70 70 6c 79 20 74 6f 20 74 s not apply to t
25dd0 68 65 0a 2a 2a 20 20 20 20 20 73 74 6f 72 61 67 he.** storag
25de0 65 20 6d 65 64 69 61 20 6f 6e 20 77 68 69 63 68 e media on which
25df0 20 74 68 65 20 64 61 74 61 62 61 73 65 20 66 69 the database fi
25e00 6c 65 20 72 65 73 69 64 65 73 2e 0a 2a 2a 0a 2a le resides..**.*
25e10 2a 20 20 3c 6c 69 3e 20 3c 62 3e 6e 6f 6c 6f 63 * <li> <b>noloc
25e20 6b 3c 2f 62 3e 3a 20 5e 54 68 65 20 6e 6f 6c 6f k</b>: ^The nolo
25e30 63 6b 20 70 61 72 61 6d 65 74 65 72 20 69 73 20 ck parameter is
25e40 61 20 62 6f 6f 6c 65 61 6e 20 71 75 65 72 79 20 a boolean query
25e50 70 61 72 61 6d 65 74 65 72 0a 2a 2a 20 20 20 20 parameter.**
25e60 20 77 68 69 63 68 20 69 66 20 73 65 74 20 64 69 which if set di
25e70 73 61 62 6c 65 73 20 66 69 6c 65 20 6c 6f 63 6b sables file lock
25e80 69 6e 67 20 69 6e 20 72 6f 6c 6c 62 61 63 6b 20 ing in rollback
25e90 6a 6f 75 72 6e 61 6c 20 6d 6f 64 65 73 2e 20 20 journal modes.
25ea0 54 68 69 73 0a 2a 2a 20 20 20 20 20 69 73 20 75 This.** is u
25eb0 73 65 66 75 6c 20 66 6f 72 20 61 63 63 65 73 73 seful for access
25ec0 69 6e 67 20 61 20 64 61 74 61 62 61 73 65 20 6f ing a database o
25ed0 6e 20 61 20 66 69 6c 65 73 79 73 74 65 6d 20 74 n a filesystem t
25ee0 68 61 74 20 64 6f 65 73 20 6e 6f 74 0a 2a 2a 20 hat does not.**
25ef0 20 20 20 20 73 75 70 70 6f 72 74 20 6c 6f 63 6b support lock
25f00 69 6e 67 2e 20 20 43 61 75 74 69 6f 6e 3a 20 20 ing. Caution:
25f10 44 61 74 61 62 61 73 65 20 63 6f 72 72 75 70 74 Database corrupt
25f20 69 6f 6e 20 6d 69 67 68 74 20 72 65 73 75 6c 74 ion might result
25f30 20 69 66 20 74 77 6f 0a 2a 2a 20 20 20 20 20 6f if two.** o
25f40 72 20 6d 6f 72 65 20 70 72 6f 63 65 73 73 65 73 r more processes
25f50 20 77 72 69 74 65 20 74 6f 20 74 68 65 20 73 61 write to the sa
25f60 6d 65 20 64 61 74 61 62 61 73 65 20 61 6e 64 20 me database and
25f70 61 6e 79 20 6f 6e 65 20 6f 66 20 74 68 6f 73 65 any one of those
25f80 0a 2a 2a 20 20 20 20 20 70 72 6f 63 65 73 73 65 .** processe
25f90 73 20 75 73 65 73 20 6e 6f 6c 6f 63 6b 3d 31 2e s uses nolock=1.
25fa0 0a 2a 2a 0a 2a 2a 20 20 3c 6c 69 3e 20 3c 62 3e .**.** <li> <b>
25fb0 69 6d 6d 75 74 61 62 6c 65 3c 2f 62 3e 3a 20 5e immutable</b>: ^
25fc0 54 68 65 20 69 6d 6d 75 74 61 62 6c 65 20 70 61 The immutable pa
25fd0 72 61 6d 65 74 65 72 20 69 73 20 61 20 62 6f 6f rameter is a boo
25fe0 6c 65 61 6e 20 71 75 65 72 79 0a 2a 2a 20 20 20 lean query.**
25ff0 20 20 70 61 72 61 6d 65 74 65 72 20 74 68 61 74 parameter that
26000 20 69 6e 64 69 63 61 74 65 73 20 74 68 61 74 20 indicates that
26010 74 68 65 20 64 61 74 61 62 61 73 65 20 66 69 6c the database fil
26020 65 20 69 73 20 73 74 6f 72 65 64 20 6f 6e 0a 2a e is stored on.*
26030 2a 20 20 20 20 20 72 65 61 64 2d 6f 6e 6c 79 20 * read-only
26040 6d 65 64 69 61 2e 20 20 5e 57 68 65 6e 20 69 6d media. ^When im
26050 6d 75 74 61 62 6c 65 20 69 73 20 73 65 74 2c 20 mutable is set,
26060 53 51 4c 69 74 65 20 61 73 73 75 6d 65 73 20 74 SQLite assumes t
26070 68 61 74 20 74 68 65 0a 2a 2a 20 20 20 20 20 64 hat the.** d
26080 61 74 61 62 61 73 65 20 66 69 6c 65 20 63 61 6e atabase file can
26090 6e 6f 74 20 62 65 20 63 68 61 6e 67 65 64 2c 20 not be changed,
260a0 65 76 65 6e 20 62 79 20 61 20 70 72 6f 63 65 73 even by a proces
260b0 73 20 77 69 74 68 20 68 69 67 68 65 72 0a 2a 2a s with higher.**
260c0 20 20 20 20 20 70 72 69 76 69 6c 65 67 65 2c 20 privilege,
260d0 61 6e 64 20 73 6f 20 74 68 65 20 64 61 74 61 62 and so the datab
260e0 61 73 65 20 69 73 20 6f 70 65 6e 65 64 20 72 65 ase is opened re
260f0 61 64 2d 6f 6e 6c 79 20 61 6e 64 20 61 6c 6c 20 ad-only and all
26100 6c 6f 63 6b 69 6e 67 0a 2a 2a 20 20 20 20 20 61 locking.** a
26110 6e 64 20 63 68 61 6e 67 65 20 64 65 74 65 63 74 nd change detect
26120 69 6f 6e 20 69 73 20 64 69 73 61 62 6c 65 64 2e ion is disabled.
26130 20 20 43 61 75 74 69 6f 6e 3a 20 53 65 74 74 69 Caution: Setti
26140 6e 67 20 74 68 65 20 69 6d 6d 75 74 61 62 6c 65 ng the immutable
26150 0a 2a 2a 20 20 20 20 20 70 72 6f 70 65 72 74 79 .** property
26160 20 6f 6e 20 61 20 64 61 74 61 62 61 73 65 20 66 on a database f
26170 69 6c 65 20 74 68 61 74 20 64 6f 65 73 20 69 6e ile that does in
26180 20 66 61 63 74 20 63 68 61 6e 67 65 20 63 61 6e fact change can
26190 20 72 65 73 75 6c 74 0a 2a 2a 20 20 20 20 20 69 result.** i
261a0 6e 20 69 6e 63 6f 72 72 65 63 74 20 71 75 65 72 n incorrect quer
261b0 79 20 72 65 73 75 6c 74 73 20 61 6e 64 2f 6f 72 y results and/or
261c0 20 5b 53 51 4c 49 54 45 5f 43 4f 52 52 55 50 54 [SQLITE_CORRUPT
261d0 5d 20 65 72 72 6f 72 73 2e 0a 2a 2a 20 20 20 20 ] errors..**
261e0 20 53 65 65 20 61 6c 73 6f 3a 20 5b 53 51 4c 49 See also: [SQLI
261f0 54 45 5f 49 4f 43 41 50 5f 49 4d 4d 55 54 41 42 TE_IOCAP_IMMUTAB
26200 4c 45 5d 2e 0a 2a 2a 20 20 20 20 20 20 20 0a 2a LE]..** .*
26210 2a 20 3c 2f 75 6c 3e 0a 2a 2a 0a 2a 2a 20 5e 53 * </ul>.**.** ^S
26220 70 65 63 69 66 79 69 6e 67 20 61 6e 20 75 6e 6b pecifying an unk
26230 6e 6f 77 6e 20 70 61 72 61 6d 65 74 65 72 20 69 nown parameter i
26240 6e 20 74 68 65 20 71 75 65 72 79 20 63 6f 6d 70 n the query comp
26250 6f 6e 65 6e 74 20 6f 66 20 61 20 55 52 49 20 69 onent of a URI i
26260 73 20 6e 6f 74 20 61 6e 0a 2a 2a 20 65 72 72 6f s not an.** erro
26270 72 2e 20 20 46 75 74 75 72 65 20 76 65 72 73 69 r. Future versi
26280 6f 6e 73 20 6f 66 20 53 51 4c 69 74 65 20 6d 69 ons of SQLite mi
26290 67 68 74 20 75 6e 64 65 72 73 74 61 6e 64 20 61 ght understand a
262a0 64 64 69 74 69 6f 6e 61 6c 20 71 75 65 72 79 0a dditional query.
262b0 2a 2a 20 70 61 72 61 6d 65 74 65 72 73 2e 20 20 ** parameters.
262c0 53 65 65 20 22 5b 71 75 65 72 79 20 70 61 72 61 See "[query para
262d0 6d 65 74 65 72 73 20 77 69 74 68 20 73 70 65 63 meters with spec
262e0 69 61 6c 20 6d 65 61 6e 69 6e 67 20 74 6f 20 53 ial meaning to S
262f0 51 4c 69 74 65 5d 22 20 66 6f 72 0a 2a 2a 20 61 QLite]" for.** a
26300 64 64 69 74 69 6f 6e 61 6c 20 69 6e 66 6f 72 6d dditional inform
26310 61 74 69 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 5b 5b 55 ation..**.** [[U
26320 52 49 20 66 69 6c 65 6e 61 6d 65 20 65 78 61 6d RI filename exam
26330 70 6c 65 73 5d 5d 20 3c 68 33 3e 55 52 49 20 66 ples]] <h3>URI f
26340 69 6c 65 6e 61 6d 65 20 65 78 61 6d 70 6c 65 73 ilename examples
26350 3c 2f 68 33 3e 0a 2a 2a 0a 2a 2a 20 3c 74 61 62 </h3>.**.** <tab
26360 6c 65 20 62 6f 72 64 65 72 3d 22 31 22 20 61 6c le border="1" al
26370 69 67 6e 3d 63 65 6e 74 65 72 20 63 65 6c 6c 70 ign=center cellp
26380 61 64 64 69 6e 67 3d 35 3e 0a 2a 2a 20 3c 74 72 adding=5>.** <tr
26390 3e 3c 74 68 3e 20 55 52 49 20 66 69 6c 65 6e 61 ><th> URI filena
263a0 6d 65 73 20 3c 74 68 3e 20 52 65 73 75 6c 74 73 mes <th> Results
263b0 0a 2a 2a 20 3c 74 72 3e 3c 74 64 3e 20 66 69 6c .** <tr><td> fil
263c0 65 3a 64 61 74 61 2e 64 62 20 3c 74 64 3e 20 0a e:data.db <td> .
263d0 2a 2a 20 20 20 20 20 20 20 20 20 20 4f 70 65 6e ** Open
263e0 20 74 68 65 20 66 69 6c 65 20 22 64 61 74 61 2e the file "data.
263f0 64 62 22 20 69 6e 20 74 68 65 20 63 75 72 72 65 db" in the curre
26400 6e 74 20 64 69 72 65 63 74 6f 72 79 2e 0a 2a 2a nt directory..**
26410 20 3c 74 72 3e 3c 74 64 3e 20 66 69 6c 65 3a 2f <tr><td> file:/
26420 68 6f 6d 65 2f 66 72 65 64 2f 64 61 74 61 2e 64 home/fred/data.d
26430 62 3c 62 72 3e 0a 2a 2a 20 20 20 20 20 20 20 20 b<br>.**
26440 20 20 66 69 6c 65 3a 2f 2f 2f 68 6f 6d 65 2f 66 file:///home/f
26450 72 65 64 2f 64 61 74 61 2e 64 62 20 3c 62 72 3e red/data.db <br>
26460 20 0a 2a 2a 20 20 20 20 20 20 20 20 20 20 66 69 .** fi
26470 6c 65 3a 2f 2f 6c 6f 63 61 6c 68 6f 73 74 2f 68 le://localhost/h
26480 6f 6d 65 2f 66 72 65 64 2f 64 61 74 61 2e 64 62 ome/fred/data.db
26490 20 3c 62 72 3e 20 3c 74 64 3e 20 0a 2a 2a 20 20 <br> <td> .**
264a0 20 20 20 20 20 20 20 20 4f 70 65 6e 20 74 68 65 Open the
264b0 20 64 61 74 61 62 61 73 65 20 66 69 6c 65 20 22 database file "
264c0 2f 68 6f 6d 65 2f 66 72 65 64 2f 64 61 74 61 2e /home/fred/data.
264d0 64 62 22 2e 0a 2a 2a 20 3c 74 72 3e 3c 74 64 3e db"..** <tr><td>
264e0 20 66 69 6c 65 3a 2f 2f 64 61 72 6b 73 74 61 72 file://darkstar
264f0 2f 68 6f 6d 65 2f 66 72 65 64 2f 64 61 74 61 2e /home/fred/data.
26500 64 62 20 3c 74 64 3e 20 0a 2a 2a 20 20 20 20 20 db <td> .**
26510 20 20 20 20 20 41 6e 20 65 72 72 6f 72 2e 20 22 An error. "
26520 64 61 72 6b 73 74 61 72 22 20 69 73 20 6e 6f 74 darkstar" is not
26530 20 61 20 72 65 63 6f 67 6e 69 7a 65 64 20 61 75 a recognized au
26540 74 68 6f 72 69 74 79 2e 0a 2a 2a 20 3c 74 72 3e thority..** <tr>
26550 3c 74 64 20 73 74 79 6c 65 3d 22 77 68 69 74 65 <td style="white
26560 2d 73 70 61 63 65 3a 6e 6f 77 72 61 70 22 3e 20 -space:nowrap">
26570 0a 2a 2a 20 20 20 20 20 20 20 20 20 20 66 69 6c .** fil
26580 65 3a 2f 2f 2f 43 3a 2f 44 6f 63 75 6d 65 6e 74 e:///C:/Document
26590 73 25 32 30 61 6e 64 25 32 30 53 65 74 74 69 6e s%20and%20Settin
265a0 67 73 2f 66 72 65 64 2f 44 65 73 6b 74 6f 70 2f gs/fred/Desktop/
265b0 64 61 74 61 2e 64 62 0a 2a 2a 20 20 20 20 20 3c data.db.** <
265c0 74 64 3e 20 57 69 6e 64 6f 77 73 20 6f 6e 6c 79 td> Windows only
265d0 3a 20 4f 70 65 6e 20 74 68 65 20 66 69 6c 65 20 : Open the file
265e0 22 64 61 74 61 2e 64 62 22 20 6f 6e 20 66 72 65 "data.db" on fre
265f0 64 27 73 20 64 65 73 6b 74 6f 70 20 6f 6e 20 64 d's desktop on d
26600 72 69 76 65 0a 2a 2a 20 20 20 20 20 20 20 20 20 rive.**
26610 20 43 3a 2e 20 4e 6f 74 65 20 74 68 61 74 20 74 C:. Note that t
26620 68 65 20 25 32 30 20 65 73 63 61 70 69 6e 67 20 he %20 escaping
26630 69 6e 20 74 68 69 73 20 65 78 61 6d 70 6c 65 20 in this example
26640 69 73 20 6e 6f 74 20 73 74 72 69 63 74 6c 79 20 is not strictly
26650 0a 2a 2a 20 20 20 20 20 20 20 20 20 20 6e 65 63 .** nec
26660 65 73 73 61 72 79 20 2d 20 73 70 61 63 65 20 63 essary - space c
26670 68 61 72 61 63 74 65 72 73 20 63 61 6e 20 62 65 haracters can be
26680 20 75 73 65 64 20 6c 69 74 65 72 61 6c 6c 79 0a used literally.
26690 2a 2a 20 20 20 20 20 20 20 20 20 20 69 6e 20 55 ** in U
266a0 52 49 20 66 69 6c 65 6e 61 6d 65 73 2e 0a 2a 2a RI filenames..**
266b0 20 3c 74 72 3e 3c 74 64 3e 20 66 69 6c 65 3a 64 <tr><td> file:d
266c0 61 74 61 2e 64 62 3f 6d 6f 64 65 3d 72 6f 26 63 ata.db?mode=ro&c
266d0 61 63 68 65 3d 70 72 69 76 61 74 65 20 3c 74 64 ache=private <td
266e0 3e 20 0a 2a 2a 20 20 20 20 20 20 20 20 20 20 4f > .** O
266f0 70 65 6e 20 66 69 6c 65 20 22 64 61 74 61 2e 64 pen file "data.d
26700 62 22 20 69 6e 20 74 68 65 20 63 75 72 72 65 6e b" in the curren
26710 74 20 64 69 72 65 63 74 6f 72 79 20 66 6f 72 20 t directory for
26720 72 65 61 64 2d 6f 6e 6c 79 20 61 63 63 65 73 73 read-only access
26730 2e 0a 2a 2a 20 20 20 20 20 20 20 20 20 20 52 65 ..** Re
26740 67 61 72 64 6c 65 73 73 20 6f 66 20 77 68 65 74 gardless of whet
26750 68 65 72 20 6f 72 20 6e 6f 74 20 73 68 61 72 65 her or not share
26760 64 2d 63 61 63 68 65 20 6d 6f 64 65 20 69 73 20 d-cache mode is
26770 65 6e 61 62 6c 65 64 20 62 79 0a 2a 2a 20 20 20 enabled by.**
26780 20 20 20 20 20 20 20 64 65 66 61 75 6c 74 2c 20 default,
26790 75 73 65 20 61 20 70 72 69 76 61 74 65 20 63 61 use a private ca
267a0 63 68 65 2e 0a 2a 2a 20 3c 74 72 3e 3c 74 64 3e che..** <tr><td>
267b0 20 66 69 6c 65 3a 2f 68 6f 6d 65 2f 66 72 65 64 file:/home/fred
267c0 2f 64 61 74 61 2e 64 62 3f 76 66 73 3d 75 6e 69 /data.db?vfs=uni
267d0 78 2d 64 6f 74 66 69 6c 65 20 3c 74 64 3e 0a 2a x-dotfile <td>.*
267e0 2a 20 20 20 20 20 20 20 20 20 20 4f 70 65 6e 20 * Open
267f0 66 69 6c 65 20 22 2f 68 6f 6d 65 2f 66 72 65 64 file "/home/fred
26800 2f 64 61 74 61 2e 64 62 22 2e 20 55 73 65 20 74 /data.db". Use t
26810 68 65 20 73 70 65 63 69 61 6c 20 56 46 53 20 22 he special VFS "
26820 75 6e 69 78 2d 64 6f 74 66 69 6c 65 22 0a 2a 2a unix-dotfile".**
26830 20 20 20 20 20 20 20 20 20 20 74 68 61 74 20 75 that u
26840 73 65 73 20 64 6f 74 2d 66 69 6c 65 73 20 69 6e ses dot-files in
26850 20 70 6c 61 63 65 20 6f 66 20 70 6f 73 69 78 20 place of posix
26860 61 64 76 69 73 6f 72 79 20 6c 6f 63 6b 69 6e 67 advisory locking
26870 2e 0a 2a 2a 20 3c 74 72 3e 3c 74 64 3e 20 66 69 ..** <tr><td> fi
26880 6c 65 3a 64 61 74 61 2e 64 62 3f 6d 6f 64 65 3d le:data.db?mode=
26890 72 65 61 64 6f 6e 6c 79 20 3c 74 64 3e 20 0a 2a readonly <td> .*
268a0 2a 20 20 20 20 20 20 20 20 20 20 41 6e 20 65 72 * An er
268b0 72 6f 72 2e 20 22 72 65 61 64 6f 6e 6c 79 22 20 ror. "readonly"
268c0 69 73 20 6e 6f 74 20 61 20 76 61 6c 69 64 20 6f is not a valid o
268d0 70 74 69 6f 6e 20 66 6f 72 20 74 68 65 20 22 6d ption for the "m
268e0 6f 64 65 22 20 70 61 72 61 6d 65 74 65 72 2e 0a ode" parameter..
268f0 2a 2a 20 3c 2f 74 61 62 6c 65 3e 0a 2a 2a 0a 2a ** </table>.**.*
26900 2a 20 5e 55 52 49 20 68 65 78 61 64 65 63 69 6d * ^URI hexadecim
26910 61 6c 20 65 73 63 61 70 65 20 73 65 71 75 65 6e al escape sequen
26920 63 65 73 20 28 25 48 48 29 20 61 72 65 20 73 75 ces (%HH) are su
26930 70 70 6f 72 74 65 64 20 77 69 74 68 69 6e 20 74 pported within t
26940 68 65 20 70 61 74 68 20 61 6e 64 0a 2a 2a 20 71 he path and.** q
26950 75 65 72 79 20 63 6f 6d 70 6f 6e 65 6e 74 73 20 uery components
26960 6f 66 20 61 20 55 52 49 2e 20 41 20 68 65 78 61 of a URI. A hexa
26970 64 65 63 69 6d 61 6c 20 65 73 63 61 70 65 20 73 decimal escape s
26980 65 71 75 65 6e 63 65 20 63 6f 6e 73 69 73 74 73 equence consists
26990 20 6f 66 20 61 0a 2a 2a 20 70 65 72 63 65 6e 74 of a.** percent
269a0 20 73 69 67 6e 20 2d 20 22 25 22 20 2d 20 66 6f sign - "%" - fo
269b0 6c 6c 6f 77 65 64 20 62 79 20 65 78 61 63 74 6c llowed by exactl
269c0 79 20 74 77 6f 20 68 65 78 61 64 65 63 69 6d 61 y two hexadecima
269d0 6c 20 64 69 67 69 74 73 20 0a 2a 2a 20 73 70 65 l digits .** spe
269e0 63 69 66 79 69 6e 67 20 61 6e 20 6f 63 74 65 74 cifying an octet
269f0 20 76 61 6c 75 65 2e 20 5e 42 65 66 6f 72 65 20 value. ^Before
26a00 74 68 65 20 70 61 74 68 20 6f 72 20 71 75 65 72 the path or quer
26a10 79 20 63 6f 6d 70 6f 6e 65 6e 74 73 20 6f 66 20 y components of
26a20 61 0a 2a 2a 20 55 52 49 20 66 69 6c 65 6e 61 6d a.** URI filenam
26a30 65 20 61 72 65 20 69 6e 74 65 72 70 72 65 74 65 e are interprete
26a40 64 2c 20 74 68 65 79 20 61 72 65 20 65 6e 63 6f d, they are enco
26a50 64 65 64 20 75 73 69 6e 67 20 55 54 46 2d 38 20 ded using UTF-8
26a60 61 6e 64 20 61 6c 6c 20 0a 2a 2a 20 68 65 78 61 and all .** hexa
26a70 64 65 63 69 6d 61 6c 20 65 73 63 61 70 65 20 73 decimal escape s
26a80 65 71 75 65 6e 63 65 73 20 72 65 70 6c 61 63 65 equences replace
26a90 64 20 62 79 20 61 20 73 69 6e 67 6c 65 20 62 79 d by a single by
26aa0 74 65 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 te containing th
26ab0 65 0a 2a 2a 20 63 6f 72 72 65 73 70 6f 6e 64 69 e.** correspondi
26ac0 6e 67 20 6f 63 74 65 74 2e 20 49 66 20 74 68 69 ng octet. If thi
26ad0 73 20 70 72 6f 63 65 73 73 20 67 65 6e 65 72 61 s process genera
26ae0 74 65 73 20 61 6e 20 69 6e 76 61 6c 69 64 20 55 tes an invalid U
26af0 54 46 2d 38 20 65 6e 63 6f 64 69 6e 67 2c 0a 2a TF-8 encoding,.*
26b00 2a 20 74 68 65 20 72 65 73 75 6c 74 73 20 61 72 * the results ar
26b10 65 20 75 6e 64 65 66 69 6e 65 64 2e 0a 2a 2a 0a e undefined..**.
26b20 2a 2a 20 3c 62 3e 4e 6f 74 65 20 74 6f 20 57 69 ** <b>Note to Wi
26b30 6e 64 6f 77 73 20 75 73 65 72 73 3a 3c 2f 62 3e ndows users:</b>
26b40 20 20 54 68 65 20 65 6e 63 6f 64 69 6e 67 20 75 The encoding u
26b50 73 65 64 20 66 6f 72 20 74 68 65 20 66 69 6c 65 sed for the file
26b60 6e 61 6d 65 20 61 72 67 75 6d 65 6e 74 0a 2a 2a name argument.**
26b70 20 6f 66 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e of sqlite3_open
26b80 28 29 20 61 6e 64 20 73 71 6c 69 74 65 33 5f 6f () and sqlite3_o
26b90 70 65 6e 5f 76 32 28 29 20 6d 75 73 74 20 62 65 pen_v2() must be
26ba0 20 55 54 46 2d 38 2c 20 6e 6f 74 20 77 68 61 74 UTF-8, not what
26bb0 65 76 65 72 0a 2a 2a 20 63 6f 64 65 70 61 67 65 ever.** codepage
26bc0 20 69 73 20 63 75 72 72 65 6e 74 6c 79 20 64 65 is currently de
26bd0 66 69 6e 65 64 2e 20 20 46 69 6c 65 6e 61 6d 65 fined. Filename
26be0 73 20 63 6f 6e 74 61 69 6e 69 6e 67 20 69 6e 74 s containing int
26bf0 65 72 6e 61 74 69 6f 6e 61 6c 0a 2a 2a 20 63 68 ernational.** ch
26c00 61 72 61 63 74 65 72 73 20 6d 75 73 74 20 62 65 aracters must be
26c10 20 63 6f 6e 76 65 72 74 65 64 20 74 6f 20 55 54 converted to UT
26c20 46 2d 38 20 70 72 69 6f 72 20 74 6f 20 70 61 73 F-8 prior to pas
26c30 73 69 6e 67 20 74 68 65 6d 20 69 6e 74 6f 0a 2a sing them into.*
26c40 2a 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e 28 29 * sqlite3_open()
26c50 20 6f 72 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e or sqlite3_open
26c60 5f 76 32 28 29 2e 0a 2a 2a 0a 2a 2a 20 3c 62 3e _v2()..**.** <b>
26c70 4e 6f 74 65 20 74 6f 20 57 69 6e 64 6f 77 73 20 Note to Windows
26c80 52 75 6e 74 69 6d 65 20 75 73 65 72 73 3a 3c 2f Runtime users:</
26c90 62 3e 20 20 54 68 65 20 74 65 6d 70 6f 72 61 72 b> The temporar
26ca0 79 20 64 69 72 65 63 74 6f 72 79 20 6d 75 73 74 y directory must
26cb0 20 62 65 20 73 65 74 0a 2a 2a 20 70 72 69 6f 72 be set.** prior
26cc0 20 74 6f 20 63 61 6c 6c 69 6e 67 20 73 71 6c 69 to calling sqli
26cd0 74 65 33 5f 6f 70 65 6e 28 29 20 6f 72 20 73 71 te3_open() or sq
26ce0 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 32 28 29 2e lite3_open_v2().
26cf0 20 20 4f 74 68 65 72 77 69 73 65 2c 20 76 61 72 Otherwise, var
26d00 69 6f 75 73 0a 2a 2a 20 66 65 61 74 75 72 65 73 ious.** features
26d10 20 74 68 61 74 20 72 65 71 75 69 72 65 20 74 68 that require th
26d20 65 20 75 73 65 20 6f 66 20 74 65 6d 70 6f 72 61 e use of tempora
26d30 72 79 20 66 69 6c 65 73 20 6d 61 79 20 66 61 69 ry files may fai
26d40 6c 2e 0a 2a 2a 0a 2a 2a 20 53 65 65 20 61 6c 73 l..**.** See als
26d50 6f 3a 20 5b 73 71 6c 69 74 65 33 5f 74 65 6d 70 o: [sqlite3_temp
26d60 5f 64 69 72 65 63 74 6f 72 79 5d 0a 2a 2f 0a 69 _directory].*/.i
26d70 6e 74 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e 28 nt sqlite3_open(
26d80 0a 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 66 . const char *f
26d90 69 6c 65 6e 61 6d 65 2c 20 20 20 2f 2a 20 44 61 ilename, /* Da
26da0 74 61 62 61 73 65 20 66 69 6c 65 6e 61 6d 65 20 tabase filename
26db0 28 55 54 46 2d 38 29 20 2a 2f 0a 20 20 73 71 6c (UTF-8) */. sql
26dc0 69 74 65 33 20 2a 2a 70 70 44 62 20 20 20 20 20 ite3 **ppDb
26dd0 20 20 20 20 20 2f 2a 20 4f 55 54 3a 20 53 51 4c /* OUT: SQL
26de0 69 74 65 20 64 62 20 68 61 6e 64 6c 65 20 2a 2f ite db handle */
26df0 0a 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f .);.int sqlite3_
26e00 6f 70 65 6e 31 36 28 0a 20 20 63 6f 6e 73 74 20 open16(. const
26e10 76 6f 69 64 20 2a 66 69 6c 65 6e 61 6d 65 2c 20 void *filename,
26e20 20 20 2f 2a 20 44 61 74 61 62 61 73 65 20 66 69 /* Database fi
26e30 6c 65 6e 61 6d 65 20 28 55 54 46 2d 31 36 29 20 lename (UTF-16)
26e40 2a 2f 0a 20 20 73 71 6c 69 74 65 33 20 2a 2a 70 */. sqlite3 **p
26e50 70 44 62 20 20 20 20 20 20 20 20 20 20 2f 2a 20 pDb /*
26e60 4f 55 54 3a 20 53 51 4c 69 74 65 20 64 62 20 68 OUT: SQLite db h
26e70 61 6e 64 6c 65 20 2a 2f 0a 29 3b 0a 69 6e 74 20 andle */.);.int
26e80 73 71 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 32 28 sqlite3_open_v2(
26e90 0a 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 66 . const char *f
26ea0 69 6c 65 6e 61 6d 65 2c 20 20 20 2f 2a 20 44 61 ilename, /* Da
26eb0 74 61 62 61 73 65 20 66 69 6c 65 6e 61 6d 65 20 tabase filename
26ec0 28 55 54 46 2d 38 29 20 2a 2f 0a 20 20 73 71 6c (UTF-8) */. sql
26ed0 69 74 65 33 20 2a 2a 70 70 44 62 2c 20 20 20 20 ite3 **ppDb,
26ee0 20 20 20 20 20 2f 2a 20 4f 55 54 3a 20 53 51 4c /* OUT: SQL
26ef0 69 74 65 20 64 62 20 68 61 6e 64 6c 65 20 2a 2f ite db handle */
26f00 0a 20 20 69 6e 74 20 66 6c 61 67 73 2c 20 20 20 . int flags,
26f10 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 46 6c /* Fl
26f20 61 67 73 20 2a 2f 0a 20 20 63 6f 6e 73 74 20 63 ags */. const c
26f30 68 61 72 20 2a 7a 56 66 73 20 20 20 20 20 20 20 har *zVfs
26f40 20 2f 2a 20 4e 61 6d 65 20 6f 66 20 56 46 53 20 /* Name of VFS
26f50 6d 6f 64 75 6c 65 20 74 6f 20 75 73 65 20 2a 2f module to use */
26f60 0a 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 .);../*.** CAPI3
26f70 52 45 46 3a 20 4f 62 74 61 69 6e 20 56 61 6c 75 REF: Obtain Valu
26f80 65 73 20 46 6f 72 20 55 52 49 20 50 61 72 61 6d es For URI Param
26f90 65 74 65 72 73 0a 2a 2a 0a 2a 2a 20 54 68 65 73 eters.**.** Thes
26fa0 65 20 61 72 65 20 75 74 69 6c 69 74 79 20 72 6f e are utility ro
26fb0 75 74 69 6e 65 73 2c 20 75 73 65 66 75 6c 20 74 utines, useful t
26fc0 6f 20 56 46 53 20 69 6d 70 6c 65 6d 65 6e 74 61 o VFS implementa
26fd0 74 69 6f 6e 73 2c 20 74 68 61 74 20 63 68 65 63 tions, that chec
26fe0 6b 0a 2a 2a 20 74 6f 20 73 65 65 20 69 66 20 61 k.** to see if a
26ff0 20 64 61 74 61 62 61 73 65 20 66 69 6c 65 20 77 database file w
27000 61 73 20 61 20 55 52 49 20 74 68 61 74 20 63 6f as a URI that co
27010 6e 74 61 69 6e 65 64 20 61 20 73 70 65 63 69 66 ntained a specif
27020 69 63 20 71 75 65 72 79 20 0a 2a 2a 20 70 61 72 ic query .** par
27030 61 6d 65 74 65 72 2c 20 61 6e 64 20 69 66 20 73 ameter, and if s
27040 6f 20 6f 62 74 61 69 6e 73 20 74 68 65 20 76 61 o obtains the va
27050 6c 75 65 20 6f 66 20 74 68 61 74 20 71 75 65 72 lue of that quer
27060 79 20 70 61 72 61 6d 65 74 65 72 2e 0a 2a 2a 0a y parameter..**.
27070 2a 2a 20 49 66 20 46 20 69 73 20 74 68 65 20 64 ** If F is the d
27080 61 74 61 62 61 73 65 20 66 69 6c 65 6e 61 6d 65 atabase filename
27090 20 70 6f 69 6e 74 65 72 20 70 61 73 73 65 64 20 pointer passed
270a0 69 6e 74 6f 20 74 68 65 20 78 4f 70 65 6e 28 29 into the xOpen()
270b0 20 6d 65 74 68 6f 64 20 6f 66 20 0a 2a 2a 20 61 method of .** a
270c0 20 56 46 53 20 69 6d 70 6c 65 6d 65 6e 74 61 74 VFS implementat
270d0 69 6f 6e 20 77 68 65 6e 20 74 68 65 20 66 6c 61 ion when the fla
270e0 67 73 20 70 61 72 61 6d 65 74 65 72 20 74 6f 20 gs parameter to
270f0 78 4f 70 65 6e 28 29 20 68 61 73 20 6f 6e 65 20 xOpen() has one
27100 6f 72 20 0a 2a 2a 20 6d 6f 72 65 20 6f 66 20 74 or .** more of t
27110 68 65 20 5b 53 51 4c 49 54 45 5f 4f 50 45 4e 5f he [SQLITE_OPEN_
27120 55 52 49 5d 20 6f 72 20 5b 53 51 4c 49 54 45 5f URI] or [SQLITE_
27130 4f 50 45 4e 5f 4d 41 49 4e 5f 44 42 5d 20 62 69 OPEN_MAIN_DB] bi
27140 74 73 20 73 65 74 20 61 6e 64 0a 2a 2a 20 50 20 ts set and.** P
27150 69 73 20 74 68 65 20 6e 61 6d 65 20 6f 66 20 74 is the name of t
27160 68 65 20 71 75 65 72 79 20 70 61 72 61 6d 65 74 he query paramet
27170 65 72 2c 20 74 68 65 6e 0a 2a 2a 20 73 71 6c 69 er, then.** sqli
27180 74 65 33 5f 75 72 69 5f 70 61 72 61 6d 65 74 65 te3_uri_paramete
27190 72 28 46 2c 50 29 20 72 65 74 75 72 6e 73 20 74 r(F,P) returns t
271a0 68 65 20 76 61 6c 75 65 20 6f 66 20 74 68 65 20 he value of the
271b0 50 0a 2a 2a 20 70 61 72 61 6d 65 74 65 72 20 69 P.** parameter i
271c0 66 20 69 74 20 65 78 69 73 74 73 20 6f 72 20 61 f it exists or a
271d0 20 4e 55 4c 4c 20 70 6f 69 6e 74 65 72 20 69 66 NULL pointer if
271e0 20 50 20 64 6f 65 73 20 6e 6f 74 20 61 70 70 65 P does not appe
271f0 61 72 20 61 73 20 61 20 0a 2a 2a 20 71 75 65 72 ar as a .** quer
27200 79 20 70 61 72 61 6d 65 74 65 72 20 6f 6e 20 46 y parameter on F
27210 2e 20 20 49 66 20 50 20 69 73 20 61 20 71 75 65 . If P is a que
27220 72 79 20 70 61 72 61 6d 65 74 65 72 20 6f 66 20 ry parameter of
27230 46 0a 2a 2a 20 68 61 73 20 6e 6f 20 65 78 70 6c F.** has no expl
27240 69 63 69 74 20 76 61 6c 75 65 2c 20 74 68 65 6e icit value, then
27250 20 73 71 6c 69 74 65 33 5f 75 72 69 5f 70 61 72 sqlite3_uri_par
27260 61 6d 65 74 65 72 28 46 2c 50 29 20 72 65 74 75 ameter(F,P) retu
27270 72 6e 73 0a 2a 2a 20 61 20 70 6f 69 6e 74 65 72 rns.** a pointer
27280 20 74 6f 20 61 6e 20 65 6d 70 74 79 20 73 74 72 to an empty str
27290 69 6e 67 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 73 ing..**.** The s
272a0 71 6c 69 74 65 33 5f 75 72 69 5f 62 6f 6f 6c 65 qlite3_uri_boole
272b0 61 6e 28 46 2c 50 2c 42 29 20 72 6f 75 74 69 6e an(F,P,B) routin
272c0 65 20 61 73 73 75 6d 65 73 20 74 68 61 74 20 50 e assumes that P
272d0 20 69 73 20 61 20 62 6f 6f 6c 65 61 6e 0a 2a 2a is a boolean.**
272e0 20 70 61 72 61 6d 65 74 65 72 20 61 6e 64 20 72 parameter and r
272f0 65 74 75 72 6e 73 20 74 72 75 65 20 28 31 29 20 eturns true (1)
27300 6f 72 20 66 61 6c 73 65 20 28 30 29 20 61 63 63 or false (0) acc
27310 6f 72 64 69 6e 67 20 74 6f 20 74 68 65 20 76 61 ording to the va
27320 6c 75 65 0a 2a 2a 20 6f 66 20 50 2e 20 20 54 68 lue.** of P. Th
27330 65 20 73 71 6c 69 74 65 33 5f 75 72 69 5f 62 6f e sqlite3_uri_bo
27340 6f 6c 65 61 6e 28 46 2c 50 2c 42 29 20 72 6f 75 olean(F,P,B) rou
27350 74 69 6e 65 20 72 65 74 75 72 6e 73 20 74 72 75 tine returns tru
27360 65 20 28 31 29 20 69 66 20 74 68 65 0a 2a 2a 20 e (1) if the.**
27370 76 61 6c 75 65 20 6f 66 20 71 75 65 72 79 20 70 value of query p
27380 61 72 61 6d 65 74 65 72 20 50 20 69 73 20 6f 6e arameter P is on
27390 65 20 6f 66 20 22 79 65 73 22 2c 20 22 74 72 75 e of "yes", "tru
273a0 65 22 2c 20 6f 72 20 22 6f 6e 22 20 69 6e 20 61 e", or "on" in a
273b0 6e 79 0a 2a 2a 20 63 61 73 65 20 6f 72 20 69 66 ny.** case or if
273c0 20 74 68 65 20 76 61 6c 75 65 20 62 65 67 69 6e the value begin
273d0 73 20 77 69 74 68 20 61 20 6e 6f 6e 2d 7a 65 72 s with a non-zer
273e0 6f 20 6e 75 6d 62 65 72 2e 20 20 54 68 65 20 0a o number. The .
273f0 2a 2a 20 73 71 6c 69 74 65 33 5f 75 72 69 5f 62 ** sqlite3_uri_b
27400 6f 6f 6c 65 61 6e 28 46 2c 50 2c 42 29 20 72 6f oolean(F,P,B) ro
27410 75 74 69 6e 65 73 20 72 65 74 75 72 6e 73 20 66 utines returns f
27420 61 6c 73 65 20 28 30 29 20 69 66 20 74 68 65 20 alse (0) if the
27430 76 61 6c 75 65 20 6f 66 0a 2a 2a 20 71 75 65 72 value of.** quer
27440 79 20 70 61 72 61 6d 65 74 65 72 20 50 20 69 73 y parameter P is
27450 20 6f 6e 65 20 6f 66 20 22 6e 6f 22 2c 20 22 66 one of "no", "f
27460 61 6c 73 65 22 2c 20 6f 72 20 22 6f 66 66 22 20 alse", or "off"
27470 69 6e 20 61 6e 79 20 63 61 73 65 20 6f 72 0a 2a in any case or.*
27480 2a 20 69 66 20 74 68 65 20 76 61 6c 75 65 20 62 * if the value b
27490 65 67 69 6e 73 20 77 69 74 68 20 61 20 6e 75 6d egins with a num
274a0 65 72 69 63 20 7a 65 72 6f 2e 20 20 49 66 20 50 eric zero. If P
274b0 20 69 73 20 6e 6f 74 20 61 20 71 75 65 72 79 0a is not a query.
274c0 2a 2a 20 70 61 72 61 6d 65 74 65 72 20 6f 6e 20 ** parameter on
274d0 46 20 6f 72 20 69 66 20 74 68 65 20 76 61 6c 75 F or if the valu
274e0 65 20 6f 66 20 50 20 69 73 20 64 6f 65 73 20 6e e of P is does n
274f0 6f 74 20 6d 61 74 63 68 20 61 6e 79 20 6f 66 20 ot match any of
27500 74 68 65 0a 2a 2a 20 61 62 6f 76 65 2c 20 74 68 the.** above, th
27510 65 6e 20 73 71 6c 69 74 65 33 5f 75 72 69 5f 62 en sqlite3_uri_b
27520 6f 6f 6c 65 61 6e 28 46 2c 50 2c 42 29 20 72 65 oolean(F,P,B) re
27530 74 75 72 6e 73 20 28 42 21 3d 30 29 2e 0a 2a 2a turns (B!=0)..**
27540 0a 2a 2a 20 54 68 65 20 73 71 6c 69 74 65 33 5f .** The sqlite3_
27550 75 72 69 5f 69 6e 74 36 34 28 46 2c 50 2c 44 29 uri_int64(F,P,D)
27560 20 72 6f 75 74 69 6e 65 20 63 6f 6e 76 65 72 74 routine convert
27570 73 20 74 68 65 20 76 61 6c 75 65 20 6f 66 20 50 s the value of P
27580 20 69 6e 74 6f 20 61 0a 2a 2a 20 36 34 2d 62 69 into a.** 64-bi
27590 74 20 73 69 67 6e 65 64 20 69 6e 74 65 67 65 72 t signed integer
275a0 20 61 6e 64 20 72 65 74 75 72 6e 73 20 74 68 61 and returns tha
275b0 74 20 69 6e 74 65 67 65 72 2c 20 6f 72 20 44 20 t integer, or D
275c0 69 66 20 50 20 64 6f 65 73 20 6e 6f 74 0a 2a 2a if P does not.**
275d0 20 65 78 69 73 74 2e 20 20 49 66 20 74 68 65 20 exist. If the
275e0 76 61 6c 75 65 20 6f 66 20 50 20 69 73 20 73 6f value of P is so
275f0 6d 65 74 68 69 6e 67 20 6f 74 68 65 72 20 74 68 mething other th
27600 61 6e 20 61 6e 20 69 6e 74 65 67 65 72 2c 20 74 an an integer, t
27610 68 65 6e 0a 2a 2a 20 7a 65 72 6f 20 69 73 20 72 hen.** zero is r
27620 65 74 75 72 6e 65 64 2e 0a 2a 2a 20 0a 2a 2a 20 eturned..** .**
27630 49 66 20 46 20 69 73 20 61 20 4e 55 4c 4c 20 70 If F is a NULL p
27640 6f 69 6e 74 65 72 2c 20 74 68 65 6e 20 73 71 6c ointer, then sql
27650 69 74 65 33 5f 75 72 69 5f 70 61 72 61 6d 65 74 ite3_uri_paramet
27660 65 72 28 46 2c 50 29 20 72 65 74 75 72 6e 73 20 er(F,P) returns
27670 4e 55 4c 4c 20 61 6e 64 0a 2a 2a 20 73 71 6c 69 NULL and.** sqli
27680 74 65 33 5f 75 72 69 5f 62 6f 6f 6c 65 61 6e 28 te3_uri_boolean(
27690 46 2c 50 2c 42 29 20 72 65 74 75 72 6e 73 20 42 F,P,B) returns B
276a0 2e 20 20 49 66 20 46 20 69 73 20 6e 6f 74 20 61 . If F is not a
276b0 20 4e 55 4c 4c 20 70 6f 69 6e 74 65 72 20 61 6e NULL pointer an
276c0 64 0a 2a 2a 20 69 73 20 6e 6f 74 20 61 20 64 61 d.** is not a da
276d0 74 61 62 61 73 65 20 66 69 6c 65 20 70 61 74 68 tabase file path
276e0 6e 61 6d 65 20 70 6f 69 6e 74 65 72 20 74 68 61 name pointer tha
276f0 74 20 53 51 4c 69 74 65 20 70 61 73 73 65 64 20 t SQLite passed
27700 69 6e 74 6f 20 74 68 65 20 78 4f 70 65 6e 0a 2a into the xOpen.*
27710 2a 20 56 46 53 20 6d 65 74 68 6f 64 2c 20 74 68 * VFS method, th
27720 65 6e 20 74 68 65 20 62 65 68 61 76 69 6f 72 20 en the behavior
27730 6f 66 20 74 68 69 73 20 72 6f 75 74 69 6e 65 20 of this routine
27740 69 73 20 75 6e 64 65 66 69 6e 65 64 20 61 6e 64 is undefined and
27750 20 70 72 6f 62 61 62 6c 79 0a 2a 2a 20 75 6e 64 probably.** und
27760 65 73 69 72 61 62 6c 65 2e 0a 2a 2f 0a 63 6f 6e esirable..*/.con
27770 73 74 20 63 68 61 72 20 2a 73 71 6c 69 74 65 33 st char *sqlite3
27780 5f 75 72 69 5f 70 61 72 61 6d 65 74 65 72 28 63 _uri_parameter(c
27790 6f 6e 73 74 20 63 68 61 72 20 2a 7a 46 69 6c 65 onst char *zFile
277a0 6e 61 6d 65 2c 20 63 6f 6e 73 74 20 63 68 61 72 name, const char
277b0 20 2a 7a 50 61 72 61 6d 29 3b 0a 69 6e 74 20 73 *zParam);.int s
277c0 71 6c 69 74 65 33 5f 75 72 69 5f 62 6f 6f 6c 65 qlite3_uri_boole
277d0 61 6e 28 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a an(const char *z
277e0 46 69 6c 65 2c 20 63 6f 6e 73 74 20 63 68 61 72 File, const char
277f0 20 2a 7a 50 61 72 61 6d 2c 20 69 6e 74 20 62 44 *zParam, int bD
27800 65 66 61 75 6c 74 29 3b 0a 73 71 6c 69 74 65 33 efault);.sqlite3
27810 5f 69 6e 74 36 34 20 73 71 6c 69 74 65 33 5f 75 _int64 sqlite3_u
27820 72 69 5f 69 6e 74 36 34 28 63 6f 6e 73 74 20 63 ri_int64(const c
27830 68 61 72 2a 2c 20 63 6f 6e 73 74 20 63 68 61 72 har*, const char
27840 2a 2c 20 73 71 6c 69 74 65 33 5f 69 6e 74 36 34 *, sqlite3_int64
27850 29 3b 0a 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 );.../*.** CAPI3
27860 52 45 46 3a 20 45 72 72 6f 72 20 43 6f 64 65 73 REF: Error Codes
27870 20 41 6e 64 20 4d 65 73 73 61 67 65 73 0a 2a 2a And Messages.**
27880 20 4d 45 54 48 4f 44 3a 20 73 71 6c 69 74 65 33 METHOD: sqlite3
27890 0a 2a 2a 0a 2a 2a 20 5e 49 66 20 74 68 65 20 6d .**.** ^If the m
278a0 6f 73 74 20 72 65 63 65 6e 74 20 73 71 6c 69 74 ost recent sqlit
278b0 65 33 5f 2a 20 41 50 49 20 63 61 6c 6c 20 61 73 e3_* API call as
278c0 73 6f 63 69 61 74 65 64 20 77 69 74 68 20 0a 2a sociated with .*
278d0 2a 20 5b 64 61 74 61 62 61 73 65 20 63 6f 6e 6e * [database conn
278e0 65 63 74 69 6f 6e 5d 20 44 20 66 61 69 6c 65 64 ection] D failed
278f0 2c 20 74 68 65 6e 20 74 68 65 20 73 71 6c 69 74 , then the sqlit
27900 65 33 5f 65 72 72 63 6f 64 65 28 44 29 20 69 6e e3_errcode(D) in
27910 74 65 72 66 61 63 65 0a 2a 2a 20 72 65 74 75 72 terface.** retur
27920 6e 73 20 74 68 65 20 6e 75 6d 65 72 69 63 20 5b ns the numeric [
27930 72 65 73 75 6c 74 20 63 6f 64 65 5d 20 6f 72 20 result code] or
27940 5b 65 78 74 65 6e 64 65 64 20 72 65 73 75 6c 74 [extended result
27950 20 63 6f 64 65 5d 20 66 6f 72 20 74 68 61 74 0a code] for that.
27960 2a 2a 20 41 50 49 20 63 61 6c 6c 2e 0a 2a 2a 20 ** API call..**
27970 49 66 20 74 68 65 20 6d 6f 73 74 20 72 65 63 65 If the most rece
27980 6e 74 20 41 50 49 20 63 61 6c 6c 20 77 61 73 20 nt API call was
27990 73 75 63 63 65 73 73 66 75 6c 2c 0a 2a 2a 20 74 successful,.** t
279a0 68 65 6e 20 74 68 65 20 72 65 74 75 72 6e 20 76 hen the return v
279b0 61 6c 75 65 20 66 72 6f 6d 20 73 71 6c 69 74 65 alue from sqlite
279c0 33 5f 65 72 72 63 6f 64 65 28 29 20 69 73 20 75 3_errcode() is u
279d0 6e 64 65 66 69 6e 65 64 2e 0a 2a 2a 20 5e 54 68 ndefined..** ^Th
279e0 65 20 73 71 6c 69 74 65 33 5f 65 78 74 65 6e 64 e sqlite3_extend
279f0 65 64 5f 65 72 72 63 6f 64 65 28 29 0a 2a 2a 20 ed_errcode().**
27a00 69 6e 74 65 72 66 61 63 65 20 69 73 20 74 68 65 interface is the
27a10 20 73 61 6d 65 20 65 78 63 65 70 74 20 74 68 61 same except tha
27a20 74 20 69 74 20 61 6c 77 61 79 73 20 72 65 74 75 t it always retu
27a30 72 6e 73 20 74 68 65 20 0a 2a 2a 20 5b 65 78 74 rns the .** [ext
27a40 65 6e 64 65 64 20 72 65 73 75 6c 74 20 63 6f 64 ended result cod
27a50 65 5d 20 65 76 65 6e 20 77 68 65 6e 20 65 78 74 e] even when ext
27a60 65 6e 64 65 64 20 72 65 73 75 6c 74 20 63 6f 64 ended result cod
27a70 65 73 20 61 72 65 0a 2a 2a 20 64 69 73 61 62 6c es are.** disabl
27a80 65 64 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 ed..**.** ^The s
27a90 71 6c 69 74 65 33 5f 65 72 72 6d 73 67 28 29 20 qlite3_errmsg()
27aa0 61 6e 64 20 73 71 6c 69 74 65 33 5f 65 72 72 6d and sqlite3_errm
27ab0 73 67 31 36 28 29 20 72 65 74 75 72 6e 20 45 6e sg16() return En
27ac0 67 6c 69 73 68 2d 6c 61 6e 67 75 61 67 65 0a 2a glish-language.*
27ad0 2a 20 74 65 78 74 20 74 68 61 74 20 64 65 73 63 * text that desc
27ae0 72 69 62 65 73 20 74 68 65 20 65 72 72 6f 72 2c ribes the error,
27af0 20 61 73 20 65 69 74 68 65 72 20 55 54 46 2d 38 as either UTF-8
27b00 20 6f 72 20 55 54 46 2d 31 36 20 72 65 73 70 65 or UTF-16 respe
27b10 63 74 69 76 65 6c 79 2e 0a 2a 2a 20 5e 28 4d 65 ctively..** ^(Me
27b20 6d 6f 72 79 20 74 6f 20 68 6f 6c 64 20 74 68 65 mory to hold the
27b30 20 65 72 72 6f 72 20 6d 65 73 73 61 67 65 20 73 error message s
27b40 74 72 69 6e 67 20 69 73 20 6d 61 6e 61 67 65 64 tring is managed
27b50 20 69 6e 74 65 72 6e 61 6c 6c 79 2e 0a 2a 2a 20 internally..**
27b60 54 68 65 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 The application
27b70 64 6f 65 73 20 6e 6f 74 20 6e 65 65 64 20 74 6f does not need to
27b80 20 77 6f 72 72 79 20 61 62 6f 75 74 20 66 72 65 worry about fre
27b90 65 69 6e 67 20 74 68 65 20 72 65 73 75 6c 74 2e eing the result.
27ba0 0a 2a 2a 20 48 6f 77 65 76 65 72 2c 20 74 68 65 .** However, the
27bb0 20 65 72 72 6f 72 20 73 74 72 69 6e 67 20 6d 69 error string mi
27bc0 67 68 74 20 62 65 20 6f 76 65 72 77 72 69 74 74 ght be overwritt
27bd0 65 6e 20 6f 72 20 64 65 61 6c 6c 6f 63 61 74 65 en or deallocate
27be0 64 20 62 79 0a 2a 2a 20 73 75 62 73 65 71 75 65 d by.** subseque
27bf0 6e 74 20 63 61 6c 6c 73 20 74 6f 20 6f 74 68 65 nt calls to othe
27c00 72 20 53 51 4c 69 74 65 20 69 6e 74 65 72 66 61 r SQLite interfa
27c10 63 65 20 66 75 6e 63 74 69 6f 6e 73 2e 29 5e 0a ce functions.)^.
27c20 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 6c 69 74 **.** ^The sqlit
27c30 65 33 5f 65 72 72 73 74 72 28 29 20 69 6e 74 65 e3_errstr() inte
27c40 72 66 61 63 65 20 72 65 74 75 72 6e 73 20 74 68 rface returns th
27c50 65 20 45 6e 67 6c 69 73 68 2d 6c 61 6e 67 75 61 e English-langua
27c60 67 65 20 74 65 78 74 0a 2a 2a 20 74 68 61 74 20 ge text.** that
27c70 64 65 73 63 72 69 62 65 73 20 74 68 65 20 5b 72 describes the [r
27c80 65 73 75 6c 74 20 63 6f 64 65 5d 2c 20 61 73 20 esult code], as
27c90 55 54 46 2d 38 2e 0a 2a 2a 20 5e 28 4d 65 6d 6f UTF-8..** ^(Memo
27ca0 72 79 20 74 6f 20 68 6f 6c 64 20 74 68 65 20 65 ry to hold the e
27cb0 72 72 6f 72 20 6d 65 73 73 61 67 65 20 73 74 72 rror message str
27cc0 69 6e 67 20 69 73 20 6d 61 6e 61 67 65 64 20 69 ing is managed i
27cd0 6e 74 65 72 6e 61 6c 6c 79 0a 2a 2a 20 61 6e 64 nternally.** and
27ce0 20 6d 75 73 74 20 6e 6f 74 20 62 65 20 66 72 65 must not be fre
27cf0 65 64 20 62 79 20 74 68 65 20 61 70 70 6c 69 63 ed by the applic
27d00 61 74 69 6f 6e 29 5e 2e 0a 2a 2a 0a 2a 2a 20 57 ation)^..**.** W
27d10 68 65 6e 20 74 68 65 20 73 65 72 69 61 6c 69 7a hen the serializ
27d20 65 64 20 5b 74 68 72 65 61 64 69 6e 67 20 6d 6f ed [threading mo
27d30 64 65 5d 20 69 73 20 69 6e 20 75 73 65 2c 20 69 de] is in use, i
27d40 74 20 6d 69 67 68 74 20 62 65 20 74 68 65 0a 2a t might be the.*
27d50 2a 20 63 61 73 65 20 74 68 61 74 20 61 20 73 65 * case that a se
27d60 63 6f 6e 64 20 65 72 72 6f 72 20 6f 63 63 75 72 cond error occur
27d70 73 20 6f 6e 20 61 20 73 65 70 61 72 61 74 65 20 s on a separate
27d80 74 68 72 65 61 64 20 69 6e 20 62 65 74 77 65 65 thread in betwee
27d90 6e 0a 2a 2a 20 74 68 65 20 74 69 6d 65 20 6f 66 n.** the time of
27da0 20 74 68 65 20 66 69 72 73 74 20 65 72 72 6f 72 the first error
27db0 20 61 6e 64 20 74 68 65 20 63 61 6c 6c 20 74 6f and the call to
27dc0 20 74 68 65 73 65 20 69 6e 74 65 72 66 61 63 65 these interface
27dd0 73 2e 0a 2a 2a 20 57 68 65 6e 20 74 68 61 74 20 s..** When that
27de0 68 61 70 70 65 6e 73 2c 20 74 68 65 20 73 65 63 happens, the sec
27df0 6f 6e 64 20 65 72 72 6f 72 20 77 69 6c 6c 20 62 ond error will b
27e00 65 20 72 65 70 6f 72 74 65 64 20 73 69 6e 63 65 e reported since
27e10 20 74 68 65 73 65 0a 2a 2a 20 69 6e 74 65 72 66 these.** interf
27e20 61 63 65 73 20 61 6c 77 61 79 73 20 72 65 70 6f aces always repo
27e30 72 74 20 74 68 65 20 6d 6f 73 74 20 72 65 63 65 rt the most rece
27e40 6e 74 20 72 65 73 75 6c 74 2e 20 20 54 6f 20 61 nt result. To a
27e50 76 6f 69 64 0a 2a 2a 20 74 68 69 73 2c 20 65 61 void.** this, ea
27e60 63 68 20 74 68 72 65 61 64 20 63 61 6e 20 6f 62 ch thread can ob
27e70 74 61 69 6e 20 65 78 63 6c 75 73 69 76 65 20 75 tain exclusive u
27e80 73 65 20 6f 66 20 74 68 65 20 5b 64 61 74 61 62 se of the [datab
27e90 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 5d 20 ase connection]
27ea0 44 0a 2a 2a 20 62 79 20 69 6e 76 6f 6b 69 6e 67 D.** by invoking
27eb0 20 5b 73 71 6c 69 74 65 33 5f 6d 75 74 65 78 5f [sqlite3_mutex_
27ec0 65 6e 74 65 72 5d 28 5b 73 71 6c 69 74 65 33 5f enter]([sqlite3_
27ed0 64 62 5f 6d 75 74 65 78 5d 28 44 29 29 20 62 65 db_mutex](D)) be
27ee0 66 6f 72 65 20 62 65 67 69 6e 6e 69 6e 67 0a 2a fore beginning.*
27ef0 2a 20 74 6f 20 75 73 65 20 44 20 61 6e 64 20 69 * to use D and i
27f00 6e 76 6f 6b 69 6e 67 20 5b 73 71 6c 69 74 65 33 nvoking [sqlite3
27f10 5f 6d 75 74 65 78 5f 6c 65 61 76 65 5d 28 5b 73 _mutex_leave]([s
27f20 71 6c 69 74 65 33 5f 64 62 5f 6d 75 74 65 78 5d qlite3_db_mutex]
27f30 28 44 29 29 20 61 66 74 65 72 0a 2a 2a 20 61 6c (D)) after.** al
27f40 6c 20 63 61 6c 6c 73 20 74 6f 20 74 68 65 20 69 l calls to the i
27f50 6e 74 65 72 66 61 63 65 73 20 6c 69 73 74 65 64 nterfaces listed
27f60 20 68 65 72 65 20 61 72 65 20 63 6f 6d 70 6c 65 here are comple
27f70 74 65 64 2e 0a 2a 2a 0a 2a 2a 20 49 66 20 61 6e ted..**.** If an
27f80 20 69 6e 74 65 72 66 61 63 65 20 66 61 69 6c 73 interface fails
27f90 20 77 69 74 68 20 53 51 4c 49 54 45 5f 4d 49 53 with SQLITE_MIS
27fa0 55 53 45 2c 20 74 68 61 74 20 6d 65 61 6e 73 20 USE, that means
27fb0 74 68 65 20 69 6e 74 65 72 66 61 63 65 0a 2a 2a the interface.**
27fc0 20 77 61 73 20 69 6e 76 6f 6b 65 64 20 69 6e 63 was invoked inc
27fd0 6f 72 72 65 63 74 6c 79 20 62 79 20 74 68 65 20 orrectly by the
27fe0 61 70 70 6c 69 63 61 74 69 6f 6e 2e 20 20 49 6e application. In
27ff0 20 74 68 61 74 20 63 61 73 65 2c 20 74 68 65 0a that case, the.
28000 2a 2a 20 65 72 72 6f 72 20 63 6f 64 65 20 61 6e ** error code an
28010 64 20 6d 65 73 73 61 67 65 20 6d 61 79 20 6f 72 d message may or
28020 20 6d 61 79 20 6e 6f 74 20 62 65 20 73 65 74 2e may not be set.
28030 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f .*/.int sqlite3_
28040 65 72 72 63 6f 64 65 28 73 71 6c 69 74 65 33 20 errcode(sqlite3
28050 2a 64 62 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 *db);.int sqlite
28060 33 5f 65 78 74 65 6e 64 65 64 5f 65 72 72 63 6f 3_extended_errco
28070 64 65 28 73 71 6c 69 74 65 33 20 2a 64 62 29 3b de(sqlite3 *db);
28080 0a 63 6f 6e 73 74 20 63 68 61 72 20 2a 73 71 6c .const char *sql
28090 69 74 65 33 5f 65 72 72 6d 73 67 28 73 71 6c 69 ite3_errmsg(sqli
280a0 74 65 33 2a 29 3b 0a 63 6f 6e 73 74 20 76 6f 69 te3*);.const voi
280b0 64 20 2a 73 71 6c 69 74 65 33 5f 65 72 72 6d 73 d *sqlite3_errms
280c0 67 31 36 28 73 71 6c 69 74 65 33 2a 29 3b 0a 63 g16(sqlite3*);.c
280d0 6f 6e 73 74 20 63 68 61 72 20 2a 73 71 6c 69 74 onst char *sqlit
280e0 65 33 5f 65 72 72 73 74 72 28 69 6e 74 29 3b 0a e3_errstr(int);.
280f0 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a ./*.** CAPI3REF:
28100 20 50 72 65 70 61 72 65 64 20 53 74 61 74 65 6d Prepared Statem
28110 65 6e 74 20 4f 62 6a 65 63 74 0a 2a 2a 20 4b 45 ent Object.** KE
28120 59 57 4f 52 44 53 3a 20 7b 70 72 65 70 61 72 65 YWORDS: {prepare
28130 64 20 73 74 61 74 65 6d 65 6e 74 7d 20 7b 70 72 d statement} {pr
28140 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 epared statement
28150 73 7d 0a 2a 2a 0a 2a 2a 20 41 6e 20 69 6e 73 74 s}.**.** An inst
28160 61 6e 63 65 20 6f 66 20 74 68 69 73 20 6f 62 6a ance of this obj
28170 65 63 74 20 72 65 70 72 65 73 65 6e 74 73 20 61 ect represents a
28180 20 73 69 6e 67 6c 65 20 53 51 4c 20 73 74 61 74 single SQL stat
28190 65 6d 65 6e 74 20 74 68 61 74 0a 2a 2a 20 68 61 ement that.** ha
281a0 73 20 62 65 65 6e 20 63 6f 6d 70 69 6c 65 64 20 s been compiled
281b0 69 6e 74 6f 20 62 69 6e 61 72 79 20 66 6f 72 6d into binary form
281c0 20 61 6e 64 20 69 73 20 72 65 61 64 79 20 74 6f and is ready to
281d0 20 62 65 20 65 76 61 6c 75 61 74 65 64 2e 0a 2a be evaluated..*
281e0 2a 0a 2a 2a 20 54 68 69 6e 6b 20 6f 66 20 65 61 *.** Think of ea
281f0 63 68 20 53 51 4c 20 73 74 61 74 65 6d 65 6e 74 ch SQL statement
28200 20 61 73 20 61 20 73 65 70 61 72 61 74 65 20 63 as a separate c
28210 6f 6d 70 75 74 65 72 20 70 72 6f 67 72 61 6d 2e omputer program.
28220 20 20 54 68 65 0a 2a 2a 20 6f 72 69 67 69 6e 61 The.** origina
28230 6c 20 53 51 4c 20 74 65 78 74 20 69 73 20 73 6f l SQL text is so
28240 75 72 63 65 20 63 6f 64 65 2e 20 20 41 20 70 72 urce code. A pr
28250 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 epared statement
28260 20 6f 62 6a 65 63 74 20 0a 2a 2a 20 69 73 20 74 object .** is t
28270 68 65 20 63 6f 6d 70 69 6c 65 64 20 6f 62 6a 65 he compiled obje
28280 63 74 20 63 6f 64 65 2e 20 20 41 6c 6c 20 53 51 ct code. All SQ
28290 4c 20 6d 75 73 74 20 62 65 20 63 6f 6e 76 65 72 L must be conver
282a0 74 65 64 20 69 6e 74 6f 20 61 0a 2a 2a 20 70 72 ted into a.** pr
282b0 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 epared statement
282c0 20 62 65 66 6f 72 65 20 69 74 20 63 61 6e 20 62 before it can b
282d0 65 20 72 75 6e 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 e run..**.** The
282e0 20 6c 69 66 65 2d 63 79 63 6c 65 20 6f 66 20 61 life-cycle of a
282f0 20 70 72 65 70 61 72 65 64 20 73 74 61 74 65 6d prepared statem
28300 65 6e 74 20 6f 62 6a 65 63 74 20 75 73 75 61 6c ent object usual
28310 6c 79 20 67 6f 65 73 20 6c 69 6b 65 20 74 68 69 ly goes like thi
28320 73 3a 0a 2a 2a 0a 2a 2a 20 3c 6f 6c 3e 0a 2a 2a s:.**.** <ol>.**
28330 20 3c 6c 69 3e 20 43 72 65 61 74 65 20 74 68 65 <li> Create the
28340 20 70 72 65 70 61 72 65 64 20 73 74 61 74 65 6d prepared statem
28350 65 6e 74 20 6f 62 6a 65 63 74 20 75 73 69 6e 67 ent object using
28360 20 5b 73 71 6c 69 74 65 33 5f 70 72 65 70 61 72 [sqlite3_prepar
28370 65 5f 76 32 28 29 5d 2e 0a 2a 2a 20 3c 6c 69 3e e_v2()]..** <li>
28380 20 42 69 6e 64 20 76 61 6c 75 65 73 20 74 6f 20 Bind values to
28390 5b 70 61 72 61 6d 65 74 65 72 73 5d 20 75 73 69 [parameters] usi
283a0 6e 67 20 74 68 65 20 73 71 6c 69 74 65 33 5f 62 ng the sqlite3_b
283b0 69 6e 64 5f 2a 28 29 0a 2a 2a 20 20 20 20 20 20 ind_*().**
283c0 69 6e 74 65 72 66 61 63 65 73 2e 0a 2a 2a 20 3c interfaces..** <
283d0 6c 69 3e 20 52 75 6e 20 74 68 65 20 53 51 4c 20 li> Run the SQL
283e0 62 79 20 63 61 6c 6c 69 6e 67 20 5b 73 71 6c 69 by calling [sqli
283f0 74 65 33 5f 73 74 65 70 28 29 5d 20 6f 6e 65 20 te3_step()] one
28400 6f 72 20 6d 6f 72 65 20 74 69 6d 65 73 2e 0a 2a or more times..*
28410 2a 20 3c 6c 69 3e 20 52 65 73 65 74 20 74 68 65 * <li> Reset the
28420 20 70 72 65 70 61 72 65 64 20 73 74 61 74 65 6d prepared statem
28430 65 6e 74 20 75 73 69 6e 67 20 5b 73 71 6c 69 74 ent using [sqlit
28440 65 33 5f 72 65 73 65 74 28 29 5d 20 74 68 65 6e e3_reset()] then
28450 20 67 6f 20 62 61 63 6b 0a 2a 2a 20 20 20 20 20 go back.**
28460 20 74 6f 20 73 74 65 70 20 32 2e 20 20 44 6f 20 to step 2. Do
28470 74 68 69 73 20 7a 65 72 6f 20 6f 72 20 6d 6f 72 this zero or mor
28480 65 20 74 69 6d 65 73 2e 0a 2a 2a 20 3c 6c 69 3e e times..** <li>
28490 20 44 65 73 74 72 6f 79 20 74 68 65 20 6f 62 6a Destroy the obj
284a0 65 63 74 20 75 73 69 6e 67 20 5b 73 71 6c 69 74 ect using [sqlit
284b0 65 33 5f 66 69 6e 61 6c 69 7a 65 28 29 5d 2e 0a e3_finalize()]..
284c0 2a 2a 20 3c 2f 6f 6c 3e 0a 2a 2f 0a 74 79 70 65 ** </ol>.*/.type
284d0 64 65 66 20 73 74 72 75 63 74 20 73 71 6c 69 74 def struct sqlit
284e0 65 33 5f 73 74 6d 74 20 73 71 6c 69 74 65 33 5f e3_stmt sqlite3_
284f0 73 74 6d 74 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 stmt;../*.** CAP
28500 49 33 52 45 46 3a 20 52 75 6e 2d 74 69 6d 65 20 I3REF: Run-time
28510 4c 69 6d 69 74 73 0a 2a 2a 20 4d 45 54 48 4f 44 Limits.** METHOD
28520 3a 20 73 71 6c 69 74 65 33 0a 2a 2a 0a 2a 2a 20 : sqlite3.**.**
28530 5e 28 54 68 69 73 20 69 6e 74 65 72 66 61 63 65 ^(This interface
28540 20 61 6c 6c 6f 77 73 20 74 68 65 20 73 69 7a 65 allows the size
28550 20 6f 66 20 76 61 72 69 6f 75 73 20 63 6f 6e 73 of various cons
28560 74 72 75 63 74 73 20 74 6f 20 62 65 20 6c 69 6d tructs to be lim
28570 69 74 65 64 0a 2a 2a 20 6f 6e 20 61 20 63 6f 6e ited.** on a con
28580 6e 65 63 74 69 6f 6e 20 62 79 20 63 6f 6e 6e 65 nection by conne
28590 63 74 69 6f 6e 20 62 61 73 69 73 2e 20 20 54 68 ction basis. Th
285a0 65 20 66 69 72 73 74 20 70 61 72 61 6d 65 74 65 e first paramete
285b0 72 20 69 73 20 74 68 65 0a 2a 2a 20 5b 64 61 74 r is the.** [dat
285c0 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e abase connection
285d0 5d 20 77 68 6f 73 65 20 6c 69 6d 69 74 20 69 73 ] whose limit is
285e0 20 74 6f 20 62 65 20 73 65 74 20 6f 72 20 71 75 to be set or qu
285f0 65 72 69 65 64 2e 20 20 54 68 65 0a 2a 2a 20 73 eried. The.** s
28600 65 63 6f 6e 64 20 70 61 72 61 6d 65 74 65 72 20 econd parameter
28610 69 73 20 6f 6e 65 20 6f 66 20 74 68 65 20 5b 6c is one of the [l
28620 69 6d 69 74 20 63 61 74 65 67 6f 72 69 65 73 5d imit categories]
28630 20 74 68 61 74 20 64 65 66 69 6e 65 20 61 0a 2a that define a.*
28640 2a 20 63 6c 61 73 73 20 6f 66 20 63 6f 6e 73 74 * class of const
28650 72 75 63 74 73 20 74 6f 20 62 65 20 73 69 7a 65 ructs to be size
28660 20 6c 69 6d 69 74 65 64 2e 20 20 54 68 65 20 74 limited. The t
28670 68 69 72 64 20 70 61 72 61 6d 65 74 65 72 20 69 hird parameter i
28680 73 20 74 68 65 0a 2a 2a 20 6e 65 77 20 6c 69 6d s the.** new lim
28690 69 74 20 66 6f 72 20 74 68 61 74 20 63 6f 6e 73 it for that cons
286a0 74 72 75 63 74 2e 29 5e 0a 2a 2a 0a 2a 2a 20 5e truct.)^.**.** ^
286b0 49 66 20 74 68 65 20 6e 65 77 20 6c 69 6d 69 74 If the new limit
286c0 20 69 73 20 61 20 6e 65 67 61 74 69 76 65 20 6e is a negative n
286d0 75 6d 62 65 72 2c 20 74 68 65 20 6c 69 6d 69 74 umber, the limit
286e0 20 69 73 20 75 6e 63 68 61 6e 67 65 64 2e 0a 2a is unchanged..*
286f0 2a 20 5e 28 46 6f 72 20 65 61 63 68 20 6c 69 6d * ^(For each lim
28700 69 74 20 63 61 74 65 67 6f 72 79 20 53 51 4c 49 it category SQLI
28710 54 45 5f 4c 49 4d 49 54 5f 3c 69 3e 4e 41 4d 45 TE_LIMIT_<i>NAME
28720 3c 2f 69 3e 20 74 68 65 72 65 20 69 73 20 61 20 </i> there is a
28730 0a 2a 2a 20 5b 6c 69 6d 69 74 73 20 7c 20 68 61 .** [limits | ha
28740 72 64 20 75 70 70 65 72 20 62 6f 75 6e 64 5d 0a rd upper bound].
28750 2a 2a 20 73 65 74 20 61 74 20 63 6f 6d 70 69 6c ** set at compil
28760 65 2d 74 69 6d 65 20 62 79 20 61 20 43 20 70 72 e-time by a C pr
28770 65 70 72 6f 63 65 73 73 6f 72 20 6d 61 63 72 6f eprocessor macro
28780 20 63 61 6c 6c 65 64 0a 2a 2a 20 5b 6c 69 6d 69 called.** [limi
28790 74 73 20 7c 20 53 51 4c 49 54 45 5f 4d 41 58 5f ts | SQLITE_MAX_
287a0 3c 69 3e 4e 41 4d 45 3c 2f 69 3e 5d 2e 0a 2a 2a <i>NAME</i>]..**
287b0 20 28 54 68 65 20 22 5f 4c 49 4d 49 54 5f 22 20 (The "_LIMIT_"
287c0 69 6e 20 74 68 65 20 6e 61 6d 65 20 69 73 20 63 in the name is c
287d0 68 61 6e 67 65 64 20 74 6f 20 22 5f 4d 41 58 5f hanged to "_MAX_
287e0 22 2e 29 29 5e 0a 2a 2a 20 5e 41 74 74 65 6d 70 ".))^.** ^Attemp
287f0 74 73 20 74 6f 20 69 6e 63 72 65 61 73 65 20 61 ts to increase a
28800 20 6c 69 6d 69 74 20 61 62 6f 76 65 20 69 74 73 limit above its
28810 20 68 61 72 64 20 75 70 70 65 72 20 62 6f 75 6e hard upper boun
28820 64 20 61 72 65 0a 2a 2a 20 73 69 6c 65 6e 74 6c d are.** silentl
28830 79 20 74 72 75 6e 63 61 74 65 64 20 74 6f 20 74 y truncated to t
28840 68 65 20 68 61 72 64 20 75 70 70 65 72 20 62 6f he hard upper bo
28850 75 6e 64 2e 0a 2a 2a 0a 2a 2a 20 5e 52 65 67 61 und..**.** ^Rega
28860 72 64 6c 65 73 73 20 6f 66 20 77 68 65 74 68 65 rdless of whethe
28870 72 20 6f 72 20 6e 6f 74 20 74 68 65 20 6c 69 6d r or not the lim
28880 69 74 20 77 61 73 20 63 68 61 6e 67 65 64 2c 20 it was changed,
28890 74 68 65 20 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 the .** [sqlite3
288a0 5f 6c 69 6d 69 74 28 29 5d 20 69 6e 74 65 72 66 _limit()] interf
288b0 61 63 65 20 72 65 74 75 72 6e 73 20 74 68 65 20 ace returns the
288c0 70 72 69 6f 72 20 76 61 6c 75 65 20 6f 66 20 74 prior value of t
288d0 68 65 20 6c 69 6d 69 74 2e 0a 2a 2a 20 5e 48 65 he limit..** ^He
288e0 6e 63 65 2c 20 74 6f 20 66 69 6e 64 20 74 68 65 nce, to find the
288f0 20 63 75 72 72 65 6e 74 20 76 61 6c 75 65 20 6f current value o
28900 66 20 61 20 6c 69 6d 69 74 20 77 69 74 68 6f 75 f a limit withou
28910 74 20 63 68 61 6e 67 69 6e 67 20 69 74 2c 0a 2a t changing it,.*
28920 2a 20 73 69 6d 70 6c 79 20 69 6e 76 6f 6b 65 20 * simply invoke
28930 74 68 69 73 20 69 6e 74 65 72 66 61 63 65 20 77 this interface w
28940 69 74 68 20 74 68 65 20 74 68 69 72 64 20 70 61 ith the third pa
28950 72 61 6d 65 74 65 72 20 73 65 74 20 74 6f 20 2d rameter set to -
28960 31 2e 0a 2a 2a 0a 2a 2a 20 52 75 6e 2d 74 69 6d 1..**.** Run-tim
28970 65 20 6c 69 6d 69 74 73 20 61 72 65 20 69 6e 74 e limits are int
28980 65 6e 64 65 64 20 66 6f 72 20 75 73 65 20 69 6e ended for use in
28990 20 61 70 70 6c 69 63 61 74 69 6f 6e 73 20 74 68 applications th
289a0 61 74 20 6d 61 6e 61 67 65 0a 2a 2a 20 62 6f 74 at manage.** bot
289b0 68 20 74 68 65 69 72 20 6f 77 6e 20 69 6e 74 65 h their own inte
289c0 72 6e 61 6c 20 64 61 74 61 62 61 73 65 20 61 6e rnal database an
289d0 64 20 61 6c 73 6f 20 64 61 74 61 62 61 73 65 73 d also databases
289e0 20 74 68 61 74 20 61 72 65 20 63 6f 6e 74 72 6f that are contro
289f0 6c 6c 65 64 0a 2a 2a 20 62 79 20 75 6e 74 72 75 lled.** by untru
28a00 73 74 65 64 20 65 78 74 65 72 6e 61 6c 20 73 6f sted external so
28a10 75 72 63 65 73 2e 20 20 41 6e 20 65 78 61 6d 70 urces. An examp
28a20 6c 65 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 6d le application m
28a30 69 67 68 74 20 62 65 20 61 0a 2a 2a 20 77 65 62 ight be a.** web
28a40 20 62 72 6f 77 73 65 72 20 74 68 61 74 20 68 61 browser that ha
28a50 73 20 69 74 73 20 6f 77 6e 20 64 61 74 61 62 61 s its own databa
28a60 73 65 73 20 66 6f 72 20 73 74 6f 72 69 6e 67 20 ses for storing
28a70 68 69 73 74 6f 72 79 20 61 6e 64 0a 2a 2a 20 73 history and.** s
28a80 65 70 61 72 61 74 65 20 64 61 74 61 62 61 73 65 eparate database
28a90 73 20 63 6f 6e 74 72 6f 6c 6c 65 64 20 62 79 20 s controlled by
28aa0 4a 61 76 61 53 63 72 69 70 74 20 61 70 70 6c 69 JavaScript appli
28ab0 63 61 74 69 6f 6e 73 20 64 6f 77 6e 6c 6f 61 64 cations download
28ac0 65 64 0a 2a 2a 20 6f 66 66 20 74 68 65 20 49 6e ed.** off the In
28ad0 74 65 72 6e 65 74 2e 20 20 54 68 65 20 69 6e 74 ternet. The int
28ae0 65 72 6e 61 6c 20 64 61 74 61 62 61 73 65 73 20 ernal databases
28af0 63 61 6e 20 62 65 20 67 69 76 65 6e 20 74 68 65 can be given the
28b00 0a 2a 2a 20 6c 61 72 67 65 2c 20 64 65 66 61 75 .** large, defau
28b10 6c 74 20 6c 69 6d 69 74 73 2e 20 20 44 61 74 61 lt limits. Data
28b20 62 61 73 65 73 20 6d 61 6e 61 67 65 64 20 62 79 bases managed by
28b30 20 65 78 74 65 72 6e 61 6c 20 73 6f 75 72 63 65 external source
28b40 73 20 63 61 6e 0a 2a 2a 20 62 65 20 67 69 76 65 s can.** be give
28b50 6e 20 6d 75 63 68 20 73 6d 61 6c 6c 65 72 20 6c n much smaller l
28b60 69 6d 69 74 73 20 64 65 73 69 67 6e 65 64 20 74 imits designed t
28b70 6f 20 70 72 65 76 65 6e 74 20 61 20 64 65 6e 69 o prevent a deni
28b80 61 6c 20 6f 66 20 73 65 72 76 69 63 65 0a 2a 2a al of service.**
28b90 20 61 74 74 61 63 6b 2e 20 20 44 65 76 65 6c 6f attack. Develo
28ba0 70 65 72 73 20 6d 69 67 68 74 20 61 6c 73 6f 20 pers might also
28bb0 77 61 6e 74 20 74 6f 20 75 73 65 20 74 68 65 20 want to use the
28bc0 5b 73 71 6c 69 74 65 33 5f 73 65 74 5f 61 75 74 [sqlite3_set_aut
28bd0 68 6f 72 69 7a 65 72 28 29 5d 0a 2a 2a 20 69 6e horizer()].** in
28be0 74 65 72 66 61 63 65 20 74 6f 20 66 75 72 74 68 terface to furth
28bf0 65 72 20 63 6f 6e 74 72 6f 6c 20 75 6e 74 72 75 er control untru
28c00 73 74 65 64 20 53 51 4c 2e 20 20 54 68 65 20 73 sted SQL. The s
28c10 69 7a 65 20 6f 66 20 74 68 65 20 64 61 74 61 62 ize of the datab
28c20 61 73 65 0a 2a 2a 20 63 72 65 61 74 65 64 20 62 ase.** created b
28c30 79 20 61 6e 20 75 6e 74 72 75 73 74 65 64 20 73 y an untrusted s
28c40 63 72 69 70 74 20 63 61 6e 20 62 65 20 63 6f 6e cript can be con
28c50 74 61 69 6e 65 64 20 75 73 69 6e 67 20 74 68 65 tained using the
28c60 0a 2a 2a 20 5b 6d 61 78 5f 70 61 67 65 5f 63 6f .** [max_page_co
28c70 75 6e 74 5d 20 5b 50 52 41 47 4d 41 5d 2e 0a 2a unt] [PRAGMA]..*
28c80 2a 0a 2a 2a 20 4e 65 77 20 72 75 6e 2d 74 69 6d *.** New run-tim
28c90 65 20 6c 69 6d 69 74 20 63 61 74 65 67 6f 72 69 e limit categori
28ca0 65 73 20 6d 61 79 20 62 65 20 61 64 64 65 64 20 es may be added
28cb0 69 6e 20 66 75 74 75 72 65 20 72 65 6c 65 61 73 in future releas
28cc0 65 73 2e 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 es..*/.int sqlit
28cd0 65 33 5f 6c 69 6d 69 74 28 73 71 6c 69 74 65 33 e3_limit(sqlite3
28ce0 2a 2c 20 69 6e 74 20 69 64 2c 20 69 6e 74 20 6e *, int id, int n
28cf0 65 77 56 61 6c 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 ewVal);../*.** C
28d00 41 50 49 33 52 45 46 3a 20 52 75 6e 2d 54 69 6d API3REF: Run-Tim
28d10 65 20 4c 69 6d 69 74 20 43 61 74 65 67 6f 72 69 e Limit Categori
28d20 65 73 0a 2a 2a 20 4b 45 59 57 4f 52 44 53 3a 20 es.** KEYWORDS:
28d30 7b 6c 69 6d 69 74 20 63 61 74 65 67 6f 72 79 7d {limit category}
28d40 20 7b 2a 6c 69 6d 69 74 20 63 61 74 65 67 6f 72 {*limit categor
28d50 69 65 73 7d 0a 2a 2a 0a 2a 2a 20 54 68 65 73 65 ies}.**.** These
28d60 20 63 6f 6e 73 74 61 6e 74 73 20 64 65 66 69 6e constants defin
28d70 65 20 76 61 72 69 6f 75 73 20 70 65 72 66 6f 72 e various perfor
28d80 6d 61 6e 63 65 20 6c 69 6d 69 74 73 0a 2a 2a 20 mance limits.**
28d90 74 68 61 74 20 63 61 6e 20 62 65 20 6c 6f 77 65 that can be lowe
28da0 72 65 64 20 61 74 20 72 75 6e 2d 74 69 6d 65 20 red at run-time
28db0 75 73 69 6e 67 20 5b 73 71 6c 69 74 65 33 5f 6c using [sqlite3_l
28dc0 69 6d 69 74 28 29 5d 2e 0a 2a 2a 20 54 68 65 20 imit()]..** The
28dd0 73 79 6e 6f 70 73 69 73 20 6f 66 20 74 68 65 20 synopsis of the
28de0 6d 65 61 6e 69 6e 67 73 20 6f 66 20 74 68 65 20 meanings of the
28df0 76 61 72 69 6f 75 73 20 6c 69 6d 69 74 73 20 69 various limits i
28e00 73 20 73 68 6f 77 6e 20 62 65 6c 6f 77 2e 0a 2a s shown below..*
28e10 2a 20 41 64 64 69 74 69 6f 6e 61 6c 20 69 6e 66 * Additional inf
28e20 6f 72 6d 61 74 69 6f 6e 20 69 73 20 61 76 61 69 ormation is avai
28e30 6c 61 62 6c 65 20 61 74 20 5b 6c 69 6d 69 74 73 lable at [limits
28e40 20 7c 20 4c 69 6d 69 74 73 20 69 6e 20 53 51 4c | Limits in SQL
28e50 69 74 65 5d 2e 0a 2a 2a 0a 2a 2a 20 3c 64 6c 3e ite]..**.** <dl>
28e60 0a 2a 2a 20 5b 5b 53 51 4c 49 54 45 5f 4c 49 4d .** [[SQLITE_LIM
28e70 49 54 5f 4c 45 4e 47 54 48 5d 5d 20 5e 28 3c 64 IT_LENGTH]] ^(<d
28e80 74 3e 53 51 4c 49 54 45 5f 4c 49 4d 49 54 5f 4c t>SQLITE_LIMIT_L
28e90 45 4e 47 54 48 3c 2f 64 74 3e 0a 2a 2a 20 3c 64 ENGTH</dt>.** <d
28ea0 64 3e 54 68 65 20 6d 61 78 69 6d 75 6d 20 73 69 d>The maximum si
28eb0 7a 65 20 6f 66 20 61 6e 79 20 73 74 72 69 6e 67 ze of any string
28ec0 20 6f 72 20 42 4c 4f 42 20 6f 72 20 74 61 62 6c or BLOB or tabl
28ed0 65 20 72 6f 77 2c 20 69 6e 20 62 79 74 65 73 2e e row, in bytes.
28ee0 3c 64 64 3e 29 5e 0a 2a 2a 0a 2a 2a 20 5b 5b 53 <dd>)^.**.** [[S
28ef0 51 4c 49 54 45 5f 4c 49 4d 49 54 5f 53 51 4c 5f QLITE_LIMIT_SQL_
28f00 4c 45 4e 47 54 48 5d 5d 20 5e 28 3c 64 74 3e 53 LENGTH]] ^(<dt>S
28f10 51 4c 49 54 45 5f 4c 49 4d 49 54 5f 53 51 4c 5f QLITE_LIMIT_SQL_
28f20 4c 45 4e 47 54 48 3c 2f 64 74 3e 0a 2a 2a 20 3c LENGTH</dt>.** <
28f30 64 64 3e 54 68 65 20 6d 61 78 69 6d 75 6d 20 6c dd>The maximum l
28f40 65 6e 67 74 68 20 6f 66 20 61 6e 20 53 51 4c 20 ength of an SQL
28f50 73 74 61 74 65 6d 65 6e 74 2c 20 69 6e 20 62 79 statement, in by
28f60 74 65 73 2e 3c 2f 64 64 3e 29 5e 0a 2a 2a 0a 2a tes.</dd>)^.**.*
28f70 2a 20 5b 5b 53 51 4c 49 54 45 5f 4c 49 4d 49 54 * [[SQLITE_LIMIT
28f80 5f 43 4f 4c 55 4d 4e 5d 5d 20 5e 28 3c 64 74 3e _COLUMN]] ^(<dt>
28f90 53 51 4c 49 54 45 5f 4c 49 4d 49 54 5f 43 4f 4c SQLITE_LIMIT_COL
28fa0 55 4d 4e 3c 2f 64 74 3e 0a 2a 2a 20 3c 64 64 3e UMN</dt>.** <dd>
28fb0 54 68 65 20 6d 61 78 69 6d 75 6d 20 6e 75 6d 62 The maximum numb
28fc0 65 72 20 6f 66 20 63 6f 6c 75 6d 6e 73 20 69 6e er of columns in
28fd0 20 61 20 74 61 62 6c 65 20 64 65 66 69 6e 69 74 a table definit
28fe0 69 6f 6e 20 6f 72 20 69 6e 20 74 68 65 0a 2a 2a ion or in the.**
28ff0 20 72 65 73 75 6c 74 20 73 65 74 20 6f 66 20 61 result set of a
29000 20 5b 53 45 4c 45 43 54 5d 20 6f 72 20 74 68 65 [SELECT] or the
29010 20 6d 61 78 69 6d 75 6d 20 6e 75 6d 62 65 72 20 maximum number
29020 6f 66 20 63 6f 6c 75 6d 6e 73 20 69 6e 20 61 6e of columns in an
29030 20 69 6e 64 65 78 0a 2a 2a 20 6f 72 20 69 6e 20 index.** or in
29040 61 6e 20 4f 52 44 45 52 20 42 59 20 6f 72 20 47 an ORDER BY or G
29050 52 4f 55 50 20 42 59 20 63 6c 61 75 73 65 2e 3c ROUP BY clause.<
29060 2f 64 64 3e 29 5e 0a 2a 2a 0a 2a 2a 20 5b 5b 53 /dd>)^.**.** [[S
29070 51 4c 49 54 45 5f 4c 49 4d 49 54 5f 45 58 50 52 QLITE_LIMIT_EXPR
29080 5f 44 45 50 54 48 5d 5d 20 5e 28 3c 64 74 3e 53 _DEPTH]] ^(<dt>S
29090 51 4c 49 54 45 5f 4c 49 4d 49 54 5f 45 58 50 52 QLITE_LIMIT_EXPR
290a0 5f 44 45 50 54 48 3c 2f 64 74 3e 0a 2a 2a 20 3c _DEPTH</dt>.** <
290b0 64 64 3e 54 68 65 20 6d 61 78 69 6d 75 6d 20 64 dd>The maximum d
290c0 65 70 74 68 20 6f 66 20 74 68 65 20 70 61 72 73 epth of the pars
290d0 65 20 74 72 65 65 20 6f 6e 20 61 6e 79 20 65 78 e tree on any ex
290e0 70 72 65 73 73 69 6f 6e 2e 3c 2f 64 64 3e 29 5e pression.</dd>)^
290f0 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 4c 49 54 45 5f .**.** [[SQLITE_
29100 4c 49 4d 49 54 5f 43 4f 4d 50 4f 55 4e 44 5f 53 LIMIT_COMPOUND_S
29110 45 4c 45 43 54 5d 5d 20 5e 28 3c 64 74 3e 53 51 ELECT]] ^(<dt>SQ
29120 4c 49 54 45 5f 4c 49 4d 49 54 5f 43 4f 4d 50 4f LITE_LIMIT_COMPO
29130 55 4e 44 5f 53 45 4c 45 43 54 3c 2f 64 74 3e 0a UND_SELECT</dt>.
29140 2a 2a 20 3c 64 64 3e 54 68 65 20 6d 61 78 69 6d ** <dd>The maxim
29150 75 6d 20 6e 75 6d 62 65 72 20 6f 66 20 74 65 72 um number of ter
29160 6d 73 20 69 6e 20 61 20 63 6f 6d 70 6f 75 6e 64 ms in a compound
29170 20 53 45 4c 45 43 54 20 73 74 61 74 65 6d 65 6e SELECT statemen
29180 74 2e 3c 2f 64 64 3e 29 5e 0a 2a 2a 0a 2a 2a 20 t.</dd>)^.**.**
29190 5b 5b 53 51 4c 49 54 45 5f 4c 49 4d 49 54 5f 56 [[SQLITE_LIMIT_V
291a0 44 42 45 5f 4f 50 5d 5d 20 5e 28 3c 64 74 3e 53 DBE_OP]] ^(<dt>S
291b0 51 4c 49 54 45 5f 4c 49 4d 49 54 5f 56 44 42 45 QLITE_LIMIT_VDBE
291c0 5f 4f 50 3c 2f 64 74 3e 0a 2a 2a 20 3c 64 64 3e _OP</dt>.** <dd>
291d0 54 68 65 20 6d 61 78 69 6d 75 6d 20 6e 75 6d 62 The maximum numb
291e0 65 72 20 6f 66 20 69 6e 73 74 72 75 63 74 69 6f er of instructio
291f0 6e 73 20 69 6e 20 61 20 76 69 72 74 75 61 6c 20 ns in a virtual
29200 6d 61 63 68 69 6e 65 20 70 72 6f 67 72 61 6d 0a machine program.
29210 2a 2a 20 75 73 65 64 20 74 6f 20 69 6d 70 6c 65 ** used to imple
29220 6d 65 6e 74 20 61 6e 20 53 51 4c 20 73 74 61 74 ment an SQL stat
29230 65 6d 65 6e 74 2e 20 20 54 68 69 73 20 6c 69 6d ement. This lim
29240 69 74 20 69 73 20 6e 6f 74 20 63 75 72 72 65 6e it is not curren
29250 74 6c 79 0a 2a 2a 20 65 6e 66 6f 72 63 65 64 2c tly.** enforced,
29260 20 74 68 6f 75 67 68 20 74 68 61 74 20 6d 69 67 though that mig
29270 68 74 20 62 65 20 61 64 64 65 64 20 69 6e 20 73 ht be added in s
29280 6f 6d 65 20 66 75 74 75 72 65 20 72 65 6c 65 61 ome future relea
29290 73 65 20 6f 66 0a 2a 2a 20 53 51 4c 69 74 65 2e se of.** SQLite.
292a0 3c 2f 64 64 3e 29 5e 0a 2a 2a 0a 2a 2a 20 5b 5b </dd>)^.**.** [[
292b0 53 51 4c 49 54 45 5f 4c 49 4d 49 54 5f 46 55 4e SQLITE_LIMIT_FUN
292c0 43 54 49 4f 4e 5f 41 52 47 5d 5d 20 5e 28 3c 64 CTION_ARG]] ^(<d
292d0 74 3e 53 51 4c 49 54 45 5f 4c 49 4d 49 54 5f 46 t>SQLITE_LIMIT_F
292e0 55 4e 43 54 49 4f 4e 5f 41 52 47 3c 2f 64 74 3e UNCTION_ARG</dt>
292f0 0a 2a 2a 20 3c 64 64 3e 54 68 65 20 6d 61 78 69 .** <dd>The maxi
29300 6d 75 6d 20 6e 75 6d 62 65 72 20 6f 66 20 61 72 mum number of ar
29310 67 75 6d 65 6e 74 73 20 6f 6e 20 61 20 66 75 6e guments on a fun
29320 63 74 69 6f 6e 2e 3c 2f 64 64 3e 29 5e 0a 2a 2a ction.</dd>)^.**
29330 0a 2a 2a 20 5b 5b 53 51 4c 49 54 45 5f 4c 49 4d .** [[SQLITE_LIM
29340 49 54 5f 41 54 54 41 43 48 45 44 5d 5d 20 5e 28 IT_ATTACHED]] ^(
29350 3c 64 74 3e 53 51 4c 49 54 45 5f 4c 49 4d 49 54 <dt>SQLITE_LIMIT
29360 5f 41 54 54 41 43 48 45 44 3c 2f 64 74 3e 0a 2a _ATTACHED</dt>.*
29370 2a 20 3c 64 64 3e 54 68 65 20 6d 61 78 69 6d 75 * <dd>The maximu
29380 6d 20 6e 75 6d 62 65 72 20 6f 66 20 5b 41 54 54 m number of [ATT
29390 41 43 48 20 7c 20 61 74 74 61 63 68 65 64 20 64 ACH | attached d
293a0 61 74 61 62 61 73 65 73 5d 2e 29 5e 3c 2f 64 64 atabases].)^</dd
293b0 3e 0a 2a 2a 0a 2a 2a 20 5b 5b 53 51 4c 49 54 45 >.**.** [[SQLITE
293c0 5f 4c 49 4d 49 54 5f 4c 49 4b 45 5f 50 41 54 54 _LIMIT_LIKE_PATT
293d0 45 52 4e 5f 4c 45 4e 47 54 48 5d 5d 0a 2a 2a 20 ERN_LENGTH]].**
293e0 5e 28 3c 64 74 3e 53 51 4c 49 54 45 5f 4c 49 4d ^(<dt>SQLITE_LIM
293f0 49 54 5f 4c 49 4b 45 5f 50 41 54 54 45 52 4e 5f IT_LIKE_PATTERN_
29400 4c 45 4e 47 54 48 3c 2f 64 74 3e 0a 2a 2a 20 3c LENGTH</dt>.** <
29410 64 64 3e 54 68 65 20 6d 61 78 69 6d 75 6d 20 6c dd>The maximum l
29420 65 6e 67 74 68 20 6f 66 20 74 68 65 20 70 61 74 ength of the pat
29430 74 65 72 6e 20 61 72 67 75 6d 65 6e 74 20 74 6f tern argument to
29440 20 74 68 65 20 5b 4c 49 4b 45 5d 20 6f 72 0a 2a the [LIKE] or.*
29450 2a 20 5b 47 4c 4f 42 5d 20 6f 70 65 72 61 74 6f * [GLOB] operato
29460 72 73 2e 3c 2f 64 64 3e 29 5e 0a 2a 2a 0a 2a 2a rs.</dd>)^.**.**
29470 20 5b 5b 53 51 4c 49 54 45 5f 4c 49 4d 49 54 5f [[SQLITE_LIMIT_
29480 56 41 52 49 41 42 4c 45 5f 4e 55 4d 42 45 52 5d VARIABLE_NUMBER]
29490 5d 0a 2a 2a 20 5e 28 3c 64 74 3e 53 51 4c 49 54 ].** ^(<dt>SQLIT
294a0 45 5f 4c 49 4d 49 54 5f 56 41 52 49 41 42 4c 45 E_LIMIT_VARIABLE
294b0 5f 4e 55 4d 42 45 52 3c 2f 64 74 3e 0a 2a 2a 20 _NUMBER</dt>.**
294c0 3c 64 64 3e 54 68 65 20 6d 61 78 69 6d 75 6d 20 <dd>The maximum
294d0 69 6e 64 65 78 20 6e 75 6d 62 65 72 20 6f 66 20 index number of
294e0 61 6e 79 20 5b 70 61 72 61 6d 65 74 65 72 5d 20 any [parameter]
294f0 69 6e 20 61 6e 20 53 51 4c 20 73 74 61 74 65 6d in an SQL statem
29500 65 6e 74 2e 29 5e 0a 2a 2a 0a 2a 2a 20 5b 5b 53 ent.)^.**.** [[S
29510 51 4c 49 54 45 5f 4c 49 4d 49 54 5f 54 52 49 47 QLITE_LIMIT_TRIG
29520 47 45 52 5f 44 45 50 54 48 5d 5d 20 5e 28 3c 64 GER_DEPTH]] ^(<d
29530 74 3e 53 51 4c 49 54 45 5f 4c 49 4d 49 54 5f 54 t>SQLITE_LIMIT_T
29540 52 49 47 47 45 52 5f 44 45 50 54 48 3c 2f 64 74 RIGGER_DEPTH</dt
29550 3e 0a 2a 2a 20 3c 64 64 3e 54 68 65 20 6d 61 78 >.** <dd>The max
29560 69 6d 75 6d 20 64 65 70 74 68 20 6f 66 20 72 65 imum depth of re
29570 63 75 72 73 69 6f 6e 20 66 6f 72 20 74 72 69 67 cursion for trig
29580 67 65 72 73 2e 3c 2f 64 64 3e 29 5e 0a 2a 2a 0a gers.</dd>)^.**.
29590 2a 2a 20 5b 5b 53 51 4c 49 54 45 5f 4c 49 4d 49 ** [[SQLITE_LIMI
295a0 54 5f 57 4f 52 4b 45 52 5f 54 48 52 45 41 44 53 T_WORKER_THREADS
295b0 5d 5d 20 5e 28 3c 64 74 3e 53 51 4c 49 54 45 5f ]] ^(<dt>SQLITE_
295c0 4c 49 4d 49 54 5f 57 4f 52 4b 45 52 5f 54 48 52 LIMIT_WORKER_THR
295d0 45 41 44 53 3c 2f 64 74 3e 0a 2a 2a 20 3c 64 64 EADS</dt>.** <dd
295e0 3e 54 68 65 20 6d 61 78 69 6d 75 6d 20 6e 75 6d >The maximum num
295f0 62 65 72 20 6f 66 20 61 75 78 69 6c 69 61 72 79 ber of auxiliary
29600 20 77 6f 72 6b 65 72 20 74 68 72 65 61 64 73 20 worker threads
29610 74 68 61 74 20 61 20 73 69 6e 67 6c 65 0a 2a 2a that a single.**
29620 20 5b 70 72 65 70 61 72 65 64 20 73 74 61 74 65 [prepared state
29630 6d 65 6e 74 5d 20 6d 61 79 20 73 74 61 72 74 2e ment] may start.
29640 3c 2f 64 64 3e 29 5e 0a 2a 2a 20 3c 2f 64 6c 3e </dd>)^.** </dl>
29650 0a 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 .*/.#define SQLI
29660 54 45 5f 4c 49 4d 49 54 5f 4c 45 4e 47 54 48 20 TE_LIMIT_LENGTH
29670 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
29680 20 20 20 30 0a 23 64 65 66 69 6e 65 20 53 51 4c 0.#define SQL
29690 49 54 45 5f 4c 49 4d 49 54 5f 53 51 4c 5f 4c 45 ITE_LIMIT_SQL_LE
296a0 4e 47 54 48 20 20 20 20 20 20 20 20 20 20 20 20 NGTH
296b0 20 20 20 20 31 0a 23 64 65 66 69 6e 65 20 53 51 1.#define SQ
296c0 4c 49 54 45 5f 4c 49 4d 49 54 5f 43 4f 4c 55 4d LITE_LIMIT_COLUM
296d0 4e 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 N
296e0 20 20 20 20 20 32 0a 23 64 65 66 69 6e 65 20 53 2.#define S
296f0 51 4c 49 54 45 5f 4c 49 4d 49 54 5f 45 58 50 52 QLITE_LIMIT_EXPR
29700 5f 44 45 50 54 48 20 20 20 20 20 20 20 20 20 20 _DEPTH
29710 20 20 20 20 20 20 33 0a 23 64 65 66 69 6e 65 20 3.#define
29720 53 51 4c 49 54 45 5f 4c 49 4d 49 54 5f 43 4f 4d SQLITE_LIMIT_COM
29730 50 4f 55 4e 44 5f 53 45 4c 45 43 54 20 20 20 20 POUND_SELECT
29740 20 20 20 20 20 20 20 34 0a 23 64 65 66 69 6e 65 4.#define
29750 20 53 51 4c 49 54 45 5f 4c 49 4d 49 54 5f 56 44 SQLITE_LIMIT_VD
29760 42 45 5f 4f 50 20 20 20 20 20 20 20 20 20 20 20 BE_OP
29770 20 20 20 20 20 20 20 20 35 0a 23 64 65 66 69 6e 5.#defin
29780 65 20 53 51 4c 49 54 45 5f 4c 49 4d 49 54 5f 46 e SQLITE_LIMIT_F
29790 55 4e 43 54 49 4f 4e 5f 41 52 47 20 20 20 20 20 UNCTION_ARG
297a0 20 20 20 20 20 20 20 20 20 36 0a 23 64 65 66 69 6.#defi
297b0 6e 65 20 53 51 4c 49 54 45 5f 4c 49 4d 49 54 5f ne SQLITE_LIMIT_
297c0 41 54 54 41 43 48 45 44 20 20 20 20 20 20 20 20 ATTACHED
297d0 20 20 20 20 20 20 20 20 20 20 37 0a 23 64 65 66 7.#def
297e0 69 6e 65 20 53 51 4c 49 54 45 5f 4c 49 4d 49 54 ine SQLITE_LIMIT
297f0 5f 4c 49 4b 45 5f 50 41 54 54 45 52 4e 5f 4c 45 _LIKE_PATTERN_LE
29800 4e 47 54 48 20 20 20 20 20 20 20 38 0a 23 64 65 NGTH 8.#de
29810 66 69 6e 65 20 53 51 4c 49 54 45 5f 4c 49 4d 49 fine SQLITE_LIMI
29820 54 5f 56 41 52 49 41 42 4c 45 5f 4e 55 4d 42 45 T_VARIABLE_NUMBE
29830 52 20 20 20 20 20 20 20 20 20 20 20 39 0a 23 64 R 9.#d
29840 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 4c 49 4d efine SQLITE_LIM
29850 49 54 5f 54 52 49 47 47 45 52 5f 44 45 50 54 48 IT_TRIGGER_DEPTH
29860 20 20 20 20 20 20 20 20 20 20 20 20 31 30 0a 23 10.#
29870 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 4c 49 define SQLITE_LI
29880 4d 49 54 5f 57 4f 52 4b 45 52 5f 54 48 52 45 41 MIT_WORKER_THREA
29890 44 53 20 20 20 20 20 20 20 20 20 20 20 31 31 0a DS 11.
298a0 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a ./*.** CAPI3REF:
298b0 20 43 6f 6d 70 69 6c 69 6e 67 20 41 6e 20 53 51 Compiling An SQ
298c0 4c 20 53 74 61 74 65 6d 65 6e 74 0a 2a 2a 20 4b L Statement.** K
298d0 45 59 57 4f 52 44 53 3a 20 7b 53 51 4c 20 73 74 EYWORDS: {SQL st
298e0 61 74 65 6d 65 6e 74 20 63 6f 6d 70 69 6c 65 72 atement compiler
298f0 7d 0a 2a 2a 20 4d 45 54 48 4f 44 3a 20 73 71 6c }.** METHOD: sql
29900 69 74 65 33 0a 2a 2a 20 43 4f 4e 53 54 52 55 43 ite3.** CONSTRUC
29910 54 4f 52 3a 20 73 71 6c 69 74 65 33 5f 73 74 6d TOR: sqlite3_stm
29920 74 0a 2a 2a 0a 2a 2a 20 54 6f 20 65 78 65 63 75 t.**.** To execu
29930 74 65 20 61 6e 20 53 51 4c 20 71 75 65 72 79 2c te an SQL query,
29940 20 69 74 20 6d 75 73 74 20 66 69 72 73 74 20 62 it must first b
29950 65 20 63 6f 6d 70 69 6c 65 64 20 69 6e 74 6f 20 e compiled into
29960 61 20 62 79 74 65 2d 63 6f 64 65 0a 2a 2a 20 70 a byte-code.** p
29970 72 6f 67 72 61 6d 20 75 73 69 6e 67 20 6f 6e 65 rogram using one
29980 20 6f 66 20 74 68 65 73 65 20 72 6f 75 74 69 6e of these routin
29990 65 73 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 66 69 es..**.** The fi
299a0 72 73 74 20 61 72 67 75 6d 65 6e 74 2c 20 22 64 rst argument, "d
299b0 62 22 2c 20 69 73 20 61 20 5b 64 61 74 61 62 61 b", is a [databa
299c0 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 5d 20 6f se connection] o
299d0 62 74 61 69 6e 65 64 20 66 72 6f 6d 20 61 0a 2a btained from a.*
299e0 2a 20 70 72 69 6f 72 20 73 75 63 63 65 73 73 66 * prior successf
299f0 75 6c 20 63 61 6c 6c 20 74 6f 20 5b 73 71 6c 69 ul call to [sqli
29a00 74 65 33 5f 6f 70 65 6e 28 29 5d 2c 20 5b 73 71 te3_open()], [sq
29a10 6c 69 74 65 33 5f 6f 70 65 6e 5f 76 32 28 29 5d lite3_open_v2()]
29a20 20 6f 72 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f or.** [sqlite3_
29a30 6f 70 65 6e 31 36 28 29 5d 2e 20 20 54 68 65 20 open16()]. The
29a40 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 database connect
29a50 69 6f 6e 20 6d 75 73 74 20 6e 6f 74 20 68 61 76 ion must not hav
29a60 65 20 62 65 65 6e 20 63 6c 6f 73 65 64 2e 0a 2a e been closed..*
29a70 2a 0a 2a 2a 20 54 68 65 20 73 65 63 6f 6e 64 20 *.** The second
29a80 61 72 67 75 6d 65 6e 74 2c 20 22 7a 53 71 6c 22 argument, "zSql"
29a90 2c 20 69 73 20 74 68 65 20 73 74 61 74 65 6d 65 , is the stateme
29aa0 6e 74 20 74 6f 20 62 65 20 63 6f 6d 70 69 6c 65 nt to be compile
29ab0 64 2c 20 65 6e 63 6f 64 65 64 0a 2a 2a 20 61 73 d, encoded.** as
29ac0 20 65 69 74 68 65 72 20 55 54 46 2d 38 20 6f 72 either UTF-8 or
29ad0 20 55 54 46 2d 31 36 2e 20 20 54 68 65 20 73 71 UTF-16. The sq
29ae0 6c 69 74 65 33 5f 70 72 65 70 61 72 65 28 29 20 lite3_prepare()
29af0 61 6e 64 20 73 71 6c 69 74 65 33 5f 70 72 65 70 and sqlite3_prep
29b00 61 72 65 5f 76 32 28 29 0a 2a 2a 20 69 6e 74 65 are_v2().** inte
29b10 72 66 61 63 65 73 20 75 73 65 20 55 54 46 2d 38 rfaces use UTF-8
29b20 2c 20 61 6e 64 20 73 71 6c 69 74 65 33 5f 70 72 , and sqlite3_pr
29b30 65 70 61 72 65 31 36 28 29 20 61 6e 64 20 73 71 epare16() and sq
29b40 6c 69 74 65 33 5f 70 72 65 70 61 72 65 31 36 5f lite3_prepare16_
29b50 76 32 28 29 0a 2a 2a 20 75 73 65 20 55 54 46 2d v2().** use UTF-
29b60 31 36 2e 0a 2a 2a 0a 2a 2a 20 5e 49 66 20 74 68 16..**.** ^If th
29b70 65 20 6e 42 79 74 65 20 61 72 67 75 6d 65 6e 74 e nByte argument
29b80 20 69 73 20 6e 65 67 61 74 69 76 65 2c 20 74 68 is negative, th
29b90 65 6e 20 7a 53 71 6c 20 69 73 20 72 65 61 64 20 en zSql is read
29ba0 75 70 20 74 6f 20 74 68 65 0a 2a 2a 20 66 69 72 up to the.** fir
29bb0 73 74 20 7a 65 72 6f 20 74 65 72 6d 69 6e 61 74 st zero terminat
29bc0 6f 72 2e 20 5e 49 66 20 6e 42 79 74 65 20 69 73 or. ^If nByte is
29bd0 20 70 6f 73 69 74 69 76 65 2c 20 74 68 65 6e 20 positive, then
29be0 69 74 20 69 73 20 74 68 65 0a 2a 2a 20 6e 75 6d it is the.** num
29bf0 62 65 72 20 6f 66 20 62 79 74 65 73 20 72 65 61 ber of bytes rea
29c00 64 20 66 72 6f 6d 20 7a 53 71 6c 2e 20 20 5e 49 d from zSql. ^I
29c10 66 20 6e 42 79 74 65 20 69 73 20 7a 65 72 6f 2c f nByte is zero,
29c20 20 74 68 65 6e 20 6e 6f 20 70 72 65 70 61 72 65 then no prepare
29c30 64 0a 2a 2a 20 73 74 61 74 65 6d 65 6e 74 20 69 d.** statement i
29c40 73 20 67 65 6e 65 72 61 74 65 64 2e 0a 2a 2a 20 s generated..**
29c50 49 66 20 74 68 65 20 63 61 6c 6c 65 72 20 6b 6e If the caller kn
29c60 6f 77 73 20 74 68 61 74 20 74 68 65 20 73 75 70 ows that the sup
29c70 70 6c 69 65 64 20 73 74 72 69 6e 67 20 69 73 20 plied string is
29c80 6e 75 6c 2d 74 65 72 6d 69 6e 61 74 65 64 2c 20 nul-terminated,
29c90 74 68 65 6e 0a 2a 2a 20 74 68 65 72 65 20 69 73 then.** there is
29ca0 20 61 20 73 6d 61 6c 6c 20 70 65 72 66 6f 72 6d a small perform
29cb0 61 6e 63 65 20 61 64 76 61 6e 74 61 67 65 20 74 ance advantage t
29cc0 6f 20 70 61 73 73 69 6e 67 20 61 6e 20 6e 42 79 o passing an nBy
29cd0 74 65 20 70 61 72 61 6d 65 74 65 72 20 74 68 61 te parameter tha
29ce0 74 0a 2a 2a 20 69 73 20 74 68 65 20 6e 75 6d 62 t.** is the numb
29cf0 65 72 20 6f 66 20 62 79 74 65 73 20 69 6e 20 74 er of bytes in t
29d00 68 65 20 69 6e 70 75 74 20 73 74 72 69 6e 67 20 he input string
29d10 3c 69 3e 69 6e 63 6c 75 64 69 6e 67 3c 2f 69 3e <i>including</i>
29d20 0a 2a 2a 20 74 68 65 20 6e 75 6c 2d 74 65 72 6d .** the nul-term
29d30 69 6e 61 74 6f 72 2e 0a 2a 2a 0a 2a 2a 20 5e 49 inator..**.** ^I
29d40 66 20 70 7a 54 61 69 6c 20 69 73 20 6e 6f 74 20 f pzTail is not
29d50 4e 55 4c 4c 20 74 68 65 6e 20 2a 70 7a 54 61 69 NULL then *pzTai
29d60 6c 20 69 73 20 6d 61 64 65 20 74 6f 20 70 6f 69 l is made to poi
29d70 6e 74 20 74 6f 20 74 68 65 20 66 69 72 73 74 20 nt to the first
29d80 62 79 74 65 0a 2a 2a 20 70 61 73 74 20 74 68 65 byte.** past the
29d90 20 65 6e 64 20 6f 66 20 74 68 65 20 66 69 72 73 end of the firs
29da0 74 20 53 51 4c 20 73 74 61 74 65 6d 65 6e 74 20 t SQL statement
29db0 69 6e 20 7a 53 71 6c 2e 20 20 54 68 65 73 65 20 in zSql. These
29dc0 72 6f 75 74 69 6e 65 73 20 6f 6e 6c 79 0a 2a 2a routines only.**
29dd0 20 63 6f 6d 70 69 6c 65 20 74 68 65 20 66 69 72 compile the fir
29de0 73 74 20 73 74 61 74 65 6d 65 6e 74 20 69 6e 20 st statement in
29df0 7a 53 71 6c 2c 20 73 6f 20 2a 70 7a 54 61 69 6c zSql, so *pzTail
29e00 20 69 73 20 6c 65 66 74 20 70 6f 69 6e 74 69 6e is left pointin
29e10 67 20 74 6f 0a 2a 2a 20 77 68 61 74 20 72 65 6d g to.** what rem
29e20 61 69 6e 73 20 75 6e 63 6f 6d 70 69 6c 65 64 2e ains uncompiled.
29e30 0a 2a 2a 0a 2a 2a 20 5e 2a 70 70 53 74 6d 74 20 .**.** ^*ppStmt
29e40 69 73 20 6c 65 66 74 20 70 6f 69 6e 74 69 6e 67 is left pointing
29e50 20 74 6f 20 61 20 63 6f 6d 70 69 6c 65 64 20 5b to a compiled [
29e60 70 72 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 prepared stateme
29e70 6e 74 5d 20 74 68 61 74 20 63 61 6e 20 62 65 0a nt] that can be.
29e80 2a 2a 20 65 78 65 63 75 74 65 64 20 75 73 69 6e ** executed usin
29e90 67 20 5b 73 71 6c 69 74 65 33 5f 73 74 65 70 28 g [sqlite3_step(
29ea0 29 5d 2e 20 20 5e 49 66 20 74 68 65 72 65 20 69 )]. ^If there i
29eb0 73 20 61 6e 20 65 72 72 6f 72 2c 20 2a 70 70 53 s an error, *ppS
29ec0 74 6d 74 20 69 73 20 73 65 74 0a 2a 2a 20 74 6f tmt is set.** to
29ed0 20 4e 55 4c 4c 2e 20 20 5e 49 66 20 74 68 65 20 NULL. ^If the
29ee0 69 6e 70 75 74 20 74 65 78 74 20 63 6f 6e 74 61 input text conta
29ef0 69 6e 73 20 6e 6f 20 53 51 4c 20 28 69 66 20 74 ins no SQL (if t
29f00 68 65 20 69 6e 70 75 74 20 69 73 20 61 6e 20 65 he input is an e
29f10 6d 70 74 79 0a 2a 2a 20 73 74 72 69 6e 67 20 6f mpty.** string o
29f20 72 20 61 20 63 6f 6d 6d 65 6e 74 29 20 74 68 65 r a comment) the
29f30 6e 20 2a 70 70 53 74 6d 74 20 69 73 20 73 65 74 n *ppStmt is set
29f40 20 74 6f 20 4e 55 4c 4c 2e 0a 2a 2a 20 54 68 65 to NULL..** The
29f50 20 63 61 6c 6c 69 6e 67 20 70 72 6f 63 65 64 75 calling procedu
29f60 72 65 20 69 73 20 72 65 73 70 6f 6e 73 69 62 6c re is responsibl
29f70 65 20 66 6f 72 20 64 65 6c 65 74 69 6e 67 20 74 e for deleting t
29f80 68 65 20 63 6f 6d 70 69 6c 65 64 0a 2a 2a 20 53 he compiled.** S
29f90 51 4c 20 73 74 61 74 65 6d 65 6e 74 20 75 73 69 QL statement usi
29fa0 6e 67 20 5b 73 71 6c 69 74 65 33 5f 66 69 6e 61 ng [sqlite3_fina
29fb0 6c 69 7a 65 28 29 5d 20 61 66 74 65 72 20 69 74 lize()] after it
29fc0 20 68 61 73 20 66 69 6e 69 73 68 65 64 20 77 69 has finished wi
29fd0 74 68 20 69 74 2e 0a 2a 2a 20 70 70 53 74 6d 74 th it..** ppStmt
29fe0 20 6d 61 79 20 6e 6f 74 20 62 65 20 4e 55 4c 4c may not be NULL
29ff0 2e 0a 2a 2a 0a 2a 2a 20 5e 4f 6e 20 73 75 63 63 ..**.** ^On succ
2a000 65 73 73 2c 20 74 68 65 20 73 71 6c 69 74 65 33 ess, the sqlite3
2a010 5f 70 72 65 70 61 72 65 28 29 20 66 61 6d 69 6c _prepare() famil
2a020 79 20 6f 66 20 72 6f 75 74 69 6e 65 73 20 72 65 y of routines re
2a030 74 75 72 6e 20 5b 53 51 4c 49 54 45 5f 4f 4b 5d turn [SQLITE_OK]
2a040 3b 0a 2a 2a 20 6f 74 68 65 72 77 69 73 65 20 61 ;.** otherwise a
2a050 6e 20 5b 65 72 72 6f 72 20 63 6f 64 65 5d 20 69 n [error code] i
2a060 73 20 72 65 74 75 72 6e 65 64 2e 0a 2a 2a 0a 2a s returned..**.*
2a070 2a 20 54 68 65 20 73 71 6c 69 74 65 33 5f 70 72 * The sqlite3_pr
2a080 65 70 61 72 65 5f 76 32 28 29 20 61 6e 64 20 73 epare_v2() and s
2a090 71 6c 69 74 65 33 5f 70 72 65 70 61 72 65 31 36 qlite3_prepare16
2a0a0 5f 76 32 28 29 20 69 6e 74 65 72 66 61 63 65 73 _v2() interfaces
2a0b0 20 61 72 65 0a 2a 2a 20 72 65 63 6f 6d 6d 65 6e are.** recommen
2a0c0 64 65 64 20 66 6f 72 20 61 6c 6c 20 6e 65 77 20 ded for all new
2a0d0 70 72 6f 67 72 61 6d 73 2e 20 54 68 65 20 74 77 programs. The tw
2a0e0 6f 20 6f 6c 64 65 72 20 69 6e 74 65 72 66 61 63 o older interfac
2a0f0 65 73 20 61 72 65 20 72 65 74 61 69 6e 65 64 0a es are retained.
2a100 2a 2a 20 66 6f 72 20 62 61 63 6b 77 61 72 64 73 ** for backwards
2a110 20 63 6f 6d 70 61 74 69 62 69 6c 69 74 79 2c 20 compatibility,
2a120 62 75 74 20 74 68 65 69 72 20 75 73 65 20 69 73 but their use is
2a130 20 64 69 73 63 6f 75 72 61 67 65 64 2e 0a 2a 2a discouraged..**
2a140 20 5e 49 6e 20 74 68 65 20 22 76 32 22 20 69 6e ^In the "v2" in
2a150 74 65 72 66 61 63 65 73 2c 20 74 68 65 20 70 72 terfaces, the pr
2a160 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 epared statement
2a170 0a 2a 2a 20 74 68 61 74 20 69 73 20 72 65 74 75 .** that is retu
2a180 72 6e 65 64 20 28 74 68 65 20 5b 73 71 6c 69 74 rned (the [sqlit
2a190 65 33 5f 73 74 6d 74 5d 20 6f 62 6a 65 63 74 29 e3_stmt] object)
2a1a0 20 63 6f 6e 74 61 69 6e 73 20 61 20 63 6f 70 79 contains a copy
2a1b0 20 6f 66 20 74 68 65 0a 2a 2a 20 6f 72 69 67 69 of the.** origi
2a1c0 6e 61 6c 20 53 51 4c 20 74 65 78 74 2e 20 54 68 nal SQL text. Th
2a1d0 69 73 20 63 61 75 73 65 73 20 74 68 65 20 5b 73 is causes the [s
2a1e0 71 6c 69 74 65 33 5f 73 74 65 70 28 29 5d 20 69 qlite3_step()] i
2a1f0 6e 74 65 72 66 61 63 65 20 74 6f 0a 2a 2a 20 62 nterface to.** b
2a200 65 68 61 76 65 20 64 69 66 66 65 72 65 6e 74 6c ehave differentl
2a210 79 20 69 6e 20 74 68 72 65 65 20 77 61 79 73 3a y in three ways:
2a220 0a 2a 2a 0a 2a 2a 20 3c 6f 6c 3e 0a 2a 2a 20 3c .**.** <ol>.** <
2a230 6c 69 3e 0a 2a 2a 20 5e 49 66 20 74 68 65 20 64 li>.** ^If the d
2a240 61 74 61 62 61 73 65 20 73 63 68 65 6d 61 20 63 atabase schema c
2a250 68 61 6e 67 65 73 2c 20 69 6e 73 74 65 61 64 20 hanges, instead
2a260 6f 66 20 72 65 74 75 72 6e 69 6e 67 20 5b 53 51 of returning [SQ
2a270 4c 49 54 45 5f 53 43 48 45 4d 41 5d 20 61 73 20 LITE_SCHEMA] as
2a280 69 74 0a 2a 2a 20 61 6c 77 61 79 73 20 75 73 65 it.** always use
2a290 64 20 74 6f 20 64 6f 2c 20 5b 73 71 6c 69 74 65 d to do, [sqlite
2a2a0 33 5f 73 74 65 70 28 29 5d 20 77 69 6c 6c 20 61 3_step()] will a
2a2b0 75 74 6f 6d 61 74 69 63 61 6c 6c 79 20 72 65 63 utomatically rec
2a2c0 6f 6d 70 69 6c 65 20 74 68 65 20 53 51 4c 0a 2a ompile the SQL.*
2a2d0 2a 20 73 74 61 74 65 6d 65 6e 74 20 61 6e 64 20 * statement and
2a2e0 74 72 79 20 74 6f 20 72 75 6e 20 69 74 20 61 67 try to run it ag
2a2f0 61 69 6e 2e 20 41 73 20 6d 61 6e 79 20 61 73 20 ain. As many as
2a300 5b 53 51 4c 49 54 45 5f 4d 41 58 5f 53 43 48 45 [SQLITE_MAX_SCHE
2a310 4d 41 5f 52 45 54 52 59 5d 0a 2a 2a 20 72 65 74 MA_RETRY].** ret
2a320 72 69 65 73 20 77 69 6c 6c 20 6f 63 63 75 72 20 ries will occur
2a330 62 65 66 6f 72 65 20 73 71 6c 69 74 65 33 5f 73 before sqlite3_s
2a340 74 65 70 28 29 20 67 69 76 65 73 20 75 70 20 61 tep() gives up a
2a350 6e 64 20 72 65 74 75 72 6e 73 20 61 6e 20 65 72 nd returns an er
2a360 72 6f 72 2e 0a 2a 2a 20 3c 2f 6c 69 3e 0a 2a 2a ror..** </li>.**
2a370 0a 2a 2a 20 3c 6c 69 3e 0a 2a 2a 20 5e 57 68 65 .** <li>.** ^Whe
2a380 6e 20 61 6e 20 65 72 72 6f 72 20 6f 63 63 75 72 n an error occur
2a390 73 2c 20 5b 73 71 6c 69 74 65 33 5f 73 74 65 70 s, [sqlite3_step
2a3a0 28 29 5d 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 ()] will return
2a3b0 6f 6e 65 20 6f 66 20 74 68 65 20 64 65 74 61 69 one of the detai
2a3c0 6c 65 64 0a 2a 2a 20 5b 65 72 72 6f 72 20 63 6f led.** [error co
2a3d0 64 65 73 5d 20 6f 72 20 5b 65 78 74 65 6e 64 65 des] or [extende
2a3e0 64 20 65 72 72 6f 72 20 63 6f 64 65 73 5d 2e 20 d error codes].
2a3f0 20 5e 54 68 65 20 6c 65 67 61 63 79 20 62 65 68 ^The legacy beh
2a400 61 76 69 6f 72 20 77 61 73 20 74 68 61 74 0a 2a avior was that.*
2a410 2a 20 5b 73 71 6c 69 74 65 33 5f 73 74 65 70 28 * [sqlite3_step(
2a420 29 5d 20 77 6f 75 6c 64 20 6f 6e 6c 79 20 72 65 )] would only re
2a430 74 75 72 6e 20 61 20 67 65 6e 65 72 69 63 20 5b turn a generic [
2a440 53 51 4c 49 54 45 5f 45 52 52 4f 52 5d 20 72 65 SQLITE_ERROR] re
2a450 73 75 6c 74 20 63 6f 64 65 0a 2a 2a 20 61 6e 64 sult code.** and
2a460 20 74 68 65 20 61 70 70 6c 69 63 61 74 69 6f 6e the application
2a470 20 77 6f 75 6c 64 20 68 61 76 65 20 74 6f 20 6d would have to m
2a480 61 6b 65 20 61 20 73 65 63 6f 6e 64 20 63 61 6c ake a second cal
2a490 6c 20 74 6f 20 5b 73 71 6c 69 74 65 33 5f 72 65 l to [sqlite3_re
2a4a0 73 65 74 28 29 5d 0a 2a 2a 20 69 6e 20 6f 72 64 set()].** in ord
2a4b0 65 72 20 74 6f 20 66 69 6e 64 20 74 68 65 20 75 er to find the u
2a4c0 6e 64 65 72 6c 79 69 6e 67 20 63 61 75 73 65 20 nderlying cause
2a4d0 6f 66 20 74 68 65 20 70 72 6f 62 6c 65 6d 2e 20 of the problem.
2a4e0 57 69 74 68 20 74 68 65 20 22 76 32 22 20 70 72 With the "v2" pr
2a4f0 65 70 61 72 65 0a 2a 2a 20 69 6e 74 65 72 66 61 epare.** interfa
2a500 63 65 73 2c 20 74 68 65 20 75 6e 64 65 72 6c 79 ces, the underly
2a510 69 6e 67 20 72 65 61 73 6f 6e 20 66 6f 72 20 74 ing reason for t
2a520 68 65 20 65 72 72 6f 72 20 69 73 20 72 65 74 75 he error is retu
2a530 72 6e 65 64 20 69 6d 6d 65 64 69 61 74 65 6c 79 rned immediately
2a540 2e 0a 2a 2a 20 3c 2f 6c 69 3e 0a 2a 2a 0a 2a 2a ..** </li>.**.**
2a550 20 3c 6c 69 3e 0a 2a 2a 20 5e 49 66 20 74 68 65 <li>.** ^If the
2a560 20 73 70 65 63 69 66 69 63 20 76 61 6c 75 65 20 specific value
2a570 62 6f 75 6e 64 20 74 6f 20 5b 70 61 72 61 6d 65 bound to [parame
2a580 74 65 72 20 7c 20 68 6f 73 74 20 70 61 72 61 6d ter | host param
2a590 65 74 65 72 5d 20 69 6e 20 74 68 65 20 0a 2a 2a eter] in the .**
2a5a0 20 57 48 45 52 45 20 63 6c 61 75 73 65 20 6d 69 WHERE clause mi
2a5b0 67 68 74 20 69 6e 66 6c 75 65 6e 63 65 20 74 68 ght influence th
2a5c0 65 20 63 68 6f 69 63 65 20 6f 66 20 71 75 65 72 e choice of quer
2a5d0 79 20 70 6c 61 6e 20 66 6f 72 20 61 20 73 74 61 y plan for a sta
2a5e0 74 65 6d 65 6e 74 2c 0a 2a 2a 20 74 68 65 6e 20 tement,.** then
2a5f0 74 68 65 20 73 74 61 74 65 6d 65 6e 74 20 77 69 the statement wi
2a600 6c 6c 20 62 65 20 61 75 74 6f 6d 61 74 69 63 61 ll be automatica
2a610 6c 6c 79 20 72 65 63 6f 6d 70 69 6c 65 64 2c 20 lly recompiled,
2a620 61 73 20 69 66 20 74 68 65 72 65 20 68 61 64 20 as if there had
2a630 62 65 65 6e 20 0a 2a 2a 20 61 20 73 63 68 65 6d been .** a schem
2a640 61 20 63 68 61 6e 67 65 2c 20 6f 6e 20 74 68 65 a change, on the
2a650 20 66 69 72 73 74 20 20 5b 73 71 6c 69 74 65 33 first [sqlite3
2a660 5f 73 74 65 70 28 29 5d 20 63 61 6c 6c 20 66 6f _step()] call fo
2a670 6c 6c 6f 77 69 6e 67 20 61 6e 79 20 63 68 61 6e llowing any chan
2a680 67 65 0a 2a 2a 20 74 6f 20 74 68 65 20 5b 73 71 ge.** to the [sq
2a690 6c 69 74 65 33 5f 62 69 6e 64 5f 74 65 78 74 20 lite3_bind_text
2a6a0 7c 20 62 69 6e 64 69 6e 67 73 5d 20 6f 66 20 74 | bindings] of t
2a6b0 68 61 74 20 5b 70 61 72 61 6d 65 74 65 72 5d 2e hat [parameter].
2a6c0 20 0a 2a 2a 20 5e 54 68 65 20 73 70 65 63 69 66 .** ^The specif
2a6d0 69 63 20 76 61 6c 75 65 20 6f 66 20 57 48 45 52 ic value of WHER
2a6e0 45 2d 63 6c 61 75 73 65 20 5b 70 61 72 61 6d 65 E-clause [parame
2a6f0 74 65 72 5d 20 6d 69 67 68 74 20 69 6e 66 6c 75 ter] might influ
2a700 65 6e 63 65 20 74 68 65 20 0a 2a 2a 20 63 68 6f ence the .** cho
2a710 69 63 65 20 6f 66 20 71 75 65 72 79 20 70 6c 61 ice of query pla
2a720 6e 20 69 66 20 74 68 65 20 70 61 72 61 6d 65 74 n if the paramet
2a730 65 72 20 69 73 20 74 68 65 20 6c 65 66 74 2d 68 er is the left-h
2a740 61 6e 64 20 73 69 64 65 20 6f 66 20 61 20 5b 4c and side of a [L
2a750 49 4b 45 5d 0a 2a 2a 20 6f 72 20 5b 47 4c 4f 42 IKE].** or [GLOB
2a760 5d 20 6f 70 65 72 61 74 6f 72 20 6f 72 20 69 66 ] operator or if
2a770 20 74 68 65 20 70 61 72 61 6d 65 74 65 72 20 69 the parameter i
2a780 73 20 63 6f 6d 70 61 72 65 64 20 74 6f 20 61 6e s compared to an
2a790 20 69 6e 64 65 78 65 64 20 63 6f 6c 75 6d 6e 0a indexed column.
2a7a0 2a 2a 20 61 6e 64 20 74 68 65 20 5b 53 51 4c 49 ** and the [SQLI
2a7b0 54 45 5f 45 4e 41 42 4c 45 5f 53 54 41 54 33 5d TE_ENABLE_STAT3]
2a7c0 20 63 6f 6d 70 69 6c 65 2d 74 69 6d 65 20 6f 70 compile-time op
2a7d0 74 69 6f 6e 20 69 73 20 65 6e 61 62 6c 65 64 2e tion is enabled.
2a7e0 0a 2a 2a 20 3c 2f 6c 69 3e 0a 2a 2a 20 3c 2f 6f .** </li>.** </o
2a7f0 6c 3e 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 65 l>.*/.int sqlite
2a800 33 5f 70 72 65 70 61 72 65 28 0a 20 20 73 71 6c 3_prepare(. sql
2a810 69 74 65 33 20 2a 64 62 2c 20 20 20 20 20 20 20 ite3 *db,
2a820 20 20 20 20 20 2f 2a 20 44 61 74 61 62 61 73 65 /* Database
2a830 20 68 61 6e 64 6c 65 20 2a 2f 0a 20 20 63 6f 6e handle */. con
2a840 73 74 20 63 68 61 72 20 2a 7a 53 71 6c 2c 20 20 st char *zSql,
2a850 20 20 20 20 20 2f 2a 20 53 51 4c 20 73 74 61 74 /* SQL stat
2a860 65 6d 65 6e 74 2c 20 55 54 46 2d 38 20 65 6e 63 ement, UTF-8 enc
2a870 6f 64 65 64 20 2a 2f 0a 20 20 69 6e 74 20 6e 42 oded */. int nB
2a880 79 74 65 2c 20 20 20 20 20 20 20 20 20 20 20 20 yte,
2a890 20 20 2f 2a 20 4d 61 78 69 6d 75 6d 20 6c 65 6e /* Maximum len
2a8a0 67 74 68 20 6f 66 20 7a 53 71 6c 20 69 6e 20 62 gth of zSql in b
2a8b0 79 74 65 73 2e 20 2a 2f 0a 20 20 73 71 6c 69 74 ytes. */. sqlit
2a8c0 65 33 5f 73 74 6d 74 20 2a 2a 70 70 53 74 6d 74 e3_stmt **ppStmt
2a8d0 2c 20 20 2f 2a 20 4f 55 54 3a 20 53 74 61 74 65 , /* OUT: State
2a8e0 6d 65 6e 74 20 68 61 6e 64 6c 65 20 2a 2f 0a 20 ment handle */.
2a8f0 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 2a 70 7a const char **pz
2a900 54 61 69 6c 20 20 20 20 20 2f 2a 20 4f 55 54 3a Tail /* OUT:
2a910 20 50 6f 69 6e 74 65 72 20 74 6f 20 75 6e 75 73 Pointer to unus
2a920 65 64 20 70 6f 72 74 69 6f 6e 20 6f 66 20 7a 53 ed portion of zS
2a930 71 6c 20 2a 2f 0a 29 3b 0a 69 6e 74 20 73 71 6c ql */.);.int sql
2a940 69 74 65 33 5f 70 72 65 70 61 72 65 5f 76 32 28 ite3_prepare_v2(
2a950 0a 20 20 73 71 6c 69 74 65 33 20 2a 64 62 2c 20 . sqlite3 *db,
2a960 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 44 61 /* Da
2a970 74 61 62 61 73 65 20 68 61 6e 64 6c 65 20 2a 2f tabase handle */
2a980 0a 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a . const char *z
2a990 53 71 6c 2c 20 20 20 20 20 20 20 2f 2a 20 53 51 Sql, /* SQ
2a9a0 4c 20 73 74 61 74 65 6d 65 6e 74 2c 20 55 54 46 L statement, UTF
2a9b0 2d 38 20 65 6e 63 6f 64 65 64 20 2a 2f 0a 20 20 -8 encoded */.
2a9c0 69 6e 74 20 6e 42 79 74 65 2c 20 20 20 20 20 20 int nByte,
2a9d0 20 20 20 20 20 20 20 20 2f 2a 20 4d 61 78 69 6d /* Maxim
2a9e0 75 6d 20 6c 65 6e 67 74 68 20 6f 66 20 7a 53 71 um length of zSq
2a9f0 6c 20 69 6e 20 62 79 74 65 73 2e 20 2a 2f 0a 20 l in bytes. */.
2aa00 20 73 71 6c 69 74 65 33 5f 73 74 6d 74 20 2a 2a sqlite3_stmt **
2aa10 70 70 53 74 6d 74 2c 20 20 2f 2a 20 4f 55 54 3a ppStmt, /* OUT:
2aa20 20 53 74 61 74 65 6d 65 6e 74 20 68 61 6e 64 6c Statement handl
2aa30 65 20 2a 2f 0a 20 20 63 6f 6e 73 74 20 63 68 61 e */. const cha
2aa40 72 20 2a 2a 70 7a 54 61 69 6c 20 20 20 20 20 2f r **pzTail /
2aa50 2a 20 4f 55 54 3a 20 50 6f 69 6e 74 65 72 20 74 * OUT: Pointer t
2aa60 6f 20 75 6e 75 73 65 64 20 70 6f 72 74 69 6f 6e o unused portion
2aa70 20 6f 66 20 7a 53 71 6c 20 2a 2f 0a 29 3b 0a 69 of zSql */.);.i
2aa80 6e 74 20 73 71 6c 69 74 65 33 5f 70 72 65 70 61 nt sqlite3_prepa
2aa90 72 65 31 36 28 0a 20 20 73 71 6c 69 74 65 33 20 re16(. sqlite3
2aaa0 2a 64 62 2c 20 20 20 20 20 20 20 20 20 20 20 20 *db,
2aab0 2f 2a 20 44 61 74 61 62 61 73 65 20 68 61 6e 64 /* Database hand
2aac0 6c 65 20 2a 2f 0a 20 20 63 6f 6e 73 74 20 76 6f le */. const vo
2aad0 69 64 20 2a 7a 53 71 6c 2c 20 20 20 20 20 20 20 id *zSql,
2aae0 2f 2a 20 53 51 4c 20 73 74 61 74 65 6d 65 6e 74 /* SQL statement
2aaf0 2c 20 55 54 46 2d 31 36 20 65 6e 63 6f 64 65 64 , UTF-16 encoded
2ab00 20 2a 2f 0a 20 20 69 6e 74 20 6e 42 79 74 65 2c */. int nByte,
2ab10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a /*
2ab20 20 4d 61 78 69 6d 75 6d 20 6c 65 6e 67 74 68 20 Maximum length
2ab30 6f 66 20 7a 53 71 6c 20 69 6e 20 62 79 74 65 73 of zSql in bytes
2ab40 2e 20 2a 2f 0a 20 20 73 71 6c 69 74 65 33 5f 73 . */. sqlite3_s
2ab50 74 6d 74 20 2a 2a 70 70 53 74 6d 74 2c 20 20 2f tmt **ppStmt, /
2ab60 2a 20 4f 55 54 3a 20 53 74 61 74 65 6d 65 6e 74 * OUT: Statement
2ab70 20 68 61 6e 64 6c 65 20 2a 2f 0a 20 20 63 6f 6e handle */. con
2ab80 73 74 20 76 6f 69 64 20 2a 2a 70 7a 54 61 69 6c st void **pzTail
2ab90 20 20 20 20 20 2f 2a 20 4f 55 54 3a 20 50 6f 69 /* OUT: Poi
2aba0 6e 74 65 72 20 74 6f 20 75 6e 75 73 65 64 20 70 nter to unused p
2abb0 6f 72 74 69 6f 6e 20 6f 66 20 7a 53 71 6c 20 2a ortion of zSql *
2abc0 2f 0a 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 /.);.int sqlite3
2abd0 5f 70 72 65 70 61 72 65 31 36 5f 76 32 28 0a 20 _prepare16_v2(.
2abe0 20 73 71 6c 69 74 65 33 20 2a 64 62 2c 20 20 20 sqlite3 *db,
2abf0 20 20 20 20 20 20 20 20 20 2f 2a 20 44 61 74 61 /* Data
2ac00 62 61 73 65 20 68 61 6e 64 6c 65 20 2a 2f 0a 20 base handle */.
2ac10 20 63 6f 6e 73 74 20 76 6f 69 64 20 2a 7a 53 71 const void *zSq
2ac20 6c 2c 20 20 20 20 20 20 20 2f 2a 20 53 51 4c 20 l, /* SQL
2ac30 73 74 61 74 65 6d 65 6e 74 2c 20 55 54 46 2d 31 statement, UTF-1
2ac40 36 20 65 6e 63 6f 64 65 64 20 2a 2f 0a 20 20 69 6 encoded */. i
2ac50 6e 74 20 6e 42 79 74 65 2c 20 20 20 20 20 20 20 nt nByte,
2ac60 20 20 20 20 20 20 20 2f 2a 20 4d 61 78 69 6d 75 /* Maximu
2ac70 6d 20 6c 65 6e 67 74 68 20 6f 66 20 7a 53 71 6c m length of zSql
2ac80 20 69 6e 20 62 79 74 65 73 2e 20 2a 2f 0a 20 20 in bytes. */.
2ac90 73 71 6c 69 74 65 33 5f 73 74 6d 74 20 2a 2a 70 sqlite3_stmt **p
2aca0 70 53 74 6d 74 2c 20 20 2f 2a 20 4f 55 54 3a 20 pStmt, /* OUT:
2acb0 53 74 61 74 65 6d 65 6e 74 20 68 61 6e 64 6c 65 Statement handle
2acc0 20 2a 2f 0a 20 20 63 6f 6e 73 74 20 76 6f 69 64 */. const void
2acd0 20 2a 2a 70 7a 54 61 69 6c 20 20 20 20 20 2f 2a **pzTail /*
2ace0 20 4f 55 54 3a 20 50 6f 69 6e 74 65 72 20 74 6f OUT: Pointer to
2acf0 20 75 6e 75 73 65 64 20 70 6f 72 74 69 6f 6e 20 unused portion
2ad00 6f 66 20 7a 53 71 6c 20 2a 2f 0a 29 3b 0a 0a 2f of zSql */.);../
2ad10 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 52 *.** CAPI3REF: R
2ad20 65 74 72 69 65 76 69 6e 67 20 53 74 61 74 65 6d etrieving Statem
2ad30 65 6e 74 20 53 51 4c 0a 2a 2a 20 4d 45 54 48 4f ent SQL.** METHO
2ad40 44 3a 20 73 71 6c 69 74 65 33 5f 73 74 6d 74 0a D: sqlite3_stmt.
2ad50 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 6c 69 74 **.** ^The sqlit
2ad60 65 33 5f 73 71 6c 28 50 29 20 69 6e 74 65 72 66 e3_sql(P) interf
2ad70 61 63 65 20 72 65 74 75 72 6e 73 20 61 20 70 6f ace returns a po
2ad80 69 6e 74 65 72 20 74 6f 20 61 20 63 6f 70 79 20 inter to a copy
2ad90 6f 66 20 74 68 65 20 55 54 46 2d 38 0a 2a 2a 20 of the UTF-8.**
2ada0 53 51 4c 20 74 65 78 74 20 75 73 65 64 20 74 6f SQL text used to
2adb0 20 63 72 65 61 74 65 20 5b 70 72 65 70 61 72 65 create [prepare
2adc0 64 20 73 74 61 74 65 6d 65 6e 74 5d 20 50 20 69 d statement] P i
2add0 66 20 50 20 77 61 73 0a 2a 2a 20 63 72 65 61 74 f P was.** creat
2ade0 65 64 20 62 79 20 65 69 74 68 65 72 20 5b 73 71 ed by either [sq
2adf0 6c 69 74 65 33 5f 70 72 65 70 61 72 65 5f 76 32 lite3_prepare_v2
2ae00 28 29 5d 20 6f 72 20 5b 73 71 6c 69 74 65 33 5f ()] or [sqlite3_
2ae10 70 72 65 70 61 72 65 31 36 5f 76 32 28 29 5d 2e prepare16_v2()].
2ae20 0a 2a 2a 20 5e 54 68 65 20 73 71 6c 69 74 65 33 .** ^The sqlite3
2ae30 5f 65 78 70 61 6e 64 65 64 5f 73 71 6c 28 50 29 _expanded_sql(P)
2ae40 20 69 6e 74 65 72 66 61 63 65 20 72 65 74 75 72 interface retur
2ae50 6e 73 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 ns a pointer to
2ae60 61 20 55 54 46 2d 38 0a 2a 2a 20 73 74 72 69 6e a UTF-8.** strin
2ae70 67 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 g containing the
2ae80 20 53 51 4c 20 74 65 78 74 20 6f 66 20 70 72 65 SQL text of pre
2ae90 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 20 pared statement
2aea0 50 20 77 69 74 68 0a 2a 2a 20 5b 62 6f 75 6e 64 P with.** [bound
2aeb0 20 70 61 72 61 6d 65 74 65 72 73 5d 20 65 78 70 parameters] exp
2aec0 61 6e 64 65 64 2e 0a 2a 2a 0a 2a 2a 20 5e 28 46 anded..**.** ^(F
2aed0 6f 72 20 65 78 61 6d 70 6c 65 2c 20 69 66 20 61 or example, if a
2aee0 20 70 72 65 70 61 72 65 64 20 73 74 61 74 65 6d prepared statem
2aef0 65 6e 74 20 69 73 20 63 72 65 61 74 65 64 20 75 ent is created u
2af00 73 69 6e 67 20 74 68 65 20 53 51 4c 0a 2a 2a 20 sing the SQL.**
2af10 74 65 78 74 20 22 53 45 4c 45 43 54 20 24 61 62 text "SELECT $ab
2af20 63 2c 3a 78 79 7a 22 20 61 6e 64 20 69 66 20 70 c,:xyz" and if p
2af30 61 72 61 6d 65 74 65 72 20 24 61 62 63 20 69 73 arameter $abc is
2af40 20 62 6f 75 6e 64 20 74 6f 20 69 6e 74 65 67 65 bound to intege
2af50 72 20 32 33 34 35 0a 2a 2a 20 61 6e 64 20 70 61 r 2345.** and pa
2af60 72 61 6d 65 74 65 72 20 3a 78 79 7a 20 69 73 20 rameter :xyz is
2af70 75 6e 62 6f 75 6e 64 2c 20 74 68 65 6e 20 73 71 unbound, then sq
2af80 6c 69 74 65 33 5f 73 71 6c 28 29 20 77 69 6c 6c lite3_sql() will
2af90 20 72 65 74 75 72 6e 0a 2a 2a 20 74 68 65 20 6f return.** the o
2afa0 72 69 67 69 6e 61 6c 20 73 74 72 69 6e 67 2c 20 riginal string,
2afb0 22 53 45 4c 45 43 54 20 24 61 62 63 2c 3a 78 79 "SELECT $abc,:xy
2afc0 7a 22 20 62 75 74 20 73 71 6c 69 74 65 33 5f 65 z" but sqlite3_e
2afd0 78 70 61 6e 64 65 64 5f 73 71 6c 28 29 0a 2a 2a xpanded_sql().**
2afe0 20 77 69 6c 6c 20 72 65 74 75 72 6e 20 22 53 45 will return "SE
2aff0 4c 45 43 54 20 32 33 34 35 2c 4e 55 4c 4c 22 2e LECT 2345,NULL".
2b000 29 5e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 )^.**.** ^The sq
2b010 6c 69 74 65 33 5f 65 78 70 61 6e 64 65 64 5f 73 lite3_expanded_s
2b020 71 6c 28 29 20 69 6e 74 65 72 66 61 63 65 20 72 ql() interface r
2b030 65 74 75 72 6e 73 20 4e 55 4c 4c 20 69 66 20 69 eturns NULL if i
2b040 6e 73 75 66 66 69 63 69 65 6e 74 20 6d 65 6d 6f nsufficient memo
2b050 72 79 0a 2a 2a 20 69 73 20 61 76 61 69 6c 61 62 ry.** is availab
2b060 6c 65 20 74 6f 20 68 6f 6c 64 20 74 68 65 20 72 le to hold the r
2b070 65 73 75 6c 74 2c 20 6f 72 20 69 66 20 74 68 65 esult, or if the
2b080 20 72 65 73 75 6c 74 20 77 6f 75 6c 64 20 65 78 result would ex
2b090 63 65 65 64 20 74 68 65 0a 2a 2a 20 74 68 65 20 ceed the.** the
2b0a0 6d 61 78 69 6d 75 6d 20 73 74 72 69 6e 67 20 6c maximum string l
2b0b0 65 6e 67 74 68 20 64 65 74 65 72 6d 69 6e 65 64 ength determined
2b0c0 20 62 79 20 74 68 65 20 5b 53 51 4c 49 54 45 5f by the [SQLITE_
2b0d0 4c 49 4d 49 54 5f 4c 45 4e 47 54 48 5d 2e 0a 2a LIMIT_LENGTH]..*
2b0e0 2a 0a 2a 2a 20 5e 54 68 65 20 5b 53 51 4c 49 54 *.** ^The [SQLIT
2b0f0 45 5f 54 52 41 43 45 5f 53 49 5a 45 5f 4c 49 4d E_TRACE_SIZE_LIM
2b100 49 54 5d 20 63 6f 6d 70 69 6c 65 2d 74 69 6d 65 IT] compile-time
2b110 20 6f 70 74 69 6f 6e 20 6c 69 6d 69 74 73 20 74 option limits t
2b120 68 65 20 73 69 7a 65 20 6f 66 0a 2a 2a 20 62 6f he size of.** bo
2b130 75 6e 64 20 70 61 72 61 6d 65 74 65 72 20 65 78 und parameter ex
2b140 70 61 6e 73 69 6f 6e 73 2e 20 20 5e 54 68 65 20 pansions. ^The
2b150 5b 53 51 4c 49 54 45 5f 4f 4d 49 54 5f 54 52 41 [SQLITE_OMIT_TRA
2b160 43 45 5d 20 63 6f 6d 70 69 6c 65 2d 74 69 6d 65 CE] compile-time
2b170 0a 2a 2a 20 6f 70 74 69 6f 6e 20 63 61 75 73 65 .** option cause
2b180 73 20 73 71 6c 69 74 65 33 5f 65 78 70 61 6e 64 s sqlite3_expand
2b190 65 64 5f 73 71 6c 28 29 20 74 6f 20 61 6c 77 61 ed_sql() to alwa
2b1a0 79 73 20 72 65 74 75 72 6e 20 4e 55 4c 4c 2e 0a ys return NULL..
2b1b0 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 74 72 69 6e **.** ^The strin
2b1c0 67 20 72 65 74 75 72 6e 65 64 20 62 79 20 73 71 g returned by sq
2b1d0 6c 69 74 65 33 5f 73 71 6c 28 50 29 20 69 73 20 lite3_sql(P) is
2b1e0 6d 61 6e 61 67 65 64 20 62 79 20 53 51 4c 69 74 managed by SQLit
2b1f0 65 20 61 6e 64 20 69 73 0a 2a 2a 20 61 75 74 6f e and is.** auto
2b200 6d 61 74 69 63 61 6c 6c 79 20 66 72 65 65 64 20 matically freed
2b210 77 68 65 6e 20 74 68 65 20 70 72 65 70 61 72 65 when the prepare
2b220 64 20 73 74 61 74 65 6d 65 6e 74 20 69 73 20 66 d statement is f
2b230 69 6e 61 6c 69 7a 65 64 2e 0a 2a 2a 20 5e 54 68 inalized..** ^Th
2b240 65 20 73 74 72 69 6e 67 20 72 65 74 75 72 6e 65 e string returne
2b250 64 20 62 79 20 73 71 6c 69 74 65 33 5f 65 78 70 d by sqlite3_exp
2b260 61 6e 64 65 64 5f 73 71 6c 28 50 29 2c 20 6f 6e anded_sql(P), on
2b270 20 74 68 65 20 6f 74 68 65 72 20 68 61 6e 64 2c the other hand,
2b280 0a 2a 2a 20 69 73 20 6f 62 74 61 69 6e 65 64 20 .** is obtained
2b290 66 72 6f 6d 20 5b 73 71 6c 69 74 65 33 5f 6d 61 from [sqlite3_ma
2b2a0 6c 6c 6f 63 28 29 5d 20 61 6e 64 20 6d 75 73 74 lloc()] and must
2b2b0 20 62 65 20 66 72 65 65 20 62 79 20 74 68 65 20 be free by the
2b2c0 61 70 70 6c 69 63 61 74 69 6f 6e 0a 2a 2a 20 62 application.** b
2b2d0 79 20 70 61 73 73 69 6e 67 20 69 74 20 74 6f 20 y passing it to
2b2e0 5b 73 71 6c 69 74 65 33 5f 66 72 65 65 28 29 5d [sqlite3_free()]
2b2f0 2e 0a 2a 2f 0a 63 6f 6e 73 74 20 63 68 61 72 20 ..*/.const char
2b300 2a 73 71 6c 69 74 65 33 5f 73 71 6c 28 73 71 6c *sqlite3_sql(sql
2b310 69 74 65 33 5f 73 74 6d 74 20 2a 70 53 74 6d 74 ite3_stmt *pStmt
2b320 29 3b 0a 63 68 61 72 20 2a 73 71 6c 69 74 65 33 );.char *sqlite3
2b330 5f 65 78 70 61 6e 64 65 64 5f 73 71 6c 28 73 71 _expanded_sql(sq
2b340 6c 69 74 65 33 5f 73 74 6d 74 20 2a 70 53 74 6d lite3_stmt *pStm
2b350 74 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 t);../*.** CAPI3
2b360 52 45 46 3a 20 44 65 74 65 72 6d 69 6e 65 20 49 REF: Determine I
2b370 66 20 41 6e 20 53 51 4c 20 53 74 61 74 65 6d 65 f An SQL Stateme
2b380 6e 74 20 57 72 69 74 65 73 20 54 68 65 20 44 61 nt Writes The Da
2b390 74 61 62 61 73 65 0a 2a 2a 20 4d 45 54 48 4f 44 tabase.** METHOD
2b3a0 3a 20 73 71 6c 69 74 65 33 5f 73 74 6d 74 0a 2a : sqlite3_stmt.*
2b3b0 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 6c 69 74 65 *.** ^The sqlite
2b3c0 33 5f 73 74 6d 74 5f 72 65 61 64 6f 6e 6c 79 28 3_stmt_readonly(
2b3d0 58 29 20 69 6e 74 65 72 66 61 63 65 20 72 65 74 X) interface ret
2b3e0 75 72 6e 73 20 74 72 75 65 20 28 6e 6f 6e 2d 7a urns true (non-z
2b3f0 65 72 6f 29 20 69 66 0a 2a 2a 20 61 6e 64 20 6f ero) if.** and o
2b400 6e 6c 79 20 69 66 20 74 68 65 20 5b 70 72 65 70 nly if the [prep
2b410 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 5d 20 ared statement]
2b420 58 20 6d 61 6b 65 73 20 6e 6f 20 64 69 72 65 63 X makes no direc
2b430 74 20 63 68 61 6e 67 65 73 20 74 6f 0a 2a 2a 20 t changes to.**
2b440 74 68 65 20 63 6f 6e 74 65 6e 74 20 6f 66 20 74 the content of t
2b450 68 65 20 64 61 74 61 62 61 73 65 20 66 69 6c 65 he database file
2b460 2e 0a 2a 2a 0a 2a 2a 20 4e 6f 74 65 20 74 68 61 ..**.** Note tha
2b470 74 20 5b 61 70 70 6c 69 63 61 74 69 6f 6e 2d 64 t [application-d
2b480 65 66 69 6e 65 64 20 53 51 4c 20 66 75 6e 63 74 efined SQL funct
2b490 69 6f 6e 73 5d 20 6f 72 0a 2a 2a 20 5b 76 69 72 ions] or.** [vir
2b4a0 74 75 61 6c 20 74 61 62 6c 65 73 5d 20 6d 69 67 tual tables] mig
2b4b0 68 74 20 63 68 61 6e 67 65 20 74 68 65 20 64 61 ht change the da
2b4c0 74 61 62 61 73 65 20 69 6e 64 69 72 65 63 74 6c tabase indirectl
2b4d0 79 20 61 73 20 61 20 73 69 64 65 20 65 66 66 65 y as a side effe
2b4e0 63 74 2e 20 20 0a 2a 2a 20 5e 28 46 6f 72 20 65 ct. .** ^(For e
2b4f0 78 61 6d 70 6c 65 2c 20 69 66 20 61 6e 20 61 70 xample, if an ap
2b500 70 6c 69 63 61 74 69 6f 6e 20 64 65 66 69 6e 65 plication define
2b510 73 20 61 20 66 75 6e 63 74 69 6f 6e 20 22 65 76 s a function "ev
2b520 61 6c 28 29 22 20 74 68 61 74 20 0a 2a 2a 20 63 al()" that .** c
2b530 61 6c 6c 73 20 5b 73 71 6c 69 74 65 33 5f 65 78 alls [sqlite3_ex
2b540 65 63 28 29 5d 2c 20 74 68 65 6e 20 74 68 65 20 ec()], then the
2b550 66 6f 6c 6c 6f 77 69 6e 67 20 53 51 4c 20 73 74 following SQL st
2b560 61 74 65 6d 65 6e 74 20 77 6f 75 6c 64 0a 2a 2a atement would.**
2b570 20 63 68 61 6e 67 65 20 74 68 65 20 64 61 74 61 change the data
2b580 62 61 73 65 20 66 69 6c 65 20 74 68 72 6f 75 67 base file throug
2b590 68 20 73 69 64 65 2d 65 66 66 65 63 74 73 3a 0a h side-effects:.
2b5a0 2a 2a 0a 2a 2a 20 3c 62 6c 6f 63 6b 71 75 6f 74 **.** <blockquot
2b5b0 65 3e 3c 70 72 65 3e 0a 2a 2a 20 20 20 20 53 45 e><pre>.** SE
2b5c0 4c 45 43 54 20 65 76 61 6c 28 27 44 45 4c 45 54 LECT eval('DELET
2b5d0 45 20 46 52 4f 4d 20 74 31 27 29 20 46 52 4f 4d E FROM t1') FROM
2b5e0 20 74 32 3b 0a 2a 2a 20 3c 2f 70 72 65 3e 3c 2f t2;.** </pre></
2b5f0 62 6c 6f 63 6b 71 75 6f 74 65 3e 0a 2a 2a 0a 2a blockquote>.**.*
2b600 2a 20 42 75 74 20 62 65 63 61 75 73 65 20 74 68 * But because th
2b610 65 20 5b 53 45 4c 45 43 54 5d 20 73 74 61 74 65 e [SELECT] state
2b620 6d 65 6e 74 20 64 6f 65 73 20 6e 6f 74 20 63 68 ment does not ch
2b630 61 6e 67 65 20 74 68 65 20 64 61 74 61 62 61 73 ange the databas
2b640 65 20 66 69 6c 65 0a 2a 2a 20 64 69 72 65 63 74 e file.** direct
2b650 6c 79 2c 20 73 71 6c 69 74 65 33 5f 73 74 6d 74 ly, sqlite3_stmt
2b660 5f 72 65 61 64 6f 6e 6c 79 28 29 20 77 6f 75 6c _readonly() woul
2b670 64 20 73 74 69 6c 6c 20 72 65 74 75 72 6e 20 74 d still return t
2b680 72 75 65 2e 29 5e 0a 2a 2a 0a 2a 2a 20 5e 54 72 rue.)^.**.** ^Tr
2b690 61 6e 73 61 63 74 69 6f 6e 20 63 6f 6e 74 72 6f ansaction contro
2b6a0 6c 20 73 74 61 74 65 6d 65 6e 74 73 20 73 75 63 l statements suc
2b6b0 68 20 61 73 20 5b 42 45 47 49 4e 5d 2c 20 5b 43 h as [BEGIN], [C
2b6c0 4f 4d 4d 49 54 5d 2c 20 5b 52 4f 4c 4c 42 41 43 OMMIT], [ROLLBAC
2b6d0 4b 5d 2c 0a 2a 2a 20 5b 53 41 56 45 50 4f 49 4e K],.** [SAVEPOIN
2b6e0 54 5d 2c 20 61 6e 64 20 5b 52 45 4c 45 41 53 45 T], and [RELEASE
2b6f0 5d 20 63 61 75 73 65 20 73 71 6c 69 74 65 33 5f ] cause sqlite3_
2b700 73 74 6d 74 5f 72 65 61 64 6f 6e 6c 79 28 29 20 stmt_readonly()
2b710 74 6f 20 72 65 74 75 72 6e 20 74 72 75 65 2c 0a to return true,.
2b720 2a 2a 20 73 69 6e 63 65 20 74 68 65 20 73 74 61 ** since the sta
2b730 74 65 6d 65 6e 74 73 20 74 68 65 6d 73 65 6c 76 tements themselv
2b740 65 73 20 64 6f 20 6e 6f 74 20 61 63 74 75 61 6c es do not actual
2b750 6c 79 20 6d 6f 64 69 66 79 20 74 68 65 20 64 61 ly modify the da
2b760 74 61 62 61 73 65 20 62 75 74 0a 2a 2a 20 72 61 tabase but.** ra
2b770 74 68 65 72 20 74 68 65 79 20 63 6f 6e 74 72 6f ther they contro
2b780 6c 20 74 68 65 20 74 69 6d 69 6e 67 20 6f 66 20 l the timing of
2b790 77 68 65 6e 20 6f 74 68 65 72 20 73 74 61 74 65 when other state
2b7a0 6d 65 6e 74 73 20 6d 6f 64 69 66 79 20 74 68 65 ments modify the
2b7b0 20 0a 2a 2a 20 64 61 74 61 62 61 73 65 2e 20 20 .** database.
2b7c0 5e 54 68 65 20 5b 41 54 54 41 43 48 5d 20 61 6e ^The [ATTACH] an
2b7d0 64 20 5b 44 45 54 41 43 48 5d 20 73 74 61 74 65 d [DETACH] state
2b7e0 6d 65 6e 74 73 20 61 6c 73 6f 20 63 61 75 73 65 ments also cause
2b7f0 0a 2a 2a 20 73 71 6c 69 74 65 33 5f 73 74 6d 74 .** sqlite3_stmt
2b800 5f 72 65 61 64 6f 6e 6c 79 28 29 20 74 6f 20 72 _readonly() to r
2b810 65 74 75 72 6e 20 74 72 75 65 20 73 69 6e 63 65 eturn true since
2b820 2c 20 77 68 69 6c 65 20 74 68 6f 73 65 20 73 74 , while those st
2b830 61 74 65 6d 65 6e 74 73 0a 2a 2a 20 63 68 61 6e atements.** chan
2b840 67 65 20 74 68 65 20 63 6f 6e 66 69 67 75 72 61 ge the configura
2b850 74 69 6f 6e 20 6f 66 20 61 20 64 61 74 61 62 61 tion of a databa
2b860 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 2c 20 74 se connection, t
2b870 68 65 79 20 64 6f 20 6e 6f 74 20 6d 61 6b 65 20 hey do not make
2b880 0a 2a 2a 20 63 68 61 6e 67 65 73 20 74 6f 20 74 .** changes to t
2b890 68 65 20 63 6f 6e 74 65 6e 74 20 6f 66 20 74 68 he content of th
2b8a0 65 20 64 61 74 61 62 61 73 65 20 66 69 6c 65 73 e database files
2b8b0 20 6f 6e 20 64 69 73 6b 2e 0a 2a 2a 20 5e 54 68 on disk..** ^Th
2b8c0 65 20 73 71 6c 69 74 65 33 5f 73 74 6d 74 5f 72 e sqlite3_stmt_r
2b8d0 65 61 64 6f 6e 6c 79 28 29 20 69 6e 74 65 72 66 eadonly() interf
2b8e0 61 63 65 20 72 65 74 75 72 6e 73 20 74 72 75 65 ace returns true
2b8f0 20 66 6f 72 20 5b 42 45 47 49 4e 5d 20 73 69 6e for [BEGIN] sin
2b900 63 65 0a 2a 2a 20 5b 42 45 47 49 4e 5d 20 6d 65 ce.** [BEGIN] me
2b910 72 65 6c 79 20 73 65 74 73 20 69 6e 74 65 72 6e rely sets intern
2b920 61 6c 20 66 6c 61 67 73 2c 20 62 75 74 20 74 68 al flags, but th
2b930 65 20 5b 42 45 47 49 4e 7c 42 45 47 49 4e 20 49 e [BEGIN|BEGIN I
2b940 4d 4d 45 44 49 41 54 45 5d 20 61 6e 64 0a 2a 2a MMEDIATE] and.**
2b950 20 5b 42 45 47 49 4e 7c 42 45 47 49 4e 20 45 58 [BEGIN|BEGIN EX
2b960 43 4c 55 53 49 56 45 5d 20 63 6f 6d 6d 61 6e 64 CLUSIVE] command
2b970 73 20 64 6f 20 74 6f 75 63 68 20 74 68 65 20 64 s do touch the d
2b980 61 74 61 62 61 73 65 20 61 6e 64 20 73 6f 0a 2a atabase and so.*
2b990 2a 20 73 71 6c 69 74 65 33 5f 73 74 6d 74 5f 72 * sqlite3_stmt_r
2b9a0 65 61 64 6f 6e 6c 79 28 29 20 72 65 74 75 72 6e eadonly() return
2b9b0 73 20 66 61 6c 73 65 20 66 6f 72 20 74 68 6f 73 s false for thos
2b9c0 65 20 63 6f 6d 6d 61 6e 64 73 2e 0a 2a 2f 0a 69 e commands..*/.i
2b9d0 6e 74 20 73 71 6c 69 74 65 33 5f 73 74 6d 74 5f nt sqlite3_stmt_
2b9e0 72 65 61 64 6f 6e 6c 79 28 73 71 6c 69 74 65 33 readonly(sqlite3
2b9f0 5f 73 74 6d 74 20 2a 70 53 74 6d 74 29 3b 0a 0a _stmt *pStmt);..
2ba00 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 /*.** CAPI3REF:
2ba10 44 65 74 65 72 6d 69 6e 65 20 49 66 20 41 20 50 Determine If A P
2ba20 72 65 70 61 72 65 64 20 53 74 61 74 65 6d 65 6e repared Statemen
2ba30 74 20 48 61 73 20 42 65 65 6e 20 52 65 73 65 74 t Has Been Reset
2ba40 0a 2a 2a 20 4d 45 54 48 4f 44 3a 20 73 71 6c 69 .** METHOD: sqli
2ba50 74 65 33 5f 73 74 6d 74 0a 2a 2a 0a 2a 2a 20 5e te3_stmt.**.** ^
2ba60 54 68 65 20 73 71 6c 69 74 65 33 5f 73 74 6d 74 The sqlite3_stmt
2ba70 5f 62 75 73 79 28 53 29 20 69 6e 74 65 72 66 61 _busy(S) interfa
2ba80 63 65 20 72 65 74 75 72 6e 73 20 74 72 75 65 20 ce returns true
2ba90 28 6e 6f 6e 2d 7a 65 72 6f 29 20 69 66 20 74 68 (non-zero) if th
2baa0 65 0a 2a 2a 20 5b 70 72 65 70 61 72 65 64 20 73 e.** [prepared s
2bab0 74 61 74 65 6d 65 6e 74 5d 20 53 20 68 61 73 20 tatement] S has
2bac0 62 65 65 6e 20 73 74 65 70 70 65 64 20 61 74 20 been stepped at
2bad0 6c 65 61 73 74 20 6f 6e 63 65 20 75 73 69 6e 67 least once using
2bae0 20 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 73 74 .** [sqlite3_st
2baf0 65 70 28 53 29 5d 20 62 75 74 20 68 61 73 20 6e ep(S)] but has n
2bb00 65 69 74 68 65 72 20 72 75 6e 20 74 6f 20 63 6f either run to co
2bb10 6d 70 6c 65 74 69 6f 6e 20 28 72 65 74 75 72 6e mpletion (return
2bb20 65 64 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f 44 4f ed.** [SQLITE_DO
2bb30 4e 45 5d 20 66 72 6f 6d 20 5b 73 71 6c 69 74 65 NE] from [sqlite
2bb40 33 5f 73 74 65 70 28 53 29 5d 29 20 6e 6f 72 0a 3_step(S)]) nor.
2bb50 2a 2a 20 62 65 65 6e 20 72 65 73 65 74 20 75 73 ** been reset us
2bb60 69 6e 67 20 5b 73 71 6c 69 74 65 33 5f 72 65 73 ing [sqlite3_res
2bb70 65 74 28 53 29 5d 2e 20 20 5e 54 68 65 20 73 71 et(S)]. ^The sq
2bb80 6c 69 74 65 33 5f 73 74 6d 74 5f 62 75 73 79 28 lite3_stmt_busy(
2bb90 53 29 0a 2a 2a 20 69 6e 74 65 72 66 61 63 65 20 S).** interface
2bba0 72 65 74 75 72 6e 73 20 66 61 6c 73 65 20 69 66 returns false if
2bbb0 20 53 20 69 73 20 61 20 4e 55 4c 4c 20 70 6f 69 S is a NULL poi
2bbc0 6e 74 65 72 2e 20 20 49 66 20 53 20 69 73 20 6e nter. If S is n
2bbd0 6f 74 20 61 20 0a 2a 2a 20 4e 55 4c 4c 20 70 6f ot a .** NULL po
2bbe0 69 6e 74 65 72 20 61 6e 64 20 69 73 20 6e 6f 74 inter and is not
2bbf0 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 61 20 a pointer to a
2bc00 76 61 6c 69 64 20 5b 70 72 65 70 61 72 65 64 20 valid [prepared
2bc10 73 74 61 74 65 6d 65 6e 74 5d 0a 2a 2a 20 6f 62 statement].** ob
2bc20 6a 65 63 74 2c 20 74 68 65 6e 20 74 68 65 20 62 ject, then the b
2bc30 65 68 61 76 69 6f 72 20 69 73 20 75 6e 64 65 66 ehavior is undef
2bc40 69 6e 65 64 20 61 6e 64 20 70 72 6f 62 61 62 6c ined and probabl
2bc50 79 20 75 6e 64 65 73 69 72 61 62 6c 65 2e 0a 2a y undesirable..*
2bc60 2a 0a 2a 2a 20 54 68 69 73 20 69 6e 74 65 72 66 *.** This interf
2bc70 61 63 65 20 63 61 6e 20 62 65 20 75 73 65 64 20 ace can be used
2bc80 69 6e 20 63 6f 6d 62 69 6e 61 74 69 6f 6e 20 5b in combination [
2bc90 73 71 6c 69 74 65 33 5f 6e 65 78 74 5f 73 74 6d sqlite3_next_stm
2bca0 74 28 29 5d 0a 2a 2a 20 74 6f 20 6c 6f 63 61 74 t()].** to locat
2bcb0 65 20 61 6c 6c 20 70 72 65 70 61 72 65 64 20 73 e all prepared s
2bcc0 74 61 74 65 6d 65 6e 74 73 20 61 73 73 6f 63 69 tatements associ
2bcd0 61 74 65 64 20 77 69 74 68 20 61 20 64 61 74 61 ated with a data
2bce0 62 61 73 65 20 0a 2a 2a 20 63 6f 6e 6e 65 63 74 base .** connect
2bcf0 69 6f 6e 20 74 68 61 74 20 61 72 65 20 69 6e 20 ion that are in
2bd00 6e 65 65 64 20 6f 66 20 62 65 69 6e 67 20 72 65 need of being re
2bd10 73 65 74 2e 20 20 54 68 69 73 20 63 61 6e 20 62 set. This can b
2bd20 65 20 75 73 65 64 2c 0a 2a 2a 20 66 6f 72 20 65 e used,.** for e
2bd30 78 61 6d 70 6c 65 2c 20 69 6e 20 64 69 61 67 6e xample, in diagn
2bd40 6f 73 74 69 63 20 72 6f 75 74 69 6e 65 73 20 74 ostic routines t
2bd50 6f 20 73 65 61 72 63 68 20 66 6f 72 20 70 72 65 o search for pre
2bd60 70 61 72 65 64 20 0a 2a 2a 20 73 74 61 74 65 6d pared .** statem
2bd70 65 6e 74 73 20 74 68 61 74 20 61 72 65 20 68 6f ents that are ho
2bd80 6c 64 69 6e 67 20 61 20 74 72 61 6e 73 61 63 74 lding a transact
2bd90 69 6f 6e 20 6f 70 65 6e 2e 0a 2a 2f 0a 69 6e 74 ion open..*/.int
2bda0 20 73 71 6c 69 74 65 33 5f 73 74 6d 74 5f 62 75 sqlite3_stmt_bu
2bdb0 73 79 28 73 71 6c 69 74 65 33 5f 73 74 6d 74 2a sy(sqlite3_stmt*
2bdc0 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 );../*.** CAPI3R
2bdd0 45 46 3a 20 44 79 6e 61 6d 69 63 61 6c 6c 79 20 EF: Dynamically
2bde0 54 79 70 65 64 20 56 61 6c 75 65 20 4f 62 6a 65 Typed Value Obje
2bdf0 63 74 0a 2a 2a 20 4b 45 59 57 4f 52 44 53 3a 20 ct.** KEYWORDS:
2be00 7b 70 72 6f 74 65 63 74 65 64 20 73 71 6c 69 74 {protected sqlit
2be10 65 33 5f 76 61 6c 75 65 7d 20 7b 75 6e 70 72 6f e3_value} {unpro
2be20 74 65 63 74 65 64 20 73 71 6c 69 74 65 33 5f 76 tected sqlite3_v
2be30 61 6c 75 65 7d 0a 2a 2a 0a 2a 2a 20 53 51 4c 69 alue}.**.** SQLi
2be40 74 65 20 75 73 65 73 20 74 68 65 20 73 71 6c 69 te uses the sqli
2be50 74 65 33 5f 76 61 6c 75 65 20 6f 62 6a 65 63 74 te3_value object
2be60 20 74 6f 20 72 65 70 72 65 73 65 6e 74 20 61 6c to represent al
2be70 6c 20 76 61 6c 75 65 73 0a 2a 2a 20 74 68 61 74 l values.** that
2be80 20 63 61 6e 20 62 65 20 73 74 6f 72 65 64 20 69 can be stored i
2be90 6e 20 61 20 64 61 74 61 62 61 73 65 20 74 61 62 n a database tab
2bea0 6c 65 2e 20 53 51 4c 69 74 65 20 75 73 65 73 20 le. SQLite uses
2beb0 64 79 6e 61 6d 69 63 20 74 79 70 69 6e 67 0a 2a dynamic typing.*
2bec0 2a 20 66 6f 72 20 74 68 65 20 76 61 6c 75 65 73 * for the values
2bed0 20 69 74 20 73 74 6f 72 65 73 2e 20 20 5e 56 61 it stores. ^Va
2bee0 6c 75 65 73 20 73 74 6f 72 65 64 20 69 6e 20 73 lues stored in s
2bef0 71 6c 69 74 65 33 5f 76 61 6c 75 65 20 6f 62 6a qlite3_value obj
2bf00 65 63 74 73 0a 2a 2a 20 63 61 6e 20 62 65 20 69 ects.** can be i
2bf10 6e 74 65 67 65 72 73 2c 20 66 6c 6f 61 74 69 6e ntegers, floatin
2bf20 67 20 70 6f 69 6e 74 20 76 61 6c 75 65 73 2c 20 g point values,
2bf30 73 74 72 69 6e 67 73 2c 20 42 4c 4f 42 73 2c 20 strings, BLOBs,
2bf40 6f 72 20 4e 55 4c 4c 2e 0a 2a 2a 0a 2a 2a 20 41 or NULL..**.** A
2bf50 6e 20 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 20 n sqlite3_value
2bf60 6f 62 6a 65 63 74 20 6d 61 79 20 62 65 20 65 69 object may be ei
2bf70 74 68 65 72 20 22 70 72 6f 74 65 63 74 65 64 22 ther "protected"
2bf80 20 6f 72 20 22 75 6e 70 72 6f 74 65 63 74 65 64 or "unprotected
2bf90 22 2e 0a 2a 2a 20 53 6f 6d 65 20 69 6e 74 65 72 "..** Some inter
2bfa0 66 61 63 65 73 20 72 65 71 75 69 72 65 20 61 20 faces require a
2bfb0 70 72 6f 74 65 63 74 65 64 20 73 71 6c 69 74 65 protected sqlite
2bfc0 33 5f 76 61 6c 75 65 2e 20 20 4f 74 68 65 72 20 3_value. Other
2bfd0 69 6e 74 65 72 66 61 63 65 73 0a 2a 2a 20 77 69 interfaces.** wi
2bfe0 6c 6c 20 61 63 63 65 70 74 20 65 69 74 68 65 72 ll accept either
2bff0 20 61 20 70 72 6f 74 65 63 74 65 64 20 6f 72 20 a protected or
2c000 61 6e 20 75 6e 70 72 6f 74 65 63 74 65 64 20 73 an unprotected s
2c010 71 6c 69 74 65 33 5f 76 61 6c 75 65 2e 0a 2a 2a qlite3_value..**
2c020 20 45 76 65 72 79 20 69 6e 74 65 72 66 61 63 65 Every interface
2c030 20 74 68 61 74 20 61 63 63 65 70 74 73 20 73 71 that accepts sq
2c040 6c 69 74 65 33 5f 76 61 6c 75 65 20 61 72 67 75 lite3_value argu
2c050 6d 65 6e 74 73 20 73 70 65 63 69 66 69 65 73 0a ments specifies.
2c060 2a 2a 20 77 68 65 74 68 65 72 20 6f 72 20 6e 6f ** whether or no
2c070 74 20 69 74 20 72 65 71 75 69 72 65 73 20 61 20 t it requires a
2c080 70 72 6f 74 65 63 74 65 64 20 73 71 6c 69 74 65 protected sqlite
2c090 33 5f 76 61 6c 75 65 2e 20 20 54 68 65 0a 2a 2a 3_value. The.**
2c0a0 20 5b 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f [sqlite3_value_
2c0b0 64 75 70 28 29 5d 20 69 6e 74 65 72 66 61 63 65 dup()] interface
2c0c0 20 63 61 6e 20 62 65 20 75 73 65 64 20 74 6f 20 can be used to
2c0d0 63 6f 6e 73 74 72 75 63 74 20 61 20 6e 65 77 20 construct a new
2c0e0 0a 2a 2a 20 70 72 6f 74 65 63 74 65 64 20 73 71 .** protected sq
2c0f0 6c 69 74 65 33 5f 76 61 6c 75 65 20 66 72 6f 6d lite3_value from
2c100 20 61 6e 20 75 6e 70 72 6f 74 65 63 74 65 64 20 an unprotected
2c110 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 2e 0a 2a sqlite3_value..*
2c120 2a 0a 2a 2a 20 54 68 65 20 74 65 72 6d 73 20 22 *.** The terms "
2c130 70 72 6f 74 65 63 74 65 64 22 20 61 6e 64 20 22 protected" and "
2c140 75 6e 70 72 6f 74 65 63 74 65 64 22 20 72 65 66 unprotected" ref
2c150 65 72 20 74 6f 20 77 68 65 74 68 65 72 20 6f 72 er to whether or
2c160 20 6e 6f 74 0a 2a 2a 20 61 20 6d 75 74 65 78 20 not.** a mutex
2c170 69 73 20 68 65 6c 64 2e 20 20 41 6e 20 69 6e 74 is held. An int
2c180 65 72 6e 61 6c 20 6d 75 74 65 78 20 69 73 20 68 ernal mutex is h
2c190 65 6c 64 20 66 6f 72 20 61 20 70 72 6f 74 65 63 eld for a protec
2c1a0 74 65 64 0a 2a 2a 20 73 71 6c 69 74 65 33 5f 76 ted.** sqlite3_v
2c1b0 61 6c 75 65 20 6f 62 6a 65 63 74 20 62 75 74 20 alue object but
2c1c0 6e 6f 20 6d 75 74 65 78 20 69 73 20 68 65 6c 64 no mutex is held
2c1d0 20 66 6f 72 20 61 6e 20 75 6e 70 72 6f 74 65 63 for an unprotec
2c1e0 74 65 64 0a 2a 2a 20 73 71 6c 69 74 65 33 5f 76 ted.** sqlite3_v
2c1f0 61 6c 75 65 20 6f 62 6a 65 63 74 2e 20 20 49 66 alue object. If
2c200 20 53 51 4c 69 74 65 20 69 73 20 63 6f 6d 70 69 SQLite is compi
2c210 6c 65 64 20 74 6f 20 62 65 20 73 69 6e 67 6c 65 led to be single
2c220 2d 74 68 72 65 61 64 65 64 0a 2a 2a 20 28 77 69 -threaded.** (wi
2c230 74 68 20 5b 53 51 4c 49 54 45 5f 54 48 52 45 41 th [SQLITE_THREA
2c240 44 53 41 46 45 3d 30 5d 20 61 6e 64 20 77 69 74 DSAFE=0] and wit
2c250 68 20 5b 73 71 6c 69 74 65 33 5f 74 68 72 65 61 h [sqlite3_threa
2c260 64 73 61 66 65 28 29 5d 20 72 65 74 75 72 6e 69 dsafe()] returni
2c270 6e 67 20 30 29 0a 2a 2a 20 6f 72 20 69 66 20 53 ng 0).** or if S
2c280 51 4c 69 74 65 20 69 73 20 72 75 6e 20 69 6e 20 QLite is run in
2c290 6f 6e 65 20 6f 66 20 72 65 64 75 63 65 64 20 6d one of reduced m
2c2a0 75 74 65 78 20 6d 6f 64 65 73 20 0a 2a 2a 20 5b utex modes .** [
2c2b0 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 53 49 SQLITE_CONFIG_SI
2c2c0 4e 47 4c 45 54 48 52 45 41 44 5d 20 6f 72 20 5b NGLETHREAD] or [
2c2d0 53 51 4c 49 54 45 5f 43 4f 4e 46 49 47 5f 4d 55 SQLITE_CONFIG_MU
2c2e0 4c 54 49 54 48 52 45 41 44 5d 0a 2a 2a 20 74 68 LTITHREAD].** th
2c2f0 65 6e 20 74 68 65 72 65 20 69 73 20 6e 6f 20 64 en there is no d
2c300 69 73 74 69 6e 63 74 69 6f 6e 20 62 65 74 77 65 istinction betwe
2c310 65 6e 20 70 72 6f 74 65 63 74 65 64 20 61 6e 64 en protected and
2c320 20 75 6e 70 72 6f 74 65 63 74 65 64 0a 2a 2a 20 unprotected.**
2c330 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 20 6f 62 sqlite3_value ob
2c340 6a 65 63 74 73 20 61 6e 64 20 74 68 65 79 20 63 jects and they c
2c350 61 6e 20 62 65 20 75 73 65 64 20 69 6e 74 65 72 an be used inter
2c360 63 68 61 6e 67 65 61 62 6c 79 2e 20 20 48 6f 77 changeably. How
2c370 65 76 65 72 2c 0a 2a 2a 20 66 6f 72 20 6d 61 78 ever,.** for max
2c380 69 6d 75 6d 20 63 6f 64 65 20 70 6f 72 74 61 62 imum code portab
2c390 69 6c 69 74 79 20 69 74 20 69 73 20 72 65 63 6f ility it is reco
2c3a0 6d 6d 65 6e 64 65 64 20 74 68 61 74 20 61 70 70 mmended that app
2c3b0 6c 69 63 61 74 69 6f 6e 73 0a 2a 2a 20 73 74 69 lications.** sti
2c3c0 6c 6c 20 6d 61 6b 65 20 74 68 65 20 64 69 73 74 ll make the dist
2c3d0 69 6e 63 74 69 6f 6e 20 62 65 74 77 65 65 6e 20 inction between
2c3e0 70 72 6f 74 65 63 74 65 64 20 61 6e 64 20 75 6e protected and un
2c3f0 70 72 6f 74 65 63 74 65 64 0a 2a 2a 20 73 71 6c protected.** sql
2c400 69 74 65 33 5f 76 61 6c 75 65 20 6f 62 6a 65 63 ite3_value objec
2c410 74 73 20 65 76 65 6e 20 77 68 65 6e 20 6e 6f 74 ts even when not
2c420 20 73 74 72 69 63 74 6c 79 20 72 65 71 75 69 72 strictly requir
2c430 65 64 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 ed..**.** ^The s
2c440 71 6c 69 74 65 33 5f 76 61 6c 75 65 20 6f 62 6a qlite3_value obj
2c450 65 63 74 73 20 74 68 61 74 20 61 72 65 20 70 61 ects that are pa
2c460 73 73 65 64 20 61 73 20 70 61 72 61 6d 65 74 65 ssed as paramete
2c470 72 73 20 69 6e 74 6f 20 74 68 65 0a 2a 2a 20 69 rs into the.** i
2c480 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 6f 66 mplementation of
2c490 20 5b 61 70 70 6c 69 63 61 74 69 6f 6e 2d 64 65 [application-de
2c4a0 66 69 6e 65 64 20 53 51 4c 20 66 75 6e 63 74 69 fined SQL functi
2c4b0 6f 6e 73 5d 20 61 72 65 20 70 72 6f 74 65 63 74 ons] are protect
2c4c0 65 64 2e 0a 2a 2a 20 5e 54 68 65 20 73 71 6c 69 ed..** ^The sqli
2c4d0 74 65 33 5f 76 61 6c 75 65 20 6f 62 6a 65 63 74 te3_value object
2c4e0 20 72 65 74 75 72 6e 65 64 20 62 79 0a 2a 2a 20 returned by.**
2c4f0 5b 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f [sqlite3_column_
2c500 76 61 6c 75 65 28 29 5d 20 69 73 20 75 6e 70 72 value()] is unpr
2c510 6f 74 65 63 74 65 64 2e 0a 2a 2a 20 55 6e 70 72 otected..** Unpr
2c520 6f 74 65 63 74 65 64 20 73 71 6c 69 74 65 33 5f otected sqlite3_
2c530 76 61 6c 75 65 20 6f 62 6a 65 63 74 73 20 6d 61 value objects ma
2c540 79 20 6f 6e 6c 79 20 62 65 20 75 73 65 64 20 77 y only be used w
2c550 69 74 68 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f ith.** [sqlite3_
2c560 72 65 73 75 6c 74 5f 76 61 6c 75 65 28 29 5d 20 result_value()]
2c570 61 6e 64 20 5b 73 71 6c 69 74 65 33 5f 62 69 6e and [sqlite3_bin
2c580 64 5f 76 61 6c 75 65 28 29 5d 2e 0a 2a 2a 20 54 d_value()]..** T
2c590 68 65 20 5b 73 71 6c 69 74 65 33 5f 76 61 6c 75 he [sqlite3_valu
2c5a0 65 5f 62 6c 6f 62 20 7c 20 73 71 6c 69 74 65 33 e_blob | sqlite3
2c5b0 5f 76 61 6c 75 65 5f 74 79 70 65 28 29 5d 20 66 _value_type()] f
2c5c0 61 6d 69 6c 79 20 6f 66 0a 2a 2a 20 69 6e 74 65 amily of.** inte
2c5d0 72 66 61 63 65 73 20 72 65 71 75 69 72 65 20 70 rfaces require p
2c5e0 72 6f 74 65 63 74 65 64 20 73 71 6c 69 74 65 33 rotected sqlite3
2c5f0 5f 76 61 6c 75 65 20 6f 62 6a 65 63 74 73 2e 0a _value objects..
2c600 2a 2f 0a 74 79 70 65 64 65 66 20 73 74 72 75 63 */.typedef struc
2c610 74 20 4d 65 6d 20 73 71 6c 69 74 65 33 5f 76 61 t Mem sqlite3_va
2c620 6c 75 65 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 lue;../*.** CAPI
2c630 33 52 45 46 3a 20 53 51 4c 20 46 75 6e 63 74 69 3REF: SQL Functi
2c640 6f 6e 20 43 6f 6e 74 65 78 74 20 4f 62 6a 65 63 on Context Objec
2c650 74 0a 2a 2a 0a 2a 2a 20 54 68 65 20 63 6f 6e 74 t.**.** The cont
2c660 65 78 74 20 69 6e 20 77 68 69 63 68 20 61 6e 20 ext in which an
2c670 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 65 78 65 SQL function exe
2c680 63 75 74 65 73 20 69 73 20 73 74 6f 72 65 64 20 cutes is stored
2c690 69 6e 20 61 6e 0a 2a 2a 20 73 71 6c 69 74 65 33 in an.** sqlite3
2c6a0 5f 63 6f 6e 74 65 78 74 20 6f 62 6a 65 63 74 2e _context object.
2c6b0 20 20 5e 41 20 70 6f 69 6e 74 65 72 20 74 6f 20 ^A pointer to
2c6c0 61 6e 20 73 71 6c 69 74 65 33 5f 63 6f 6e 74 65 an sqlite3_conte
2c6d0 78 74 20 6f 62 6a 65 63 74 0a 2a 2a 20 69 73 20 xt object.** is
2c6e0 61 6c 77 61 79 73 20 66 69 72 73 74 20 70 61 72 always first par
2c6f0 61 6d 65 74 65 72 20 74 6f 20 5b 61 70 70 6c 69 ameter to [appli
2c700 63 61 74 69 6f 6e 2d 64 65 66 69 6e 65 64 20 53 cation-defined S
2c710 51 4c 20 66 75 6e 63 74 69 6f 6e 73 5d 2e 0a 2a QL functions]..*
2c720 2a 20 54 68 65 20 61 70 70 6c 69 63 61 74 69 6f * The applicatio
2c730 6e 2d 64 65 66 69 6e 65 64 20 53 51 4c 20 66 75 n-defined SQL fu
2c740 6e 63 74 69 6f 6e 20 69 6d 70 6c 65 6d 65 6e 74 nction implement
2c750 61 74 69 6f 6e 20 77 69 6c 6c 20 70 61 73 73 20 ation will pass
2c760 74 68 69 73 0a 2a 2a 20 70 6f 69 6e 74 65 72 20 this.** pointer
2c770 74 68 72 6f 75 67 68 20 69 6e 74 6f 20 63 61 6c through into cal
2c780 6c 73 20 74 6f 20 5b 73 71 6c 69 74 65 33 5f 72 ls to [sqlite3_r
2c790 65 73 75 6c 74 5f 69 6e 74 20 7c 20 73 71 6c 69 esult_int | sqli
2c7a0 74 65 33 5f 72 65 73 75 6c 74 28 29 5d 2c 0a 2a te3_result()],.*
2c7b0 2a 20 5b 73 71 6c 69 74 65 33 5f 61 67 67 72 65 * [sqlite3_aggre
2c7c0 67 61 74 65 5f 63 6f 6e 74 65 78 74 28 29 5d 2c gate_context()],
2c7d0 20 5b 73 71 6c 69 74 65 33 5f 75 73 65 72 5f 64 [sqlite3_user_d
2c7e0 61 74 61 28 29 5d 2c 0a 2a 2a 20 5b 73 71 6c 69 ata()],.** [sqli
2c7f0 74 65 33 5f 63 6f 6e 74 65 78 74 5f 64 62 5f 68 te3_context_db_h
2c800 61 6e 64 6c 65 28 29 5d 2c 20 5b 73 71 6c 69 74 andle()], [sqlit
2c810 65 33 5f 67 65 74 5f 61 75 78 64 61 74 61 28 29 e3_get_auxdata()
2c820 5d 2c 0a 2a 2a 20 61 6e 64 2f 6f 72 20 5b 73 71 ],.** and/or [sq
2c830 6c 69 74 65 33 5f 73 65 74 5f 61 75 78 64 61 74 lite3_set_auxdat
2c840 61 28 29 5d 2e 0a 2a 2f 0a 74 79 70 65 64 65 66 a()]..*/.typedef
2c850 20 73 74 72 75 63 74 20 73 71 6c 69 74 65 33 5f struct sqlite3_
2c860 63 6f 6e 74 65 78 74 20 73 71 6c 69 74 65 33 5f context sqlite3_
2c870 63 6f 6e 74 65 78 74 3b 0a 0a 2f 2a 0a 2a 2a 20 context;../*.**
2c880 43 41 50 49 33 52 45 46 3a 20 42 69 6e 64 69 6e CAPI3REF: Bindin
2c890 67 20 56 61 6c 75 65 73 20 54 6f 20 50 72 65 70 g Values To Prep
2c8a0 61 72 65 64 20 53 74 61 74 65 6d 65 6e 74 73 0a ared Statements.
2c8b0 2a 2a 20 4b 45 59 57 4f 52 44 53 3a 20 7b 68 6f ** KEYWORDS: {ho
2c8c0 73 74 20 70 61 72 61 6d 65 74 65 72 7d 20 7b 68 st parameter} {h
2c8d0 6f 73 74 20 70 61 72 61 6d 65 74 65 72 73 7d 20 ost parameters}
2c8e0 7b 68 6f 73 74 20 70 61 72 61 6d 65 74 65 72 20 {host parameter
2c8f0 6e 61 6d 65 7d 0a 2a 2a 20 4b 45 59 57 4f 52 44 name}.** KEYWORD
2c900 53 3a 20 7b 53 51 4c 20 70 61 72 61 6d 65 74 65 S: {SQL paramete
2c910 72 7d 20 7b 53 51 4c 20 70 61 72 61 6d 65 74 65 r} {SQL paramete
2c920 72 73 7d 20 7b 70 61 72 61 6d 65 74 65 72 20 62 rs} {parameter b
2c930 69 6e 64 69 6e 67 7d 0a 2a 2a 20 4d 45 54 48 4f inding}.** METHO
2c940 44 3a 20 73 71 6c 69 74 65 33 5f 73 74 6d 74 0a D: sqlite3_stmt.
2c950 2a 2a 0a 2a 2a 20 5e 28 49 6e 20 74 68 65 20 53 **.** ^(In the S
2c960 51 4c 20 73 74 61 74 65 6d 65 6e 74 20 74 65 78 QL statement tex
2c970 74 20 69 6e 70 75 74 20 74 6f 20 5b 73 71 6c 69 t input to [sqli
2c980 74 65 33 5f 70 72 65 70 61 72 65 5f 76 32 28 29 te3_prepare_v2()
2c990 5d 20 61 6e 64 20 69 74 73 20 76 61 72 69 61 6e ] and its varian
2c9a0 74 73 2c 0a 2a 2a 20 6c 69 74 65 72 61 6c 73 20 ts,.** literals
2c9b0 6d 61 79 20 62 65 20 72 65 70 6c 61 63 65 64 20 may be replaced
2c9c0 62 79 20 61 20 5b 70 61 72 61 6d 65 74 65 72 5d by a [parameter]
2c9d0 20 74 68 61 74 20 6d 61 74 63 68 65 73 20 6f 6e that matches on
2c9e0 65 20 6f 66 20 66 6f 6c 6c 6f 77 69 6e 67 0a 2a e of following.*
2c9f0 2a 20 74 65 6d 70 6c 61 74 65 73 3a 0a 2a 2a 0a * templates:.**.
2ca00 2a 2a 20 3c 75 6c 3e 0a 2a 2a 20 3c 6c 69 3e 20 ** <ul>.** <li>
2ca10 20 3f 0a 2a 2a 20 3c 6c 69 3e 20 20 3f 4e 4e 4e ?.** <li> ?NNN
2ca20 0a 2a 2a 20 3c 6c 69 3e 20 20 3a 56 56 56 0a 2a .** <li> :VVV.*
2ca30 2a 20 3c 6c 69 3e 20 20 40 56 56 56 0a 2a 2a 20 * <li> @VVV.**
2ca40 3c 6c 69 3e 20 20 24 56 56 56 0a 2a 2a 20 3c 2f <li> $VVV.** </
2ca50 75 6c 3e 0a 2a 2a 0a 2a 2a 20 49 6e 20 74 68 65 ul>.**.** In the
2ca60 20 74 65 6d 70 6c 61 74 65 73 20 61 62 6f 76 65 templates above
2ca70 2c 20 4e 4e 4e 20 72 65 70 72 65 73 65 6e 74 73 , NNN represents
2ca80 20 61 6e 20 69 6e 74 65 67 65 72 20 6c 69 74 65 an integer lite
2ca90 72 61 6c 2c 0a 2a 2a 20 61 6e 64 20 56 56 56 20 ral,.** and VVV
2caa0 72 65 70 72 65 73 65 6e 74 73 20 61 6e 20 61 6c represents an al
2cab0 70 68 61 6e 75 6d 65 72 69 63 20 69 64 65 6e 74 phanumeric ident
2cac0 69 66 69 65 72 2e 29 5e 20 20 5e 54 68 65 20 76 ifier.)^ ^The v
2cad0 61 6c 75 65 73 20 6f 66 20 74 68 65 73 65 0a 2a alues of these.*
2cae0 2a 20 70 61 72 61 6d 65 74 65 72 73 20 28 61 6c * parameters (al
2caf0 73 6f 20 63 61 6c 6c 65 64 20 22 68 6f 73 74 20 so called "host
2cb00 70 61 72 61 6d 65 74 65 72 20 6e 61 6d 65 73 22 parameter names"
2cb10 20 6f 72 20 22 53 51 4c 20 70 61 72 61 6d 65 74 or "SQL paramet
2cb20 65 72 73 22 29 0a 2a 2a 20 63 61 6e 20 62 65 20 ers").** can be
2cb30 73 65 74 20 75 73 69 6e 67 20 74 68 65 20 73 71 set using the sq
2cb40 6c 69 74 65 33 5f 62 69 6e 64 5f 2a 28 29 20 72 lite3_bind_*() r
2cb50 6f 75 74 69 6e 65 73 20 64 65 66 69 6e 65 64 20 outines defined
2cb60 68 65 72 65 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 here..**.** ^The
2cb70 20 66 69 72 73 74 20 61 72 67 75 6d 65 6e 74 20 first argument
2cb80 74 6f 20 74 68 65 20 73 71 6c 69 74 65 33 5f 62 to the sqlite3_b
2cb90 69 6e 64 5f 2a 28 29 20 72 6f 75 74 69 6e 65 73 ind_*() routines
2cba0 20 69 73 20 61 6c 77 61 79 73 0a 2a 2a 20 61 20 is always.** a
2cbb0 70 6f 69 6e 74 65 72 20 74 6f 20 74 68 65 20 5b pointer to the [
2cbc0 73 71 6c 69 74 65 33 5f 73 74 6d 74 5d 20 6f 62 sqlite3_stmt] ob
2cbd0 6a 65 63 74 20 72 65 74 75 72 6e 65 64 20 66 72 ject returned fr
2cbe0 6f 6d 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 70 om.** [sqlite3_p
2cbf0 72 65 70 61 72 65 5f 76 32 28 29 5d 20 6f 72 20 repare_v2()] or
2cc00 69 74 73 20 76 61 72 69 61 6e 74 73 2e 0a 2a 2a its variants..**
2cc10 0a 2a 2a 20 5e 54 68 65 20 73 65 63 6f 6e 64 20 .** ^The second
2cc20 61 72 67 75 6d 65 6e 74 20 69 73 20 74 68 65 20 argument is the
2cc30 69 6e 64 65 78 20 6f 66 20 74 68 65 20 53 51 4c index of the SQL
2cc40 20 70 61 72 61 6d 65 74 65 72 20 74 6f 20 62 65 parameter to be
2cc50 20 73 65 74 2e 0a 2a 2a 20 5e 54 68 65 20 6c 65 set..** ^The le
2cc60 66 74 6d 6f 73 74 20 53 51 4c 20 70 61 72 61 6d ftmost SQL param
2cc70 65 74 65 72 20 68 61 73 20 61 6e 20 69 6e 64 65 eter has an inde
2cc80 78 20 6f 66 20 31 2e 20 20 5e 57 68 65 6e 20 74 x of 1. ^When t
2cc90 68 65 20 73 61 6d 65 20 6e 61 6d 65 64 0a 2a 2a he same named.**
2cca0 20 53 51 4c 20 70 61 72 61 6d 65 74 65 72 20 69 SQL parameter i
2ccb0 73 20 75 73 65 64 20 6d 6f 72 65 20 74 68 61 6e s used more than
2ccc0 20 6f 6e 63 65 2c 20 73 65 63 6f 6e 64 20 61 6e once, second an
2ccd0 64 20 73 75 62 73 65 71 75 65 6e 74 0a 2a 2a 20 d subsequent.**
2cce0 6f 63 63 75 72 72 65 6e 63 65 73 20 68 61 76 65 occurrences have
2ccf0 20 74 68 65 20 73 61 6d 65 20 69 6e 64 65 78 20 the same index
2cd00 61 73 20 74 68 65 20 66 69 72 73 74 20 6f 63 63 as the first occ
2cd10 75 72 72 65 6e 63 65 2e 0a 2a 2a 20 5e 54 68 65 urrence..** ^The
2cd20 20 69 6e 64 65 78 20 66 6f 72 20 6e 61 6d 65 64 index for named
2cd30 20 70 61 72 61 6d 65 74 65 72 73 20 63 61 6e 20 parameters can
2cd40 62 65 20 6c 6f 6f 6b 65 64 20 75 70 20 75 73 69 be looked up usi
2cd50 6e 67 20 74 68 65 0a 2a 2a 20 5b 73 71 6c 69 74 ng the.** [sqlit
2cd60 65 33 5f 62 69 6e 64 5f 70 61 72 61 6d 65 74 65 e3_bind_paramete
2cd70 72 5f 69 6e 64 65 78 28 29 5d 20 41 50 49 20 69 r_index()] API i
2cd80 66 20 64 65 73 69 72 65 64 2e 20 20 5e 54 68 65 f desired. ^The
2cd90 20 69 6e 64 65 78 0a 2a 2a 20 66 6f 72 20 22 3f index.** for "?
2cda0 4e 4e 4e 22 20 70 61 72 61 6d 65 74 65 72 73 20 NNN" parameters
2cdb0 69 73 20 74 68 65 20 76 61 6c 75 65 20 6f 66 20 is the value of
2cdc0 4e 4e 4e 2e 0a 2a 2a 20 5e 54 68 65 20 4e 4e 4e NNN..** ^The NNN
2cdd0 20 76 61 6c 75 65 20 6d 75 73 74 20 62 65 20 62 value must be b
2cde0 65 74 77 65 65 6e 20 31 20 61 6e 64 20 74 68 65 etween 1 and the
2cdf0 20 5b 73 71 6c 69 74 65 33 5f 6c 69 6d 69 74 28 [sqlite3_limit(
2ce00 29 5d 0a 2a 2a 20 70 61 72 61 6d 65 74 65 72 20 )].** parameter
2ce10 5b 53 51 4c 49 54 45 5f 4c 49 4d 49 54 5f 56 41 [SQLITE_LIMIT_VA
2ce20 52 49 41 42 4c 45 5f 4e 55 4d 42 45 52 5d 20 28 RIABLE_NUMBER] (
2ce30 64 65 66 61 75 6c 74 20 76 61 6c 75 65 3a 20 39 default value: 9
2ce40 39 39 29 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 99)..**.** ^The
2ce50 74 68 69 72 64 20 61 72 67 75 6d 65 6e 74 20 69 third argument i
2ce60 73 20 74 68 65 20 76 61 6c 75 65 20 74 6f 20 62 s the value to b
2ce70 69 6e 64 20 74 6f 20 74 68 65 20 70 61 72 61 6d ind to the param
2ce80 65 74 65 72 2e 0a 2a 2a 20 5e 49 66 20 74 68 65 eter..** ^If the
2ce90 20 74 68 69 72 64 20 70 61 72 61 6d 65 74 65 72 third parameter
2cea0 20 74 6f 20 73 71 6c 69 74 65 33 5f 62 69 6e 64 to sqlite3_bind
2ceb0 5f 74 65 78 74 28 29 20 6f 72 20 73 71 6c 69 74 _text() or sqlit
2cec0 65 33 5f 62 69 6e 64 5f 74 65 78 74 31 36 28 29 e3_bind_text16()
2ced0 0a 2a 2a 20 6f 72 20 73 71 6c 69 74 65 33 5f 62 .** or sqlite3_b
2cee0 69 6e 64 5f 62 6c 6f 62 28 29 20 69 73 20 61 20 ind_blob() is a
2cef0 4e 55 4c 4c 20 70 6f 69 6e 74 65 72 20 74 68 65 NULL pointer the
2cf00 6e 20 74 68 65 20 66 6f 75 72 74 68 20 70 61 72 n the fourth par
2cf10 61 6d 65 74 65 72 0a 2a 2a 20 69 73 20 69 67 6e ameter.** is ign
2cf20 6f 72 65 64 20 61 6e 64 20 74 68 65 20 65 6e 64 ored and the end
2cf30 20 72 65 73 75 6c 74 20 69 73 20 74 68 65 20 73 result is the s
2cf40 61 6d 65 20 61 73 20 73 71 6c 69 74 65 33 5f 62 ame as sqlite3_b
2cf50 69 6e 64 5f 6e 75 6c 6c 28 29 2e 0a 2a 2a 0a 2a ind_null()..**.*
2cf60 2a 20 5e 28 49 6e 20 74 68 6f 73 65 20 72 6f 75 * ^(In those rou
2cf70 74 69 6e 65 73 20 74 68 61 74 20 68 61 76 65 20 tines that have
2cf80 61 20 66 6f 75 72 74 68 20 61 72 67 75 6d 65 6e a fourth argumen
2cf90 74 2c 20 69 74 73 20 76 61 6c 75 65 20 69 73 20 t, its value is
2cfa0 74 68 65 0a 2a 2a 20 6e 75 6d 62 65 72 20 6f 66 the.** number of
2cfb0 20 62 79 74 65 73 20 69 6e 20 74 68 65 20 70 61 bytes in the pa
2cfc0 72 61 6d 65 74 65 72 2e 20 20 54 6f 20 62 65 20 rameter. To be
2cfd0 63 6c 65 61 72 3a 20 74 68 65 20 76 61 6c 75 65 clear: the value
2cfe0 20 69 73 20 74 68 65 0a 2a 2a 20 6e 75 6d 62 65 is the.** numbe
2cff0 72 20 6f 66 20 3c 75 3e 62 79 74 65 73 3c 2f 75 r of <u>bytes</u
2d000 3e 20 69 6e 20 74 68 65 20 76 61 6c 75 65 2c 20 > in the value,
2d010 6e 6f 74 20 74 68 65 20 6e 75 6d 62 65 72 20 6f not the number o
2d020 66 20 63 68 61 72 61 63 74 65 72 73 2e 29 5e 0a f characters.)^.
2d030 2a 2a 20 5e 49 66 20 74 68 65 20 66 6f 75 72 74 ** ^If the fourt
2d040 68 20 70 61 72 61 6d 65 74 65 72 20 74 6f 20 73 h parameter to s
2d050 71 6c 69 74 65 33 5f 62 69 6e 64 5f 74 65 78 74 qlite3_bind_text
2d060 28 29 20 6f 72 20 73 71 6c 69 74 65 33 5f 62 69 () or sqlite3_bi
2d070 6e 64 5f 74 65 78 74 31 36 28 29 0a 2a 2a 20 69 nd_text16().** i
2d080 73 20 6e 65 67 61 74 69 76 65 2c 20 74 68 65 6e s negative, then
2d090 20 74 68 65 20 6c 65 6e 67 74 68 20 6f 66 20 74 the length of t
2d0a0 68 65 20 73 74 72 69 6e 67 20 69 73 0a 2a 2a 20 he string is.**
2d0b0 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 62 79 the number of by
2d0c0 74 65 73 20 75 70 20 74 6f 20 74 68 65 20 66 69 tes up to the fi
2d0d0 72 73 74 20 7a 65 72 6f 20 74 65 72 6d 69 6e 61 rst zero termina
2d0e0 74 6f 72 2e 0a 2a 2a 20 49 66 20 74 68 65 20 66 tor..** If the f
2d0f0 6f 75 72 74 68 20 70 61 72 61 6d 65 74 65 72 20 ourth parameter
2d100 74 6f 20 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f to sqlite3_bind_
2d110 62 6c 6f 62 28 29 20 69 73 20 6e 65 67 61 74 69 blob() is negati
2d120 76 65 2c 20 74 68 65 6e 0a 2a 2a 20 74 68 65 20 ve, then.** the
2d130 62 65 68 61 76 69 6f 72 20 69 73 20 75 6e 64 65 behavior is unde
2d140 66 69 6e 65 64 2e 0a 2a 2a 20 49 66 20 61 20 6e fined..** If a n
2d150 6f 6e 2d 6e 65 67 61 74 69 76 65 20 66 6f 75 72 on-negative four
2d160 74 68 20 70 61 72 61 6d 65 74 65 72 20 69 73 20 th parameter is
2d170 70 72 6f 76 69 64 65 64 20 74 6f 20 73 71 6c 69 provided to sqli
2d180 74 65 33 5f 62 69 6e 64 5f 74 65 78 74 28 29 0a te3_bind_text().
2d190 2a 2a 20 6f 72 20 73 71 6c 69 74 65 33 5f 62 69 ** or sqlite3_bi
2d1a0 6e 64 5f 74 65 78 74 31 36 28 29 20 6f 72 20 73 nd_text16() or s
2d1b0 71 6c 69 74 65 33 5f 62 69 6e 64 5f 74 65 78 74 qlite3_bind_text
2d1c0 36 34 28 29 20 74 68 65 6e 0a 2a 2a 20 74 68 61 64() then.** tha
2d1d0 74 20 70 61 72 61 6d 65 74 65 72 20 6d 75 73 74 t parameter must
2d1e0 20 62 65 20 74 68 65 20 62 79 74 65 20 6f 66 66 be the byte off
2d1f0 73 65 74 0a 2a 2a 20 77 68 65 72 65 20 74 68 65 set.** where the
2d200 20 4e 55 4c 20 74 65 72 6d 69 6e 61 74 6f 72 20 NUL terminator
2d210 77 6f 75 6c 64 20 6f 63 63 75 72 20 61 73 73 75 would occur assu
2d220 6d 69 6e 67 20 74 68 65 20 73 74 72 69 6e 67 20 ming the string
2d230 77 65 72 65 20 4e 55 4c 0a 2a 2a 20 74 65 72 6d were NUL.** term
2d240 69 6e 61 74 65 64 2e 20 20 49 66 20 61 6e 79 20 inated. If any
2d250 4e 55 4c 20 63 68 61 72 61 63 74 65 72 73 20 6f NUL characters o
2d260 63 63 75 72 20 61 74 20 62 79 74 65 20 6f 66 66 ccur at byte off
2d270 73 65 74 73 20 6c 65 73 73 20 74 68 61 6e 20 0a sets less than .
2d280 2a 2a 20 74 68 65 20 76 61 6c 75 65 20 6f 66 20 ** the value of
2d290 74 68 65 20 66 6f 75 72 74 68 20 70 61 72 61 6d the fourth param
2d2a0 65 74 65 72 20 74 68 65 6e 20 74 68 65 20 72 65 eter then the re
2d2b0 73 75 6c 74 69 6e 67 20 73 74 72 69 6e 67 20 76 sulting string v
2d2c0 61 6c 75 65 20 77 69 6c 6c 0a 2a 2a 20 63 6f 6e alue will.** con
2d2d0 74 61 69 6e 20 65 6d 62 65 64 64 65 64 20 4e 55 tain embedded NU
2d2e0 4c 73 2e 20 20 54 68 65 20 72 65 73 75 6c 74 20 Ls. The result
2d2f0 6f 66 20 65 78 70 72 65 73 73 69 6f 6e 73 20 69 of expressions i
2d300 6e 76 6f 6c 76 69 6e 67 20 73 74 72 69 6e 67 73 nvolving strings
2d310 0a 2a 2a 20 77 69 74 68 20 65 6d 62 65 64 64 65 .** with embedde
2d320 64 20 4e 55 4c 73 20 69 73 20 75 6e 64 65 66 69 d NULs is undefi
2d330 6e 65 64 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 ned..**.** ^The
2d340 66 69 66 74 68 20 61 72 67 75 6d 65 6e 74 20 74 fifth argument t
2d350 6f 20 74 68 65 20 42 4c 4f 42 20 61 6e 64 20 73 o the BLOB and s
2d360 74 72 69 6e 67 20 62 69 6e 64 69 6e 67 20 69 6e tring binding in
2d370 74 65 72 66 61 63 65 73 0a 2a 2a 20 69 73 20 61 terfaces.** is a
2d380 20 64 65 73 74 72 75 63 74 6f 72 20 75 73 65 64 destructor used
2d390 20 74 6f 20 64 69 73 70 6f 73 65 20 6f 66 20 74 to dispose of t
2d3a0 68 65 20 42 4c 4f 42 20 6f 72 0a 2a 2a 20 73 74 he BLOB or.** st
2d3b0 72 69 6e 67 20 61 66 74 65 72 20 53 51 4c 69 74 ring after SQLit
2d3c0 65 20 68 61 73 20 66 69 6e 69 73 68 65 64 20 77 e has finished w
2d3d0 69 74 68 20 69 74 2e 20 20 5e 54 68 65 20 64 65 ith it. ^The de
2d3e0 73 74 72 75 63 74 6f 72 20 69 73 20 63 61 6c 6c structor is call
2d3f0 65 64 0a 2a 2a 20 74 6f 20 64 69 73 70 6f 73 65 ed.** to dispose
2d400 20 6f 66 20 74 68 65 20 42 4c 4f 42 20 6f 72 20 of the BLOB or
2d410 73 74 72 69 6e 67 20 65 76 65 6e 20 69 66 20 74 string even if t
2d420 68 65 20 63 61 6c 6c 20 74 6f 20 62 69 6e 64 20 he call to bind
2d430 41 50 49 20 66 61 69 6c 73 2e 0a 2a 2a 20 5e 49 API fails..** ^I
2d440 66 20 74 68 65 20 66 69 66 74 68 20 61 72 67 75 f the fifth argu
2d450 6d 65 6e 74 20 69 73 0a 2a 2a 20 74 68 65 20 73 ment is.** the s
2d460 70 65 63 69 61 6c 20 76 61 6c 75 65 20 5b 53 51 pecial value [SQ
2d470 4c 49 54 45 5f 53 54 41 54 49 43 5d 2c 20 74 68 LITE_STATIC], th
2d480 65 6e 20 53 51 4c 69 74 65 20 61 73 73 75 6d 65 en SQLite assume
2d490 73 20 74 68 61 74 20 74 68 65 0a 2a 2a 20 69 6e s that the.** in
2d4a0 66 6f 72 6d 61 74 69 6f 6e 20 69 73 20 69 6e 20 formation is in
2d4b0 73 74 61 74 69 63 2c 20 75 6e 6d 61 6e 61 67 65 static, unmanage
2d4c0 64 20 73 70 61 63 65 20 61 6e 64 20 64 6f 65 73 d space and does
2d4d0 20 6e 6f 74 20 6e 65 65 64 20 74 6f 20 62 65 20 not need to be
2d4e0 66 72 65 65 64 2e 0a 2a 2a 20 5e 49 66 20 74 68 freed..** ^If th
2d4f0 65 20 66 69 66 74 68 20 61 72 67 75 6d 65 6e 74 e fifth argument
2d500 20 68 61 73 20 74 68 65 20 76 61 6c 75 65 20 5b has the value [
2d510 53 51 4c 49 54 45 5f 54 52 41 4e 53 49 45 4e 54 SQLITE_TRANSIENT
2d520 5d 2c 20 74 68 65 6e 0a 2a 2a 20 53 51 4c 69 74 ], then.** SQLit
2d530 65 20 6d 61 6b 65 73 20 69 74 73 20 6f 77 6e 20 e makes its own
2d540 70 72 69 76 61 74 65 20 63 6f 70 79 20 6f 66 20 private copy of
2d550 74 68 65 20 64 61 74 61 20 69 6d 6d 65 64 69 61 the data immedia
2d560 74 65 6c 79 2c 20 62 65 66 6f 72 65 0a 2a 2a 20 tely, before.**
2d570 74 68 65 20 73 71 6c 69 74 65 33 5f 62 69 6e 64 the sqlite3_bind
2d580 5f 2a 28 29 20 72 6f 75 74 69 6e 65 20 72 65 74 _*() routine ret
2d590 75 72 6e 73 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 urns..**.** ^The
2d5a0 20 73 69 78 74 68 20 61 72 67 75 6d 65 6e 74 20 sixth argument
2d5b0 74 6f 20 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f to sqlite3_bind_
2d5c0 74 65 78 74 36 34 28 29 20 6d 75 73 74 20 62 65 text64() must be
2d5d0 20 6f 6e 65 20 6f 66 0a 2a 2a 20 5b 53 51 4c 49 one of.** [SQLI
2d5e0 54 45 5f 55 54 46 38 5d 2c 20 5b 53 51 4c 49 54 TE_UTF8], [SQLIT
2d5f0 45 5f 55 54 46 31 36 5d 2c 20 5b 53 51 4c 49 54 E_UTF16], [SQLIT
2d600 45 5f 55 54 46 31 36 42 45 5d 2c 20 6f 72 20 5b E_UTF16BE], or [
2d610 53 51 4c 49 54 45 5f 55 54 46 31 36 4c 45 5d 0a SQLITE_UTF16LE].
2d620 2a 2a 20 74 6f 20 73 70 65 63 69 66 79 20 74 68 ** to specify th
2d630 65 20 65 6e 63 6f 64 69 6e 67 20 6f 66 20 74 68 e encoding of th
2d640 65 20 74 65 78 74 20 69 6e 20 74 68 65 20 74 68 e text in the th
2d650 69 72 64 20 70 61 72 61 6d 65 74 65 72 2e 20 20 ird parameter.
2d660 49 66 0a 2a 2a 20 74 68 65 20 73 69 78 74 68 20 If.** the sixth
2d670 61 72 67 75 6d 65 6e 74 20 74 6f 20 73 71 6c 69 argument to sqli
2d680 74 65 33 5f 62 69 6e 64 5f 74 65 78 74 36 34 28 te3_bind_text64(
2d690 29 20 69 73 20 6e 6f 74 20 6f 6e 65 20 6f 66 20 ) is not one of
2d6a0 74 68 65 0a 2a 2a 20 61 6c 6c 6f 77 65 64 20 76 the.** allowed v
2d6b0 61 6c 75 65 73 20 73 68 6f 77 6e 20 61 62 6f 76 alues shown abov
2d6c0 65 2c 20 6f 72 20 69 66 20 74 68 65 20 74 65 78 e, or if the tex
2d6d0 74 20 65 6e 63 6f 64 69 6e 67 20 69 73 20 64 69 t encoding is di
2d6e0 66 66 65 72 65 6e 74 0a 2a 2a 20 66 72 6f 6d 20 fferent.** from
2d6f0 74 68 65 20 65 6e 63 6f 64 69 6e 67 20 73 70 65 the encoding spe
2d700 63 69 66 69 65 64 20 62 79 20 74 68 65 20 73 69 cified by the si
2d710 78 74 68 20 70 61 72 61 6d 65 74 65 72 2c 20 74 xth parameter, t
2d720 68 65 6e 20 74 68 65 20 62 65 68 61 76 69 6f 72 hen the behavior
2d730 0a 2a 2a 20 69 73 20 75 6e 64 65 66 69 6e 65 64 .** is undefined
2d740 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 6c ..**.** ^The sql
2d750 69 74 65 33 5f 62 69 6e 64 5f 7a 65 72 6f 62 6c ite3_bind_zerobl
2d760 6f 62 28 29 20 72 6f 75 74 69 6e 65 20 62 69 6e ob() routine bin
2d770 64 73 20 61 20 42 4c 4f 42 20 6f 66 20 6c 65 6e ds a BLOB of len
2d780 67 74 68 20 4e 20 74 68 61 74 0a 2a 2a 20 69 73 gth N that.** is
2d790 20 66 69 6c 6c 65 64 20 77 69 74 68 20 7a 65 72 filled with zer
2d7a0 6f 65 73 2e 20 20 5e 41 20 7a 65 72 6f 62 6c 6f oes. ^A zeroblo
2d7b0 62 20 75 73 65 73 20 61 20 66 69 78 65 64 20 61 b uses a fixed a
2d7c0 6d 6f 75 6e 74 20 6f 66 20 6d 65 6d 6f 72 79 0a mount of memory.
2d7d0 2a 2a 20 28 6a 75 73 74 20 61 6e 20 69 6e 74 65 ** (just an inte
2d7e0 67 65 72 20 74 6f 20 68 6f 6c 64 20 69 74 73 20 ger to hold its
2d7f0 73 69 7a 65 29 20 77 68 69 6c 65 20 69 74 20 69 size) while it i
2d800 73 20 62 65 69 6e 67 20 70 72 6f 63 65 73 73 65 s being processe
2d810 64 2e 0a 2a 2a 20 5a 65 72 6f 62 6c 6f 62 73 20 d..** Zeroblobs
2d820 61 72 65 20 69 6e 74 65 6e 64 65 64 20 74 6f 20 are intended to
2d830 73 65 72 76 65 20 61 73 20 70 6c 61 63 65 68 6f serve as placeho
2d840 6c 64 65 72 73 20 66 6f 72 20 42 4c 4f 42 73 20 lders for BLOBs
2d850 77 68 6f 73 65 0a 2a 2a 20 63 6f 6e 74 65 6e 74 whose.** content
2d860 20 69 73 20 6c 61 74 65 72 20 77 72 69 74 74 65 is later writte
2d870 6e 20 75 73 69 6e 67 0a 2a 2a 20 5b 73 71 6c 69 n using.** [sqli
2d880 74 65 33 5f 62 6c 6f 62 5f 6f 70 65 6e 20 7c 20 te3_blob_open |
2d890 69 6e 63 72 65 6d 65 6e 74 61 6c 20 42 4c 4f 42 incremental BLOB
2d8a0 20 49 2f 4f 5d 20 72 6f 75 74 69 6e 65 73 2e 0a I/O] routines..
2d8b0 2a 2a 20 5e 41 20 6e 65 67 61 74 69 76 65 20 76 ** ^A negative v
2d8c0 61 6c 75 65 20 66 6f 72 20 74 68 65 20 7a 65 72 alue for the zer
2d8d0 6f 62 6c 6f 62 20 72 65 73 75 6c 74 73 20 69 6e oblob results in
2d8e0 20 61 20 7a 65 72 6f 2d 6c 65 6e 67 74 68 20 42 a zero-length B
2d8f0 4c 4f 42 2e 0a 2a 2a 0a 2a 2a 20 5e 49 66 20 61 LOB..**.** ^If a
2d900 6e 79 20 6f 66 20 74 68 65 20 73 71 6c 69 74 65 ny of the sqlite
2d910 33 5f 62 69 6e 64 5f 2a 28 29 20 72 6f 75 74 69 3_bind_*() routi
2d920 6e 65 73 20 61 72 65 20 63 61 6c 6c 65 64 20 77 nes are called w
2d930 69 74 68 20 61 20 4e 55 4c 4c 20 70 6f 69 6e 74 ith a NULL point
2d940 65 72 0a 2a 2a 20 66 6f 72 20 74 68 65 20 5b 70 er.** for the [p
2d950 72 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e repared statemen
2d960 74 5d 20 6f 72 20 77 69 74 68 20 61 20 70 72 65 t] or with a pre
2d970 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 20 pared statement
2d980 66 6f 72 20 77 68 69 63 68 0a 2a 2a 20 5b 73 71 for which.** [sq
2d990 6c 69 74 65 33 5f 73 74 65 70 28 29 5d 20 68 61 lite3_step()] ha
2d9a0 73 20 62 65 65 6e 20 63 61 6c 6c 65 64 20 6d 6f s been called mo
2d9b0 72 65 20 72 65 63 65 6e 74 6c 79 20 74 68 61 6e re recently than
2d9c0 20 5b 73 71 6c 69 74 65 33 5f 72 65 73 65 74 28 [sqlite3_reset(
2d9d0 29 5d 2c 0a 2a 2a 20 74 68 65 6e 20 74 68 65 20 )],.** then the
2d9e0 63 61 6c 6c 20 77 69 6c 6c 20 72 65 74 75 72 6e call will return
2d9f0 20 5b 53 51 4c 49 54 45 5f 4d 49 53 55 53 45 5d [SQLITE_MISUSE]
2da00 2e 20 20 49 66 20 61 6e 79 20 73 71 6c 69 74 65 . If any sqlite
2da10 33 5f 62 69 6e 64 5f 28 29 0a 2a 2a 20 72 6f 75 3_bind_().** rou
2da20 74 69 6e 65 20 69 73 20 70 61 73 73 65 64 20 61 tine is passed a
2da30 20 5b 70 72 65 70 61 72 65 64 20 73 74 61 74 65 [prepared state
2da40 6d 65 6e 74 5d 20 74 68 61 74 20 68 61 73 20 62 ment] that has b
2da50 65 65 6e 20 66 69 6e 61 6c 69 7a 65 64 2c 20 74 een finalized, t
2da60 68 65 0a 2a 2a 20 72 65 73 75 6c 74 20 69 73 20 he.** result is
2da70 75 6e 64 65 66 69 6e 65 64 20 61 6e 64 20 70 72 undefined and pr
2da80 6f 62 61 62 6c 79 20 68 61 72 6d 66 75 6c 2e 0a obably harmful..
2da90 2a 2a 0a 2a 2a 20 5e 42 69 6e 64 69 6e 67 73 20 **.** ^Bindings
2daa0 61 72 65 20 6e 6f 74 20 63 6c 65 61 72 65 64 20 are not cleared
2dab0 62 79 20 74 68 65 20 5b 73 71 6c 69 74 65 33 5f by the [sqlite3_
2dac0 72 65 73 65 74 28 29 5d 20 72 6f 75 74 69 6e 65 reset()] routine
2dad0 2e 0a 2a 2a 20 5e 55 6e 62 6f 75 6e 64 20 70 61 ..** ^Unbound pa
2dae0 72 61 6d 65 74 65 72 73 20 61 72 65 20 69 6e 74 rameters are int
2daf0 65 72 70 72 65 74 65 64 20 61 73 20 4e 55 4c 4c erpreted as NULL
2db00 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 6c ..**.** ^The sql
2db10 69 74 65 33 5f 62 69 6e 64 5f 2a 20 72 6f 75 74 ite3_bind_* rout
2db20 69 6e 65 73 20 72 65 74 75 72 6e 20 5b 53 51 4c ines return [SQL
2db30 49 54 45 5f 4f 4b 5d 20 6f 6e 20 73 75 63 63 65 ITE_OK] on succe
2db40 73 73 20 6f 72 20 61 6e 0a 2a 2a 20 5b 65 72 72 ss or an.** [err
2db50 6f 72 20 63 6f 64 65 5d 20 69 66 20 61 6e 79 74 or code] if anyt
2db60 68 69 6e 67 20 67 6f 65 73 20 77 72 6f 6e 67 2e hing goes wrong.
2db70 0a 2a 2a 20 5e 5b 53 51 4c 49 54 45 5f 54 4f 4f .** ^[SQLITE_TOO
2db80 42 49 47 5d 20 6d 69 67 68 74 20 62 65 20 72 65 BIG] might be re
2db90 74 75 72 6e 65 64 20 69 66 20 74 68 65 20 73 69 turned if the si
2dba0 7a 65 20 6f 66 20 61 20 73 74 72 69 6e 67 20 6f ze of a string o
2dbb0 72 20 42 4c 4f 42 0a 2a 2a 20 65 78 63 65 65 64 r BLOB.** exceed
2dbc0 73 20 6c 69 6d 69 74 73 20 69 6d 70 6f 73 65 64 s limits imposed
2dbd0 20 62 79 20 5b 73 71 6c 69 74 65 33 5f 6c 69 6d by [sqlite3_lim
2dbe0 69 74 5d 28 5b 53 51 4c 49 54 45 5f 4c 49 4d 49 it]([SQLITE_LIMI
2dbf0 54 5f 4c 45 4e 47 54 48 5d 29 20 6f 72 0a 2a 2a T_LENGTH]) or.**
2dc00 20 5b 53 51 4c 49 54 45 5f 4d 41 58 5f 4c 45 4e [SQLITE_MAX_LEN
2dc10 47 54 48 5d 2e 0a 2a 2a 20 5e 5b 53 51 4c 49 54 GTH]..** ^[SQLIT
2dc20 45 5f 52 41 4e 47 45 5d 20 69 73 20 72 65 74 75 E_RANGE] is retu
2dc30 72 6e 65 64 20 69 66 20 74 68 65 20 70 61 72 61 rned if the para
2dc40 6d 65 74 65 72 0a 2a 2a 20 69 6e 64 65 78 20 69 meter.** index i
2dc50 73 20 6f 75 74 20 6f 66 20 72 61 6e 67 65 2e 20 s out of range.
2dc60 20 5e 5b 53 51 4c 49 54 45 5f 4e 4f 4d 45 4d 5d ^[SQLITE_NOMEM]
2dc70 20 69 73 20 72 65 74 75 72 6e 65 64 20 69 66 20 is returned if
2dc80 6d 61 6c 6c 6f 63 28 29 20 66 61 69 6c 73 2e 0a malloc() fails..
2dc90 2a 2a 0a 2a 2a 20 53 65 65 20 61 6c 73 6f 3a 20 **.** See also:
2dca0 5b 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 70 61 [sqlite3_bind_pa
2dcb0 72 61 6d 65 74 65 72 5f 63 6f 75 6e 74 28 29 5d rameter_count()]
2dcc0 2c 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 62 69 ,.** [sqlite3_bi
2dcd0 6e 64 5f 70 61 72 61 6d 65 74 65 72 5f 6e 61 6d nd_parameter_nam
2dce0 65 28 29 5d 2c 20 61 6e 64 20 5b 73 71 6c 69 74 e()], and [sqlit
2dcf0 65 33 5f 62 69 6e 64 5f 70 61 72 61 6d 65 74 65 e3_bind_paramete
2dd00 72 5f 69 6e 64 65 78 28 29 5d 2e 0a 2a 2f 0a 69 r_index()]..*/.i
2dd10 6e 74 20 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f nt sqlite3_bind_
2dd20 62 6c 6f 62 28 73 71 6c 69 74 65 33 5f 73 74 6d blob(sqlite3_stm
2dd30 74 2a 2c 20 69 6e 74 2c 20 63 6f 6e 73 74 20 76 t*, int, const v
2dd40 6f 69 64 2a 2c 20 69 6e 74 20 6e 2c 20 76 6f 69 oid*, int n, voi
2dd50 64 28 2a 29 28 76 6f 69 64 2a 29 29 3b 0a 69 6e d(*)(void*));.in
2dd60 74 20 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 62 t sqlite3_bind_b
2dd70 6c 6f 62 36 34 28 73 71 6c 69 74 65 33 5f 73 74 lob64(sqlite3_st
2dd80 6d 74 2a 2c 20 69 6e 74 2c 20 63 6f 6e 73 74 20 mt*, int, const
2dd90 76 6f 69 64 2a 2c 20 73 71 6c 69 74 65 33 5f 75 void*, sqlite3_u
2dda0 69 6e 74 36 34 2c 0a 20 20 20 20 20 20 20 20 20 int64,.
2ddb0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 v
2ddc0 6f 69 64 28 2a 29 28 76 6f 69 64 2a 29 29 3b 0a oid(*)(void*));.
2ddd0 69 6e 74 20 73 71 6c 69 74 65 33 5f 62 69 6e 64 int sqlite3_bind
2dde0 5f 64 6f 75 62 6c 65 28 73 71 6c 69 74 65 33 5f _double(sqlite3_
2ddf0 73 74 6d 74 2a 2c 20 69 6e 74 2c 20 64 6f 75 62 stmt*, int, doub
2de00 6c 65 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 le);.int sqlite3
2de10 5f 62 69 6e 64 5f 69 6e 74 28 73 71 6c 69 74 65 _bind_int(sqlite
2de20 33 5f 73 74 6d 74 2a 2c 20 69 6e 74 2c 20 69 6e 3_stmt*, int, in
2de30 74 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f t);.int sqlite3_
2de40 62 69 6e 64 5f 69 6e 74 36 34 28 73 71 6c 69 74 bind_int64(sqlit
2de50 65 33 5f 73 74 6d 74 2a 2c 20 69 6e 74 2c 20 73 e3_stmt*, int, s
2de60 71 6c 69 74 65 33 5f 69 6e 74 36 34 29 3b 0a 69 qlite3_int64);.i
2de70 6e 74 20 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f nt sqlite3_bind_
2de80 6e 75 6c 6c 28 73 71 6c 69 74 65 33 5f 73 74 6d null(sqlite3_stm
2de90 74 2a 2c 20 69 6e 74 29 3b 0a 69 6e 74 20 73 71 t*, int);.int sq
2dea0 6c 69 74 65 33 5f 62 69 6e 64 5f 74 65 78 74 28 lite3_bind_text(
2deb0 73 71 6c 69 74 65 33 5f 73 74 6d 74 2a 2c 69 6e sqlite3_stmt*,in
2dec0 74 2c 63 6f 6e 73 74 20 63 68 61 72 2a 2c 69 6e t,const char*,in
2ded0 74 2c 76 6f 69 64 28 2a 29 28 76 6f 69 64 2a 29 t,void(*)(void*)
2dee0 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f 62 );.int sqlite3_b
2def0 69 6e 64 5f 74 65 78 74 31 36 28 73 71 6c 69 74 ind_text16(sqlit
2df00 65 33 5f 73 74 6d 74 2a 2c 20 69 6e 74 2c 20 63 e3_stmt*, int, c
2df10 6f 6e 73 74 20 76 6f 69 64 2a 2c 20 69 6e 74 2c onst void*, int,
2df20 20 76 6f 69 64 28 2a 29 28 76 6f 69 64 2a 29 29 void(*)(void*))
2df30 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f 62 69 ;.int sqlite3_bi
2df40 6e 64 5f 74 65 78 74 36 34 28 73 71 6c 69 74 65 nd_text64(sqlite
2df50 33 5f 73 74 6d 74 2a 2c 20 69 6e 74 2c 20 63 6f 3_stmt*, int, co
2df60 6e 73 74 20 63 68 61 72 2a 2c 20 73 71 6c 69 74 nst char*, sqlit
2df70 65 33 5f 75 69 6e 74 36 34 2c 0a 20 20 20 20 20 e3_uint64,.
2df80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2df90 20 20 20 20 76 6f 69 64 28 2a 29 28 76 6f 69 64 void(*)(void
2dfa0 2a 29 2c 20 75 6e 73 69 67 6e 65 64 20 63 68 61 *), unsigned cha
2dfb0 72 20 65 6e 63 6f 64 69 6e 67 29 3b 0a 69 6e 74 r encoding);.int
2dfc0 20 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 76 61 sqlite3_bind_va
2dfd0 6c 75 65 28 73 71 6c 69 74 65 33 5f 73 74 6d 74 lue(sqlite3_stmt
2dfe0 2a 2c 20 69 6e 74 2c 20 63 6f 6e 73 74 20 73 71 *, int, const sq
2dff0 6c 69 74 65 33 5f 76 61 6c 75 65 2a 29 3b 0a 69 lite3_value*);.i
2e000 6e 74 20 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f nt sqlite3_bind_
2e010 7a 65 72 6f 62 6c 6f 62 28 73 71 6c 69 74 65 33 zeroblob(sqlite3
2e020 5f 73 74 6d 74 2a 2c 20 69 6e 74 2c 20 69 6e 74 _stmt*, int, int
2e030 20 6e 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 n);.int sqlite3
2e040 5f 62 69 6e 64 5f 7a 65 72 6f 62 6c 6f 62 36 34 _bind_zeroblob64
2e050 28 73 71 6c 69 74 65 33 5f 73 74 6d 74 2a 2c 20 (sqlite3_stmt*,
2e060 69 6e 74 2c 20 73 71 6c 69 74 65 33 5f 75 69 6e int, sqlite3_uin
2e070 74 36 34 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 t64);../*.** CAP
2e080 49 33 52 45 46 3a 20 4e 75 6d 62 65 72 20 4f 66 I3REF: Number Of
2e090 20 53 51 4c 20 50 61 72 61 6d 65 74 65 72 73 0a SQL Parameters.
2e0a0 2a 2a 20 4d 45 54 48 4f 44 3a 20 73 71 6c 69 74 ** METHOD: sqlit
2e0b0 65 33 5f 73 74 6d 74 0a 2a 2a 0a 2a 2a 20 5e 54 e3_stmt.**.** ^T
2e0c0 68 69 73 20 72 6f 75 74 69 6e 65 20 63 61 6e 20 his routine can
2e0d0 62 65 20 75 73 65 64 20 74 6f 20 66 69 6e 64 20 be used to find
2e0e0 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 5b 53 the number of [S
2e0f0 51 4c 20 70 61 72 61 6d 65 74 65 72 73 5d 0a 2a QL parameters].*
2e100 2a 20 69 6e 20 61 20 5b 70 72 65 70 61 72 65 64 * in a [prepared
2e110 20 73 74 61 74 65 6d 65 6e 74 5d 2e 20 20 53 51 statement]. SQ
2e120 4c 20 70 61 72 61 6d 65 74 65 72 73 20 61 72 65 L parameters are
2e130 20 74 6f 6b 65 6e 73 20 6f 66 20 74 68 65 0a 2a tokens of the.*
2e140 2a 20 66 6f 72 6d 20 22 3f 22 2c 20 22 3f 4e 4e * form "?", "?NN
2e150 4e 22 2c 20 22 3a 41 41 41 22 2c 20 22 24 41 41 N", ":AAA", "$AA
2e160 41 22 2c 20 6f 72 20 22 40 41 41 41 22 20 74 68 A", or "@AAA" th
2e170 61 74 20 73 65 72 76 65 20 61 73 0a 2a 2a 20 70 at serve as.** p
2e180 6c 61 63 65 68 6f 6c 64 65 72 73 20 66 6f 72 20 laceholders for
2e190 76 61 6c 75 65 73 20 74 68 61 74 20 61 72 65 20 values that are
2e1a0 5b 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 62 6c [sqlite3_bind_bl
2e1b0 6f 62 20 7c 20 62 6f 75 6e 64 5d 0a 2a 2a 20 74 ob | bound].** t
2e1c0 6f 20 74 68 65 20 70 61 72 61 6d 65 74 65 72 73 o the parameters
2e1d0 20 61 74 20 61 20 6c 61 74 65 72 20 74 69 6d 65 at a later time
2e1e0 2e 0a 2a 2a 0a 2a 2a 20 5e 28 54 68 69 73 20 72 ..**.** ^(This r
2e1f0 6f 75 74 69 6e 65 20 61 63 74 75 61 6c 6c 79 20 outine actually
2e200 72 65 74 75 72 6e 73 20 74 68 65 20 69 6e 64 65 returns the inde
2e210 78 20 6f 66 20 74 68 65 20 6c 61 72 67 65 73 74 x of the largest
2e220 20 28 72 69 67 68 74 6d 6f 73 74 29 0a 2a 2a 20 (rightmost).**
2e230 70 61 72 61 6d 65 74 65 72 2e 20 46 6f 72 20 61 parameter. For a
2e240 6c 6c 20 66 6f 72 6d 73 20 65 78 63 65 70 74 20 ll forms except
2e250 3f 4e 4e 4e 2c 20 74 68 69 73 20 77 69 6c 6c 20 ?NNN, this will
2e260 63 6f 72 72 65 73 70 6f 6e 64 20 74 6f 20 74 68 correspond to th
2e270 65 0a 2a 2a 20 6e 75 6d 62 65 72 20 6f 66 20 75 e.** number of u
2e280 6e 69 71 75 65 20 70 61 72 61 6d 65 74 65 72 73 nique parameters
2e290 2e 20 20 49 66 20 70 61 72 61 6d 65 74 65 72 73 . If parameters
2e2a0 20 6f 66 20 74 68 65 20 3f 4e 4e 4e 20 66 6f 72 of the ?NNN for
2e2b0 6d 20 61 72 65 20 75 73 65 64 2c 0a 2a 2a 20 74 m are used,.** t
2e2c0 68 65 72 65 20 6d 61 79 20 62 65 20 67 61 70 73 here may be gaps
2e2d0 20 69 6e 20 74 68 65 20 6c 69 73 74 2e 29 5e 0a in the list.)^.
2e2e0 2a 2a 0a 2a 2a 20 53 65 65 20 61 6c 73 6f 3a 20 **.** See also:
2e2f0 5b 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 62 6c [sqlite3_bind_bl
2e300 6f 62 7c 73 71 6c 69 74 65 33 5f 62 69 6e 64 28 ob|sqlite3_bind(
2e310 29 5d 2c 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f )],.** [sqlite3_
2e320 62 69 6e 64 5f 70 61 72 61 6d 65 74 65 72 5f 6e bind_parameter_n
2e330 61 6d 65 28 29 5d 2c 20 61 6e 64 0a 2a 2a 20 5b ame()], and.** [
2e340 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 70 61 72 sqlite3_bind_par
2e350 61 6d 65 74 65 72 5f 69 6e 64 65 78 28 29 5d 2e ameter_index()].
2e360 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f .*/.int sqlite3_
2e370 62 69 6e 64 5f 70 61 72 61 6d 65 74 65 72 5f 63 bind_parameter_c
2e380 6f 75 6e 74 28 73 71 6c 69 74 65 33 5f 73 74 6d ount(sqlite3_stm
2e390 74 2a 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 t*);../*.** CAPI
2e3a0 33 52 45 46 3a 20 4e 61 6d 65 20 4f 66 20 41 20 3REF: Name Of A
2e3b0 48 6f 73 74 20 50 61 72 61 6d 65 74 65 72 0a 2a Host Parameter.*
2e3c0 2a 20 4d 45 54 48 4f 44 3a 20 73 71 6c 69 74 65 * METHOD: sqlite
2e3d0 33 5f 73 74 6d 74 0a 2a 2a 0a 2a 2a 20 5e 54 68 3_stmt.**.** ^Th
2e3e0 65 20 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 70 e sqlite3_bind_p
2e3f0 61 72 61 6d 65 74 65 72 5f 6e 61 6d 65 28 50 2c arameter_name(P,
2e400 4e 29 20 69 6e 74 65 72 66 61 63 65 20 72 65 74 N) interface ret
2e410 75 72 6e 73 0a 2a 2a 20 74 68 65 20 6e 61 6d 65 urns.** the name
2e420 20 6f 66 20 74 68 65 20 4e 2d 74 68 20 5b 53 51 of the N-th [SQ
2e430 4c 20 70 61 72 61 6d 65 74 65 72 5d 20 69 6e 20 L parameter] in
2e440 74 68 65 20 5b 70 72 65 70 61 72 65 64 20 73 74 the [prepared st
2e450 61 74 65 6d 65 6e 74 5d 20 50 2e 0a 2a 2a 20 5e atement] P..** ^
2e460 28 53 51 4c 20 70 61 72 61 6d 65 74 65 72 73 20 (SQL parameters
2e470 6f 66 20 74 68 65 20 66 6f 72 6d 20 22 3f 4e 4e of the form "?NN
2e480 4e 22 20 6f 72 20 22 3a 41 41 41 22 20 6f 72 20 N" or ":AAA" or
2e490 22 40 41 41 41 22 20 6f 72 20 22 24 41 41 41 22 "@AAA" or "$AAA"
2e4a0 0a 2a 2a 20 68 61 76 65 20 61 20 6e 61 6d 65 20 .** have a name
2e4b0 77 68 69 63 68 20 69 73 20 74 68 65 20 73 74 72 which is the str
2e4c0 69 6e 67 20 22 3f 4e 4e 4e 22 20 6f 72 20 22 3a ing "?NNN" or ":
2e4d0 41 41 41 22 20 6f 72 20 22 40 41 41 41 22 20 6f AAA" or "@AAA" o
2e4e0 72 20 22 24 41 41 41 22 0a 2a 2a 20 72 65 73 70 r "$AAA".** resp
2e4f0 65 63 74 69 76 65 6c 79 2e 0a 2a 2a 20 49 6e 20 ectively..** In
2e500 6f 74 68 65 72 20 77 6f 72 64 73 2c 20 74 68 65 other words, the
2e510 20 69 6e 69 74 69 61 6c 20 22 3a 22 20 6f 72 20 initial ":" or
2e520 22 24 22 20 6f 72 20 22 40 22 20 6f 72 20 22 3f "$" or "@" or "?
2e530 22 0a 2a 2a 20 69 73 20 69 6e 63 6c 75 64 65 64 ".** is included
2e540 20 61 73 20 70 61 72 74 20 6f 66 20 74 68 65 20 as part of the
2e550 6e 61 6d 65 2e 29 5e 0a 2a 2a 20 5e 50 61 72 61 name.)^.** ^Para
2e560 6d 65 74 65 72 73 20 6f 66 20 74 68 65 20 66 6f meters of the fo
2e570 72 6d 20 22 3f 22 20 77 69 74 68 6f 75 74 20 61 rm "?" without a
2e580 20 66 6f 6c 6c 6f 77 69 6e 67 20 69 6e 74 65 67 following integ
2e590 65 72 20 68 61 76 65 20 6e 6f 20 6e 61 6d 65 0a er have no name.
2e5a0 2a 2a 20 61 6e 64 20 61 72 65 20 72 65 66 65 72 ** and are refer
2e5b0 72 65 64 20 74 6f 20 61 73 20 22 6e 61 6d 65 6c red to as "namel
2e5c0 65 73 73 22 20 6f 72 20 22 61 6e 6f 6e 79 6d 6f ess" or "anonymo
2e5d0 75 73 20 70 61 72 61 6d 65 74 65 72 73 22 2e 0a us parameters"..
2e5e0 2a 2a 0a 2a 2a 20 5e 54 68 65 20 66 69 72 73 74 **.** ^The first
2e5f0 20 68 6f 73 74 20 70 61 72 61 6d 65 74 65 72 20 host parameter
2e600 68 61 73 20 61 6e 20 69 6e 64 65 78 20 6f 66 20 has an index of
2e610 31 2c 20 6e 6f 74 20 30 2e 0a 2a 2a 0a 2a 2a 20 1, not 0..**.**
2e620 5e 49 66 20 74 68 65 20 76 61 6c 75 65 20 4e 20 ^If the value N
2e630 69 73 20 6f 75 74 20 6f 66 20 72 61 6e 67 65 20 is out of range
2e640 6f 72 20 69 66 20 74 68 65 20 4e 2d 74 68 20 70 or if the N-th p
2e650 61 72 61 6d 65 74 65 72 20 69 73 0a 2a 2a 20 6e arameter is.** n
2e660 61 6d 65 6c 65 73 73 2c 20 74 68 65 6e 20 4e 55 ameless, then NU
2e670 4c 4c 20 69 73 20 72 65 74 75 72 6e 65 64 2e 20 LL is returned.
2e680 20 5e 54 68 65 20 72 65 74 75 72 6e 65 64 20 73 ^The returned s
2e690 74 72 69 6e 67 20 69 73 0a 2a 2a 20 61 6c 77 61 tring is.** alwa
2e6a0 79 73 20 69 6e 20 55 54 46 2d 38 20 65 6e 63 6f ys in UTF-8 enco
2e6b0 64 69 6e 67 20 65 76 65 6e 20 69 66 20 74 68 65 ding even if the
2e6c0 20 6e 61 6d 65 64 20 70 61 72 61 6d 65 74 65 72 named parameter
2e6d0 20 77 61 73 0a 2a 2a 20 6f 72 69 67 69 6e 61 6c was.** original
2e6e0 6c 79 20 73 70 65 63 69 66 69 65 64 20 61 73 20 ly specified as
2e6f0 55 54 46 2d 31 36 20 69 6e 20 5b 73 71 6c 69 74 UTF-16 in [sqlit
2e700 65 33 5f 70 72 65 70 61 72 65 31 36 28 29 5d 20 e3_prepare16()]
2e710 6f 72 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 70 or.** [sqlite3_p
2e720 72 65 70 61 72 65 31 36 5f 76 32 28 29 5d 2e 0a repare16_v2()]..
2e730 2a 2a 0a 2a 2a 20 53 65 65 20 61 6c 73 6f 3a 20 **.** See also:
2e740 5b 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 62 6c [sqlite3_bind_bl
2e750 6f 62 7c 73 71 6c 69 74 65 33 5f 62 69 6e 64 28 ob|sqlite3_bind(
2e760 29 5d 2c 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f )],.** [sqlite3_
2e770 62 69 6e 64 5f 70 61 72 61 6d 65 74 65 72 5f 63 bind_parameter_c
2e780 6f 75 6e 74 28 29 5d 2c 20 61 6e 64 0a 2a 2a 20 ount()], and.**
2e790 5b 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 70 61 [sqlite3_bind_pa
2e7a0 72 61 6d 65 74 65 72 5f 69 6e 64 65 78 28 29 5d rameter_index()]
2e7b0 2e 0a 2a 2f 0a 63 6f 6e 73 74 20 63 68 61 72 20 ..*/.const char
2e7c0 2a 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 70 61 *sqlite3_bind_pa
2e7d0 72 61 6d 65 74 65 72 5f 6e 61 6d 65 28 73 71 6c rameter_name(sql
2e7e0 69 74 65 33 5f 73 74 6d 74 2a 2c 20 69 6e 74 29 ite3_stmt*, int)
2e7f0 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 ;../*.** CAPI3RE
2e800 46 3a 20 49 6e 64 65 78 20 4f 66 20 41 20 50 61 F: Index Of A Pa
2e810 72 61 6d 65 74 65 72 20 57 69 74 68 20 41 20 47 rameter With A G
2e820 69 76 65 6e 20 4e 61 6d 65 0a 2a 2a 20 4d 45 54 iven Name.** MET
2e830 48 4f 44 3a 20 73 71 6c 69 74 65 33 5f 73 74 6d HOD: sqlite3_stm
2e840 74 0a 2a 2a 0a 2a 2a 20 5e 52 65 74 75 72 6e 20 t.**.** ^Return
2e850 74 68 65 20 69 6e 64 65 78 20 6f 66 20 61 6e 20 the index of an
2e860 53 51 4c 20 70 61 72 61 6d 65 74 65 72 20 67 69 SQL parameter gi
2e870 76 65 6e 20 69 74 73 20 6e 61 6d 65 2e 20 20 5e ven its name. ^
2e880 54 68 65 0a 2a 2a 20 69 6e 64 65 78 20 76 61 6c The.** index val
2e890 75 65 20 72 65 74 75 72 6e 65 64 20 69 73 20 73 ue returned is s
2e8a0 75 69 74 61 62 6c 65 20 66 6f 72 20 75 73 65 20 uitable for use
2e8b0 61 73 20 74 68 65 20 73 65 63 6f 6e 64 0a 2a 2a as the second.**
2e8c0 20 70 61 72 61 6d 65 74 65 72 20 74 6f 20 5b 73 parameter to [s
2e8d0 71 6c 69 74 65 33 5f 62 69 6e 64 5f 62 6c 6f 62 qlite3_bind_blob
2e8e0 7c 73 71 6c 69 74 65 33 5f 62 69 6e 64 28 29 5d |sqlite3_bind()]
2e8f0 2e 20 20 5e 41 20 7a 65 72 6f 0a 2a 2a 20 69 73 . ^A zero.** is
2e900 20 72 65 74 75 72 6e 65 64 20 69 66 20 6e 6f 20 returned if no
2e910 6d 61 74 63 68 69 6e 67 20 70 61 72 61 6d 65 74 matching paramet
2e920 65 72 20 69 73 20 66 6f 75 6e 64 2e 20 20 5e 54 er is found. ^T
2e930 68 65 20 70 61 72 61 6d 65 74 65 72 0a 2a 2a 20 he parameter.**
2e940 6e 61 6d 65 20 6d 75 73 74 20 62 65 20 67 69 76 name must be giv
2e950 65 6e 20 69 6e 20 55 54 46 2d 38 20 65 76 65 6e en in UTF-8 even
2e960 20 69 66 20 74 68 65 20 6f 72 69 67 69 6e 61 6c if the original
2e970 20 73 74 61 74 65 6d 65 6e 74 0a 2a 2a 20 77 61 statement.** wa
2e980 73 20 70 72 65 70 61 72 65 64 20 66 72 6f 6d 20 s prepared from
2e990 55 54 46 2d 31 36 20 74 65 78 74 20 75 73 69 6e UTF-16 text usin
2e9a0 67 20 5b 73 71 6c 69 74 65 33 5f 70 72 65 70 61 g [sqlite3_prepa
2e9b0 72 65 31 36 5f 76 32 28 29 5d 2e 0a 2a 2a 0a 2a re16_v2()]..**.*
2e9c0 2a 20 53 65 65 20 61 6c 73 6f 3a 20 5b 73 71 6c * See also: [sql
2e9d0 69 74 65 33 5f 62 69 6e 64 5f 62 6c 6f 62 7c 73 ite3_bind_blob|s
2e9e0 71 6c 69 74 65 33 5f 62 69 6e 64 28 29 5d 2c 0a qlite3_bind()],.
2e9f0 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 62 69 6e 64 ** [sqlite3_bind
2ea00 5f 70 61 72 61 6d 65 74 65 72 5f 63 6f 75 6e 74 _parameter_count
2ea10 28 29 5d 2c 20 61 6e 64 0a 2a 2a 20 5b 73 71 6c ()], and.** [sql
2ea20 69 74 65 33 5f 62 69 6e 64 5f 70 61 72 61 6d 65 ite3_bind_parame
2ea30 74 65 72 5f 6e 61 6d 65 28 29 5d 2e 0a 2a 2f 0a ter_name()]..*/.
2ea40 69 6e 74 20 73 71 6c 69 74 65 33 5f 62 69 6e 64 int sqlite3_bind
2ea50 5f 70 61 72 61 6d 65 74 65 72 5f 69 6e 64 65 78 _parameter_index
2ea60 28 73 71 6c 69 74 65 33 5f 73 74 6d 74 2a 2c 20 (sqlite3_stmt*,
2ea70 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 4e 61 6d const char *zNam
2ea80 65 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 e);../*.** CAPI3
2ea90 52 45 46 3a 20 52 65 73 65 74 20 41 6c 6c 20 42 REF: Reset All B
2eaa0 69 6e 64 69 6e 67 73 20 4f 6e 20 41 20 50 72 65 indings On A Pre
2eab0 70 61 72 65 64 20 53 74 61 74 65 6d 65 6e 74 0a pared Statement.
2eac0 2a 2a 20 4d 45 54 48 4f 44 3a 20 73 71 6c 69 74 ** METHOD: sqlit
2ead0 65 33 5f 73 74 6d 74 0a 2a 2a 0a 2a 2a 20 5e 43 e3_stmt.**.** ^C
2eae0 6f 6e 74 72 61 72 79 20 74 6f 20 74 68 65 20 69 ontrary to the i
2eaf0 6e 74 75 69 74 69 6f 6e 20 6f 66 20 6d 61 6e 79 ntuition of many
2eb00 2c 20 5b 73 71 6c 69 74 65 33 5f 72 65 73 65 74 , [sqlite3_reset
2eb10 28 29 5d 20 64 6f 65 73 20 6e 6f 74 20 72 65 73 ()] does not res
2eb20 65 74 0a 2a 2a 20 74 68 65 20 5b 73 71 6c 69 74 et.** the [sqlit
2eb30 65 33 5f 62 69 6e 64 5f 62 6c 6f 62 20 7c 20 62 e3_bind_blob | b
2eb40 69 6e 64 69 6e 67 73 5d 20 6f 6e 20 61 20 5b 70 indings] on a [p
2eb50 72 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e repared statemen
2eb60 74 5d 2e 0a 2a 2a 20 5e 55 73 65 20 74 68 69 73 t]..** ^Use this
2eb70 20 72 6f 75 74 69 6e 65 20 74 6f 20 72 65 73 65 routine to rese
2eb80 74 20 61 6c 6c 20 68 6f 73 74 20 70 61 72 61 6d t all host param
2eb90 65 74 65 72 73 20 74 6f 20 4e 55 4c 4c 2e 0a 2a eters to NULL..*
2eba0 2f 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f 63 6c /.int sqlite3_cl
2ebb0 65 61 72 5f 62 69 6e 64 69 6e 67 73 28 73 71 6c ear_bindings(sql
2ebc0 69 74 65 33 5f 73 74 6d 74 2a 29 3b 0a 0a 2f 2a ite3_stmt*);../*
2ebd0 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 4e 75 .** CAPI3REF: Nu
2ebe0 6d 62 65 72 20 4f 66 20 43 6f 6c 75 6d 6e 73 20 mber Of Columns
2ebf0 49 6e 20 41 20 52 65 73 75 6c 74 20 53 65 74 0a In A Result Set.
2ec00 2a 2a 20 4d 45 54 48 4f 44 3a 20 73 71 6c 69 74 ** METHOD: sqlit
2ec10 65 33 5f 73 74 6d 74 0a 2a 2a 0a 2a 2a 20 5e 52 e3_stmt.**.** ^R
2ec20 65 74 75 72 6e 20 74 68 65 20 6e 75 6d 62 65 72 eturn the number
2ec30 20 6f 66 20 63 6f 6c 75 6d 6e 73 20 69 6e 20 74 of columns in t
2ec40 68 65 20 72 65 73 75 6c 74 20 73 65 74 20 72 65 he result set re
2ec50 74 75 72 6e 65 64 20 62 79 20 74 68 65 0a 2a 2a turned by the.**
2ec60 20 5b 70 72 65 70 61 72 65 64 20 73 74 61 74 65 [prepared state
2ec70 6d 65 6e 74 5d 2e 20 5e 54 68 69 73 20 72 6f 75 ment]. ^This rou
2ec80 74 69 6e 65 20 72 65 74 75 72 6e 73 20 30 20 69 tine returns 0 i
2ec90 66 20 70 53 74 6d 74 20 69 73 20 61 6e 20 53 51 f pStmt is an SQ
2eca0 4c 0a 2a 2a 20 73 74 61 74 65 6d 65 6e 74 20 74 L.** statement t
2ecb0 68 61 74 20 64 6f 65 73 20 6e 6f 74 20 72 65 74 hat does not ret
2ecc0 75 72 6e 20 64 61 74 61 20 28 66 6f 72 20 65 78 urn data (for ex
2ecd0 61 6d 70 6c 65 20 61 6e 20 5b 55 50 44 41 54 45 ample an [UPDATE
2ece0 5d 29 2e 0a 2a 2a 0a 2a 2a 20 53 65 65 20 61 6c ])..**.** See al
2ecf0 73 6f 3a 20 5b 73 71 6c 69 74 65 33 5f 64 61 74 so: [sqlite3_dat
2ed00 61 5f 63 6f 75 6e 74 28 29 5d 0a 2a 2f 0a 69 6e a_count()].*/.in
2ed10 74 20 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e t sqlite3_column
2ed20 5f 63 6f 75 6e 74 28 73 71 6c 69 74 65 33 5f 73 _count(sqlite3_s
2ed30 74 6d 74 20 2a 70 53 74 6d 74 29 3b 0a 0a 2f 2a tmt *pStmt);../*
2ed40 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 43 6f .** CAPI3REF: Co
2ed50 6c 75 6d 6e 20 4e 61 6d 65 73 20 49 6e 20 41 20 lumn Names In A
2ed60 52 65 73 75 6c 74 20 53 65 74 0a 2a 2a 20 4d 45 Result Set.** ME
2ed70 54 48 4f 44 3a 20 73 71 6c 69 74 65 33 5f 73 74 THOD: sqlite3_st
2ed80 6d 74 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 73 65 20 mt.**.** ^These
2ed90 72 6f 75 74 69 6e 65 73 20 72 65 74 75 72 6e 20 routines return
2eda0 74 68 65 20 6e 61 6d 65 20 61 73 73 69 67 6e 65 the name assigne
2edb0 64 20 74 6f 20 61 20 70 61 72 74 69 63 75 6c 61 d to a particula
2edc0 72 20 63 6f 6c 75 6d 6e 0a 2a 2a 20 69 6e 20 74 r column.** in t
2edd0 68 65 20 72 65 73 75 6c 74 20 73 65 74 20 6f 66 he result set of
2ede0 20 61 20 5b 53 45 4c 45 43 54 5d 20 73 74 61 74 a [SELECT] stat
2edf0 65 6d 65 6e 74 2e 20 20 5e 54 68 65 20 73 71 6c ement. ^The sql
2ee00 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 6e 61 6d 65 ite3_column_name
2ee10 28 29 0a 2a 2a 20 69 6e 74 65 72 66 61 63 65 20 ().** interface
2ee20 72 65 74 75 72 6e 73 20 61 20 70 6f 69 6e 74 65 returns a pointe
2ee30 72 20 74 6f 20 61 20 7a 65 72 6f 2d 74 65 72 6d r to a zero-term
2ee40 69 6e 61 74 65 64 20 55 54 46 2d 38 20 73 74 72 inated UTF-8 str
2ee50 69 6e 67 0a 2a 2a 20 61 6e 64 20 73 71 6c 69 74 ing.** and sqlit
2ee60 65 33 5f 63 6f 6c 75 6d 6e 5f 6e 61 6d 65 31 36 e3_column_name16
2ee70 28 29 20 72 65 74 75 72 6e 73 20 61 20 70 6f 69 () returns a poi
2ee80 6e 74 65 72 20 74 6f 20 61 20 7a 65 72 6f 2d 74 nter to a zero-t
2ee90 65 72 6d 69 6e 61 74 65 64 0a 2a 2a 20 55 54 46 erminated.** UTF
2eea0 2d 31 36 20 73 74 72 69 6e 67 2e 20 20 5e 54 68 -16 string. ^Th
2eeb0 65 20 66 69 72 73 74 20 70 61 72 61 6d 65 74 65 e first paramete
2eec0 72 20 69 73 20 74 68 65 20 5b 70 72 65 70 61 72 r is the [prepar
2eed0 65 64 20 73 74 61 74 65 6d 65 6e 74 5d 0a 2a 2a ed statement].**
2eee0 20 74 68 61 74 20 69 6d 70 6c 65 6d 65 6e 74 73 that implements
2eef0 20 74 68 65 20 5b 53 45 4c 45 43 54 5d 20 73 74 the [SELECT] st
2ef00 61 74 65 6d 65 6e 74 2e 20 5e 54 68 65 20 73 65 atement. ^The se
2ef10 63 6f 6e 64 20 70 61 72 61 6d 65 74 65 72 20 69 cond parameter i
2ef20 73 20 74 68 65 0a 2a 2a 20 63 6f 6c 75 6d 6e 20 s the.** column
2ef30 6e 75 6d 62 65 72 2e 20 20 5e 54 68 65 20 6c 65 number. ^The le
2ef40 66 74 6d 6f 73 74 20 63 6f 6c 75 6d 6e 20 69 73 ftmost column is
2ef50 20 6e 75 6d 62 65 72 20 30 2e 0a 2a 2a 0a 2a 2a number 0..**.**
2ef60 20 5e 54 68 65 20 72 65 74 75 72 6e 65 64 20 73 ^The returned s
2ef70 74 72 69 6e 67 20 70 6f 69 6e 74 65 72 20 69 73 tring pointer is
2ef80 20 76 61 6c 69 64 20 75 6e 74 69 6c 20 65 69 74 valid until eit
2ef90 68 65 72 20 74 68 65 20 5b 70 72 65 70 61 72 65 her the [prepare
2efa0 64 20 73 74 61 74 65 6d 65 6e 74 5d 0a 2a 2a 20 d statement].**
2efb0 69 73 20 64 65 73 74 72 6f 79 65 64 20 62 79 20 is destroyed by
2efc0 5b 73 71 6c 69 74 65 33 5f 66 69 6e 61 6c 69 7a [sqlite3_finaliz
2efd0 65 28 29 5d 20 6f 72 20 75 6e 74 69 6c 20 74 68 e()] or until th
2efe0 65 20 73 74 61 74 65 6d 65 6e 74 20 69 73 20 61 e statement is a
2eff0 75 74 6f 6d 61 74 69 63 61 6c 6c 79 0a 2a 2a 20 utomatically.**
2f000 72 65 70 72 65 70 61 72 65 64 20 62 79 20 74 68 reprepared by th
2f010 65 20 66 69 72 73 74 20 63 61 6c 6c 20 74 6f 20 e first call to
2f020 5b 73 71 6c 69 74 65 33 5f 73 74 65 70 28 29 5d [sqlite3_step()]
2f030 20 66 6f 72 20 61 20 70 61 72 74 69 63 75 6c 61 for a particula
2f040 72 20 72 75 6e 0a 2a 2a 20 6f 72 20 75 6e 74 69 r run.** or unti
2f050 6c 20 74 68 65 20 6e 65 78 74 20 63 61 6c 6c 20 l the next call
2f060 74 6f 0a 2a 2a 20 73 71 6c 69 74 65 33 5f 63 6f to.** sqlite3_co
2f070 6c 75 6d 6e 5f 6e 61 6d 65 28 29 20 6f 72 20 73 lumn_name() or s
2f080 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 6e 61 qlite3_column_na
2f090 6d 65 31 36 28 29 20 6f 6e 20 74 68 65 20 73 61 me16() on the sa
2f0a0 6d 65 20 63 6f 6c 75 6d 6e 2e 0a 2a 2a 0a 2a 2a me column..**.**
2f0b0 20 5e 49 66 20 73 71 6c 69 74 65 33 5f 6d 61 6c ^If sqlite3_mal
2f0c0 6c 6f 63 28 29 20 66 61 69 6c 73 20 64 75 72 69 loc() fails duri
2f0d0 6e 67 20 74 68 65 20 70 72 6f 63 65 73 73 69 6e ng the processin
2f0e0 67 20 6f 66 20 65 69 74 68 65 72 20 72 6f 75 74 g of either rout
2f0f0 69 6e 65 0a 2a 2a 20 28 66 6f 72 20 65 78 61 6d ine.** (for exam
2f100 70 6c 65 20 64 75 72 69 6e 67 20 61 20 63 6f 6e ple during a con
2f110 76 65 72 73 69 6f 6e 20 66 72 6f 6d 20 55 54 46 version from UTF
2f120 2d 38 20 74 6f 20 55 54 46 2d 31 36 29 20 74 68 -8 to UTF-16) th
2f130 65 6e 20 61 0a 2a 2a 20 4e 55 4c 4c 20 70 6f 69 en a.** NULL poi
2f140 6e 74 65 72 20 69 73 20 72 65 74 75 72 6e 65 64 nter is returned
2f150 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 6e 61 6d ..**.** ^The nam
2f160 65 20 6f 66 20 61 20 72 65 73 75 6c 74 20 63 6f e of a result co
2f170 6c 75 6d 6e 20 69 73 20 74 68 65 20 76 61 6c 75 lumn is the valu
2f180 65 20 6f 66 20 74 68 65 20 22 41 53 22 20 63 6c e of the "AS" cl
2f190 61 75 73 65 20 66 6f 72 0a 2a 2a 20 74 68 61 74 ause for.** that
2f1a0 20 63 6f 6c 75 6d 6e 2c 20 69 66 20 74 68 65 72 column, if ther
2f1b0 65 20 69 73 20 61 6e 20 41 53 20 63 6c 61 75 73 e is an AS claus
2f1c0 65 2e 20 20 49 66 20 74 68 65 72 65 20 69 73 20 e. If there is
2f1d0 6e 6f 20 41 53 20 63 6c 61 75 73 65 0a 2a 2a 20 no AS clause.**
2f1e0 74 68 65 6e 20 74 68 65 20 6e 61 6d 65 20 6f 66 then the name of
2f1f0 20 74 68 65 20 63 6f 6c 75 6d 6e 20 69 73 20 75 the column is u
2f200 6e 73 70 65 63 69 66 69 65 64 20 61 6e 64 20 6d nspecified and m
2f210 61 79 20 63 68 61 6e 67 65 20 66 72 6f 6d 0a 2a ay change from.*
2f220 2a 20 6f 6e 65 20 72 65 6c 65 61 73 65 20 6f 66 * one release of
2f230 20 53 51 4c 69 74 65 20 74 6f 20 74 68 65 20 6e SQLite to the n
2f240 65 78 74 2e 0a 2a 2f 0a 63 6f 6e 73 74 20 63 68 ext..*/.const ch
2f250 61 72 20 2a 73 71 6c 69 74 65 33 5f 63 6f 6c 75 ar *sqlite3_colu
2f260 6d 6e 5f 6e 61 6d 65 28 73 71 6c 69 74 65 33 5f mn_name(sqlite3_
2f270 73 74 6d 74 2a 2c 20 69 6e 74 20 4e 29 3b 0a 63 stmt*, int N);.c
2f280 6f 6e 73 74 20 76 6f 69 64 20 2a 73 71 6c 69 74 onst void *sqlit
2f290 65 33 5f 63 6f 6c 75 6d 6e 5f 6e 61 6d 65 31 36 e3_column_name16
2f2a0 28 73 71 6c 69 74 65 33 5f 73 74 6d 74 2a 2c 20 (sqlite3_stmt*,
2f2b0 69 6e 74 20 4e 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 int N);../*.** C
2f2c0 41 50 49 33 52 45 46 3a 20 53 6f 75 72 63 65 20 API3REF: Source
2f2d0 4f 66 20 44 61 74 61 20 49 6e 20 41 20 51 75 65 Of Data In A Que
2f2e0 72 79 20 52 65 73 75 6c 74 0a 2a 2a 20 4d 45 54 ry Result.** MET
2f2f0 48 4f 44 3a 20 73 71 6c 69 74 65 33 5f 73 74 6d HOD: sqlite3_stm
2f300 74 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 73 65 20 72 t.**.** ^These r
2f310 6f 75 74 69 6e 65 73 20 70 72 6f 76 69 64 65 20 outines provide
2f320 61 20 6d 65 61 6e 73 20 74 6f 20 64 65 74 65 72 a means to deter
2f330 6d 69 6e 65 20 74 68 65 20 64 61 74 61 62 61 73 mine the databas
2f340 65 2c 20 74 61 62 6c 65 2c 20 61 6e 64 0a 2a 2a e, table, and.**
2f350 20 74 61 62 6c 65 20 63 6f 6c 75 6d 6e 20 74 68 table column th
2f360 61 74 20 69 73 20 74 68 65 20 6f 72 69 67 69 6e at is the origin
2f370 20 6f 66 20 61 20 70 61 72 74 69 63 75 6c 61 72 of a particular
2f380 20 72 65 73 75 6c 74 20 63 6f 6c 75 6d 6e 20 69 result column i
2f390 6e 0a 2a 2a 20 5b 53 45 4c 45 43 54 5d 20 73 74 n.** [SELECT] st
2f3a0 61 74 65 6d 65 6e 74 2e 0a 2a 2a 20 5e 54 68 65 atement..** ^The
2f3b0 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 64 61 74 name of the dat
2f3c0 61 62 61 73 65 20 6f 72 20 74 61 62 6c 65 20 6f abase or table o
2f3d0 72 20 63 6f 6c 75 6d 6e 20 63 61 6e 20 62 65 20 r column can be
2f3e0 72 65 74 75 72 6e 65 64 20 61 73 0a 2a 2a 20 65 returned as.** e
2f3f0 69 74 68 65 72 20 61 20 55 54 46 2d 38 20 6f 72 ither a UTF-8 or
2f400 20 55 54 46 2d 31 36 20 73 74 72 69 6e 67 2e 20 UTF-16 string.
2f410 20 5e 54 68 65 20 5f 64 61 74 61 62 61 73 65 5f ^The _database_
2f420 20 72 6f 75 74 69 6e 65 73 20 72 65 74 75 72 6e routines return
2f430 0a 2a 2a 20 74 68 65 20 64 61 74 61 62 61 73 65 .** the database
2f440 20 6e 61 6d 65 2c 20 74 68 65 20 5f 74 61 62 6c name, the _tabl
2f450 65 5f 20 72 6f 75 74 69 6e 65 73 20 72 65 74 75 e_ routines retu
2f460 72 6e 20 74 68 65 20 74 61 62 6c 65 20 6e 61 6d rn the table nam
2f470 65 2c 20 61 6e 64 0a 2a 2a 20 74 68 65 20 6f 72 e, and.** the or
2f480 69 67 69 6e 5f 20 72 6f 75 74 69 6e 65 73 20 72 igin_ routines r
2f490 65 74 75 72 6e 20 74 68 65 20 63 6f 6c 75 6d 6e eturn the column
2f4a0 20 6e 61 6d 65 2e 0a 2a 2a 20 5e 54 68 65 20 72 name..** ^The r
2f4b0 65 74 75 72 6e 65 64 20 73 74 72 69 6e 67 20 69 eturned string i
2f4c0 73 20 76 61 6c 69 64 20 75 6e 74 69 6c 20 74 68 s valid until th
2f4d0 65 20 5b 70 72 65 70 61 72 65 64 20 73 74 61 74 e [prepared stat
2f4e0 65 6d 65 6e 74 5d 20 69 73 20 64 65 73 74 72 6f ement] is destro
2f4f0 79 65 64 0a 2a 2a 20 75 73 69 6e 67 20 5b 73 71 yed.** using [sq
2f500 6c 69 74 65 33 5f 66 69 6e 61 6c 69 7a 65 28 29 lite3_finalize()
2f510 5d 20 6f 72 20 75 6e 74 69 6c 20 74 68 65 20 73 ] or until the s
2f520 74 61 74 65 6d 65 6e 74 20 69 73 20 61 75 74 6f tatement is auto
2f530 6d 61 74 69 63 61 6c 6c 79 0a 2a 2a 20 72 65 70 matically.** rep
2f540 72 65 70 61 72 65 64 20 62 79 20 74 68 65 20 66 repared by the f
2f550 69 72 73 74 20 63 61 6c 6c 20 74 6f 20 5b 73 71 irst call to [sq
2f560 6c 69 74 65 33 5f 73 74 65 70 28 29 5d 20 66 6f lite3_step()] fo
2f570 72 20 61 20 70 61 72 74 69 63 75 6c 61 72 20 72 r a particular r
2f580 75 6e 0a 2a 2a 20 6f 72 20 75 6e 74 69 6c 20 74 un.** or until t
2f590 68 65 20 73 61 6d 65 20 69 6e 66 6f 72 6d 61 74 he same informat
2f5a0 69 6f 6e 20 69 73 20 72 65 71 75 65 73 74 65 64 ion is requested
2f5b0 0a 2a 2a 20 61 67 61 69 6e 20 69 6e 20 61 20 64 .** again in a d
2f5c0 69 66 66 65 72 65 6e 74 20 65 6e 63 6f 64 69 6e ifferent encodin
2f5d0 67 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 6e 61 g..**.** ^The na
2f5e0 6d 65 73 20 72 65 74 75 72 6e 65 64 20 61 72 65 mes returned are
2f5f0 20 74 68 65 20 6f 72 69 67 69 6e 61 6c 20 75 6e the original un
2f600 2d 61 6c 69 61 73 65 64 20 6e 61 6d 65 73 20 6f -aliased names o
2f610 66 20 74 68 65 0a 2a 2a 20 64 61 74 61 62 61 73 f the.** databas
2f620 65 2c 20 74 61 62 6c 65 2c 20 61 6e 64 20 63 6f e, table, and co
2f630 6c 75 6d 6e 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 lumn..**.** ^The
2f640 20 66 69 72 73 74 20 61 72 67 75 6d 65 6e 74 20 first argument
2f650 74 6f 20 74 68 65 73 65 20 69 6e 74 65 72 66 61 to these interfa
2f660 63 65 73 20 69 73 20 61 20 5b 70 72 65 70 61 72 ces is a [prepar
2f670 65 64 20 73 74 61 74 65 6d 65 6e 74 5d 2e 0a 2a ed statement]..*
2f680 2a 20 5e 54 68 65 73 65 20 66 75 6e 63 74 69 6f * ^These functio
2f690 6e 73 20 72 65 74 75 72 6e 20 69 6e 66 6f 72 6d ns return inform
2f6a0 61 74 69 6f 6e 20 61 62 6f 75 74 20 74 68 65 20 ation about the
2f6b0 4e 74 68 20 72 65 73 75 6c 74 20 63 6f 6c 75 6d Nth result colum
2f6c0 6e 20 72 65 74 75 72 6e 65 64 20 62 79 0a 2a 2a n returned by.**
2f6d0 20 74 68 65 20 73 74 61 74 65 6d 65 6e 74 2c 20 the statement,
2f6e0 77 68 65 72 65 20 4e 20 69 73 20 74 68 65 20 73 where N is the s
2f6f0 65 63 6f 6e 64 20 66 75 6e 63 74 69 6f 6e 20 61 econd function a
2f700 72 67 75 6d 65 6e 74 2e 0a 2a 2a 20 5e 54 68 65 rgument..** ^The
2f710 20 6c 65 66 74 2d 6d 6f 73 74 20 63 6f 6c 75 6d left-most colum
2f720 6e 20 69 73 20 63 6f 6c 75 6d 6e 20 30 20 66 6f n is column 0 fo
2f730 72 20 74 68 65 73 65 20 72 6f 75 74 69 6e 65 73 r these routines
2f740 2e 0a 2a 2a 0a 2a 2a 20 5e 49 66 20 74 68 65 20 ..**.** ^If the
2f750 4e 74 68 20 63 6f 6c 75 6d 6e 20 72 65 74 75 72 Nth column retur
2f760 6e 65 64 20 62 79 20 74 68 65 20 73 74 61 74 65 ned by the state
2f770 6d 65 6e 74 20 69 73 20 61 6e 20 65 78 70 72 65 ment is an expre
2f780 73 73 69 6f 6e 20 6f 72 0a 2a 2a 20 73 75 62 71 ssion or.** subq
2f790 75 65 72 79 20 61 6e 64 20 69 73 20 6e 6f 74 20 uery and is not
2f7a0 61 20 63 6f 6c 75 6d 6e 20 76 61 6c 75 65 2c 20 a column value,
2f7b0 74 68 65 6e 20 61 6c 6c 20 6f 66 20 74 68 65 73 then all of thes
2f7c0 65 20 66 75 6e 63 74 69 6f 6e 73 20 72 65 74 75 e functions retu
2f7d0 72 6e 0a 2a 2a 20 4e 55 4c 4c 2e 20 20 5e 54 68 rn.** NULL. ^Th
2f7e0 65 73 65 20 72 6f 75 74 69 6e 65 20 6d 69 67 68 ese routine migh
2f7f0 74 20 61 6c 73 6f 20 72 65 74 75 72 6e 20 4e 55 t also return NU
2f800 4c 4c 20 69 66 20 61 20 6d 65 6d 6f 72 79 20 61 LL if a memory a
2f810 6c 6c 6f 63 61 74 69 6f 6e 20 65 72 72 6f 72 0a llocation error.
2f820 2a 2a 20 6f 63 63 75 72 73 2e 20 20 5e 4f 74 68 ** occurs. ^Oth
2f830 65 72 77 69 73 65 2c 20 74 68 65 79 20 72 65 74 erwise, they ret
2f840 75 72 6e 20 74 68 65 20 6e 61 6d 65 20 6f 66 20 urn the name of
2f850 74 68 65 20 61 74 74 61 63 68 65 64 20 64 61 74 the attached dat
2f860 61 62 61 73 65 2c 20 74 61 62 6c 65 2c 0a 2a 2a abase, table,.**
2f870 20 6f 72 20 63 6f 6c 75 6d 6e 20 74 68 61 74 20 or column that
2f880 71 75 65 72 79 20 72 65 73 75 6c 74 20 63 6f 6c query result col
2f890 75 6d 6e 20 77 61 73 20 65 78 74 72 61 63 74 65 umn was extracte
2f8a0 64 20 66 72 6f 6d 2e 0a 2a 2a 0a 2a 2a 20 5e 41 d from..**.** ^A
2f8b0 73 20 77 69 74 68 20 61 6c 6c 20 6f 74 68 65 72 s with all other
2f8c0 20 53 51 4c 69 74 65 20 41 50 49 73 2c 20 74 68 SQLite APIs, th
2f8d0 6f 73 65 20 77 68 6f 73 65 20 6e 61 6d 65 73 20 ose whose names
2f8e0 65 6e 64 20 77 69 74 68 20 22 31 36 22 20 72 65 end with "16" re
2f8f0 74 75 72 6e 0a 2a 2a 20 55 54 46 2d 31 36 20 65 turn.** UTF-16 e
2f900 6e 63 6f 64 65 64 20 73 74 72 69 6e 67 73 20 61 ncoded strings a
2f910 6e 64 20 74 68 65 20 6f 74 68 65 72 20 66 75 6e nd the other fun
2f920 63 74 69 6f 6e 73 20 72 65 74 75 72 6e 20 55 54 ctions return UT
2f930 46 2d 38 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 73 F-8..**.** ^Thes
2f940 65 20 41 50 49 73 20 61 72 65 20 6f 6e 6c 79 20 e APIs are only
2f950 61 76 61 69 6c 61 62 6c 65 20 69 66 20 74 68 65 available if the
2f960 20 6c 69 62 72 61 72 79 20 77 61 73 20 63 6f 6d library was com
2f970 70 69 6c 65 64 20 77 69 74 68 20 74 68 65 0a 2a piled with the.*
2f980 2a 20 5b 53 51 4c 49 54 45 5f 45 4e 41 42 4c 45 * [SQLITE_ENABLE
2f990 5f 43 4f 4c 55 4d 4e 5f 4d 45 54 41 44 41 54 41 _COLUMN_METADATA
2f9a0 5d 20 43 2d 70 72 65 70 72 6f 63 65 73 73 6f 72 ] C-preprocessor
2f9b0 20 73 79 6d 62 6f 6c 2e 0a 2a 2a 0a 2a 2a 20 49 symbol..**.** I
2f9c0 66 20 74 77 6f 20 6f 72 20 6d 6f 72 65 20 74 68 f two or more th
2f9d0 72 65 61 64 73 20 63 61 6c 6c 20 6f 6e 65 20 6f reads call one o
2f9e0 72 20 6d 6f 72 65 20 6f 66 20 74 68 65 73 65 20 r more of these
2f9f0 72 6f 75 74 69 6e 65 73 20 61 67 61 69 6e 73 74 routines against
2fa00 20 74 68 65 20 73 61 6d 65 0a 2a 2a 20 70 72 65 the same.** pre
2fa10 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 20 pared statement
2fa20 61 6e 64 20 63 6f 6c 75 6d 6e 20 61 74 20 74 68 and column at th
2fa30 65 20 73 61 6d 65 20 74 69 6d 65 20 74 68 65 6e e same time then
2fa40 20 74 68 65 20 72 65 73 75 6c 74 73 20 61 72 65 the results are
2fa50 0a 2a 2a 20 75 6e 64 65 66 69 6e 65 64 2e 0a 2a .** undefined..*
2fa60 2a 0a 2a 2a 20 49 66 20 74 77 6f 20 6f 72 20 6d *.** If two or m
2fa70 6f 72 65 20 74 68 72 65 61 64 73 20 63 61 6c 6c ore threads call
2fa80 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 0a 2a 2a 20 one or more.**
2fa90 5b 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f [sqlite3_column_
2faa0 64 61 74 61 62 61 73 65 5f 6e 61 6d 65 20 7c 20 database_name |
2fab0 63 6f 6c 75 6d 6e 20 6d 65 74 61 64 61 74 61 20 column metadata
2fac0 69 6e 74 65 72 66 61 63 65 73 5d 0a 2a 2a 20 66 interfaces].** f
2fad0 6f 72 20 74 68 65 20 73 61 6d 65 20 5b 70 72 65 or the same [pre
2fae0 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 5d pared statement]
2faf0 20 61 6e 64 20 72 65 73 75 6c 74 20 63 6f 6c 75 and result colu
2fb00 6d 6e 0a 2a 2a 20 61 74 20 74 68 65 20 73 61 6d mn.** at the sam
2fb10 65 20 74 69 6d 65 20 74 68 65 6e 20 74 68 65 20 e time then the
2fb20 72 65 73 75 6c 74 73 20 61 72 65 20 75 6e 64 65 results are unde
2fb30 66 69 6e 65 64 2e 0a 2a 2f 0a 63 6f 6e 73 74 20 fined..*/.const
2fb40 63 68 61 72 20 2a 73 71 6c 69 74 65 33 5f 63 6f char *sqlite3_co
2fb50 6c 75 6d 6e 5f 64 61 74 61 62 61 73 65 5f 6e 61 lumn_database_na
2fb60 6d 65 28 73 71 6c 69 74 65 33 5f 73 74 6d 74 2a me(sqlite3_stmt*
2fb70 2c 69 6e 74 29 3b 0a 63 6f 6e 73 74 20 76 6f 69 ,int);.const voi
2fb80 64 20 2a 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d d *sqlite3_colum
2fb90 6e 5f 64 61 74 61 62 61 73 65 5f 6e 61 6d 65 31 n_database_name1
2fba0 36 28 73 71 6c 69 74 65 33 5f 73 74 6d 74 2a 2c 6(sqlite3_stmt*,
2fbb0 69 6e 74 29 3b 0a 63 6f 6e 73 74 20 63 68 61 72 int);.const char
2fbc0 20 2a 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e *sqlite3_column
2fbd0 5f 74 61 62 6c 65 5f 6e 61 6d 65 28 73 71 6c 69 _table_name(sqli
2fbe0 74 65 33 5f 73 74 6d 74 2a 2c 69 6e 74 29 3b 0a te3_stmt*,int);.
2fbf0 63 6f 6e 73 74 20 76 6f 69 64 20 2a 73 71 6c 69 const void *sqli
2fc00 74 65 33 5f 63 6f 6c 75 6d 6e 5f 74 61 62 6c 65 te3_column_table
2fc10 5f 6e 61 6d 65 31 36 28 73 71 6c 69 74 65 33 5f _name16(sqlite3_
2fc20 73 74 6d 74 2a 2c 69 6e 74 29 3b 0a 63 6f 6e 73 stmt*,int);.cons
2fc30 74 20 63 68 61 72 20 2a 73 71 6c 69 74 65 33 5f t char *sqlite3_
2fc40 63 6f 6c 75 6d 6e 5f 6f 72 69 67 69 6e 5f 6e 61 column_origin_na
2fc50 6d 65 28 73 71 6c 69 74 65 33 5f 73 74 6d 74 2a me(sqlite3_stmt*
2fc60 2c 69 6e 74 29 3b 0a 63 6f 6e 73 74 20 76 6f 69 ,int);.const voi
2fc70 64 20 2a 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d d *sqlite3_colum
2fc80 6e 5f 6f 72 69 67 69 6e 5f 6e 61 6d 65 31 36 28 n_origin_name16(
2fc90 73 71 6c 69 74 65 33 5f 73 74 6d 74 2a 2c 69 6e sqlite3_stmt*,in
2fca0 74 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 t);../*.** CAPI3
2fcb0 52 45 46 3a 20 44 65 63 6c 61 72 65 64 20 44 61 REF: Declared Da
2fcc0 74 61 74 79 70 65 20 4f 66 20 41 20 51 75 65 72 tatype Of A Quer
2fcd0 79 20 52 65 73 75 6c 74 0a 2a 2a 20 4d 45 54 48 y Result.** METH
2fce0 4f 44 3a 20 73 71 6c 69 74 65 33 5f 73 74 6d 74 OD: sqlite3_stmt
2fcf0 0a 2a 2a 0a 2a 2a 20 5e 28 54 68 65 20 66 69 72 .**.** ^(The fir
2fd00 73 74 20 70 61 72 61 6d 65 74 65 72 20 69 73 20 st parameter is
2fd10 61 20 5b 70 72 65 70 61 72 65 64 20 73 74 61 74 a [prepared stat
2fd20 65 6d 65 6e 74 5d 2e 0a 2a 2a 20 49 66 20 74 68 ement]..** If th
2fd30 69 73 20 73 74 61 74 65 6d 65 6e 74 20 69 73 20 is statement is
2fd40 61 20 5b 53 45 4c 45 43 54 5d 20 73 74 61 74 65 a [SELECT] state
2fd50 6d 65 6e 74 20 61 6e 64 20 74 68 65 20 4e 74 68 ment and the Nth
2fd60 20 63 6f 6c 75 6d 6e 20 6f 66 20 74 68 65 0a 2a column of the.*
2fd70 2a 20 72 65 74 75 72 6e 65 64 20 72 65 73 75 6c * returned resul
2fd80 74 20 73 65 74 20 6f 66 20 74 68 61 74 20 5b 53 t set of that [S
2fd90 45 4c 45 43 54 5d 20 69 73 20 61 20 74 61 62 6c ELECT] is a tabl
2fda0 65 20 63 6f 6c 75 6d 6e 20 28 6e 6f 74 20 61 6e e column (not an
2fdb0 0a 2a 2a 20 65 78 70 72 65 73 73 69 6f 6e 20 6f .** expression o
2fdc0 72 20 73 75 62 71 75 65 72 79 29 20 74 68 65 6e r subquery) then
2fdd0 20 74 68 65 20 64 65 63 6c 61 72 65 64 20 74 79 the declared ty
2fde0 70 65 20 6f 66 20 74 68 65 20 74 61 62 6c 65 0a pe of the table.
2fdf0 2a 2a 20 63 6f 6c 75 6d 6e 20 69 73 20 72 65 74 ** column is ret
2fe00 75 72 6e 65 64 2e 29 5e 20 20 5e 49 66 20 74 68 urned.)^ ^If th
2fe10 65 20 4e 74 68 20 63 6f 6c 75 6d 6e 20 6f 66 20 e Nth column of
2fe20 74 68 65 20 72 65 73 75 6c 74 20 73 65 74 20 69 the result set i
2fe30 73 20 61 6e 0a 2a 2a 20 65 78 70 72 65 73 73 69 s an.** expressi
2fe40 6f 6e 20 6f 72 20 73 75 62 71 75 65 72 79 2c 20 on or subquery,
2fe50 74 68 65 6e 20 61 20 4e 55 4c 4c 20 70 6f 69 6e then a NULL poin
2fe60 74 65 72 20 69 73 20 72 65 74 75 72 6e 65 64 2e ter is returned.
2fe70 0a 2a 2a 20 5e 54 68 65 20 72 65 74 75 72 6e 65 .** ^The returne
2fe80 64 20 73 74 72 69 6e 67 20 69 73 20 61 6c 77 61 d string is alwa
2fe90 79 73 20 55 54 46 2d 38 20 65 6e 63 6f 64 65 64 ys UTF-8 encoded
2fea0 2e 0a 2a 2a 0a 2a 2a 20 5e 28 46 6f 72 20 65 78 ..**.** ^(For ex
2feb0 61 6d 70 6c 65 2c 20 67 69 76 65 6e 20 74 68 65 ample, given the
2fec0 20 64 61 74 61 62 61 73 65 20 73 63 68 65 6d 61 database schema
2fed0 3a 0a 2a 2a 0a 2a 2a 20 43 52 45 41 54 45 20 54 :.**.** CREATE T
2fee0 41 42 4c 45 20 74 31 28 63 31 20 56 41 52 49 41 ABLE t1(c1 VARIA
2fef0 4e 54 29 3b 0a 2a 2a 0a 2a 2a 20 61 6e 64 20 74 NT);.**.** and t
2ff00 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 73 74 61 he following sta
2ff10 74 65 6d 65 6e 74 20 74 6f 20 62 65 20 63 6f 6d tement to be com
2ff20 70 69 6c 65 64 3a 0a 2a 2a 0a 2a 2a 20 53 45 4c piled:.**.** SEL
2ff30 45 43 54 20 63 31 20 2b 20 31 2c 20 63 31 20 46 ECT c1 + 1, c1 F
2ff40 52 4f 4d 20 74 31 3b 0a 2a 2a 0a 2a 2a 20 74 68 ROM t1;.**.** th
2ff50 69 73 20 72 6f 75 74 69 6e 65 20 77 6f 75 6c 64 is routine would
2ff60 20 72 65 74 75 72 6e 20 74 68 65 20 73 74 72 69 return the stri
2ff70 6e 67 20 22 56 41 52 49 41 4e 54 22 20 66 6f 72 ng "VARIANT" for
2ff80 20 74 68 65 20 73 65 63 6f 6e 64 20 72 65 73 75 the second resu
2ff90 6c 74 0a 2a 2a 20 63 6f 6c 75 6d 6e 20 28 69 3d lt.** column (i=
2ffa0 3d 31 29 2c 20 61 6e 64 20 61 20 4e 55 4c 4c 20 =1), and a NULL
2ffb0 70 6f 69 6e 74 65 72 20 66 6f 72 20 74 68 65 20 pointer for the
2ffc0 66 69 72 73 74 20 72 65 73 75 6c 74 20 63 6f 6c first result col
2ffd0 75 6d 6e 20 28 69 3d 3d 30 29 2e 29 5e 0a 2a 2a umn (i==0).)^.**
2ffe0 0a 2a 2a 20 5e 53 51 4c 69 74 65 20 75 73 65 73 .** ^SQLite uses
2fff0 20 64 79 6e 61 6d 69 63 20 72 75 6e 2d 74 69 6d dynamic run-tim
30000 65 20 74 79 70 69 6e 67 2e 20 20 5e 53 6f 20 6a e typing. ^So j
30010 75 73 74 20 62 65 63 61 75 73 65 20 61 20 63 6f ust because a co
30020 6c 75 6d 6e 0a 2a 2a 20 69 73 20 64 65 63 6c 61 lumn.** is decla
30030 72 65 64 20 74 6f 20 63 6f 6e 74 61 69 6e 20 61 red to contain a
30040 20 70 61 72 74 69 63 75 6c 61 72 20 74 79 70 65 particular type
30050 20 64 6f 65 73 20 6e 6f 74 20 6d 65 61 6e 20 74 does not mean t
30060 68 61 74 20 74 68 65 0a 2a 2a 20 64 61 74 61 20 hat the.** data
30070 73 74 6f 72 65 64 20 69 6e 20 74 68 61 74 20 63 stored in that c
30080 6f 6c 75 6d 6e 20 69 73 20 6f 66 20 74 68 65 20 olumn is of the
30090 64 65 63 6c 61 72 65 64 20 74 79 70 65 2e 20 20 declared type.
300a0 53 51 4c 69 74 65 20 69 73 0a 2a 2a 20 73 74 72 SQLite is.** str
300b0 6f 6e 67 6c 79 20 74 79 70 65 64 2c 20 62 75 74 ongly typed, but
300c0 20 74 68 65 20 74 79 70 69 6e 67 20 69 73 20 64 the typing is d
300d0 79 6e 61 6d 69 63 20 6e 6f 74 20 73 74 61 74 69 ynamic not stati
300e0 63 2e 20 20 5e 54 79 70 65 0a 2a 2a 20 69 73 20 c. ^Type.** is
300f0 61 73 73 6f 63 69 61 74 65 64 20 77 69 74 68 20 associated with
30100 69 6e 64 69 76 69 64 75 61 6c 20 76 61 6c 75 65 individual value
30110 73 2c 20 6e 6f 74 20 77 69 74 68 20 74 68 65 20 s, not with the
30120 63 6f 6e 74 61 69 6e 65 72 73 0a 2a 2a 20 75 73 containers.** us
30130 65 64 20 74 6f 20 68 6f 6c 64 20 74 68 6f 73 65 ed to hold those
30140 20 76 61 6c 75 65 73 2e 0a 2a 2f 0a 63 6f 6e 73 values..*/.cons
30150 74 20 63 68 61 72 20 2a 73 71 6c 69 74 65 33 5f t char *sqlite3_
30160 63 6f 6c 75 6d 6e 5f 64 65 63 6c 74 79 70 65 28 column_decltype(
30170 73 71 6c 69 74 65 33 5f 73 74 6d 74 2a 2c 69 6e sqlite3_stmt*,in
30180 74 29 3b 0a 63 6f 6e 73 74 20 76 6f 69 64 20 2a t);.const void *
30190 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 64 sqlite3_column_d
301a0 65 63 6c 74 79 70 65 31 36 28 73 71 6c 69 74 65 ecltype16(sqlite
301b0 33 5f 73 74 6d 74 2a 2c 69 6e 74 29 3b 0a 0a 2f 3_stmt*,int);../
301c0 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 45 *.** CAPI3REF: E
301d0 76 61 6c 75 61 74 65 20 41 6e 20 53 51 4c 20 53 valuate An SQL S
301e0 74 61 74 65 6d 65 6e 74 0a 2a 2a 20 4d 45 54 48 tatement.** METH
301f0 4f 44 3a 20 73 71 6c 69 74 65 33 5f 73 74 6d 74 OD: sqlite3_stmt
30200 0a 2a 2a 0a 2a 2a 20 41 66 74 65 72 20 61 20 5b .**.** After a [
30210 70 72 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 prepared stateme
30220 6e 74 5d 20 68 61 73 20 62 65 65 6e 20 70 72 65 nt] has been pre
30230 70 61 72 65 64 20 75 73 69 6e 67 20 65 69 74 68 pared using eith
30240 65 72 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 70 er.** [sqlite3_p
30250 72 65 70 61 72 65 5f 76 32 28 29 5d 20 6f 72 20 repare_v2()] or
30260 5b 73 71 6c 69 74 65 33 5f 70 72 65 70 61 72 65 [sqlite3_prepare
30270 31 36 5f 76 32 28 29 5d 20 6f 72 20 6f 6e 65 20 16_v2()] or one
30280 6f 66 20 74 68 65 20 6c 65 67 61 63 79 0a 2a 2a of the legacy.**
30290 20 69 6e 74 65 72 66 61 63 65 73 20 5b 73 71 6c interfaces [sql
302a0 69 74 65 33 5f 70 72 65 70 61 72 65 28 29 5d 20 ite3_prepare()]
302b0 6f 72 20 5b 73 71 6c 69 74 65 33 5f 70 72 65 70 or [sqlite3_prep
302c0 61 72 65 31 36 28 29 5d 2c 20 74 68 69 73 20 66 are16()], this f
302d0 75 6e 63 74 69 6f 6e 0a 2a 2a 20 6d 75 73 74 20 unction.** must
302e0 62 65 20 63 61 6c 6c 65 64 20 6f 6e 65 20 6f 72 be called one or
302f0 20 6d 6f 72 65 20 74 69 6d 65 73 20 74 6f 20 65 more times to e
30300 76 61 6c 75 61 74 65 20 74 68 65 20 73 74 61 74 valuate the stat
30310 65 6d 65 6e 74 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 ement..**.** The
30320 20 64 65 74 61 69 6c 73 20 6f 66 20 74 68 65 20 details of the
30330 62 65 68 61 76 69 6f 72 20 6f 66 20 74 68 65 20 behavior of the
30340 73 71 6c 69 74 65 33 5f 73 74 65 70 28 29 20 69 sqlite3_step() i
30350 6e 74 65 72 66 61 63 65 20 64 65 70 65 6e 64 0a nterface depend.
30360 2a 2a 20 6f 6e 20 77 68 65 74 68 65 72 20 74 68 ** on whether th
30370 65 20 73 74 61 74 65 6d 65 6e 74 20 77 61 73 20 e statement was
30380 70 72 65 70 61 72 65 64 20 75 73 69 6e 67 20 74 prepared using t
30390 68 65 20 6e 65 77 65 72 20 22 76 32 22 20 69 6e he newer "v2" in
303a0 74 65 72 66 61 63 65 0a 2a 2a 20 5b 73 71 6c 69 terface.** [sqli
303b0 74 65 33 5f 70 72 65 70 61 72 65 5f 76 32 28 29 te3_prepare_v2()
303c0 5d 20 61 6e 64 20 5b 73 71 6c 69 74 65 33 5f 70 ] and [sqlite3_p
303d0 72 65 70 61 72 65 31 36 5f 76 32 28 29 5d 20 6f repare16_v2()] o
303e0 72 20 74 68 65 20 6f 6c 64 65 72 20 6c 65 67 61 r the older lega
303f0 63 79 0a 2a 2a 20 69 6e 74 65 72 66 61 63 65 20 cy.** interface
30400 5b 73 71 6c 69 74 65 33 5f 70 72 65 70 61 72 65 [sqlite3_prepare
30410 28 29 5d 20 61 6e 64 20 5b 73 71 6c 69 74 65 33 ()] and [sqlite3
30420 5f 70 72 65 70 61 72 65 31 36 28 29 5d 2e 20 20 _prepare16()].
30430 54 68 65 20 75 73 65 20 6f 66 20 74 68 65 0a 2a The use of the.*
30440 2a 20 6e 65 77 20 22 76 32 22 20 69 6e 74 65 72 * new "v2" inter
30450 66 61 63 65 20 69 73 20 72 65 63 6f 6d 6d 65 6e face is recommen
30460 64 65 64 20 66 6f 72 20 6e 65 77 20 61 70 70 6c ded for new appl
30470 69 63 61 74 69 6f 6e 73 20 62 75 74 20 74 68 65 ications but the
30480 20 6c 65 67 61 63 79 0a 2a 2a 20 69 6e 74 65 72 legacy.** inter
30490 66 61 63 65 20 77 69 6c 6c 20 63 6f 6e 74 69 6e face will contin
304a0 75 65 20 74 6f 20 62 65 20 73 75 70 70 6f 72 74 ue to be support
304b0 65 64 2e 0a 2a 2a 0a 2a 2a 20 5e 49 6e 20 74 68 ed..**.** ^In th
304c0 65 20 6c 65 67 61 63 79 20 69 6e 74 65 72 66 61 e legacy interfa
304d0 63 65 2c 20 74 68 65 20 72 65 74 75 72 6e 20 76 ce, the return v
304e0 61 6c 75 65 20 77 69 6c 6c 20 62 65 20 65 69 74 alue will be eit
304f0 68 65 72 20 5b 53 51 4c 49 54 45 5f 42 55 53 59 her [SQLITE_BUSY
30500 5d 2c 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f 44 4f ],.** [SQLITE_DO
30510 4e 45 5d 2c 20 5b 53 51 4c 49 54 45 5f 52 4f 57 NE], [SQLITE_ROW
30520 5d 2c 20 5b 53 51 4c 49 54 45 5f 45 52 52 4f 52 ], [SQLITE_ERROR
30530 5d 2c 20 6f 72 20 5b 53 51 4c 49 54 45 5f 4d 49 ], or [SQLITE_MI
30540 53 55 53 45 5d 2e 0a 2a 2a 20 5e 57 69 74 68 20 SUSE]..** ^With
30550 74 68 65 20 22 76 32 22 20 69 6e 74 65 72 66 61 the "v2" interfa
30560 63 65 2c 20 61 6e 79 20 6f 66 20 74 68 65 20 6f ce, any of the o
30570 74 68 65 72 20 5b 72 65 73 75 6c 74 20 63 6f 64 ther [result cod
30580 65 73 5d 20 6f 72 0a 2a 2a 20 5b 65 78 74 65 6e es] or.** [exten
30590 64 65 64 20 72 65 73 75 6c 74 20 63 6f 64 65 73 ded result codes
305a0 5d 20 6d 69 67 68 74 20 62 65 20 72 65 74 75 72 ] might be retur
305b0 6e 65 64 20 61 73 20 77 65 6c 6c 2e 0a 2a 2a 0a ned as well..**.
305c0 2a 2a 20 5e 5b 53 51 4c 49 54 45 5f 42 55 53 59 ** ^[SQLITE_BUSY
305d0 5d 20 6d 65 61 6e 73 20 74 68 61 74 20 74 68 65 ] means that the
305e0 20 64 61 74 61 62 61 73 65 20 65 6e 67 69 6e 65 database engine
305f0 20 77 61 73 20 75 6e 61 62 6c 65 20 74 6f 20 61 was unable to a
30600 63 71 75 69 72 65 20 74 68 65 0a 2a 2a 20 64 61 cquire the.** da
30610 74 61 62 61 73 65 20 6c 6f 63 6b 73 20 69 74 20 tabase locks it
30620 6e 65 65 64 73 20 74 6f 20 64 6f 20 69 74 73 20 needs to do its
30630 6a 6f 62 2e 20 20 5e 49 66 20 74 68 65 20 73 74 job. ^If the st
30640 61 74 65 6d 65 6e 74 20 69 73 20 61 20 5b 43 4f atement is a [CO
30650 4d 4d 49 54 5d 0a 2a 2a 20 6f 72 20 6f 63 63 75 MMIT].** or occu
30660 72 73 20 6f 75 74 73 69 64 65 20 6f 66 20 61 6e rs outside of an
30670 20 65 78 70 6c 69 63 69 74 20 74 72 61 6e 73 61 explicit transa
30680 63 74 69 6f 6e 2c 20 74 68 65 6e 20 79 6f 75 20 ction, then you
30690 63 61 6e 20 72 65 74 72 79 20 74 68 65 0a 2a 2a can retry the.**
306a0 20 73 74 61 74 65 6d 65 6e 74 2e 20 20 49 66 20 statement. If
306b0 74 68 65 20 73 74 61 74 65 6d 65 6e 74 20 69 73 the statement is
306c0 20 6e 6f 74 20 61 20 5b 43 4f 4d 4d 49 54 5d 20 not a [COMMIT]
306d0 61 6e 64 20 6f 63 63 75 72 73 20 77 69 74 68 69 and occurs withi
306e0 6e 20 61 6e 0a 2a 2a 20 65 78 70 6c 69 63 69 74 n an.** explicit
306f0 20 74 72 61 6e 73 61 63 74 69 6f 6e 20 74 68 65 transaction the
30700 6e 20 79 6f 75 20 73 68 6f 75 6c 64 20 72 6f 6c n you should rol
30710 6c 62 61 63 6b 20 74 68 65 20 74 72 61 6e 73 61 lback the transa
30720 63 74 69 6f 6e 20 62 65 66 6f 72 65 0a 2a 2a 20 ction before.**
30730 63 6f 6e 74 69 6e 75 69 6e 67 2e 0a 2a 2a 0a 2a continuing..**.*
30740 2a 20 5e 5b 53 51 4c 49 54 45 5f 44 4f 4e 45 5d * ^[SQLITE_DONE]
30750 20 6d 65 61 6e 73 20 74 68 61 74 20 74 68 65 20 means that the
30760 73 74 61 74 65 6d 65 6e 74 20 68 61 73 20 66 69 statement has fi
30770 6e 69 73 68 65 64 20 65 78 65 63 75 74 69 6e 67 nished executing
30780 0a 2a 2a 20 73 75 63 63 65 73 73 66 75 6c 6c 79 .** successfully
30790 2e 20 20 73 71 6c 69 74 65 33 5f 73 74 65 70 28 . sqlite3_step(
307a0 29 20 73 68 6f 75 6c 64 20 6e 6f 74 20 62 65 20 ) should not be
307b0 63 61 6c 6c 65 64 20 61 67 61 69 6e 20 6f 6e 20 called again on
307c0 74 68 69 73 20 76 69 72 74 75 61 6c 0a 2a 2a 20 this virtual.**
307d0 6d 61 63 68 69 6e 65 20 77 69 74 68 6f 75 74 20 machine without
307e0 66 69 72 73 74 20 63 61 6c 6c 69 6e 67 20 5b 73 first calling [s
307f0 71 6c 69 74 65 33 5f 72 65 73 65 74 28 29 5d 20 qlite3_reset()]
30800 74 6f 20 72 65 73 65 74 20 74 68 65 20 76 69 72 to reset the vir
30810 74 75 61 6c 0a 2a 2a 20 6d 61 63 68 69 6e 65 20 tual.** machine
30820 62 61 63 6b 20 74 6f 20 69 74 73 20 69 6e 69 74 back to its init
30830 69 61 6c 20 73 74 61 74 65 2e 0a 2a 2a 0a 2a 2a ial state..**.**
30840 20 5e 49 66 20 74 68 65 20 53 51 4c 20 73 74 61 ^If the SQL sta
30850 74 65 6d 65 6e 74 20 62 65 69 6e 67 20 65 78 65 tement being exe
30860 63 75 74 65 64 20 72 65 74 75 72 6e 73 20 61 6e cuted returns an
30870 79 20 64 61 74 61 2c 20 74 68 65 6e 20 5b 53 51 y data, then [SQ
30880 4c 49 54 45 5f 52 4f 57 5d 0a 2a 2a 20 69 73 20 LITE_ROW].** is
30890 72 65 74 75 72 6e 65 64 20 65 61 63 68 20 74 69 returned each ti
308a0 6d 65 20 61 20 6e 65 77 20 72 6f 77 20 6f 66 20 me a new row of
308b0 64 61 74 61 20 69 73 20 72 65 61 64 79 20 66 6f data is ready fo
308c0 72 20 70 72 6f 63 65 73 73 69 6e 67 20 62 79 20 r processing by
308d0 74 68 65 0a 2a 2a 20 63 61 6c 6c 65 72 2e 20 54 the.** caller. T
308e0 68 65 20 76 61 6c 75 65 73 20 6d 61 79 20 62 65 he values may be
308f0 20 61 63 63 65 73 73 65 64 20 75 73 69 6e 67 20 accessed using
30900 74 68 65 20 5b 63 6f 6c 75 6d 6e 20 61 63 63 65 the [column acce
30910 73 73 20 66 75 6e 63 74 69 6f 6e 73 5d 2e 0a 2a ss functions]..*
30920 2a 20 73 71 6c 69 74 65 33 5f 73 74 65 70 28 29 * sqlite3_step()
30930 20 69 73 20 63 61 6c 6c 65 64 20 61 67 61 69 6e is called again
30940 20 74 6f 20 72 65 74 72 69 65 76 65 20 74 68 65 to retrieve the
30950 20 6e 65 78 74 20 72 6f 77 20 6f 66 20 64 61 74 next row of dat
30960 61 2e 0a 2a 2a 0a 2a 2a 20 5e 5b 53 51 4c 49 54 a..**.** ^[SQLIT
30970 45 5f 45 52 52 4f 52 5d 20 6d 65 61 6e 73 20 74 E_ERROR] means t
30980 68 61 74 20 61 20 72 75 6e 2d 74 69 6d 65 20 65 hat a run-time e
30990 72 72 6f 72 20 28 73 75 63 68 20 61 73 20 61 20 rror (such as a
309a0 63 6f 6e 73 74 72 61 69 6e 74 0a 2a 2a 20 76 69 constraint.** vi
309b0 6f 6c 61 74 69 6f 6e 29 20 68 61 73 20 6f 63 63 olation) has occ
309c0 75 72 72 65 64 2e 20 20 73 71 6c 69 74 65 33 5f urred. sqlite3_
309d0 73 74 65 70 28 29 20 73 68 6f 75 6c 64 20 6e 6f step() should no
309e0 74 20 62 65 20 63 61 6c 6c 65 64 20 61 67 61 69 t be called agai
309f0 6e 20 6f 6e 0a 2a 2a 20 74 68 65 20 56 4d 2e 20 n on.** the VM.
30a00 4d 6f 72 65 20 69 6e 66 6f 72 6d 61 74 69 6f 6e More information
30a10 20 6d 61 79 20 62 65 20 66 6f 75 6e 64 20 62 79 may be found by
30a20 20 63 61 6c 6c 69 6e 67 20 5b 73 71 6c 69 74 65 calling [sqlite
30a30 33 5f 65 72 72 6d 73 67 28 29 5d 2e 0a 2a 2a 20 3_errmsg()]..**
30a40 5e 57 69 74 68 20 74 68 65 20 6c 65 67 61 63 79 ^With the legacy
30a50 20 69 6e 74 65 72 66 61 63 65 2c 20 61 20 6d 6f interface, a mo
30a60 72 65 20 73 70 65 63 69 66 69 63 20 65 72 72 6f re specific erro
30a70 72 20 63 6f 64 65 20 28 66 6f 72 20 65 78 61 6d r code (for exam
30a80 70 6c 65 2c 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f ple,.** [SQLITE_
30a90 49 4e 54 45 52 52 55 50 54 5d 2c 20 5b 53 51 4c INTERRUPT], [SQL
30aa0 49 54 45 5f 53 43 48 45 4d 41 5d 2c 20 5b 53 51 ITE_SCHEMA], [SQ
30ab0 4c 49 54 45 5f 43 4f 52 52 55 50 54 5d 2c 20 61 LITE_CORRUPT], a
30ac0 6e 64 20 73 6f 20 66 6f 72 74 68 29 0a 2a 2a 20 nd so forth).**
30ad0 63 61 6e 20 62 65 20 6f 62 74 61 69 6e 65 64 20 can be obtained
30ae0 62 79 20 63 61 6c 6c 69 6e 67 20 5b 73 71 6c 69 by calling [sqli
30af0 74 65 33 5f 72 65 73 65 74 28 29 5d 20 6f 6e 20 te3_reset()] on
30b00 74 68 65 0a 2a 2a 20 5b 70 72 65 70 61 72 65 64 the.** [prepared
30b10 20 73 74 61 74 65 6d 65 6e 74 5d 2e 20 20 5e 49 statement]. ^I
30b20 6e 20 74 68 65 20 22 76 32 22 20 69 6e 74 65 72 n the "v2" inter
30b30 66 61 63 65 2c 0a 2a 2a 20 74 68 65 20 6d 6f 72 face,.** the mor
30b40 65 20 73 70 65 63 69 66 69 63 20 65 72 72 6f 72 e specific error
30b50 20 63 6f 64 65 20 69 73 20 72 65 74 75 72 6e 65 code is returne
30b60 64 20 64 69 72 65 63 74 6c 79 20 62 79 20 73 71 d directly by sq
30b70 6c 69 74 65 33 5f 73 74 65 70 28 29 2e 0a 2a 2a lite3_step()..**
30b80 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f 4d 49 53 55 .** [SQLITE_MISU
30b90 53 45 5d 20 6d 65 61 6e 73 20 74 68 61 74 20 74 SE] means that t
30ba0 68 65 20 74 68 69 73 20 72 6f 75 74 69 6e 65 20 he this routine
30bb0 77 61 73 20 63 61 6c 6c 65 64 20 69 6e 61 70 70 was called inapp
30bc0 72 6f 70 72 69 61 74 65 6c 79 2e 0a 2a 2a 20 50 ropriately..** P
30bd0 65 72 68 61 70 73 20 69 74 20 77 61 73 20 63 61 erhaps it was ca
30be0 6c 6c 65 64 20 6f 6e 20 61 20 5b 70 72 65 70 61 lled on a [prepa
30bf0 72 65 64 20 73 74 61 74 65 6d 65 6e 74 5d 20 74 red statement] t
30c00 68 61 74 20 68 61 73 0a 2a 2a 20 61 6c 72 65 61 hat has.** alrea
30c10 64 79 20 62 65 65 6e 20 5b 73 71 6c 69 74 65 33 dy been [sqlite3
30c20 5f 66 69 6e 61 6c 69 7a 65 20 7c 20 66 69 6e 61 _finalize | fina
30c30 6c 69 7a 65 64 5d 20 6f 72 20 6f 6e 20 6f 6e 65 lized] or on one
30c40 20 74 68 61 74 20 68 61 64 0a 2a 2a 20 70 72 65 that had.** pre
30c50 76 69 6f 75 73 6c 79 20 72 65 74 75 72 6e 65 64 viously returned
30c60 20 5b 53 51 4c 49 54 45 5f 45 52 52 4f 52 5d 20 [SQLITE_ERROR]
30c70 6f 72 20 5b 53 51 4c 49 54 45 5f 44 4f 4e 45 5d or [SQLITE_DONE]
30c80 2e 20 20 4f 72 20 69 74 20 63 6f 75 6c 64 0a 2a . Or it could.*
30c90 2a 20 62 65 20 74 68 65 20 63 61 73 65 20 74 68 * be the case th
30ca0 61 74 20 74 68 65 20 73 61 6d 65 20 64 61 74 61 at the same data
30cb0 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 base connection
30cc0 69 73 20 62 65 69 6e 67 20 75 73 65 64 20 62 79 is being used by
30cd0 20 74 77 6f 20 6f 72 0a 2a 2a 20 6d 6f 72 65 20 two or.** more
30ce0 74 68 72 65 61 64 73 20 61 74 20 74 68 65 20 73 threads at the s
30cf0 61 6d 65 20 6d 6f 6d 65 6e 74 20 69 6e 20 74 69 ame moment in ti
30d00 6d 65 2e 0a 2a 2a 0a 2a 2a 20 46 6f 72 20 61 6c me..**.** For al
30d10 6c 20 76 65 72 73 69 6f 6e 73 20 6f 66 20 53 51 l versions of SQ
30d20 4c 69 74 65 20 75 70 20 74 6f 20 61 6e 64 20 69 Lite up to and i
30d30 6e 63 6c 75 64 69 6e 67 20 33 2e 36 2e 32 33 2e ncluding 3.6.23.
30d40 31 2c 20 61 20 63 61 6c 6c 20 74 6f 0a 2a 2a 20 1, a call to.**
30d50 5b 73 71 6c 69 74 65 33 5f 72 65 73 65 74 28 29 [sqlite3_reset()
30d60 5d 20 77 61 73 20 72 65 71 75 69 72 65 64 20 61 ] was required a
30d70 66 74 65 72 20 73 71 6c 69 74 65 33 5f 73 74 65 fter sqlite3_ste
30d80 70 28 29 20 72 65 74 75 72 6e 65 64 20 61 6e 79 p() returned any
30d90 74 68 69 6e 67 0a 2a 2a 20 6f 74 68 65 72 20 74 thing.** other t
30da0 68 61 6e 20 5b 53 51 4c 49 54 45 5f 52 4f 57 5d han [SQLITE_ROW]
30db0 20 62 65 66 6f 72 65 20 61 6e 79 20 73 75 62 73 before any subs
30dc0 65 71 75 65 6e 74 20 69 6e 76 6f 63 61 74 69 6f equent invocatio
30dd0 6e 20 6f 66 0a 2a 2a 20 73 71 6c 69 74 65 33 5f n of.** sqlite3_
30de0 73 74 65 70 28 29 2e 20 20 46 61 69 6c 75 72 65 step(). Failure
30df0 20 74 6f 20 72 65 73 65 74 20 74 68 65 20 70 72 to reset the pr
30e00 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 epared statement
30e10 20 75 73 69 6e 67 20 0a 2a 2a 20 5b 73 71 6c 69 using .** [sqli
30e20 74 65 33 5f 72 65 73 65 74 28 29 5d 20 77 6f 75 te3_reset()] wou
30e30 6c 64 20 72 65 73 75 6c 74 20 69 6e 20 61 6e 20 ld result in an
30e40 5b 53 51 4c 49 54 45 5f 4d 49 53 55 53 45 5d 20 [SQLITE_MISUSE]
30e50 72 65 74 75 72 6e 20 66 72 6f 6d 0a 2a 2a 20 73 return from.** s
30e60 71 6c 69 74 65 33 5f 73 74 65 70 28 29 2e 20 20 qlite3_step().
30e70 42 75 74 20 61 66 74 65 72 20 5b 76 65 72 73 69 But after [versi
30e80 6f 6e 20 33 2e 36 2e 32 33 2e 31 5d 20 28 5b 64 on 3.6.23.1] ([d
30e90 61 74 65 6f 66 3a 33 2e 36 2e 32 33 2e 31 5d 2c ateof:3.6.23.1],
30ea0 0a 2a 2a 20 73 71 6c 69 74 65 33 5f 73 74 65 70 .** sqlite3_step
30eb0 28 29 20 62 65 67 61 6e 0a 2a 2a 20 63 61 6c 6c () began.** call
30ec0 69 6e 67 20 5b 73 71 6c 69 74 65 33 5f 72 65 73 ing [sqlite3_res
30ed0 65 74 28 29 5d 20 61 75 74 6f 6d 61 74 69 63 61 et()] automatica
30ee0 6c 6c 79 20 69 6e 20 74 68 69 73 20 63 69 72 63 lly in this circ
30ef0 75 6d 73 74 61 6e 63 65 20 72 61 74 68 65 72 0a umstance rather.
30f00 2a 2a 20 74 68 61 6e 20 72 65 74 75 72 6e 69 6e ** than returnin
30f10 67 20 5b 53 51 4c 49 54 45 5f 4d 49 53 55 53 45 g [SQLITE_MISUSE
30f20 5d 2e 20 20 54 68 69 73 20 69 73 20 6e 6f 74 20 ]. This is not
30f30 63 6f 6e 73 69 64 65 72 65 64 20 61 20 63 6f 6d considered a com
30f40 70 61 74 69 62 69 6c 69 74 79 0a 2a 2a 20 62 72 patibility.** br
30f50 65 61 6b 20 62 65 63 61 75 73 65 20 61 6e 79 20 eak because any
30f60 61 70 70 6c 69 63 61 74 69 6f 6e 20 74 68 61 74 application that
30f70 20 65 76 65 72 20 72 65 63 65 69 76 65 73 20 61 ever receives a
30f80 6e 20 53 51 4c 49 54 45 5f 4d 49 53 55 53 45 20 n SQLITE_MISUSE
30f90 65 72 72 6f 72 0a 2a 2a 20 69 73 20 62 72 6f 6b error.** is brok
30fa0 65 6e 20 62 79 20 64 65 66 69 6e 69 74 69 6f 6e en by definition
30fb0 2e 20 20 54 68 65 20 5b 53 51 4c 49 54 45 5f 4f . The [SQLITE_O
30fc0 4d 49 54 5f 41 55 54 4f 52 45 53 45 54 5d 20 63 MIT_AUTORESET] c
30fd0 6f 6d 70 69 6c 65 2d 74 69 6d 65 20 6f 70 74 69 ompile-time opti
30fe0 6f 6e 0a 2a 2a 20 63 61 6e 20 62 65 20 75 73 65 on.** can be use
30ff0 64 20 74 6f 20 72 65 73 74 6f 72 65 20 74 68 65 d to restore the
31000 20 6c 65 67 61 63 79 20 62 65 68 61 76 69 6f 72 legacy behavior
31010 2e 0a 2a 2a 0a 2a 2a 20 3c 62 3e 47 6f 6f 66 79 ..**.** <b>Goofy
31020 20 49 6e 74 65 72 66 61 63 65 20 41 6c 65 72 74 Interface Alert
31030 3a 3c 2f 62 3e 20 49 6e 20 74 68 65 20 6c 65 67 :</b> In the leg
31040 61 63 79 20 69 6e 74 65 72 66 61 63 65 2c 20 74 acy interface, t
31050 68 65 20 73 71 6c 69 74 65 33 5f 73 74 65 70 28 he sqlite3_step(
31060 29 0a 2a 2a 20 41 50 49 20 61 6c 77 61 79 73 20 ).** API always
31070 72 65 74 75 72 6e 73 20 61 20 67 65 6e 65 72 69 returns a generi
31080 63 20 65 72 72 6f 72 20 63 6f 64 65 2c 20 5b 53 c error code, [S
31090 51 4c 49 54 45 5f 45 52 52 4f 52 5d 2c 20 66 6f QLITE_ERROR], fo
310a0 6c 6c 6f 77 69 6e 67 20 61 6e 79 0a 2a 2a 20 65 llowing any.** e
310b0 72 72 6f 72 20 6f 74 68 65 72 20 74 68 61 6e 20 rror other than
310c0 5b 53 51 4c 49 54 45 5f 42 55 53 59 5d 20 61 6e [SQLITE_BUSY] an
310d0 64 20 5b 53 51 4c 49 54 45 5f 4d 49 53 55 53 45 d [SQLITE_MISUSE
310e0 5d 2e 20 20 59 6f 75 20 6d 75 73 74 20 63 61 6c ]. You must cal
310f0 6c 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 72 65 l.** [sqlite3_re
31100 73 65 74 28 29 5d 20 6f 72 20 5b 73 71 6c 69 74 set()] or [sqlit
31110 65 33 5f 66 69 6e 61 6c 69 7a 65 28 29 5d 20 69 e3_finalize()] i
31120 6e 20 6f 72 64 65 72 20 74 6f 20 66 69 6e 64 20 n order to find
31130 6f 6e 65 20 6f 66 20 74 68 65 0a 2a 2a 20 73 70 one of the.** sp
31140 65 63 69 66 69 63 20 5b 65 72 72 6f 72 20 63 6f ecific [error co
31150 64 65 73 5d 20 74 68 61 74 20 62 65 74 74 65 72 des] that better
31160 20 64 65 73 63 72 69 62 65 73 20 74 68 65 20 65 describes the e
31170 72 72 6f 72 2e 0a 2a 2a 20 57 65 20 61 64 6d 69 rror..** We admi
31180 74 20 74 68 61 74 20 74 68 69 73 20 69 73 20 61 t that this is a
31190 20 67 6f 6f 66 79 20 64 65 73 69 67 6e 2e 20 20 goofy design.
311a0 54 68 65 20 70 72 6f 62 6c 65 6d 20 68 61 73 20 The problem has
311b0 62 65 65 6e 20 66 69 78 65 64 0a 2a 2a 20 77 69 been fixed.** wi
311c0 74 68 20 74 68 65 20 22 76 32 22 20 69 6e 74 65 th the "v2" inte
311d0 72 66 61 63 65 2e 20 20 49 66 20 79 6f 75 20 70 rface. If you p
311e0 72 65 70 61 72 65 20 61 6c 6c 20 6f 66 20 79 6f repare all of yo
311f0 75 72 20 53 51 4c 20 73 74 61 74 65 6d 65 6e 74 ur SQL statement
31200 73 0a 2a 2a 20 75 73 69 6e 67 20 65 69 74 68 65 s.** using eithe
31210 72 20 5b 73 71 6c 69 74 65 33 5f 70 72 65 70 61 r [sqlite3_prepa
31220 72 65 5f 76 32 28 29 5d 20 6f 72 20 5b 73 71 6c re_v2()] or [sql
31230 69 74 65 33 5f 70 72 65 70 61 72 65 31 36 5f 76 ite3_prepare16_v
31240 32 28 29 5d 20 69 6e 73 74 65 61 64 0a 2a 2a 20 2()] instead.**
31250 6f 66 20 74 68 65 20 6c 65 67 61 63 79 20 5b 73 of the legacy [s
31260 71 6c 69 74 65 33 5f 70 72 65 70 61 72 65 28 29 qlite3_prepare()
31270 5d 20 61 6e 64 20 5b 73 71 6c 69 74 65 33 5f 70 ] and [sqlite3_p
31280 72 65 70 61 72 65 31 36 28 29 5d 20 69 6e 74 65 repare16()] inte
31290 72 66 61 63 65 73 2c 0a 2a 2a 20 74 68 65 6e 20 rfaces,.** then
312a0 74 68 65 20 6d 6f 72 65 20 73 70 65 63 69 66 69 the more specifi
312b0 63 20 5b 65 72 72 6f 72 20 63 6f 64 65 73 5d 20 c [error codes]
312c0 61 72 65 20 72 65 74 75 72 6e 65 64 20 64 69 72 are returned dir
312d0 65 63 74 6c 79 0a 2a 2a 20 62 79 20 73 71 6c 69 ectly.** by sqli
312e0 74 65 33 5f 73 74 65 70 28 29 2e 20 20 54 68 65 te3_step(). The
312f0 20 75 73 65 20 6f 66 20 74 68 65 20 22 76 32 22 use of the "v2"
31300 20 69 6e 74 65 72 66 61 63 65 20 69 73 20 72 65 interface is re
31310 63 6f 6d 6d 65 6e 64 65 64 2e 0a 2a 2f 0a 69 6e commended..*/.in
31320 74 20 73 71 6c 69 74 65 33 5f 73 74 65 70 28 73 t sqlite3_step(s
31330 71 6c 69 74 65 33 5f 73 74 6d 74 2a 29 3b 0a 0a qlite3_stmt*);..
31340 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 /*.** CAPI3REF:
31350 4e 75 6d 62 65 72 20 6f 66 20 63 6f 6c 75 6d 6e Number of column
31360 73 20 69 6e 20 61 20 72 65 73 75 6c 74 20 73 65 s in a result se
31370 74 0a 2a 2a 20 4d 45 54 48 4f 44 3a 20 73 71 6c t.** METHOD: sql
31380 69 74 65 33 5f 73 74 6d 74 0a 2a 2a 0a 2a 2a 20 ite3_stmt.**.**
31390 5e 54 68 65 20 73 71 6c 69 74 65 33 5f 64 61 74 ^The sqlite3_dat
313a0 61 5f 63 6f 75 6e 74 28 50 29 20 69 6e 74 65 72 a_count(P) inter
313b0 66 61 63 65 20 72 65 74 75 72 6e 73 20 74 68 65 face returns the
313c0 20 6e 75 6d 62 65 72 20 6f 66 20 63 6f 6c 75 6d number of colum
313d0 6e 73 20 69 6e 20 74 68 65 0a 2a 2a 20 63 75 72 ns in the.** cur
313e0 72 65 6e 74 20 72 6f 77 20 6f 66 20 74 68 65 20 rent row of the
313f0 72 65 73 75 6c 74 20 73 65 74 20 6f 66 20 5b 70 result set of [p
31400 72 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e repared statemen
31410 74 5d 20 50 2e 0a 2a 2a 20 5e 49 66 20 70 72 65 t] P..** ^If pre
31420 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 20 pared statement
31430 50 20 64 6f 65 73 20 6e 6f 74 20 68 61 76 65 20 P does not have
31440 72 65 73 75 6c 74 73 20 72 65 61 64 79 20 74 6f results ready to
31450 20 72 65 74 75 72 6e 0a 2a 2a 20 28 76 69 61 20 return.** (via
31460 63 61 6c 6c 73 20 74 6f 20 74 68 65 20 5b 73 71 calls to the [sq
31470 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 lite3_column_int
31480 20 7c 20 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d | sqlite3_colum
31490 6e 5f 2a 28 29 5d 20 6f 66 0a 2a 2a 20 69 6e 74 n_*()] of.** int
314a0 65 72 66 61 63 65 73 29 20 74 68 65 6e 20 73 71 erfaces) then sq
314b0 6c 69 74 65 33 5f 64 61 74 61 5f 63 6f 75 6e 74 lite3_data_count
314c0 28 50 29 20 72 65 74 75 72 6e 73 20 30 2e 0a 2a (P) returns 0..*
314d0 2a 20 5e 54 68 65 20 73 71 6c 69 74 65 33 5f 64 * ^The sqlite3_d
314e0 61 74 61 5f 63 6f 75 6e 74 28 50 29 20 72 6f 75 ata_count(P) rou
314f0 74 69 6e 65 20 61 6c 73 6f 20 72 65 74 75 72 6e tine also return
31500 73 20 30 20 69 66 20 50 20 69 73 20 61 20 4e 55 s 0 if P is a NU
31510 4c 4c 20 70 6f 69 6e 74 65 72 2e 0a 2a 2a 20 5e LL pointer..** ^
31520 54 68 65 20 73 71 6c 69 74 65 33 5f 64 61 74 61 The sqlite3_data
31530 5f 63 6f 75 6e 74 28 50 29 20 72 6f 75 74 69 6e _count(P) routin
31540 65 20 72 65 74 75 72 6e 73 20 30 20 69 66 20 74 e returns 0 if t
31550 68 65 20 70 72 65 76 69 6f 75 73 20 63 61 6c 6c he previous call
31560 20 74 6f 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f to.** [sqlite3_
31570 73 74 65 70 5d 28 50 29 20 72 65 74 75 72 6e 65 step](P) returne
31580 64 20 5b 53 51 4c 49 54 45 5f 44 4f 4e 45 5d 2e d [SQLITE_DONE].
31590 20 20 5e 54 68 65 20 73 71 6c 69 74 65 33 5f 64 ^The sqlite3_d
315a0 61 74 61 5f 63 6f 75 6e 74 28 50 29 0a 2a 2a 20 ata_count(P).**
315b0 77 69 6c 6c 20 72 65 74 75 72 6e 20 6e 6f 6e 2d will return non-
315c0 7a 65 72 6f 20 69 66 20 70 72 65 76 69 6f 75 73 zero if previous
315d0 20 63 61 6c 6c 20 74 6f 20 5b 73 71 6c 69 74 65 call to [sqlite
315e0 33 5f 73 74 65 70 5d 28 50 29 20 72 65 74 75 72 3_step](P) retur
315f0 6e 65 64 0a 2a 2a 20 5b 53 51 4c 49 54 45 5f 52 ned.** [SQLITE_R
31600 4f 57 5d 2c 20 65 78 63 65 70 74 20 69 6e 20 74 OW], except in t
31610 68 65 20 63 61 73 65 20 6f 66 20 74 68 65 20 5b he case of the [
31620 50 52 41 47 4d 41 20 69 6e 63 72 65 6d 65 6e 74 PRAGMA increment
31630 61 6c 5f 76 61 63 75 75 6d 5d 0a 2a 2a 20 77 68 al_vacuum].** wh
31640 65 72 65 20 69 74 20 61 6c 77 61 79 73 20 72 65 ere it always re
31650 74 75 72 6e 73 20 7a 65 72 6f 20 73 69 6e 63 65 turns zero since
31660 20 65 61 63 68 20 73 74 65 70 20 6f 66 20 74 68 each step of th
31670 61 74 20 6d 75 6c 74 69 2d 73 74 65 70 0a 2a 2a at multi-step.**
31680 20 70 72 61 67 6d 61 20 72 65 74 75 72 6e 73 20 pragma returns
31690 30 20 63 6f 6c 75 6d 6e 73 20 6f 66 20 64 61 74 0 columns of dat
316a0 61 2e 0a 2a 2a 0a 2a 2a 20 53 65 65 20 61 6c 73 a..**.** See als
316b0 6f 3a 20 5b 73 71 6c 69 74 65 33 5f 63 6f 6c 75 o: [sqlite3_colu
316c0 6d 6e 5f 63 6f 75 6e 74 28 29 5d 0a 2a 2f 0a 69 mn_count()].*/.i
316d0 6e 74 20 73 71 6c 69 74 65 33 5f 64 61 74 61 5f nt sqlite3_data_
316e0 63 6f 75 6e 74 28 73 71 6c 69 74 65 33 5f 73 74 count(sqlite3_st
316f0 6d 74 20 2a 70 53 74 6d 74 29 3b 0a 0a 2f 2a 0a mt *pStmt);../*.
31700 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 46 75 6e ** CAPI3REF: Fun
31710 64 61 6d 65 6e 74 61 6c 20 44 61 74 61 74 79 70 damental Datatyp
31720 65 73 0a 2a 2a 20 4b 45 59 57 4f 52 44 53 3a 20 es.** KEYWORDS:
31730 53 51 4c 49 54 45 5f 54 45 58 54 0a 2a 2a 0a 2a SQLITE_TEXT.**.*
31740 2a 20 5e 28 45 76 65 72 79 20 76 61 6c 75 65 20 * ^(Every value
31750 69 6e 20 53 51 4c 69 74 65 20 68 61 73 20 6f 6e in SQLite has on
31760 65 20 6f 66 20 66 69 76 65 20 66 75 6e 64 61 6d e of five fundam
31770 65 6e 74 61 6c 20 64 61 74 61 74 79 70 65 73 3a ental datatypes:
31780 0a 2a 2a 0a 2a 2a 20 3c 75 6c 3e 0a 2a 2a 20 3c .**.** <ul>.** <
31790 6c 69 3e 20 36 34 2d 62 69 74 20 73 69 67 6e 65 li> 64-bit signe
317a0 64 20 69 6e 74 65 67 65 72 0a 2a 2a 20 3c 6c 69 d integer.** <li
317b0 3e 20 36 34 2d 62 69 74 20 49 45 45 45 20 66 6c > 64-bit IEEE fl
317c0 6f 61 74 69 6e 67 20 70 6f 69 6e 74 20 6e 75 6d oating point num
317d0 62 65 72 0a 2a 2a 20 3c 6c 69 3e 20 73 74 72 69 ber.** <li> stri
317e0 6e 67 0a 2a 2a 20 3c 6c 69 3e 20 42 4c 4f 42 0a ng.** <li> BLOB.
317f0 2a 2a 20 3c 6c 69 3e 20 4e 55 4c 4c 0a 2a 2a 20 ** <li> NULL.**
31800 3c 2f 75 6c 3e 29 5e 0a 2a 2a 0a 2a 2a 20 54 68 </ul>)^.**.** Th
31810 65 73 65 20 63 6f 6e 73 74 61 6e 74 73 20 61 72 ese constants ar
31820 65 20 63 6f 64 65 73 20 66 6f 72 20 65 61 63 68 e codes for each
31830 20 6f 66 20 74 68 6f 73 65 20 74 79 70 65 73 2e of those types.
31840 0a 2a 2a 0a 2a 2a 20 4e 6f 74 65 20 74 68 61 74 .**.** Note that
31850 20 74 68 65 20 53 51 4c 49 54 45 5f 54 45 58 54 the SQLITE_TEXT
31860 20 63 6f 6e 73 74 61 6e 74 20 77 61 73 20 61 6c constant was al
31870 73 6f 20 75 73 65 64 20 69 6e 20 53 51 4c 69 74 so used in SQLit
31880 65 20 76 65 72 73 69 6f 6e 20 32 0a 2a 2a 20 66 e version 2.** f
31890 6f 72 20 61 20 63 6f 6d 70 6c 65 74 65 6c 79 20 or a completely
318a0 64 69 66 66 65 72 65 6e 74 20 6d 65 61 6e 69 6e different meanin
318b0 67 2e 20 20 53 6f 66 74 77 61 72 65 20 74 68 61 g. Software tha
318c0 74 20 6c 69 6e 6b 73 20 61 67 61 69 6e 73 74 20 t links against
318d0 62 6f 74 68 0a 2a 2a 20 53 51 4c 69 74 65 20 76 both.** SQLite v
318e0 65 72 73 69 6f 6e 20 32 20 61 6e 64 20 53 51 4c ersion 2 and SQL
318f0 69 74 65 20 76 65 72 73 69 6f 6e 20 33 20 73 68 ite version 3 sh
31900 6f 75 6c 64 20 75 73 65 20 53 51 4c 49 54 45 33 ould use SQLITE3
31910 5f 54 45 58 54 2c 20 6e 6f 74 0a 2a 2a 20 53 51 _TEXT, not.** SQ
31920 4c 49 54 45 5f 54 45 58 54 2e 0a 2a 2f 0a 23 64 LITE_TEXT..*/.#d
31930 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 49 4e 54 efine SQLITE_INT
31940 45 47 45 52 20 20 31 0a 23 64 65 66 69 6e 65 20 EGER 1.#define
31950 53 51 4c 49 54 45 5f 46 4c 4f 41 54 20 20 20 20 SQLITE_FLOAT
31960 32 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 2.#define SQLITE
31970 5f 42 4c 4f 42 20 20 20 20 20 34 0a 23 64 65 66 _BLOB 4.#def
31980 69 6e 65 20 53 51 4c 49 54 45 5f 4e 55 4c 4c 20 ine SQLITE_NULL
31990 20 20 20 20 35 0a 23 69 66 64 65 66 20 53 51 4c 5.#ifdef SQL
319a0 49 54 45 5f 54 45 58 54 0a 23 20 75 6e 64 65 66 ITE_TEXT.# undef
319b0 20 53 51 4c 49 54 45 5f 54 45 58 54 0a 23 65 6c SQLITE_TEXT.#el
319c0 73 65 0a 23 20 64 65 66 69 6e 65 20 53 51 4c 49 se.# define SQLI
319d0 54 45 5f 54 45 58 54 20 20 20 20 20 33 0a 23 65 TE_TEXT 3.#e
319e0 6e 64 69 66 0a 23 64 65 66 69 6e 65 20 53 51 4c ndif.#define SQL
319f0 49 54 45 33 5f 54 45 58 54 20 20 20 20 20 33 0a ITE3_TEXT 3.
31a00 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a ./*.** CAPI3REF:
31a10 20 52 65 73 75 6c 74 20 56 61 6c 75 65 73 20 46 Result Values F
31a20 72 6f 6d 20 41 20 51 75 65 72 79 0a 2a 2a 20 4b rom A Query.** K
31a30 45 59 57 4f 52 44 53 3a 20 7b 63 6f 6c 75 6d 6e EYWORDS: {column
31a40 20 61 63 63 65 73 73 20 66 75 6e 63 74 69 6f 6e access function
31a50 73 7d 0a 2a 2a 20 4d 45 54 48 4f 44 3a 20 73 71 s}.** METHOD: sq
31a60 6c 69 74 65 33 5f 73 74 6d 74 0a 2a 2a 0a 2a 2a lite3_stmt.**.**
31a70 20 5e 54 68 65 73 65 20 72 6f 75 74 69 6e 65 73 ^These routines
31a80 20 72 65 74 75 72 6e 20 69 6e 66 6f 72 6d 61 74 return informat
31a90 69 6f 6e 20 61 62 6f 75 74 20 61 20 73 69 6e 67 ion about a sing
31aa0 6c 65 20 63 6f 6c 75 6d 6e 20 6f 66 20 74 68 65 le column of the
31ab0 20 63 75 72 72 65 6e 74 0a 2a 2a 20 72 65 73 75 current.** resu
31ac0 6c 74 20 72 6f 77 20 6f 66 20 61 20 71 75 65 72 lt row of a quer
31ad0 79 2e 20 20 5e 49 6e 20 65 76 65 72 79 20 63 61 y. ^In every ca
31ae0 73 65 20 74 68 65 20 66 69 72 73 74 20 61 72 67 se the first arg
31af0 75 6d 65 6e 74 20 69 73 20 61 20 70 6f 69 6e 74 ument is a point
31b00 65 72 0a 2a 2a 20 74 6f 20 74 68 65 20 5b 70 72 er.** to the [pr
31b10 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e 74 epared statement
31b20 5d 20 74 68 61 74 20 69 73 20 62 65 69 6e 67 20 ] that is being
31b30 65 76 61 6c 75 61 74 65 64 20 28 74 68 65 20 5b evaluated (the [
31b40 73 71 6c 69 74 65 33 5f 73 74 6d 74 2a 5d 0a 2a sqlite3_stmt*].*
31b50 2a 20 74 68 61 74 20 77 61 73 20 72 65 74 75 72 * that was retur
31b60 6e 65 64 20 66 72 6f 6d 20 5b 73 71 6c 69 74 65 ned from [sqlite
31b70 33 5f 70 72 65 70 61 72 65 5f 76 32 28 29 5d 20 3_prepare_v2()]
31b80 6f 72 20 6f 6e 65 20 6f 66 20 69 74 73 20 76 61 or one of its va
31b90 72 69 61 6e 74 73 29 0a 2a 2a 20 61 6e 64 20 74 riants).** and t
31ba0 68 65 20 73 65 63 6f 6e 64 20 61 72 67 75 6d 65 he second argume
31bb0 6e 74 20 69 73 20 74 68 65 20 69 6e 64 65 78 20 nt is the index
31bc0 6f 66 20 74 68 65 20 63 6f 6c 75 6d 6e 20 66 6f of the column fo
31bd0 72 20 77 68 69 63 68 20 69 6e 66 6f 72 6d 61 74 r which informat
31be0 69 6f 6e 0a 2a 2a 20 73 68 6f 75 6c 64 20 62 65 ion.** should be
31bf0 20 72 65 74 75 72 6e 65 64 2e 20 5e 54 68 65 20 returned. ^The
31c00 6c 65 66 74 6d 6f 73 74 20 63 6f 6c 75 6d 6e 20 leftmost column
31c10 6f 66 20 74 68 65 20 72 65 73 75 6c 74 20 73 65 of the result se
31c20 74 20 68 61 73 20 74 68 65 20 69 6e 64 65 78 20 t has the index
31c30 30 2e 0a 2a 2a 20 5e 54 68 65 20 6e 75 6d 62 65 0..** ^The numbe
31c40 72 20 6f 66 20 63 6f 6c 75 6d 6e 73 20 69 6e 20 r of columns in
31c50 74 68 65 20 72 65 73 75 6c 74 20 63 61 6e 20 62 the result can b
31c60 65 20 64 65 74 65 72 6d 69 6e 65 64 20 75 73 69 e determined usi
31c70 6e 67 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 63 ng.** [sqlite3_c
31c80 6f 6c 75 6d 6e 5f 63 6f 75 6e 74 28 29 5d 2e 0a olumn_count()]..
31c90 2a 2a 0a 2a 2a 20 49 66 20 74 68 65 20 53 51 4c **.** If the SQL
31ca0 20 73 74 61 74 65 6d 65 6e 74 20 64 6f 65 73 20 statement does
31cb0 6e 6f 74 20 63 75 72 72 65 6e 74 6c 79 20 70 6f not currently po
31cc0 69 6e 74 20 74 6f 20 61 20 76 61 6c 69 64 20 72 int to a valid r
31cd0 6f 77 2c 20 6f 72 20 69 66 20 74 68 65 0a 2a 2a ow, or if the.**
31ce0 20 63 6f 6c 75 6d 6e 20 69 6e 64 65 78 20 69 73 column index is
31cf0 20 6f 75 74 20 6f 66 20 72 61 6e 67 65 2c 20 74 out of range, t
31d00 68 65 20 72 65 73 75 6c 74 20 69 73 20 75 6e 64 he result is und
31d10 65 66 69 6e 65 64 2e 0a 2a 2a 20 54 68 65 73 65 efined..** These
31d20 20 72 6f 75 74 69 6e 65 73 20 6d 61 79 20 6f 6e routines may on
31d30 6c 79 20 62 65 20 63 61 6c 6c 65 64 20 77 68 65 ly be called whe
31d40 6e 20 74 68 65 20 6d 6f 73 74 20 72 65 63 65 6e n the most recen
31d50 74 20 63 61 6c 6c 20 74 6f 0a 2a 2a 20 5b 73 71 t call to.** [sq
31d60 6c 69 74 65 33 5f 73 74 65 70 28 29 5d 20 68 61 lite3_step()] ha
31d70 73 20 72 65 74 75 72 6e 65 64 20 5b 53 51 4c 49 s returned [SQLI
31d80 54 45 5f 52 4f 57 5d 20 61 6e 64 20 6e 65 69 74 TE_ROW] and neit
31d90 68 65 72 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f her.** [sqlite3_
31da0 72 65 73 65 74 28 29 5d 20 6e 6f 72 20 5b 73 71 reset()] nor [sq
31db0 6c 69 74 65 33 5f 66 69 6e 61 6c 69 7a 65 28 29 lite3_finalize()
31dc0 5d 20 68 61 76 65 20 62 65 65 6e 20 63 61 6c 6c ] have been call
31dd0 65 64 20 73 75 62 73 65 71 75 65 6e 74 6c 79 2e ed subsequently.
31de0 0a 2a 2a 20 49 66 20 61 6e 79 20 6f 66 20 74 68 .** If any of th
31df0 65 73 65 20 72 6f 75 74 69 6e 65 73 20 61 72 65 ese routines are
31e00 20 63 61 6c 6c 65 64 20 61 66 74 65 72 20 5b 73 called after [s
31e10 71 6c 69 74 65 33 5f 72 65 73 65 74 28 29 5d 20 qlite3_reset()]
31e20 6f 72 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 66 or.** [sqlite3_f
31e30 69 6e 61 6c 69 7a 65 28 29 5d 20 6f 72 20 61 66 inalize()] or af
31e40 74 65 72 20 5b 73 71 6c 69 74 65 33 5f 73 74 65 ter [sqlite3_ste
31e50 70 28 29 5d 20 68 61 73 20 72 65 74 75 72 6e 65 p()] has returne
31e60 64 0a 2a 2a 20 73 6f 6d 65 74 68 69 6e 67 20 6f d.** something o
31e70 74 68 65 72 20 74 68 61 6e 20 5b 53 51 4c 49 54 ther than [SQLIT
31e80 45 5f 52 4f 57 5d 2c 20 74 68 65 20 72 65 73 75 E_ROW], the resu
31e90 6c 74 73 20 61 72 65 20 75 6e 64 65 66 69 6e 65 lts are undefine
31ea0 64 2e 0a 2a 2a 20 49 66 20 5b 73 71 6c 69 74 65 d..** If [sqlite
31eb0 33 5f 73 74 65 70 28 29 5d 20 6f 72 20 5b 73 71 3_step()] or [sq
31ec0 6c 69 74 65 33 5f 72 65 73 65 74 28 29 5d 20 6f lite3_reset()] o
31ed0 72 20 5b 73 71 6c 69 74 65 33 5f 66 69 6e 61 6c r [sqlite3_final
31ee0 69 7a 65 28 29 5d 0a 2a 2a 20 61 72 65 20 63 61 ize()].** are ca
31ef0 6c 6c 65 64 20 66 72 6f 6d 20 61 20 64 69 66 66 lled from a diff
31f00 65 72 65 6e 74 20 74 68 72 65 61 64 20 77 68 69 erent thread whi
31f10 6c 65 20 61 6e 79 20 6f 66 20 74 68 65 73 65 20 le any of these
31f20 72 6f 75 74 69 6e 65 73 0a 2a 2a 20 61 72 65 20 routines.** are
31f30 70 65 6e 64 69 6e 67 2c 20 74 68 65 6e 20 74 68 pending, then th
31f40 65 20 72 65 73 75 6c 74 73 20 61 72 65 20 75 6e e results are un
31f50 64 65 66 69 6e 65 64 2e 0a 2a 2a 0a 2a 2a 20 5e defined..**.** ^
31f60 54 68 65 20 73 71 6c 69 74 65 33 5f 63 6f 6c 75 The sqlite3_colu
31f70 6d 6e 5f 74 79 70 65 28 29 20 72 6f 75 74 69 6e mn_type() routin
31f80 65 20 72 65 74 75 72 6e 73 20 74 68 65 0a 2a 2a e returns the.**
31f90 20 5b 53 51 4c 49 54 45 5f 49 4e 54 45 47 45 52 [SQLITE_INTEGER
31fa0 20 7c 20 64 61 74 61 74 79 70 65 20 63 6f 64 65 | datatype code
31fb0 5d 20 66 6f 72 20 74 68 65 20 69 6e 69 74 69 61 ] for the initia
31fc0 6c 20 64 61 74 61 20 74 79 70 65 0a 2a 2a 20 6f l data type.** o
31fd0 66 20 74 68 65 20 72 65 73 75 6c 74 20 63 6f 6c f the result col
31fe0 75 6d 6e 2e 20 20 5e 54 68 65 20 72 65 74 75 72 umn. ^The retur
31ff0 6e 65 64 20 76 61 6c 75 65 20 69 73 20 6f 6e 65 ned value is one
32000 20 6f 66 20 5b 53 51 4c 49 54 45 5f 49 4e 54 45 of [SQLITE_INTE
32010 47 45 52 5d 2c 0a 2a 2a 20 5b 53 51 4c 49 54 45 GER],.** [SQLITE
32020 5f 46 4c 4f 41 54 5d 2c 20 5b 53 51 4c 49 54 45 _FLOAT], [SQLITE
32030 5f 54 45 58 54 5d 2c 20 5b 53 51 4c 49 54 45 5f _TEXT], [SQLITE_
32040 42 4c 4f 42 5d 2c 20 6f 72 20 5b 53 51 4c 49 54 BLOB], or [SQLIT
32050 45 5f 4e 55 4c 4c 5d 2e 20 20 54 68 65 20 76 61 E_NULL]. The va
32060 6c 75 65 0a 2a 2a 20 72 65 74 75 72 6e 65 64 20 lue.** returned
32070 62 79 20 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d by sqlite3_colum
32080 6e 5f 74 79 70 65 28 29 20 69 73 20 6f 6e 6c 79 n_type() is only
32090 20 6d 65 61 6e 69 6e 67 66 75 6c 20 69 66 20 6e meaningful if n
320a0 6f 20 74 79 70 65 0a 2a 2a 20 63 6f 6e 76 65 72 o type.** conver
320b0 73 69 6f 6e 73 20 68 61 76 65 20 6f 63 63 75 72 sions have occur
320c0 72 65 64 20 61 73 20 64 65 73 63 72 69 62 65 64 red as described
320d0 20 62 65 6c 6f 77 2e 20 20 41 66 74 65 72 20 61 below. After a
320e0 20 74 79 70 65 20 63 6f 6e 76 65 72 73 69 6f 6e type conversion
320f0 2c 0a 2a 2a 20 74 68 65 20 76 61 6c 75 65 20 72 ,.** the value r
32100 65 74 75 72 6e 65 64 20 62 79 20 73 71 6c 69 74 eturned by sqlit
32110 65 33 5f 63 6f 6c 75 6d 6e 5f 74 79 70 65 28 29 e3_column_type()
32120 20 69 73 20 75 6e 64 65 66 69 6e 65 64 2e 20 20 is undefined.
32130 46 75 74 75 72 65 0a 2a 2a 20 76 65 72 73 69 6f Future.** versio
32140 6e 73 20 6f 66 20 53 51 4c 69 74 65 20 6d 61 79 ns of SQLite may
32150 20 63 68 61 6e 67 65 20 74 68 65 20 62 65 68 61 change the beha
32160 76 69 6f 72 20 6f 66 20 73 71 6c 69 74 65 33 5f vior of sqlite3_
32170 63 6f 6c 75 6d 6e 5f 74 79 70 65 28 29 0a 2a 2a column_type().**
32180 20 66 6f 6c 6c 6f 77 69 6e 67 20 61 20 74 79 70 following a typ
32190 65 20 63 6f 6e 76 65 72 73 69 6f 6e 2e 0a 2a 2a e conversion..**
321a0 0a 2a 2a 20 5e 49 66 20 74 68 65 20 72 65 73 75 .** ^If the resu
321b0 6c 74 20 69 73 20 61 20 42 4c 4f 42 20 6f 72 20 lt is a BLOB or
321c0 55 54 46 2d 38 20 73 74 72 69 6e 67 20 74 68 65 UTF-8 string the
321d0 6e 20 74 68 65 20 73 71 6c 69 74 65 33 5f 63 6f n the sqlite3_co
321e0 6c 75 6d 6e 5f 62 79 74 65 73 28 29 0a 2a 2a 20 lumn_bytes().**
321f0 72 6f 75 74 69 6e 65 20 72 65 74 75 72 6e 73 20 routine returns
32200 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 62 79 the number of by
32210 74 65 73 20 69 6e 20 74 68 61 74 20 42 4c 4f 42 tes in that BLOB
32220 20 6f 72 20 73 74 72 69 6e 67 2e 0a 2a 2a 20 5e or string..** ^
32230 49 66 20 74 68 65 20 72 65 73 75 6c 74 20 69 73 If the result is
32240 20 61 20 55 54 46 2d 31 36 20 73 74 72 69 6e 67 a UTF-16 string
32250 2c 20 74 68 65 6e 20 73 71 6c 69 74 65 33 5f 63 , then sqlite3_c
32260 6f 6c 75 6d 6e 5f 62 79 74 65 73 28 29 20 63 6f olumn_bytes() co
32270 6e 76 65 72 74 73 0a 2a 2a 20 74 68 65 20 73 74 nverts.** the st
32280 72 69 6e 67 20 74 6f 20 55 54 46 2d 38 20 61 6e ring to UTF-8 an
32290 64 20 74 68 65 6e 20 72 65 74 75 72 6e 73 20 74 d then returns t
322a0 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 62 79 74 he number of byt
322b0 65 73 2e 0a 2a 2a 20 5e 49 66 20 74 68 65 20 72 es..** ^If the r
322c0 65 73 75 6c 74 20 69 73 20 61 20 6e 75 6d 65 72 esult is a numer
322d0 69 63 20 76 61 6c 75 65 20 74 68 65 6e 20 73 71 ic value then sq
322e0 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 62 79 74 lite3_column_byt
322f0 65 73 28 29 20 75 73 65 73 0a 2a 2a 20 5b 73 71 es() uses.** [sq
32300 6c 69 74 65 33 5f 73 6e 70 72 69 6e 74 66 28 29 lite3_snprintf()
32310 5d 20 74 6f 20 63 6f 6e 76 65 72 74 20 74 68 61 ] to convert tha
32320 74 20 76 61 6c 75 65 20 74 6f 20 61 20 55 54 46 t value to a UTF
32330 2d 38 20 73 74 72 69 6e 67 20 61 6e 64 20 72 65 -8 string and re
32340 74 75 72 6e 73 0a 2a 2a 20 74 68 65 20 6e 75 6d turns.** the num
32350 62 65 72 20 6f 66 20 62 79 74 65 73 20 69 6e 20 ber of bytes in
32360 74 68 61 74 20 73 74 72 69 6e 67 2e 0a 2a 2a 20 that string..**
32370 5e 49 66 20 74 68 65 20 72 65 73 75 6c 74 20 69 ^If the result i
32380 73 20 4e 55 4c 4c 2c 20 74 68 65 6e 20 73 71 6c s NULL, then sql
32390 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 62 79 74 65 ite3_column_byte
323a0 73 28 29 20 72 65 74 75 72 6e 73 20 7a 65 72 6f s() returns zero
323b0 2e 0a 2a 2a 0a 2a 2a 20 5e 49 66 20 74 68 65 20 ..**.** ^If the
323c0 72 65 73 75 6c 74 20 69 73 20 61 20 42 4c 4f 42 result is a BLOB
323d0 20 6f 72 20 55 54 46 2d 31 36 20 73 74 72 69 6e or UTF-16 strin
323e0 67 20 74 68 65 6e 20 74 68 65 20 73 71 6c 69 74 g then the sqlit
323f0 65 33 5f 63 6f 6c 75 6d 6e 5f 62 79 74 65 73 31 e3_column_bytes1
32400 36 28 29 0a 2a 2a 20 72 6f 75 74 69 6e 65 20 72 6().** routine r
32410 65 74 75 72 6e 73 20 74 68 65 20 6e 75 6d 62 65 eturns the numbe
32420 72 20 6f 66 20 62 79 74 65 73 20 69 6e 20 74 68 r of bytes in th
32430 61 74 20 42 4c 4f 42 20 6f 72 20 73 74 72 69 6e at BLOB or strin
32440 67 2e 0a 2a 2a 20 5e 49 66 20 74 68 65 20 72 65 g..** ^If the re
32450 73 75 6c 74 20 69 73 20 61 20 55 54 46 2d 38 20 sult is a UTF-8
32460 73 74 72 69 6e 67 2c 20 74 68 65 6e 20 73 71 6c string, then sql
32470 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 62 79 74 65 ite3_column_byte
32480 73 31 36 28 29 20 63 6f 6e 76 65 72 74 73 0a 2a s16() converts.*
32490 2a 20 74 68 65 20 73 74 72 69 6e 67 20 74 6f 20 * the string to
324a0 55 54 46 2d 31 36 20 61 6e 64 20 74 68 65 6e 20 UTF-16 and then
324b0 72 65 74 75 72 6e 73 20 74 68 65 20 6e 75 6d 62 returns the numb
324c0 65 72 20 6f 66 20 62 79 74 65 73 2e 0a 2a 2a 20 er of bytes..**
324d0 5e 49 66 20 74 68 65 20 72 65 73 75 6c 74 20 69 ^If the result i
324e0 73 20 61 20 6e 75 6d 65 72 69 63 20 76 61 6c 75 s a numeric valu
324f0 65 20 74 68 65 6e 20 73 71 6c 69 74 65 33 5f 63 e then sqlite3_c
32500 6f 6c 75 6d 6e 5f 62 79 74 65 73 31 36 28 29 20 olumn_bytes16()
32510 75 73 65 73 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 uses.** [sqlite3
32520 5f 73 6e 70 72 69 6e 74 66 28 29 5d 20 74 6f 20 _snprintf()] to
32530 63 6f 6e 76 65 72 74 20 74 68 61 74 20 76 61 6c convert that val
32540 75 65 20 74 6f 20 61 20 55 54 46 2d 31 36 20 73 ue to a UTF-16 s
32550 74 72 69 6e 67 20 61 6e 64 20 72 65 74 75 72 6e tring and return
32560 73 0a 2a 2a 20 74 68 65 20 6e 75 6d 62 65 72 20 s.** the number
32570 6f 66 20 62 79 74 65 73 20 69 6e 20 74 68 61 74 of bytes in that
32580 20 73 74 72 69 6e 67 2e 0a 2a 2a 20 5e 49 66 20 string..** ^If
32590 74 68 65 20 72 65 73 75 6c 74 20 69 73 20 4e 55 the result is NU
325a0 4c 4c 2c 20 74 68 65 6e 20 73 71 6c 69 74 65 33 LL, then sqlite3
325b0 5f 63 6f 6c 75 6d 6e 5f 62 79 74 65 73 31 36 28 _column_bytes16(
325c0 29 20 72 65 74 75 72 6e 73 20 7a 65 72 6f 2e 0a ) returns zero..
325d0 2a 2a 0a 2a 2a 20 5e 54 68 65 20 76 61 6c 75 65 **.** ^The value
325e0 73 20 72 65 74 75 72 6e 65 64 20 62 79 20 5b 73 s returned by [s
325f0 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 62 79 qlite3_column_by
32600 74 65 73 28 29 5d 20 61 6e 64 20 0a 2a 2a 20 5b tes()] and .** [
32610 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 62 sqlite3_column_b
32620 79 74 65 73 31 36 28 29 5d 20 64 6f 20 6e 6f 74 ytes16()] do not
32630 20 69 6e 63 6c 75 64 65 20 74 68 65 20 7a 65 72 include the zer
32640 6f 20 74 65 72 6d 69 6e 61 74 6f 72 73 20 61 74 o terminators at
32650 20 74 68 65 20 65 6e 64 0a 2a 2a 20 6f 66 20 74 the end.** of t
32660 68 65 20 73 74 72 69 6e 67 2e 20 20 5e 46 6f 72 he string. ^For
32670 20 63 6c 61 72 69 74 79 3a 20 74 68 65 20 76 61 clarity: the va
32680 6c 75 65 73 20 72 65 74 75 72 6e 65 64 20 62 79 lues returned by
32690 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 63 6f 6c .** [sqlite3_col
326a0 75 6d 6e 5f 62 79 74 65 73 28 29 5d 20 61 6e 64 umn_bytes()] and
326b0 20 5b 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e [sqlite3_column
326c0 5f 62 79 74 65 73 31 36 28 29 5d 20 61 72 65 20 _bytes16()] are
326d0 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 0a 2a 2a the number of.**
326e0 20 62 79 74 65 73 20 69 6e 20 74 68 65 20 73 74 bytes in the st
326f0 72 69 6e 67 2c 20 6e 6f 74 20 74 68 65 20 6e 75 ring, not the nu
32700 6d 62 65 72 20 6f 66 20 63 68 61 72 61 63 74 65 mber of characte
32710 72 73 2e 0a 2a 2a 0a 2a 2a 20 5e 53 74 72 69 6e rs..**.** ^Strin
32720 67 73 20 72 65 74 75 72 6e 65 64 20 62 79 20 73 gs returned by s
32730 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 74 65 qlite3_column_te
32740 78 74 28 29 20 61 6e 64 20 73 71 6c 69 74 65 33 xt() and sqlite3
32750 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 31 36 28 29 _column_text16()
32760 2c 0a 2a 2a 20 65 76 65 6e 20 65 6d 70 74 79 20 ,.** even empty
32770 73 74 72 69 6e 67 73 2c 20 61 72 65 20 61 6c 77 strings, are alw
32780 61 79 73 20 7a 65 72 6f 2d 74 65 72 6d 69 6e 61 ays zero-termina
32790 74 65 64 2e 20 20 5e 54 68 65 20 72 65 74 75 72 ted. ^The retur
327a0 6e 0a 2a 2a 20 76 61 6c 75 65 20 66 72 6f 6d 20 n.** value from
327b0 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 62 sqlite3_column_b
327c0 6c 6f 62 28 29 20 66 6f 72 20 61 20 7a 65 72 6f lob() for a zero
327d0 2d 6c 65 6e 67 74 68 20 42 4c 4f 42 20 69 73 20 -length BLOB is
327e0 61 20 4e 55 4c 4c 20 70 6f 69 6e 74 65 72 2e 0a a NULL pointer..
327f0 2a 2a 0a 2a 2a 20 3c 62 3e 57 61 72 6e 69 6e 67 **.** <b>Warning
32800 3a 3c 2f 62 3e 20 5e 54 68 65 20 6f 62 6a 65 63 :</b> ^The objec
32810 74 20 72 65 74 75 72 6e 65 64 20 62 79 20 5b 73 t returned by [s
32820 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 76 61 qlite3_column_va
32830 6c 75 65 28 29 5d 20 69 73 20 61 6e 0a 2a 2a 20 lue()] is an.**
32840 5b 75 6e 70 72 6f 74 65 63 74 65 64 20 73 71 6c [unprotected sql
32850 69 74 65 33 5f 76 61 6c 75 65 5d 20 6f 62 6a 65 ite3_value] obje
32860 63 74 2e 20 20 49 6e 20 61 20 6d 75 6c 74 69 74 ct. In a multit
32870 68 72 65 61 64 65 64 20 65 6e 76 69 72 6f 6e 6d hreaded environm
32880 65 6e 74 2c 0a 2a 2a 20 61 6e 20 75 6e 70 72 6f ent,.** an unpro
32890 74 65 63 74 65 64 20 73 71 6c 69 74 65 33 5f 76 tected sqlite3_v
328a0 61 6c 75 65 20 6f 62 6a 65 63 74 20 6d 61 79 20 alue object may
328b0 6f 6e 6c 79 20 62 65 20 75 73 65 64 20 73 61 66 only be used saf
328c0 65 6c 79 20 77 69 74 68 0a 2a 2a 20 5b 73 71 6c ely with.** [sql
328d0 69 74 65 33 5f 62 69 6e 64 5f 76 61 6c 75 65 28 ite3_bind_value(
328e0 29 5d 20 61 6e 64 20 5b 73 71 6c 69 74 65 33 5f )] and [sqlite3_
328f0 72 65 73 75 6c 74 5f 76 61 6c 75 65 28 29 5d 2e result_value()].
32900 0a 2a 2a 20 49 66 20 74 68 65 20 5b 75 6e 70 72 .** If the [unpr
32910 6f 74 65 63 74 65 64 20 73 71 6c 69 74 65 33 5f otected sqlite3_
32920 76 61 6c 75 65 5d 20 6f 62 6a 65 63 74 20 72 65 value] object re
32930 74 75 72 6e 65 64 20 62 79 0a 2a 2a 20 5b 73 71 turned by.** [sq
32940 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 76 61 6c lite3_column_val
32950 75 65 28 29 5d 20 69 73 20 75 73 65 64 20 69 6e ue()] is used in
32960 20 61 6e 79 20 6f 74 68 65 72 20 77 61 79 2c 20 any other way,
32970 69 6e 63 6c 75 64 69 6e 67 20 63 61 6c 6c 73 0a including calls.
32980 2a 2a 20 74 6f 20 72 6f 75 74 69 6e 65 73 20 6c ** to routines l
32990 69 6b 65 20 5b 73 71 6c 69 74 65 33 5f 76 61 6c ike [sqlite3_val
329a0 75 65 5f 69 6e 74 28 29 5d 2c 20 5b 73 71 6c 69 ue_int()], [sqli
329b0 74 65 33 5f 76 61 6c 75 65 5f 74 65 78 74 28 29 te3_value_text()
329c0 5d 2c 0a 2a 2a 20 6f 72 20 5b 73 71 6c 69 74 65 ],.** or [sqlite
329d0 33 5f 76 61 6c 75 65 5f 62 79 74 65 73 28 29 5d 3_value_bytes()]
329e0 2c 20 74 68 65 20 62 65 68 61 76 69 6f 72 20 69 , the behavior i
329f0 73 20 6e 6f 74 20 74 68 72 65 61 64 73 61 66 65 s not threadsafe
32a00 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 73 65 20 72 6f ..**.** These ro
32a10 75 74 69 6e 65 73 20 61 74 74 65 6d 70 74 20 74 utines attempt t
32a20 6f 20 63 6f 6e 76 65 72 74 20 74 68 65 20 76 61 o convert the va
32a30 6c 75 65 20 77 68 65 72 65 20 61 70 70 72 6f 70 lue where approp
32a40 72 69 61 74 65 2e 20 20 5e 46 6f 72 0a 2a 2a 20 riate. ^For.**
32a50 65 78 61 6d 70 6c 65 2c 20 69 66 20 74 68 65 20 example, if the
32a60 69 6e 74 65 72 6e 61 6c 20 72 65 70 72 65 73 65 internal represe
32a70 6e 74 61 74 69 6f 6e 20 69 73 20 46 4c 4f 41 54 ntation is FLOAT
32a80 20 61 6e 64 20 61 20 74 65 78 74 20 72 65 73 75 and a text resu
32a90 6c 74 0a 2a 2a 20 69 73 20 72 65 71 75 65 73 74 lt.** is request
32aa0 65 64 2c 20 5b 73 71 6c 69 74 65 33 5f 73 6e 70 ed, [sqlite3_snp
32ab0 72 69 6e 74 66 28 29 5d 20 69 73 20 75 73 65 64 rintf()] is used
32ac0 20 69 6e 74 65 72 6e 61 6c 6c 79 20 74 6f 20 70 internally to p
32ad0 65 72 66 6f 72 6d 20 74 68 65 0a 2a 2a 20 63 6f erform the.** co
32ae0 6e 76 65 72 73 69 6f 6e 20 61 75 74 6f 6d 61 74 nversion automat
32af0 69 63 61 6c 6c 79 2e 20 20 5e 28 54 68 65 20 66 ically. ^(The f
32b00 6f 6c 6c 6f 77 69 6e 67 20 74 61 62 6c 65 20 64 ollowing table d
32b10 65 74 61 69 6c 73 20 74 68 65 20 63 6f 6e 76 65 etails the conve
32b20 72 73 69 6f 6e 73 0a 2a 2a 20 74 68 61 74 20 61 rsions.** that a
32b30 72 65 20 61 70 70 6c 69 65 64 3a 0a 2a 2a 0a 2a re applied:.**.*
32b40 2a 20 3c 62 6c 6f 63 6b 71 75 6f 74 65 3e 0a 2a * <blockquote>.*
32b50 2a 20 3c 74 61 62 6c 65 20 62 6f 72 64 65 72 3d * <table border=
32b60 22 31 22 3e 0a 2a 2a 20 3c 74 72 3e 3c 74 68 3e "1">.** <tr><th>
32b70 20 49 6e 74 65 72 6e 61 6c 3c 62 72 3e 54 79 70 Internal<br>Typ
32b80 65 20 3c 74 68 3e 20 52 65 71 75 65 73 74 65 64 e <th> Requested
32b90 3c 62 72 3e 54 79 70 65 20 3c 74 68 3e 20 20 43 <br>Type <th> C
32ba0 6f 6e 76 65 72 73 69 6f 6e 0a 2a 2a 0a 2a 2a 20 onversion.**.**
32bb0 3c 74 72 3e 3c 74 64 3e 20 20 4e 55 4c 4c 20 20 <tr><td> NULL
32bc0 20 20 3c 74 64 3e 20 49 4e 54 45 47 45 52 20 20 <td> INTEGER
32bd0 20 3c 74 64 3e 20 52 65 73 75 6c 74 20 69 73 20 <td> Result is
32be0 30 0a 2a 2a 20 3c 74 72 3e 3c 74 64 3e 20 20 4e 0.** <tr><td> N
32bf0 55 4c 4c 20 20 20 20 3c 74 64 3e 20 20 46 4c 4f ULL <td> FLO
32c00 41 54 20 20 20 20 3c 74 64 3e 20 52 65 73 75 6c AT <td> Resul
32c10 74 20 69 73 20 30 2e 30 0a 2a 2a 20 3c 74 72 3e t is 0.0.** <tr>
32c20 3c 74 64 3e 20 20 4e 55 4c 4c 20 20 20 20 3c 74 <td> NULL <t
32c30 64 3e 20 20 20 54 45 58 54 20 20 20 20 3c 74 64 d> TEXT <td
32c40 3e 20 52 65 73 75 6c 74 20 69 73 20 61 20 4e 55 > Result is a NU
32c50 4c 4c 20 70 6f 69 6e 74 65 72 0a 2a 2a 20 3c 74 LL pointer.** <t
32c60 72 3e 3c 74 64 3e 20 20 4e 55 4c 4c 20 20 20 20 r><td> NULL
32c70 3c 74 64 3e 20 20 20 42 4c 4f 42 20 20 20 20 3c <td> BLOB <
32c80 74 64 3e 20 52 65 73 75 6c 74 20 69 73 20 61 20 td> Result is a
32c90 4e 55 4c 4c 20 70 6f 69 6e 74 65 72 0a 2a 2a 20 NULL pointer.**
32ca0 3c 74 72 3e 3c 74 64 3e 20 49 4e 54 45 47 45 52 <tr><td> INTEGER
32cb0 20 20 3c 74 64 3e 20 20 46 4c 4f 41 54 20 20 20 <td> FLOAT
32cc0 20 3c 74 64 3e 20 43 6f 6e 76 65 72 74 20 66 72 <td> Convert fr
32cd0 6f 6d 20 69 6e 74 65 67 65 72 20 74 6f 20 66 6c om integer to fl
32ce0 6f 61 74 0a 2a 2a 20 3c 74 72 3e 3c 74 64 3e 20 oat.** <tr><td>
32cf0 49 4e 54 45 47 45 52 20 20 3c 74 64 3e 20 20 20 INTEGER <td>
32d00 54 45 58 54 20 20 20 20 3c 74 64 3e 20 41 53 43 TEXT <td> ASC
32d10 49 49 20 72 65 6e 64 65 72 69 6e 67 20 6f 66 20 II rendering of
32d20 74 68 65 20 69 6e 74 65 67 65 72 0a 2a 2a 20 3c the integer.** <
32d30 74 72 3e 3c 74 64 3e 20 49 4e 54 45 47 45 52 20 tr><td> INTEGER
32d40 20 3c 74 64 3e 20 20 20 42 4c 4f 42 20 20 20 20 <td> BLOB
32d50 3c 74 64 3e 20 53 61 6d 65 20 61 73 20 49 4e 54 <td> Same as INT
32d60 45 47 45 52 2d 3e 54 45 58 54 0a 2a 2a 20 3c 74 EGER->TEXT.** <t
32d70 72 3e 3c 74 64 3e 20 20 46 4c 4f 41 54 20 20 20 r><td> FLOAT
32d80 3c 74 64 3e 20 49 4e 54 45 47 45 52 20 20 20 3c <td> INTEGER <
32d90 74 64 3e 20 5b 43 41 53 54 5d 20 74 6f 20 49 4e td> [CAST] to IN
32da0 54 45 47 45 52 0a 2a 2a 20 3c 74 72 3e 3c 74 64 TEGER.** <tr><td
32db0 3e 20 20 46 4c 4f 41 54 20 20 20 3c 74 64 3e 20 > FLOAT <td>
32dc0 20 20 54 45 58 54 20 20 20 20 3c 74 64 3e 20 41 TEXT <td> A
32dd0 53 43 49 49 20 72 65 6e 64 65 72 69 6e 67 20 6f SCII rendering o
32de0 66 20 74 68 65 20 66 6c 6f 61 74 0a 2a 2a 20 3c f the float.** <
32df0 74 72 3e 3c 74 64 3e 20 20 46 4c 4f 41 54 20 20 tr><td> FLOAT
32e00 20 3c 74 64 3e 20 20 20 42 4c 4f 42 20 20 20 20 <td> BLOB
32e10 3c 74 64 3e 20 5b 43 41 53 54 5d 20 74 6f 20 42 <td> [CAST] to B
32e20 4c 4f 42 0a 2a 2a 20 3c 74 72 3e 3c 74 64 3e 20 LOB.** <tr><td>
32e30 20 54 45 58 54 20 20 20 20 3c 74 64 3e 20 49 4e TEXT <td> IN
32e40 54 45 47 45 52 20 20 20 3c 74 64 3e 20 5b 43 41 TEGER <td> [CA
32e50 53 54 5d 20 74 6f 20 49 4e 54 45 47 45 52 0a 2a ST] to INTEGER.*
32e60 2a 20 3c 74 72 3e 3c 74 64 3e 20 20 54 45 58 54 * <tr><td> TEXT
32e70 20 20 20 20 3c 74 64 3e 20 20 46 4c 4f 41 54 20 <td> FLOAT
32e80 20 20 20 3c 74 64 3e 20 5b 43 41 53 54 5d 20 74 <td> [CAST] t
32e90 6f 20 52 45 41 4c 0a 2a 2a 20 3c 74 72 3e 3c 74 o REAL.** <tr><t
32ea0 64 3e 20 20 54 45 58 54 20 20 20 20 3c 74 64 3e d> TEXT <td>
32eb0 20 20 20 42 4c 4f 42 20 20 20 20 3c 74 64 3e 20 BLOB <td>
32ec0 4e 6f 20 63 68 61 6e 67 65 0a 2a 2a 20 3c 74 72 No change.** <tr
32ed0 3e 3c 74 64 3e 20 20 42 4c 4f 42 20 20 20 20 3c ><td> BLOB <
32ee0 74 64 3e 20 49 4e 54 45 47 45 52 20 20 20 3c 74 td> INTEGER <t
32ef0 64 3e 20 5b 43 41 53 54 5d 20 74 6f 20 49 4e 54 d> [CAST] to INT
32f00 45 47 45 52 0a 2a 2a 20 3c 74 72 3e 3c 74 64 3e EGER.** <tr><td>
32f10 20 20 42 4c 4f 42 20 20 20 20 3c 74 64 3e 20 20 BLOB <td>
32f20 46 4c 4f 41 54 20 20 20 20 3c 74 64 3e 20 5b 43 FLOAT <td> [C
32f30 41 53 54 5d 20 74 6f 20 52 45 41 4c 0a 2a 2a 20 AST] to REAL.**
32f40 3c 74 72 3e 3c 74 64 3e 20 20 42 4c 4f 42 20 20 <tr><td> BLOB
32f50 20 20 3c 74 64 3e 20 20 20 54 45 58 54 20 20 20 <td> TEXT
32f60 20 3c 74 64 3e 20 41 64 64 20 61 20 7a 65 72 6f <td> Add a zero
32f70 20 74 65 72 6d 69 6e 61 74 6f 72 20 69 66 20 6e terminator if n
32f80 65 65 64 65 64 0a 2a 2a 20 3c 2f 74 61 62 6c 65 eeded.** </table
32f90 3e 0a 2a 2a 20 3c 2f 62 6c 6f 63 6b 71 75 6f 74 >.** </blockquot
32fa0 65 3e 29 5e 0a 2a 2a 0a 2a 2a 20 4e 6f 74 65 20 e>)^.**.** Note
32fb0 74 68 61 74 20 77 68 65 6e 20 74 79 70 65 20 63 that when type c
32fc0 6f 6e 76 65 72 73 69 6f 6e 73 20 6f 63 63 75 72 onversions occur
32fd0 2c 20 70 6f 69 6e 74 65 72 73 20 72 65 74 75 72 , pointers retur
32fe0 6e 65 64 20 62 79 20 70 72 69 6f 72 0a 2a 2a 20 ned by prior.**
32ff0 63 61 6c 6c 73 20 74 6f 20 73 71 6c 69 74 65 33 calls to sqlite3
33000 5f 63 6f 6c 75 6d 6e 5f 62 6c 6f 62 28 29 2c 20 _column_blob(),
33010 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 74 sqlite3_column_t
33020 65 78 74 28 29 2c 20 61 6e 64 2f 6f 72 0a 2a 2a ext(), and/or.**
33030 20 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f sqlite3_column_
33040 74 65 78 74 31 36 28 29 20 6d 61 79 20 62 65 20 text16() may be
33050 69 6e 76 61 6c 69 64 61 74 65 64 2e 0a 2a 2a 20 invalidated..**
33060 54 79 70 65 20 63 6f 6e 76 65 72 73 69 6f 6e 73 Type conversions
33070 20 61 6e 64 20 70 6f 69 6e 74 65 72 20 69 6e 76 and pointer inv
33080 61 6c 69 64 61 74 69 6f 6e 73 20 6d 69 67 68 74 alidations might
33090 20 6f 63 63 75 72 0a 2a 2a 20 69 6e 20 74 68 65 occur.** in the
330a0 20 66 6f 6c 6c 6f 77 69 6e 67 20 63 61 73 65 73 following cases
330b0 3a 0a 2a 2a 0a 2a 2a 20 3c 75 6c 3e 0a 2a 2a 20 :.**.** <ul>.**
330c0 3c 6c 69 3e 20 54 68 65 20 69 6e 69 74 69 61 6c <li> The initial
330d0 20 63 6f 6e 74 65 6e 74 20 69 73 20 61 20 42 4c content is a BL
330e0 4f 42 20 61 6e 64 20 73 71 6c 69 74 65 33 5f 63 OB and sqlite3_c
330f0 6f 6c 75 6d 6e 5f 74 65 78 74 28 29 20 6f 72 0a olumn_text() or.
33100 2a 2a 20 20 20 20 20 20 73 71 6c 69 74 65 33 5f ** sqlite3_
33110 63 6f 6c 75 6d 6e 5f 74 65 78 74 31 36 28 29 20 column_text16()
33120 69 73 20 63 61 6c 6c 65 64 2e 20 20 41 20 7a 65 is called. A ze
33130 72 6f 2d 74 65 72 6d 69 6e 61 74 6f 72 20 6d 69 ro-terminator mi
33140 67 68 74 0a 2a 2a 20 20 20 20 20 20 6e 65 65 64 ght.** need
33150 20 74 6f 20 62 65 20 61 64 64 65 64 20 74 6f 20 to be added to
33160 74 68 65 20 73 74 72 69 6e 67 2e 3c 2f 6c 69 3e the string.</li>
33170 0a 2a 2a 20 3c 6c 69 3e 20 54 68 65 20 69 6e 69 .** <li> The ini
33180 74 69 61 6c 20 63 6f 6e 74 65 6e 74 20 69 73 20 tial content is
33190 55 54 46 2d 38 20 74 65 78 74 20 61 6e 64 20 73 UTF-8 text and s
331a0 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 62 79 qlite3_column_by
331b0 74 65 73 31 36 28 29 20 6f 72 0a 2a 2a 20 20 20 tes16() or.**
331c0 20 20 20 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d sqlite3_colum
331d0 6e 5f 74 65 78 74 31 36 28 29 20 69 73 20 63 61 n_text16() is ca
331e0 6c 6c 65 64 2e 20 20 54 68 65 20 63 6f 6e 74 65 lled. The conte
331f0 6e 74 20 6d 75 73 74 20 62 65 20 63 6f 6e 76 65 nt must be conve
33200 72 74 65 64 0a 2a 2a 20 20 20 20 20 20 74 6f 20 rted.** to
33210 55 54 46 2d 31 36 2e 3c 2f 6c 69 3e 0a 2a 2a 20 UTF-16.</li>.**
33220 3c 6c 69 3e 20 54 68 65 20 69 6e 69 74 69 61 6c <li> The initial
33230 20 63 6f 6e 74 65 6e 74 20 69 73 20 55 54 46 2d content is UTF-
33240 31 36 20 74 65 78 74 20 61 6e 64 20 73 71 6c 69 16 text and sqli
33250 74 65 33 5f 63 6f 6c 75 6d 6e 5f 62 79 74 65 73 te3_column_bytes
33260 28 29 20 6f 72 0a 2a 2a 20 20 20 20 20 20 73 71 () or.** sq
33270 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 74 65 78 lite3_column_tex
33280 74 28 29 20 69 73 20 63 61 6c 6c 65 64 2e 20 20 t() is called.
33290 54 68 65 20 63 6f 6e 74 65 6e 74 20 6d 75 73 74 The content must
332a0 20 62 65 20 63 6f 6e 76 65 72 74 65 64 0a 2a 2a be converted.**
332b0 20 20 20 20 20 20 74 6f 20 55 54 46 2d 38 2e 3c to UTF-8.<
332c0 2f 6c 69 3e 0a 2a 2a 20 3c 2f 75 6c 3e 0a 2a 2a /li>.** </ul>.**
332d0 0a 2a 2a 20 5e 43 6f 6e 76 65 72 73 69 6f 6e 73 .** ^Conversions
332e0 20 62 65 74 77 65 65 6e 20 55 54 46 2d 31 36 62 between UTF-16b
332f0 65 20 61 6e 64 20 55 54 46 2d 31 36 6c 65 20 61 e and UTF-16le a
33300 72 65 20 61 6c 77 61 79 73 20 64 6f 6e 65 20 69 re always done i
33310 6e 20 70 6c 61 63 65 20 61 6e 64 20 64 6f 0a 2a n place and do.*
33320 2a 20 6e 6f 74 20 69 6e 76 61 6c 69 64 61 74 65 * not invalidate
33330 20 61 20 70 72 69 6f 72 20 70 6f 69 6e 74 65 72 a prior pointer
33340 2c 20 74 68 6f 75 67 68 20 6f 66 20 63 6f 75 72 , though of cour
33350 73 65 20 74 68 65 20 63 6f 6e 74 65 6e 74 20 6f se the content o
33360 66 20 74 68 65 20 62 75 66 66 65 72 0a 2a 2a 20 f the buffer.**
33370 74 68 61 74 20 74 68 65 20 70 72 69 6f 72 20 70 that the prior p
33380 6f 69 6e 74 65 72 20 72 65 66 65 72 65 6e 63 65 ointer reference
33390 73 20 77 69 6c 6c 20 68 61 76 65 20 62 65 65 6e s will have been
333a0 20 6d 6f 64 69 66 69 65 64 2e 20 20 4f 74 68 65 modified. Othe
333b0 72 20 6b 69 6e 64 73 0a 2a 2a 20 6f 66 20 63 6f r kinds.** of co
333c0 6e 76 65 72 73 69 6f 6e 20 61 72 65 20 64 6f 6e nversion are don
333d0 65 20 69 6e 20 70 6c 61 63 65 20 77 68 65 6e 20 e in place when
333e0 69 74 20 69 73 20 70 6f 73 73 69 62 6c 65 2c 20 it is possible,
333f0 62 75 74 20 73 6f 6d 65 74 69 6d 65 73 20 74 68 but sometimes th
33400 65 79 0a 2a 2a 20 61 72 65 20 6e 6f 74 20 70 6f ey.** are not po
33410 73 73 69 62 6c 65 20 61 6e 64 20 69 6e 20 74 68 ssible and in th
33420 6f 73 65 20 63 61 73 65 73 20 70 72 69 6f 72 20 ose cases prior
33430 70 6f 69 6e 74 65 72 73 20 61 72 65 20 69 6e 76 pointers are inv
33440 61 6c 69 64 61 74 65 64 2e 0a 2a 2a 0a 2a 2a 20 alidated..**.**
33450 54 68 65 20 73 61 66 65 73 74 20 70 6f 6c 69 63 The safest polic
33460 79 20 69 73 20 74 6f 20 69 6e 76 6f 6b 65 20 74 y is to invoke t
33470 68 65 73 65 20 72 6f 75 74 69 6e 65 73 0a 2a 2a hese routines.**
33480 20 69 6e 20 6f 6e 65 20 6f 66 20 74 68 65 20 66 in one of the f
33490 6f 6c 6c 6f 77 69 6e 67 20 77 61 79 73 3a 0a 2a ollowing ways:.*
334a0 2a 0a 2a 2a 20 3c 75 6c 3e 0a 2a 2a 20 20 3c 6c *.** <ul>.** <l
334b0 69 3e 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e i>sqlite3_column
334c0 5f 74 65 78 74 28 29 20 66 6f 6c 6c 6f 77 65 64 _text() followed
334d0 20 62 79 20 73 71 6c 69 74 65 33 5f 63 6f 6c 75 by sqlite3_colu
334e0 6d 6e 5f 62 79 74 65 73 28 29 3c 2f 6c 69 3e 0a mn_bytes()</li>.
334f0 2a 2a 20 20 3c 6c 69 3e 73 71 6c 69 74 65 33 5f ** <li>sqlite3_
33500 63 6f 6c 75 6d 6e 5f 62 6c 6f 62 28 29 20 66 6f column_blob() fo
33510 6c 6c 6f 77 65 64 20 62 79 20 73 71 6c 69 74 65 llowed by sqlite
33520 33 5f 63 6f 6c 75 6d 6e 5f 62 79 74 65 73 28 29 3_column_bytes()
33530 3c 2f 6c 69 3e 0a 2a 2a 20 20 3c 6c 69 3e 73 71 </li>.** <li>sq
33540 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 74 65 78 lite3_column_tex
33550 74 31 36 28 29 20 66 6f 6c 6c 6f 77 65 64 20 62 t16() followed b
33560 79 20 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e y sqlite3_column
33570 5f 62 79 74 65 73 31 36 28 29 3c 2f 6c 69 3e 0a _bytes16()</li>.
33580 2a 2a 20 3c 2f 75 6c 3e 0a 2a 2a 0a 2a 2a 20 49 ** </ul>.**.** I
33590 6e 20 6f 74 68 65 72 20 77 6f 72 64 73 2c 20 79 n other words, y
335a0 6f 75 20 73 68 6f 75 6c 64 20 63 61 6c 6c 20 73 ou should call s
335b0 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 74 65 qlite3_column_te
335c0 78 74 28 29 2c 0a 2a 2a 20 73 71 6c 69 74 65 33 xt(),.** sqlite3
335d0 5f 63 6f 6c 75 6d 6e 5f 62 6c 6f 62 28 29 2c 20 _column_blob(),
335e0 6f 72 20 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d or sqlite3_colum
335f0 6e 5f 74 65 78 74 31 36 28 29 20 66 69 72 73 74 n_text16() first
33600 20 74 6f 20 66 6f 72 63 65 20 74 68 65 20 72 65 to force the re
33610 73 75 6c 74 0a 2a 2a 20 69 6e 74 6f 20 74 68 65 sult.** into the
33620 20 64 65 73 69 72 65 64 20 66 6f 72 6d 61 74 2c desired format,
33630 20 74 68 65 6e 20 69 6e 76 6f 6b 65 20 73 71 6c then invoke sql
33640 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 62 79 74 65 ite3_column_byte
33650 73 28 29 20 6f 72 0a 2a 2a 20 73 71 6c 69 74 65 s() or.** sqlite
33660 33 5f 63 6f 6c 75 6d 6e 5f 62 79 74 65 73 31 36 3_column_bytes16
33670 28 29 20 74 6f 20 66 69 6e 64 20 74 68 65 20 73 () to find the s
33680 69 7a 65 20 6f 66 20 74 68 65 20 72 65 73 75 6c ize of the resul
33690 74 2e 20 20 44 6f 20 6e 6f 74 20 6d 69 78 20 63 t. Do not mix c
336a0 61 6c 6c 73 0a 2a 2a 20 74 6f 20 73 71 6c 69 74 alls.** to sqlit
336b0 65 33 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 29 e3_column_text()
336c0 20 6f 72 20 73 71 6c 69 74 65 33 5f 63 6f 6c 75 or sqlite3_colu
336d0 6d 6e 5f 62 6c 6f 62 28 29 20 77 69 74 68 20 63 mn_blob() with c
336e0 61 6c 6c 73 20 74 6f 0a 2a 2a 20 73 71 6c 69 74 alls to.** sqlit
336f0 65 33 5f 63 6f 6c 75 6d 6e 5f 62 79 74 65 73 31 e3_column_bytes1
33700 36 28 29 2c 20 61 6e 64 20 64 6f 20 6e 6f 74 20 6(), and do not
33710 6d 69 78 20 63 61 6c 6c 73 20 74 6f 20 73 71 6c mix calls to sql
33720 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 ite3_column_text
33730 31 36 28 29 0a 2a 2a 20 77 69 74 68 20 63 61 6c 16().** with cal
33740 6c 73 20 74 6f 20 73 71 6c 69 74 65 33 5f 63 6f ls to sqlite3_co
33750 6c 75 6d 6e 5f 62 79 74 65 73 28 29 2e 0a 2a 2a lumn_bytes()..**
33760 0a 2a 2a 20 5e 54 68 65 20 70 6f 69 6e 74 65 72 .** ^The pointer
33770 73 20 72 65 74 75 72 6e 65 64 20 61 72 65 20 76 s returned are v
33780 61 6c 69 64 20 75 6e 74 69 6c 20 61 20 74 79 70 alid until a typ
33790 65 20 63 6f 6e 76 65 72 73 69 6f 6e 20 6f 63 63 e conversion occ
337a0 75 72 73 20 61 73 0a 2a 2a 20 64 65 73 63 72 69 urs as.** descri
337b0 62 65 64 20 61 62 6f 76 65 2c 20 6f 72 20 75 6e bed above, or un
337c0 74 69 6c 20 5b 73 71 6c 69 74 65 33 5f 73 74 65 til [sqlite3_ste
337d0 70 28 29 5d 20 6f 72 20 5b 73 71 6c 69 74 65 33 p()] or [sqlite3
337e0 5f 72 65 73 65 74 28 29 5d 20 6f 72 0a 2a 2a 20 _reset()] or.**
337f0 5b 73 71 6c 69 74 65 33 5f 66 69 6e 61 6c 69 7a [sqlite3_finaliz
33800 65 28 29 5d 20 69 73 20 63 61 6c 6c 65 64 2e 20 e()] is called.
33810 20 5e 54 68 65 20 6d 65 6d 6f 72 79 20 73 70 61 ^The memory spa
33820 63 65 20 75 73 65 64 20 74 6f 20 68 6f 6c 64 20 ce used to hold
33830 73 74 72 69 6e 67 73 0a 2a 2a 20 61 6e 64 20 42 strings.** and B
33840 4c 4f 42 73 20 69 73 20 66 72 65 65 64 20 61 75 LOBs is freed au
33850 74 6f 6d 61 74 69 63 61 6c 6c 79 2e 20 20 44 6f tomatically. Do
33860 20 3c 65 6d 3e 6e 6f 74 3c 2f 65 6d 3e 20 70 61 <em>not</em> pa
33870 73 73 20 74 68 65 20 70 6f 69 6e 74 65 72 73 20 ss the pointers
33880 72 65 74 75 72 6e 65 64 0a 2a 2a 20 66 72 6f 6d returned.** from
33890 20 5b 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e [sqlite3_column
338a0 5f 62 6c 6f 62 28 29 5d 2c 20 5b 73 71 6c 69 74 _blob()], [sqlit
338b0 65 33 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 29 e3_column_text()
338c0 5d 2c 20 65 74 63 2e 20 69 6e 74 6f 0a 2a 2a 20 ], etc. into.**
338d0 5b 73 71 6c 69 74 65 33 5f 66 72 65 65 28 29 5d [sqlite3_free()]
338e0 2e 0a 2a 2a 0a 2a 2a 20 5e 28 49 66 20 61 20 6d ..**.** ^(If a m
338f0 65 6d 6f 72 79 20 61 6c 6c 6f 63 61 74 69 6f 6e emory allocation
33900 20 65 72 72 6f 72 20 6f 63 63 75 72 73 20 64 75 error occurs du
33910 72 69 6e 67 20 74 68 65 20 65 76 61 6c 75 61 74 ring the evaluat
33920 69 6f 6e 20 6f 66 20 61 6e 79 0a 2a 2a 20 6f 66 ion of any.** of
33930 20 74 68 65 73 65 20 72 6f 75 74 69 6e 65 73 2c these routines,
33940 20 61 20 64 65 66 61 75 6c 74 20 76 61 6c 75 65 a default value
33950 20 69 73 20 72 65 74 75 72 6e 65 64 2e 20 20 54 is returned. T
33960 68 65 20 64 65 66 61 75 6c 74 20 76 61 6c 75 65 he default value
33970 0a 2a 2a 20 69 73 20 65 69 74 68 65 72 20 74 68 .** is either th
33980 65 20 69 6e 74 65 67 65 72 20 30 2c 20 74 68 65 e integer 0, the
33990 20 66 6c 6f 61 74 69 6e 67 20 70 6f 69 6e 74 20 floating point
339a0 6e 75 6d 62 65 72 20 30 2e 30 2c 20 6f 72 20 61 number 0.0, or a
339b0 20 4e 55 4c 4c 0a 2a 2a 20 70 6f 69 6e 74 65 72 NULL.** pointer
339c0 2e 20 20 53 75 62 73 65 71 75 65 6e 74 20 63 61 . Subsequent ca
339d0 6c 6c 73 20 74 6f 20 5b 73 71 6c 69 74 65 33 5f lls to [sqlite3_
339e0 65 72 72 63 6f 64 65 28 29 5d 20 77 69 6c 6c 20 errcode()] will
339f0 72 65 74 75 72 6e 0a 2a 2a 20 5b 53 51 4c 49 54 return.** [SQLIT
33a00 45 5f 4e 4f 4d 45 4d 5d 2e 29 5e 0a 2a 2f 0a 63 E_NOMEM].)^.*/.c
33a10 6f 6e 73 74 20 76 6f 69 64 20 2a 73 71 6c 69 74 onst void *sqlit
33a20 65 33 5f 63 6f 6c 75 6d 6e 5f 62 6c 6f 62 28 73 e3_column_blob(s
33a30 71 6c 69 74 65 33 5f 73 74 6d 74 2a 2c 20 69 6e qlite3_stmt*, in
33a40 74 20 69 43 6f 6c 29 3b 0a 69 6e 74 20 73 71 6c t iCol);.int sql
33a50 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 62 79 74 65 ite3_column_byte
33a60 73 28 73 71 6c 69 74 65 33 5f 73 74 6d 74 2a 2c s(sqlite3_stmt*,
33a70 20 69 6e 74 20 69 43 6f 6c 29 3b 0a 69 6e 74 20 int iCol);.int
33a80 73 71 6c 69 74 65 33 5f 63 6f 6c 75 6d 6e 5f 62 sqlite3_column_b
33a90 79 74 65 73 31 36 28 73 71 6c 69 74 65 33 5f 73 ytes16(sqlite3_s
33aa0 74 6d 74 2a 2c 20 69 6e 74 20 69 43 6f 6c 29 3b tmt*, int iCol);
33ab0 0a 64 6f 75 62 6c 65 20 73 71 6c 69 74 65 33 5f .double sqlite3_
33ac0 63 6f 6c 75 6d 6e 5f 64 6f 75 62 6c 65 28 73 71 column_double(sq
33ad0 6c 69 74 65 33 5f 73 74 6d 74 2a 2c 20 69 6e 74 lite3_stmt*, int
33ae0 20 69 43 6f 6c 29 3b 0a 69 6e 74 20 73 71 6c 69 iCol);.int sqli
33af0 74 65 33 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28 73 te3_column_int(s
33b00 71 6c 69 74 65 33 5f 73 74 6d 74 2a 2c 20 69 6e qlite3_stmt*, in
33b10 74 20 69 43 6f 6c 29 3b 0a 73 71 6c 69 74 65 33 t iCol);.sqlite3
33b20 5f 69 6e 74 36 34 20 73 71 6c 69 74 65 33 5f 63 _int64 sqlite3_c
33b30 6f 6c 75 6d 6e 5f 69 6e 74 36 34 28 73 71 6c 69 olumn_int64(sqli
33b40 74 65 33 5f 73 74 6d 74 2a 2c 20 69 6e 74 20 69 te3_stmt*, int i
33b50 43 6f 6c 29 3b 0a 63 6f 6e 73 74 20 75 6e 73 69 Col);.const unsi
33b60 67 6e 65 64 20 63 68 61 72 20 2a 73 71 6c 69 74 gned char *sqlit
33b70 65 33 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 73 e3_column_text(s
33b80 71 6c 69 74 65 33 5f 73 74 6d 74 2a 2c 20 69 6e qlite3_stmt*, in
33b90 74 20 69 43 6f 6c 29 3b 0a 63 6f 6e 73 74 20 76 t iCol);.const v
33ba0 6f 69 64 20 2a 73 71 6c 69 74 65 33 5f 63 6f 6c oid *sqlite3_col
33bb0 75 6d 6e 5f 74 65 78 74 31 36 28 73 71 6c 69 74 umn_text16(sqlit
33bc0 65 33 5f 73 74 6d 74 2a 2c 20 69 6e 74 20 69 43 e3_stmt*, int iC
33bd0 6f 6c 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 ol);.int sqlite3
33be0 5f 63 6f 6c 75 6d 6e 5f 74 79 70 65 28 73 71 6c _column_type(sql
33bf0 69 74 65 33 5f 73 74 6d 74 2a 2c 20 69 6e 74 20 ite3_stmt*, int
33c00 69 43 6f 6c 29 3b 0a 73 71 6c 69 74 65 33 5f 76 iCol);.sqlite3_v
33c10 61 6c 75 65 20 2a 73 71 6c 69 74 65 33 5f 63 6f alue *sqlite3_co
33c20 6c 75 6d 6e 5f 76 61 6c 75 65 28 73 71 6c 69 74 lumn_value(sqlit
33c30 65 33 5f 73 74 6d 74 2a 2c 20 69 6e 74 20 69 43 e3_stmt*, int iC
33c40 6f 6c 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 ol);../*.** CAPI
33c50 33 52 45 46 3a 20 44 65 73 74 72 6f 79 20 41 20 3REF: Destroy A
33c60 50 72 65 70 61 72 65 64 20 53 74 61 74 65 6d 65 Prepared Stateme
33c70 6e 74 20 4f 62 6a 65 63 74 0a 2a 2a 20 44 45 53 nt Object.** DES
33c80 54 52 55 43 54 4f 52 3a 20 73 71 6c 69 74 65 33 TRUCTOR: sqlite3
33c90 5f 73 74 6d 74 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 _stmt.**.** ^The
33ca0 20 73 71 6c 69 74 65 33 5f 66 69 6e 61 6c 69 7a sqlite3_finaliz
33cb0 65 28 29 20 66 75 6e 63 74 69 6f 6e 20 69 73 20 e() function is
33cc0 63 61 6c 6c 65 64 20 74 6f 20 64 65 6c 65 74 65 called to delete
33cd0 20 61 20 5b 70 72 65 70 61 72 65 64 20 73 74 61 a [prepared sta
33ce0 74 65 6d 65 6e 74 5d 2e 0a 2a 2a 20 5e 49 66 20 tement]..** ^If
33cf0 74 68 65 20 6d 6f 73 74 20 72 65 63 65 6e 74 20 the most recent
33d00 65 76 61 6c 75 61 74 69 6f 6e 20 6f 66 20 74 68 evaluation of th
33d10 65 20 73 74 61 74 65 6d 65 6e 74 20 65 6e 63 6f e statement enco
33d20 75 6e 74 65 72 65 64 20 6e 6f 20 65 72 72 6f 72 untered no error
33d30 73 0a 2a 2a 20 6f 72 20 69 66 20 74 68 65 20 73 s.** or if the s
33d40 74 61 74 65 6d 65 6e 74 20 69 73 20 6e 65 76 65 tatement is neve
33d50 72 20 62 65 65 6e 20 65 76 61 6c 75 61 74 65 64 r been evaluated
33d60 2c 20 74 68 65 6e 20 73 71 6c 69 74 65 33 5f 66 , then sqlite3_f
33d70 69 6e 61 6c 69 7a 65 28 29 20 72 65 74 75 72 6e inalize() return
33d80 73 0a 2a 2a 20 53 51 4c 49 54 45 5f 4f 4b 2e 20 s.** SQLITE_OK.
33d90 20 5e 49 66 20 74 68 65 20 6d 6f 73 74 20 72 65 ^If the most re
33da0 63 65 6e 74 20 65 76 61 6c 75 61 74 69 6f 6e 20 cent evaluation
33db0 6f 66 20 73 74 61 74 65 6d 65 6e 74 20 53 20 66 of statement S f
33dc0 61 69 6c 65 64 2c 20 74 68 65 6e 0a 2a 2a 20 73 ailed, then.** s
33dd0 71 6c 69 74 65 33 5f 66 69 6e 61 6c 69 7a 65 28 qlite3_finalize(
33de0 53 29 20 72 65 74 75 72 6e 73 20 74 68 65 20 61 S) returns the a
33df0 70 70 72 6f 70 72 69 61 74 65 20 5b 65 72 72 6f ppropriate [erro
33e00 72 20 63 6f 64 65 5d 20 6f 72 0a 2a 2a 20 5b 65 r code] or.** [e
33e10 78 74 65 6e 64 65 64 20 65 72 72 6f 72 20 63 6f xtended error co
33e20 64 65 5d 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 de]..**.** ^The
33e30 73 71 6c 69 74 65 33 5f 66 69 6e 61 6c 69 7a 65 sqlite3_finalize
33e40 28 53 29 20 72 6f 75 74 69 6e 65 20 63 61 6e 20 (S) routine can
33e50 62 65 20 63 61 6c 6c 65 64 20 61 74 20 61 6e 79 be called at any
33e60 20 70 6f 69 6e 74 20 64 75 72 69 6e 67 0a 2a 2a point during.**
33e70 20 74 68 65 20 6c 69 66 65 20 63 79 63 6c 65 20 the life cycle
33e80 6f 66 20 5b 70 72 65 70 61 72 65 64 20 73 74 61 of [prepared sta
33e90 74 65 6d 65 6e 74 5d 20 53 3a 0a 2a 2a 20 62 65 tement] S:.** be
33ea0 66 6f 72 65 20 73 74 61 74 65 6d 65 6e 74 20 53 fore statement S
33eb0 20 69 73 20 65 76 65 72 20 65 76 61 6c 75 61 74 is ever evaluat
33ec0 65 64 2c 20 61 66 74 65 72 0a 2a 2a 20 6f 6e 65 ed, after.** one
33ed0 20 6f 72 20 6d 6f 72 65 20 63 61 6c 6c 73 20 74 or more calls t
33ee0 6f 20 5b 73 71 6c 69 74 65 33 5f 72 65 73 65 74 o [sqlite3_reset
33ef0 28 29 5d 2c 20 6f 72 20 61 66 74 65 72 20 61 6e ()], or after an
33f00 79 20 63 61 6c 6c 0a 2a 2a 20 74 6f 20 5b 73 71 y call.** to [sq
33f10 6c 69 74 65 33 5f 73 74 65 70 28 29 5d 20 72 65 lite3_step()] re
33f20 67 61 72 64 6c 65 73 73 20 6f 66 20 77 68 65 74 gardless of whet
33f30 68 65 72 20 6f 72 20 6e 6f 74 20 74 68 65 20 73 her or not the s
33f40 74 61 74 65 6d 65 6e 74 20 68 61 73 0a 2a 2a 20 tatement has.**
33f50 63 6f 6d 70 6c 65 74 65 64 20 65 78 65 63 75 74 completed execut
33f60 69 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 5e 49 6e 76 6f ion..**.** ^Invo
33f70 6b 69 6e 67 20 73 71 6c 69 74 65 33 5f 66 69 6e king sqlite3_fin
33f80 61 6c 69 7a 65 28 29 20 6f 6e 20 61 20 4e 55 4c alize() on a NUL
33f90 4c 20 70 6f 69 6e 74 65 72 20 69 73 20 61 20 68 L pointer is a h
33fa0 61 72 6d 6c 65 73 73 20 6e 6f 2d 6f 70 2e 0a 2a armless no-op..*
33fb0 2a 0a 2a 2a 20 54 68 65 20 61 70 70 6c 69 63 61 *.** The applica
33fc0 74 69 6f 6e 20 6d 75 73 74 20 66 69 6e 61 6c 69 tion must finali
33fd0 7a 65 20 65 76 65 72 79 20 5b 70 72 65 70 61 72 ze every [prepar
33fe0 65 64 20 73 74 61 74 65 6d 65 6e 74 5d 20 69 6e ed statement] in
33ff0 20 6f 72 64 65 72 20 74 6f 20 61 76 6f 69 64 0a order to avoid.
34000 2a 2a 20 72 65 73 6f 75 72 63 65 20 6c 65 61 6b ** resource leak
34010 73 2e 20 20 49 74 20 69 73 20 61 20 67 72 69 65 s. It is a grie
34020 76 6f 75 73 20 65 72 72 6f 72 20 66 6f 72 20 74 vous error for t
34030 68 65 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 74 he application t
34040 6f 20 74 72 79 20 74 6f 20 75 73 65 0a 2a 2a 20 o try to use.**
34050 61 20 70 72 65 70 61 72 65 64 20 73 74 61 74 65 a prepared state
34060 6d 65 6e 74 20 61 66 74 65 72 20 69 74 20 68 61 ment after it ha
34070 73 20 62 65 65 6e 20 66 69 6e 61 6c 69 7a 65 64 s been finalized
34080 2e 20 20 41 6e 79 20 75 73 65 20 6f 66 20 61 20 . Any use of a
34090 70 72 65 70 61 72 65 64 0a 2a 2a 20 73 74 61 74 prepared.** stat
340a0 65 6d 65 6e 74 20 61 66 74 65 72 20 69 74 20 68 ement after it h
340b0 61 73 20 62 65 65 6e 20 66 69 6e 61 6c 69 7a 65 as been finalize
340c0 64 20 63 61 6e 20 72 65 73 75 6c 74 20 69 6e 20 d can result in
340d0 75 6e 64 65 66 69 6e 65 64 20 61 6e 64 0a 2a 2a undefined and.**
340e0 20 75 6e 64 65 73 69 72 61 62 6c 65 20 62 65 68 undesirable beh
340f0 61 76 69 6f 72 20 73 75 63 68 20 61 73 20 73 65 avior such as se
34100 67 66 61 75 6c 74 73 20 61 6e 64 20 68 65 61 70 gfaults and heap
34110 20 63 6f 72 72 75 70 74 69 6f 6e 2e 0a 2a 2f 0a corruption..*/.
34120 69 6e 74 20 73 71 6c 69 74 65 33 5f 66 69 6e 61 int sqlite3_fina
34130 6c 69 7a 65 28 73 71 6c 69 74 65 33 5f 73 74 6d lize(sqlite3_stm
34140 74 20 2a 70 53 74 6d 74 29 3b 0a 0a 2f 2a 0a 2a t *pStmt);../*.*
34150 2a 20 43 41 50 49 33 52 45 46 3a 20 52 65 73 65 * CAPI3REF: Rese
34160 74 20 41 20 50 72 65 70 61 72 65 64 20 53 74 61 t A Prepared Sta
34170 74 65 6d 65 6e 74 20 4f 62 6a 65 63 74 0a 2a 2a tement Object.**
34180 20 4d 45 54 48 4f 44 3a 20 73 71 6c 69 74 65 33 METHOD: sqlite3
34190 5f 73 74 6d 74 0a 2a 2a 0a 2a 2a 20 54 68 65 20 _stmt.**.** The
341a0 73 71 6c 69 74 65 33 5f 72 65 73 65 74 28 29 20 sqlite3_reset()
341b0 66 75 6e 63 74 69 6f 6e 20 69 73 20 63 61 6c 6c function is call
341c0 65 64 20 74 6f 20 72 65 73 65 74 20 61 20 5b 70 ed to reset a [p
341d0 72 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e repared statemen
341e0 74 5d 0a 2a 2a 20 6f 62 6a 65 63 74 20 62 61 63 t].** object bac
341f0 6b 20 74 6f 20 69 74 73 20 69 6e 69 74 69 61 6c k to its initial
34200 20 73 74 61 74 65 2c 20 72 65 61 64 79 20 74 6f state, ready to
34210 20 62 65 20 72 65 2d 65 78 65 63 75 74 65 64 2e be re-executed.
34220 0a 2a 2a 20 5e 41 6e 79 20 53 51 4c 20 73 74 61 .** ^Any SQL sta
34230 74 65 6d 65 6e 74 20 76 61 72 69 61 62 6c 65 73 tement variables
34240 20 74 68 61 74 20 68 61 64 20 76 61 6c 75 65 73 that had values
34250 20 62 6f 75 6e 64 20 74 6f 20 74 68 65 6d 20 75 bound to them u
34260 73 69 6e 67 0a 2a 2a 20 74 68 65 20 5b 73 71 6c sing.** the [sql
34270 69 74 65 33 5f 62 69 6e 64 5f 62 6c 6f 62 20 7c ite3_bind_blob |
34280 20 73 71 6c 69 74 65 33 5f 62 69 6e 64 5f 2a 28 sqlite3_bind_*(
34290 29 20 41 50 49 5d 20 72 65 74 61 69 6e 20 74 68 ) API] retain th
342a0 65 69 72 20 76 61 6c 75 65 73 2e 0a 2a 2a 20 55 eir values..** U
342b0 73 65 20 5b 73 71 6c 69 74 65 33 5f 63 6c 65 61 se [sqlite3_clea
342c0 72 5f 62 69 6e 64 69 6e 67 73 28 29 5d 20 74 6f r_bindings()] to
342d0 20 72 65 73 65 74 20 74 68 65 20 62 69 6e 64 69 reset the bindi
342e0 6e 67 73 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 ngs..**.** ^The
342f0 5b 73 71 6c 69 74 65 33 5f 72 65 73 65 74 28 53 [sqlite3_reset(S
34300 29 5d 20 69 6e 74 65 72 66 61 63 65 20 72 65 73 )] interface res
34310 65 74 73 20 74 68 65 20 5b 70 72 65 70 61 72 65 ets the [prepare
34320 64 20 73 74 61 74 65 6d 65 6e 74 5d 20 53 0a 2a d statement] S.*
34330 2a 20 62 61 63 6b 20 74 6f 20 74 68 65 20 62 65 * back to the be
34340 67 69 6e 6e 69 6e 67 20 6f 66 20 69 74 73 20 70 ginning of its p
34350 72 6f 67 72 61 6d 2e 0a 2a 2a 0a 2a 2a 20 5e 49 rogram..**.** ^I
34360 66 20 74 68 65 20 6d 6f 73 74 20 72 65 63 65 6e f the most recen
34370 74 20 63 61 6c 6c 20 74 6f 20 5b 73 71 6c 69 74 t call to [sqlit
34380 65 33 5f 73 74 65 70 28 53 29 5d 20 66 6f 72 20 e3_step(S)] for
34390 74 68 65 0a 2a 2a 20 5b 70 72 65 70 61 72 65 64 the.** [prepared
343a0 20 73 74 61 74 65 6d 65 6e 74 5d 20 53 20 72 65 statement] S re
343b0 74 75 72 6e 65 64 20 5b 53 51 4c 49 54 45 5f 52 turned [SQLITE_R
343c0 4f 57 5d 20 6f 72 20 5b 53 51 4c 49 54 45 5f 44 OW] or [SQLITE_D
343d0 4f 4e 45 5d 2c 0a 2a 2a 20 6f 72 20 69 66 20 5b ONE],.** or if [
343e0 73 71 6c 69 74 65 33 5f 73 74 65 70 28 53 29 5d sqlite3_step(S)]
343f0 20 68 61 73 20 6e 65 76 65 72 20 62 65 66 6f 72 has never befor
34400 65 20 62 65 65 6e 20 63 61 6c 6c 65 64 20 6f 6e e been called on
34410 20 53 2c 0a 2a 2a 20 74 68 65 6e 20 5b 73 71 6c S,.** then [sql
34420 69 74 65 33 5f 72 65 73 65 74 28 53 29 5d 20 72 ite3_reset(S)] r
34430 65 74 75 72 6e 73 20 5b 53 51 4c 49 54 45 5f 4f eturns [SQLITE_O
34440 4b 5d 2e 0a 2a 2a 0a 2a 2a 20 5e 49 66 20 74 68 K]..**.** ^If th
34450 65 20 6d 6f 73 74 20 72 65 63 65 6e 74 20 63 61 e most recent ca
34460 6c 6c 20 74 6f 20 5b 73 71 6c 69 74 65 33 5f 73 ll to [sqlite3_s
34470 74 65 70 28 53 29 5d 20 66 6f 72 20 74 68 65 0a tep(S)] for the.
34480 2a 2a 20 5b 70 72 65 70 61 72 65 64 20 73 74 61 ** [prepared sta
34490 74 65 6d 65 6e 74 5d 20 53 20 69 6e 64 69 63 61 tement] S indica
344a0 74 65 64 20 61 6e 20 65 72 72 6f 72 2c 20 74 68 ted an error, th
344b0 65 6e 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 72 en.** [sqlite3_r
344c0 65 73 65 74 28 53 29 5d 20 72 65 74 75 72 6e 73 eset(S)] returns
344d0 20 61 6e 20 61 70 70 72 6f 70 72 69 61 74 65 20 an appropriate
344e0 5b 65 72 72 6f 72 20 63 6f 64 65 5d 2e 0a 2a 2a [error code]..**
344f0 0a 2a 2a 20 5e 54 68 65 20 5b 73 71 6c 69 74 65 .** ^The [sqlite
34500 33 5f 72 65 73 65 74 28 53 29 5d 20 69 6e 74 65 3_reset(S)] inte
34510 72 66 61 63 65 20 64 6f 65 73 20 6e 6f 74 20 63 rface does not c
34520 68 61 6e 67 65 20 74 68 65 20 76 61 6c 75 65 73 hange the values
34530 0a 2a 2a 20 6f 66 20 61 6e 79 20 5b 73 71 6c 69 .** of any [sqli
34540 74 65 33 5f 62 69 6e 64 5f 62 6c 6f 62 7c 62 69 te3_bind_blob|bi
34550 6e 64 69 6e 67 73 5d 20 6f 6e 20 74 68 65 20 5b ndings] on the [
34560 70 72 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 prepared stateme
34570 6e 74 5d 20 53 2e 0a 2a 2f 0a 69 6e 74 20 73 71 nt] S..*/.int sq
34580 6c 69 74 65 33 5f 72 65 73 65 74 28 73 71 6c 69 lite3_reset(sqli
34590 74 65 33 5f 73 74 6d 74 20 2a 70 53 74 6d 74 29 te3_stmt *pStmt)
345a0 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 ;../*.** CAPI3RE
345b0 46 3a 20 43 72 65 61 74 65 20 4f 72 20 52 65 64 F: Create Or Red
345c0 65 66 69 6e 65 20 53 51 4c 20 46 75 6e 63 74 69 efine SQL Functi
345d0 6f 6e 73 0a 2a 2a 20 4b 45 59 57 4f 52 44 53 3a ons.** KEYWORDS:
345e0 20 7b 66 75 6e 63 74 69 6f 6e 20 63 72 65 61 74 {function creat
345f0 69 6f 6e 20 72 6f 75 74 69 6e 65 73 7d 0a 2a 2a ion routines}.**
34600 20 4b 45 59 57 4f 52 44 53 3a 20 7b 61 70 70 6c KEYWORDS: {appl
34610 69 63 61 74 69 6f 6e 2d 64 65 66 69 6e 65 64 20 ication-defined
34620 53 51 4c 20 66 75 6e 63 74 69 6f 6e 7d 0a 2a 2a SQL function}.**
34630 20 4b 45 59 57 4f 52 44 53 3a 20 7b 61 70 70 6c KEYWORDS: {appl
34640 69 63 61 74 69 6f 6e 2d 64 65 66 69 6e 65 64 20 ication-defined
34650 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73 7d 0a 2a SQL functions}.*
34660 2a 20 4d 45 54 48 4f 44 3a 20 73 71 6c 69 74 65 * METHOD: sqlite
34670 33 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 73 65 20 66 3.**.** ^These f
34680 75 6e 63 74 69 6f 6e 73 20 28 63 6f 6c 6c 65 63 unctions (collec
34690 74 69 76 65 6c 79 20 6b 6e 6f 77 6e 20 61 73 20 tively known as
346a0 22 66 75 6e 63 74 69 6f 6e 20 63 72 65 61 74 69 "function creati
346b0 6f 6e 20 72 6f 75 74 69 6e 65 73 22 29 0a 2a 2a on routines").**
346c0 20 61 72 65 20 75 73 65 64 20 74 6f 20 61 64 64 are used to add
346d0 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 6f SQL functions o
346e0 72 20 61 67 67 72 65 67 61 74 65 73 20 6f 72 20 r aggregates or
346f0 74 6f 20 72 65 64 65 66 69 6e 65 20 74 68 65 20 to redefine the
34700 62 65 68 61 76 69 6f 72 0a 2a 2a 20 6f 66 20 65 behavior.** of e
34710 78 69 73 74 69 6e 67 20 53 51 4c 20 66 75 6e 63 xisting SQL func
34720 74 69 6f 6e 73 20 6f 72 20 61 67 67 72 65 67 61 tions or aggrega
34730 74 65 73 2e 20 20 54 68 65 20 6f 6e 6c 79 20 64 tes. The only d
34740 69 66 66 65 72 65 6e 63 65 73 20 62 65 74 77 65 ifferences betwe
34750 65 6e 0a 2a 2a 20 74 68 65 73 65 20 72 6f 75 74 en.** these rout
34760 69 6e 65 73 20 61 72 65 20 74 68 65 20 74 65 78 ines are the tex
34770 74 20 65 6e 63 6f 64 69 6e 67 20 65 78 70 65 63 t encoding expec
34780 74 65 64 20 66 6f 72 0a 2a 2a 20 74 68 65 20 73 ted for.** the s
34790 65 63 6f 6e 64 20 70 61 72 61 6d 65 74 65 72 20 econd parameter
347a0 28 74 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 65 (the name of the
347b0 20 66 75 6e 63 74 69 6f 6e 20 62 65 69 6e 67 20 function being
347c0 63 72 65 61 74 65 64 29 0a 2a 2a 20 61 6e 64 20 created).** and
347d0 74 68 65 20 70 72 65 73 65 6e 63 65 20 6f 72 20 the presence or
347e0 61 62 73 65 6e 63 65 20 6f 66 20 61 20 64 65 73 absence of a des
347f0 74 72 75 63 74 6f 72 20 63 61 6c 6c 62 61 63 6b tructor callback
34800 20 66 6f 72 0a 2a 2a 20 74 68 65 20 61 70 70 6c for.** the appl
34810 69 63 61 74 69 6f 6e 20 64 61 74 61 20 70 6f 69 ication data poi
34820 6e 74 65 72 2e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 nter..**.** ^The
34830 20 66 69 72 73 74 20 70 61 72 61 6d 65 74 65 72 first parameter
34840 20 69 73 20 74 68 65 20 5b 64 61 74 61 62 61 73 is the [databas
34850 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 5d 20 74 6f e connection] to
34860 20 77 68 69 63 68 20 74 68 65 20 53 51 4c 0a 2a which the SQL.*
34870 2a 20 66 75 6e 63 74 69 6f 6e 20 69 73 20 74 6f * function is to
34880 20 62 65 20 61 64 64 65 64 2e 20 20 5e 49 66 20 be added. ^If
34890 61 6e 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 75 an application u
348a0 73 65 73 20 6d 6f 72 65 20 74 68 61 6e 20 6f 6e ses more than on
348b0 65 20 64 61 74 61 62 61 73 65 0a 2a 2a 20 63 6f e database.** co
348c0 6e 6e 65 63 74 69 6f 6e 20 74 68 65 6e 20 61 70 nnection then ap
348d0 70 6c 69 63 61 74 69 6f 6e 2d 64 65 66 69 6e 65 plication-define
348e0 64 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 d SQL functions
348f0 6d 75 73 74 20 62 65 20 61 64 64 65 64 0a 2a 2a must be added.**
34900 20 74 6f 20 65 61 63 68 20 64 61 74 61 62 61 73 to each databas
34910 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 73 65 70 e connection sep
34920 61 72 61 74 65 6c 79 2e 0a 2a 2a 0a 2a 2a 20 5e arately..**.** ^
34930 54 68 65 20 73 65 63 6f 6e 64 20 70 61 72 61 6d The second param
34940 65 74 65 72 20 69 73 20 74 68 65 20 6e 61 6d 65 eter is the name
34950 20 6f 66 20 74 68 65 20 53 51 4c 20 66 75 6e 63 of the SQL func
34960 74 69 6f 6e 20 74 6f 20 62 65 20 63 72 65 61 74 tion to be creat
34970 65 64 20 6f 72 0a 2a 2a 20 72 65 64 65 66 69 6e ed or.** redefin
34980 65 64 2e 20 20 5e 54 68 65 20 6c 65 6e 67 74 68 ed. ^The length
34990 20 6f 66 20 74 68 65 20 6e 61 6d 65 20 69 73 20 of the name is
349a0 6c 69 6d 69 74 65 64 20 74 6f 20 32 35 35 20 62 limited to 255 b
349b0 79 74 65 73 20 69 6e 20 61 20 55 54 46 2d 38 0a ytes in a UTF-8.
349c0 2a 2a 20 72 65 70 72 65 73 65 6e 74 61 74 69 6f ** representatio
349d0 6e 2c 20 65 78 63 6c 75 73 69 76 65 20 6f 66 20 n, exclusive of
349e0 74 68 65 20 7a 65 72 6f 2d 74 65 72 6d 69 6e 61 the zero-termina
349f0 74 6f 72 2e 20 20 5e 4e 6f 74 65 20 74 68 61 74 tor. ^Note that
34a00 20 74 68 65 20 6e 61 6d 65 0a 2a 2a 20 6c 65 6e the name.** len
34a10 67 74 68 20 6c 69 6d 69 74 20 69 73 20 69 6e 20 gth limit is in
34a20 55 54 46 2d 38 20 62 79 74 65 73 2c 20 6e 6f 74 UTF-8 bytes, not
34a30 20 63 68 61 72 61 63 74 65 72 73 20 6e 6f 72 20 characters nor
34a40 55 54 46 2d 31 36 20 62 79 74 65 73 2e 20 20 0a UTF-16 bytes. .
34a50 2a 2a 20 5e 41 6e 79 20 61 74 74 65 6d 70 74 20 ** ^Any attempt
34a60 74 6f 20 63 72 65 61 74 65 20 61 20 66 75 6e 63 to create a func
34a70 74 69 6f 6e 20 77 69 74 68 20 61 20 6c 6f 6e 67 tion with a long
34a80 65 72 20 6e 61 6d 65 0a 2a 2a 20 77 69 6c 6c 20 er name.** will
34a90 72 65 73 75 6c 74 20 69 6e 20 5b 53 51 4c 49 54 result in [SQLIT
34aa0 45 5f 4d 49 53 55 53 45 5d 20 62 65 69 6e 67 20 E_MISUSE] being
34ab0 72 65 74 75 72 6e 65 64 2e 0a 2a 2a 0a 2a 2a 20 returned..**.**
34ac0 5e 54 68 65 20 74 68 69 72 64 20 70 61 72 61 6d ^The third param
34ad0 65 74 65 72 20 28 6e 41 72 67 29 0a 2a 2a 20 69 eter (nArg).** i
34ae0 73 20 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 s the number of
34af0 61 72 67 75 6d 65 6e 74 73 20 74 68 61 74 20 74 arguments that t
34b00 68 65 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 he SQL function
34b10 6f 72 0a 2a 2a 20 61 67 67 72 65 67 61 74 65 20 or.** aggregate
34b20 74 61 6b 65 73 2e 20 5e 49 66 20 74 68 69 73 20 takes. ^If this
34b30 70 61 72 61 6d 65 74 65 72 20 69 73 20 2d 31 2c parameter is -1,
34b40 20 74 68 65 6e 20 74 68 65 20 53 51 4c 20 66 75 then the SQL fu
34b50 6e 63 74 69 6f 6e 20 6f 72 0a 2a 2a 20 61 67 67 nction or.** agg
34b60 72 65 67 61 74 65 20 6d 61 79 20 74 61 6b 65 20 regate may take
34b70 61 6e 79 20 6e 75 6d 62 65 72 20 6f 66 20 61 72 any number of ar
34b80 67 75 6d 65 6e 74 73 20 62 65 74 77 65 65 6e 20 guments between
34b90 30 20 61 6e 64 20 74 68 65 20 6c 69 6d 69 74 0a 0 and the limit.
34ba0 2a 2a 20 73 65 74 20 62 79 20 5b 73 71 6c 69 74 ** set by [sqlit
34bb0 65 33 5f 6c 69 6d 69 74 5d 28 5b 53 51 4c 49 54 e3_limit]([SQLIT
34bc0 45 5f 4c 49 4d 49 54 5f 46 55 4e 43 54 49 4f 4e E_LIMIT_FUNCTION
34bd0 5f 41 52 47 5d 29 2e 20 20 49 66 20 74 68 65 20 _ARG]). If the
34be0 74 68 69 72 64 0a 2a 2a 20 70 61 72 61 6d 65 74 third.** paramet
34bf0 65 72 20 69 73 20 6c 65 73 73 20 74 68 61 6e 20 er is less than
34c00 2d 31 20 6f 72 20 67 72 65 61 74 65 72 20 74 68 -1 or greater th
34c10 61 6e 20 31 32 37 20 74 68 65 6e 20 74 68 65 20 an 127 then the
34c20 62 65 68 61 76 69 6f 72 20 69 73 0a 2a 2a 20 75 behavior is.** u
34c30 6e 64 65 66 69 6e 65 64 2e 0a 2a 2a 0a 2a 2a 20 ndefined..**.**
34c40 5e 54 68 65 20 66 6f 75 72 74 68 20 70 61 72 61 ^The fourth para
34c50 6d 65 74 65 72 2c 20 65 54 65 78 74 52 65 70 2c meter, eTextRep,
34c60 20 73 70 65 63 69 66 69 65 73 20 77 68 61 74 0a specifies what.
34c70 2a 2a 20 5b 53 51 4c 49 54 45 5f 55 54 46 38 20 ** [SQLITE_UTF8
34c80 7c 20 74 65 78 74 20 65 6e 63 6f 64 69 6e 67 5d | text encoding]
34c90 20 74 68 69 73 20 53 51 4c 20 66 75 6e 63 74 69 this SQL functi
34ca0 6f 6e 20 70 72 65 66 65 72 73 20 66 6f 72 0a 2a on prefers for.*
34cb0 2a 20 69 74 73 20 70 61 72 61 6d 65 74 65 72 73 * its parameters
34cc0 2e 20 20 54 68 65 20 61 70 70 6c 69 63 61 74 69 . The applicati
34cd0 6f 6e 20 73 68 6f 75 6c 64 20 73 65 74 20 74 68 on should set th
34ce0 69 73 20 70 61 72 61 6d 65 74 65 72 20 74 6f 0a is parameter to.
34cf0 2a 2a 20 5b 53 51 4c 49 54 45 5f 55 54 46 31 36 ** [SQLITE_UTF16
34d00 4c 45 5d 20 69 66 20 74 68 65 20 66 75 6e 63 74 LE] if the funct
34d10 69 6f 6e 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 ion implementati
34d20 6f 6e 20 69 6e 76 6f 6b 65 73 20 0a 2a 2a 20 5b on invokes .** [
34d30 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f 74 65 sqlite3_value_te
34d40 78 74 31 36 6c 65 28 29 5d 20 6f 6e 20 61 6e 20 xt16le()] on an
34d50 69 6e 70 75 74 2c 20 6f 72 20 5b 53 51 4c 49 54 input, or [SQLIT
34d60 45 5f 55 54 46 31 36 42 45 5d 20 69 66 20 74 68 E_UTF16BE] if th
34d70 65 0a 2a 2a 20 69 6d 70 6c 65 6d 65 6e 74 61 74 e.** implementat
34d80 69 6f 6e 20 69 6e 76 6f 6b 65 73 20 5b 73 71 6c ion invokes [sql
34d90 69 74 65 33 5f 76 61 6c 75 65 5f 74 65 78 74 31 ite3_value_text1
34da0 36 62 65 28 29 5d 20 6f 6e 20 61 6e 20 69 6e 70 6be()] on an inp
34db0 75 74 2c 20 6f 72 0a 2a 2a 20 5b 53 51 4c 49 54 ut, or.** [SQLIT
34dc0 45 5f 55 54 46 31 36 5d 20 69 66 20 5b 73 71 6c E_UTF16] if [sql
34dd0 69 74 65 33 5f 76 61 6c 75 65 5f 74 65 78 74 31 ite3_value_text1
34de0 36 28 29 5d 20 69 73 20 75 73 65 64 2c 20 6f 72 6()] is used, or
34df0 20 5b 53 51 4c 49 54 45 5f 55 54 46 38 5d 0a 2a [SQLITE_UTF8].*
34e00 2a 20 6f 74 68 65 72 77 69 73 65 2e 20 20 5e 54 * otherwise. ^T
34e10 68 65 20 73 61 6d 65 20 53 51 4c 20 66 75 6e 63 he same SQL func
34e20 74 69 6f 6e 20 6d 61 79 20 62 65 20 72 65 67 69 tion may be regi
34e30 73 74 65 72 65 64 20 6d 75 6c 74 69 70 6c 65 20 stered multiple
34e40 74 69 6d 65 73 20 75 73 69 6e 67 0a 2a 2a 20 64 times using.** d
34e50 69 66 66 65 72 65 6e 74 20 70 72 65 66 65 72 72 ifferent preferr
34e60 65 64 20 74 65 78 74 20 65 6e 63 6f 64 69 6e 67 ed text encoding
34e70 73 2c 20 77 69 74 68 20 64 69 66 66 65 72 65 6e s, with differen
34e80 74 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e t implementation
34e90 73 20 66 6f 72 0a 2a 2a 20 65 61 63 68 20 65 6e s for.** each en
34ea0 63 6f 64 69 6e 67 2e 0a 2a 2a 20 5e 57 68 65 6e coding..** ^When
34eb0 20 6d 75 6c 74 69 70 6c 65 20 69 6d 70 6c 65 6d multiple implem
34ec0 65 6e 74 61 74 69 6f 6e 73 20 6f 66 20 74 68 65 entations of the
34ed0 20 73 61 6d 65 20 66 75 6e 63 74 69 6f 6e 20 61 same function a
34ee0 72 65 20 61 76 61 69 6c 61 62 6c 65 2c 20 53 51 re available, SQ
34ef0 4c 69 74 65 0a 2a 2a 20 77 69 6c 6c 20 70 69 63 Lite.** will pic
34f00 6b 20 74 68 65 20 6f 6e 65 20 74 68 61 74 20 69 k the one that i
34f10 6e 76 6f 6c 76 65 73 20 74 68 65 20 6c 65 61 73 nvolves the leas
34f20 74 20 61 6d 6f 75 6e 74 20 6f 66 20 64 61 74 61 t amount of data
34f30 20 63 6f 6e 76 65 72 73 69 6f 6e 2e 0a 2a 2a 0a conversion..**.
34f40 2a 2a 20 5e 54 68 65 20 66 6f 75 72 74 68 20 70 ** ^The fourth p
34f50 61 72 61 6d 65 74 65 72 20 6d 61 79 20 6f 70 74 arameter may opt
34f60 69 6f 6e 61 6c 6c 79 20 62 65 20 4f 52 65 64 20 ionally be ORed
34f70 77 69 74 68 20 5b 53 51 4c 49 54 45 5f 44 45 54 with [SQLITE_DET
34f80 45 52 4d 49 4e 49 53 54 49 43 5d 0a 2a 2a 20 74 ERMINISTIC].** t
34f90 6f 20 73 69 67 6e 61 6c 20 74 68 61 74 20 74 68 o signal that th
34fa0 65 20 66 75 6e 63 74 69 6f 6e 20 77 69 6c 6c 20 e function will
34fb0 61 6c 77 61 79 73 20 72 65 74 75 72 6e 20 74 68 always return th
34fc0 65 20 73 61 6d 65 20 72 65 73 75 6c 74 20 67 69 e same result gi
34fd0 76 65 6e 0a 2a 2a 20 74 68 65 20 73 61 6d 65 20 ven.** the same
34fe0 69 6e 70 75 74 73 20 77 69 74 68 69 6e 20 61 20 inputs within a
34ff0 73 69 6e 67 6c 65 20 53 51 4c 20 73 74 61 74 65 single SQL state
35000 6d 65 6e 74 2e 20 20 4d 6f 73 74 20 53 51 4c 20 ment. Most SQL
35010 66 75 6e 63 74 69 6f 6e 73 20 61 72 65 0a 2a 2a functions are.**
35020 20 64 65 74 65 72 6d 69 6e 69 73 74 69 63 2e 20 deterministic.
35030 20 54 68 65 20 62 75 69 6c 74 2d 69 6e 20 5b 72 The built-in [r
35040 61 6e 64 6f 6d 28 29 5d 20 53 51 4c 20 66 75 6e andom()] SQL fun
35050 63 74 69 6f 6e 20 69 73 20 61 6e 20 65 78 61 6d ction is an exam
35060 70 6c 65 20 6f 66 20 61 0a 2a 2a 20 66 75 6e 63 ple of a.** func
35070 74 69 6f 6e 20 74 68 61 74 20 69 73 20 6e 6f 74 tion that is not
35080 20 64 65 74 65 72 6d 69 6e 69 73 74 69 63 2e 20 deterministic.
35090 20 54 68 65 20 53 51 4c 69 74 65 20 71 75 65 72 The SQLite quer
350a0 79 20 70 6c 61 6e 6e 65 72 20 69 73 20 61 62 6c y planner is abl
350b0 65 20 74 6f 0a 2a 2a 20 70 65 72 66 6f 72 6d 20 e to.** perform
350c0 61 64 64 69 74 69 6f 6e 61 6c 20 6f 70 74 69 6d additional optim
350d0 69 7a 61 74 69 6f 6e 73 20 6f 6e 20 64 65 74 65 izations on dete
350e0 72 6d 69 6e 69 73 74 69 63 20 66 75 6e 63 74 69 rministic functi
350f0 6f 6e 73 2c 20 73 6f 20 75 73 65 0a 2a 2a 20 6f ons, so use.** o
35100 66 20 74 68 65 20 5b 53 51 4c 49 54 45 5f 44 45 f the [SQLITE_DE
35110 54 45 52 4d 49 4e 49 53 54 49 43 5d 20 66 6c 61 TERMINISTIC] fla
35120 67 20 69 73 20 72 65 63 6f 6d 6d 65 6e 64 65 64 g is recommended
35130 20 77 68 65 72 65 20 70 6f 73 73 69 62 6c 65 2e where possible.
35140 0a 2a 2a 0a 2a 2a 20 5e 28 54 68 65 20 66 69 66 .**.** ^(The fif
35150 74 68 20 70 61 72 61 6d 65 74 65 72 20 69 73 20 th parameter is
35160 61 6e 20 61 72 62 69 74 72 61 72 79 20 70 6f 69 an arbitrary poi
35170 6e 74 65 72 2e 20 20 54 68 65 20 69 6d 70 6c 65 nter. The imple
35180 6d 65 6e 74 61 74 69 6f 6e 20 6f 66 20 74 68 65 mentation of the
35190 0a 2a 2a 20 66 75 6e 63 74 69 6f 6e 20 63 61 6e .** function can
351a0 20 67 61 69 6e 20 61 63 63 65 73 73 20 74 6f 20 gain access to
351b0 74 68 69 73 20 70 6f 69 6e 74 65 72 20 75 73 69 this pointer usi
351c0 6e 67 20 5b 73 71 6c 69 74 65 33 5f 75 73 65 72 ng [sqlite3_user
351d0 5f 64 61 74 61 28 29 5d 2e 29 5e 0a 2a 2a 0a 2a _data()].)^.**.*
351e0 2a 20 5e 54 68 65 20 73 69 78 74 68 2c 20 73 65 * ^The sixth, se
351f0 76 65 6e 74 68 20 61 6e 64 20 65 69 67 68 74 68 venth and eighth
35200 20 70 61 72 61 6d 65 74 65 72 73 2c 20 78 46 75 parameters, xFu
35210 6e 63 2c 20 78 53 74 65 70 20 61 6e 64 20 78 46 nc, xStep and xF
35220 69 6e 61 6c 2c 20 61 72 65 0a 2a 2a 20 70 6f 69 inal, are.** poi
35230 6e 74 65 72 73 20 74 6f 20 43 2d 6c 61 6e 67 75 nters to C-langu
35240 61 67 65 20 66 75 6e 63 74 69 6f 6e 73 20 74 68 age functions th
35250 61 74 20 69 6d 70 6c 65 6d 65 6e 74 20 74 68 65 at implement the
35260 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 6f 72 SQL function or
35270 0a 2a 2a 20 61 67 67 72 65 67 61 74 65 2e 20 5e .** aggregate. ^
35280 41 20 73 63 61 6c 61 72 20 53 51 4c 20 66 75 6e A scalar SQL fun
35290 63 74 69 6f 6e 20 72 65 71 75 69 72 65 73 20 61 ction requires a
352a0 6e 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e n implementation
352b0 20 6f 66 20 74 68 65 20 78 46 75 6e 63 0a 2a 2a of the xFunc.**
352c0 20 63 61 6c 6c 62 61 63 6b 20 6f 6e 6c 79 3b 20 callback only;
352d0 4e 55 4c 4c 20 70 6f 69 6e 74 65 72 73 20 6d 75 NULL pointers mu
352e0 73 74 20 62 65 20 70 61 73 73 65 64 20 61 73 20 st be passed as
352f0 74 68 65 20 78 53 74 65 70 20 61 6e 64 20 78 46 the xStep and xF
35300 69 6e 61 6c 0a 2a 2a 20 70 61 72 61 6d 65 74 65 inal.** paramete
35310 72 73 2e 20 5e 41 6e 20 61 67 67 72 65 67 61 74 rs. ^An aggregat
35320 65 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 72 e SQL function r
35330 65 71 75 69 72 65 73 20 61 6e 20 69 6d 70 6c 65 equires an imple
35340 6d 65 6e 74 61 74 69 6f 6e 20 6f 66 20 78 53 74 mentation of xSt
35350 65 70 0a 2a 2a 20 61 6e 64 20 78 46 69 6e 61 6c ep.** and xFinal
35360 20 61 6e 64 20 4e 55 4c 4c 20 70 6f 69 6e 74 65 and NULL pointe
35370 72 20 6d 75 73 74 20 62 65 20 70 61 73 73 65 64 r must be passed
35380 20 66 6f 72 20 78 46 75 6e 63 2e 20 5e 54 6f 20 for xFunc. ^To
35390 64 65 6c 65 74 65 20 61 6e 20 65 78 69 73 74 69 delete an existi
353a0 6e 67 0a 2a 2a 20 53 51 4c 20 66 75 6e 63 74 69 ng.** SQL functi
353b0 6f 6e 20 6f 72 20 61 67 67 72 65 67 61 74 65 2c on or aggregate,
353c0 20 70 61 73 73 20 4e 55 4c 4c 20 70 6f 69 6e 74 pass NULL point
353d0 65 72 73 20 66 6f 72 20 61 6c 6c 20 74 68 72 65 ers for all thre
353e0 65 20 66 75 6e 63 74 69 6f 6e 0a 2a 2a 20 63 61 e function.** ca
353f0 6c 6c 62 61 63 6b 73 2e 0a 2a 2a 0a 2a 2a 20 5e llbacks..**.** ^
35400 28 49 66 20 74 68 65 20 6e 69 6e 74 68 20 70 61 (If the ninth pa
35410 72 61 6d 65 74 65 72 20 74 6f 20 73 71 6c 69 74 rameter to sqlit
35420 65 33 5f 63 72 65 61 74 65 5f 66 75 6e 63 74 69 e3_create_functi
35430 6f 6e 5f 76 32 28 29 20 69 73 20 6e 6f 74 20 4e on_v2() is not N
35440 55 4c 4c 2c 0a 2a 2a 20 74 68 65 6e 20 69 74 20 ULL,.** then it
35450 69 73 20 64 65 73 74 72 75 63 74 6f 72 20 66 6f is destructor fo
35460 72 20 74 68 65 20 61 70 70 6c 69 63 61 74 69 6f r the applicatio
35470 6e 20 64 61 74 61 20 70 6f 69 6e 74 65 72 2e 20 n data pointer.
35480 0a 2a 2a 20 54 68 65 20 64 65 73 74 72 75 63 74 .** The destruct
35490 6f 72 20 69 73 20 69 6e 76 6f 6b 65 64 20 77 68 or is invoked wh
354a0 65 6e 20 74 68 65 20 66 75 6e 63 74 69 6f 6e 20 en the function
354b0 69 73 20 64 65 6c 65 74 65 64 2c 20 65 69 74 68 is deleted, eith
354c0 65 72 20 62 79 20 62 65 69 6e 67 0a 2a 2a 20 6f er by being.** o
354d0 76 65 72 6c 6f 61 64 65 64 20 6f 72 20 77 68 65 verloaded or whe
354e0 6e 20 74 68 65 20 64 61 74 61 62 61 73 65 20 63 n the database c
354f0 6f 6e 6e 65 63 74 69 6f 6e 20 63 6c 6f 73 65 73 onnection closes
35500 2e 29 5e 0a 2a 2a 20 5e 54 68 65 20 64 65 73 74 .)^.** ^The dest
35510 72 75 63 74 6f 72 20 69 73 20 61 6c 73 6f 20 69 ructor is also i
35520 6e 76 6f 6b 65 64 20 69 66 20 74 68 65 20 63 61 nvoked if the ca
35530 6c 6c 20 74 6f 0a 2a 2a 20 73 71 6c 69 74 65 33 ll to.** sqlite3
35540 5f 63 72 65 61 74 65 5f 66 75 6e 63 74 69 6f 6e _create_function
35550 5f 76 32 28 29 20 66 61 69 6c 73 2e 0a 2a 2a 20 _v2() fails..**
35560 5e 57 68 65 6e 20 74 68 65 20 64 65 73 74 72 75 ^When the destru
35570 63 74 6f 72 20 63 61 6c 6c 62 61 63 6b 20 6f 66 ctor callback of
35580 20 74 68 65 20 74 65 6e 74 68 20 70 61 72 61 6d the tenth param
35590 65 74 65 72 20 69 73 20 69 6e 76 6f 6b 65 64 2c eter is invoked,
355a0 20 69 74 0a 2a 2a 20 69 73 20 70 61 73 73 65 64 it.** is passed
355b0 20 61 20 73 69 6e 67 6c 65 20 61 72 67 75 6d 65 a single argume
355c0 6e 74 20 77 68 69 63 68 20 69 73 20 61 20 63 6f nt which is a co
355d0 70 79 20 6f 66 20 74 68 65 20 61 70 70 6c 69 63 py of the applic
355e0 61 74 69 6f 6e 20 64 61 74 61 20 0a 2a 2a 20 70 ation data .** p
355f0 6f 69 6e 74 65 72 20 77 68 69 63 68 20 77 61 73 ointer which was
35600 20 74 68 65 20 66 69 66 74 68 20 70 61 72 61 6d the fifth param
35610 65 74 65 72 20 74 6f 20 73 71 6c 69 74 65 33 5f eter to sqlite3_
35620 63 72 65 61 74 65 5f 66 75 6e 63 74 69 6f 6e 5f create_function_
35630 76 32 28 29 2e 0a 2a 2a 0a 2a 2a 20 5e 49 74 20 v2()..**.** ^It
35640 69 73 20 70 65 72 6d 69 74 74 65 64 20 74 6f 20 is permitted to
35650 72 65 67 69 73 74 65 72 20 6d 75 6c 74 69 70 6c register multipl
35660 65 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e e implementation
35670 73 20 6f 66 20 74 68 65 20 73 61 6d 65 0a 2a 2a s of the same.**
35680 20 66 75 6e 63 74 69 6f 6e 73 20 77 69 74 68 20 functions with
35690 74 68 65 20 73 61 6d 65 20 6e 61 6d 65 20 62 75 the same name bu
356a0 74 20 77 69 74 68 20 65 69 74 68 65 72 20 64 69 t with either di
356b0 66 66 65 72 69 6e 67 20 6e 75 6d 62 65 72 73 20 ffering numbers
356c0 6f 66 0a 2a 2a 20 61 72 67 75 6d 65 6e 74 73 20 of.** arguments
356d0 6f 72 20 64 69 66 66 65 72 69 6e 67 20 70 72 65 or differing pre
356e0 66 65 72 72 65 64 20 74 65 78 74 20 65 6e 63 6f ferred text enco
356f0 64 69 6e 67 73 2e 20 20 5e 53 51 4c 69 74 65 20 dings. ^SQLite
35700 77 69 6c 6c 20 75 73 65 0a 2a 2a 20 74 68 65 20 will use.** the
35710 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 74 implementation t
35720 68 61 74 20 6d 6f 73 74 20 63 6c 6f 73 65 6c 79 hat most closely
35730 20 6d 61 74 63 68 65 73 20 74 68 65 20 77 61 79 matches the way
35740 20 69 6e 20 77 68 69 63 68 20 74 68 65 0a 2a 2a in which the.**
35750 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 20 69 73 SQL function is
35760 20 75 73 65 64 2e 20 20 5e 41 20 66 75 6e 63 74 used. ^A funct
35770 69 6f 6e 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 ion implementati
35780 6f 6e 20 77 69 74 68 20 61 20 6e 6f 6e 2d 6e 65 on with a non-ne
35790 67 61 74 69 76 65 0a 2a 2a 20 6e 41 72 67 20 70 gative.** nArg p
357a0 61 72 61 6d 65 74 65 72 20 69 73 20 61 20 62 65 arameter is a be
357b0 74 74 65 72 20 6d 61 74 63 68 20 74 68 61 6e 20 tter match than
357c0 61 20 66 75 6e 63 74 69 6f 6e 20 69 6d 70 6c 65 a function imple
357d0 6d 65 6e 74 61 74 69 6f 6e 20 77 69 74 68 0a 2a mentation with.*
357e0 2a 20 61 20 6e 65 67 61 74 69 76 65 20 6e 41 72 * a negative nAr
357f0 67 2e 20 20 5e 41 20 66 75 6e 63 74 69 6f 6e 20 g. ^A function
35800 77 68 65 72 65 20 74 68 65 20 70 72 65 66 65 72 where the prefer
35810 72 65 64 20 74 65 78 74 20 65 6e 63 6f 64 69 6e red text encodin
35820 67 0a 2a 2a 20 6d 61 74 63 68 65 73 20 74 68 65 g.** matches the
35830 20 64 61 74 61 62 61 73 65 20 65 6e 63 6f 64 69 database encodi
35840 6e 67 20 69 73 20 61 20 62 65 74 74 65 72 0a 2a ng is a better.*
35850 2a 20 6d 61 74 63 68 20 74 68 61 6e 20 61 20 66 * match than a f
35860 75 6e 63 74 69 6f 6e 20 77 68 65 72 65 20 74 68 unction where th
35870 65 20 65 6e 63 6f 64 69 6e 67 20 69 73 20 64 69 e encoding is di
35880 66 66 65 72 65 6e 74 2e 20 20 0a 2a 2a 20 5e 41 fferent. .** ^A
35890 20 66 75 6e 63 74 69 6f 6e 20 77 68 65 72 65 20 function where
358a0 74 68 65 20 65 6e 63 6f 64 69 6e 67 20 64 69 66 the encoding dif
358b0 66 65 72 65 6e 63 65 20 69 73 20 62 65 74 77 65 ference is betwe
358c0 65 6e 20 55 54 46 31 36 6c 65 20 61 6e 64 20 55 en UTF16le and U
358d0 54 46 31 36 62 65 0a 2a 2a 20 69 73 20 61 20 63 TF16be.** is a c
358e0 6c 6f 73 65 72 20 6d 61 74 63 68 20 74 68 61 6e loser match than
358f0 20 61 20 66 75 6e 63 74 69 6f 6e 20 77 68 65 72 a function wher
35900 65 20 74 68 65 20 65 6e 63 6f 64 69 6e 67 20 64 e the encoding d
35910 69 66 66 65 72 65 6e 63 65 20 69 73 0a 2a 2a 20 ifference is.**
35920 62 65 74 77 65 65 6e 20 55 54 46 38 20 61 6e 64 between UTF8 and
35930 20 55 54 46 31 36 2e 0a 2a 2a 0a 2a 2a 20 5e 42 UTF16..**.** ^B
35940 75 69 6c 74 2d 69 6e 20 66 75 6e 63 74 69 6f 6e uilt-in function
35950 73 20 6d 61 79 20 62 65 20 6f 76 65 72 6c 6f 61 s may be overloa
35960 64 65 64 20 62 79 20 6e 65 77 20 61 70 70 6c 69 ded by new appli
35970 63 61 74 69 6f 6e 2d 64 65 66 69 6e 65 64 20 66 cation-defined f
35980 75 6e 63 74 69 6f 6e 73 2e 0a 2a 2a 0a 2a 2a 20 unctions..**.**
35990 5e 41 6e 20 61 70 70 6c 69 63 61 74 69 6f 6e 2d ^An application-
359a0 64 65 66 69 6e 65 64 20 66 75 6e 63 74 69 6f 6e defined function
359b0 20 69 73 20 70 65 72 6d 69 74 74 65 64 20 74 6f is permitted to
359c0 20 63 61 6c 6c 20 6f 74 68 65 72 0a 2a 2a 20 53 call other.** S
359d0 51 4c 69 74 65 20 69 6e 74 65 72 66 61 63 65 73 QLite interfaces
359e0 2e 20 20 48 6f 77 65 76 65 72 2c 20 73 75 63 68 . However, such
359f0 20 63 61 6c 6c 73 20 6d 75 73 74 20 6e 6f 74 0a calls must not.
35a00 2a 2a 20 63 6c 6f 73 65 20 74 68 65 20 64 61 74 ** close the dat
35a10 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e abase connection
35a20 20 6e 6f 72 20 66 69 6e 61 6c 69 7a 65 20 6f 72 nor finalize or
35a30 20 72 65 73 65 74 20 74 68 65 20 70 72 65 70 61 reset the prepa
35a40 72 65 64 0a 2a 2a 20 73 74 61 74 65 6d 65 6e 74 red.** statement
35a50 20 69 6e 20 77 68 69 63 68 20 74 68 65 20 66 75 in which the fu
35a60 6e 63 74 69 6f 6e 20 69 73 20 72 75 6e 6e 69 6e nction is runnin
35a70 67 2e 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 65 g..*/.int sqlite
35a80 33 5f 63 72 65 61 74 65 5f 66 75 6e 63 74 69 6f 3_create_functio
35a90 6e 28 0a 20 20 73 71 6c 69 74 65 33 20 2a 64 62 n(. sqlite3 *db
35aa0 2c 0a 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a ,. const char *
35ab0 7a 46 75 6e 63 74 69 6f 6e 4e 61 6d 65 2c 0a 20 zFunctionName,.
35ac0 20 69 6e 74 20 6e 41 72 67 2c 0a 20 20 69 6e 74 int nArg,. int
35ad0 20 65 54 65 78 74 52 65 70 2c 0a 20 20 76 6f 69 eTextRep,. voi
35ae0 64 20 2a 70 41 70 70 2c 0a 20 20 76 6f 69 64 20 d *pApp,. void
35af0 28 2a 78 46 75 6e 63 29 28 73 71 6c 69 74 65 33 (*xFunc)(sqlite3
35b00 5f 63 6f 6e 74 65 78 74 2a 2c 69 6e 74 2c 73 71 _context*,int,sq
35b10 6c 69 74 65 33 5f 76 61 6c 75 65 2a 2a 29 2c 0a lite3_value**),.
35b20 20 20 76 6f 69 64 20 28 2a 78 53 74 65 70 29 28 void (*xStep)(
35b30 73 71 6c 69 74 65 33 5f 63 6f 6e 74 65 78 74 2a sqlite3_context*
35b40 2c 69 6e 74 2c 73 71 6c 69 74 65 33 5f 76 61 6c ,int,sqlite3_val
35b50 75 65 2a 2a 29 2c 0a 20 20 76 6f 69 64 20 28 2a ue**),. void (*
35b60 78 46 69 6e 61 6c 29 28 73 71 6c 69 74 65 33 5f xFinal)(sqlite3_
35b70 63 6f 6e 74 65 78 74 2a 29 0a 29 3b 0a 69 6e 74 context*).);.int
35b80 20 73 71 6c 69 74 65 33 5f 63 72 65 61 74 65 5f sqlite3_create_
35b90 66 75 6e 63 74 69 6f 6e 31 36 28 0a 20 20 73 71 function16(. sq
35ba0 6c 69 74 65 33 20 2a 64 62 2c 0a 20 20 63 6f 6e lite3 *db,. con
35bb0 73 74 20 76 6f 69 64 20 2a 7a 46 75 6e 63 74 69 st void *zFuncti
35bc0 6f 6e 4e 61 6d 65 2c 0a 20 20 69 6e 74 20 6e 41 onName,. int nA
35bd0 72 67 2c 0a 20 20 69 6e 74 20 65 54 65 78 74 52 rg,. int eTextR
35be0 65 70 2c 0a 20 20 76 6f 69 64 20 2a 70 41 70 70 ep,. void *pApp
35bf0 2c 0a 20 20 76 6f 69 64 20 28 2a 78 46 75 6e 63 ,. void (*xFunc
35c00 29 28 73 71 6c 69 74 65 33 5f 63 6f 6e 74 65 78 )(sqlite3_contex
35c10 74 2a 2c 69 6e 74 2c 73 71 6c 69 74 65 33 5f 76 t*,int,sqlite3_v
35c20 61 6c 75 65 2a 2a 29 2c 0a 20 20 76 6f 69 64 20 alue**),. void
35c30 28 2a 78 53 74 65 70 29 28 73 71 6c 69 74 65 33 (*xStep)(sqlite3
35c40 5f 63 6f 6e 74 65 78 74 2a 2c 69 6e 74 2c 73 71 _context*,int,sq
35c50 6c 69 74 65 33 5f 76 61 6c 75 65 2a 2a 29 2c 0a lite3_value**),.
35c60 20 20 76 6f 69 64 20 28 2a 78 46 69 6e 61 6c 29 void (*xFinal)
35c70 28 73 71 6c 69 74 65 33 5f 63 6f 6e 74 65 78 74 (sqlite3_context
35c80 2a 29 0a 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 *).);.int sqlite
35c90 33 5f 63 72 65 61 74 65 5f 66 75 6e 63 74 69 6f 3_create_functio
35ca0 6e 5f 76 32 28 0a 20 20 73 71 6c 69 74 65 33 20 n_v2(. sqlite3
35cb0 2a 64 62 2c 0a 20 20 63 6f 6e 73 74 20 63 68 61 *db,. const cha
35cc0 72 20 2a 7a 46 75 6e 63 74 69 6f 6e 4e 61 6d 65 r *zFunctionName
35cd0 2c 0a 20 20 69 6e 74 20 6e 41 72 67 2c 0a 20 20 ,. int nArg,.
35ce0 69 6e 74 20 65 54 65 78 74 52 65 70 2c 0a 20 20 int eTextRep,.
35cf0 76 6f 69 64 20 2a 70 41 70 70 2c 0a 20 20 76 6f void *pApp,. vo
35d00 69 64 20 28 2a 78 46 75 6e 63 29 28 73 71 6c 69 id (*xFunc)(sqli
35d10 74 65 33 5f 63 6f 6e 74 65 78 74 2a 2c 69 6e 74 te3_context*,int
35d20 2c 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 2a 2a ,sqlite3_value**
35d30 29 2c 0a 20 20 76 6f 69 64 20 28 2a 78 53 74 65 ),. void (*xSte
35d40 70 29 28 73 71 6c 69 74 65 33 5f 63 6f 6e 74 65 p)(sqlite3_conte
35d50 78 74 2a 2c 69 6e 74 2c 73 71 6c 69 74 65 33 5f xt*,int,sqlite3_
35d60 76 61 6c 75 65 2a 2a 29 2c 0a 20 20 76 6f 69 64 value**),. void
35d70 20 28 2a 78 46 69 6e 61 6c 29 28 73 71 6c 69 74 (*xFinal)(sqlit
35d80 65 33 5f 63 6f 6e 74 65 78 74 2a 29 2c 0a 20 20 e3_context*),.
35d90 76 6f 69 64 28 2a 78 44 65 73 74 72 6f 79 29 28 void(*xDestroy)(
35da0 76 6f 69 64 2a 29 0a 29 3b 0a 0a 2f 2a 0a 2a 2a void*).);../*.**
35db0 20 43 41 50 49 33 52 45 46 3a 20 54 65 78 74 20 CAPI3REF: Text
35dc0 45 6e 63 6f 64 69 6e 67 73 0a 2a 2a 0a 2a 2a 20 Encodings.**.**
35dd0 54 68 65 73 65 20 63 6f 6e 73 74 61 6e 74 20 64 These constant d
35de0 65 66 69 6e 65 20 69 6e 74 65 67 65 72 20 63 6f efine integer co
35df0 64 65 73 20 74 68 61 74 20 72 65 70 72 65 73 65 des that represe
35e00 6e 74 20 74 68 65 20 76 61 72 69 6f 75 73 0a 2a nt the various.*
35e10 2a 20 74 65 78 74 20 65 6e 63 6f 64 69 6e 67 73 * text encodings
35e20 20 73 75 70 70 6f 72 74 65 64 20 62 79 20 53 51 supported by SQ
35e30 4c 69 74 65 2e 0a 2a 2f 0a 23 64 65 66 69 6e 65 Lite..*/.#define
35e40 20 53 51 4c 49 54 45 5f 55 54 46 38 20 20 20 20 SQLITE_UTF8
35e50 20 20 20 20 20 20 20 31 20 20 20 20 2f 2a 20 49 1 /* I
35e60 4d 50 3a 20 52 2d 33 37 35 31 34 2d 33 35 35 36 MP: R-37514-3556
35e70 36 20 2a 2f 0a 23 64 65 66 69 6e 65 20 53 51 4c 6 */.#define SQL
35e80 49 54 45 5f 55 54 46 31 36 4c 45 20 20 20 20 20 ITE_UTF16LE
35e90 20 20 20 32 20 20 20 20 2f 2a 20 49 4d 50 3a 20 2 /* IMP:
35ea0 52 2d 30 33 33 37 31 2d 33 37 36 33 37 20 2a 2f R-03371-37637 */
35eb0 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f .#define SQLITE_
35ec0 55 54 46 31 36 42 45 20 20 20 20 20 20 20 20 33 UTF16BE 3
35ed0 20 20 20 20 2f 2a 20 49 4d 50 3a 20 52 2d 35 31 /* IMP: R-51
35ee0 39 37 31 2d 33 34 31 35 34 20 2a 2f 0a 23 64 65 971-34154 */.#de
35ef0 66 69 6e 65 20 53 51 4c 49 54 45 5f 55 54 46 31 fine SQLITE_UTF1
35f00 36 20 20 20 20 20 20 20 20 20 20 34 20 20 20 20 6 4
35f10 2f 2a 20 55 73 65 20 6e 61 74 69 76 65 20 62 79 /* Use native by
35f20 74 65 20 6f 72 64 65 72 20 2a 2f 0a 23 64 65 66 te order */.#def
35f30 69 6e 65 20 53 51 4c 49 54 45 5f 41 4e 59 20 20 ine SQLITE_ANY
35f40 20 20 20 20 20 20 20 20 20 20 35 20 20 20 20 2f 5 /
35f50 2a 20 44 65 70 72 65 63 61 74 65 64 20 2a 2f 0a * Deprecated */.
35f60 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f 55 #define SQLITE_U
35f70 54 46 31 36 5f 41 4c 49 47 4e 45 44 20 20 38 20 TF16_ALIGNED 8
35f80 20 20 20 2f 2a 20 73 71 6c 69 74 65 33 5f 63 72 /* sqlite3_cr
35f90 65 61 74 65 5f 63 6f 6c 6c 61 74 69 6f 6e 20 6f eate_collation o
35fa0 6e 6c 79 20 2a 2f 0a 0a 2f 2a 0a 2a 2a 20 43 41 nly */../*.** CA
35fb0 50 49 33 52 45 46 3a 20 46 75 6e 63 74 69 6f 6e PI3REF: Function
35fc0 20 46 6c 61 67 73 0a 2a 2a 0a 2a 2a 20 54 68 65 Flags.**.** The
35fd0 73 65 20 63 6f 6e 73 74 61 6e 74 73 20 6d 61 79 se constants may
35fe0 20 62 65 20 4f 52 65 64 20 74 6f 67 65 74 68 65 be ORed togethe
35ff0 72 20 77 69 74 68 20 74 68 65 20 0a 2a 2a 20 5b r with the .** [
36000 53 51 4c 49 54 45 5f 55 54 46 38 20 7c 20 70 72 SQLITE_UTF8 | pr
36010 65 66 65 72 72 65 64 20 74 65 78 74 20 65 6e 63 eferred text enc
36020 6f 64 69 6e 67 5d 20 61 73 20 74 68 65 20 66 6f oding] as the fo
36030 75 72 74 68 20 61 72 67 75 6d 65 6e 74 0a 2a 2a urth argument.**
36040 20 74 6f 20 5b 73 71 6c 69 74 65 33 5f 63 72 65 to [sqlite3_cre
36050 61 74 65 5f 66 75 6e 63 74 69 6f 6e 28 29 5d 2c ate_function()],
36060 20 5b 73 71 6c 69 74 65 33 5f 63 72 65 61 74 65 [sqlite3_create
36070 5f 66 75 6e 63 74 69 6f 6e 31 36 28 29 5d 2c 20 _function16()],
36080 6f 72 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f 63 or.** [sqlite3_c
36090 72 65 61 74 65 5f 66 75 6e 63 74 69 6f 6e 5f 76 reate_function_v
360a0 32 28 29 5d 2e 0a 2a 2f 0a 23 64 65 66 69 6e 65 2()]..*/.#define
360b0 20 53 51 4c 49 54 45 5f 44 45 54 45 52 4d 49 4e SQLITE_DETERMIN
360c0 49 53 54 49 43 20 20 20 20 30 78 38 30 30 0a 0a ISTIC 0x800..
360d0 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 /*.** CAPI3REF:
360e0 44 65 70 72 65 63 61 74 65 64 20 46 75 6e 63 74 Deprecated Funct
360f0 69 6f 6e 73 0a 2a 2a 20 44 45 50 52 45 43 41 54 ions.** DEPRECAT
36100 45 44 0a 2a 2a 0a 2a 2a 20 54 68 65 73 65 20 66 ED.**.** These f
36110 75 6e 63 74 69 6f 6e 73 20 61 72 65 20 5b 64 65 unctions are [de
36120 70 72 65 63 61 74 65 64 5d 2e 20 20 49 6e 20 6f precated]. In o
36130 72 64 65 72 20 74 6f 20 6d 61 69 6e 74 61 69 6e rder to maintain
36140 0a 2a 2a 20 62 61 63 6b 77 61 72 64 73 20 63 6f .** backwards co
36150 6d 70 61 74 69 62 69 6c 69 74 79 20 77 69 74 68 mpatibility with
36160 20 6f 6c 64 65 72 20 63 6f 64 65 2c 20 74 68 65 older code, the
36170 73 65 20 66 75 6e 63 74 69 6f 6e 73 20 63 6f 6e se functions con
36180 74 69 6e 75 65 20 0a 2a 2a 20 74 6f 20 62 65 20 tinue .** to be
36190 73 75 70 70 6f 72 74 65 64 2e 20 20 48 6f 77 65 supported. Howe
361a0 76 65 72 2c 20 6e 65 77 20 61 70 70 6c 69 63 61 ver, new applica
361b0 74 69 6f 6e 73 20 73 68 6f 75 6c 64 20 61 76 6f tions should avo
361c0 69 64 0a 2a 2a 20 74 68 65 20 75 73 65 20 6f 66 id.** the use of
361d0 20 74 68 65 73 65 20 66 75 6e 63 74 69 6f 6e 73 these functions
361e0 2e 20 20 54 6f 20 65 6e 63 6f 75 72 61 67 65 20 . To encourage
361f0 70 72 6f 67 72 61 6d 6d 65 72 73 20 74 6f 20 61 programmers to a
36200 76 6f 69 64 0a 2a 2a 20 74 68 65 73 65 20 66 75 void.** these fu
36210 6e 63 74 69 6f 6e 73 2c 20 77 65 20 77 69 6c 6c nctions, we will
36220 20 6e 6f 74 20 65 78 70 6c 61 69 6e 20 77 68 61 not explain wha
36230 74 20 74 68 65 79 20 64 6f 2e 0a 2a 2f 0a 23 69 t they do..*/.#i
36240 66 6e 64 65 66 20 53 51 4c 49 54 45 5f 4f 4d 49 fndef SQLITE_OMI
36250 54 5f 44 45 50 52 45 43 41 54 45 44 0a 53 51 4c T_DEPRECATED.SQL
36260 49 54 45 5f 44 45 50 52 45 43 41 54 45 44 20 69 ITE_DEPRECATED i
36270 6e 74 20 73 71 6c 69 74 65 33 5f 61 67 67 72 65 nt sqlite3_aggre
36280 67 61 74 65 5f 63 6f 75 6e 74 28 73 71 6c 69 74 gate_count(sqlit
36290 65 33 5f 63 6f 6e 74 65 78 74 2a 29 3b 0a 53 51 e3_context*);.SQ
362a0 4c 49 54 45 5f 44 45 50 52 45 43 41 54 45 44 20 LITE_DEPRECATED
362b0 69 6e 74 20 73 71 6c 69 74 65 33 5f 65 78 70 69 int sqlite3_expi
362c0 72 65 64 28 73 71 6c 69 74 65 33 5f 73 74 6d 74 red(sqlite3_stmt
362d0 2a 29 3b 0a 53 51 4c 49 54 45 5f 44 45 50 52 45 *);.SQLITE_DEPRE
362e0 43 41 54 45 44 20 69 6e 74 20 73 71 6c 69 74 65 CATED int sqlite
362f0 33 5f 74 72 61 6e 73 66 65 72 5f 62 69 6e 64 69 3_transfer_bindi
36300 6e 67 73 28 73 71 6c 69 74 65 33 5f 73 74 6d 74 ngs(sqlite3_stmt
36310 2a 2c 20 73 71 6c 69 74 65 33 5f 73 74 6d 74 2a *, sqlite3_stmt*
36320 29 3b 0a 53 51 4c 49 54 45 5f 44 45 50 52 45 43 );.SQLITE_DEPREC
36330 41 54 45 44 20 69 6e 74 20 73 71 6c 69 74 65 33 ATED int sqlite3
36340 5f 67 6c 6f 62 61 6c 5f 72 65 63 6f 76 65 72 28 _global_recover(
36350 76 6f 69 64 29 3b 0a 53 51 4c 49 54 45 5f 44 45 void);.SQLITE_DE
36360 50 52 45 43 41 54 45 44 20 76 6f 69 64 20 73 71 PRECATED void sq
36370 6c 69 74 65 33 5f 74 68 72 65 61 64 5f 63 6c 65 lite3_thread_cle
36380 61 6e 75 70 28 76 6f 69 64 29 3b 0a 53 51 4c 49 anup(void);.SQLI
36390 54 45 5f 44 45 50 52 45 43 41 54 45 44 20 69 6e TE_DEPRECATED in
363a0 74 20 73 71 6c 69 74 65 33 5f 6d 65 6d 6f 72 79 t sqlite3_memory
363b0 5f 61 6c 61 72 6d 28 76 6f 69 64 28 2a 29 28 76 _alarm(void(*)(v
363c0 6f 69 64 2a 2c 73 71 6c 69 74 65 33 5f 69 6e 74 oid*,sqlite3_int
363d0 36 34 2c 69 6e 74 29 2c 0a 20 20 20 20 20 20 20 64,int),.
363e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 v
363f0 6f 69 64 2a 2c 73 71 6c 69 74 65 33 5f 69 6e 74 oid*,sqlite3_int
36400 36 34 29 3b 0a 23 65 6e 64 69 66 0a 0a 2f 2a 0a 64);.#endif../*.
36410 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 4f 62 74 ** CAPI3REF: Obt
36420 61 69 6e 69 6e 67 20 53 51 4c 20 56 61 6c 75 65 aining SQL Value
36430 73 0a 2a 2a 20 4d 45 54 48 4f 44 3a 20 73 71 6c s.** METHOD: sql
36440 69 74 65 33 5f 76 61 6c 75 65 0a 2a 2a 0a 2a 2a ite3_value.**.**
36450 20 54 68 65 20 43 2d 6c 61 6e 67 75 61 67 65 20 The C-language
36460 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 6f implementation o
36470 66 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 f SQL functions
36480 61 6e 64 20 61 67 67 72 65 67 61 74 65 73 20 75 and aggregates u
36490 73 65 73 0a 2a 2a 20 74 68 69 73 20 73 65 74 20 ses.** this set
364a0 6f 66 20 69 6e 74 65 72 66 61 63 65 20 72 6f 75 of interface rou
364b0 74 69 6e 65 73 20 74 6f 20 61 63 63 65 73 73 20 tines to access
364c0 74 68 65 20 70 61 72 61 6d 65 74 65 72 20 76 61 the parameter va
364d0 6c 75 65 73 20 6f 6e 0a 2a 2a 20 74 68 65 20 66 lues on.** the f
364e0 75 6e 63 74 69 6f 6e 20 6f 72 20 61 67 67 72 65 unction or aggre
364f0 67 61 74 65 2e 20 20 0a 2a 2a 0a 2a 2a 20 54 68 gate. .**.** Th
36500 65 20 78 46 75 6e 63 20 28 66 6f 72 20 73 63 61 e xFunc (for sca
36510 6c 61 72 20 66 75 6e 63 74 69 6f 6e 73 29 20 6f lar functions) o
36520 72 20 78 53 74 65 70 20 28 66 6f 72 20 61 67 67 r xStep (for agg
36530 72 65 67 61 74 65 73 29 20 70 61 72 61 6d 65 74 regates) paramet
36540 65 72 73 0a 2a 2a 20 74 6f 20 5b 73 71 6c 69 74 ers.** to [sqlit
36550 65 33 5f 63 72 65 61 74 65 5f 66 75 6e 63 74 69 e3_create_functi
36560 6f 6e 28 29 5d 20 61 6e 64 20 5b 73 71 6c 69 74 on()] and [sqlit
36570 65 33 5f 63 72 65 61 74 65 5f 66 75 6e 63 74 69 e3_create_functi
36580 6f 6e 31 36 28 29 5d 0a 2a 2a 20 64 65 66 69 6e on16()].** defin
36590 65 20 63 61 6c 6c 62 61 63 6b 73 20 74 68 61 74 e callbacks that
365a0 20 69 6d 70 6c 65 6d 65 6e 74 20 74 68 65 20 53 implement the S
365b0 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 61 6e 64 QL functions and
365c0 20 61 67 67 72 65 67 61 74 65 73 2e 0a 2a 2a 20 aggregates..**
365d0 54 68 65 20 33 72 64 20 70 61 72 61 6d 65 74 65 The 3rd paramete
365e0 72 20 74 6f 20 74 68 65 73 65 20 63 61 6c 6c 62 r to these callb
365f0 61 63 6b 73 20 69 73 20 61 6e 20 61 72 72 61 79 acks is an array
36600 20 6f 66 20 70 6f 69 6e 74 65 72 73 20 74 6f 0a of pointers to.
36610 2a 2a 20 5b 70 72 6f 74 65 63 74 65 64 20 73 71 ** [protected sq
36620 6c 69 74 65 33 5f 76 61 6c 75 65 5d 20 6f 62 6a lite3_value] obj
36630 65 63 74 73 2e 20 20 54 68 65 72 65 20 69 73 20 ects. There is
36640 6f 6e 65 20 5b 73 71 6c 69 74 65 33 5f 76 61 6c one [sqlite3_val
36650 75 65 5d 20 6f 62 6a 65 63 74 20 66 6f 72 0a 2a ue] object for.*
36660 2a 20 65 61 63 68 20 70 61 72 61 6d 65 74 65 72 * each parameter
36670 20 74 6f 20 74 68 65 20 53 51 4c 20 66 75 6e 63 to the SQL func
36680 74 69 6f 6e 2e 20 20 54 68 65 73 65 20 72 6f 75 tion. These rou
36690 74 69 6e 65 73 20 61 72 65 20 75 73 65 64 20 74 tines are used t
366a0 6f 0a 2a 2a 20 65 78 74 72 61 63 74 20 76 61 6c o.** extract val
366b0 75 65 73 20 66 72 6f 6d 20 74 68 65 20 5b 73 71 ues from the [sq
366c0 6c 69 74 65 33 5f 76 61 6c 75 65 5d 20 6f 62 6a lite3_value] obj
366d0 65 63 74 73 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 73 ects..**.** Thes
366e0 65 20 72 6f 75 74 69 6e 65 73 20 77 6f 72 6b 20 e routines work
366f0 6f 6e 6c 79 20 77 69 74 68 20 5b 70 72 6f 74 65 only with [prote
36700 63 74 65 64 20 73 71 6c 69 74 65 33 5f 76 61 6c cted sqlite3_val
36710 75 65 5d 20 6f 62 6a 65 63 74 73 2e 0a 2a 2a 20 ue] objects..**
36720 41 6e 79 20 61 74 74 65 6d 70 74 20 74 6f 20 75 Any attempt to u
36730 73 65 20 74 68 65 73 65 20 72 6f 75 74 69 6e 65 se these routine
36740 73 20 6f 6e 20 61 6e 20 5b 75 6e 70 72 6f 74 65 s on an [unprote
36750 63 74 65 64 20 73 71 6c 69 74 65 33 5f 76 61 6c cted sqlite3_val
36760 75 65 5d 0a 2a 2a 20 6f 62 6a 65 63 74 20 72 65 ue].** object re
36770 73 75 6c 74 73 20 69 6e 20 75 6e 64 65 66 69 6e sults in undefin
36780 65 64 20 62 65 68 61 76 69 6f 72 2e 0a 2a 2a 0a ed behavior..**.
36790 2a 2a 20 5e 54 68 65 73 65 20 72 6f 75 74 69 6e ** ^These routin
367a0 65 73 20 77 6f 72 6b 20 6a 75 73 74 20 6c 69 6b es work just lik
367b0 65 20 74 68 65 20 63 6f 72 72 65 73 70 6f 6e 64 e the correspond
367c0 69 6e 67 20 5b 63 6f 6c 75 6d 6e 20 61 63 63 65 ing [column acce
367d0 73 73 20 66 75 6e 63 74 69 6f 6e 73 5d 0a 2a 2a ss functions].**
367e0 20 65 78 63 65 70 74 20 74 68 61 74 20 74 68 65 except that the
367f0 73 65 20 72 6f 75 74 69 6e 65 73 20 74 61 6b 65 se routines take
36800 20 61 20 73 69 6e 67 6c 65 20 5b 70 72 6f 74 65 a single [prote
36810 63 74 65 64 20 73 71 6c 69 74 65 33 5f 76 61 6c cted sqlite3_val
36820 75 65 5d 20 6f 62 6a 65 63 74 0a 2a 2a 20 70 6f ue] object.** po
36830 69 6e 74 65 72 20 69 6e 73 74 65 61 64 20 6f 66 inter instead of
36840 20 61 20 5b 73 71 6c 69 74 65 33 5f 73 74 6d 74 a [sqlite3_stmt
36850 2a 5d 20 70 6f 69 6e 74 65 72 20 61 6e 64 20 61 *] pointer and a
36860 6e 20 69 6e 74 65 67 65 72 20 63 6f 6c 75 6d 6e n integer column
36870 20 6e 75 6d 62 65 72 2e 0a 2a 2a 0a 2a 2a 20 5e number..**.** ^
36880 54 68 65 20 73 71 6c 69 74 65 33 5f 76 61 6c 75 The sqlite3_valu
36890 65 5f 74 65 78 74 31 36 28 29 20 69 6e 74 65 72 e_text16() inter
368a0 66 61 63 65 20 65 78 74 72 61 63 74 73 20 61 20 face extracts a
368b0 55 54 46 2d 31 36 20 73 74 72 69 6e 67 0a 2a 2a UTF-16 string.**
368c0 20 69 6e 20 74 68 65 20 6e 61 74 69 76 65 20 62 in the native b
368d0 79 74 65 2d 6f 72 64 65 72 20 6f 66 20 74 68 65 yte-order of the
368e0 20 68 6f 73 74 20 6d 61 63 68 69 6e 65 2e 20 20 host machine.
368f0 5e 54 68 65 0a 2a 2a 20 73 71 6c 69 74 65 33 5f ^The.** sqlite3_
36900 76 61 6c 75 65 5f 74 65 78 74 31 36 62 65 28 29 value_text16be()
36910 20 61 6e 64 20 73 71 6c 69 74 65 33 5f 76 61 6c and sqlite3_val
36920 75 65 5f 74 65 78 74 31 36 6c 65 28 29 20 69 6e ue_text16le() in
36930 74 65 72 66 61 63 65 73 0a 2a 2a 20 65 78 74 72 terfaces.** extr
36940 61 63 74 20 55 54 46 2d 31 36 20 73 74 72 69 6e act UTF-16 strin
36950 67 73 20 61 73 20 62 69 67 2d 65 6e 64 69 61 6e gs as big-endian
36960 20 61 6e 64 20 6c 69 74 74 6c 65 2d 65 6e 64 69 and little-endi
36970 61 6e 20 72 65 73 70 65 63 74 69 76 65 6c 79 2e an respectively.
36980 0a 2a 2a 0a 2a 2a 20 5e 28 54 68 65 20 73 71 6c .**.** ^(The sql
36990 69 74 65 33 5f 76 61 6c 75 65 5f 6e 75 6d 65 72 ite3_value_numer
369a0 69 63 5f 74 79 70 65 28 29 20 69 6e 74 65 72 66 ic_type() interf
369b0 61 63 65 20 61 74 74 65 6d 70 74 73 20 74 6f 20 ace attempts to
369c0 61 70 70 6c 79 0a 2a 2a 20 6e 75 6d 65 72 69 63 apply.** numeric
369d0 20 61 66 66 69 6e 69 74 79 20 74 6f 20 74 68 65 affinity to the
369e0 20 76 61 6c 75 65 2e 20 20 54 68 69 73 20 6d 65 value. This me
369f0 61 6e 73 20 74 68 61 74 20 61 6e 20 61 74 74 65 ans that an atte
36a00 6d 70 74 20 69 73 0a 2a 2a 20 6d 61 64 65 20 74 mpt is.** made t
36a10 6f 20 63 6f 6e 76 65 72 74 20 74 68 65 20 76 61 o convert the va
36a20 6c 75 65 20 74 6f 20 61 6e 20 69 6e 74 65 67 65 lue to an intege
36a30 72 20 6f 72 20 66 6c 6f 61 74 69 6e 67 20 70 6f r or floating po
36a40 69 6e 74 2e 20 20 49 66 0a 2a 2a 20 73 75 63 68 int. If.** such
36a50 20 61 20 63 6f 6e 76 65 72 73 69 6f 6e 20 69 73 a conversion is
36a60 20 70 6f 73 73 69 62 6c 65 20 77 69 74 68 6f 75 possible withou
36a70 74 20 6c 6f 73 73 20 6f 66 20 69 6e 66 6f 72 6d t loss of inform
36a80 61 74 69 6f 6e 20 28 69 6e 20 6f 74 68 65 72 0a ation (in other.
36a90 2a 2a 20 77 6f 72 64 73 2c 20 69 66 20 74 68 65 ** words, if the
36aa0 20 76 61 6c 75 65 20 69 73 20 61 20 73 74 72 69 value is a stri
36ab0 6e 67 20 74 68 61 74 20 6c 6f 6f 6b 73 20 6c 69 ng that looks li
36ac0 6b 65 20 61 20 6e 75 6d 62 65 72 29 0a 2a 2a 20 ke a number).**
36ad0 74 68 65 6e 20 74 68 65 20 63 6f 6e 76 65 72 73 then the convers
36ae0 69 6f 6e 20 69 73 20 70 65 72 66 6f 72 6d 65 64 ion is performed
36af0 2e 20 20 4f 74 68 65 72 77 69 73 65 20 6e 6f 20 . Otherwise no
36b00 63 6f 6e 76 65 72 73 69 6f 6e 20 6f 63 63 75 72 conversion occur
36b10 73 2e 0a 2a 2a 20 54 68 65 20 5b 53 51 4c 49 54 s..** The [SQLIT
36b20 45 5f 49 4e 54 45 47 45 52 20 7c 20 64 61 74 61 E_INTEGER | data
36b30 74 79 70 65 5d 20 61 66 74 65 72 20 63 6f 6e 76 type] after conv
36b40 65 72 73 69 6f 6e 20 69 73 20 72 65 74 75 72 6e ersion is return
36b50 65 64 2e 29 5e 0a 2a 2a 0a 2a 2a 20 50 6c 65 61 ed.)^.**.** Plea
36b60 73 65 20 70 61 79 20 70 61 72 74 69 63 75 6c 61 se pay particula
36b70 72 20 61 74 74 65 6e 74 69 6f 6e 20 74 6f 20 74 r attention to t
36b80 68 65 20 66 61 63 74 20 74 68 61 74 20 74 68 65 he fact that the
36b90 20 70 6f 69 6e 74 65 72 20 72 65 74 75 72 6e 65 pointer returne
36ba0 64 0a 2a 2a 20 66 72 6f 6d 20 5b 73 71 6c 69 74 d.** from [sqlit
36bb0 65 33 5f 76 61 6c 75 65 5f 62 6c 6f 62 28 29 5d e3_value_blob()]
36bc0 2c 20 5b 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 , [sqlite3_value
36bd0 5f 74 65 78 74 28 29 5d 2c 20 6f 72 0a 2a 2a 20 _text()], or.**
36be0 5b 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f 74 [sqlite3_value_t
36bf0 65 78 74 31 36 28 29 5d 20 63 61 6e 20 62 65 20 ext16()] can be
36c00 69 6e 76 61 6c 69 64 61 74 65 64 20 62 79 20 61 invalidated by a
36c10 20 73 75 62 73 65 71 75 65 6e 74 20 63 61 6c 6c subsequent call
36c20 20 74 6f 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 5f to.** [sqlite3_
36c30 76 61 6c 75 65 5f 62 79 74 65 73 28 29 5d 2c 20 value_bytes()],
36c40 5b 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f 62 [sqlite3_value_b
36c50 79 74 65 73 31 36 28 29 5d 2c 20 5b 73 71 6c 69 ytes16()], [sqli
36c60 74 65 33 5f 76 61 6c 75 65 5f 74 65 78 74 28 29 te3_value_text()
36c70 5d 2c 0a 2a 2a 20 6f 72 20 5b 73 71 6c 69 74 65 ],.** or [sqlite
36c80 33 5f 76 61 6c 75 65 5f 74 65 78 74 31 36 28 29 3_value_text16()
36c90 5d 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 73 65 20 72 ]..**.** These r
36ca0 6f 75 74 69 6e 65 73 20 6d 75 73 74 20 62 65 20 outines must be
36cb0 63 61 6c 6c 65 64 20 66 72 6f 6d 20 74 68 65 20 called from the
36cc0 73 61 6d 65 20 74 68 72 65 61 64 20 61 73 0a 2a same thread as.*
36cd0 2a 20 74 68 65 20 53 51 4c 20 66 75 6e 63 74 69 * the SQL functi
36ce0 6f 6e 20 74 68 61 74 20 73 75 70 70 6c 69 65 64 on that supplied
36cf0 20 74 68 65 20 5b 73 71 6c 69 74 65 33 5f 76 61 the [sqlite3_va
36d00 6c 75 65 2a 5d 20 70 61 72 61 6d 65 74 65 72 73 lue*] parameters
36d10 2e 0a 2a 2f 0a 63 6f 6e 73 74 20 76 6f 69 64 20 ..*/.const void
36d20 2a 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f 62 *sqlite3_value_b
36d30 6c 6f 62 28 73 71 6c 69 74 65 33 5f 76 61 6c 75 lob(sqlite3_valu
36d40 65 2a 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 e*);.int sqlite3
36d50 5f 76 61 6c 75 65 5f 62 79 74 65 73 28 73 71 6c _value_bytes(sql
36d60 69 74 65 33 5f 76 61 6c 75 65 2a 29 3b 0a 69 6e ite3_value*);.in
36d70 74 20 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f t sqlite3_value_
36d80 62 79 74 65 73 31 36 28 73 71 6c 69 74 65 33 5f bytes16(sqlite3_
36d90 76 61 6c 75 65 2a 29 3b 0a 64 6f 75 62 6c 65 20 value*);.double
36da0 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f 64 6f sqlite3_value_do
36db0 75 62 6c 65 28 73 71 6c 69 74 65 33 5f 76 61 6c uble(sqlite3_val
36dc0 75 65 2a 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 ue*);.int sqlite
36dd0 33 5f 76 61 6c 75 65 5f 69 6e 74 28 73 71 6c 69 3_value_int(sqli
36de0 74 65 33 5f 76 61 6c 75 65 2a 29 3b 0a 73 71 6c te3_value*);.sql
36df0 69 74 65 33 5f 69 6e 74 36 34 20 73 71 6c 69 74 ite3_int64 sqlit
36e00 65 33 5f 76 61 6c 75 65 5f 69 6e 74 36 34 28 73 e3_value_int64(s
36e10 71 6c 69 74 65 33 5f 76 61 6c 75 65 2a 29 3b 0a qlite3_value*);.
36e20 63 6f 6e 73 74 20 75 6e 73 69 67 6e 65 64 20 63 const unsigned c
36e30 68 61 72 20 2a 73 71 6c 69 74 65 33 5f 76 61 6c har *sqlite3_val
36e40 75 65 5f 74 65 78 74 28 73 71 6c 69 74 65 33 5f ue_text(sqlite3_
36e50 76 61 6c 75 65 2a 29 3b 0a 63 6f 6e 73 74 20 76 value*);.const v
36e60 6f 69 64 20 2a 73 71 6c 69 74 65 33 5f 76 61 6c oid *sqlite3_val
36e70 75 65 5f 74 65 78 74 31 36 28 73 71 6c 69 74 65 ue_text16(sqlite
36e80 33 5f 76 61 6c 75 65 2a 29 3b 0a 63 6f 6e 73 74 3_value*);.const
36e90 20 76 6f 69 64 20 2a 73 71 6c 69 74 65 33 5f 76 void *sqlite3_v
36ea0 61 6c 75 65 5f 74 65 78 74 31 36 6c 65 28 73 71 alue_text16le(sq
36eb0 6c 69 74 65 33 5f 76 61 6c 75 65 2a 29 3b 0a 63 lite3_value*);.c
36ec0 6f 6e 73 74 20 76 6f 69 64 20 2a 73 71 6c 69 74 onst void *sqlit
36ed0 65 33 5f 76 61 6c 75 65 5f 74 65 78 74 31 36 62 e3_value_text16b
36ee0 65 28 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 2a e(sqlite3_value*
36ef0 29 3b 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f 76 );.int sqlite3_v
36f00 61 6c 75 65 5f 74 79 70 65 28 73 71 6c 69 74 65 alue_type(sqlite
36f10 33 5f 76 61 6c 75 65 2a 29 3b 0a 69 6e 74 20 73 3_value*);.int s
36f20 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f 6e 75 6d qlite3_value_num
36f30 65 72 69 63 5f 74 79 70 65 28 73 71 6c 69 74 65 eric_type(sqlite
36f40 33 5f 76 61 6c 75 65 2a 29 3b 0a 0a 2f 2a 0a 2a 3_value*);../*.*
36f50 2a 20 43 41 50 49 33 52 45 46 3a 20 46 69 6e 64 * CAPI3REF: Find
36f60 69 6e 67 20 54 68 65 20 53 75 62 74 79 70 65 20 ing The Subtype
36f70 4f 66 20 53 51 4c 20 56 61 6c 75 65 73 0a 2a 2a Of SQL Values.**
36f80 20 4d 45 54 48 4f 44 3a 20 73 71 6c 69 74 65 33 METHOD: sqlite3
36f90 5f 76 61 6c 75 65 0a 2a 2a 0a 2a 2a 20 54 68 65 _value.**.** The
36fa0 20 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f 73 sqlite3_value_s
36fb0 75 62 74 79 70 65 28 56 29 20 66 75 6e 63 74 69 ubtype(V) functi
36fc0 6f 6e 20 72 65 74 75 72 6e 73 20 74 68 65 20 73 on returns the s
36fd0 75 62 74 79 70 65 20 66 6f 72 0a 2a 2a 20 61 6e ubtype for.** an
36fe0 20 5b 61 70 70 6c 69 63 61 74 69 6f 6e 2d 64 65 [application-de
36ff0 66 69 6e 65 64 20 53 51 4c 20 66 75 6e 63 74 69 fined SQL functi
37000 6f 6e 5d 20 61 72 67 75 6d 65 6e 74 20 56 2e 20 on] argument V.
37010 20 54 68 65 20 73 75 62 74 79 70 65 0a 2a 2a 20 The subtype.**
37020 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 63 61 6e 20 information can
37030 62 65 20 75 73 65 64 20 74 6f 20 70 61 73 73 20 be used to pass
37040 61 20 6c 69 6d 69 74 65 64 20 61 6d 6f 75 6e 74 a limited amount
37050 20 6f 66 20 63 6f 6e 74 65 78 74 20 66 72 6f 6d of context from
37060 0a 2a 2a 20 6f 6e 65 20 53 51 4c 20 66 75 6e 63 .** one SQL func
37070 74 69 6f 6e 20 74 6f 20 61 6e 6f 74 68 65 72 2e tion to another.
37080 20 20 55 73 65 20 74 68 65 20 5b 73 71 6c 69 74 Use the [sqlit
37090 65 33 5f 72 65 73 75 6c 74 5f 73 75 62 74 79 70 e3_result_subtyp
370a0 65 28 29 5d 0a 2a 2a 20 72 6f 75 74 69 6e 65 20 e()].** routine
370b0 74 6f 20 73 65 74 20 74 68 65 20 73 75 62 74 79 to set the subty
370c0 70 65 20 66 6f 72 20 74 68 65 20 72 65 74 75 72 pe for the retur
370d0 6e 20 76 61 6c 75 65 20 6f 66 20 61 6e 20 53 51 n value of an SQ
370e0 4c 20 66 75 6e 63 74 69 6f 6e 2e 0a 2a 2a 0a 2a L function..**.*
370f0 2a 20 53 51 4c 69 74 65 20 6d 61 6b 65 73 20 6e * SQLite makes n
37100 6f 20 75 73 65 20 6f 66 20 73 75 62 74 79 70 65 o use of subtype
37110 20 69 74 73 65 6c 66 2e 20 20 49 74 20 6d 65 72 itself. It mer
37120 65 6c 79 20 70 61 73 73 65 73 20 74 68 65 20 73 ely passes the s
37130 75 62 74 79 70 65 0a 2a 2a 20 66 72 6f 6d 20 74 ubtype.** from t
37140 68 65 20 72 65 73 75 6c 74 20 6f 66 20 6f 6e 65 he result of one
37150 20 5b 61 70 70 6c 69 63 61 74 69 6f 6e 2d 64 65 [application-de
37160 66 69 6e 65 64 20 53 51 4c 20 66 75 6e 63 74 69 fined SQL functi
37170 6f 6e 5d 20 69 6e 74 6f 20 74 68 65 0a 2a 2a 20 on] into the.**
37180 69 6e 70 75 74 20 6f 66 20 61 6e 6f 74 68 65 72 input of another
37190 2e 0a 2a 2f 0a 75 6e 73 69 67 6e 65 64 20 69 6e ..*/.unsigned in
371a0 74 20 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f t sqlite3_value_
371b0 73 75 62 74 79 70 65 28 73 71 6c 69 74 65 33 5f subtype(sqlite3_
371c0 76 61 6c 75 65 2a 29 3b 0a 0a 2f 2a 0a 2a 2a 20 value*);../*.**
371d0 43 41 50 49 33 52 45 46 3a 20 43 6f 70 79 20 41 CAPI3REF: Copy A
371e0 6e 64 20 46 72 65 65 20 53 51 4c 20 56 61 6c 75 nd Free SQL Valu
371f0 65 73 0a 2a 2a 20 4d 45 54 48 4f 44 3a 20 73 71 es.** METHOD: sq
37200 6c 69 74 65 33 5f 76 61 6c 75 65 0a 2a 2a 0a 2a lite3_value.**.*
37210 2a 20 5e 54 68 65 20 73 71 6c 69 74 65 33 5f 76 * ^The sqlite3_v
37220 61 6c 75 65 5f 64 75 70 28 56 29 20 69 6e 74 65 alue_dup(V) inte
37230 72 66 61 63 65 20 6d 61 6b 65 73 20 61 20 63 6f rface makes a co
37240 70 79 20 6f 66 20 74 68 65 20 5b 73 71 6c 69 74 py of the [sqlit
37250 65 33 5f 76 61 6c 75 65 5d 0a 2a 2a 20 6f 62 6a e3_value].** obj
37260 65 63 74 20 44 20 61 6e 64 20 72 65 74 75 72 6e ect D and return
37270 73 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 s a pointer to t
37280 68 61 74 20 63 6f 70 79 2e 20 20 5e 54 68 65 20 hat copy. ^The
37290 5b 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5d 20 [sqlite3_value]
372a0 72 65 74 75 72 6e 65 64 0a 2a 2a 20 69 73 20 61 returned.** is a
372b0 20 5b 70 72 6f 74 65 63 74 65 64 20 73 71 6c 69 [protected sqli
372c0 74 65 33 5f 76 61 6c 75 65 5d 20 6f 62 6a 65 63 te3_value] objec
372d0 74 20 65 76 65 6e 20 69 66 20 74 68 65 20 69 6e t even if the in
372e0 70 75 74 20 69 73 20 6e 6f 74 2e 0a 2a 2a 20 5e put is not..** ^
372f0 54 68 65 20 73 71 6c 69 74 65 33 5f 76 61 6c 75 The sqlite3_valu
37300 65 5f 64 75 70 28 56 29 20 69 6e 74 65 72 66 61 e_dup(V) interfa
37310 63 65 20 72 65 74 75 72 6e 73 20 4e 55 4c 4c 20 ce returns NULL
37320 69 66 20 56 20 69 73 20 4e 55 4c 4c 20 6f 72 20 if V is NULL or
37330 69 66 20 61 0a 2a 2a 20 6d 65 6d 6f 72 79 20 61 if a.** memory a
37340 6c 6c 6f 63 61 74 69 6f 6e 20 66 61 69 6c 73 2e llocation fails.
37350 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 6c 69 .**.** ^The sqli
37360 74 65 33 5f 76 61 6c 75 65 5f 66 72 65 65 28 56 te3_value_free(V
37370 29 20 69 6e 74 65 72 66 61 63 65 20 66 72 65 65 ) interface free
37380 73 20 61 6e 20 5b 73 71 6c 69 74 65 33 5f 76 61 s an [sqlite3_va
37390 6c 75 65 5d 20 6f 62 6a 65 63 74 0a 2a 2a 20 70 lue] object.** p
373a0 72 65 76 69 6f 75 73 6c 79 20 6f 62 74 61 69 6e reviously obtain
373b0 65 64 20 66 72 6f 6d 20 5b 73 71 6c 69 74 65 33 ed from [sqlite3
373c0 5f 76 61 6c 75 65 5f 64 75 70 28 29 5d 2e 20 20 _value_dup()].
373d0 5e 49 66 20 56 20 69 73 20 61 20 4e 55 4c 4c 20 ^If V is a NULL
373e0 70 6f 69 6e 74 65 72 0a 2a 2a 20 74 68 65 6e 20 pointer.** then
373f0 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f 66 72 sqlite3_value_fr
37400 65 65 28 56 29 20 69 73 20 61 20 68 61 72 6d 6c ee(V) is a harml
37410 65 73 73 20 6e 6f 2d 6f 70 2e 0a 2a 2f 0a 73 71 ess no-op..*/.sq
37420 6c 69 74 65 33 5f 76 61 6c 75 65 20 2a 73 71 6c lite3_value *sql
37430 69 74 65 33 5f 76 61 6c 75 65 5f 64 75 70 28 63 ite3_value_dup(c
37440 6f 6e 73 74 20 73 71 6c 69 74 65 33 5f 76 61 6c onst sqlite3_val
37450 75 65 2a 29 3b 0a 76 6f 69 64 20 73 71 6c 69 74 ue*);.void sqlit
37460 65 33 5f 76 61 6c 75 65 5f 66 72 65 65 28 73 71 e3_value_free(sq
37470 6c 69 74 65 33 5f 76 61 6c 75 65 2a 29 3b 0a 0a lite3_value*);..
37480 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 /*.** CAPI3REF:
37490 4f 62 74 61 69 6e 20 41 67 67 72 65 67 61 74 65 Obtain Aggregate
374a0 20 46 75 6e 63 74 69 6f 6e 20 43 6f 6e 74 65 78 Function Contex
374b0 74 0a 2a 2a 20 4d 45 54 48 4f 44 3a 20 73 71 6c t.** METHOD: sql
374c0 69 74 65 33 5f 63 6f 6e 74 65 78 74 0a 2a 2a 0a ite3_context.**.
374d0 2a 2a 20 49 6d 70 6c 65 6d 65 6e 74 61 74 69 6f ** Implementatio
374e0 6e 73 20 6f 66 20 61 67 67 72 65 67 61 74 65 20 ns of aggregate
374f0 53 51 4c 20 66 75 6e 63 74 69 6f 6e 73 20 75 73 SQL functions us
37500 65 20 74 68 69 73 0a 2a 2a 20 72 6f 75 74 69 6e e this.** routin
37510 65 20 74 6f 20 61 6c 6c 6f 63 61 74 65 20 6d 65 e to allocate me
37520 6d 6f 72 79 20 66 6f 72 20 73 74 6f 72 69 6e 67 mory for storing
37530 20 74 68 65 69 72 20 73 74 61 74 65 2e 0a 2a 2a their state..**
37540 0a 2a 2a 20 5e 54 68 65 20 66 69 72 73 74 20 74 .** ^The first t
37550 69 6d 65 20 74 68 65 20 73 71 6c 69 74 65 33 5f ime the sqlite3_
37560 61 67 67 72 65 67 61 74 65 5f 63 6f 6e 74 65 78 aggregate_contex
37570 74 28 43 2c 4e 29 20 72 6f 75 74 69 6e 65 20 69 t(C,N) routine i
37580 73 20 63 61 6c 6c 65 64 20 0a 2a 2a 20 66 6f 72 s called .** for
37590 20 61 20 70 61 72 74 69 63 75 6c 61 72 20 61 67 a particular ag
375a0 67 72 65 67 61 74 65 20 66 75 6e 63 74 69 6f 6e gregate function
375b0 2c 20 53 51 4c 69 74 65 0a 2a 2a 20 61 6c 6c 6f , SQLite.** allo
375c0 63 61 74 65 73 20 4e 20 6f 66 20 6d 65 6d 6f 72 cates N of memor
375d0 79 2c 20 7a 65 72 6f 65 73 20 6f 75 74 20 74 68 y, zeroes out th
375e0 61 74 20 6d 65 6d 6f 72 79 2c 20 61 6e 64 20 72 at memory, and r
375f0 65 74 75 72 6e 73 20 61 20 70 6f 69 6e 74 65 72 eturns a pointer
37600 0a 2a 2a 20 74 6f 20 74 68 65 20 6e 65 77 20 6d .** to the new m
37610 65 6d 6f 72 79 2e 20 5e 4f 6e 20 73 65 63 6f 6e emory. ^On secon
37620 64 20 61 6e 64 20 73 75 62 73 65 71 75 65 6e 74 d and subsequent
37630 20 63 61 6c 6c 73 20 74 6f 0a 2a 2a 20 73 71 6c calls to.** sql
37640 69 74 65 33 5f 61 67 67 72 65 67 61 74 65 5f 63 ite3_aggregate_c
37650 6f 6e 74 65 78 74 28 29 20 66 6f 72 20 74 68 65 ontext() for the
37660 20 73 61 6d 65 20 61 67 67 72 65 67 61 74 65 20 same aggregate
37670 66 75 6e 63 74 69 6f 6e 20 69 6e 73 74 61 6e 63 function instanc
37680 65 2c 0a 2a 2a 20 74 68 65 20 73 61 6d 65 20 62 e,.** the same b
37690 75 66 66 65 72 20 69 73 20 72 65 74 75 72 6e 65 uffer is returne
376a0 64 2e 20 20 53 71 6c 69 74 65 33 5f 61 67 67 72 d. Sqlite3_aggr
376b0 65 67 61 74 65 5f 63 6f 6e 74 65 78 74 28 29 20 egate_context()
376c0 69 73 20 6e 6f 72 6d 61 6c 6c 79 0a 2a 2a 20 63 is normally.** c
376d0 61 6c 6c 65 64 20 6f 6e 63 65 20 66 6f 72 20 65 alled once for e
376e0 61 63 68 20 69 6e 76 6f 63 61 74 69 6f 6e 20 6f ach invocation o
376f0 66 20 74 68 65 20 78 53 74 65 70 20 63 61 6c 6c f the xStep call
37700 62 61 63 6b 20 61 6e 64 20 74 68 65 6e 20 6f 6e back and then on
37710 65 0a 2a 2a 20 6c 61 73 74 20 74 69 6d 65 20 77 e.** last time w
37720 68 65 6e 20 74 68 65 20 78 46 69 6e 61 6c 20 63 hen the xFinal c
37730 61 6c 6c 62 61 63 6b 20 69 73 20 69 6e 76 6f 6b allback is invok
37740 65 64 2e 20 20 5e 28 57 68 65 6e 20 6e 6f 20 72 ed. ^(When no r
37750 6f 77 73 20 6d 61 74 63 68 0a 2a 2a 20 61 6e 20 ows match.** an
37760 61 67 67 72 65 67 61 74 65 20 71 75 65 72 79 2c aggregate query,
37770 20 74 68 65 20 78 53 74 65 70 28 29 20 63 61 6c the xStep() cal
37780 6c 62 61 63 6b 20 6f 66 20 74 68 65 20 61 67 67 lback of the agg
37790 72 65 67 61 74 65 20 66 75 6e 63 74 69 6f 6e 0a regate function.
377a0 2a 2a 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f ** implementatio
377b0 6e 20 69 73 20 6e 65 76 65 72 20 63 61 6c 6c 65 n is never calle
377c0 64 20 61 6e 64 20 78 46 69 6e 61 6c 28 29 20 69 d and xFinal() i
377d0 73 20 63 61 6c 6c 65 64 20 65 78 61 63 74 6c 79 s called exactly
377e0 20 6f 6e 63 65 2e 0a 2a 2a 20 49 6e 20 74 68 6f once..** In tho
377f0 73 65 20 63 61 73 65 73 2c 20 73 71 6c 69 74 65 se cases, sqlite
37800 33 5f 61 67 67 72 65 67 61 74 65 5f 63 6f 6e 74 3_aggregate_cont
37810 65 78 74 28 29 20 6d 69 67 68 74 20 62 65 20 63 ext() might be c
37820 61 6c 6c 65 64 20 66 6f 72 20 74 68 65 0a 2a 2a alled for the.**
37830 20 66 69 72 73 74 20 74 69 6d 65 20 66 72 6f 6d first time from
37840 20 77 69 74 68 69 6e 20 78 46 69 6e 61 6c 28 29 within xFinal()
37850 2e 29 5e 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 .)^.**.** ^The s
37860 71 6c 69 74 65 33 5f 61 67 67 72 65 67 61 74 65 qlite3_aggregate
37870 5f 63 6f 6e 74 65 78 74 28 43 2c 4e 29 20 72 6f _context(C,N) ro
37880 75 74 69 6e 65 20 72 65 74 75 72 6e 73 20 61 20 utine returns a
37890 4e 55 4c 4c 20 70 6f 69 6e 74 65 72 20 0a 2a 2a NULL pointer .**
378a0 20 77 68 65 6e 20 66 69 72 73 74 20 63 61 6c 6c when first call
378b0 65 64 20 69 66 20 4e 20 69 73 20 6c 65 73 73 20 ed if N is less
378c0 74 68 61 6e 20 6f 72 20 65 71 75 61 6c 20 74 6f than or equal to
378d0 20 7a 65 72 6f 20 6f 72 20 69 66 20 61 20 6d 65 zero or if a me
378e0 6d 6f 72 79 0a 2a 2a 20 61 6c 6c 6f 63 61 74 65 mory.** allocate
378f0 20 65 72 72 6f 72 20 6f 63 63 75 72 73 2e 0a 2a error occurs..*
37900 2a 0a 2a 2a 20 5e 28 54 68 65 20 61 6d 6f 75 6e *.** ^(The amoun
37910 74 20 6f 66 20 73 70 61 63 65 20 61 6c 6c 6f 63 t of space alloc
37920 61 74 65 64 20 62 79 20 73 71 6c 69 74 65 33 5f ated by sqlite3_
37930 61 67 67 72 65 67 61 74 65 5f 63 6f 6e 74 65 78 aggregate_contex
37940 74 28 43 2c 4e 29 20 69 73 0a 2a 2a 20 64 65 74 t(C,N) is.** det
37950 65 72 6d 69 6e 65 64 20 62 79 20 74 68 65 20 4e ermined by the N
37960 20 70 61 72 61 6d 65 74 65 72 20 6f 6e 20 66 69 parameter on fi
37970 72 73 74 20 73 75 63 63 65 73 73 66 75 6c 20 63 rst successful c
37980 61 6c 6c 2e 20 20 43 68 61 6e 67 69 6e 67 20 74 all. Changing t
37990 68 65 0a 2a 2a 20 76 61 6c 75 65 20 6f 66 20 4e he.** value of N
379a0 20 69 6e 20 73 75 62 73 65 71 75 65 6e 74 20 63 in subsequent c
379b0 61 6c 6c 20 74 6f 20 73 71 6c 69 74 65 33 5f 61 all to sqlite3_a
379c0 67 67 72 65 67 61 74 65 5f 63 6f 6e 74 65 78 74 ggregate_context
379d0 28 29 20 77 69 74 68 69 6e 0a 2a 2a 20 74 68 65 () within.** the
379e0 20 73 61 6d 65 20 61 67 67 72 65 67 61 74 65 20 same aggregate
379f0 66 75 6e 63 74 69 6f 6e 20 69 6e 73 74 61 6e 63 function instanc
37a00 65 20 77 69 6c 6c 20 6e 6f 74 20 72 65 73 69 7a e will not resiz
37a10 65 20 74 68 65 20 6d 65 6d 6f 72 79 0a 2a 2a 20 e the memory.**
37a20 61 6c 6c 6f 63 61 74 69 6f 6e 2e 29 5e 20 20 57 allocation.)^ W
37a30 69 74 68 69 6e 20 74 68 65 20 78 46 69 6e 61 6c ithin the xFinal
37a40 20 63 61 6c 6c 62 61 63 6b 2c 20 69 74 20 69 73 callback, it is
37a50 20 63 75 73 74 6f 6d 61 72 79 20 74 6f 20 73 65 customary to se
37a60 74 0a 2a 2a 20 4e 3d 30 20 69 6e 20 63 61 6c 6c t.** N=0 in call
37a70 73 20 74 6f 20 73 71 6c 69 74 65 33 5f 61 67 67 s to sqlite3_agg
37a80 72 65 67 61 74 65 5f 63 6f 6e 74 65 78 74 28 43 regate_context(C
37a90 2c 4e 29 20 73 6f 20 74 68 61 74 20 6e 6f 20 0a ,N) so that no .
37aa0 2a 2a 20 70 6f 69 6e 74 6c 65 73 73 20 6d 65 6d ** pointless mem
37ab0 6f 72 79 20 61 6c 6c 6f 63 61 74 69 6f 6e 73 20 ory allocations
37ac0 6f 63 63 75 72 2e 0a 2a 2a 0a 2a 2a 20 5e 53 51 occur..**.** ^SQ
37ad0 4c 69 74 65 20 61 75 74 6f 6d 61 74 69 63 61 6c Lite automatical
37ae0 6c 79 20 66 72 65 65 73 20 74 68 65 20 6d 65 6d ly frees the mem
37af0 6f 72 79 20 61 6c 6c 6f 63 61 74 65 64 20 62 79 ory allocated by
37b00 20 0a 2a 2a 20 73 71 6c 69 74 65 33 5f 61 67 67 .** sqlite3_agg
37b10 72 65 67 61 74 65 5f 63 6f 6e 74 65 78 74 28 29 regate_context()
37b20 20 77 68 65 6e 20 74 68 65 20 61 67 67 72 65 67 when the aggreg
37b30 61 74 65 20 71 75 65 72 79 20 63 6f 6e 63 6c 75 ate query conclu
37b40 64 65 73 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 66 des..**.** The f
37b50 69 72 73 74 20 70 61 72 61 6d 65 74 65 72 20 6d irst parameter m
37b60 75 73 74 20 62 65 20 61 20 63 6f 70 79 20 6f 66 ust be a copy of
37b70 20 74 68 65 0a 2a 2a 20 5b 73 71 6c 69 74 65 33 the.** [sqlite3
37b80 5f 63 6f 6e 74 65 78 74 20 7c 20 53 51 4c 20 66 _context | SQL f
37b90 75 6e 63 74 69 6f 6e 20 63 6f 6e 74 65 78 74 5d unction context]
37ba0 20 74 68 61 74 20 69 73 20 74 68 65 20 66 69 72 that is the fir
37bb0 73 74 20 70 61 72 61 6d 65 74 65 72 0a 2a 2a 20 st parameter.**
37bc0 74 6f 20 74 68 65 20 78 53 74 65 70 20 6f 72 20 to the xStep or
37bd0 78 46 69 6e 61 6c 20 63 61 6c 6c 62 61 63 6b 20 xFinal callback
37be0 72 6f 75 74 69 6e 65 20 74 68 61 74 20 69 6d 70 routine that imp
37bf0 6c 65 6d 65 6e 74 73 20 74 68 65 20 61 67 67 72 lements the aggr
37c00 65 67 61 74 65 0a 2a 2a 20 66 75 6e 63 74 69 6f egate.** functio
37c10 6e 2e 0a 2a 2a 0a 2a 2a 20 54 68 69 73 20 72 6f n..**.** This ro
37c20 75 74 69 6e 65 20 6d 75 73 74 20 62 65 20 63 61 utine must be ca
37c30 6c 6c 65 64 20 66 72 6f 6d 20 74 68 65 20 73 61 lled from the sa
37c40 6d 65 20 74 68 72 65 61 64 20 69 6e 20 77 68 69 me thread in whi
37c50 63 68 0a 2a 2a 20 74 68 65 20 61 67 67 72 65 67 ch.** the aggreg
37c60 61 74 65 20 53 51 4c 20 66 75 6e 63 74 69 6f 6e ate SQL function
37c70 20 69 73 20 72 75 6e 6e 69 6e 67 2e 0a 2a 2f 0a is running..*/.
37c80 76 6f 69 64 20 2a 73 71 6c 69 74 65 33 5f 61 67 void *sqlite3_ag
37c90 67 72 65 67 61 74 65 5f 63 6f 6e 74 65 78 74 28 gregate_context(
37ca0 73 71 6c 69 74 65 33 5f 63 6f 6e 74 65 78 74 2a sqlite3_context*
37cb0 2c 20 69 6e 74 20 6e 42 79 74 65 73 29 3b 0a 0a , int nBytes);..
37cc0 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 46 3a 20 /*.** CAPI3REF:
37cd0 55 73 65 72 20 44 61 74 61 20 46 6f 72 20 46 75 User Data For Fu
37ce0 6e 63 74 69 6f 6e 73 0a 2a 2a 20 4d 45 54 48 4f nctions.** METHO
37cf0 44 3a 20 73 71 6c 69 74 65 33 5f 63 6f 6e 74 65 D: sqlite3_conte
37d00 78 74 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 xt.**.** ^The sq
37d10 6c 69 74 65 33 5f 75 73 65 72 5f 64 61 74 61 28 lite3_user_data(
37d20 29 20 69 6e 74 65 72 66 61 63 65 20 72 65 74 75 ) interface retu
37d30 72 6e 73 20 61 20 63 6f 70 79 20 6f 66 0a 2a 2a rns a copy of.**
37d40 20 74 68 65 20 70 6f 69 6e 74 65 72 20 74 68 61 the pointer tha
37d50 74 20 77 61 73 20 74 68 65 20 70 55 73 65 72 44 t was the pUserD
37d60 61 74 61 20 70 61 72 61 6d 65 74 65 72 20 28 74 ata parameter (t
37d70 68 65 20 35 74 68 20 70 61 72 61 6d 65 74 65 72 he 5th parameter
37d80 29 0a 2a 2a 20 6f 66 20 74 68 65 20 5b 73 71 6c ).** of the [sql
37d90 69 74 65 33 5f 63 72 65 61 74 65 5f 66 75 6e 63 ite3_create_func
37da0 74 69 6f 6e 28 29 5d 0a 2a 2a 20 61 6e 64 20 5b tion()].** and [
37db0 73 71 6c 69 74 65 33 5f 63 72 65 61 74 65 5f 66 sqlite3_create_f
37dc0 75 6e 63 74 69 6f 6e 31 36 28 29 5d 20 72 6f 75 unction16()] rou
37dd0 74 69 6e 65 73 20 74 68 61 74 20 6f 72 69 67 69 tines that origi
37de0 6e 61 6c 6c 79 0a 2a 2a 20 72 65 67 69 73 74 65 nally.** registe
37df0 72 65 64 20 74 68 65 20 61 70 70 6c 69 63 61 74 red the applicat
37e00 69 6f 6e 20 64 65 66 69 6e 65 64 20 66 75 6e 63 ion defined func
37e10 74 69 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 54 68 69 73 tion..**.** This
37e20 20 72 6f 75 74 69 6e 65 20 6d 75 73 74 20 62 65 routine must be
37e30 20 63 61 6c 6c 65 64 20 66 72 6f 6d 20 74 68 65 called from the
37e40 20 73 61 6d 65 20 74 68 72 65 61 64 20 69 6e 20 same thread in
37e50 77 68 69 63 68 0a 2a 2a 20 74 68 65 20 61 70 70 which.** the app
37e60 6c 69 63 61 74 69 6f 6e 2d 64 65 66 69 6e 65 64 lication-defined
37e70 20 66 75 6e 63 74 69 6f 6e 20 69 73 20 72 75 6e function is run
37e80 6e 69 6e 67 2e 0a 2a 2f 0a 76 6f 69 64 20 2a 73 ning..*/.void *s
37e90 71 6c 69 74 65 33 5f 75 73 65 72 5f 64 61 74 61 qlite3_user_data
37ea0 28 73 71 6c 69 74 65 33 5f 63 6f 6e 74 65 78 74 (sqlite3_context
37eb0 2a 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 *);../*.** CAPI3
37ec0 52 45 46 3a 20 44 61 74 61 62 61 73 65 20 43 6f REF: Database Co
37ed0 6e 6e 65 63 74 69 6f 6e 20 46 6f 72 20 46 75 6e nnection For Fun
37ee0 63 74 69 6f 6e 73 0a 2a 2a 20 4d 45 54 48 4f 44 ctions.** METHOD
37ef0 3a 20 73 71 6c 69 74 65 33 5f 63 6f 6e 74 65 78 : sqlite3_contex
37f00 74 0a 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 6c t.**.** ^The sql
37f10 69 74 65 33 5f 63 6f 6e 74 65 78 74 5f 64 62 5f ite3_context_db_
37f20 68 61 6e 64 6c 65 28 29 20 69 6e 74 65 72 66 61 handle() interfa
37f30 63 65 20 72 65 74 75 72 6e 73 20 61 20 63 6f 70 ce returns a cop
37f40 79 20 6f 66 0a 2a 2a 20 74 68 65 20 70 6f 69 6e y of.** the poin
37f50 74 65 72 20 74 6f 20 74 68 65 20 5b 64 61 74 61 ter to the [data
37f60 62 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 5d base connection]
37f70 20 28 74 68 65 20 31 73 74 20 70 61 72 61 6d 65 (the 1st parame
37f80 74 65 72 29 0a 2a 2a 20 6f 66 20 74 68 65 20 5b ter).** of the [
37f90 73 71 6c 69 74 65 33 5f 63 72 65 61 74 65 5f 66 sqlite3_create_f
37fa0 75 6e 63 74 69 6f 6e 28 29 5d 0a 2a 2a 20 61 6e unction()].** an
37fb0 64 20 5b 73 71 6c 69 74 65 33 5f 63 72 65 61 74 d [sqlite3_creat
37fc0 65 5f 66 75 6e 63 74 69 6f 6e 31 36 28 29 5d 20 e_function16()]
37fd0 72 6f 75 74 69 6e 65 73 20 74 68 61 74 20 6f 72 routines that or
37fe0 69 67 69 6e 61 6c 6c 79 0a 2a 2a 20 72 65 67 69 iginally.** regi
37ff0 73 74 65 72 65 64 20 74 68 65 20 61 70 70 6c 69 stered the appli
38000 63 61 74 69 6f 6e 20 64 65 66 69 6e 65 64 20 66 cation defined f
38010 75 6e 63 74 69 6f 6e 2e 0a 2a 2f 0a 73 71 6c 69 unction..*/.sqli
38020 74 65 33 20 2a 73 71 6c 69 74 65 33 5f 63 6f 6e te3 *sqlite3_con
38030 74 65 78 74 5f 64 62 5f 68 61 6e 64 6c 65 28 73 text_db_handle(s
38040 71 6c 69 74 65 33 5f 63 6f 6e 74 65 78 74 2a 29 qlite3_context*)
38050 3b 0a 0a 2f 2a 0a 2a 2a 20 43 41 50 49 33 52 45 ;../*.** CAPI3RE
38060 46 3a 20 46 75 6e 63 74 69 6f 6e 20 41 75 78 69 F: Function Auxi
38070 6c 69 61 72 79 20 44 61 74 61 0a 2a 2a 20 4d 45 liary Data.** ME
38080 54 48 4f 44 3a 20 73 71 6c 69 74 65 33 5f 63 6f THOD: sqlite3_co
38090 6e 74 65 78 74 0a 2a 2a 0a 2a 2a 20 54 68 65 73 ntext.**.** Thes
380a0 65 20 66 75 6e 63 74 69 6f 6e 73 20 6d 61 79 20 e functions may
380b0 62 65 20 75 73 65 64 20 62 79 20 28 6e 6f 6e 2d be used by (non-
380c0 61 67 67 72 65 67 61 74 65 29 20 53 51 4c 20 66 aggregate) SQL f
380d0 75 6e 63 74 69 6f 6e 73 20 74 6f 0a 2a 2a 20 61 unctions to.** a
380e0 73 73 6f 63 69 61 74 65 20 6d 65 74 61 64 61 74 ssociate metadat
380f0 61 20 77 69 74 68 20 61 72 67 75 6d 65 6e 74 20 a with argument
38100 76 61 6c 75 65 73 2e 20 49 66 20 74 68 65 20 73 values. If the s
38110 61 6d 65 20 76 61 6c 75 65 20 69 73 20 70 61 73 ame value is pas
38120 73 65 64 20 74 6f 0a 2a 2a 20 6d 75 6c 74 69 70 sed to.** multip
38130 6c 65 20 69 6e 76 6f 63 61 74 69 6f 6e 73 20 6f le invocations o
38140 66 20 74 68 65 20 73 61 6d 65 20 53 51 4c 20 66 f the same SQL f
38150 75 6e 63 74 69 6f 6e 20 64 75 72 69 6e 67 20 71 unction during q
38160 75 65 72 79 20 65 78 65 63 75 74 69 6f 6e 2c 20 uery execution,
38170 75 6e 64 65 72 0a 2a 2a 20 73 6f 6d 65 20 63 69 under.** some ci
38180 72 63 75 6d 73 74 61 6e 63 65 73 20 74 68 65 20 rcumstances the
38190 61 73 73 6f 63 69 61 74 65 64 20 6d 65 74 61 64 associated metad
381a0 61 74 61 20 6d 61 79 20 62 65 20 70 72 65 73 65 ata may be prese
381b0 72 76 65 64 2e 20 20 41 6e 20 65 78 61 6d 70 6c rved. An exampl
381c0 65 0a 2a 2a 20 6f 66 20 77 68 65 72 65 20 74 68 e.** of where th
381d0 69 73 20 6d 69 67 68 74 20 62 65 20 75 73 65 66 is might be usef
381e0 75 6c 20 69 73 20 69 6e 20 61 20 72 65 67 75 6c ul is in a regul
381f0 61 72 2d 65 78 70 72 65 73 73 69 6f 6e 20 6d 61 ar-expression ma
38200 74 63 68 69 6e 67 0a 2a 2a 20 66 75 6e 63 74 69 tching.** functi
38210 6f 6e 2e 20 54 68 65 20 63 6f 6d 70 69 6c 65 64 on. The compiled
38220 20 76 65 72 73 69 6f 6e 20 6f 66 20 74 68 65 20 version of the
38230 72 65 67 75 6c 61 72 20 65 78 70 72 65 73 73 69 regular expressi
38240 6f 6e 20 63 61 6e 20 62 65 20 73 74 6f 72 65 64 on can be stored
38250 20 61 73 0a 2a 2a 20 6d 65 74 61 64 61 74 61 20 as.** metadata
38260 61 73 73 6f 63 69 61 74 65 64 20 77 69 74 68 20 associated with
38270 74 68 65 20 70 61 74 74 65 72 6e 20 73 74 72 69 the pattern stri
38280 6e 67 2e 20 20 0a 2a 2a 20 54 68 65 6e 20 61 73 ng. .** Then as
38290 20 6c 6f 6e 67 20 61 73 20 74 68 65 20 70 61 74 long as the pat
382a0 74 65 72 6e 20 73 74 72 69 6e 67 20 72 65 6d 61 tern string rema
382b0 69 6e 73 20 74 68 65 20 73 61 6d 65 2c 0a 2a 2a ins the same,.**
382c0 20 74 68 65 20 63 6f 6d 70 69 6c 65 64 20 72 65 the compiled re
382d0 67 75 6c 61 72 20 65 78 70 72 65 73 73 69 6f 6e gular expression
382e0 20 63 61 6e 20 62 65 20 72 65 75 73 65 64 20 6f can be reused o
382f0 6e 20 6d 75 6c 74 69 70 6c 65 0a 2a 2a 20 69 6e n multiple.** in
38300 76 6f 63 61 74 69 6f 6e 73 20 6f 66 20 74 68 65 vocations of the
38310 20 73 61 6d 65 20 66 75 6e 63 74 69 6f 6e 2e 0a same function..
38320 2a 2a 0a 2a 2a 20 5e 54 68 65 20 73 71 6c 69 74 **.** ^The sqlit
38330 65 33 5f 67 65 74 5f 61 75 78 64 61 74 61 28 29 e3_get_auxdata()
38340 20 69 6e 74 65 72 66 61 63 65 20 72 65 74 75 72 interface retur
38350 6e 73 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 ns a pointer to
38360 74 68 65 20 6d 65 74 61 64 61 74 61 0a 2a 2a 20 the metadata.**
38370 61 73 73 6f 63 69 61 74 65 64 20 62 79 20 74 68 associated by th
38380 65 20 73 71 6c 69 74 65 33 5f 73 65 74 5f 61 75 e sqlite3_set_au
38390 78 64 61 74 61 28 29 20 66 75 6e 63 74 69 6f 6e xdata() function
383a0 20 77 69 74 68 20 74 68 65 20 4e 74 68 20 61 72 with the Nth ar
383b0 67 75 6d 65 6e 74 0a 2a 2a 20 76 61 6c 75 65 20 gument.** value
383c0 74 6f 20 74 68 65 20 61 70 70 6c 69 63 61 74 69 to the applicati
383d0 6f 6e 2d 64 65 66 69 6e 65 64 20 66 75 6e 63 74 on-defined funct
383e0 69 6f 6e 2e 20 5e 49 66 20 74 68 65 72 65 20 69 ion. ^If there i
383f0 73 20 6e 6f 20 6d 65 74 61 64 61 74 61 0a 2a 2a s no metadata.**
38400 20 61 73 73 6f 63 69 61 74 65 64 20 77 69 74 68 associated with
38410 20 74 68 65 20 66 75 6e 63 74 69 6f 6e 20 61 72 the function ar
38420 67 75 6d 65 6e 74 2c 20 74 68 69 73 20 73 71 6c gument, this sql
38430 69 74 65 33 5f 67 65 74 5f 61 75 78 64 61 74 61 ite3_get_auxdata
38440 28 29 20 69 6e 74 65 72 66 61 63 65 0a 2a 2a 20 () interface.**
38450 72 65 74 75 72 6e 73 20 61 20 4e 55 4c 4c 20 70 returns a NULL p
38460 6f 69 6e 74 65 72 2e 0a 2a 2a 0a 2a 2a 20 5e 54 ointer..**.** ^T
38470 68 65 20 73 71 6c 69 74 65 33 5f 73 65 74 5f 61 he sqlite3_set_a
38480 75 78 64 61 74 61 28 43 2c 4e 2c 50 2c 58 29 20 uxdata(C,N,P,X)
38490 69 6e 74 65 72 66 61 63 65 20 73 61 76 65 73 20 interface saves
384a0 50 20 61 73 20 6d 65 74 61 64 61 74 61 20 66 6f P as metadata fo
384b0 72 20 74 68 65 20 4e 2d 74 68 0a 2a 2a 20 61 72 r the N-th.** ar
384c0 67 75 6d 65 6e 74 20 6f 66 20 74 68 65 20 61 70 gument of the ap
384d0 70 6c 69 63 61 74 69 6f 6e 2d 64 65 66 69 6e 65 plication-define
384e0 64 20 66 75 6e 63 74 69 6f 6e 2e 20 20 5e 53 75 d function. ^Su
384f0 62 73 65 71 75 65 6e 74 0a 2a 2a 20 63 61 6c 6c bsequent.** call
38500 73 20 74 6f 20 73 71 6c 69 74 65 33 5f 67 65 74 s to sqlite3_get
38510 5f 61 75 78 64 61 74 61 28 43 2c 4e 29 20 72 65 _auxdata(C,N) re
38520 74 75 72 6e 20 50 20 66 72 6f 6d 20 74 68 65 20 turn P from the
38530 6d 6f 73 74 20 72 65 63 65 6e 74 0a 2a 2a 20 73 most recent.** s
38540 71 6c 69 74 65 33 5f 73 65 74 5f 61 75 78 64 61 qlite3_set_auxda
38550 74 61 28 43 2c 4e 2c 50 2c 58 29 20 63 61 6c 6c ta(C,N,P,X) call
38560 20 69 66 20 74 68 65 20 6d 65 74 61 64 61 74 61 if the metadata
38570 20 69 73 20 73 74 69 6c 6c 20 76 61 6c 69 64 20 is still valid
38580 6f 72 0a 2a 2a 20 4e 55 4c 4c 20 69 66 20 74 68 or.** NULL if th
38590 65 20 6d 65 74 61 64 61 74 61 20 68 61 73 20 62 e metadata has b
385a0 65 65 6e 20 64 69 73 63 61 72 64 65 64 2e 0a 2a een discarded..*
385b0 2a 20 5e 41 66 74 65 72 20 65 61 63 68 20 63 61 * ^After each ca
385c0 6c 6c 20 74 6f 20 73 71 6c 69 74 65 33 5f 73 65 ll to sqlite3_se
385d0 74 5f 61 75 78 64 61 74 61 28 43 2c 4e 2c 50 2c t_auxdata(C,N,P,
385e0 58 29 20 77 68 65 72 65 20 58 20 69 73 20 6e 6f X) where X is no
385f0 74 20 4e 55 4c 4c 2c 0a 2a 2a 20 53 51 4c 69 74 t NULL,.** SQLit
38600 65 20 77 69 6c 6c 20 69 6e 76 6f 6b 65 20 74 68 e will invoke th
38610 65 20 64 65 73 74 72 75 63 74 6f 72 20 66 75 6e e destructor fun
38620 63 74 69 6f 6e 20 58 20 77 69 74 68 20 70 61 72 ction X with par
38630 61 6d 65 74 65 72 20 50 20 65 78 61 63 74 6c 79 ameter P exactly
38640 0a 2a 2a 20 6f 6e 63 65 2c 20 77 68 65 6e 20 74 .** once, when t
38650 68 65 20 6d 65 74 61 64 61 74 61 20 69 73 20 64 he metadata is d
38660 69 73 63 61 72 64 65 64 2e 0a 2a 2a 20 53 51 4c iscarded..** SQL
38670 69 74 65 20 69 73 20 66 72 65 65 20 74 6f 20 64 ite is free to d
38680 69 73 63 61 72 64 20 74 68 65 20 6d 65 74 61 64 iscard the metad
38690 61 74 61 20 61 74 20 61 6e 79 20 74 69 6d 65 2c ata at any time,
386a0 20 69 6e 63 6c 75 64 69 6e 67 3a 20 3c 75 6c 3e including: <ul>
386b0 0a 2a 2a 20 3c 6c 69 3e 20 5e 28 77 68 65 6e 20 .** <li> ^(when
386c0 74 68 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e the correspondin
386d0 67 20 66 75 6e 63 74 69 6f 6e 20 70 61 72 61 6d g function param
386e0 65 74 65 72 20 63 68 61 6e 67 65 73 29 5e 2c 20 eter changes)^,
386f0 6f 72 0a 2a 2a 20 3c 6c 69 3e 20 5e 28 77 68 65 or.** <li> ^(whe
38700 6e 20 5b 73 71 6c 69 74 65 33 5f 72 65 73 65 74 n [sqlite3_reset
38710 28 29 5d 20 6f 72 20 5b 73 71 6c 69 74 65 33 5f ()] or [sqlite3_
38720 66 69 6e 61 6c 69 7a 65 28 29 5d 20 69 73 20 63 finalize()] is c
38730 61 6c 6c 65 64 20 66 6f 72 20 74 68 65 0a 2a 2a alled for the.**
38740 20 20 20 20 20 20 53 51 4c 20 73 74 61 74 65 6d SQL statem
38750 65 6e 74 29 5e 2c 20 6f 72 0a 2a 2a 20 3c 6c 69 ent)^, or.** <li
38760 3e 20 5e 28 77 68 65 6e 20 73 71 6c 69 74 65 33 > ^(when sqlite3
38770 5f 73 65 74 5f 61 75 78 64 61 74 61 28 29 20 69 _set_auxdata() i
38780 73 20 69 6e 76 6f 6b 65 64 20 61 67 61 69 6e 20 s invoked again
38790 6f 6e 20 74 68 65 20 73 61 6d 65 0a 2a 2a 20 20 on the same.**
387a0 20 20 20 20 20 70 61 72 61 6d 65 74 65 72 29 5e parameter)^
387b0 2c 20 6f 72 0a 2a 2a 20 3c 6c 69 3e 20 5e 28 64 , or.** <li> ^(d
387c0 75 72 69 6e 67 20 74 68 65 20 6f 72 69 67 69 6e uring the origin
387d0 61 6c 20 73 71 6c 69 74 65 33 5f 73 65 74 5f 61 al sqlite3_set_a
387e0 75 78 64 61 74 61