/ Check-in [74ad80eb]
Login

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

Overview
Comment:Fix problems in the previous commit.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | trigger-trace
Files: files | file ages | folders
SHA1: 74ad80eb745c708bdbbbf24cbbbf50971e84182f
User & Date: dan 2017-01-21 16:21:24
Context
2017-01-21
16:21
Fix problems in the previous commit. Leaf check-in: 74ad80eb user: dan tags: trigger-trace
15:58
Add extra (somewhat inefficient) trace callbacks for triggers if SQLITE_TRACE_TRIGGER is defined. check-in: ffda1d1e user: dan tags: trigger-trace
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

958
959
960
961
962
963
964
965
966
967
968

969
970
971
972
973
974
975
976
977
978
979
....
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
....
5875
5876
5877
5878
5879
5880
5881




5882
5883
5884
5885
5886
5887
5888
....
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
    pFrame = p->pFrame;
    p->pFrame = pFrame->pParent;
    p->nFrame--;
    sqlite3VdbeSetChanges(db, p->nChange);
    pcx = sqlite3VdbeFrameRestore(pFrame);
#ifdef SQLITE_TRACE_TRIGGER
    if( (db->mTrace & SQLITE_TRACE_STMT) && aOp[0].p4.z ){
      int nNest = 0;
      VdbeFrame *pF;
      int nTotal = nVmStep - pFrame->nVmStep;
      char *zTrace;

      assert( db->xTrace );
      for(pF=p->pFrame; pF; pF=pF->pParent) nNest++;
      zTrace = sqlite3_mprintf("%.*s%s completed (VM steps: total=%d self=%d)", 
          nNest, "                                                    :",
          aOp[0].p4.z, nTotal, nVmStep - pFrame->nVmStepAdj
      );
      if( zTrace ){
        (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, 0, zTrace);
        sqlite3_free(zTrace);
      }
      if( p->pFrame ){
................................................................................
    pFrame->nCursor = p->nCursor;
    pFrame->aOp = p->aOp;
    pFrame->nOp = p->nOp;
    pFrame->token = pProgram->token;
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
    pFrame->anExec = p->anExec;
#endif
#ifdef SQLITE_TRACE_TRIGGER
    pFrame->nVmStep = nVmStep;
    pFrame->nVmStepAdj = nVmStep;
#endif

    pEnd = &VdbeFrameMem(pFrame)[pFrame->nChildMem];
    for(pMem=VdbeFrameMem(pFrame); pMem!=pEnd; pMem++){
      pMem->flags = MEM_Undefined;
      pMem->db = db;
    }
  }else{
................................................................................
  p->nFrame++;
  pFrame->pParent = p->pFrame;
  pFrame->lastRowid = lastRowid;
  pFrame->nChange = p->nChange;
  pFrame->nDbChange = p->db->nChange;
  assert( pFrame->pAuxData==0 );
  pFrame->pAuxData = p->pAuxData;




  p->pAuxData = 0;
  p->nChange = 0;
  p->pFrame = pFrame;
  p->aMem = aMem = VdbeFrameMem(pFrame);
  p->nMem = pFrame->nChildMem;
  p->nCursor = (u16)pFrame->nChildCsr;
  p->apCsr = (VdbeCursor **)&aMem[p->nMem];
................................................................................
      char *z = sqlite3VdbeExpandSql(p, zTrace);
      x(db->pTraceArg, z);
      sqlite3_free(z);
    }else
#endif
#ifdef SQLITE_TRACE_TRIGGER
    if( p->pFrame ){
      int nNest = -1;
      VdbeFrame *pFrame;
      for(pFrame=p->pFrame; pFrame; pFrame=pFrame->pParent) nNest++;
      zTrace = sqlite3_mprintf("%.*s%s",
          nNest, "                                                    :", zTrace
      );
      if( zTrace ){
        (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, zTrace);
        sqlite3_free(zTrace);
      }
    }else
#endif







<
<


>

<

|







 







<
<
<
<







 







>
>
>
>







 







<
<
<
|
|







958
959
960
961
962
963
964


965
966
967
968

969
970
971
972
973
974
975
976
977
....
5848
5849
5850
5851
5852
5853
5854




5855
5856
5857
5858
5859
5860
5861
....
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
....
6911
6912
6913
6914
6915
6916
6917



6918
6919
6920
6921
6922
6923
6924
6925
6926
    pFrame = p->pFrame;
    p->pFrame = pFrame->pParent;
    p->nFrame--;
    sqlite3VdbeSetChanges(db, p->nChange);
    pcx = sqlite3VdbeFrameRestore(pFrame);
#ifdef SQLITE_TRACE_TRIGGER
    if( (db->mTrace & SQLITE_TRACE_STMT) && aOp[0].p4.z ){


      int nTotal = nVmStep - pFrame->nVmStep;
      char *zTrace;
      assert( nTotal>=0 );
      assert( db->xTrace );

      zTrace = sqlite3_mprintf("%.*s%s completed (VM steps: total=%d self=%d)", 
          p->nFrame, "                                                    :",
          aOp[0].p4.z, nTotal, nVmStep - pFrame->nVmStepAdj
      );
      if( zTrace ){
        (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, 0, zTrace);
        sqlite3_free(zTrace);
      }
      if( p->pFrame ){
................................................................................
    pFrame->nCursor = p->nCursor;
    pFrame->aOp = p->aOp;
    pFrame->nOp = p->nOp;
    pFrame->token = pProgram->token;
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
    pFrame->anExec = p->anExec;
#endif





    pEnd = &VdbeFrameMem(pFrame)[pFrame->nChildMem];
    for(pMem=VdbeFrameMem(pFrame); pMem!=pEnd; pMem++){
      pMem->flags = MEM_Undefined;
      pMem->db = db;
    }
  }else{
................................................................................
  p->nFrame++;
  pFrame->pParent = p->pFrame;
  pFrame->lastRowid = lastRowid;
  pFrame->nChange = p->nChange;
  pFrame->nDbChange = p->db->nChange;
  assert( pFrame->pAuxData==0 );
  pFrame->pAuxData = p->pAuxData;
#ifdef SQLITE_TRACE_TRIGGER
  pFrame->nVmStep = nVmStep;
  pFrame->nVmStepAdj = nVmStep;
#endif
  p->pAuxData = 0;
  p->nChange = 0;
  p->pFrame = pFrame;
  p->aMem = aMem = VdbeFrameMem(pFrame);
  p->nMem = pFrame->nChildMem;
  p->nCursor = (u16)pFrame->nChildCsr;
  p->apCsr = (VdbeCursor **)&aMem[p->nMem];
................................................................................
      char *z = sqlite3VdbeExpandSql(p, zTrace);
      x(db->pTraceArg, z);
      sqlite3_free(z);
    }else
#endif
#ifdef SQLITE_TRACE_TRIGGER
    if( p->pFrame ){



      zTrace = sqlite3_mprintf("%.*s%s", p->nFrame-1, 
          "                                                    :", zTrace
      );
      if( zTrace ){
        (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, zTrace);
        sqlite3_free(zTrace);
      }
    }else
#endif