Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch trigger-trace Excluding Merge-Ins
This is equivalent to a diff from 0d1ad13a29 to 74ad80eb74
2017-01-21
| ||
16:27 | Change sqlite3_blob_reopen() to call sqlite3VdbeExec() directly rather than going through sqlite3_step(). Performance enhancement. (check-in: 347df3c1fd user: drh tags: trunk) | |
16:21 | Fix problems in the previous commit. (Leaf check-in: 74ad80eb74 user: dan tags: trigger-trace) | |
15:58 | Add extra (somewhat inefficient) trace callbacks for triggers if SQLITE_TRACE_TRIGGER is defined. (check-in: ffda1d1e1c user: dan tags: trigger-trace) | |
15:55 | In the kvtest.c test utility, reuse the buffer into which blobs are read, rather than reallocating it for each row. This is a closer match to how other test programs work, and thus provides a better comparison. (check-in: 0d1ad13a29 user: drh tags: trunk) | |
14:11 | Remove an unnecessary sqlite3_bind_int64() call from sqlite3_blob_open(). Also other minor refactoring of the sqlite3_blob implementation. (check-in: 9d197a5323 user: drh tags: trunk) | |
Changes to src/shell.c.
610 610 typedef struct ShellState ShellState; 611 611 struct ShellState { 612 612 sqlite3 *db; /* The database */ 613 613 int echoOn; /* True to echo input commands */ 614 614 int autoExplain; /* Automatically turn on .explain mode */ 615 615 int autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */ 616 616 int statsOn; /* True to display memory stats before each finalize */ 617 + int vmstepsOn; /* Display VM steps before each finalize */ 617 618 int scanstatsOn; /* True to display scan stats before each finalize */ 618 619 int countChanges; /* True to display change counts */ 619 620 int backslashOn; /* Resolve C-style \x escapes in SQL input text */ 620 621 int outCount; /* Revert to stdout when reaching zero */ 621 622 int cnt; /* Number of records displayed so far */ 622 623 FILE *out; /* Write results here */ 623 624 FILE *traceOut; /* Output for sqlite3_trace() */ ................................................................................ 1992 1993 exec_prepared_stmt(pArg, pStmt, xCallback); 1993 1994 explain_data_delete(pArg); 1994 1995 1995 1996 /* print usage stats if stats on */ 1996 1997 if( pArg && pArg->statsOn ){ 1997 1998 display_stats(db, pArg, 0); 1998 1999 } 2000 + 2001 + if( pArg && pArg->vmstepsOn && pStmt ){ 2002 + int iCur = sqlite3_stmt_status(pStmt, SQLITE_STMTSTATUS_VM_STEP, 0); 2003 + FILE *out = pArg->traceOut ? pArg->traceOut : pArg->out; 2004 + raw_printf(out, "VM steps: %d\n", iCur); 2005 + } 1999 2006 2000 2007 /* print loop-counters if required */ 2001 2008 if( pArg && pArg->scanstatsOn ){ 2002 2009 display_scanstats(db, pArg); 2003 2010 } 2004 2011 2005 2012 /* Finalize the statement just executed. If this fails, save a ................................................................................ 5334 5341 sqlite3_file_control(p->db, zDbName, SQLITE_FCNTL_VFSNAME, &zVfsName); 5335 5342 if( zVfsName ){ 5336 5343 utf8_printf(p->out, "%s\n", zVfsName); 5337 5344 sqlite3_free(zVfsName); 5338 5345 } 5339 5346 } 5340 5347 }else 5348 + 5349 + if( c=='v' && strncmp(azArg[0], "vmsteps", n)==0 ){ 5350 + if( nArg==2 ){ 5351 + p->vmstepsOn = booleanValue(azArg[1]); 5352 + }else{ 5353 + raw_printf(stderr, "Usage: .vmsteps ?on|off?\n"); 5354 + rc = 1; 5355 + } 5356 + }else 5357 + 5341 5358 5342 5359 #if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE) 5343 5360 if( c=='w' && strncmp(azArg[0], "wheretrace", n)==0 ){ 5344 5361 sqlite3WhereTrace = nArg>=2 ? booleanValue(azArg[1]) : 0xff; 5345 5362 }else 5346 5363 #endif 5347 5364
Changes to src/vdbe.c.
956 956 if( pOp->p1==SQLITE_OK && p->pFrame ){ 957 957 /* Halt the sub-program. Return control to the parent frame. */ 958 958 pFrame = p->pFrame; 959 959 p->pFrame = pFrame->pParent; 960 960 p->nFrame--; 961 961 sqlite3VdbeSetChanges(db, p->nChange); 962 962 pcx = sqlite3VdbeFrameRestore(pFrame); 963 +#ifdef SQLITE_TRACE_TRIGGER 964 + if( (db->mTrace & SQLITE_TRACE_STMT) && aOp[0].p4.z ){ 965 + int nTotal = nVmStep - pFrame->nVmStep; 966 + char *zTrace; 967 + assert( nTotal>=0 ); 968 + assert( db->xTrace ); 969 + zTrace = sqlite3_mprintf("%.*s%s completed (VM steps: total=%d self=%d)", 970 + p->nFrame, " :", 971 + aOp[0].p4.z, nTotal, nVmStep - pFrame->nVmStepAdj 972 + ); 973 + if( zTrace ){ 974 + (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, 0, zTrace); 975 + sqlite3_free(zTrace); 976 + } 977 + if( p->pFrame ){ 978 + p->pFrame->nVmStepAdj += nTotal; 979 + } 980 + } 981 +#endif 963 982 lastRowid = db->lastRowid; 964 983 if( pOp->p2==OE_Ignore ){ 965 984 /* Instruction pcx is the OP_Program that invoked the sub-program 966 985 ** currently being halted. If the p2 instruction of this OP_Halt 967 986 ** instruction is set to OE_Ignore, then the sub-program is throwing 968 987 ** an IGNORE exception. In this case jump to the address specified 969 988 ** as the p2 of the calling OP_Program. */ ................................................................................ 5850 5869 p->nFrame++; 5851 5870 pFrame->pParent = p->pFrame; 5852 5871 pFrame->lastRowid = lastRowid; 5853 5872 pFrame->nChange = p->nChange; 5854 5873 pFrame->nDbChange = p->db->nChange; 5855 5874 assert( pFrame->pAuxData==0 ); 5856 5875 pFrame->pAuxData = p->pAuxData; 5876 +#ifdef SQLITE_TRACE_TRIGGER 5877 + pFrame->nVmStep = nVmStep; 5878 + pFrame->nVmStepAdj = nVmStep; 5879 +#endif 5857 5880 p->pAuxData = 0; 5858 5881 p->nChange = 0; 5859 5882 p->pFrame = pFrame; 5860 5883 p->aMem = aMem = VdbeFrameMem(pFrame); 5861 5884 p->nMem = pFrame->nChildMem; 5862 5885 p->nCursor = (u16)pFrame->nChildCsr; 5863 5886 p->apCsr = (VdbeCursor **)&aMem[p->nMem]; ................................................................................ 6885 6908 #ifndef SQLITE_OMIT_DEPRECATED 6886 6909 if( db->mTrace & SQLITE_TRACE_LEGACY ){ 6887 6910 void (*x)(void*,const char*) = (void(*)(void*,const char*))db->xTrace; 6888 6911 char *z = sqlite3VdbeExpandSql(p, zTrace); 6889 6912 x(db->pTraceArg, z); 6890 6913 sqlite3_free(z); 6891 6914 }else 6915 +#endif 6916 +#ifdef SQLITE_TRACE_TRIGGER 6917 + if( p->pFrame ){ 6918 + zTrace = sqlite3_mprintf("%.*s%s", p->nFrame-1, 6919 + " :", zTrace 6920 + ); 6921 + if( zTrace ){ 6922 + (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, zTrace); 6923 + sqlite3_free(zTrace); 6924 + } 6925 + }else 6892 6926 #endif 6893 6927 { 6894 6928 (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, zTrace); 6895 6929 } 6896 6930 } 6897 6931 #ifdef SQLITE_USE_FCNTL_TRACE 6898 6932 zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql);
Changes to src/vdbeInt.h.
171 171 int pc; /* Program Counter in parent (calling) frame */ 172 172 int nOp; /* Size of aOp array */ 173 173 int nMem; /* Number of entries in aMem */ 174 174 int nChildMem; /* Number of memory cells for child frame */ 175 175 int nChildCsr; /* Number of cursors for child frame */ 176 176 int nChange; /* Statement changes (Vdbe.nChange) */ 177 177 int nDbChange; /* Value of db->nChange */ 178 +#ifdef SQLITE_TRACE_TRIGGER 179 + int nVmStep; /* Value of nVmStep at start of program */ 180 + int nVmStepAdj; /* Adjusted for nested programs */ 181 +#endif 178 182 }; 179 183 180 184 #define VdbeFrameMem(p) ((Mem *)&((u8 *)p)[ROUND8(sizeof(VdbeFrame))]) 181 185 182 186 /* 183 187 ** Internally, the vdbe manipulates nearly all SQL values as Mem 184 188 ** structures. Each Mem struct may cache multiple representations (string,