aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <>2023-03-01 15:21:53 +0000
committerdrh <>2023-03-01 15:21:53 +0000
commitfe373482552e7b254cf6d3f94ca734014a58250b (patch)
tree30b4045e120f591466052042bd8c753e0f02ebb0 /src/expr.c
parent46960e4677ec68a7b4139a9310d5d728bd25ef03 (diff)
downloadsqlite-fe373482552e7b254cf6d3f94ca734014a58250b.tar.gz
sqlite-fe373482552e7b254cf6d3f94ca734014a58250b.zip
Follow-up to [bbaf1f2eb1e1637b]: Make sure subtypes do not cross a subquery
boundary even if the function that returned the value with a subtype is buried down inside a larger expression. This fixes a problem identified by [forum:/forumpost/37dd14a538|forum post 37dd14a538]. FossilOrigin-Name: e72661eb680ea707a839cb3d5cf6c7ef03706e7b40af1b84760147e59cd61a50
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/expr.c b/src/expr.c
index ea3c90167..763e961b6 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -4719,10 +4719,13 @@ expr_code_doover:
return target;
}
case TK_COLLATE: {
- if( !ExprHasProperty(pExpr, EP_Collate)
- && ALWAYS(pExpr->pLeft)
- && pExpr->pLeft->op==TK_FUNCTION
- ){
+ if( !ExprHasProperty(pExpr, EP_Collate) ){
+ /* A TK_COLLATE Expr node without the EP_Collate tag is a so-called
+ ** "SOFT-COLLATE" that is added to constraints that are pushed down
+ ** from outer queries into sub-queries by the push-down optimization.
+ ** Clear subtypes as subtypes may not cross a subquery boundary.
+ */
+ assert( pExpr->pLeft );
inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
if( inReg!=target ){
sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target);