Fossil SCM

Update the built-in SQLite to the first 3.19.0 beta.

drh 2017-05-11 21:09 trunk
Commit d6a0debd8c986dc25a71357f1e7b940179a41e38153097788b10cdeba3fd43d1
2 files changed +167 -54 +19 -7
+167 -54
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,11 +398,11 @@
398398
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
399399
** [sqlite_version()] and [sqlite_source_id()].
400400
*/
401401
#define SQLITE_VERSION "3.19.0"
402402
#define SQLITE_VERSION_NUMBER 3019000
403
-#define SQLITE_SOURCE_ID "2017-05-10 16:12:00 92ab1f7257d2866c69eaaf4cf85990677b911ef425e9c5a36a96978cccfb551c"
403
+#define SQLITE_SOURCE_ID "2017-05-11 19:09:19 339df63f4064f3b9c8d4e8b82e72d00b49d9406bc350b14809a4caf7ddc4b736"
404404
405405
/*
406406
** CAPI3REF: Run-Time Library Version Numbers
407407
** KEYWORDS: sqlite3_version sqlite3_sourceid
408408
**
@@ -2948,10 +2948,11 @@
29482948
SQLITE_API void sqlite3_randomness(int N, void *P);
29492949
29502950
/*
29512951
** CAPI3REF: Compile-Time Authorization Callbacks
29522952
** METHOD: sqlite3
2953
+** KEYWORDS: {authorizer callback}
29532954
**
29542955
** ^This routine registers an authorizer callback with a particular
29552956
** [database connection], supplied in the first argument.
29562957
** ^The authorizer callback is invoked as SQL statements are being compiled
29572958
** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
@@ -2975,20 +2976,26 @@
29752976
**
29762977
** ^The first parameter to the authorizer callback is a copy of the third
29772978
** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
29782979
** to the callback is an integer [SQLITE_COPY | action code] that specifies
29792980
** the particular action to be authorized. ^The third through sixth parameters
2980
-** to the callback are zero-terminated strings that contain additional
2981
-** details about the action to be authorized.
2981
+** to the callback are either NULL pointers or zero-terminated strings
2982
+** that contain additional details about the action to be authorized.
2983
+** Applications must always be prepared to encounter a NULL pointer in any
2984
+** of the third through the sixth parameters of the authorization callback.
29822985
**
29832986
** ^If the action code is [SQLITE_READ]
29842987
** and the callback returns [SQLITE_IGNORE] then the
29852988
** [prepared statement] statement is constructed to substitute
29862989
** a NULL value in place of the table column that would have
29872990
** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE]
29882991
** return can be used to deny an untrusted user access to individual
29892992
** columns of a table.
2993
+** ^When a table is referenced by a [SELECT] but no column values are
2994
+** extracted from that table (for example in a query like
2995
+** "SELECT count(*) FROM tab") then the [SQLITE_READ] authorizer callback
2996
+** is invoked once for that table with a column name that is an empty string.
29902997
** ^If the action code is [SQLITE_DELETE] and the callback returns
29912998
** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the
29922999
** [truncate optimization] is disabled and all rows are deleted individually.
29933000
**
29943001
** An authorizer is used when [sqlite3_prepare | preparing]
@@ -5031,14 +5038,15 @@
50315038
** metadata associated with the pattern string.
50325039
** Then as long as the pattern string remains the same,
50335040
** the compiled regular expression can be reused on multiple
50345041
** invocations of the same function.
50355042
**
5036
-** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
5037
-** associated by the sqlite3_set_auxdata() function with the Nth argument
5038
-** value to the application-defined function. ^If there is no metadata
5039
-** associated with the function argument, this sqlite3_get_auxdata() interface
5043
+** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata
5044
+** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument
5045
+** value to the application-defined function. ^N is zero for the left-most
5046
+** function argument. ^If there is no metadata
5047
+** associated with the function argument, the sqlite3_get_auxdata(C,N) interface
50405048
** returns a NULL pointer.
50415049
**
50425050
** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
50435051
** argument of the application-defined function. ^Subsequent
50445052
** calls to sqlite3_get_auxdata(C,N) return P from the most recent
@@ -5064,10 +5072,14 @@
50645072
** sqlite3_set_auxdata() has been called.
50655073
**
50665074
** ^(In practice, metadata is preserved between function calls for
50675075
** function parameters that are compile-time constants, including literal
50685076
** values and [parameters] and expressions composed from the same.)^
5077
+**
5078
+** The value of the N parameter to these interfaces should be non-negative.
5079
+** Future enhancements may make use of negative N values to define new
5080
+** kinds of function caching behavior.
50695081
**
50705082
** These routines must be called from the same thread in which
50715083
** the SQL function is running.
50725084
*/
50735085
SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
@@ -18207,15 +18219,15 @@
1820718219
** of this structure. All such structures associated with a single VM
1820818220
** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed
1820918221
** when the VM is halted (if not before).
1821018222
*/
1821118223
struct AuxData {
18212
- int iOp; /* Instruction number of OP_Function opcode */
18213
- int iArg; /* Index of function argument. */
18224
+ int iAuxOp; /* Instruction number of OP_Function opcode */
18225
+ int iAuxArg; /* Index of function argument. */
1821418226
void *pAux; /* Aux data pointer */
18215
- void (*xDelete)(void *); /* Destructor for the aux data */
18216
- AuxData *pNext; /* Next element in list */
18227
+ void (*xDeleteAux)(void*); /* Destructor for the aux data */
18228
+ AuxData *pNextAux; /* Next element in list */
1821718229
};
1821818230
1821918231
/*
1822018232
** The "context" argument for an installable function. A pointer to an
1822118233
** instance of this structure is the first argument to the routines used
@@ -74368,20 +74380,22 @@
7436874380
*/
7436974381
SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(sqlite3 *db, AuxData **pp, int iOp, int mask){
7437074382
while( *pp ){
7437174383
AuxData *pAux = *pp;
7437274384
if( (iOp<0)
74373
- || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & MASKBIT32(pAux->iArg))))
74385
+ || (pAux->iAuxOp==iOp
74386
+ && pAux->iAuxArg>=0
74387
+ && (pAux->iAuxArg>31 || !(mask & MASKBIT32(pAux->iAuxArg))))
7437474388
){
74375
- testcase( pAux->iArg==31 );
74376
- if( pAux->xDelete ){
74377
- pAux->xDelete(pAux->pAux);
74389
+ testcase( pAux->iAuxArg==31 );
74390
+ if( pAux->xDeleteAux ){
74391
+ pAux->xDeleteAux(pAux->pAux);
7437874392
}
74379
- *pp = pAux->pNext;
74393
+ *pp = pAux->pNextAux;
7438074394
sqlite3DbFree(db, pAux);
7438174395
}else{
74382
- pp= &pAux->pNext;
74396
+ pp= &pAux->pNextAux;
7438374397
}
7438474398
}
7438574399
}
7438674400
7438774401
/*
@@ -76878,10 +76892,16 @@
7687876892
}
7687976893
7688076894
/*
7688176895
** Return the auxiliary data pointer, if any, for the iArg'th argument to
7688276896
** the user-function defined by pCtx.
76897
+**
76898
+** The left-most argument is 0.
76899
+**
76900
+** Undocumented behavior: If iArg is negative then access a cache of
76901
+** auxiliary data pointers that is available to all functions within a
76902
+** single prepared statement. The iArg values must match.
7688376903
*/
7688476904
SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
7688576905
AuxData *pAuxData;
7688676906
7688776907
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
@@ -76888,21 +76908,28 @@
7688876908
#if SQLITE_ENABLE_STAT3_OR_STAT4
7688976909
if( pCtx->pVdbe==0 ) return 0;
7689076910
#else
7689176911
assert( pCtx->pVdbe!=0 );
7689276912
#endif
76893
- for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
76894
- if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
76913
+ for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){
76914
+ if( pAuxData->iAuxArg==iArg && (pAuxData->iAuxOp==pCtx->iOp || iArg<0) ){
76915
+ return pAuxData->pAux;
76916
+ }
7689576917
}
76896
-
76897
- return (pAuxData ? pAuxData->pAux : 0);
76918
+ return 0;
7689876919
}
7689976920
7690076921
/*
7690176922
** Set the auxiliary data pointer and delete function, for the iArg'th
7690276923
** argument to the user-function defined by pCtx. Any previous value is
7690376924
** deleted by calling the delete function specified when it was set.
76925
+**
76926
+** The left-most argument is 0.
76927
+**
76928
+** Undocumented behavior: If iArg is negative then make the data available
76929
+** to all functions within the current prepared statement using iArg as an
76930
+** access code.
7690476931
*/
7690576932
SQLITE_API void sqlite3_set_auxdata(
7690676933
sqlite3_context *pCtx,
7690776934
int iArg,
7690876935
void *pAux,
@@ -76910,37 +76937,38 @@
7691076937
){
7691176938
AuxData *pAuxData;
7691276939
Vdbe *pVdbe = pCtx->pVdbe;
7691376940
7691476941
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
76915
- if( iArg<0 ) goto failed;
7691676942
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
7691776943
if( pVdbe==0 ) goto failed;
7691876944
#else
7691976945
assert( pVdbe!=0 );
7692076946
#endif
7692176947
76922
- for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
76923
- if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
76948
+ for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){
76949
+ if( pAuxData->iAuxArg==iArg && (pAuxData->iAuxOp==pCtx->iOp || iArg<0) ){
76950
+ break;
76951
+ }
7692476952
}
7692576953
if( pAuxData==0 ){
7692676954
pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));
7692776955
if( !pAuxData ) goto failed;
76928
- pAuxData->iOp = pCtx->iOp;
76929
- pAuxData->iArg = iArg;
76930
- pAuxData->pNext = pVdbe->pAuxData;
76956
+ pAuxData->iAuxOp = pCtx->iOp;
76957
+ pAuxData->iAuxArg = iArg;
76958
+ pAuxData->pNextAux = pVdbe->pAuxData;
7693176959
pVdbe->pAuxData = pAuxData;
7693276960
if( pCtx->fErrorOrAux==0 ){
7693376961
pCtx->isError = 0;
7693476962
pCtx->fErrorOrAux = 1;
7693576963
}
76936
- }else if( pAuxData->xDelete ){
76937
- pAuxData->xDelete(pAuxData->pAux);
76964
+ }else if( pAuxData->xDeleteAux ){
76965
+ pAuxData->xDeleteAux(pAuxData->pAux);
7693876966
}
7693976967
7694076968
pAuxData->pAux = pAux;
76941
- pAuxData->xDelete = xDelete;
76969
+ pAuxData->xDeleteAux = xDelete;
7694276970
return;
7694376971
7694476972
failed:
7694576973
if( xDelete ){
7694676974
xDelete(pAux);
@@ -99595,10 +99623,22 @@
9959599623
}
9959699624
9959799625
if( db->xAuth==0 ){
9959899626
return SQLITE_OK;
9959999627
}
99628
+
99629
+ /* EVIDENCE-OF: R-43249-19882 The third through sixth parameters to the
99630
+ ** callback are either NULL pointers or zero-terminated strings that
99631
+ ** contain additional details about the action to be authorized.
99632
+ **
99633
+ ** The following testcase() macros show that any of the 3rd through 6th
99634
+ ** parameters can be either NULL or a string. */
99635
+ testcase( zArg1==0 );
99636
+ testcase( zArg2==0 );
99637
+ testcase( zArg3==0 );
99638
+ testcase( pParse->zAuthContext==0 );
99639
+
9960099640
rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext
9960199641
#ifdef SQLITE_USER_AUTHENTICATION
9960299642
,db->auth.zAuthUser
9960399643
#endif
9960499644
);
@@ -104930,11 +104970,18 @@
104930104970
104931104971
#ifndef SQLITE_OMIT_TRUNCATE_OPTIMIZATION
104932104972
/* Special case: A DELETE without a WHERE clause deletes everything.
104933104973
** It is easier just to erase the whole table. Prior to version 3.6.5,
104934104974
** this optimization caused the row change count (the value returned by
104935
- ** API function sqlite3_count_changes) to be set incorrectly. */
104975
+ ** API function sqlite3_count_changes) to be set incorrectly.
104976
+ **
104977
+ ** The "rcauth==SQLITE_OK" terms is the
104978
+ ** IMPLEMENATION-OF: R-17228-37124 If the action code is SQLITE_DELETE and
104979
+ ** the callback returns SQLITE_IGNORE then the DELETE operation proceeds but
104980
+ ** the truncate optimization is disabled and all rows are deleted
104981
+ ** individually.
104982
+ */
104936104983
if( rcauth==SQLITE_OK
104937104984
&& pWhere==0
104938104985
&& !bComplex
104939104986
&& !IsVirtual(pTab)
104940104987
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
@@ -121585,19 +121632,27 @@
121585121632
for(i=0; i<pTabList->nSrc; i++){
121586121633
struct SrcList_item *pItem = &pTabList->a[i];
121587121634
SelectDest dest;
121588121635
Select *pSub;
121589121636
121590
- /* Issue SQLITE_READ authorizations with a NULL column name for any tables that
121637
+ /* Issue SQLITE_READ authorizations with a fake column name for any tables that
121591121638
** are referenced but from which no values are extracted. Examples of where these
121592121639
** kinds of null SQLITE_READ authorizations would occur:
121593121640
**
121594
- ** SELECT count(*) FROM t1; -- SQLITE_READ t1 null
121595
- ** SELECT t1.* FROM t1, t2; -- SQLITE_READ t2 null
121641
+ ** SELECT count(*) FROM t1; -- SQLITE_READ t1.""
121642
+ ** SELECT t1.* FROM t1, t2; -- SQLITE_READ t2.""
121643
+ **
121644
+ ** The fake column name is an empty string. It is possible for a table to
121645
+ ** have a column named by the empty string, in which case there is no way to
121646
+ ** distinguish between an unreferenced table and an actual reference to the
121647
+ ** "" column. The original design was for the fake column name to be a NULL,
121648
+ ** which would be unambiguous. But legacy authorization callbacks might
121649
+ ** assume the column name is non-NULL and segfault. The use of an empty string
121650
+ ** for the fake column name seems safer.
121596121651
*/
121597121652
if( pItem->colUsed==0 ){
121598
- sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, pItem->zDatabase, 0);
121653
+ sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, "", pItem->zDatabase);
121599121654
}
121600121655
121601121656
#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
121602121657
/* Generate code for all sub-queries in the FROM clause
121603121658
*/
@@ -179491,10 +179546,11 @@
179491179546
const char *zJson; /* Original JSON string */
179492179547
u32 *aUp; /* Index of parent of each node */
179493179548
u8 oom; /* Set to true if out of memory */
179494179549
u8 nErr; /* Number of errors seen */
179495179550
u16 iDepth; /* Nesting depth */
179551
+ int nJson; /* Length of the zJson string in bytes */
179496179552
};
179497179553
179498179554
/*
179499179555
** Maximum nesting depth of JSON for this implementation.
179500179556
**
@@ -179732,10 +179788,18 @@
179732179788
pParse->nNode = 0;
179733179789
pParse->nAlloc = 0;
179734179790
sqlite3_free(pParse->aUp);
179735179791
pParse->aUp = 0;
179736179792
}
179793
+
179794
+/*
179795
+** Free a JsonParse object that was obtained from sqlite3_malloc().
179796
+*/
179797
+static void jsonParseFree(JsonParse *pParse){
179798
+ jsonParseReset(pParse);
179799
+ sqlite3_free(pParse);
179800
+}
179737179801
179738179802
/*
179739179803
** Convert the JsonNode pNode into a pure JSON string and
179740179804
** append to pOut. Subsubstructure is also included. Return
179741179805
** the number of JsonNode objects that are encoded.
@@ -180283,10 +180347,53 @@
180283180347
return SQLITE_NOMEM;
180284180348
}
180285180349
jsonParseFillInParentage(pParse, 0, 0);
180286180350
return SQLITE_OK;
180287180351
}
180352
+
180353
+/*
180354
+** Magic number used for the JSON parse cache in sqlite3_get_auxdata()
180355
+*/
180356
+#define JSON_CACHE_ID (-429938)
180357
+
180358
+/*
180359
+** Obtain a complete parse of the JSON found in the first argument
180360
+** of the argv array. Use the sqlite3_get_auxdata() cache for this
180361
+** parse if it is available. If the cache is not available or if it
180362
+** is no longer valid, parse the JSON again and return the new parse,
180363
+** and also register the new parse so that it will be available for
180364
+** future sqlite3_get_auxdata() calls.
180365
+*/
180366
+static JsonParse *jsonParseCached(
180367
+ sqlite3_context *pCtx,
180368
+ sqlite3_value **argv
180369
+){
180370
+ const char *zJson = (const char*)sqlite3_value_text(argv[0]);
180371
+ int nJson = sqlite3_value_bytes(argv[0]);
180372
+ JsonParse *p;
180373
+ if( zJson==0 ) return 0;
180374
+ p = (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID);
180375
+ if( p && p->nJson==nJson && memcmp(p->zJson,zJson,nJson)==0 ){
180376
+ p->nErr = 0;
180377
+ return p; /* The cached entry matches, so return it */
180378
+ }
180379
+ p = sqlite3_malloc( sizeof(*p) + nJson + 1 );
180380
+ if( p==0 ){
180381
+ sqlite3_result_error_nomem(pCtx);
180382
+ return 0;
180383
+ }
180384
+ memset(p, 0, sizeof(*p));
180385
+ p->zJson = (char*)&p[1];
180386
+ memcpy((char*)p->zJson, zJson, nJson+1);
180387
+ if( jsonParse(p, pCtx, p->zJson) ){
180388
+ sqlite3_free(p);
180389
+ return 0;
180390
+ }
180391
+ p->nJson = nJson;
180392
+ sqlite3_set_auxdata(pCtx, JSON_CACHE_ID, p, (void(*)(void*))jsonParseFree);
180393
+ return (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID);
180394
+}
180288180395
180289180396
/*
180290180397
** Compare the OBJECT label at pNode against zKey,nKey. Return true on
180291180398
** a match.
180292180399
*/
@@ -180649,33 +180756,34 @@
180649180756
static void jsonArrayLengthFunc(
180650180757
sqlite3_context *ctx,
180651180758
int argc,
180652180759
sqlite3_value **argv
180653180760
){
180654
- JsonParse x; /* The parse */
180761
+ JsonParse *p; /* The parse */
180655180762
sqlite3_int64 n = 0;
180656180763
u32 i;
180657180764
JsonNode *pNode;
180658180765
180659
- if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;
180660
- assert( x.nNode );
180766
+ p = jsonParseCached(ctx, argv);
180767
+ if( p==0 ) return;
180768
+ assert( p->nNode );
180661180769
if( argc==2 ){
180662180770
const char *zPath = (const char*)sqlite3_value_text(argv[1]);
180663
- pNode = jsonLookup(&x, zPath, 0, ctx);
180771
+ pNode = jsonLookup(p, zPath, 0, ctx);
180664180772
}else{
180665
- pNode = x.aNode;
180773
+ pNode = p->aNode;
180666180774
}
180667180775
if( pNode==0 ){
180668
- x.nErr = 1;
180669
- }else if( pNode->eType==JSON_ARRAY ){
180776
+ return;
180777
+ }
180778
+ if( pNode->eType==JSON_ARRAY ){
180670180779
assert( (pNode->jnFlags & JNODE_APPEND)==0 );
180671180780
for(i=1; i<=pNode->n; n++){
180672180781
i += jsonNodeSize(&pNode[i]);
180673180782
}
180674180783
}
180675
- if( x.nErr==0 ) sqlite3_result_int64(ctx, n);
180676
- jsonParseReset(&x);
180784
+ sqlite3_result_int64(ctx, n);
180677180785
}
180678180786
180679180787
/*
180680180788
** json_extract(JSON, PATH, ...)
180681180789
**
@@ -180687,24 +180795,25 @@
180687180795
static void jsonExtractFunc(
180688180796
sqlite3_context *ctx,
180689180797
int argc,
180690180798
sqlite3_value **argv
180691180799
){
180692
- JsonParse x; /* The parse */
180800
+ JsonParse *p; /* The parse */
180693180801
JsonNode *pNode;
180694180802
const char *zPath;
180695180803
JsonString jx;
180696180804
int i;
180697180805
180698180806
if( argc<2 ) return;
180699
- if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;
180807
+ p = jsonParseCached(ctx, argv);
180808
+ if( p==0 ) return;
180700180809
jsonInit(&jx, ctx);
180701180810
jsonAppendChar(&jx, '[');
180702180811
for(i=1; i<argc; i++){
180703180812
zPath = (const char*)sqlite3_value_text(argv[i]);
180704
- pNode = jsonLookup(&x, zPath, 0, ctx);
180705
- if( x.nErr ) break;
180813
+ pNode = jsonLookup(p, zPath, 0, ctx);
180814
+ if( p->nErr ) break;
180706180815
if( argc>2 ){
180707180816
jsonAppendSeparator(&jx);
180708180817
if( pNode ){
180709180818
jsonRenderNode(pNode, &jx, 0);
180710180819
}else{
@@ -180718,11 +180827,10 @@
180718180827
jsonAppendChar(&jx, ']');
180719180828
jsonResult(&jx);
180720180829
sqlite3_result_subtype(ctx, JSON_SUBTYPE);
180721180830
}
180722180831
jsonReset(&jx);
180723
- jsonParseReset(&x);
180724180832
}
180725180833
180726180834
/* This is the RFC 7396 MergePatch algorithm.
180727180835
*/
180728180836
static JsonNode *jsonMergePatch(
@@ -193984,10 +194092,11 @@
193984194092
Fts5StructureSegment *pSeg; /* Output segment */
193985194093
Fts5Buffer term;
193986194094
int bOldest; /* True if the output segment is the oldest */
193987194095
int eDetail = p->pConfig->eDetail;
193988194096
const int flags = FTS5INDEX_QUERY_NOOUTPUT;
194097
+ int bTermWritten = 0; /* True if current term already output */
193989194098
193990194099
assert( iLvl<pStruct->nLevel );
193991194100
assert( pLvl->nMerge<=pLvl->nSeg );
193992194101
193993194102
memset(&writer, 0, sizeof(Fts5SegWriter));
@@ -194037,22 +194146,26 @@
194037194146
Fts5SegIter *pSegIter = &pIter->aSeg[ pIter->aFirst[1].iFirst ];
194038194147
int nPos; /* position-list size field value */
194039194148
int nTerm;
194040194149
const u8 *pTerm;
194041194150
194042
- /* Check for key annihilation. */
194043
- if( pSegIter->nPos==0 && (bOldest || pSegIter->bDel==0) ) continue;
194044
-
194045194151
pTerm = fts5MultiIterTerm(pIter, &nTerm);
194046194152
if( nTerm!=term.n || memcmp(pTerm, term.p, nTerm) ){
194047194153
if( pnRem && writer.nLeafWritten>nRem ){
194048194154
break;
194049194155
}
194156
+ fts5BufferSet(&p->rc, &term, nTerm, pTerm);
194157
+ bTermWritten =0;
194158
+ }
194050194159
194160
+ /* Check for key annihilation. */
194161
+ if( pSegIter->nPos==0 && (bOldest || pSegIter->bDel==0) ) continue;
194162
+
194163
+ if( p->rc==SQLITE_OK && bTermWritten==0 ){
194051194164
/* This is a new term. Append a term to the output segment. */
194052194165
fts5WriteAppendTerm(p, &writer, nTerm, pTerm);
194053
- fts5BufferSet(&p->rc, &term, nTerm, pTerm);
194166
+ bTermWritten = 1;
194054194167
}
194055194168
194056194169
/* Append the rowid to the output */
194057194170
/* WRITEPOSLISTSIZE */
194058194171
fts5WriteAppendRowid(p, &writer, fts5MultiIterRowid(pIter));
@@ -198908,11 +199021,11 @@
198908199021
int nArg, /* Number of args */
198909199022
sqlite3_value **apUnused /* Function arguments */
198910199023
){
198911199024
assert( nArg==0 );
198912199025
UNUSED_PARAM2(nArg, apUnused);
198913
- sqlite3_result_text(pCtx, "fts5: 2017-05-10 16:12:00 92ab1f7257d2866c69eaaf4cf85990677b911ef425e9c5a36a96978cccfb551c", -1, SQLITE_TRANSIENT);
199026
+ sqlite3_result_text(pCtx, "fts5: 2017-05-11 19:09:19 339df63f4064f3b9c8d4e8b82e72d00b49d9406bc350b14809a4caf7ddc4b736", -1, SQLITE_TRANSIENT);
198914199027
}
198915199028
198916199029
static int fts5Init(sqlite3 *db){
198917199030
static const sqlite3_module fts5Mod = {
198918199031
/* iVersion */ 2,
198919199032
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,11 +398,11 @@
398 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
399 ** [sqlite_version()] and [sqlite_source_id()].
400 */
401 #define SQLITE_VERSION "3.19.0"
402 #define SQLITE_VERSION_NUMBER 3019000
403 #define SQLITE_SOURCE_ID "2017-05-10 16:12:00 92ab1f7257d2866c69eaaf4cf85990677b911ef425e9c5a36a96978cccfb551c"
404
405 /*
406 ** CAPI3REF: Run-Time Library Version Numbers
407 ** KEYWORDS: sqlite3_version sqlite3_sourceid
408 **
@@ -2948,10 +2948,11 @@
2948 SQLITE_API void sqlite3_randomness(int N, void *P);
2949
2950 /*
2951 ** CAPI3REF: Compile-Time Authorization Callbacks
2952 ** METHOD: sqlite3
 
2953 **
2954 ** ^This routine registers an authorizer callback with a particular
2955 ** [database connection], supplied in the first argument.
2956 ** ^The authorizer callback is invoked as SQL statements are being compiled
2957 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
@@ -2975,20 +2976,26 @@
2975 **
2976 ** ^The first parameter to the authorizer callback is a copy of the third
2977 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
2978 ** to the callback is an integer [SQLITE_COPY | action code] that specifies
2979 ** the particular action to be authorized. ^The third through sixth parameters
2980 ** to the callback are zero-terminated strings that contain additional
2981 ** details about the action to be authorized.
 
 
2982 **
2983 ** ^If the action code is [SQLITE_READ]
2984 ** and the callback returns [SQLITE_IGNORE] then the
2985 ** [prepared statement] statement is constructed to substitute
2986 ** a NULL value in place of the table column that would have
2987 ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE]
2988 ** return can be used to deny an untrusted user access to individual
2989 ** columns of a table.
 
 
 
 
2990 ** ^If the action code is [SQLITE_DELETE] and the callback returns
2991 ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the
2992 ** [truncate optimization] is disabled and all rows are deleted individually.
2993 **
2994 ** An authorizer is used when [sqlite3_prepare | preparing]
@@ -5031,14 +5038,15 @@
5031 ** metadata associated with the pattern string.
5032 ** Then as long as the pattern string remains the same,
5033 ** the compiled regular expression can be reused on multiple
5034 ** invocations of the same function.
5035 **
5036 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
5037 ** associated by the sqlite3_set_auxdata() function with the Nth argument
5038 ** value to the application-defined function. ^If there is no metadata
5039 ** associated with the function argument, this sqlite3_get_auxdata() interface
 
5040 ** returns a NULL pointer.
5041 **
5042 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
5043 ** argument of the application-defined function. ^Subsequent
5044 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
@@ -5064,10 +5072,14 @@
5064 ** sqlite3_set_auxdata() has been called.
5065 **
5066 ** ^(In practice, metadata is preserved between function calls for
5067 ** function parameters that are compile-time constants, including literal
5068 ** values and [parameters] and expressions composed from the same.)^
 
 
 
 
5069 **
5070 ** These routines must be called from the same thread in which
5071 ** the SQL function is running.
5072 */
5073 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
@@ -18207,15 +18219,15 @@
18207 ** of this structure. All such structures associated with a single VM
18208 ** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed
18209 ** when the VM is halted (if not before).
18210 */
18211 struct AuxData {
18212 int iOp; /* Instruction number of OP_Function opcode */
18213 int iArg; /* Index of function argument. */
18214 void *pAux; /* Aux data pointer */
18215 void (*xDelete)(void *); /* Destructor for the aux data */
18216 AuxData *pNext; /* Next element in list */
18217 };
18218
18219 /*
18220 ** The "context" argument for an installable function. A pointer to an
18221 ** instance of this structure is the first argument to the routines used
@@ -74368,20 +74380,22 @@
74368 */
74369 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(sqlite3 *db, AuxData **pp, int iOp, int mask){
74370 while( *pp ){
74371 AuxData *pAux = *pp;
74372 if( (iOp<0)
74373 || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & MASKBIT32(pAux->iArg))))
 
 
74374 ){
74375 testcase( pAux->iArg==31 );
74376 if( pAux->xDelete ){
74377 pAux->xDelete(pAux->pAux);
74378 }
74379 *pp = pAux->pNext;
74380 sqlite3DbFree(db, pAux);
74381 }else{
74382 pp= &pAux->pNext;
74383 }
74384 }
74385 }
74386
74387 /*
@@ -76878,10 +76892,16 @@
76878 }
76879
76880 /*
76881 ** Return the auxiliary data pointer, if any, for the iArg'th argument to
76882 ** the user-function defined by pCtx.
 
 
 
 
 
 
76883 */
76884 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
76885 AuxData *pAuxData;
76886
76887 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
@@ -76888,21 +76908,28 @@
76888 #if SQLITE_ENABLE_STAT3_OR_STAT4
76889 if( pCtx->pVdbe==0 ) return 0;
76890 #else
76891 assert( pCtx->pVdbe!=0 );
76892 #endif
76893 for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
76894 if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
 
 
76895 }
76896
76897 return (pAuxData ? pAuxData->pAux : 0);
76898 }
76899
76900 /*
76901 ** Set the auxiliary data pointer and delete function, for the iArg'th
76902 ** argument to the user-function defined by pCtx. Any previous value is
76903 ** deleted by calling the delete function specified when it was set.
 
 
 
 
 
 
76904 */
76905 SQLITE_API void sqlite3_set_auxdata(
76906 sqlite3_context *pCtx,
76907 int iArg,
76908 void *pAux,
@@ -76910,37 +76937,38 @@
76910 ){
76911 AuxData *pAuxData;
76912 Vdbe *pVdbe = pCtx->pVdbe;
76913
76914 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
76915 if( iArg<0 ) goto failed;
76916 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
76917 if( pVdbe==0 ) goto failed;
76918 #else
76919 assert( pVdbe!=0 );
76920 #endif
76921
76922 for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
76923 if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
 
 
76924 }
76925 if( pAuxData==0 ){
76926 pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));
76927 if( !pAuxData ) goto failed;
76928 pAuxData->iOp = pCtx->iOp;
76929 pAuxData->iArg = iArg;
76930 pAuxData->pNext = pVdbe->pAuxData;
76931 pVdbe->pAuxData = pAuxData;
76932 if( pCtx->fErrorOrAux==0 ){
76933 pCtx->isError = 0;
76934 pCtx->fErrorOrAux = 1;
76935 }
76936 }else if( pAuxData->xDelete ){
76937 pAuxData->xDelete(pAuxData->pAux);
76938 }
76939
76940 pAuxData->pAux = pAux;
76941 pAuxData->xDelete = xDelete;
76942 return;
76943
76944 failed:
76945 if( xDelete ){
76946 xDelete(pAux);
@@ -99595,10 +99623,22 @@
99595 }
99596
99597 if( db->xAuth==0 ){
99598 return SQLITE_OK;
99599 }
 
 
 
 
 
 
 
 
 
 
 
 
99600 rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext
99601 #ifdef SQLITE_USER_AUTHENTICATION
99602 ,db->auth.zAuthUser
99603 #endif
99604 );
@@ -104930,11 +104970,18 @@
104930
104931 #ifndef SQLITE_OMIT_TRUNCATE_OPTIMIZATION
104932 /* Special case: A DELETE without a WHERE clause deletes everything.
104933 ** It is easier just to erase the whole table. Prior to version 3.6.5,
104934 ** this optimization caused the row change count (the value returned by
104935 ** API function sqlite3_count_changes) to be set incorrectly. */
 
 
 
 
 
 
 
104936 if( rcauth==SQLITE_OK
104937 && pWhere==0
104938 && !bComplex
104939 && !IsVirtual(pTab)
104940 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
@@ -121585,19 +121632,27 @@
121585 for(i=0; i<pTabList->nSrc; i++){
121586 struct SrcList_item *pItem = &pTabList->a[i];
121587 SelectDest dest;
121588 Select *pSub;
121589
121590 /* Issue SQLITE_READ authorizations with a NULL column name for any tables that
121591 ** are referenced but from which no values are extracted. Examples of where these
121592 ** kinds of null SQLITE_READ authorizations would occur:
121593 **
121594 ** SELECT count(*) FROM t1; -- SQLITE_READ t1 null
121595 ** SELECT t1.* FROM t1, t2; -- SQLITE_READ t2 null
 
 
 
 
 
 
 
 
121596 */
121597 if( pItem->colUsed==0 ){
121598 sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, pItem->zDatabase, 0);
121599 }
121600
121601 #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
121602 /* Generate code for all sub-queries in the FROM clause
121603 */
@@ -179491,10 +179546,11 @@
179491 const char *zJson; /* Original JSON string */
179492 u32 *aUp; /* Index of parent of each node */
179493 u8 oom; /* Set to true if out of memory */
179494 u8 nErr; /* Number of errors seen */
179495 u16 iDepth; /* Nesting depth */
 
179496 };
179497
179498 /*
179499 ** Maximum nesting depth of JSON for this implementation.
179500 **
@@ -179732,10 +179788,18 @@
179732 pParse->nNode = 0;
179733 pParse->nAlloc = 0;
179734 sqlite3_free(pParse->aUp);
179735 pParse->aUp = 0;
179736 }
 
 
 
 
 
 
 
 
179737
179738 /*
179739 ** Convert the JsonNode pNode into a pure JSON string and
179740 ** append to pOut. Subsubstructure is also included. Return
179741 ** the number of JsonNode objects that are encoded.
@@ -180283,10 +180347,53 @@
180283 return SQLITE_NOMEM;
180284 }
180285 jsonParseFillInParentage(pParse, 0, 0);
180286 return SQLITE_OK;
180287 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180288
180289 /*
180290 ** Compare the OBJECT label at pNode against zKey,nKey. Return true on
180291 ** a match.
180292 */
@@ -180649,33 +180756,34 @@
180649 static void jsonArrayLengthFunc(
180650 sqlite3_context *ctx,
180651 int argc,
180652 sqlite3_value **argv
180653 ){
180654 JsonParse x; /* The parse */
180655 sqlite3_int64 n = 0;
180656 u32 i;
180657 JsonNode *pNode;
180658
180659 if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;
180660 assert( x.nNode );
 
180661 if( argc==2 ){
180662 const char *zPath = (const char*)sqlite3_value_text(argv[1]);
180663 pNode = jsonLookup(&x, zPath, 0, ctx);
180664 }else{
180665 pNode = x.aNode;
180666 }
180667 if( pNode==0 ){
180668 x.nErr = 1;
180669 }else if( pNode->eType==JSON_ARRAY ){
 
180670 assert( (pNode->jnFlags & JNODE_APPEND)==0 );
180671 for(i=1; i<=pNode->n; n++){
180672 i += jsonNodeSize(&pNode[i]);
180673 }
180674 }
180675 if( x.nErr==0 ) sqlite3_result_int64(ctx, n);
180676 jsonParseReset(&x);
180677 }
180678
180679 /*
180680 ** json_extract(JSON, PATH, ...)
180681 **
@@ -180687,24 +180795,25 @@
180687 static void jsonExtractFunc(
180688 sqlite3_context *ctx,
180689 int argc,
180690 sqlite3_value **argv
180691 ){
180692 JsonParse x; /* The parse */
180693 JsonNode *pNode;
180694 const char *zPath;
180695 JsonString jx;
180696 int i;
180697
180698 if( argc<2 ) return;
180699 if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;
 
180700 jsonInit(&jx, ctx);
180701 jsonAppendChar(&jx, '[');
180702 for(i=1; i<argc; i++){
180703 zPath = (const char*)sqlite3_value_text(argv[i]);
180704 pNode = jsonLookup(&x, zPath, 0, ctx);
180705 if( x.nErr ) break;
180706 if( argc>2 ){
180707 jsonAppendSeparator(&jx);
180708 if( pNode ){
180709 jsonRenderNode(pNode, &jx, 0);
180710 }else{
@@ -180718,11 +180827,10 @@
180718 jsonAppendChar(&jx, ']');
180719 jsonResult(&jx);
180720 sqlite3_result_subtype(ctx, JSON_SUBTYPE);
180721 }
180722 jsonReset(&jx);
180723 jsonParseReset(&x);
180724 }
180725
180726 /* This is the RFC 7396 MergePatch algorithm.
180727 */
180728 static JsonNode *jsonMergePatch(
@@ -193984,10 +194092,11 @@
193984 Fts5StructureSegment *pSeg; /* Output segment */
193985 Fts5Buffer term;
193986 int bOldest; /* True if the output segment is the oldest */
193987 int eDetail = p->pConfig->eDetail;
193988 const int flags = FTS5INDEX_QUERY_NOOUTPUT;
 
193989
193990 assert( iLvl<pStruct->nLevel );
193991 assert( pLvl->nMerge<=pLvl->nSeg );
193992
193993 memset(&writer, 0, sizeof(Fts5SegWriter));
@@ -194037,22 +194146,26 @@
194037 Fts5SegIter *pSegIter = &pIter->aSeg[ pIter->aFirst[1].iFirst ];
194038 int nPos; /* position-list size field value */
194039 int nTerm;
194040 const u8 *pTerm;
194041
194042 /* Check for key annihilation. */
194043 if( pSegIter->nPos==0 && (bOldest || pSegIter->bDel==0) ) continue;
194044
194045 pTerm = fts5MultiIterTerm(pIter, &nTerm);
194046 if( nTerm!=term.n || memcmp(pTerm, term.p, nTerm) ){
194047 if( pnRem && writer.nLeafWritten>nRem ){
194048 break;
194049 }
 
 
 
194050
 
 
 
 
194051 /* This is a new term. Append a term to the output segment. */
194052 fts5WriteAppendTerm(p, &writer, nTerm, pTerm);
194053 fts5BufferSet(&p->rc, &term, nTerm, pTerm);
194054 }
194055
194056 /* Append the rowid to the output */
194057 /* WRITEPOSLISTSIZE */
194058 fts5WriteAppendRowid(p, &writer, fts5MultiIterRowid(pIter));
@@ -198908,11 +199021,11 @@
198908 int nArg, /* Number of args */
198909 sqlite3_value **apUnused /* Function arguments */
198910 ){
198911 assert( nArg==0 );
198912 UNUSED_PARAM2(nArg, apUnused);
198913 sqlite3_result_text(pCtx, "fts5: 2017-05-10 16:12:00 92ab1f7257d2866c69eaaf4cf85990677b911ef425e9c5a36a96978cccfb551c", -1, SQLITE_TRANSIENT);
198914 }
198915
198916 static int fts5Init(sqlite3 *db){
198917 static const sqlite3_module fts5Mod = {
198918 /* iVersion */ 2,
198919
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,11 +398,11 @@
398 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
399 ** [sqlite_version()] and [sqlite_source_id()].
400 */
401 #define SQLITE_VERSION "3.19.0"
402 #define SQLITE_VERSION_NUMBER 3019000
403 #define SQLITE_SOURCE_ID "2017-05-11 19:09:19 339df63f4064f3b9c8d4e8b82e72d00b49d9406bc350b14809a4caf7ddc4b736"
404
405 /*
406 ** CAPI3REF: Run-Time Library Version Numbers
407 ** KEYWORDS: sqlite3_version sqlite3_sourceid
408 **
@@ -2948,10 +2948,11 @@
2948 SQLITE_API void sqlite3_randomness(int N, void *P);
2949
2950 /*
2951 ** CAPI3REF: Compile-Time Authorization Callbacks
2952 ** METHOD: sqlite3
2953 ** KEYWORDS: {authorizer callback}
2954 **
2955 ** ^This routine registers an authorizer callback with a particular
2956 ** [database connection], supplied in the first argument.
2957 ** ^The authorizer callback is invoked as SQL statements are being compiled
2958 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
@@ -2975,20 +2976,26 @@
2976 **
2977 ** ^The first parameter to the authorizer callback is a copy of the third
2978 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
2979 ** to the callback is an integer [SQLITE_COPY | action code] that specifies
2980 ** the particular action to be authorized. ^The third through sixth parameters
2981 ** to the callback are either NULL pointers or zero-terminated strings
2982 ** that contain additional details about the action to be authorized.
2983 ** Applications must always be prepared to encounter a NULL pointer in any
2984 ** of the third through the sixth parameters of the authorization callback.
2985 **
2986 ** ^If the action code is [SQLITE_READ]
2987 ** and the callback returns [SQLITE_IGNORE] then the
2988 ** [prepared statement] statement is constructed to substitute
2989 ** a NULL value in place of the table column that would have
2990 ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE]
2991 ** return can be used to deny an untrusted user access to individual
2992 ** columns of a table.
2993 ** ^When a table is referenced by a [SELECT] but no column values are
2994 ** extracted from that table (for example in a query like
2995 ** "SELECT count(*) FROM tab") then the [SQLITE_READ] authorizer callback
2996 ** is invoked once for that table with a column name that is an empty string.
2997 ** ^If the action code is [SQLITE_DELETE] and the callback returns
2998 ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the
2999 ** [truncate optimization] is disabled and all rows are deleted individually.
3000 **
3001 ** An authorizer is used when [sqlite3_prepare | preparing]
@@ -5031,14 +5038,15 @@
5038 ** metadata associated with the pattern string.
5039 ** Then as long as the pattern string remains the same,
5040 ** the compiled regular expression can be reused on multiple
5041 ** invocations of the same function.
5042 **
5043 ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata
5044 ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument
5045 ** value to the application-defined function. ^N is zero for the left-most
5046 ** function argument. ^If there is no metadata
5047 ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface
5048 ** returns a NULL pointer.
5049 **
5050 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
5051 ** argument of the application-defined function. ^Subsequent
5052 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
@@ -5064,10 +5072,14 @@
5072 ** sqlite3_set_auxdata() has been called.
5073 **
5074 ** ^(In practice, metadata is preserved between function calls for
5075 ** function parameters that are compile-time constants, including literal
5076 ** values and [parameters] and expressions composed from the same.)^
5077 **
5078 ** The value of the N parameter to these interfaces should be non-negative.
5079 ** Future enhancements may make use of negative N values to define new
5080 ** kinds of function caching behavior.
5081 **
5082 ** These routines must be called from the same thread in which
5083 ** the SQL function is running.
5084 */
5085 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
@@ -18207,15 +18219,15 @@
18219 ** of this structure. All such structures associated with a single VM
18220 ** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed
18221 ** when the VM is halted (if not before).
18222 */
18223 struct AuxData {
18224 int iAuxOp; /* Instruction number of OP_Function opcode */
18225 int iAuxArg; /* Index of function argument. */
18226 void *pAux; /* Aux data pointer */
18227 void (*xDeleteAux)(void*); /* Destructor for the aux data */
18228 AuxData *pNextAux; /* Next element in list */
18229 };
18230
18231 /*
18232 ** The "context" argument for an installable function. A pointer to an
18233 ** instance of this structure is the first argument to the routines used
@@ -74368,20 +74380,22 @@
74380 */
74381 SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(sqlite3 *db, AuxData **pp, int iOp, int mask){
74382 while( *pp ){
74383 AuxData *pAux = *pp;
74384 if( (iOp<0)
74385 || (pAux->iAuxOp==iOp
74386 && pAux->iAuxArg>=0
74387 && (pAux->iAuxArg>31 || !(mask & MASKBIT32(pAux->iAuxArg))))
74388 ){
74389 testcase( pAux->iAuxArg==31 );
74390 if( pAux->xDeleteAux ){
74391 pAux->xDeleteAux(pAux->pAux);
74392 }
74393 *pp = pAux->pNextAux;
74394 sqlite3DbFree(db, pAux);
74395 }else{
74396 pp= &pAux->pNextAux;
74397 }
74398 }
74399 }
74400
74401 /*
@@ -76878,10 +76892,16 @@
76892 }
76893
76894 /*
76895 ** Return the auxiliary data pointer, if any, for the iArg'th argument to
76896 ** the user-function defined by pCtx.
76897 **
76898 ** The left-most argument is 0.
76899 **
76900 ** Undocumented behavior: If iArg is negative then access a cache of
76901 ** auxiliary data pointers that is available to all functions within a
76902 ** single prepared statement. The iArg values must match.
76903 */
76904 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
76905 AuxData *pAuxData;
76906
76907 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
@@ -76888,21 +76908,28 @@
76908 #if SQLITE_ENABLE_STAT3_OR_STAT4
76909 if( pCtx->pVdbe==0 ) return 0;
76910 #else
76911 assert( pCtx->pVdbe!=0 );
76912 #endif
76913 for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){
76914 if( pAuxData->iAuxArg==iArg && (pAuxData->iAuxOp==pCtx->iOp || iArg<0) ){
76915 return pAuxData->pAux;
76916 }
76917 }
76918 return 0;
 
76919 }
76920
76921 /*
76922 ** Set the auxiliary data pointer and delete function, for the iArg'th
76923 ** argument to the user-function defined by pCtx. Any previous value is
76924 ** deleted by calling the delete function specified when it was set.
76925 **
76926 ** The left-most argument is 0.
76927 **
76928 ** Undocumented behavior: If iArg is negative then make the data available
76929 ** to all functions within the current prepared statement using iArg as an
76930 ** access code.
76931 */
76932 SQLITE_API void sqlite3_set_auxdata(
76933 sqlite3_context *pCtx,
76934 int iArg,
76935 void *pAux,
@@ -76910,37 +76937,38 @@
76937 ){
76938 AuxData *pAuxData;
76939 Vdbe *pVdbe = pCtx->pVdbe;
76940
76941 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
 
76942 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
76943 if( pVdbe==0 ) goto failed;
76944 #else
76945 assert( pVdbe!=0 );
76946 #endif
76947
76948 for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){
76949 if( pAuxData->iAuxArg==iArg && (pAuxData->iAuxOp==pCtx->iOp || iArg<0) ){
76950 break;
76951 }
76952 }
76953 if( pAuxData==0 ){
76954 pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));
76955 if( !pAuxData ) goto failed;
76956 pAuxData->iAuxOp = pCtx->iOp;
76957 pAuxData->iAuxArg = iArg;
76958 pAuxData->pNextAux = pVdbe->pAuxData;
76959 pVdbe->pAuxData = pAuxData;
76960 if( pCtx->fErrorOrAux==0 ){
76961 pCtx->isError = 0;
76962 pCtx->fErrorOrAux = 1;
76963 }
76964 }else if( pAuxData->xDeleteAux ){
76965 pAuxData->xDeleteAux(pAuxData->pAux);
76966 }
76967
76968 pAuxData->pAux = pAux;
76969 pAuxData->xDeleteAux = xDelete;
76970 return;
76971
76972 failed:
76973 if( xDelete ){
76974 xDelete(pAux);
@@ -99595,10 +99623,22 @@
99623 }
99624
99625 if( db->xAuth==0 ){
99626 return SQLITE_OK;
99627 }
99628
99629 /* EVIDENCE-OF: R-43249-19882 The third through sixth parameters to the
99630 ** callback are either NULL pointers or zero-terminated strings that
99631 ** contain additional details about the action to be authorized.
99632 **
99633 ** The following testcase() macros show that any of the 3rd through 6th
99634 ** parameters can be either NULL or a string. */
99635 testcase( zArg1==0 );
99636 testcase( zArg2==0 );
99637 testcase( zArg3==0 );
99638 testcase( pParse->zAuthContext==0 );
99639
99640 rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext
99641 #ifdef SQLITE_USER_AUTHENTICATION
99642 ,db->auth.zAuthUser
99643 #endif
99644 );
@@ -104930,11 +104970,18 @@
104970
104971 #ifndef SQLITE_OMIT_TRUNCATE_OPTIMIZATION
104972 /* Special case: A DELETE without a WHERE clause deletes everything.
104973 ** It is easier just to erase the whole table. Prior to version 3.6.5,
104974 ** this optimization caused the row change count (the value returned by
104975 ** API function sqlite3_count_changes) to be set incorrectly.
104976 **
104977 ** The "rcauth==SQLITE_OK" terms is the
104978 ** IMPLEMENATION-OF: R-17228-37124 If the action code is SQLITE_DELETE and
104979 ** the callback returns SQLITE_IGNORE then the DELETE operation proceeds but
104980 ** the truncate optimization is disabled and all rows are deleted
104981 ** individually.
104982 */
104983 if( rcauth==SQLITE_OK
104984 && pWhere==0
104985 && !bComplex
104986 && !IsVirtual(pTab)
104987 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
@@ -121585,19 +121632,27 @@
121632 for(i=0; i<pTabList->nSrc; i++){
121633 struct SrcList_item *pItem = &pTabList->a[i];
121634 SelectDest dest;
121635 Select *pSub;
121636
121637 /* Issue SQLITE_READ authorizations with a fake column name for any tables that
121638 ** are referenced but from which no values are extracted. Examples of where these
121639 ** kinds of null SQLITE_READ authorizations would occur:
121640 **
121641 ** SELECT count(*) FROM t1; -- SQLITE_READ t1.""
121642 ** SELECT t1.* FROM t1, t2; -- SQLITE_READ t2.""
121643 **
121644 ** The fake column name is an empty string. It is possible for a table to
121645 ** have a column named by the empty string, in which case there is no way to
121646 ** distinguish between an unreferenced table and an actual reference to the
121647 ** "" column. The original design was for the fake column name to be a NULL,
121648 ** which would be unambiguous. But legacy authorization callbacks might
121649 ** assume the column name is non-NULL and segfault. The use of an empty string
121650 ** for the fake column name seems safer.
121651 */
121652 if( pItem->colUsed==0 ){
121653 sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, "", pItem->zDatabase);
121654 }
121655
121656 #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
121657 /* Generate code for all sub-queries in the FROM clause
121658 */
@@ -179491,10 +179546,11 @@
179546 const char *zJson; /* Original JSON string */
179547 u32 *aUp; /* Index of parent of each node */
179548 u8 oom; /* Set to true if out of memory */
179549 u8 nErr; /* Number of errors seen */
179550 u16 iDepth; /* Nesting depth */
179551 int nJson; /* Length of the zJson string in bytes */
179552 };
179553
179554 /*
179555 ** Maximum nesting depth of JSON for this implementation.
179556 **
@@ -179732,10 +179788,18 @@
179788 pParse->nNode = 0;
179789 pParse->nAlloc = 0;
179790 sqlite3_free(pParse->aUp);
179791 pParse->aUp = 0;
179792 }
179793
179794 /*
179795 ** Free a JsonParse object that was obtained from sqlite3_malloc().
179796 */
179797 static void jsonParseFree(JsonParse *pParse){
179798 jsonParseReset(pParse);
179799 sqlite3_free(pParse);
179800 }
179801
179802 /*
179803 ** Convert the JsonNode pNode into a pure JSON string and
179804 ** append to pOut. Subsubstructure is also included. Return
179805 ** the number of JsonNode objects that are encoded.
@@ -180283,10 +180347,53 @@
180347 return SQLITE_NOMEM;
180348 }
180349 jsonParseFillInParentage(pParse, 0, 0);
180350 return SQLITE_OK;
180351 }
180352
180353 /*
180354 ** Magic number used for the JSON parse cache in sqlite3_get_auxdata()
180355 */
180356 #define JSON_CACHE_ID (-429938)
180357
180358 /*
180359 ** Obtain a complete parse of the JSON found in the first argument
180360 ** of the argv array. Use the sqlite3_get_auxdata() cache for this
180361 ** parse if it is available. If the cache is not available or if it
180362 ** is no longer valid, parse the JSON again and return the new parse,
180363 ** and also register the new parse so that it will be available for
180364 ** future sqlite3_get_auxdata() calls.
180365 */
180366 static JsonParse *jsonParseCached(
180367 sqlite3_context *pCtx,
180368 sqlite3_value **argv
180369 ){
180370 const char *zJson = (const char*)sqlite3_value_text(argv[0]);
180371 int nJson = sqlite3_value_bytes(argv[0]);
180372 JsonParse *p;
180373 if( zJson==0 ) return 0;
180374 p = (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID);
180375 if( p && p->nJson==nJson && memcmp(p->zJson,zJson,nJson)==0 ){
180376 p->nErr = 0;
180377 return p; /* The cached entry matches, so return it */
180378 }
180379 p = sqlite3_malloc( sizeof(*p) + nJson + 1 );
180380 if( p==0 ){
180381 sqlite3_result_error_nomem(pCtx);
180382 return 0;
180383 }
180384 memset(p, 0, sizeof(*p));
180385 p->zJson = (char*)&p[1];
180386 memcpy((char*)p->zJson, zJson, nJson+1);
180387 if( jsonParse(p, pCtx, p->zJson) ){
180388 sqlite3_free(p);
180389 return 0;
180390 }
180391 p->nJson = nJson;
180392 sqlite3_set_auxdata(pCtx, JSON_CACHE_ID, p, (void(*)(void*))jsonParseFree);
180393 return (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID);
180394 }
180395
180396 /*
180397 ** Compare the OBJECT label at pNode against zKey,nKey. Return true on
180398 ** a match.
180399 */
@@ -180649,33 +180756,34 @@
180756 static void jsonArrayLengthFunc(
180757 sqlite3_context *ctx,
180758 int argc,
180759 sqlite3_value **argv
180760 ){
180761 JsonParse *p; /* The parse */
180762 sqlite3_int64 n = 0;
180763 u32 i;
180764 JsonNode *pNode;
180765
180766 p = jsonParseCached(ctx, argv);
180767 if( p==0 ) return;
180768 assert( p->nNode );
180769 if( argc==2 ){
180770 const char *zPath = (const char*)sqlite3_value_text(argv[1]);
180771 pNode = jsonLookup(p, zPath, 0, ctx);
180772 }else{
180773 pNode = p->aNode;
180774 }
180775 if( pNode==0 ){
180776 return;
180777 }
180778 if( pNode->eType==JSON_ARRAY ){
180779 assert( (pNode->jnFlags & JNODE_APPEND)==0 );
180780 for(i=1; i<=pNode->n; n++){
180781 i += jsonNodeSize(&pNode[i]);
180782 }
180783 }
180784 sqlite3_result_int64(ctx, n);
 
180785 }
180786
180787 /*
180788 ** json_extract(JSON, PATH, ...)
180789 **
@@ -180687,24 +180795,25 @@
180795 static void jsonExtractFunc(
180796 sqlite3_context *ctx,
180797 int argc,
180798 sqlite3_value **argv
180799 ){
180800 JsonParse *p; /* The parse */
180801 JsonNode *pNode;
180802 const char *zPath;
180803 JsonString jx;
180804 int i;
180805
180806 if( argc<2 ) return;
180807 p = jsonParseCached(ctx, argv);
180808 if( p==0 ) return;
180809 jsonInit(&jx, ctx);
180810 jsonAppendChar(&jx, '[');
180811 for(i=1; i<argc; i++){
180812 zPath = (const char*)sqlite3_value_text(argv[i]);
180813 pNode = jsonLookup(p, zPath, 0, ctx);
180814 if( p->nErr ) break;
180815 if( argc>2 ){
180816 jsonAppendSeparator(&jx);
180817 if( pNode ){
180818 jsonRenderNode(pNode, &jx, 0);
180819 }else{
@@ -180718,11 +180827,10 @@
180827 jsonAppendChar(&jx, ']');
180828 jsonResult(&jx);
180829 sqlite3_result_subtype(ctx, JSON_SUBTYPE);
180830 }
180831 jsonReset(&jx);
 
180832 }
180833
180834 /* This is the RFC 7396 MergePatch algorithm.
180835 */
180836 static JsonNode *jsonMergePatch(
@@ -193984,10 +194092,11 @@
194092 Fts5StructureSegment *pSeg; /* Output segment */
194093 Fts5Buffer term;
194094 int bOldest; /* True if the output segment is the oldest */
194095 int eDetail = p->pConfig->eDetail;
194096 const int flags = FTS5INDEX_QUERY_NOOUTPUT;
194097 int bTermWritten = 0; /* True if current term already output */
194098
194099 assert( iLvl<pStruct->nLevel );
194100 assert( pLvl->nMerge<=pLvl->nSeg );
194101
194102 memset(&writer, 0, sizeof(Fts5SegWriter));
@@ -194037,22 +194146,26 @@
194146 Fts5SegIter *pSegIter = &pIter->aSeg[ pIter->aFirst[1].iFirst ];
194147 int nPos; /* position-list size field value */
194148 int nTerm;
194149 const u8 *pTerm;
194150
 
 
 
194151 pTerm = fts5MultiIterTerm(pIter, &nTerm);
194152 if( nTerm!=term.n || memcmp(pTerm, term.p, nTerm) ){
194153 if( pnRem && writer.nLeafWritten>nRem ){
194154 break;
194155 }
194156 fts5BufferSet(&p->rc, &term, nTerm, pTerm);
194157 bTermWritten =0;
194158 }
194159
194160 /* Check for key annihilation. */
194161 if( pSegIter->nPos==0 && (bOldest || pSegIter->bDel==0) ) continue;
194162
194163 if( p->rc==SQLITE_OK && bTermWritten==0 ){
194164 /* This is a new term. Append a term to the output segment. */
194165 fts5WriteAppendTerm(p, &writer, nTerm, pTerm);
194166 bTermWritten = 1;
194167 }
194168
194169 /* Append the rowid to the output */
194170 /* WRITEPOSLISTSIZE */
194171 fts5WriteAppendRowid(p, &writer, fts5MultiIterRowid(pIter));
@@ -198908,11 +199021,11 @@
199021 int nArg, /* Number of args */
199022 sqlite3_value **apUnused /* Function arguments */
199023 ){
199024 assert( nArg==0 );
199025 UNUSED_PARAM2(nArg, apUnused);
199026 sqlite3_result_text(pCtx, "fts5: 2017-05-11 19:09:19 339df63f4064f3b9c8d4e8b82e72d00b49d9406bc350b14809a4caf7ddc4b736", -1, SQLITE_TRANSIENT);
199027 }
199028
199029 static int fts5Init(sqlite3 *db){
199030 static const sqlite3_module fts5Mod = {
199031 /* iVersion */ 2,
199032
+19 -7
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121121
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122122
** [sqlite_version()] and [sqlite_source_id()].
123123
*/
124124
#define SQLITE_VERSION "3.19.0"
125125
#define SQLITE_VERSION_NUMBER 3019000
126
-#define SQLITE_SOURCE_ID "2017-05-10 16:12:00 92ab1f7257d2866c69eaaf4cf85990677b911ef425e9c5a36a96978cccfb551c"
126
+#define SQLITE_SOURCE_ID "2017-05-11 19:09:19 339df63f4064f3b9c8d4e8b82e72d00b49d9406bc350b14809a4caf7ddc4b736"
127127
128128
/*
129129
** CAPI3REF: Run-Time Library Version Numbers
130130
** KEYWORDS: sqlite3_version sqlite3_sourceid
131131
**
@@ -2671,10 +2671,11 @@
26712671
SQLITE_API void sqlite3_randomness(int N, void *P);
26722672
26732673
/*
26742674
** CAPI3REF: Compile-Time Authorization Callbacks
26752675
** METHOD: sqlite3
2676
+** KEYWORDS: {authorizer callback}
26762677
**
26772678
** ^This routine registers an authorizer callback with a particular
26782679
** [database connection], supplied in the first argument.
26792680
** ^The authorizer callback is invoked as SQL statements are being compiled
26802681
** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
@@ -2698,20 +2699,26 @@
26982699
**
26992700
** ^The first parameter to the authorizer callback is a copy of the third
27002701
** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
27012702
** to the callback is an integer [SQLITE_COPY | action code] that specifies
27022703
** the particular action to be authorized. ^The third through sixth parameters
2703
-** to the callback are zero-terminated strings that contain additional
2704
-** details about the action to be authorized.
2704
+** to the callback are either NULL pointers or zero-terminated strings
2705
+** that contain additional details about the action to be authorized.
2706
+** Applications must always be prepared to encounter a NULL pointer in any
2707
+** of the third through the sixth parameters of the authorization callback.
27052708
**
27062709
** ^If the action code is [SQLITE_READ]
27072710
** and the callback returns [SQLITE_IGNORE] then the
27082711
** [prepared statement] statement is constructed to substitute
27092712
** a NULL value in place of the table column that would have
27102713
** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE]
27112714
** return can be used to deny an untrusted user access to individual
27122715
** columns of a table.
2716
+** ^When a table is referenced by a [SELECT] but no column values are
2717
+** extracted from that table (for example in a query like
2718
+** "SELECT count(*) FROM tab") then the [SQLITE_READ] authorizer callback
2719
+** is invoked once for that table with a column name that is an empty string.
27132720
** ^If the action code is [SQLITE_DELETE] and the callback returns
27142721
** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the
27152722
** [truncate optimization] is disabled and all rows are deleted individually.
27162723
**
27172724
** An authorizer is used when [sqlite3_prepare | preparing]
@@ -4754,14 +4761,15 @@
47544761
** metadata associated with the pattern string.
47554762
** Then as long as the pattern string remains the same,
47564763
** the compiled regular expression can be reused on multiple
47574764
** invocations of the same function.
47584765
**
4759
-** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
4760
-** associated by the sqlite3_set_auxdata() function with the Nth argument
4761
-** value to the application-defined function. ^If there is no metadata
4762
-** associated with the function argument, this sqlite3_get_auxdata() interface
4766
+** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata
4767
+** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument
4768
+** value to the application-defined function. ^N is zero for the left-most
4769
+** function argument. ^If there is no metadata
4770
+** associated with the function argument, the sqlite3_get_auxdata(C,N) interface
47634771
** returns a NULL pointer.
47644772
**
47654773
** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
47664774
** argument of the application-defined function. ^Subsequent
47674775
** calls to sqlite3_get_auxdata(C,N) return P from the most recent
@@ -4787,10 +4795,14 @@
47874795
** sqlite3_set_auxdata() has been called.
47884796
**
47894797
** ^(In practice, metadata is preserved between function calls for
47904798
** function parameters that are compile-time constants, including literal
47914799
** values and [parameters] and expressions composed from the same.)^
4800
+**
4801
+** The value of the N parameter to these interfaces should be non-negative.
4802
+** Future enhancements may make use of negative N values to define new
4803
+** kinds of function caching behavior.
47924804
**
47934805
** These routines must be called from the same thread in which
47944806
** the SQL function is running.
47954807
*/
47964808
SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
47974809
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.19.0"
125 #define SQLITE_VERSION_NUMBER 3019000
126 #define SQLITE_SOURCE_ID "2017-05-10 16:12:00 92ab1f7257d2866c69eaaf4cf85990677b911ef425e9c5a36a96978cccfb551c"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
@@ -2671,10 +2671,11 @@
2671 SQLITE_API void sqlite3_randomness(int N, void *P);
2672
2673 /*
2674 ** CAPI3REF: Compile-Time Authorization Callbacks
2675 ** METHOD: sqlite3
 
2676 **
2677 ** ^This routine registers an authorizer callback with a particular
2678 ** [database connection], supplied in the first argument.
2679 ** ^The authorizer callback is invoked as SQL statements are being compiled
2680 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
@@ -2698,20 +2699,26 @@
2698 **
2699 ** ^The first parameter to the authorizer callback is a copy of the third
2700 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
2701 ** to the callback is an integer [SQLITE_COPY | action code] that specifies
2702 ** the particular action to be authorized. ^The third through sixth parameters
2703 ** to the callback are zero-terminated strings that contain additional
2704 ** details about the action to be authorized.
 
 
2705 **
2706 ** ^If the action code is [SQLITE_READ]
2707 ** and the callback returns [SQLITE_IGNORE] then the
2708 ** [prepared statement] statement is constructed to substitute
2709 ** a NULL value in place of the table column that would have
2710 ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE]
2711 ** return can be used to deny an untrusted user access to individual
2712 ** columns of a table.
 
 
 
 
2713 ** ^If the action code is [SQLITE_DELETE] and the callback returns
2714 ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the
2715 ** [truncate optimization] is disabled and all rows are deleted individually.
2716 **
2717 ** An authorizer is used when [sqlite3_prepare | preparing]
@@ -4754,14 +4761,15 @@
4754 ** metadata associated with the pattern string.
4755 ** Then as long as the pattern string remains the same,
4756 ** the compiled regular expression can be reused on multiple
4757 ** invocations of the same function.
4758 **
4759 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
4760 ** associated by the sqlite3_set_auxdata() function with the Nth argument
4761 ** value to the application-defined function. ^If there is no metadata
4762 ** associated with the function argument, this sqlite3_get_auxdata() interface
 
4763 ** returns a NULL pointer.
4764 **
4765 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
4766 ** argument of the application-defined function. ^Subsequent
4767 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
@@ -4787,10 +4795,14 @@
4787 ** sqlite3_set_auxdata() has been called.
4788 **
4789 ** ^(In practice, metadata is preserved between function calls for
4790 ** function parameters that are compile-time constants, including literal
4791 ** values and [parameters] and expressions composed from the same.)^
 
 
 
 
4792 **
4793 ** These routines must be called from the same thread in which
4794 ** the SQL function is running.
4795 */
4796 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
4797
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.19.0"
125 #define SQLITE_VERSION_NUMBER 3019000
126 #define SQLITE_SOURCE_ID "2017-05-11 19:09:19 339df63f4064f3b9c8d4e8b82e72d00b49d9406bc350b14809a4caf7ddc4b736"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
@@ -2671,10 +2671,11 @@
2671 SQLITE_API void sqlite3_randomness(int N, void *P);
2672
2673 /*
2674 ** CAPI3REF: Compile-Time Authorization Callbacks
2675 ** METHOD: sqlite3
2676 ** KEYWORDS: {authorizer callback}
2677 **
2678 ** ^This routine registers an authorizer callback with a particular
2679 ** [database connection], supplied in the first argument.
2680 ** ^The authorizer callback is invoked as SQL statements are being compiled
2681 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
@@ -2698,20 +2699,26 @@
2699 **
2700 ** ^The first parameter to the authorizer callback is a copy of the third
2701 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
2702 ** to the callback is an integer [SQLITE_COPY | action code] that specifies
2703 ** the particular action to be authorized. ^The third through sixth parameters
2704 ** to the callback are either NULL pointers or zero-terminated strings
2705 ** that contain additional details about the action to be authorized.
2706 ** Applications must always be prepared to encounter a NULL pointer in any
2707 ** of the third through the sixth parameters of the authorization callback.
2708 **
2709 ** ^If the action code is [SQLITE_READ]
2710 ** and the callback returns [SQLITE_IGNORE] then the
2711 ** [prepared statement] statement is constructed to substitute
2712 ** a NULL value in place of the table column that would have
2713 ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE]
2714 ** return can be used to deny an untrusted user access to individual
2715 ** columns of a table.
2716 ** ^When a table is referenced by a [SELECT] but no column values are
2717 ** extracted from that table (for example in a query like
2718 ** "SELECT count(*) FROM tab") then the [SQLITE_READ] authorizer callback
2719 ** is invoked once for that table with a column name that is an empty string.
2720 ** ^If the action code is [SQLITE_DELETE] and the callback returns
2721 ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the
2722 ** [truncate optimization] is disabled and all rows are deleted individually.
2723 **
2724 ** An authorizer is used when [sqlite3_prepare | preparing]
@@ -4754,14 +4761,15 @@
4761 ** metadata associated with the pattern string.
4762 ** Then as long as the pattern string remains the same,
4763 ** the compiled regular expression can be reused on multiple
4764 ** invocations of the same function.
4765 **
4766 ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata
4767 ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument
4768 ** value to the application-defined function. ^N is zero for the left-most
4769 ** function argument. ^If there is no metadata
4770 ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface
4771 ** returns a NULL pointer.
4772 **
4773 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
4774 ** argument of the application-defined function. ^Subsequent
4775 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
@@ -4787,10 +4795,14 @@
4795 ** sqlite3_set_auxdata() has been called.
4796 **
4797 ** ^(In practice, metadata is preserved between function calls for
4798 ** function parameters that are compile-time constants, including literal
4799 ** values and [parameters] and expressions composed from the same.)^
4800 **
4801 ** The value of the N parameter to these interfaces should be non-negative.
4802 ** Future enhancements may make use of negative N values to define new
4803 ** kinds of function caching behavior.
4804 **
4805 ** These routines must be called from the same thread in which
4806 ** the SQL function is running.
4807 */
4808 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
4809

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button