aboutsummaryrefslogtreecommitdiff
path: root/src/resolve.c
diff options
context:
space:
mode:
authordan <Dan Kennedy>2024-10-05 18:10:02 +0000
committerdan <Dan Kennedy>2024-10-05 18:10:02 +0000
commitd564bdb0507aabce5d64905734d5d7e050a2c86d (patch)
tree30cf80a5761d65c2b9caffb15df0d5fa02a87c2a /src/resolve.c
parentc857b9eb5d9cfab1366fb80e5d1c306e340b6d65 (diff)
downloadsqlite-d564bdb0507aabce5d64905734d5d7e050a2c86d.tar.gz
sqlite-d564bdb0507aabce5d64905734d5d7e050a2c86d.zip
Allow expressions with subtypes to be read from indexes unless they are being used as direct or indirect parameters to SQLITE_SUBTYPE functions.
FossilOrigin-Name: aa440e78e9004c7ca3e03beaf264f54d0070ad7298a3c96ca097d8b35c872e5f
Diffstat (limited to 'src/resolve.c')
-rw-r--r--src/resolve.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/resolve.c b/src/resolve.c
index 8e8da6691..d6a5144af 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -1183,6 +1183,24 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
}
}
#endif
+
+ /* If the function may call sqlite3_value_subtype(), then set the
+ ** EP_SubtArg flag on all of its argument expressions. This prevents
+ ** where.c from replacing the expression with a value read from an
+ ** index on the same expression, which will not have the correct
+ ** subtype. Also set the flag if the function expression itself is
+ ** an EP_SubtArg expression. In this case subtypes are required as
+ ** the function may return a value with a subtype back to its
+ ** caller using sqlite3_result_value(). */
+ if( (pDef->funcFlags & SQLITE_SUBTYPE)
+ || ExprHasProperty(pExpr, EP_SubtArg)
+ ){
+ int ii;
+ for(ii=0; ii<n; ii++){
+ ExprSetProperty(pList->a[ii].pExpr, EP_SubtArg);
+ }
+ }
+
if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) ){
/* For the purposes of the EP_ConstFunc flag, date and time
** functions and other functions that change slowly are considered