diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/json.c | 4 | ||||
-rw-r--r-- | src/sqlite.h.in | 37 | ||||
-rw-r--r-- | src/sqliteInt.h | 6 | ||||
-rw-r--r-- | src/window.c | 2 |
4 files changed, 29 insertions, 20 deletions
diff --git a/src/json.c b/src/json.c index ab6939d02..132a274cd 100644 --- a/src/json.c +++ b/src/json.c @@ -3835,11 +3835,11 @@ void sqlite3RegisterJsonFunctions(void){ #endif WAGGREGATE(json_group_array, 1, 0, 0, jsonArrayStep, jsonArrayFinal, jsonArrayValue, jsonGroupInverse, - SQLITE_VALUE_SUBTYPE|SQLITE_RESULT_SUBTYPE|SQLITE_UTF8| + SQLITE_SUBTYPE|SQLITE_RESULT_SUBTYPE|SQLITE_UTF8| SQLITE_DETERMINISTIC), WAGGREGATE(json_group_object, 2, 0, 0, jsonObjectStep, jsonObjectFinal, jsonObjectValue, jsonGroupInverse, - SQLITE_VALUE_SUBTYPE|SQLITE_RESULT_SUBTYPE|SQLITE_UTF8| + SQLITE_SUBTYPE|SQLITE_RESULT_SUBTYPE|SQLITE_UTF8| SQLITE_DETERMINISTIC) }; sqlite3InsertBuiltinFuncs(aJsonFunc, ArraySize(aJsonFunc)); diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 2853289fc..09e6f4765 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5572,20 +5572,12 @@ int sqlite3_create_window_function( ** security-adverse side-effects and information-leaks. ** </dd> ** -** [[SQLITE_VALUE_SUBTYPE]] <dt>SQLITE_VALUE_SUBTYPE</dt><dd> -** The SQLITE_VALUE_SUBTYPE flag indicates to SQLite that a function may call +** [[SQLITE_SUBTYPE]] <dt>SQLITE_SUBTYPE</dt><dd> +** The SQLITE_SUBTYPE flag indicates to SQLite that a function may call ** [sqlite3_value_subtype()] to inspect the sub-types of its arguments. ** Every function that invokes [sqlite3_value_subtype()] should have this ** property. If it does not, then the query planner might generate -** incorrect code for queries that use that function. This property -** used to be called [SQLITE_SUBTYPE]. Its name was changed to disinguish -** it from [SQLITE_RESULT_SUBTYPE]. The old name is also retained for -** backwards compatibility. -** -** [[SQLITE_SUBTYPE]] <dt>SQLITE_SUBTYPE</dt><dd> -** The SQLITE_SUBTYPE flag is an alias for [SQLITE_VALUE_SUBTYPE] used for -** backwards compatibility. The newer [SQLITE_VALUE_SUBTYPE] -** symbol is preferred. +** incorrect code for queries that use that function. ** ** [[SQLITE_RESULT_SUBTYPE]] <dt>SQLITE_RESULT_SUBTYPE</dt><dd> ** The SQLITE_RESULT_SUBTYPE flag indicates to SQLite that a function might call @@ -5594,14 +5586,16 @@ int sqlite3_create_window_function( ** Every function that invokes [sqlite3_result_subtype()] should have this ** property. If it does not, then the call to [sqlite3_result_subtype()] ** might become a no-op if the function is used as term in an -** [expression index]. +** [expression index]. On the other hand, SQL functions that never invoke +** [sqlite3_result_subtype()] should avoid setting this property, as the +** purpose of this property is to disable certain optimizations that are +** incompatible with subtypes. ** </dd> ** </dl> */ #define SQLITE_DETERMINISTIC 0x000000800 #define SQLITE_DIRECTONLY 0x000080000 -#define SQLITE_SUBTYPE 0x000100000 /* Deprecated name */ -#define SQLITE_VALUE_SUBTYPE 0x000100000 /* Use instead of SQLITE_SUBTYPE */ +#define SQLITE_SUBTYPE 0x000100000 #define SQLITE_INNOCUOUS 0x000200000 #define SQLITE_RESULT_SUBTYPE 0x001000000 @@ -5800,6 +5794,13 @@ int sqlite3_value_encoding(sqlite3_value*); ** information can be used to pass a limited amount of context from ** one SQL function to another. Use the [sqlite3_result_subtype()] ** routine to set the subtype for the return value of an SQL function. +** +** Every [application-defined SQL function] that invoke this interface +** <i>must</i> include the [SQLITE_SUBTYPE] property in the text +** encoding argument when the function is [sqlite3_create_function|registered]. +** The sqlite3_value_subtype() can return an incorrect answer if it +** is invoked from within an application-defined SQL function that does +** not have the [SQLITE_SUBTYPE] property. */ unsigned int sqlite3_value_subtype(sqlite3_value*); @@ -6219,6 +6220,14 @@ int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); ** higher order bits are discarded. ** The number of subtype bytes preserved by SQLite might increase ** in future releases of SQLite. +** +** Every [application-defined SQL function] that invokes this interface +** <i>must</i> include the [SQLITE_RESULT_SUBTYPE] property in its +** text encoding argument when the SQL function is +** [sqlite3_create_function|registered]. If the sqlite3_result_subtype() +** interface is invoked within an SQL function that does not have the +** SQLITE_RESULT_SUBTYPE property, then sqlite3_result_subtype() +** might fail to set the result subtype. */ void sqlite3_result_subtype(sqlite3_context*,unsigned int); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 1a1e1268a..35c4d403e 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2018,7 +2018,7 @@ struct FuncDestructor { #define SQLITE_FUNC_WINDOW 0x00010000 /* Built-in window-only function */ #define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */ #define SQLITE_FUNC_DIRECT 0x00080000 /* Not for use in TRIGGERs or VIEWs */ -/* SQLITE_VALUE_SUBTYPE 0x00100000 // Consumer of subtypes */ +/* SQLITE_SUBTYPE 0x00100000 // Consumer of subtypes */ #define SQLITE_FUNC_UNSAFE 0x00200000 /* Function has side effects */ #define SQLITE_FUNC_INLINE 0x00400000 /* Functions implemented in-line */ #define SQLITE_FUNC_BUILTIN 0x00800000 /* This is a built-in function */ @@ -2117,7 +2117,7 @@ struct FuncDestructor { #define JFUNCTION(zName, nArg, bUseCache, bRS, bWS, iArg, xFunc) \ {nArg, SQLITE_FUNC_BUILTIN|SQLITE_DETERMINISTIC|SQLITE_FUNC_CONSTANT|\ SQLITE_UTF8|((bUseCache)*SQLITE_FUNC_RUNONLY)|\ - ((bRS)*SQLITE_VALUE_SUBTYPE)|((bWS)*SQLITE_RESULT_SUBTYPE), \ + ((bRS)*SQLITE_SUBTYPE)|((bWS)*SQLITE_RESULT_SUBTYPE), \ SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } #define INLINE_FUNC(zName, nArg, iArg, mFlags) \ {nArg, SQLITE_FUNC_BUILTIN|\ @@ -4454,7 +4454,7 @@ struct Window { int regStartRowid; int regEndRowid; u8 bExprArgs; /* Defer evaluation of window function arguments - ** due to the SQLITE_VALUE_SUBTYPE flag */ + ** due to the SQLITE_SUBTYPE flag */ }; #ifndef SQLITE_OMIT_WINDOWFUNC diff --git a/src/window.c b/src/window.c index edbfb6c7e..62df349fb 100644 --- a/src/window.c +++ b/src/window.c @@ -1038,7 +1038,7 @@ int sqlite3WindowRewrite(Parse *pParse, Select *p){ assert( ExprUseXList(pWin->pOwner) ); assert( pWin->pWFunc!=0 ); pArgs = pWin->pOwner->x.pList; - if( pWin->pWFunc->funcFlags & SQLITE_VALUE_SUBTYPE ){ + if( pWin->pWFunc->funcFlags & SQLITE_SUBTYPE ){ selectWindowRewriteEList(pParse, pMWin, pSrc, pArgs, pTab, &pSublist); pWin->iArgCol = (pSublist ? pSublist->nExpr : 0); pWin->bExprArgs = 1; |