On Fri, Sep 21, 2012 at 10:22 AM, Marco Bambini <ma...@sqlabs.net> wrote:
> Can I parse the output of the EXPLAIN my_query statement in order to have > an indirect access to columns involved in the WHERE clause? > You could use EXPLAIN QUERY PLAN, but they would only tell you which terms were used for indexing. And furthermore, the output format of EXPLAIN QUERY PLAN is not guaranteed to be stable. We don't change it except for good reason, but some times good reasons arise, and so you cannot depend on the output format staying the same forever. You could also use the EXPLAIN output to look at the raw VDBE code, and especially in the comment field for OP_Column opcodes. But, the comment field is only filled in if you compile with SQLITE_DEBUG, and even then you don't know if the column is used in the WHERE clause or perhaps somewhere else in the statement. > > -- > Marco Bambini > http://www.sqlabs.com > http://twitter.com/sqlabs > > > > On Sep 21, 2012, at 4:10 PM, Richard Hipp <d...@sqlite.org> wrote: > > > On Fri, Sep 21, 2012 at 9:56 AM, Marco Bambini <ma...@sqlabs.net> wrote: > > > >> Hello, > >> is there a way to extract column names involved in a WHERE clause of a > >> query without manually parse the select statement? > >> > >> For example from a query like: > >> SELECT * FROM myTable WHERE col1=… AND col2=…; > >> I would need to extract both col1 and col2. > >> > >> There are no APIs in SQLite to do that. No. I think you have to parse > > the SQL yourself. > > > > > > > >> Thanks. > >> -- > >> Marco Bambini > >> http://www.sqlabs.com > >> > >> > >> > >> > >> > >> > >> > >> > >> _______________________________________________ > >> sqlite-users mailing list > >> sqlite-users@sqlite.org > >> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > >> > > > > > > > > -- > > D. Richard Hipp > > d...@sqlite.org > > _______________________________________________ > > sqlite-users mailing list > > sqlite-users@sqlite.org > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > > > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users