On Wed, Oct 07, 2015 at 04:58:10PM +0300, Aki Tuomi wrote: > On Wed, Oct 07, 2015 at 09:35:54AM -0400, Richard Hipp wrote: > > On 10/7/15, Aki Tuomi <cmouse at cmouse.fi> wrote: > > > > > > Is there any way to see whether sqlite3_trace has been attached to a > > > particular connection? > > > > > > > Perhaps run "sqlite3_exec(db, "SELECT 'trace-test';",0,0,0)" and see > > if you get a trace callback? > > > > Problem is that I can see the trace on some queries, but not on all. I have > tried to make sure there is only one, and only one database connection, but > I would like to ensure somehow that there isn't anything fishy going on. > > We use persistent SQL statements on our code, which means they are prepared > once during SQL connection lifetime. Can this cause any issues? > > Basically our quries follow this cycle: > > bind > bind > ... > execute > fetch > reset > clear bindings > > I changed the code to set the trace every time before sqlite3_step in execute > and got the following result: > > SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE > disabled=0 and type=:qtype and name=:qname > <no trace> > > SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE > disabled=0 and type=:qtype and name=:qname > Oct 07 16:53:20 Query: SELECT > content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE > disabled=0 and type='SOA' and name='example.com' > > SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE > disabled=0 and type=:qtype and name=:qname and domain_id=:domain_id > <no trace> > > SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE > disabled=0 and name=:qname and domain_id=:domain_id > <no trace> > > I am now extremely puzzled why my_trace is not being called more than once. > > By abusing the sqliteInt.h from sources I was able to also ensure that xTrace > is set before sqlite3_step is called. >
Abusing bit more it would seem that when it's not logging, it's going thru sqlite3Reprepare and doing a rerun. Wonder if this causes the logging be suppressed? See http://p.ip.fi/bt6b Aki