Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Nov 20, 2020. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlite.h.cmake
More file actions
Latest commit
886 lines (832 loc) · 37.9 KB
/
Copy pathsqlite.h.cmake
File metadata and controls
886 lines (832 loc) · 37.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
/*
**2001September15
**
**Theauthordisclaimscopyrighttothissourcecode.Inplaceof
**alegalnotice,hereisablessing:
**
**Mayyoudogoodandnotevil.
**Mayyoufindforgivenessforyourselfandforgiveothers.
**Mayyousharefreely,nevertakingmorethanyougive.
**
*************************************************************************
**ThisheaderfiledefinestheinterfacethattheSQLitelibrary
**presentstoclientprograms.
**
**@(#) $Id: sqlite.h.in,v 1.60.2.1 2004/10/06 15:52:36 drh Exp $
*/
#ifndef _SQLITE_H_
#define _SQLITE_H_
#include <stdarg.h> /* Needed for the definition of va_list */
/*
**MakesurewecancallthisstufffromC++.
*/
#ifdef __cplusplus
extern"C"{
#endif
/*
**TheversionoftheSQLitelibrary.
*/
#ifdef SQLITE_VERSION
# undef SQLITE_VERSION
#else
# define SQLITE_VERSION "${VERS}"
#endif
/*
**Theversionstringisalsocompiledintothelibrarysothataprogram
**canchecktomakesurethatthelib*.afileandthe*.hfilearefrom
**thesameversion.
*/
externconstcharsqlite_version[];
/*
**TheSQLITE_UTF8macroisdefinedifthelibraryexpectstosee
**UTF-8encodeddata.TheSQLITE_ISO8859macroisdefinedifthe
**iso8859encodedshouldbeused.
*/
#define SQLITE_${ENCODING} 1
/*
**Thefollowingconstantholdsoneoftwostrings,"UTF-8"or"iso8859",
**dependingonwhichcharacterencodingtheSQLitelibraryexpectsto
**see.ThecharacterencodingmakesadifferencefortheLIKEandGLOB
**operatorsandfortheLENGTH() andSUBSTR() functions.
*/
externconstcharsqlite_encoding[];
/*
**Eachopensqlitedatabaseisrepresentedbyaninstanceofthe
**followingopaquestructure.
*/
typedefstructsqlitesqlite;
/*
**Afunctiontoopenanewsqlitedatabase.
**
**Ifthedatabasedoesnotexistandmodeindicateswrite
**permission,thenanewdatabaseiscreated.Ifthedatabase
**doesnotexistandmodedoesnotindicatewritepermission,
**thentheopenfails,anerrormessagegenerated (iferrmsg!=0)
**andthefunctionreturns0.
**
**Ifmodedoesnotindicatesuserwritepermission,thenthe
**databaseisopenedread-only.
**
**TheTruth:Ascurrentlyimplemented,alldatabasesareopened
**forwritingallthetime.Maybesomedaywewillprovidethe
**abilitytoopenadatabasereadonly.Themodeparametersis
**providedinanticipationofthatenhancement.
*/
sqlite*sqlite_open(constchar*filename,intmode,char**errmsg);
/*
**Afunctiontoclosethedatabase.
**
**Callthisfunctionwithapointertoastructurethatwaspreviously
**returnedfromsqlite_open() andthecorrespondingdatabasewillbyclosed.
*/
voidsqlite_close(sqlite*);
/*
**Thetypeforacallbackfunction.
*/
typedefint (*sqlite_callback)(void*,int,char**,char**);
/*
**AfunctiontoexecutesoneormorestatementsofSQL.
**
**IfoneormoreoftheSQLstatementsarequeries,then
**thecallbackfunctionspecifiedbythe3rdparameteris
**invokedonceforeachrowofthequeryresult.Thiscallback
**shouldnormallyreturn0.Ifthecallbackreturnsanon-zero
**valuethenthequeryisaborted,allsubsequentSQLstatements
**areskippedandthesqlite_exec() functionreturnstheSQLITE_ABORT.
**
**The4thparameterisanarbitrarypointerthatispassed
**tothecallbackfunctionasitsfirstparameter.
**
**The2ndparametertothecallbackfunctionisthenumberof
**columnsinthequeryresult.The3rdparametertothecallback
**isanarrayofstringsholdingthevaluesforeachcolumn.
**The4thparametertothecallbackisanarrayofstringsholding
**thenamesofeachcolumn.
**
**ThecallbackfunctionmaybeNULL,evenforqueries.ANULL
**callbackisnotanerror.Itjustmeansthatnocallback
**willbeinvoked.
**
**IfanerroroccurswhileparsingorevaluatingtheSQL (but
**notwhileexecutingthecallback) thenanappropriateerror
**messageiswrittenintomemoryobtainedfrommalloc() and
***errmsgismadetopointtothatmessage.Thecallingfunction
**isresponsibleforfreeingthememorythatholdstheerror
**message.Usesqlite_freemem() forthis.Iferrmsg==NULL,
**thennoerrormessageiseverwritten.
**
**ThereturnvalueisisSQLITE_OKiftherearenoerrorsand
**someotherreturncodeifthereisanerror.Theparticular
**returnvaluedependsonthetypeoferror.
**
**Ifthequerycouldnotbeexecutedbecauseadatabasefileis
**lockedorbusy,thenthisfunctionreturnsSQLITE_BUSY. (This
**behaviorcanbemodifiedsomewhatusingthesqlite_busy_handler()
**andsqlite_busy_timeout() functionsbelow.)
*/
intsqlite_exec(
sqlite*,/*Anopendatabase*/
constchar*sql,/*SQLtobeexecuted*/
sqlite_callback,/*Callbackfunction*/
void*,/*1stargumenttocallbackfunction*/
char**errmsg/*Errormsgwrittenhere*/
);
/*
**Returnvaluesforsqlite_exec() andsqlite_step()
*/
#define SQLITE_OK 0 /* Successful result */
#define SQLITE_ERROR 1 /* SQL error or missing database */
#define SQLITE_INTERNAL 2 /* An internal logic error in SQLite */
#define SQLITE_PERM 3 /* Access permission denied */
#define SQLITE_ABORT 4 /* Callback routine requested an abort */
#define SQLITE_BUSY 5 /* The database file is locked */
#define SQLITE_LOCKED 6 /* A table in the database is locked */
#define SQLITE_NOMEM 7 /* A malloc() failed */
#define SQLITE_READONLY 8 /* Attempt to write a readonly database */
#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite_interrupt() */
#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */
#define SQLITE_CORRUPT 11 /* The database disk image is malformed */
#define SQLITE_NOTFOUND 12 /* (Internal Only) Table or record not found */
#define SQLITE_FULL 13 /* Insertion failed because database is full */
#define SQLITE_CANTOPEN 14 /* Unable to open the database file */
#define SQLITE_PROTOCOL 15 /* Database lock protocol error */
#define SQLITE_EMPTY 16 /* (Internal Only) Database table is empty */
#define SQLITE_SCHEMA 17 /* The database schema changed */
#define SQLITE_TOOBIG 18 /* Too much data for one row of a table */
#define SQLITE_CONSTRAINT 19 /* Abort due to contraint violation */
#define SQLITE_MISMATCH 20 /* Data type mismatch */
#define SQLITE_MISUSE 21 /* Library used incorrectly */
#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */
#define SQLITE_AUTH 23 /* Authorization denied */
#define SQLITE_FORMAT 24 /* Auxiliary database format error */
#define SQLITE_RANGE 25 /* 2nd parameter to sqlite_bind out of range */
#define SQLITE_NOTADB 26 /* File opened that is not a database file */
#define SQLITE_ROW 100 /* sqlite_step() has another row ready */
#define SQLITE_DONE 101 /* sqlite_step() has finished executing */
/*
**EachentryinanSQLitetablehasauniqueintegerkey. (Thekeyis
**thevalueoftheINTEGERPRIMARYKEYcolumnifthereissuchacolumn,
**otherwisethekeyisgeneratedatrandom.Theuniquekeyisalways
**availableastheROWID,OID,or_ROWID_column.) Thefollowingroutine
**returnstheintegerkeyofthemostrecentinsertinthedatabase.
**
**Thisfunctionissimilartothemysql_insert_id() functionfromMySQL.
*/
intsqlite_last_insert_rowid(sqlite*);
/*
**Thisfunctionreturnsthenumberofdatabaserowsthatwerechanged
** (orinsertedordeleted) bythemostrecentcalledsqlite_exec().
**
**Allchangesarecounted,eveniftheywerelaterundonebya
**ROLLBACKorABORT.Except,changesassociatedwithcreatingand
**droppingtablesarenotcounted.
**
**Ifacallbackinvokessqlite_exec() recursively,thenthechanges
**intheinner,recursivecallarecountedtogetherwiththechanges
**intheoutercall.
**
**SQLiteimplementsthecommand"DELETE FROM table"withoutaWHEREclause
**bydroppingandrecreatingthetable. (Thisismuchfasterthangoing
**throughanddeletingindividualelementsformthetable.) Becauseof
**thisoptimization,thechangecountfor"DELETE FROM table"willbe
**zeroregardlessofthenumberofelementsthatwereoriginallyinthe
**table.Togetanaccuratecountofthenumberofrowsdeleted,use
**"DELETE FROM table WHERE 1"instead.
*/
intsqlite_changes(sqlite*);
/*
**Thisfunctionreturnsthenumberofdatabaserowsthatwerechanged
**bythelastINSERT,UPDATE,orDELETEstatmentexecutedbysqlite_exec(),
**orbythelastVMtoruntocompletion.Thechangecountisnotupdated
**bySQLstatementsotherthanINSERT,UPDATEorDELETE.
**
**Changesarecounted,eveniftheyarelaterundonebyaROLLBACKor
**ABORT.Changesassociatedwithtriggerprogramsthatexecuteasa
**resultoftheINSERT,UPDATE,orDELETEstatementarenotcounted.
**
**Ifacallbackinvokessqlite_exec() recursively,thenthechanges
**intheinner,recursivecallarecountedtogetherwiththechanges
**intheoutercall.
**
**SQLiteimplementsthecommand"DELETE FROM table"withoutaWHEREclause
**bydroppingandrecreatingthetable. (Thisismuchfasterthangoing
**throughanddeletingindividualelementsformthetable.) Becauseof
**thisoptimization,thechangecountfor"DELETE FROM table"willbe
**zeroregardlessofthenumberofelementsthatwereoriginallyinthe
**table.Togetanaccuratecountofthenumberofrowsdeleted,use
**"DELETE FROM table WHERE 1"instead.
**
*******THISISANEXPERIMENTALAPIANDISSUBJECTTOCHANGE******
*/
intsqlite_last_statement_changes(sqlite*);
/*Iftheparametertothisroutineisoneofthereturnvalueconstants
**definedabove,thenthisroutinereturnsaconstanttextstringwhich
**descripts (inEnglish) themeaningofthereturnvalue.
*/
constchar*sqlite_error_string(int);
#define sqliteErrStr sqlite_error_string /* Legacy. Do not use in new code. */
/*Thisfunctioncausesanypendingdatabaseoperationtoabortand
**returnatitsearliestopportunity.Thisroutineistypically
**calledinresponsetoauseractionsuchaspressing"Cancel"
**orCtrl-Cwheretheuserwantsalongqueryoperationtohalt
**immediately.
*/
voidsqlite_interrupt(sqlite*);
/*Thisfunctionreturnstrueifthegiveninputstringcomprises
**oneormorecompleteSQLstatements.
**
**Thealgorithmissimple.Ifthelasttokenotherthanspaces
**andcommentsisasemicolon,thenreturntrue.otherwisereturn
**false.
*/
intsqlite_complete(constchar*sql);
/*
**Thisroutineidentifiesacallbackfunctionthatisinvoked
**wheneveranattemptismadetoopenadatabasetablethatis
**currentlylockedbyanotherprocessorthread.Ifthebusycallback
**isNULL,thensqlite_exec() returnsSQLITE_BUSYimmediatelyif
**itfindsalockedtable.IfthebusycallbackisnotNULL,then
**sqlite_exec() invokesthecallbackwiththreearguments.The
**secondargumentisthenameofthelockedtableandthethird
**argumentisthenumberoftimesthetablehasbeenbusy.Ifthe
**busycallbackreturns0,thensqlite_exec() immediatelyreturns
**SQLITE_BUSY.Ifthecallbackreturnsnon-zero,thensqlite_exec()
**triestoopenthetableagainandthecyclerepeats.
**
**ThedefaultbusycallbackisNULL.
**
**Sqliteisre-entrant,sothebusyhandlermaystartanewquery.
** (Itisnotclearwhyanyonewouldeverywanttodothis,butit
**isallowed,intheory.) Butthebusyhandlermaynotclosethe
**database.Closingthedatabasefromabusyhandlerwilldelete
**datastructuresoutfromundertheexecutingqueryandwill
**probablyresultinacoredump.
*/
voidsqlite_busy_handler(sqlite*,int(*)(void*,constchar*,int),void*);
/*
**Thisroutinesetsabusyhandlerthatsleepsforawhilewhena
**tableislocked.Thehandlerwillsleepmultipletimesuntil
**atleast"ms"millesecondsofsleepinghavebeendone.After
**"ms"millesecondsofsleeping,thehandlerreturns0which
**causessqlite_exec() toreturnSQLITE_BUSY.
**
**Callingthisroutinewithanargumentlessthanorequaltozero
**turnsoffallbusyhandlers.
*/
voidsqlite_busy_timeout(sqlite*,intms);
/*
**Thisnextroutineisreallyjustawrapperaroundsqlite_exec().
**Insteadofinvokingauser-suppliedcallbackforeachrowofthe
**result,thisroutinerememberseachrowoftheresultinmemory
**obtainedfrommalloc(),thenreturnsalloftheresultafterthe
**queryhasfinished.
**
**Asanexample,supposethequeryresultwherethistable:
**
**Name|Age
**-----------------------
**Alice|43
**Bob|28
**Cindy|21
**
**Ifthe3rdargumentwere&azResultthenafterthefunctionreturns
**azResultwillcontainthefollowingdata:
**
**azResult[0]="Name";
**azResult[1]="Age";
**azResult[2]="Alice";
**azResult[3]="43";
**azResult[4]="Bob";
**azResult[5]="28";
**azResult[6]="Cindy";
**azResult[7]="21";
**
**Noticethatthereisanextrarowofdatacontainingthecolumn
**headers.Butthe*nrowreturnvalueisstill3.*ncolumnis
**setto2.Ingeneral,thenumberofvaluesinsertedintoazResult
**willbe ((*nrow) +1)*(*ncolumn).
**
**Afterthecallingfunctionhasfinishedusingtheresult,itshould
**passtheresultdatapointertosqlite_free_table() inorderto
**releasethememorythatwasmalloc-ed.Becauseofthewaythe
**malloc() happens,thecallingfunctionmustnottrytocall
**malloc() directly.Onlysqlite_free_table() isabletorelease
**thememoryproperlyandsafely.
**
**Thereturnvalueofthisroutineisthesameasfromsqlite_exec().
*/
intsqlite_get_table(
sqlite*,/*Anopendatabase*/
constchar*sql,/*SQLtobeexecuted*/
char***resultp,/*Resultwrittentoachar*[]thatthispointsto*/
int*nrow,/*Numberofresultrowswrittenhere*/
int*ncolumn,/*Numberofresultcolumnswrittenhere*/
char**errmsg/*Errormsgwrittenhere*/
);
/*
**Callthisroutinetofreethememorythatsqlite_get_table() allocated.
*/
voidsqlite_free_table(char**result);
/*
**Thefollowingroutinesarewrappersaroundsqlite_exec() and
**sqlite_get_table().Theonlydifferencebetweentheroutinesthat
**followandtheoriginalsisthatthesecondargumenttothe
**routinesthatfollowisreallyaprintf()-styleformat
**stringdescribingtheSQLtobeexecuted.Argumentstotheformat
**stringappearattheendoftheargumentlist.
**
**Alloftheusualprintfformattingoptionsapply.Inaddition,there
**isa"%q"option.%qworkslike%sinthatitsubstitutesanull-terminated
**stringfromtheargumentlist.But%qalsodoublesevery'\''character.
**%qisdesignedforuseinsideastringliteral.Bydoublingeach'\''
**characteritescapesthatcharacterandallowsittobeinsertedinto
**thestring.
**
**Forexample,sosomestringvariablecontainstextasfollows:
**
**char*zText="It's a happy day!";
**
**WecanusethistextinanSQLstatementasfollows:
**
**sqlite_exec_printf(db,"INSERT INTO table VALUES('%q')",
**callback1,0,0,zText);
**
**Becausethe%qformatstringisused,the'\''characterinzText
**isescapedandtheSQLgeneratedisasfollows:
**
**INSERTINTOtable1VALUES('It''sahappyday!')
**
**Thisiscorrect.Hadweused%sinsteadof%q,thegeneratedSQL
**wouldhavelookedlikethis:
**
**INSERTINTOtable1VALUES('It'sahappyday!');
**
**ThissecondexampleisanSQLsyntaxerror.Asageneralruleyou
**shouldalwaysuse%qinsteadof%swheninsertingtextintoastring
**literal.
*/
intsqlite_exec_printf(
sqlite*,/*Anopendatabase*/
constchar*sqlFormat,/*printf-styleformatstringfortheSQL*/
sqlite_callback,/*Callbackfunction*/
void*,/*1stargumenttocallbackfunction*/
char**errmsg,/*Errormsgwrittenhere*/
.../*Argumentstotheformatstring.*/
);
intsqlite_exec_vprintf(
sqlite*,/*Anopendatabase*/
constchar*sqlFormat,/*printf-styleformatstringfortheSQL*/
sqlite_callback,/*Callbackfunction*/
void*,/*1stargumenttocallbackfunction*/
char**errmsg,/*Errormsgwrittenhere*/
va_listap/*Argumentstotheformatstring.*/
);
intsqlite_get_table_printf(
sqlite*,/*Anopendatabase*/
constchar*sqlFormat,/*printf-styleformatstringfortheSQL*/
char***resultp,/*Resultwrittentoachar*[]thatthispointsto*/
int*nrow,/*Numberofresultrowswrittenhere*/
int*ncolumn,/*Numberofresultcolumnswrittenhere*/
char**errmsg,/*Errormsgwrittenhere*/
.../*Argumentstotheformatstring*/
);
intsqlite_get_table_vprintf(
sqlite*,/*Anopendatabase*/
constchar*sqlFormat,/*printf-styleformatstringfortheSQL*/
char***resultp,/*Resultwrittentoachar*[]thatthispointsto*/
int*nrow,/*Numberofresultrowswrittenhere*/
int*ncolumn,/*Numberofresultcolumnswrittenhere*/
char**errmsg,/*Errormsgwrittenhere*/
va_listap/*Argumentstotheformatstring*/
);
char*sqlite_mprintf(constchar*,...);
char*sqlite_vmprintf(constchar*,va_list);
/*
**Windowssystemsshouldcallthisroutinetofreememorythat
**isreturnedintheintheerrmsgparameterofsqlite_open() when
**SQLiteisaDLL.Forsomereason,itdoesnotworktocallfree()
**directly.
*/
voidsqlite_freemem(void*p);
/*
**Windowssystemsneedfunctionstocalltoreturnthesqlite_version
**andsqlite_encodingstrings.
*/
constchar*sqlite_libversion(void);
constchar*sqlite_libencoding(void);
/*
**Apointertothefollowingstructureisusedtocommunicatewith
**theimplementationsofuser-definedfunctions.
*/
typedefstructsqlite_funcsqlite_func;
/*
**Usethefollowingroutinestocreatenewuser-definedfunctions.See
**thedocumentationfordetails.
*/
intsqlite_create_function(
sqlite*,/*Databasewherethenewfunctionisregistered*/
constchar*zName,/*Nameofthenewfunction*/
intnArg,/*Numberofarguments.-1meansanynumber*/
void (*xFunc)(sqlite_func*,int,constchar**),/*Ccodetoimplement*/
void*pUserData/*Availableviathesqlite_user_data() call*/
);
intsqlite_create_aggregate(
sqlite*,/*Databasewherethenewfunctionisregistered*/
constchar*zName,/*Nameofthefunction*/
intnArg,/*Numberofarguments*/
void (*xStep)(sqlite_func*,int,constchar**),/*Calledforeachrow*/
void (*xFinalize)(sqlite_func*),/*Calledoncetogetfinalresult*/
void*pUserData/*Availableviathesqlite_user_data() call*/
);
/*
**Usethefollowingroutinetodefinethedatatypereturnedbya
**user-definedfunction.Thesecondargumentcanbeoneofthe
**constantsSQLITE_NUMERIC,SQLITE_TEXT,orSQLITE_ARGSorit
**canbeanintegergreaterthanorequaltozero.Whenthedatatype
**parameterisnon-negative,thetypeoftheresultwillbethe
**sameasthedatatype-thargument.Ifdatatype==SQLITE_NUMERIC
**thentheresultisalwaysnumeric.Ifdatatype==SQLITE_TEXTthen
**theresultisalwaystext.Ifdatatype==SQLITE_ARGSthentheresult
**isnumericifanyargumentisnumericandistextotherwise.
*/
intsqlite_function_type(
sqlite*db,/*Thedatabasetherethefunctionisregistered*/
constchar*zName,/*Nameofthefunction*/
intdatatype/*Thedatatypeforthisfunction*/
);
#define SQLITE_NUMERIC (-1)
/*#define SQLITE_TEXT (-2) // See below */
#define SQLITE_ARGS (-3)
/*
**SQLiteversion3definesSQLITE_TEXTdifferently.Toallowboth
**version2andversion3tobeincluded,undefinethembothifa
**conflictisseen.DefineSQLITE2_TEXTtobetheversion2value.
*/
#ifdef SQLITE_TEXT
# undef SQLITE_TEXT
#else
# define SQLITE_TEXT (-2)
#endif
#define SQLITE2_TEXT (-2)
/*
**Theuserfunctionimplementationscalloneofthefollowingfourroutines
**inordertoreturntheirresults.Thefirstparametertoeachofthese
**routinesisacopyofthefirstargumenttoxFunc() orxFinialize().
**Thesecondparametertotheseroutinesistheresulttobereturned.
**ANULLcanbepassedasthesecondparametertosqlite_set_result_string()
**inordertoreturnaNULLresult.
**
**The3rdargumentto_stringand_erroristhenumberofcharactersto
**takefromthestring.Ifthisargumentisnegative,thenallcharacters
**uptoandincludingthefirst'\000'areused.
**
**Thesqlite_set_result_string() functionallocatesabuffertoholdthe
**resultandreturnsapointertothisbuffer.Thecallingroutine
** (thatis,theimplmentationofauserfunction) canalterthecontent
**ofthisbufferifdesired.
*/
char*sqlite_set_result_string(sqlite_func*,constchar*,int);
voidsqlite_set_result_int(sqlite_func*,int);
voidsqlite_set_result_double(sqlite_func*,double);
voidsqlite_set_result_error(sqlite_func*,constchar*,int);
/*
**ThepUserDataparametertothesqlite_create_function() and
**sqlite_create_aggregate() routinesusedtoregisteruserfunctions
**isavailabletotheimplementationofthefunctionusingthis
**call.
*/
void*sqlite_user_data(sqlite_func*);
/*
**Aggregatefunctionsusethefollowingroutinetoallocate
**astructureforstoringtheirstate.Thefirsttimethisroutine
**iscalledforaparticularaggregate,anewstructureofsizenBytes
**isallocated,zeroed,andreturned.Onsubsequentcalls (forthe
**sameaggregateinstance) thesamebufferisreturned.Theimplementation
**oftheaggregatecanusethereturnedbuffertoaccumulatedata.
**
**ThebufferallocatedisfreedautomaticallybeSQLite.
*/
void*sqlite_aggregate_context(sqlite_func*,intnBytes);
/*
**ThenextroutinereturnsthenumberofcallstoxStepforaparticular
**aggregatefunctioninstance.ThecurrentcalltoxStepcountssothis
**routinealwaysreturnsatleast1.
*/
intsqlite_aggregate_count(sqlite_func*);
/*
**ThisroutineregistersacallbackwiththeSQLitelibrary.The
**callbackisinvoked (atcompile-time,notatrun-time) foreach
**attempttoaccessacolumnofatableinthedatabase.Thecallback
**returnsSQLITE_OKifaccessisallowed,SQLITE_DENYiftheentire
**SQLstatementshouldbeabortedwithanerrorandSQLITE_IGNORE
**ifthecolumnshouldbetreatedasaNULLvalue.
*/
intsqlite_set_authorizer(
sqlite*,
int (*xAuth)(void*,int,constchar*,constchar*,constchar*,constchar*),
void*pUserData
);
/*
**Thesecondparametertotheaccessauthorizationfunctionabovewill
**beoneofthevaluesbelow.Thesevaluessignifywhatkindofoperation
**istobeauthorized.The3rdand4thparameterstotheauthorization
**functionwillbeparametersorNULLdependingonwhichofthefollowing
**codesisusedasthesecondparameter.The5thparameteristhename
**ofthedatabase ("main","temp",etc.) ifapplicable.The6thparameter
**isthenameoftheinner-mosttriggerorviewthatisresponsiblefor
**theaccessattemptorNULLifthisaccessattemptisdirectlyfrom
**inputSQLcode.
**
**Arg-3Arg-4
*/
#define SQLITE_COPY 0 /* Table Name File Name */
#define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */
#define SQLITE_CREATE_TABLE 2 /* Table Name NULL */
#define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */
#define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */
#define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */
#define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */
#define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */
#define SQLITE_CREATE_VIEW 8 /* View Name NULL */
#define SQLITE_DELETE 9 /* Table Name NULL */
#define SQLITE_DROP_INDEX 10 /* Index Name Table Name */
#define SQLITE_DROP_TABLE 11 /* Table Name NULL */
#define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */
#define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */
#define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */
#define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */
#define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */
#define SQLITE_DROP_VIEW 17 /* View Name NULL */
#define SQLITE_INSERT 18 /* Table Name NULL */
#define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */
#define SQLITE_READ 20 /* Table Name Column Name */
#define SQLITE_SELECT 21 /* NULL NULL */
#define SQLITE_TRANSACTION 22 /* NULL NULL */
#define SQLITE_UPDATE 23 /* Table Name Column Name */
#define SQLITE_ATTACH 24 /* Filename NULL */
#define SQLITE_DETACH 25 /* Database Name NULL */
/*
**Thereturnvalueoftheauthorizationfunctionshouldbeoneofthe
**followingconstants:
*/
/*#define SQLITE_OK 0 // Allow access (This is actually defined above) */
#define SQLITE_DENY 1 /* Abort the SQL statement with an error */
#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */
/*
**Registerafunctionthatiscalledateveryinvocationofsqlite_exec()
**orsqlite_compile().Thisfunctioncanbeused (forexample) togenerate
**alogfileofallSQLexecutedagainstadatabase.
*/
void*sqlite_trace(sqlite*,void(*xTrace)(void*,constchar*),void*);
/***TheCallback-FreeAPI
**
**ThefollowingroutinesimplementanewwaytoaccessSQLitethatdoesnot
**involvetheuseofcallbacks.
**
**Ansqlite_vmisanopaqueobjectthatrepresentsasingleSQLstatement
**thatisreadytobeexecuted.
*/
typedefstructsqlite_vmsqlite_vm;
/*
**ToexecuteanSQLitequerywithouttheuseofcallbacks,youfirsthave
**tocompiletheSQLusingthisroutine.The1stparameter"db"isapointer
**toansqliteobjectobtainedfromsqlite_open().The2ndparameter
**"zSql"isthetextoftheSQLtobecompiled.Theremainingparameters
**arealloutputs.
**
***pzTailismadetopointtothefirstcharacterpasttheendofthefirst
**SQLstatementinzSql.Thisroutineonlycompilesthefirststatement
**inzSql,so*pzTailisleftpointingtowhatremainsuncompiled.
**
***ppVmisleftpointingtoa"virtual machine"thatcanbeusedtoexecute
**thecompiledstatement.Orifthereisanerror,*ppVmmaybesettoNULL.
**IftheinputtextcontainednoSQL (iftheinputisandemptystringor
**acomment) then*ppVmissettoNULL.
**
**Ifanyerrorsaredetectedduringcompilation,anerrormessageiswritten
**intospaceobtainedfrommalloc() and*pzErrMsgismadetopointtothat
**errormessage.Thecallingroutineisresponsibleforfreeingthetext
**ofthismessagewhenithasfinishedwithit.Usesqlite_freemem() to
**freethemessage.pzErrMsgmaybeNULLinwhichcasenoerrormessage
**willbegenerated.
**
**Onsuccess,SQLITE_OKisreturned.Otherwiseanderrorcodeisreturned.
*/
intsqlite_compile(
sqlite*db,/*Theopendatabase*/
constchar*zSql,/*SQLstatementtobecompiled*/
constchar**pzTail,/*OUT:uncompiledtailofzSql*/
sqlite_vm**ppVm,/*OUT:thevirtualmachinetoexecutezSql*/
char**pzErrmsg/*OUT:Errormessage.*/
);
/*
**AfteranSQLstatementhasbeencompiled,itishandedtothisroutine
**tobeexecuted.Thisroutineexecutesthestatementasfarasitcan
**gothenreturns.ThereturnvaluewillbeoneofSQLITE_DONE,
**SQLITE_ERROR,SQLITE_BUSY,SQLITE_ROW,orSQLITE_MISUSE.
**
**SQLITE_DONEmeansthattheexecuteoftheSQLstatementiscomplete
**annoerrorshaveoccurred.sqlite_step() shouldnotbecalledagain
**forthesamevirtualmachine.*pNissettothenumberofcolumnsin
**theresultsetand*pazColNameissettoanarrayofstringsthat
**describethecolumnnamesanddatatypes.Thenameofthei-thcolumn
**is (*pazColName)[i]andthedatatypeofthei-thcolumnis
** (*pazColName)[i+*pN].*pazValueissettoNULL.
**
**SQLITE_ERRORmeansthatthevirtualmachineencounteredarun-time
**error.sqlite_step() shouldnotbecalledagainforthesame
**virtualmachine.*pNissetto0and*pazColNameand*pazValueareset
**toNULL.Usesqlite_finalize() toobtainthespecificerrorcode
**andtheerrormessagetextfortheerror.
**
**SQLITE_BUSYmeansthatanattempttoopenthedatabasefailedbecause
**anotherthreadorprocessisholdingalock.Thecallingroutine
**cantryagaintoopenthedatabasebycallingsqlite_step() again.
**ThereturncodewillonlybeSQLITE_BUSYifnobusyhandlerisregistered
**usingthesqlite_busy_handler() orsqlite_busy_timeout() routines.If
**abusyhandlercallbackhasbeenregisteredbutreturns0,thenthis
**routinewillreturnSQLITE_ERRORandsqltie_finalize() willreturn
**SQLITE_BUSYwhenitiscalled.
**
**SQLITE_ROWmeansthatasinglerowoftheresultisnowavailable.
**Thedataiscontainedin*pazValue.Thevalueofthei-thcolumnis
** (*azValue)[i].*pNand*pazColNamearesetasdescribedinSQLITE_DONE.
**Invokesqlite_step() againtoadvancetothenextrow.
**
**SQLITE_MISUSEisreturnedifsqlite_step() iscalledincorrectly.
**Forexample,ifyoucallsqlite_step() afterthevirtualmachine
**hashalted (afterapriorcalltosqlite_step() hasreturnedSQLITE_DONE)
**orifyoucallsqlite_step() withanincorrectlyinitializedvirtual
**machineoravirtualmachinethathasbeendeletedorthatisassociated
**withansqlitestructurethathasbeenclosed.
*/
intsqlite_step(
sqlite_vm*pVm,/*Thevirtualmachinetoexecute*/
int*pN,/*OUT:Numberofcolumnsinresult*/
constchar***pazValue,/*OUT:Columndata*/
constchar***pazColName/*OUT:Columnnamesanddatatypes*/
);
/*
**Thisroutineiscalledtodeleteavirtualmachineafterithasfinished
**executing.Thereturnvalueistheresultcode.SQLITE_OKisreturned
**ifthestatementexecutedsuccessfullyandsomeothervalueisreturnedif
**therewasanykindoferror.IfanerroroccurredandpzErrMsgisnot
**NULL,thenanerrormessageiswrittenintomemoryobtainedfrommalloc()
**and*pzErrMsgismadetopointtothaterrormessage.Thecallingroutine
**shouldusesqlite_freemem() todeletethismessagewhenithasfinished
**withit.
**
**Thisroutinecanbecalledatanypointduringtheexecutionofthe
**virtualmachine.Ifthevirtualmachinehasnotcompletedexecution
**whenthisroutineiscalled,thatislikeencounteringanerroror
**aninterrupt. (Seesqlite_interrupt().) Incompleteupdatesmaybe
**rolledbackandtransactionscancelled,dependingonthecircumstances,
**andtheresultcodereturnedwillbeSQLITE_ABORT.
*/
intsqlite_finalize(sqlite_vm*,char**pzErrMsg);
/*
**Thisroutinedeletesthevirtualmachine,writesanyerrormessageto
***pzErrMsgandreturnsanSQLitereturncodeinthesamewayasthe
**sqlite_finalize() function.
**
**Additionally,ifppVmisnotNULL,*ppVmisleftpointingtoanewvirtual
**machineloadedwiththecompiledversionoftheoriginalqueryreadyfor
**execution.
**
**Ifsqlite_reset() returnsSQLITE_SCHEMA,then*ppVmissettoNULL.
**
*******THISISANEXPERIMENTALAPIANDISSUBJECTTOCHANGE******
*/
intsqlite_reset(sqlite_vm*,char**pzErrMsg);
/*
**IftheSQLthatwashandedtosqlite_compilecontainsvariablesthat
**arerepresetedintheSQLtextbyaquestionmark ('?').Thisroutine
**isusedtoassignvaluestothosevariables.
**
**Thefirstparameterisavirtualmachineobtainedfromsqlite_compile().
**The2nd"idx"parameterdetermineswhichvariableintheSQLstatement
**tobindthevalueto.Theleftmost'?'is1.The3rdparameteris
**thevaluetoassigntothatvariable.The4thparameteristhenumber
**ofbytesinthevalue,includingtheterminating \000forstrings.
**Finally,the5th"copy"parameterisTRUEifSQLiteshouldmakeits
**ownprivatecopyofthisvalue,orfalseifthespacethatthe3rd
**parameterpointstowillbeunchangingandcanbeuseddirectlyby
**SQLite.
**
**UnboundvariablesaretreatedashavingavalueofNULL.Toexplicitly
**setavariabletoNULL,callthisroutinewiththe3rdparameterasa
**NULLpointer.
**
**Ifthe4th"len"parameteris-1,thenstrlen() isusedtofindthe
**length.
**
**Thisroutinecanonlybecalledimmediatelyaftersqlite_compile()
**orsqlite_reset() andbeforeanycallstosqlite_step().
**
*******THISISANEXPERIMENTALAPIANDISSUBJECTTOCHANGE******
*/
intsqlite_bind(sqlite_vm*,intidx,constchar*value,intlen,intcopy);
/*
**Thisroutineconfiguresacallbackfunction-theprogresscallback-that
**isinvokedperiodicallyduringlongrunningcallstosqlite_exec(),
**sqlite_step() andsqlite_get_table().AnexampleuseforthisAPIistokeep
**aGUIupdatedduringalargequery.
**
**TheprogresscallbackisinvokedonceforeveryNvirtualmachineopcodes,
**whereNisthesecondargumenttothisfunction.Theprogresscallback
**itselfisidentifiedbythethirdargumenttothisfunction.Thefourth
**argumenttothisfunctionisavoidpointerpassedtotheprogresscallback
**functioneachtimeitisinvoked.
**
**Ifacalltosqlite_exec(),sqlite_step() orsqlite_get_table() results
**inlessthanNopcodesbeingexecuted,thentheprogresscallbackisnot
**invoked.
**
**Callingthisroutineoverwritesanypreviouslyinstalledprogresscallback.
**Toremovetheprogresscallbackaltogether,passNULLasthethird
**argumenttothisfunction.
**
**Iftheprogresscallbackreturnsaresultotherthan0,thenthecurrent
**queryisimmediatelyterminatedandanydatabasechangesrolledback.Ifthe
**querywaspartofalargertransaction,thenthetransactionisnotrolled
**backandremainsactive.Thesqlite_exec() callreturnsSQLITE_ABORT.
**
*******THISISANEXPERIMENTALAPIANDISSUBJECTTOCHANGE******
*/
voidsqlite_progress_handler(sqlite*,int,int(*)(void*),void*);
/*
**Registeracallbackfunctiontobeinvokedwheneveranewtransaction
**iscommitted.ThepArgargumentispassedthroughtothecallback.
**callback.Ifthecallbackfunctionreturnsnon-zero,thenthecommit
**isconvertedintoarollback.
**
**Ifanotherfunctionwaspreviouslyregistered,itspArgvalueisreturned.
**OtherwiseNULLisreturned.
**
**RegisteringaNULLfunctiondisablesthecallback.
**
*******THISISANEXPERIMENTALAPIANDISSUBJECTTOCHANGE******
*/
void*sqlite_commit_hook(sqlite*,int(*)(void*),void*);
/*
**OpenanencryptedSQLitedatabase.IfpKey==0ornKey==0,thisroutine
**isthesameassqlite_open().
**
**ThecodetoimplementthisAPIisnotavailableinthepublicrelease
**ofSQLite.
*/
sqlite*sqlite_open_encrypted(
constchar*zFilename,/*Nameoftheencrypteddatabase*/
constvoid*pKey,/*Pointertothekey*/
intnKey,/*Numberofbytesinthekey*/
int*pErrcode,/*Writeerrorcodehere*/
char**pzErrmsg/*Writeerrormessagehere*/
);
/*
**Changethekeyonanopendatabase.Ifthecurrentdatabaseisnot
**encrypted,thisroutinewillencryptit.IfpNew==0ornNew==0,the
**databaseisdecrypted.
**
**ThecodetoimplementthisAPIisnotavailableinthepublicrelease
**ofSQLite.
*/
intsqlite_rekey(
sqlite*db,/*Databasetoberekeyed*/
constvoid*pKey,intnKey/*Thenewkey*/
);
/*
**Encodeabinarybuffer"in"ofsizenbytessothatitcontains
**noinstancesofcharacters'\''or'\000'.Theoutputis
**null-terminatedandcanbeusedasastringvalueinanINSERT
**orUPDATEstatement.Usesqlite_decode_binary() toconvertthe
**stringbackintoitsoriginalbinary.
**
**Theresultiswrittenintoapreallocatedoutputbuffer"out".
**"out"mustbeabletoholdatleast2+(257*n)/254bytes.
**Inotherwords,theoutputwillbeexpandedbyasmuchas3
**bytesforevery254bytesofinputplus2bytesoffixedoverhead.
** (Thisisapproximately2+1.0118*norabouta1.2%sizeincrease.)
**
**Thereturnvalueisthenumberofcharactersintheencoded
**string,excludingthe"\000"terminator.
**
**Ifout==NULLthennooutputisgeneratedbuttheroutinestillreturns
**thenumberofcharactersthatwouldhavebeengeneratedifouthad
**notbeenNULL.
*/
intsqlite_encode_binary(constunsignedchar*in,intn,unsignedchar*out);
/*
**Decodethestring"in"intobinarydataandwriteitinto"out".
**Thisroutinereversestheencodingcreatedbysqlite_encode_binary().
**Theoutputwillalwaysbeafewbyteslessthantheinput.Thenumber
**ofbytesofoutputisreturned.Iftheinputisnotawell-formed
**encoding,-1isreturned.
**
**The"in"and"out"parametersmaypointtothesamebufferinorder
**todecodeastringinplace.
*/
intsqlite_decode_binary(constunsignedchar*in,unsignedchar*out);
#ifdef __cplusplus
}/*Endofthe'extern"C"'block*/
#endif
#endif /* _SQLITE_H_ */