Earlier detection of a misplaced ORDER BY or LIMIT clause in a compound
SELECT. This prevents problems in recursive CTEs with multiple recursive terms in which there is an ORDER BY or LIMIT clause on the last non-recursive term. FossilOrigin-Name: e893f88750ea64d45922429e022c585748974016404f2a2b7952f5a227865246
This commit is contained in:
+13
-3
@@ -497,11 +497,21 @@ cmd ::= select(X). {
|
||||
static void parserDoubleLinkSelect(Parse *pParse, Select *p){
|
||||
assert( p!=0 );
|
||||
if( p->pPrior ){
|
||||
Select *pNext = 0, *pLoop;
|
||||
int mxSelect, cnt = 0;
|
||||
for(pLoop=p; pLoop; pNext=pLoop, pLoop=pLoop->pPrior, cnt++){
|
||||
Select *pNext = 0, *pLoop = p;
|
||||
int mxSelect, cnt = 1;
|
||||
while(1){
|
||||
pLoop->pNext = pNext;
|
||||
pLoop->selFlags |= SF_Compound;
|
||||
pNext = pLoop;
|
||||
pLoop = pLoop->pPrior;
|
||||
if( pLoop==0 ) break;
|
||||
cnt++;
|
||||
if( pLoop->pOrderBy || pLoop->pLimit ){
|
||||
sqlite3ErrorMsg(pParse,"%s clause should come after %s not before",
|
||||
pLoop->pOrderBy!=0 ? "ORDER BY" : "LIMIT",
|
||||
sqlite3SelectOpName(pNext->op));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( (p->selFlags & SF_MultiValue)==0 &&
|
||||
(mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0 &&
|
||||
|
||||
Reference in New Issue
Block a user