On Mon, Nov 10, 2014 at 4:40 AM, Prakash Premkumar <prakash.p...@gmail.com>
wrote:

> The where clause in sqlite is encoded as a tree
>
> Let's say I have select statement like :
>
> SELECT * from employee where salary = 3+5*4+3;
>
> The tree which takes care of operator precedence is :
>
>                            =
>                          /    \
>               salary        +
>                              /   \
>                            3     3
>                           /
>                          *
>                       /    \
>                      5     4
>


No.

If you recompile the SQLite command-line shell (sqlite3.exe) using the
-DSQLITE_ENABLE_SELECTTRACE option, then you can enter:

   CREATE TABLE employee(employee_id,salary);
   .selecttrace 0x100
   SELECT * FROM employee WHERE salary = 3+5*4+3;


The ".selecttrace 0x100" line will cause SQLite to print out its parse tree
using ascii-art.  The result:

'-- SELECT
    |-- result-set
    |   '-- op=116
    |-- FROM
    |   '-- {-1,*} employee
    '-- WHERE
        '-- EQ
            |-- ID 'salary'
            '-- ADD
                |-- ADD
                |   |-- 3
                |   '-- MUL
                |       |-- 5
                |       '-- 4
                '-- 3



-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to