/ Check-in [ed915f57]
Login

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

Overview
Comment:Additional I/O Tracing support. (CVS 3667)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ed915f579a8e5b75681a9a6012b5041500cad36c
User & Date: drh 2007-03-01 00:29:14
Context
2007-03-02
06:24
Minor fixes so that testfixture builds without IO tracing enabled. (CVS 3668) check-in: 8d3829cd user: danielk1977 tags: trunk
2007-03-01
00:29
Additional I/O Tracing support. (CVS 3667) check-in: ed915f57 user: drh tags: trunk
2007-02-28
06:14
Work around incompatibilities in the windows printf() routine within the new I/O tracing logic. (CVS 3666) check-in: ceb3a07f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

    14     14   ** The pager is used to access a database disk file.  It implements
    15     15   ** atomic commit and rollback through the use of a journal file that
    16     16   ** is separate from the database file.  The pager also implements file
    17     17   ** locking to prevent two processes from writing the same database
    18     18   ** file simultaneously, or one process from reading the database while
    19     19   ** another is writing.
    20     20   **
    21         -** @(#) $Id: pager.c,v 1.283 2007/02/28 04:47:27 drh Exp $
           21  +** @(#) $Id: pager.c,v 1.284 2007/03/01 00:29:14 drh Exp $
    22     22   */
    23     23   #ifndef SQLITE_OMIT_DISKIO
    24     24   #include "sqliteInt.h"
    25     25   #include "os.h"
    26     26   #include "pager.h"
    27     27   #include <assert.h>
    28     28   #include <string.h>
................................................................................
  2503   2503     ** sqlite_dont_rollback() optimization for the rest of this transaction.
  2504   2504     ** It is necessary to do this because the page marked alwaysRollback
  2505   2505     ** might be reloaded at a later time but at that point we won't remember
  2506   2506     ** that is was marked alwaysRollback.  This means that all pages must
  2507   2507     ** be marked as alwaysRollback from here on out.
  2508   2508     */
  2509   2509     if( pPg->alwaysRollback ){
         2510  +    IOTRACE(("ALWAYS_ROLLBACK %p\n", pPager))
  2510   2511       pPager->alwaysRollback = 1;
  2511   2512     }
  2512   2513   
  2513   2514     /* Unlink the old page from the free list and the hash table
  2514   2515     */
  2515   2516     unlinkPage(pPg);
  2516   2517     TEST_INCR(pPager->nOvfl);

Changes to src/sqliteInt.h.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.539 2007/02/28 04:47:27 drh Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.540 2007/03/01 00:29:14 drh Exp $
    15     15   */
    16     16   #ifndef _SQLITEINT_H_
    17     17   #define _SQLITEINT_H_
    18     18   
    19     19   /*
    20     20   ** Extra interface definitions for those who need them
    21     21   */
................................................................................
  1900   1900   /*
  1901   1901   ** If the SQLITE_ENABLE IOTRACE exists then the global variable
  1902   1902   ** sqlite3_io_trace is a pointer to a printf-like routine used to
  1903   1903   ** print I/O tracing messages. 
  1904   1904   */
  1905   1905   #ifdef SQLITE_ENABLE_IOTRACE
  1906   1906   # define IOTRACE(A)  if( sqlite3_io_trace ){ sqlite3_io_trace A; }
         1907  +  void sqlite3VdbeIOTrace(Vdbe*);
  1907   1908   #else
  1908   1909   # define IOTRACE(A)
         1910  +# define sqlite3VdbeIOTrace(X)
  1909   1911   #endif
  1910   1912   extern void (*sqlite3_io_trace)(const char*,...);
  1911   1913   
  1912   1914   #endif

Changes to src/vdbe.c.

    39     39   **
    40     40   ** Various scripts scan this source file in order to generate HTML
    41     41   ** documentation, headers files, or other derived files.  The formatting
    42     42   ** of the code in this file is, therefore, important.  See other comments
    43     43   ** in this file for details.  If in doubt, do not deviate from existing
    44     44   ** commenting and indentation practices when changing or adding code.
    45     45   **
    46         -** $Id: vdbe.c,v 1.589 2007/02/14 09:19:37 danielk1977 Exp $
           46  +** $Id: vdbe.c,v 1.590 2007/03/01 00:29:14 drh Exp $
    47     47   */
    48     48   #include "sqliteInt.h"
    49     49   #include "os.h"
    50     50   #include <ctype.h>
    51     51   #include "vdbeInt.h"
    52     52   
    53     53   /*
................................................................................
   450    450     if( p->popStack ){
   451    451       popStack(&pTos, p->popStack);
   452    452       p->popStack = 0;
   453    453     }
   454    454     p->resOnStack = 0;
   455    455     db->busyHandler.nBusy = 0;
   456    456     CHECK_FOR_INTERRUPT;
          457  +  sqlite3VdbeIOTraceSql(p);
   457    458   #ifdef SQLITE_DEBUG
   458    459     if( (p->db->flags & SQLITE_VdbeListing)!=0
   459    460       || sqlite3OsFileExists("vdbe_explain")
   460    461     ){
   461    462       int i;
   462    463       printf("VDBE Program Listing:\n");
   463    464       sqlite3VdbePrintSql(p);

Changes to src/vdbeaux.c.

   769    769     if( pOp->opcode==OP_Noop && pOp->p3!=0 ){
   770    770       const char *z = pOp->p3;
   771    771       while( isspace(*(u8*)z) ) z++;
   772    772       printf("SQL: [%s]\n", z);
   773    773     }
   774    774   #endif
   775    775   }
          776  +
          777  +#if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
          778  +/*
          779  +** Print an IOTRACE message showing SQL content.
          780  +*/
          781  +void sqlite3VdbeIOTraceSql(Vdbe *p){
          782  +  int nOp = p->nOp;
          783  +  VdbeOp *pOp;
          784  +  if( sqlite3_io_trace==0 ) return;
          785  +  if( nOp<1 ) return;
          786  +  pOp = &p->aOp[nOp-1];
          787  +  if( pOp->opcode==OP_Noop && pOp->p3!=0 ){
          788  +    char *z = sqlite3StrDup(pOp->p3);
          789  +    int i, j;
          790  +    for(i=0; isspace(z[i]); i++){}
          791  +    for(j=0; z[i]; i++){
          792  +      if( isspace(z[i]) ){
          793  +        if( z[i-1]!=' ' ){
          794  +          z[j++] = ' ';
          795  +        }
          796  +      }else{
          797  +        z[j++] = z[i];
          798  +      }
          799  +    }
          800  +    z[j] = 0;
          801  +    sqlite3_io_trace("SQL %s\n", z);
          802  +    sqliteFree(z);
          803  +  }
          804  +}
          805  +#endif /* !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE */
          806  +
   776    807   
   777    808   /*
   778    809   ** Prepare a virtual machine for execution.  This involves things such
   779    810   ** as allocating stack space and initializing the program counter.
   780    811   ** After the VDBE has be prepped, it can be executed by one or more
   781    812   ** calls to sqlite3VdbeExec().  
   782    813   **