1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Report an error if the number of named columns in a VIEW is different

from the number of result columns in the SELECT statement that implements
the VIEW.

FossilOrigin-Name: 6e4ac0be2de1a16fcbb2a314504122ad95aa257e
This commit is contained in:
drh
2015-09-25 13:42:55 +00:00
parent 8ffddeb708
commit 2679f14fd9
4 changed files with 28 additions and 8 deletions

View File

@@ -4861,7 +4861,17 @@ int sqlite3Select(
struct SrcList_item *pItem = &pTabList->a[i];
Select *pSub = pItem->pSelect;
int isAggSub;
Table *pTab = pItem->pTab;
if( pSub==0 ) continue;
/* Catch mismatch in the declared columns of a view and the number of
** columns in the SELECT on the RHS */
if( pTab->nCol!=pSub->pEList->nExpr ){
sqlite3ErrorMsg(pParse, "expected %d columns for '%s' but got %d",
pTab->nCol, pTab->zName, pSub->pEList->nExpr);
goto select_end;
}
isAggSub = (pSub->selFlags & SF_Aggregate)!=0;
if( flattenSubquery(pParse, p, i, isAgg, isAggSub) ){
/* This subquery can be absorbed into its parent. */