aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sqlite.h.in6
-rw-r--r--src/vdbeapi.c10
2 files changed, 16 insertions, 0 deletions
diff --git a/src/sqlite.h.in b/src/sqlite.h.in
index 09e6f4765..0932a2cb2 100644
--- a/src/sqlite.h.in
+++ b/src/sqlite.h.in
@@ -6228,6 +6228,12 @@ int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
** 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.
+**
+** If SQLite is compiled with -DSQLITE_STRICT_SUBTYPE=1, then any
+** SQL function that invokes the sqlite3_result_subtype() interface
+** and that does not have the SQLITE_RESULT_SUBTYPE property will raise
+** an error. Future versions of SQLite might enable -DSQLITE_STRICT_SUBTYPE=1
+** by default.
*/
void sqlite3_result_subtype(sqlite3_context*,unsigned int);
diff --git a/src/vdbeapi.c b/src/vdbeapi.c
index 6724035fd..af717734e 100644
--- a/src/vdbeapi.c
+++ b/src/vdbeapi.c
@@ -539,6 +539,16 @@ void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){
#ifdef SQLITE_ENABLE_API_ARMOR
if( pCtx==0 ) return;
#endif
+#if defined(SQLITE_STRICT_SUBTYPE) && SQLITE_STRICT_SUBTYPE+0!=0
+ if( (pCtx->pFunc->funcFlags & SQLITE_RESULT_SUBTYPE)==0 ){
+ char zErr[200];
+ sqlite3_snprintf(sizeof(zErr), zErr,
+ "misuse of sqlite3_result_subtype() by %s()",
+ pCtx->pFunc->zName);
+ sqlite3_result_error(pCtx, zErr, -1);
+ return;
+ }
+#endif /* SQLITE_STRICT_SUBTYPE */
pOut = pCtx->pOut;
assert( sqlite3_mutex_held(pOut->db->mutex) );
pOut->eSubtype = eSubtype & 0xff;