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

Prevent the flattening or where-term push-down optimizations from obscuring

misuses of SQL row values that can lead to crashes or assert() failures.

FossilOrigin-Name: 433d16ff3adfede3be53d5b0e0512f37e225591b
This commit is contained in:
dan
2016-12-07 15:38:37 +00:00
parent 9314bd5fe2
commit 44c5604ced
6 changed files with 96 additions and 46 deletions

View File

@@ -2355,6 +2355,28 @@ void sqlite3SubselectError(Parse *pParse, int nActual, int nExpect){
}
#endif
/*
** Expression pExpr is a vector that has been used in a context where
** it is not permitted. If pExpr is a sub-select vector, this routine
** loads the Parse object with a message of the form:
**
** "sub-select returns N columns - expected 1"
**
** Or, if it is a regular scalar vector:
**
** "row value misused"
*/
void sqlite3VectorErrorMsg(Parse *pParse, Expr *pExpr){
#ifndef SQLITE_OMIT_SUBQUERY
if( pExpr->flags & EP_xIsSelect ){
sqlite3SubselectError(pParse, pExpr->x.pSelect->pEList->nExpr, 1);
}else
#endif
{
sqlite3ErrorMsg(pParse, "row value misused");
}
}
/*
** Generate code for scalar subqueries used as a subquery expression, EXISTS,
** or IN operators. Examples:
@@ -2637,11 +2659,7 @@ int sqlite3ExprCheckIN(Parse *pParse, Expr *pIn){
return 1;
}
}else if( nVector!=1 ){
if( (pIn->pLeft->flags & EP_xIsSelect) ){
sqlite3SubselectError(pParse, nVector, 1);
}else{
sqlite3ErrorMsg(pParse, "row value misused");
}
sqlite3VectorErrorMsg(pParse, pIn->pLeft);
return 1;
}
return 0;