aboutsummaryrefslogtreecommitdiff
path: root/src/resolve.c
diff options
context:
space:
mode:
authordrh <>2024-10-08 10:10:42 +0000
committerdrh <>2024-10-08 10:10:42 +0000
commiteaefd9ccc8cc73ecb17bdfceabcaff4d5285e837 (patch)
tree9301f1ec78df6f944ca0b424b8f12233cfdb5b4f /src/resolve.c
parent2813eb3c9e64a706fdec47b3075ab33f1013d2af (diff)
parent7998b889e884b5752ac3c11da443022343ba1b8a (diff)
downloadsqlite-eaefd9ccc8cc73ecb17bdfceabcaff4d5285e837.tar.gz
sqlite-eaefd9ccc8cc73ecb17bdfceabcaff4d5285e837.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: 39a56a23fec24dd713905457b6d4ed7c148f88e325a26c376f1e6daf147c69c8
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