aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <>2023-10-18 13:18:52 +0000
committerdrh <>2023-10-18 13:18:52 +0000
commitf8202f1ff3ff84908ff1038886f6c6c01eba8dc2 (patch)
tree42f4fc6905198c62a4547c91140fa90e8d62df45 /src/expr.c
parent0b4de1acac7da83cfaf72cbd00d1d1f2fd456b1a (diff)
downloadsqlite-f8202f1ff3ff84908ff1038886f6c6c01eba8dc2.tar.gz
sqlite-f8202f1ff3ff84908ff1038886f6c6c01eba8dc2.zip
Enhance the parser so that it can accept an ORDER BY clause on a function
invocation. For this incremental check-in, the ORDER BY clause is currently ignored. FossilOrigin-Name: 3a98ff24bf468ed42d410a9a12d9f9b2ca154c7babe99fd6bc6f7b0565e0d132
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/expr.c b/src/expr.c
index f7290262e..07b6dfcef 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -1182,6 +1182,44 @@ Expr *sqlite3ExprFunction(
}
/*
+** Attach an ORDER BY clause to a function call.
+**
+** functionname( arguments ORDER BY sortlist )
+** \_____________________/ \______/
+** pExpr pOrderBy
+**
+** The ORDER BY clause is inserted into a new Expr node of type TK_ORDER
+** and added to the Expr.pLeft field of the parent TK_FUNCTION node.
+*/
+void sqlite3ExprAddFunctionOrderBy(
+ Parse *pParse, /* Parsing context */
+ Expr *pExpr, /* The function call to which ORDER BY is to be added */
+ ExprList *pOrderBy /* The ORDER BY clause to add */
+){
+ Expr *pOB;
+ sqlite3 *db = pParse->db;
+ if( pOrderBy==0 ){
+ assert( db->mallocFailed );
+ return;
+ }
+ if( pExpr==0 ){
+ assert( db->mallocFailed );
+ sqlite3ExprListDelete(db, pOrderBy);
+ return;
+ }
+ assert( pExpr->op==TK_FUNCTION );
+ assert( pExpr->pLeft==0 );
+ pOB = sqlite3ExprAlloc(db, TK_ORDER, 0, 0);
+ if( pOB==0 ){
+ sqlite3ExprListDelete(db, pOrderBy);
+ return;
+ }
+ pOB->x.pList = pOrderBy;
+ assert( ExprUseXList(pOB) );
+ pExpr->pLeft = pOB;
+}
+
+/*
** Check to see if a function is usable according to current access
** rules:
**