Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | The callback on sqlite3_trace() is invoked the first time sqlite3_step() is called after sqlite3_prepare() or sqlite3_reset(). Ticket #900. (CVS 1960) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
0cc2f40e6afa157ead45140c4e28a9a3 |
User & Date: | drh 2004-09-15 13:38:11.000 |
Context
2004-09-17
| ||
17:23 | The INSERT code generator does a better job of detecting if the table being written into is used in the SELECT on the right-hand side. ticket #901. (CVS 1961) (check-in: 709bb22d6d user: drh tags: trunk) | |
2004-09-15
| ||
13:38 | The callback on sqlite3_trace() is invoked the first time sqlite3_step() is called after sqlite3_prepare() or sqlite3_reset(). Ticket #900. (CVS 1960) (check-in: 0cc2f40e6a user: drh tags: trunk) | |
2004-09-13
| ||
13:46 | Remove the encode/decode from the version 3.0 source tree. (CVS 1959) (check-in: c1f1320be5 user: drh tags: trunk) | |
Changes
Changes to src/build.c.
︙ | ︙ | |||
19 20 21 22 23 24 25 | ** DROP INDEX ** creating ID lists ** BEGIN TRANSACTION ** COMMIT ** ROLLBACK ** PRAGMA ** | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ** DROP INDEX ** creating ID lists ** BEGIN TRANSACTION ** COMMIT ** ROLLBACK ** PRAGMA ** ** $Id: build.c,v 1.253 2004/09/15 13:38:11 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** This routine is called when a new SQL statement is beginning to ** be parsed. Check to see if the schema for the database needs |
︙ | ︙ | |||
77 78 79 80 81 82 83 | if( (mask & pParse->cookieMask)==0 ) continue; sqlite3VdbeAddOp(v, OP_Transaction, iDb, (mask & pParse->writeMask)!=0); sqlite3VdbeAddOp(v, OP_VerifyCookie, iDb, pParse->cookieValue[iDb]); } sqlite3VdbeAddOp(v, OP_Goto, 0, pParse->cookieGoto); } | < | > > < | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | if( (mask & pParse->cookieMask)==0 ) continue; sqlite3VdbeAddOp(v, OP_Transaction, iDb, (mask & pParse->writeMask)!=0); sqlite3VdbeAddOp(v, OP_VerifyCookie, iDb, pParse->cookieValue[iDb]); } sqlite3VdbeAddOp(v, OP_Goto, 0, pParse->cookieGoto); } /* Add a No-op that contains the complete text of the compiled SQL ** statement as its P3 argument. This does not change the functionality ** of the program. ** ** This is used to implement sqlite3_trace() functionality. */ sqlite3VdbeOp3(v, OP_Noop, 0, 0, pParse->zSql, pParse->zTail-pParse->zSql); } /* Get the VDBE program ready for execution */ if( v && pParse->nErr==0 ){ FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stdout : 0; |
︙ | ︙ |
Changes to src/main.c.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** ** $Id: main.c,v 1.260 2004/09/15 13:38:11 drh Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* ** The following constant value is used by the SQLITE_BIGENDIAN and |
︙ | ︙ | |||
976 977 978 979 980 981 982 | if( sqlite3SafetyOn(db) ){ return SQLITE_MISUSE; } memset(&sParse, 0, sizeof(sParse)); sParse.db = db; sqlite3RunParser(&sParse, zSql, &zErrMsg); | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 976 977 978 979 980 981 982 983 984 985 986 987 988 989 | if( sqlite3SafetyOn(db) ){ return SQLITE_MISUSE; } memset(&sParse, 0, sizeof(sParse)); sParse.db = db; sqlite3RunParser(&sParse, zSql, &zErrMsg); if( sqlite3_malloc_failed ){ rc = SQLITE_NOMEM; sqlite3RollbackAll(db); sqlite3ResetInternalSchema(db, 0); db->flags &= ~SQLITE_InTrans; goto prepare_out; |
︙ | ︙ |
Changes to src/vdbeapi.c.
︙ | ︙ | |||
146 147 148 149 150 151 152 153 154 155 156 157 158 159 | } db = p->db; if( sqlite3SafetyOn(db) ){ p->rc = SQLITE_MISUSE; return SQLITE_MISUSE; } if( p->pc<0 ){ db->activeVdbeCnt++; p->pc = 0; } if( p->explain ){ rc = sqlite3VdbeList(p); }else{ rc = sqlite3VdbeExec(p); | > > > > > > > > > > > > > > > > > > > > > > > > | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | } db = p->db; if( sqlite3SafetyOn(db) ){ p->rc = SQLITE_MISUSE; return SQLITE_MISUSE; } if( p->pc<0 ){ /* Invoke the trace callback if there is one */ if( (db = p->db)->xTrace && !db->init.busy ){ assert( p->nOp>0 ); assert( p->aOp[p->nOp-1].opcode==OP_Noop ); assert( p->aOp[p->nOp-1].p3!=0 ); assert( p->aOp[p->nOp-1].p3type==P3_DYNAMIC ); sqlite3SafetyOff(db); db->xTrace(db->pTraceArg, p->aOp[p->nOp-1].p3); if( sqlite3SafetyOn(db) ){ p->rc = SQLITE_MISUSE; return SQLITE_MISUSE; } } /* Print a copy of SQL as it is executed if the SQL_TRACE pragma is turned ** on in debugging mode. */ #ifdef SQLITE_DEBUG if( (db->flags & SQLITE_SqlTrace)!=0 ){ sqlite3DebugPrintf("SQL-trace: %s\n", p->aOp[p->nOp-1].p3); } #endif /* SQLITE_DEBUG */ db->activeVdbeCnt++; p->pc = 0; } if( p->explain ){ rc = sqlite3VdbeList(p); }else{ rc = sqlite3VdbeExec(p); |
︙ | ︙ |
Changes to src/vdbeaux.c.
︙ | ︙ | |||
524 525 526 527 528 529 530 | /* ** Print the SQL that was used to generate a VDBE program. */ void sqlite3VdbePrintSql(Vdbe *p){ #ifdef SQLITE_DEBUG int nOp = p->nOp; VdbeOp *pOp; | | | | 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 | /* ** Print the SQL that was used to generate a VDBE program. */ void sqlite3VdbePrintSql(Vdbe *p){ #ifdef SQLITE_DEBUG int nOp = p->nOp; VdbeOp *pOp; if( nOp<1 ) return; pOp = &p->aOp[nOp-1]; if( pOp->opcode==OP_Noop && pOp->p3!=0 ){ const char *z = pOp->p3; while( isspace(*(u8*)z) ) z++; printf("SQL: [%s]\n", z); } #endif } |
︙ | ︙ | |||
555 556 557 558 559 560 561 | int isExplain /* True if the EXPLAIN keywords is present */ ){ int n; assert( p!=0 ); assert( p->magic==VDBE_MAGIC_INIT ); | | | < < | 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 | int isExplain /* True if the EXPLAIN keywords is present */ ){ int n; assert( p!=0 ); assert( p->magic==VDBE_MAGIC_INIT ); /* There should be at least one opcode. */ assert( p->nOp>0 ); /* No instruction ever pushes more than a single element onto the ** stack. And the stack never grows on successive executions of the ** same loop. So the total number of instructions is an upper bound ** on the maximum stack depth required. ** ** Allocation all the stack space we will ever need. |
︙ | ︙ |
Changes to test/trace.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the "sqlite3_trace()" API. # | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the "sqlite3_trace()" API. # # $Id: trace.test,v 1.3 2004/09/15 13:38:11 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl set ::stmtlist {} do_test trace-1.1 { set rc [catch {db trace 1 2 3} msg] |
︙ | ︙ | |||
34 35 36 37 38 39 40 | CREATE TABLE t1(a,b); INSERT INTO t1 VALUES(1,2); SELECT * FROM t1; } } {1 2} do_test trace-1.4 { set ::stmtlist | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 34 35 36 37 38 39 40 41 42 43 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 74 75 76 77 78 79 80 | CREATE TABLE t1(a,b); INSERT INTO t1 VALUES(1,2); SELECT * FROM t1; } } {1 2} 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 set DB [sqlite3 db test.db] do_test trace-2.1 { set STMT [sqlite3_prepare $DB {INSERT INTO t1 VALUES(2,3)} -1 TAIL] db trace trace_proc proc trace_proc sql { global TRACE_OUT set TRACE_OUT $sql } set TRACE_OUT {} sqlite3_step $STMT set TRACE_OUT } {INSERT INTO t1 VALUES(2,3)} do_test trace-2.2 { set TRACE_OUT {} sqlite3_reset $STMT set TRACE_OUT } {} do_test trace-2.3 { sqlite3_step $STMT set TRACE_OUT } {INSERT INTO t1 VALUES(2,3)} do_test trace-2.4 { execsql {SELECT * FROM t1} } {1 2 2 3 2 3} do_test trace-2.5 { set TRACE_OUT } {SELECT * FROM t1} finish_test |
Changes to www/capi3ref.tcl.
|
| | | 1 2 3 4 5 6 7 8 | set rcsid {$Id: capi3ref.tcl,v 1.12 2004/09/15 13:38:11 drh Exp $} source common.tcl header {C/C++ Interface For SQLite Version 3} puts { <h2>C/C++ Interface For SQLite Version 3</h2> } proc api {name prototype desc {notused x}} { |
︙ | ︙ | |||
1002 1003 1004 1005 1006 1007 1008 | SQLITE_DONE. Or it could be the case the the same database connection is being used simulataneously by two or more threads. } api {} { void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); } { | | > > | | | 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 | SQLITE_DONE. Or it could be the case the the same database connection is being used simulataneously by two or more threads. } api {} { void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); } { Register a function that is called each time an SQL statement is evaluated. The callback function is invoked on the first call to sqlite3_step() after calls to sqlite3_prepare() or sqlite3_reset(). This function can be used (for example) to generate a log file of all SQL executed against a database. This can be useful when debugging an application that uses SQLite. } api {} { void *sqlite3_user_data(sqlite3_context*); } { The pUserData parameter to the sqlite3_create_function() and |
︙ | ︙ |