SQLite

Check-in [0d4d3df4bc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Make sure the sqlite3_trace() callback is invoked, even if the prepared statement was marked "expired" before it ever entered sqlite3_step(). Ticket [11d5aa455e0d98f3c1e6a08].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0d4d3df4bc5e75ce1543b5539a1e9e279d2a062f
User & Date: drh 2014-08-19 20:27:40.455
Context
2014-08-19
20:41
A better fix for the sqlite3_trace() problem. Ticket [11d5aa455e0d98f3c1e6a] (check-in: 44d5bd4cc3 user: drh tags: trunk)
20:27
Make sure the sqlite3_trace() callback is invoked, even if the prepared statement was marked "expired" before it ever entered sqlite3_step(). Ticket [11d5aa455e0d98f3c1e6a08]. (check-in: 0d4d3df4bc user: drh tags: trunk)
19:28
Improvements to output formatting with the ".trace" command in the command-line shell. (check-in: d09d63c077 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbeapi.c.
509
510
511
512
513
514
515
516

517

518
519
520
521
522
523
524
525
526
  if( vdbeSafetyNotNull(v) ){
    return SQLITE_MISUSE_BKPT;
  }
  db = v->db;
  sqlite3_mutex_enter(db->mutex);
  v->doingRerun = 0;
  while( (rc = sqlite3Step(v))==SQLITE_SCHEMA
         && cnt++ < SQLITE_MAX_SCHEMA_RETRY

         && (rc2 = rc = sqlite3Reprepare(v))==SQLITE_OK ){

    sqlite3_reset(pStmt);
    v->doingRerun = 1;
    assert( v->expired==0 );
  }
  if( rc2!=SQLITE_OK ){
    /* This case occurs after failing to recompile an sql statement. 
    ** The error message from the SQL compiler has already been loaded 
    ** into the database handle. This block copies the error message 
    ** from the database handle into the statement and sets the statement







|
>
|
>

|







509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
  if( vdbeSafetyNotNull(v) ){
    return SQLITE_MISUSE_BKPT;
  }
  db = v->db;
  sqlite3_mutex_enter(db->mutex);
  v->doingRerun = 0;
  while( (rc = sqlite3Step(v))==SQLITE_SCHEMA
         && cnt++ < SQLITE_MAX_SCHEMA_RETRY ){
    int savedPc = v->pc;
    rc2 = rc = sqlite3Reprepare(v);
    if( rc!=SQLITE_OK) break;
    sqlite3_reset(pStmt);
    v->doingRerun = savedPc>=0;
    assert( v->expired==0 );
  }
  if( rc2!=SQLITE_OK ){
    /* This case occurs after failing to recompile an sql statement. 
    ** The error message from the SQL compiler has already been loaded 
    ** into the database handle. This block copies the error message 
    ** from the database handle into the statement and sets the statement
Changes to test/trace.test.
44
45
46
47
48
49
50
















51
52
53
54
55
56
57
do_test trace-1.4 {
  set ::stmtlist
} {{CREATE TABLE t1(a,b);} {INSERT INTO t1 VALUES(1,2);} {SELECT * FROM t1;}}
do_test trace-1.5 {
  db trace {}
  db trace
} {}

















# If we prepare a statement and execute it multiple times, the trace
# happens on each execution.
#
db close
sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
do_test trace-2.1 {







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
do_test trace-1.4 {
  set ::stmtlist
} {{CREATE TABLE t1(a,b);} {INSERT INTO t1 VALUES(1,2);} {SELECT * FROM t1;}}
do_test trace-1.5 {
  db trace {}
  db trace
} {}
do_test trace-1.6 {
  db eval {
     CREATE TABLE t1b(x TEXT PRIMARY KEY, y);
     INSERT INTO t1b VALUES('abc','def'),('ghi','jkl'),('mno','pqr');
  }
  set ::stmtlist {}
  set xyzzy a*
  db trace trace_proc
  db eval {
     SELECT y FROM t1b WHERE x GLOB $xyzzy
  }
} {def}
do_test trace-1.7 {
  set ::stmtlist
} {{SELECT y FROM t1b WHERE x GLOB 'a*'}}
db trace {}

# If we prepare a statement and execute it multiple times, the trace
# happens on each execution.
#
db close
sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
do_test trace-2.1 {