On 30 Jun 2011, at 10:28, Igor Tandetnik wrote:

> On 6/30/2011 1:15 PM, Simon Gornall wrote:
>> Is it possible to get the columns operated on by a WHERE clause from the 
>> sqlite3_stmt once it's been prepared ?
>> 
>> I looked at the sqlite3_set_authorizer, but it doesn't seem to have
>> an action code for examining WHERE - the only codes that use
>> column/table info are UPDATE (which I already know) and READ (I don't
>> know what this is used for but it sounds more general than I'd
>> need).
> 
> READ action gives you the columns that the statement needs to read, for 
> any reason. They may be mentioned in SELECT, WHERE, ORDER BY, LIMIT, ON 
> and other clauses - whenever an expression is allowed by the syntax.
> 
> Seems to be just what you need.

Well, perhaps I'm missing something, but if the statement for which I'm caching 
results was something like 

        SELECT * FROM tableName WHERE columnName = zzz;

I'd only want to clear the results cache when statements like:

        UPDATE tableName set columnName = xxx where id=yyy;

were processed. I'd specifically *not* want to clear the results-cache for the 
above statement when I got:

        UPDATE tableName set otherColumnName = xxx where id = yyy;

...because changing values in the column 'otherColumnName' can't affect the 
results-list for a query only dependent on the column 'columnName'.


And I think the READ action would give me all the columns (because * was 
selected) when processing the SELECT statement. In order to cross-match the 
columns-for-the-select-statement and the columns-for-the-update, I need to know 
only the columns in the criteria part of the SELECT statement, not those used 
by any clause in the SELECT.



On 30 Jun 2011, at 10:23, Richard Hipp wrote:

> 

> Would the update_hook be helpful here?
> 
>    http://www.sqlite.org/c3ref/update_hook.html

Well, I actually know the columns being updated at the update-stage already. 
What I don't know is the set of columns that correspond to the criteria part of 
the query statement for which I'm caching results. The update-hook doesn't 
really help anyway (for this, I'm planning on using it for other stuff later 
[grin]) because it only provides the {database|table|row-id} information, not 
the columns-within-the-update statement.

Cheers
        Simon


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

Reply via email to