/ Check-in [6748a83d]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Show the process-id on log messages from mptester.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6748a83dc5c02db37ecd963e678c5c69db142cac
User & Date: drh 2013-04-11 11:53:45
Context
2013-04-11
13:26
Fix pragma code generation so that it always outputs an OP_Trace opcode so that pragmas are shown in sqlite3_trace() output. check-in: 663f04bd user: drh tags: trunk
11:53
Show the process-id on log messages from mptester. check-in: 6748a83d user: drh tags: trunk
01:16
Have the UNIX VFS issue warnings via sqlite3_log() if a database file is renamed or unlinked or linked to more than one name while the file is open. check-in: e238dcf9 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to mptest/mptest.c.

    34     34   ** test script.
    35     35   */
    36     36   #include "sqlite3.h"
    37     37   #include <stdio.h>
    38     38   #if defined(_WIN32)
    39     39   # define WIN32_LEAN_AND_MEAN
    40     40   # include <windows.h>
           41  +# include <process.h>
           42  +# define GETPID _getpid
    41     43   #else
    42     44   # include <unistd.h>
           45  +# define GETPID getpid
    43     46   #endif
    44     47   #include <stdlib.h>
    45     48   #include <string.h>
    46     49   #include <assert.h>
    47     50   #include <ctype.h>
    48     51   
    49     52   /* The suffix to append to the child command lines, if any */
................................................................................
    63     66     const char *zVfs;      /* Name of VFS to use. Often NULL meaning "default" */
    64     67     char *zDbFile;         /* Name of the database */
    65     68     sqlite3 *db;           /* Open connection to database */
    66     69     char *zErrLog;         /* Filename for error log */
    67     70     FILE *pErrLog;         /* Where to write errors */
    68     71     char *zLog;            /* Name of output log file */
    69     72     FILE *pLog;            /* Where to write log messages */
    70         -  char zName[12];        /* Symbolic name of this process */
           73  +  char zName[32];        /* Symbolic name of this process */
    71     74     int taskId;            /* Task ID.  0 means supervisor. */
    72     75     int iTrace;            /* Tracing level */
    73     76     int bSqlTrace;         /* True to trace SQL commands */
    74     77     int nError;            /* Number of errors */
    75     78     int nTest;             /* Number of --match operators */
    76     79     int iTimeout;          /* Milliseconds until a busy timeout */
    77     80     int bSync;             /* Call fsync() */
................................................................................
   327    330   /*
   328    331   ** SQL error log callback
   329    332   */
   330    333   static void sqlErrorCallback(void *pArg, int iErrCode, const char *zMsg){
   331    334     UNUSED_PARAMETER(pArg);
   332    335     if( (iErrCode&0xff)==SQLITE_SCHEMA && g.iTrace<3 ) return;
   333    336     if( g.iTimeout==0 && (iErrCode&0xff)==SQLITE_BUSY && g.iTrace<3 ) return;
   334         -  if( iErrCode==SQLITE_OK ){
          337  +  if( (iErrCode&0xff)==SQLITE_NOTICE ){
   335    338       logMessage("(info) %s", zMsg);
   336    339     }else{
   337    340       errorMessage("(errcode=%d) %s", iErrCode, zMsg);
   338    341     }
   339    342   }
   340    343   
   341    344   /*
................................................................................
  1185   1188       fprintf(stderr, "SQLite library and header mismatch\n"
  1186   1189                       "Library: %s\n"
  1187   1190                       "Header:  %s\n",
  1188   1191                       sqlite3_sourceid(), SQLITE_SOURCE_ID);
  1189   1192       exit(1);
  1190   1193     }
  1191   1194     n = argc-2;
  1192         -  sqlite3_snprintf(sizeof(g.zName), g.zName, "mptest");
         1195  +  sqlite3_snprintf(sizeof(g.zName), g.zName, "%05d.mptest", GETPID());
  1193   1196     g.zVfs = findOption(argv+2, &n, "vfs", 1);
  1194   1197     zClient = findOption(argv+2, &n, "client", 1);
  1195   1198     g.zErrLog = findOption(argv+2, &n, "errlog", 1);
  1196   1199     g.zLog = findOption(argv+2, &n, "log", 1);
  1197   1200     zTrace = findOption(argv+2, &n, "trace", 1);
  1198   1201     if( zTrace ) g.iTrace = atoi(zTrace);
  1199   1202     if( findOption(argv+2, &n, "quiet", 0)!=0 ) g.iTrace = 0;
................................................................................
  1205   1208       g.pErrLog = stderr;
  1206   1209     }
  1207   1210     if( g.zLog ){
  1208   1211       g.pLog = fopen(g.zLog, "a");
  1209   1212     }else{
  1210   1213       g.pLog = stdout;
  1211   1214     }
         1215  +  
  1212   1216     sqlite3_config(SQLITE_CONFIG_LOG, sqlErrorCallback, 0);
  1213   1217     if( zClient ){
  1214   1218       iClient = atoi(zClient);
  1215   1219       if( iClient<1 ) fatalError("illegal client number: %d\n", iClient);
  1216         -    sqlite3_snprintf(sizeof(g.zName), g.zName, "client%02d", iClient);
         1220  +    sqlite3_snprintf(sizeof(g.zName), g.zName, "%05d.client%02d",
         1221  +                     GETPID(), iClient);
  1217   1222     }else{
  1218   1223       if( g.iTrace>0 ){
  1219   1224         printf("With SQLite " SQLITE_VERSION " " SQLITE_SOURCE_ID "\n" );
  1220   1225         for(i=0; (zCOption = sqlite3_compileoption_get(i))!=0; i++){
  1221   1226           printf("-DSQLITE_%s\n", zCOption);
  1222   1227         }
  1223   1228         fflush(stdout);