mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Fix a case where SQLite was failing to detect a syntax error in queries like "SELECT ... FROM (<select-1> UNION ALL <select-2>)" when <select-1> and <select-2> return different numbers of result columns.
FossilOrigin-Name: 200a81358c3117401d2258dd06bb8d2ea4f0ef51
This commit is contained in:
@@ -2689,6 +2689,12 @@ static void substSelect(
|
||||
** operators have an implied DISTINCT which is disallowed by
|
||||
** restriction (4).
|
||||
**
|
||||
** Also, each component of the sub-query must return the same number
|
||||
** of result columns. This is actually a requirement for any compound
|
||||
** SELECT statement, but all the code here does is make sure that no
|
||||
** such (illegal) sub-query is flattened. The caller will detect the
|
||||
** syntax error and return a detailed message.
|
||||
**
|
||||
** (18) If the sub-query is a compound select, then all terms of the
|
||||
** ORDER by clause of the parent must be simple references to
|
||||
** columns of the sub-query.
|
||||
@@ -2832,6 +2838,7 @@ static int flattenSubquery(
|
||||
if( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))!=0
|
||||
|| (pSub1->pPrior && pSub1->op!=TK_ALL)
|
||||
|| pSub1->pSrc->nSrc<1
|
||||
|| pSub->pEList->nExpr!=pSub1->pEList->nExpr
|
||||
){
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user