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

Fix the typeof() and length() optimization so that it works for aggregates

as well as scalar queries.

FossilOrigin-Name: bc18215a8a660442db6ddeeda4a88df0acffe0f7
This commit is contained in:
drh
2012-03-28 02:43:20 +00:00
parent a748fdcc43
commit 31ec740a3d
3 changed files with 10 additions and 8 deletions

View File

@@ -2599,9 +2599,11 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
** loading.
*/
if( (pDef->flags & (SQLITE_FUNC_LENGTH|SQLITE_FUNC_TYPEOF))!=0 ){
u8 op;
assert( nFarg==1 );
assert( pFarg->a[0].pExpr!=0 );
if( pFarg->a[0].pExpr->op==TK_COLUMN ){
op = pFarg->a[0].pExpr->op;
if( op==TK_COLUMN || op==TK_AGG_COLUMN ){
assert( SQLITE_FUNC_LENGTH==OPFLAG_LENGTHARG );
assert( SQLITE_FUNC_TYPEOF==OPFLAG_TYPEOFARG );
testcase( pDef->flags==SQLITE_FUNC_LENGTH );