aboutsummaryrefslogtreecommitdiff
path: root/src/trigger.c
diff options
context:
space:
mode:
authordrh <>2021-03-30 01:52:21 +0000
committerdrh <>2021-03-30 01:52:21 +0000
commit0d23f678b1d26a469a801c1e80f46003c55cf2e1 (patch)
tree7d876ff31dc8436162b51c10086ba019f7e70153 /src/trigger.c
parent28a314e74da9dc2875d47365c9c6520a00a94df6 (diff)
downloadsqlite-0d23f678b1d26a469a801c1e80f46003c55cf2e1.tar.gz
sqlite-0d23f678b1d26a469a801c1e80f46003c55cf2e1.zip
Raise an error if a term of the form "TABLE.*" appears in the RETURNING clause,
as SQLite does not (yet) know how to handle that. Ticket [132994c8b1063bfb]. FossilOrigin-Name: 3039bcaff95bb5d096c80b5eefdaeda6abd1d1337e829f32fd28a968f663f481
Diffstat (limited to 'src/trigger.c')
-rw-r--r--src/trigger.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/trigger.c b/src/trigger.c
index 562084561..3acdf1431 100644
--- a/src/trigger.c
+++ b/src/trigger.c
@@ -823,6 +823,25 @@ SrcList *sqlite3TriggerStepSrc(
return pSrc;
}
+/*
+** Return true if the pExpr term from the RETURNING clause argument
+** list is of the form "*". Raise an error if the terms if of the
+** form "table.*".
+*/
+static int isAsteriskTerm(
+ Parse *pParse, /* Parsing context */
+ Expr *pTerm /* A term in the RETURNING clause */
+){
+ assert( pTerm!=0 );
+ if( pTerm->op==TK_ASTERISK ) return 1;
+ if( pTerm->op!=TK_DOT ) return 0;
+ assert( pTerm->pRight!=0 );
+ assert( pTerm->pLeft!=0 );
+ if( pTerm->pRight->op!=TK_ASTERISK ) return 0;
+ sqlite3ErrorMsg(pParse, "RETURNING may not use \"TABLE.*\" wildcards");
+ return 1;
+}
+
/* The input list pList is the list of result set terms from a RETURNING
** clause. The table that we are returning from is pTab.
**
@@ -840,7 +859,8 @@ static ExprList *sqlite3ExpandReturning(
for(i=0; i<pList->nExpr; i++){
Expr *pOldExpr = pList->a[i].pExpr;
- if( ALWAYS(pOldExpr!=0) && pOldExpr->op==TK_ASTERISK ){
+ if( NEVER(pOldExpr==0) ) continue;
+ if( isAsteriskTerm(pParse, pOldExpr) ){
int jj;
for(jj=0; jj<pTab->nCol; jj++){
Expr *pNewExpr;