File
src/test_intarray.h
— part of check-in
[5471aca015]
at
2016-07-09 16:14:45
on branch trunk
— Fix various internal #defines to conform to new C-language naming restrictions,
specifically that private-use macros names must not begin with "_".
(user:
drh
size: 4603)
[more...]
0000: 2f 2a 0a 2a 2a 20 32 30 30 39 20 4e 6f 76 65 6d /*.** 2009 Novem
0010: 62 65 72 20 31 30 0a 2a 2a 0a 2a 2a 20 54 68 65 ber 10.**.** The
0020: 20 61 75 74 68 6f 72 20 64 69 73 63 6c 61 69 6d author disclaim
0030: 73 20 63 6f 70 79 72 69 67 68 74 20 74 6f 20 74 s copyright to t
0040: 68 69 73 20 73 6f 75 72 63 65 20 63 6f 64 65 2e his source code.
0050: 20 20 49 6e 20 70 6c 61 63 65 20 6f 66 0a 2a 2a In place of.**
0060: 20 61 20 6c 65 67 61 6c 20 6e 6f 74 69 63 65 2c a legal notice,
0070: 20 68 65 72 65 20 69 73 20 61 20 62 6c 65 73 73 here is a bless
0080: 69 6e 67 3a 0a 2a 2a 0a 2a 2a 20 20 20 20 4d 61 ing:.**.** Ma
0090: 79 20 79 6f 75 20 64 6f 20 67 6f 6f 64 20 61 6e y you do good an
00a0: 64 20 6e 6f 74 20 65 76 69 6c 2e 0a 2a 2a 20 20 d not evil..**
00b0: 20 20 4d 61 79 20 79 6f 75 20 66 69 6e 64 20 66 May you find f
00c0: 6f 72 67 69 76 65 6e 65 73 73 20 66 6f 72 20 79 orgiveness for y
00d0: 6f 75 72 73 65 6c 66 20 61 6e 64 20 66 6f 72 67 ourself and forg
00e0: 69 76 65 20 6f 74 68 65 72 73 2e 0a 2a 2a 20 20 ive others..**
00f0: 20 20 4d 61 79 20 79 6f 75 20 73 68 61 72 65 20 May you share
0100: 66 72 65 65 6c 79 2c 20 6e 65 76 65 72 20 74 61 freely, never ta
0110: 6b 69 6e 67 20 6d 6f 72 65 20 74 68 61 6e 20 79 king more than y
0120: 6f 75 20 67 69 76 65 2e 0a 2a 2a 0a 2a 2a 2a 2a ou 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 0a 2a 2a 0a 2a 2a 20 54 68 69 73 *****.**.** This
0180: 20 69 73 20 74 68 65 20 43 2d 6c 61 6e 67 75 61 is the C-langua
0190: 67 65 20 69 6e 74 65 72 66 61 63 65 20 64 65 66 ge interface def
01a0: 69 6e 69 74 69 6f 6e 20 66 6f 72 20 74 68 65 20 inition for the
01b0: 22 69 6e 74 61 72 72 61 79 22 20 6f 72 0a 2a 2a "intarray" or.**
01c0: 20 69 6e 74 65 67 65 72 20 61 72 72 61 79 20 76 integer array v
01d0: 69 72 74 75 61 6c 20 74 61 62 6c 65 20 66 6f 72 irtual table for
01e0: 20 53 51 4c 69 74 65 2e 0a 2a 2a 0a 2a 2a 20 54 SQLite..**.** T
01f0: 68 65 20 69 6e 74 61 72 72 61 79 20 76 69 72 74 he intarray virt
0200: 75 61 6c 20 74 61 62 6c 65 20 69 73 20 64 65 73 ual table is des
0210: 69 67 6e 65 64 20 74 6f 20 66 61 63 69 6c 69 74 igned to facilit
0220: 61 74 65 20 75 73 69 6e 67 20 61 6e 0a 2a 2a 20 ate using an.**
0230: 61 72 72 61 79 20 6f 66 20 69 6e 74 65 67 65 72 array of integer
0240: 73 20 61 73 20 74 68 65 20 72 69 67 68 74 2d 68 s as the right-h
0250: 61 6e 64 20 73 69 64 65 20 6f 66 20 61 6e 20 49 and side of an I
0260: 4e 20 6f 70 65 72 61 74 6f 72 2e 20 20 53 6f 0a N operator. So.
0270: 2a 2a 20 69 6e 73 74 65 61 64 20 6f 66 20 64 6f ** instead of do
0280: 69 6e 67 20 61 20 70 72 65 70 61 72 65 64 20 73 ing a prepared s
0290: 74 61 74 65 6d 65 6e 74 20 6c 69 6b 65 20 74 68 tatement like th
02a0: 69 73 3a 0a 2a 2a 0a 2a 2a 20 20 20 20 20 53 45 is:.**.** SE
02b0: 4c 45 43 54 20 2a 20 46 52 4f 4d 20 74 61 62 6c LECT * FROM tabl
02c0: 65 20 57 48 45 52 45 20 78 20 49 4e 20 28 3f 2c e WHERE x IN (?,
02d0: 3f 2c 3f 2c 2e 2e 2e 2c 3f 29 3b 0a 2a 2a 0a 2a ?,?,...,?);.**.*
02e0: 2a 20 41 6e 64 20 74 68 65 6e 20 62 69 6e 64 69 * And then bindi
02f0: 6e 67 20 69 6e 64 69 76 64 75 61 6c 20 69 6e 74 ng indivdual int
0300: 65 67 65 72 73 20 74 6f 20 65 61 63 68 20 6f 66 egers to each of
0310: 20 3f 20 73 6c 6f 74 73 2c 20 61 20 43 2d 6c 61 ? slots, a C-la
0320: 6e 67 75 61 67 65 0a 2a 2a 20 61 70 70 6c 69 63 nguage.** applic
0330: 61 74 69 6f 6e 20 63 61 6e 20 63 72 65 61 74 65 ation can create
0340: 20 61 6e 20 69 6e 74 61 72 72 61 79 20 6f 62 6a an intarray obj
0350: 65 63 74 20 28 6e 61 6d 65 64 20 22 65 78 31 22 ect (named "ex1"
0360: 20 69 6e 20 74 68 65 20 66 6f 6c 6c 6f 77 69 6e in the followin
0370: 67 0a 2a 2a 20 65 78 61 6d 70 6c 65 29 2c 20 70 g.** example), p
0380: 72 65 70 61 72 65 20 61 20 73 74 61 74 65 6d 65 repare a stateme
0390: 6e 74 20 6c 69 6b 65 20 74 68 69 73 3a 0a 2a 2a nt like this:.**
03a0: 0a 2a 2a 20 20 20 20 20 53 45 4c 45 43 54 20 2a .** SELECT *
03b0: 20 46 52 4f 4d 20 74 61 62 6c 65 20 57 48 45 52 FROM table WHER
03c0: 45 20 78 20 49 4e 20 65 78 31 3b 0a 2a 2a 0a 2a E x IN ex1;.**.*
03d0: 2a 20 54 68 65 6e 20 62 69 6e 64 20 61 6e 20 6f * Then bind an o
03e0: 72 64 69 6e 61 72 79 20 43 2f 43 2b 2b 20 61 72 rdinary C/C++ ar
03f0: 72 61 79 20 6f 66 20 69 6e 74 65 67 65 72 20 76 ray of integer v
0400: 61 6c 75 65 73 20 74 6f 20 74 68 65 20 65 78 31 alues to the ex1
0410: 20 6f 62 6a 65 63 74 0a 2a 2a 20 74 6f 20 72 75 object.** to ru
0420: 6e 20 74 68 65 20 73 74 61 74 65 6d 65 6e 74 2e n the statement.
0430: 0a 2a 2a 0a 2a 2a 20 55 53 41 47 45 3a 0a 2a 2a .**.** USAGE:.**
0440: 0a 2a 2a 20 4f 6e 65 20 6f 72 20 6d 6f 72 65 20 .** One or more
0450: 69 6e 74 61 72 72 61 79 20 6f 62 6a 65 63 74 73 intarray objects
0460: 20 63 61 6e 20 62 65 20 63 72 65 61 74 65 64 20 can be created
0470: 61 73 20 66 6f 6c 6c 6f 77 73 3a 0a 2a 2a 0a 2a as follows:.**.*
0480: 2a 20 20 20 20 20 20 73 71 6c 69 74 65 33 5f 69 * sqlite3_i
0490: 6e 74 61 72 72 61 79 20 2a 70 31 2c 20 2a 70 32 ntarray *p1, *p2
04a0: 2c 20 2a 70 33 3b 0a 2a 2a 20 20 20 20 20 20 73 , *p3;.** s
04b0: 71 6c 69 74 65 33 5f 69 6e 74 61 72 72 61 79 5f qlite3_intarray_
04c0: 63 72 65 61 74 65 28 64 62 2c 20 22 65 78 31 22 create(db, "ex1"
04d0: 2c 20 26 70 31 29 3b 0a 2a 2a 20 20 20 20 20 20 , &p1);.**
04e0: 73 71 6c 69 74 65 33 5f 69 6e 74 61 72 72 61 79 sqlite3_intarray
04f0: 5f 63 72 65 61 74 65 28 64 62 2c 20 22 65 78 32 _create(db, "ex2
0500: 22 2c 20 26 70 32 29 3b 0a 2a 2a 20 20 20 20 20 ", &p2);.**
0510: 20 73 71 6c 69 74 65 33 5f 69 6e 74 61 72 72 61 sqlite3_intarra
0520: 79 5f 63 72 65 61 74 65 28 64 62 2c 20 22 65 78 y_create(db, "ex
0530: 33 22 2c 20 26 70 33 29 3b 0a 2a 2a 0a 2a 2a 20 3", &p3);.**.**
0540: 45 61 63 68 20 63 61 6c 6c 20 74 6f 20 73 71 6c Each call to sql
0550: 69 74 65 33 5f 69 6e 74 61 72 72 61 79 5f 63 72 ite3_intarray_cr
0560: 65 61 74 65 28 29 20 67 65 6e 65 72 61 74 65 73 eate() generates
0570: 20 61 20 6e 65 77 20 76 69 72 74 75 61 6c 20 74 a new virtual t
0580: 61 62 6c 65 0a 2a 2a 20 6d 6f 64 75 6c 65 20 61 able.** module a
0590: 6e 64 20 61 20 73 69 6e 67 6c 65 74 6f 6e 20 6f nd a singleton o
05a0: 66 20 74 68 61 74 20 76 69 72 74 75 61 6c 20 74 f that virtual t
05b0: 61 62 6c 65 20 6d 6f 64 75 6c 65 20 69 6e 20 74 able module in t
05c0: 68 65 20 54 45 4d 50 0a 2a 2a 20 64 61 74 61 62 he TEMP.** datab
05d0: 61 73 65 2e 20 20 42 6f 74 68 20 74 68 65 20 6d ase. Both the m
05e0: 6f 64 75 6c 65 20 61 6e 64 20 74 68 65 20 76 69 odule and the vi
05f0: 72 74 75 61 6c 20 74 61 62 6c 65 20 69 6e 73 74 rtual table inst
0600: 61 6e 63 65 20 75 73 65 20 74 68 65 0a 2a 2a 20 ance use the.**
0610: 6e 61 6d 65 20 67 69 76 65 6e 20 62 79 20 74 68 name given by th
0620: 65 20 73 65 63 6f 6e 64 20 70 61 72 61 6d 65 74 e second paramet
0630: 65 72 2e 20 20 54 68 65 20 76 69 72 74 75 61 6c er. The virtual
0640: 20 74 61 62 6c 65 73 20 63 61 6e 20 74 68 65 6e tables can then
0650: 20 62 65 0a 2a 2a 20 75 73 65 64 20 69 6e 20 70 be.** used in p
0660: 72 65 70 61 72 65 64 20 73 74 61 74 65 6d 65 6e repared statemen
0670: 74 73 3a 0a 2a 2a 0a 2a 2a 20 20 20 20 20 20 53 ts:.**.** S
0680: 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 74 31 2c ELECT * FROM t1,
0690: 20 74 32 2c 20 74 33 0a 2a 2a 20 20 20 20 20 20 t2, t3.**
06a0: 20 57 48 45 52 45 20 74 31 2e 78 20 49 4e 20 65 WHERE t1.x IN e
06b0: 78 31 0a 2a 2a 20 20 20 20 20 20 20 20 20 41 4e x1.** AN
06c0: 44 20 74 32 2e 79 20 49 4e 20 65 78 32 0a 2a 2a D t2.y IN ex2.**
06d0: 20 20 20 20 20 20 20 20 20 41 4e 44 20 74 33 2e AND t3.
06e0: 7a 20 49 4e 20 65 78 33 3b 0a 2a 2a 0a 2a 2a 20 z IN ex3;.**.**
06f0: 45 61 63 68 20 69 6e 74 65 67 65 72 20 61 72 72 Each integer arr
0700: 61 79 20 69 73 20 69 6e 69 74 69 61 6c 6c 79 20 ay is initially
0710: 65 6d 70 74 79 2e 20 20 4e 65 77 20 61 72 72 61 empty. New arra
0720: 79 73 20 63 61 6e 20 62 65 20 62 6f 75 6e 64 20 ys can be bound
0730: 74 6f 0a 2a 2a 20 61 6e 20 69 6e 74 65 67 65 72 to.** an integer
0740: 20 61 72 72 61 79 20 61 73 20 66 6f 6c 6c 6f 77 array as follow
0750: 73 3a 0a 2a 2a 0a 2a 2a 20 20 20 20 20 73 71 6c s:.**.** sql
0760: 69 74 65 33 5f 69 6e 74 36 34 20 61 31 5b 5d 20 ite3_int64 a1[]
0770: 3d 20 7b 20 31 2c 20 32 2c 20 33 2c 20 34 20 7d = { 1, 2, 3, 4 }
0780: 3b 0a 2a 2a 20 20 20 20 20 73 71 6c 69 74 65 33 ;.** sqlite3
0790: 5f 69 6e 74 36 34 20 61 32 5b 5d 20 3d 20 7b 20 _int64 a2[] = {
07a0: 35 2c 20 36 2c 20 37 2c 20 38 2c 20 39 2c 20 31 5, 6, 7, 8, 9, 1
07b0: 30 2c 20 31 31 20 7d 3b 0a 2a 2a 20 20 20 20 20 0, 11 };.**
07c0: 73 71 6c 69 74 65 33 5f 69 6e 74 36 34 20 2a 61 sqlite3_int64 *a
07d0: 33 20 3d 20 73 71 6c 69 74 65 33 5f 6d 61 6c 6c 3 = sqlite3_mall
07e0: 6f 63 28 20 31 30 30 2a 73 69 7a 65 6f 66 28 73 oc( 100*sizeof(s
07f0: 71 6c 69 74 65 33 5f 69 6e 74 36 34 29 20 29 3b qlite3_int64) );
0800: 0a 2a 2a 20 20 20 20 20 2f 2f 20 46 69 6c 6c 20 .** // Fill
0810: 69 6e 20 63 6f 6e 74 65 6e 74 20 6f 66 20 61 33 in content of a3
0820: 5b 5d 0a 2a 2a 20 20 20 20 20 73 71 6c 69 74 65 [].** sqlite
0830: 33 5f 69 6e 74 61 72 72 61 79 5f 62 69 6e 64 28 3_intarray_bind(
0840: 70 31 2c 20 34 2c 20 61 31 2c 20 30 29 3b 0a 2a p1, 4, a1, 0);.*
0850: 2a 20 20 20 20 20 73 71 6c 69 74 65 33 5f 69 6e * sqlite3_in
0860: 74 61 72 72 61 79 5f 62 69 6e 64 28 70 32 2c 20 tarray_bind(p2,
0870: 37 2c 20 61 32 2c 20 30 29 3b 0a 2a 2a 20 20 20 7, a2, 0);.**
0880: 20 20 73 71 6c 69 74 65 33 5f 69 6e 74 61 72 72 sqlite3_intarr
0890: 61 79 5f 62 69 6e 64 28 70 33 2c 20 31 30 30 2c ay_bind(p3, 100,
08a0: 20 61 33 2c 20 73 71 6c 69 74 65 33 5f 66 72 65 a3, sqlite3_fre
08b0: 65 29 3b 0a 2a 2a 0a 2a 2a 20 41 20 73 69 6e 67 e);.**.** A sing
08c0: 6c 65 20 69 6e 74 61 72 72 61 79 20 6f 62 6a 65 le intarray obje
08d0: 63 74 20 63 61 6e 20 62 65 20 72 65 62 6f 75 6e ct can be reboun
08e0: 64 20 6d 75 6c 74 69 70 6c 65 20 74 69 6d 65 73 d multiple times
08f0: 2e 20 20 42 75 74 20 64 6f 20 6e 6f 74 0a 2a 2a . But do not.**
0900: 20 61 74 74 65 6d 70 74 20 74 6f 20 63 68 61 6e attempt to chan
0910: 67 65 20 74 68 65 20 62 69 6e 64 69 6e 67 73 20 ge the bindings
0920: 6f 66 20 61 6e 20 69 6e 74 61 72 72 61 79 20 77 of an intarray w
0930: 68 69 6c 65 20 69 74 20 69 73 20 69 6e 20 74 68 hile it is in th
0940: 65 20 6d 69 64 64 6c 65 0a 2a 2a 20 6f 66 20 61 e middle.** of a
0950: 20 71 75 65 72 79 2e 0a 2a 2a 0a 2a 2a 20 54 68 query..**.** Th
0960: 65 20 61 72 72 61 79 20 74 68 61 74 20 68 6f 6c e array that hol
0970: 64 73 20 74 68 65 20 69 6e 74 65 67 65 72 73 20 ds the integers
0980: 69 73 20 61 75 74 6f 6d 61 74 69 63 61 6c 6c 79 is automatically
0990: 20 66 72 65 65 64 20 62 79 20 74 68 65 20 66 75 freed by the fu
09a0: 6e 63 74 69 6f 6e 0a 2a 2a 20 69 6e 20 74 68 65 nction.** in the
09b0: 20 66 6f 75 72 74 68 20 70 61 72 61 6d 65 74 65 fourth paramete
09c0: 72 20 74 6f 20 73 71 6c 69 74 65 33 5f 69 6e 74 r to sqlite3_int
09d0: 61 72 72 61 79 5f 62 69 6e 64 28 29 20 77 68 65 array_bind() whe
09e0: 6e 20 74 68 65 20 61 72 72 61 79 20 69 73 20 6e n the array is n
09f0: 6f 0a 2a 2a 20 6c 6f 6e 67 65 72 20 6e 65 65 64 o.** longer need
0a00: 65 64 2e 20 20 54 68 65 20 61 70 70 6c 69 63 61 ed. The applica
0a10: 74 69 6f 6e 20 6d 75 73 74 20 6e 6f 74 20 63 68 tion must not ch
0a20: 61 6e 67 65 20 74 68 65 20 69 6e 74 61 72 72 61 ange the intarra
0a30: 79 20 76 61 6c 75 65 73 0a 2a 2a 20 77 68 69 6c y values.** whil
0a40: 65 20 61 6e 20 69 6e 74 61 72 72 61 79 20 69 73 e an intarray is
0a50: 20 69 6e 20 74 68 65 20 6d 69 64 64 6c 65 20 6f in the middle o
0a60: 66 20 61 20 71 75 65 72 79 2e 0a 2a 2a 0a 2a 2a f a query..**.**
0a70: 20 54 68 65 20 69 6e 74 61 72 72 61 79 20 6f 62 The intarray ob
0a80: 6a 65 63 74 20 69 73 20 61 75 74 6f 6d 61 74 69 ject is automati
0a90: 63 61 6c 6c 79 20 64 65 73 74 72 6f 79 65 64 20 cally destroyed
0aa0: 77 68 65 6e 20 69 74 73 20 63 6f 72 72 65 73 70 when its corresp
0ab0: 6f 6e 64 69 6e 67 0a 2a 2a 20 76 69 72 74 75 61 onding.** virtua
0ac0: 6c 20 74 61 62 6c 65 20 69 73 20 64 72 6f 70 70 l table is dropp
0ad0: 65 64 2e 20 20 53 69 6e 63 65 20 74 68 65 20 76 ed. Since the v
0ae0: 69 72 74 75 61 6c 20 74 61 62 6c 65 73 20 61 72 irtual tables ar
0af0: 65 20 63 72 65 61 74 65 64 20 69 6e 20 74 68 65 e created in the
0b00: 0a 2a 2a 20 54 45 4d 50 20 64 61 74 61 62 61 73 .** TEMP databas
0b10: 65 2c 20 74 68 65 79 20 61 72 65 20 61 75 74 6f e, they are auto
0b20: 6d 61 74 69 63 61 6c 6c 79 20 64 72 6f 70 70 65 matically droppe
0b30: 64 20 77 68 65 6e 20 74 68 65 20 64 61 74 61 62 d when the datab
0b40: 61 73 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 0a 2a ase connection.*
0b50: 2a 20 63 6c 6f 73 65 73 20 73 6f 20 74 68 65 20 * closes so the
0b60: 61 70 70 6c 69 63 61 74 69 6f 6e 20 64 6f 65 73 application does
0b70: 20 6e 6f 74 20 6e 6f 72 6d 61 6c 6c 79 20 6e 65 not normally ne
0b80: 65 64 20 74 6f 20 74 61 6b 65 20 61 6e 79 20 73 ed to take any s
0b90: 70 65 63 69 61 6c 0a 2a 2a 20 61 63 74 69 6f 6e pecial.** action
0ba0: 20 74 6f 20 66 72 65 65 20 74 68 65 20 69 6e 74 to free the int
0bb0: 61 72 72 61 79 20 6f 62 6a 65 63 74 73 2e 0a 2a array objects..*
0bc0: 2f 0a 23 69 6e 63 6c 75 64 65 20 22 73 71 6c 69 /.#include "sqli
0bd0: 74 65 33 2e 68 22 0a 23 69 66 6e 64 65 66 20 53 te3.h".#ifndef S
0be0: 51 4c 49 54 45 5f 49 4e 54 41 52 52 41 59 5f 48 QLITE_INTARRAY_H
0bf0: 0a 23 64 65 66 69 6e 65 20 53 51 4c 49 54 45 5f .#define SQLITE_
0c00: 49 4e 54 41 52 52 41 59 5f 48 0a 0a 2f 2a 0a 2a INTARRAY_H../*.*
0c10: 2a 20 4d 61 6b 65 20 73 75 72 65 20 77 65 20 63 * Make sure we c
0c20: 61 6e 20 63 61 6c 6c 20 74 68 69 73 20 73 74 75 an call this stu
0c30: 66 66 20 66 72 6f 6d 20 43 2b 2b 2e 0a 2a 2f 0a ff from C++..*/.
0c40: 23 69 66 64 65 66 20 5f 5f 63 70 6c 75 73 70 6c #ifdef __cpluspl
0c50: 75 73 0a 65 78 74 65 72 6e 20 22 43 22 20 7b 0a us.extern "C" {.
0c60: 23 65 6e 64 69 66 0a 0a 2f 2a 0a 2a 2a 20 41 6e #endif../*.** An
0c70: 20 73 71 6c 69 74 65 33 5f 69 6e 74 61 72 72 61 sqlite3_intarra
0c80: 79 20 69 73 20 61 6e 20 61 62 73 74 72 61 63 74 y is an abstract
0c90: 20 74 79 70 65 20 74 6f 20 73 74 6f 72 65 73 20 type to stores
0ca0: 61 6e 20 69 6e 73 74 61 6e 63 65 20 6f 66 0a 2a an instance of.*
0cb0: 2a 20 61 6e 20 69 6e 74 65 67 65 72 20 61 72 72 * an integer arr
0cc0: 61 79 2e 0a 2a 2f 0a 74 79 70 65 64 65 66 20 73 ay..*/.typedef s
0cd0: 74 72 75 63 74 20 73 71 6c 69 74 65 33 5f 69 6e truct sqlite3_in
0ce0: 74 61 72 72 61 79 20 73 71 6c 69 74 65 33 5f 69 tarray sqlite3_i
0cf0: 6e 74 61 72 72 61 79 3b 0a 0a 2f 2a 0a 2a 2a 20 ntarray;../*.**
0d00: 49 6e 76 6f 6b 65 20 74 68 69 73 20 72 6f 75 74 Invoke this rout
0d10: 69 6e 65 20 74 6f 20 63 72 65 61 74 65 20 61 20 ine to create a
0d20: 73 70 65 63 69 66 69 63 20 69 6e 73 74 61 6e 63 specific instanc
0d30: 65 20 6f 66 20 61 6e 20 69 6e 74 61 72 72 61 79 e of an intarray
0d40: 20 6f 62 6a 65 63 74 2e 0a 2a 2a 20 54 68 65 20 object..** The
0d50: 6e 65 77 20 69 6e 74 61 72 72 61 79 20 6f 62 6a new intarray obj
0d60: 65 63 74 20 69 73 20 72 65 74 75 72 6e 65 64 20 ect is returned
0d70: 62 79 20 74 68 65 20 33 72 64 20 70 61 72 61 6d by the 3rd param
0d80: 65 74 65 72 2e 0a 2a 2a 0a 2a 2a 20 45 61 63 68 eter..**.** Each
0d90: 20 69 6e 74 61 72 72 61 79 20 6f 62 6a 65 63 74 intarray object
0da0: 20 63 6f 72 72 65 73 70 6f 6e 64 73 20 74 6f 20 corresponds to
0db0: 61 20 76 69 72 74 75 61 6c 20 74 61 62 6c 65 20 a virtual table
0dc0: 69 6e 20 74 68 65 20 54 45 4d 50 20 74 61 62 6c in the TEMP tabl
0dd0: 65 0a 2a 2a 20 77 69 74 68 20 61 20 6e 61 6d 65 e.** with a name
0de0: 20 6f 66 20 7a 4e 61 6d 65 2e 0a 2a 2a 0a 2a 2a of zName..**.**
0df0: 20 44 65 73 74 72 6f 79 20 74 68 65 20 69 6e 74 Destroy the int
0e00: 61 72 72 61 79 20 6f 62 6a 65 63 74 20 62 79 20 array object by
0e10: 64 72 6f 70 70 69 6e 67 20 74 68 65 20 76 69 72 dropping the vir
0e20: 74 75 61 6c 20 74 61 62 6c 65 2e 20 20 49 66 20 tual table. If
0e30: 6e 6f 74 20 64 6f 6e 65 0a 2a 2a 20 65 78 70 6c not done.** expl
0e40: 69 63 69 74 6c 79 20 62 79 20 74 68 65 20 61 70 icitly by the ap
0e50: 70 6c 69 63 61 74 69 6f 6e 2c 20 74 68 65 20 76 plication, the v
0e60: 69 72 74 75 61 6c 20 74 61 62 6c 65 20 77 69 6c irtual table wil
0e70: 6c 20 62 65 20 64 72 6f 70 70 65 64 20 69 6d 70 l be dropped imp
0e80: 6c 69 63 69 74 6c 79 0a 2a 2a 20 62 79 20 74 68 licitly.** by th
0e90: 65 20 73 79 73 74 65 6d 20 77 68 65 6e 20 74 68 e system when th
0ea0: 65 20 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 e database conne
0eb0: 63 74 69 6f 6e 20 69 73 20 63 6c 6f 73 65 64 2e ction is closed.
0ec0: 0a 2a 2f 0a 53 51 4c 49 54 45 5f 41 50 49 20 69 .*/.SQLITE_API i
0ed0: 6e 74 20 73 71 6c 69 74 65 33 5f 69 6e 74 61 72 nt sqlite3_intar
0ee0: 72 61 79 5f 63 72 65 61 74 65 28 0a 20 20 73 71 ray_create(. sq
0ef0: 6c 69 74 65 33 20 2a 64 62 2c 0a 20 20 63 6f 6e lite3 *db,. con
0f00: 73 74 20 63 68 61 72 20 2a 7a 4e 61 6d 65 2c 0a st char *zName,.
0f10: 20 20 73 71 6c 69 74 65 33 5f 69 6e 74 61 72 72 sqlite3_intarr
0f20: 61 79 20 2a 2a 70 70 52 65 74 75 72 6e 0a 29 3b ay **ppReturn.);
0f30: 0a 0a 2f 2a 0a 2a 2a 20 42 69 6e 64 20 61 20 6e ../*.** Bind a n
0f40: 65 77 20 61 72 72 61 79 20 61 72 72 61 79 20 6f ew array array o
0f50: 66 20 69 6e 74 65 67 65 72 73 20 74 6f 20 61 20 f integers to a
0f60: 73 70 65 63 69 66 69 63 20 69 6e 74 61 72 72 61 specific intarra
0f70: 79 20 6f 62 6a 65 63 74 2e 0a 2a 2a 0a 2a 2a 20 y object..**.**
0f80: 54 68 65 20 61 72 72 61 79 20 6f 66 20 69 6e 74 The array of int
0f90: 65 67 65 72 73 20 62 6f 75 6e 64 20 6d 75 73 74 egers bound must
0fa0: 20 62 65 20 75 6e 63 68 61 6e 67 65 64 20 66 6f be unchanged fo
0fb0: 72 20 74 68 65 20 64 75 72 61 74 69 6f 6e 20 6f r the duration o
0fc0: 66 0a 2a 2a 20 61 6e 79 20 71 75 65 72 79 20 61 f.** any query a
0fd0: 67 61 69 6e 73 74 20 74 68 65 20 63 6f 72 72 65 gainst the corre
0fe0: 73 70 6f 6e 64 69 6e 67 20 76 69 72 74 75 61 6c sponding virtual
0ff0: 20 74 61 62 6c 65 2e 20 20 49 66 20 74 68 65 20 table. If the
1000: 69 6e 74 65 67 65 72 0a 2a 2a 20 61 72 72 61 79 integer.** array
1010: 20 64 6f 65 73 20 63 68 61 6e 67 65 20 6f 72 20 does change or
1020: 69 73 20 64 65 61 6c 6c 6f 63 61 74 65 64 20 75 is deallocated u
1030: 6e 64 65 66 69 6e 65 64 20 62 65 68 61 76 69 6f ndefined behavio
1040: 72 20 77 69 6c 6c 20 72 65 73 75 6c 74 2e 0a 2a r will result..*
1050: 2f 0a 53 51 4c 49 54 45 5f 41 50 49 20 69 6e 74 /.SQLITE_API int
1060: 20 73 71 6c 69 74 65 33 5f 69 6e 74 61 72 72 61 sqlite3_intarra
1070: 79 5f 62 69 6e 64 28 0a 20 20 73 71 6c 69 74 65 y_bind(. sqlite
1080: 33 5f 69 6e 74 61 72 72 61 79 20 2a 70 49 6e 74 3_intarray *pInt
1090: 41 72 72 61 79 2c 20 20 20 2f 2a 20 54 68 65 20 Array, /* The
10a0: 69 6e 74 61 72 72 61 79 20 6f 62 6a 65 63 74 20 intarray object
10b0: 74 6f 20 62 69 6e 64 20 74 6f 20 2a 2f 0a 20 20 to bind to */.
10c0: 69 6e 74 20 6e 45 6c 65 6d 65 6e 74 73 2c 20 20 int nElements,
10d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f /
10e0: 2a 20 4e 75 6d 62 65 72 20 6f 66 20 65 6c 65 6d * Number of elem
10f0: 65 6e 74 73 20 69 6e 20 74 68 65 20 69 6e 74 61 ents in the inta
1100: 72 72 61 79 20 2a 2f 0a 20 20 73 71 6c 69 74 65 rray */. sqlite
1110: 33 5f 69 6e 74 36 34 20 2a 61 45 6c 65 6d 65 6e 3_int64 *aElemen
1120: 74 73 2c 20 20 20 20 20 20 2f 2a 20 43 6f 6e 74 ts, /* Cont
1130: 65 6e 74 20 6f 66 20 74 68 65 20 69 6e 74 61 72 ent of the intar
1140: 72 61 79 20 2a 2f 0a 20 20 76 6f 69 64 20 28 2a ray */. void (*
1150: 78 46 72 65 65 29 28 76 6f 69 64 2a 29 20 20 20 xFree)(void*)
1160: 20 20 20 20 20 20 20 20 2f 2a 20 48 6f 77 20 74 /* How t
1170: 6f 20 64 69 73 70 6f 73 65 20 6f 66 20 74 68 65 o dispose of the
1180: 20 69 6e 74 61 72 72 61 79 20 77 68 65 6e 20 64 intarray when d
1190: 6f 6e 65 20 2a 2f 0a 29 3b 0a 0a 23 69 66 64 65 one */.);..#ifde
11a0: 66 20 5f 5f 63 70 6c 75 73 70 6c 75 73 0a 7d 20 f __cplusplus.}
11b0: 20 2f 2a 20 45 6e 64 20 6f 66 20 74 68 65 20 27 /* End of the '
11c0: 65 78 74 65 72 6e 20 22 43 22 27 20 62 6c 6f 63 extern "C"' bloc
11d0: 6b 20 2a 2f 0a 23 65 6e 64 69 66 0a 23 65 6e 64 k */.#endif.#end
11e0: 69 66 20 2f 2a 20 53 51 4c 49 54 45 5f 49 4e 54 if /* SQLITE_INT
11f0: 41 52 52 41 59 5f 48 20 2a 2f 0a ARRAY_H */.