/ Check-in [59bdbb10]
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:Fix harmless compiler warnings in mptest.c.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | mptest
Files: files | file ages | folders
SHA1: 59bdbb10ed67bf79e0991e2ad58a28321dedb959
User & Date: drh 2013-04-08 13:59:11
Context
2013-04-08
14:28
Add the "mptester" target to the makefiles. Make mptester run with synchronous off by default. Closed-Leaf check-in: 1397830b user: drh tags: mptest
13:59
Fix harmless compiler warnings in mptest.c. check-in: 59bdbb10 user: drh tags: mptest
13:48
Add the vfsname() and eval() SQL functions to mptest.c. Enhancements to the test/config01.test script. check-in: 91397a14 user: drh tags: mptest
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to mptest/mptest.c.

37
38
39
40
41
42
43



44
45
46
47
48
49
50
...
275
276
277
278
279
280
281


282
283
284
285
286
287
288
289
290
291

292
293
294
295
296
297
298
299
300
301
302
303

304
305
306
307
308
309
310

311
312
313
314
315
316
317
...
431
432
433
434
435
436
437

438
439
440
441
442
443
444
...
475
476
477
478
479
480
481

482
483
484
485
486
487
488
...
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>




/* Global data
*/
static struct Global {
  char *argv0;           /* Name of the executable */
  const char *zVfs;      /* Name of VFS to use. Often NULL meaning "default" */
  char *zDbFile;         /* Name of the database */
  sqlite3 *db;           /* Open connection to database */
................................................................................
static void vfsNameFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  sqlite3 *db = sqlite3_context_db_handle(context);
  char *zVfs = 0;


  sqlite3_file_control(db, "main", SQLITE_FCNTL_VFSNAME, &zVfs);
  if( zVfs ){
    sqlite3_result_text(context, zVfs, -1, sqlite3_free);
  }
}

/*
** Busy handler with a g.iTimeout-millisecond timeout
*/
static int busyHandler(void *pCD, int count){

  if( count*10>g.iTimeout ){
    if( g.iTimeout>0 ) errorMessage("timeout after %dms", g.iTimeout);
    return 0;
  }
  sqlite3_sleep(10);
  return 1;
}

/*
** SQL Trace callback
*/
static void sqlTraceCallback(void *NotUsed1, const char *zSql){

  logMessage("[%.*s]", clipLength(zSql), zSql);
}

/*
** SQL error log callback
*/
static void sqlErrorCallback(void *pArg, int iErrCode, const char *zMsg){

  if( (iErrCode&0xff)==SQLITE_SCHEMA && g.iTrace<3 ) return;
  errorMessage("(errcode=%d) %s", iErrCode, zMsg);
}

/*
** Prepare an SQL statement.  Issue a fatal error if unable.
*/
................................................................................

/*
** Callback function for evalSql()
*/
static int evalCallback(void *pCData, int argc, char **argv, char **azCol){
  String *p = (String*)pCData;
  int i;

  for(i=0; i<argc; i++) stringAppendTerm(p, argv[i]);
  return 0;
}

/*
** Run arbitrary SQL and record the results in an output string
** given by the first parameter.
................................................................................
  sqlite3_value **argv
){
  sqlite3 *db = sqlite3_context_db_handle(context);
  const char *zSql = (const char*)sqlite3_value_text(argv[0]);
  String res;
  char *zErrMsg = 0;
  int rc;

  memset(&res, 0, sizeof(res));
  rc = sqlite3_exec(db, zSql, evalCallback, &res, &zErrMsg);
  if( zErrMsg ){
    sqlite3_result_error(context, zErrMsg, -1);
    sqlite3_free(zErrMsg);
  }else if( rc ){
    sqlite3_result_error_code(context, rc);
................................................................................
    argv[5] = zTrace;
    if( g.bSqlTrace ){
      argv[6] = "--sqltrace";
      argv[7] = 0;
    }else{
      argv[6] = 0;
    }
    _spawnv(_P_NOWAIT, g.argv0, argv);
#endif
  }
}

/*
** Read the entire content of a file into memory
*/







>
>
>







 







>
>










>












>







>







 







>







 







>







 







|







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
...
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
...
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
...
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
...
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>

/* Mark a parameter as unused to suppress compiler warnings */
#define UNUSED_PARAMETER(x)  (void)x

/* Global data
*/
static struct Global {
  char *argv0;           /* Name of the executable */
  const char *zVfs;      /* Name of VFS to use. Often NULL meaning "default" */
  char *zDbFile;         /* Name of the database */
  sqlite3 *db;           /* Open connection to database */
................................................................................
static void vfsNameFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  sqlite3 *db = sqlite3_context_db_handle(context);
  char *zVfs = 0;
  UNUSED_PARAMETER(argc);
  UNUSED_PARAMETER(argv);
  sqlite3_file_control(db, "main", SQLITE_FCNTL_VFSNAME, &zVfs);
  if( zVfs ){
    sqlite3_result_text(context, zVfs, -1, sqlite3_free);
  }
}

/*
** Busy handler with a g.iTimeout-millisecond timeout
*/
static int busyHandler(void *pCD, int count){
  UNUSED_PARAMETER(pCD);
  if( count*10>g.iTimeout ){
    if( g.iTimeout>0 ) errorMessage("timeout after %dms", g.iTimeout);
    return 0;
  }
  sqlite3_sleep(10);
  return 1;
}

/*
** SQL Trace callback
*/
static void sqlTraceCallback(void *NotUsed1, const char *zSql){
  UNUSED_PARAMETER(NotUsed1);
  logMessage("[%.*s]", clipLength(zSql), zSql);
}

/*
** SQL error log callback
*/
static void sqlErrorCallback(void *pArg, int iErrCode, const char *zMsg){
  UNUSED_PARAMETER(pArg);
  if( (iErrCode&0xff)==SQLITE_SCHEMA && g.iTrace<3 ) return;
  errorMessage("(errcode=%d) %s", iErrCode, zMsg);
}

/*
** Prepare an SQL statement.  Issue a fatal error if unable.
*/
................................................................................

/*
** Callback function for evalSql()
*/
static int evalCallback(void *pCData, int argc, char **argv, char **azCol){
  String *p = (String*)pCData;
  int i;
  UNUSED_PARAMETER(azCol);
  for(i=0; i<argc; i++) stringAppendTerm(p, argv[i]);
  return 0;
}

/*
** Run arbitrary SQL and record the results in an output string
** given by the first parameter.
................................................................................
  sqlite3_value **argv
){
  sqlite3 *db = sqlite3_context_db_handle(context);
  const char *zSql = (const char*)sqlite3_value_text(argv[0]);
  String res;
  char *zErrMsg = 0;
  int rc;
  UNUSED_PARAMETER(argc);
  memset(&res, 0, sizeof(res));
  rc = sqlite3_exec(db, zSql, evalCallback, &res, &zErrMsg);
  if( zErrMsg ){
    sqlite3_result_error(context, zErrMsg, -1);
    sqlite3_free(zErrMsg);
  }else if( rc ){
    sqlite3_result_error_code(context, rc);
................................................................................
    argv[5] = zTrace;
    if( g.bSqlTrace ){
      argv[6] = "--sqltrace";
      argv[7] = 0;
    }else{
      argv[6] = 0;
    }
    _spawnv(_P_NOWAIT, g.argv0, (const char*const*)argv);
#endif
  }
}

/*
** Read the entire content of a file into memory
*/