[sqlite] Logging only SQL commands which make changes, parsing PRAGMAs

2012-08-23 Thread Simon Slavin
I'm trying to log SQL commands which might make changes to the database, but 
not those which just read it.  This routine does /not/ need to deal with 
arbitrary tricksy SQL commands generated by third parties, just SQL commands I 
myself have written or my program has generated, intended specifically for 
SQLite.  And I'm going to assume that I will be sensible when I program so my 
commands won't start with spaces or play mind games.

Since this routine introduces load on every SQL command, it's okay to have a 
few false positives (but preferably not false negatives), if this makes the 
test simpler and faster.  So as a first approximation it logged everything 
except commands which start with 'SELECT'.  Which is fine.

But I do PRAGMAs every so often and now I notice a few PRAGMA commands in my 
logs which don't need to be there because they just test modes and schema.  So 
I want to log PRAGMA commands which might change things, and ignore those that 
won't.  So does the list think that simply looking for commands which start 
with 'PRAGMA' and have an '=' in them is a good fast way to do this ?  Or is 
there a better way that's still pretty fast ?

The routine is written in PHP, so I don't have access to the low-level VM parts 
of SQLite to put traps in.

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


Re: [sqlite] Logging only SQL commands which make changes, parsing PRAGMAs

2012-08-23 Thread Kit
2012/8/23 Simon Slavin slav...@bigfraud.org:
 I'm trying to log SQL commands which might make changes to the database, but 
 not those which just read it...
 Simon.

Use triggers.
-- 
Kit
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users