SQLite

Check-in [bc18215a8a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix the typeof() and length() optimization so that it works for aggregates as well as scalar queries.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | faster-typeof-and-length
Files: files | file ages | folders
SHA1: bc18215a8a660442db6ddeeda4a88df0acffe0f7
User & Date: drh 2012-03-28 02:43:20.877
Context
2012-03-28
02:51
Test cases for length() of a large blob in an aggregate query. (check-in: d095fa4bfa user: drh tags: faster-typeof-and-length)
02:43
Fix the typeof() and length() optimization so that it works for aggregates as well as scalar queries. (check-in: bc18215a8a user: drh tags: faster-typeof-and-length)
01:34
Evaluate typeof(X) and length(Y) where X is any column and Y is a blob column without actually loading X and Y from disk. (check-in: b899dbeb60 user: drh tags: faster-typeof-and-length)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/expr.c.
2595
2596
2597
2598
2599
2600
2601

2602
2603
2604

2605
2606
2607
2608
2609
2610
2611

        /* For length() and typeof() functions with a column argument,
        ** set the P5 parameter to the OP_Column opcode to OPFLAG_LENGTHARG
        ** or OPFLAG_TYPEOFARG respectively, to avoid unnecessary data
        ** loading.
        */
        if( (pDef->flags & (SQLITE_FUNC_LENGTH|SQLITE_FUNC_TYPEOF))!=0 ){

          assert( nFarg==1 );
          assert( pFarg->a[0].pExpr!=0 );
          if( pFarg->a[0].pExpr->op==TK_COLUMN ){

            assert( SQLITE_FUNC_LENGTH==OPFLAG_LENGTHARG );
            assert( SQLITE_FUNC_TYPEOF==OPFLAG_TYPEOFARG );
            testcase( pDef->flags==SQLITE_FUNC_LENGTH );
            pFarg->a[0].pExpr->op2 = pDef->flags;
          }
        }








>


|
>







2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613

        /* For length() and typeof() functions with a column argument,
        ** set the P5 parameter to the OP_Column opcode to OPFLAG_LENGTHARG
        ** or OPFLAG_TYPEOFARG respectively, to avoid unnecessary data
        ** loading.
        */
        if( (pDef->flags & (SQLITE_FUNC_LENGTH|SQLITE_FUNC_TYPEOF))!=0 ){
          u8 op;
          assert( nFarg==1 );
          assert( pFarg->a[0].pExpr!=0 );
          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 );
            pFarg->a[0].pExpr->op2 = pDef->flags;
          }
        }