sqllogictest
Check-in [3a0c7f7549]
Not logged in

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

Overview
Comment:Add the --parameters command-line option. If the argument is optimizer=N with N a number, then on the SQLite engine, invoke sqlite3_test_control() to disable the optimizations identified by bitmask N. Update the run-all.sh script so that all tests are run three times with different optimizer settings - to verify that the same answers are generated regardless.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3a0c7f754948bd25d1f818d0c63454b8a3b6db2e
User & Date: drh 2010-12-07 02:30:21
Context
2010-12-07
03:33
Update makefiles to build SQLite with the necessary options. Update SQLite to the latest version. Change run-all.sh so that it runs tests in sorted order. check-in: ab656a0873 user: drh tags: trunk
02:30
Add the --parameters command-line option. If the argument is optimizer=N with N a number, then on the SQLite engine, invoke sqlite3_test_control() to disable the optimizations identified by bitmask N. Update the run-all.sh script so that all tests are run three times with different optimizer settings - to verify that the same answers are generated regardless. check-in: 3a0c7f7549 user: drh tags: trunk
2010-12-06
21:13
Update the built-in SQLite amalgamation to a version 3.7.4 release candidate. check-in: d8af10c23b user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/Makefile.no-odbc.

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#
OPTS += -DSQLITE_OMIT_ALTERTABLE
OPTS += -DSQLITE_OMIT_ANALYZE
OPTS += -DSQLITE_OMIT_ATTACH
OPTS += -DSQLITE_OMIT_AUTHORIZATION
OPTS += -DSQLITE_OMIT_AUTOINCREMENT
OPTS += -DSQLITE_OMIT_AUTOVACUUM
OPTS += -DSQLITE_OMIT_BUILTIN_TEST
OPTS += -DSQLITE_OMIT_COMPLETE
OPTS += -DSQLITE_OMIT_CONFLICT_CLAUSE
OPTS += -DSQLITE_OMIT_DATETIME_FUNCS
OPTS += -DSQLITE_OMIT_GET_TABLE
OPTS += -DSQLITE_OMIT_INCRBLOB
OPTS += -DSQLITE_OMIT_LOAD_EXTENSION
OPTS += -DSQLITE_OMIT_MEMORYDB







|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#
OPTS += -DSQLITE_OMIT_ALTERTABLE
OPTS += -DSQLITE_OMIT_ANALYZE
OPTS += -DSQLITE_OMIT_ATTACH
OPTS += -DSQLITE_OMIT_AUTHORIZATION
OPTS += -DSQLITE_OMIT_AUTOINCREMENT
OPTS += -DSQLITE_OMIT_AUTOVACUUM
#OPTS += -DSQLITE_OMIT_BUILTIN_TEST
OPTS += -DSQLITE_OMIT_COMPLETE
OPTS += -DSQLITE_OMIT_CONFLICT_CLAUSE
OPTS += -DSQLITE_OMIT_DATETIME_FUNCS
OPTS += -DSQLITE_OMIT_GET_TABLE
OPTS += -DSQLITE_OMIT_INCRBLOB
OPTS += -DSQLITE_OMIT_LOAD_EXTENSION
OPTS += -DSQLITE_OMIT_MEMORYDB

Changes to src/run-all.sh.

2
3
4
5
6
7
8


9
#
# Run this script to run all test cases
#
find ../test -name '*.test' -print |
  while read i
  do
    ./sqllogictest -verify $i


  done







>
>

2
3
4
5
6
7
8
9
10
11
#
# Run this script to run all test cases
#
find ../test -name '*.test' -print |
  while read i
  do
    ./sqllogictest -verify $i
    ./sqllogictest -verify -parameter optimizer=64 $i
    ./sqllogictest -verify -parameter optimizer=255 $i
  done

Changes to src/slt_odbc3.c.

336
337
338
339
340
341
342
343

344
345
346
347
348
349
350
** connection is returned by writing into *ppConn.
**
** This routine returns 0 on success and non-zero if there are any errors.
*/
static int ODBC3Connect(
  void *NotUsed,              /* Argument from DbEngine object.  Not used */
  const char *zConnectStr,    /* Connection string */
  void **ppConn               /* Write completed connection here */

){
  int rc = 0;
  SQLRETURN ret; /* ODBC API return status */
  ODBC3_Handles *pODBC3conn = NULL;
  char szConnStrIn[512] = "";

  /* Allocate a structure to hold all of our ODBC3 handles */







|
>







336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
** connection is returned by writing into *ppConn.
**
** This routine returns 0 on success and non-zero if there are any errors.
*/
static int ODBC3Connect(
  void *NotUsed,              /* Argument from DbEngine object.  Not used */
  const char *zConnectStr,    /* Connection string */
  void **ppConn,              /* Write completed connection here */
  const char *zOptions        /* Option parameters */
){
  int rc = 0;
  SQLRETURN ret; /* ODBC API return status */
  ODBC3_Handles *pODBC3conn = NULL;
  char szConnStrIn[512] = "";

  /* Allocate a structure to hold all of our ODBC3 handles */

Changes to src/slt_sqlite.c.

21
22
23
24
25
26
27





















28
29
30
31
32
33
34
..
38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67













68
69
70
71
72
73
74
**
*******************************************************************************
** Here begins the implementation of the SQLite DbEngine object.
**
** Use this interface as a model for other database engine interfaces.
*/
#include "sqlite3.h"






















/*
** This routine is called to open a connection to a new, empty database.
** The zConnectStr argument is the value of the -connection command-line
** option.  This is intended to contain information on how to connect to
** the database engine.  The zConnectStr argument will be NULL if there
** is no -connection on the command-line.  In the case of SQLite, the
................................................................................
** connection is returned by writing into *ppConn.
**
** This routine returns 0 on success and non-zero if there are any errors.
*/
static int sqliteConnect(
  void *NotUsed,              /* Argument from DbEngine object.  Not used */
  const char *zConnectStr,    /* Connection string */
  void **ppConn               /* Write completed connection here */

){
  sqlite3 *db;
  int rc;

  /* If the database filename is defined and the database already exists,
  ** then delete the database before we start, thus resetting it to an
  ** empty database.
  */
  zConnectStr = "test.db";
  if( zConnectStr ){
#ifndef WIN32
    unlink(zConnectStr);
#else
    _unlink(zConnectStr);
#endif
  }

  /* Open a connection to the new database.
  */
  rc = sqlite3_open(zConnectStr, &db);
  if( rc!=SQLITE_OK ){
    return 1;













  }
  sqlite3_exec(db, "PRAGMA synchronous=OFF", 0, 0, 0);
  *ppConn = (void*)db;
  return 0;  
}

/*







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
>








|
|












>
>
>
>
>
>
>
>
>
>
>
>
>







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
..
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
**
*******************************************************************************
** Here begins the implementation of the SQLite DbEngine object.
**
** Use this interface as a model for other database engine interfaces.
*/
#include "sqlite3.h"
#include <ctype.h>
#include <stdio.h>


/*
** Skip forward over whitespace in a string.
*/
static const char *skipWhitespace(const char *z){
  while( isspace(*z) ){ z++; }
  return z;
}

/*
** Skip forward to the end of a string or past the next ";" character
** in the string.
*/
static const char *skipToNextParameter(const char *z){
  while( z[0] && z[0]!=';' ){ z++; }
  if( z[0]==';' ) z++;
  return skipWhitespace(z);
}

/*
** This routine is called to open a connection to a new, empty database.
** The zConnectStr argument is the value of the -connection command-line
** option.  This is intended to contain information on how to connect to
** the database engine.  The zConnectStr argument will be NULL if there
** is no -connection on the command-line.  In the case of SQLite, the
................................................................................
** connection is returned by writing into *ppConn.
**
** This routine returns 0 on success and non-zero if there are any errors.
*/
static int sqliteConnect(
  void *NotUsed,              /* Argument from DbEngine object.  Not used */
  const char *zConnectStr,    /* Connection string */
  void **ppConn,              /* Write completed connection here */
  const char *zParam          /* Value of the -parameters command-line option */
){
  sqlite3 *db;
  int rc;

  /* If the database filename is defined and the database already exists,
  ** then delete the database before we start, thus resetting it to an
  ** empty database.
  */
  if( zConnectStr==0 ) zConnectStr = "test.db";
  if( zConnectStr && zConnectStr[0] ){
#ifndef WIN32
    unlink(zConnectStr);
#else
    _unlink(zConnectStr);
#endif
  }

  /* Open a connection to the new database.
  */
  rc = sqlite3_open(zConnectStr, &db);
  if( rc!=SQLITE_OK ){
    return 1;
  }
  if( zParam ){
    zParam = skipWhitespace(zParam);
    while( zParam[0] ){
      if( memcmp(zParam, "optimizer=", 10)==0 ){
        int x = atoi(&zParam[10]);
        sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, db, x);
      }else{
        fprintf(stderr, "unknown parameter: [%s]\n", zParam);
        exit(1);
      }
      zParam = skipToNextParameter(zParam);
    }
  }
  sqlite3_exec(db, "PRAGMA synchronous=OFF", 0, 0, 0);
  *ppConn = (void*)db;
  return 0;  
}

/*

Changes to src/sqllogictest.c.

323
324
325
326
327
328
329

330
331
332
333
334
335
336
...
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366


367
368
369
370
371
372
373
...
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
...
738
739
740
741
742
743
744
745
746



747
748
749
750
  int nResult;                         /* Number of query results */
  char **azResult;                     /* Query result vector */
  Script sScript;                      /* Script parsing status */
  FILE *in;                            /* For reading script */
  char zHash[100];                     /* Storage space for hash results */
  int hashThreshold = DEFAULT_HASH_THRESHOLD;  /* Threshold for hashing res */
  int bHt = 0;                         /* True if -ht command-line option */


  /* Add calls to the registration procedures for new database engine
  ** interfaces here
  */
  registerSqlite();
#ifndef OMIT_ODBC
  registerODBC3();
................................................................................

  /* Scan the command-line and process arguments
  */
  for(i=1; i<argc; i++){
    int n = (int)strlen(argv[i]);
    if( strncmp(argv[i], "-verify",n)==0 ){
      verifyMode = 1;
#if 0  /* Obsolete code */
    }else if( strncmp(argv[i], "-engine",n)==0 ){
      zDbEngine = argv[++i];
    }else if( strncmp(argv[i], "-connection",n)==0 ){
      zConnection = argv[++i];
#endif
    }else if( strncmp(argv[i], "-odbc",n)==0 ){
      zDbEngine = "ODBC3";
      zConnection = argv[++i];


    }else if( strncmp(argv[i], "-ht",n)==0 ){
      hashThreshold = atoi(argv[++i]);
      bHt = -1;
    }else if( zScriptFile==0 ){
      zScriptFile = argv[i];
    }else{
      fprintf(stderr, "%s: unknown argument: %s\n", argv[0], argv[i]);
................................................................................
  sScript.zScript = zScript;
  sScript.zLine = zScript;
  sScript.iEnd = nScript;
  sScript.copyFlag = !verifyMode;

  /* Open the database engine under test
  */
  rc = pEngine->xConnect(pEngine->pAuxData, zConnection, &pConn);
  if( rc ){
    fprintf(stderr, "%s: unable to connect to database\n", argv[0]);
    exit(1);
  }

  /* Get the "real" db name
  */
................................................................................
    fprintf(stderr, "%s: disconnection from database failed\n", argv[0]);
    nErr++;
  }

  /* Report the number of errors and quit.
  */
  if( verifyMode || nErr || nSkipped){
    fprintf(stderr, "%s: %d errors out of %d SQL statement.  %d skipped.\n",
           zScriptFile, nErr, nCmd, nSkipped);



  }
  free(zScript);
  return nErr; 
}







>







 







<




<



>
>







 







|







 







|
|
>
>
>




323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
...
352
353
354
355
356
357
358

359
360
361
362

363
364
365
366
367
368
369
370
371
372
373
374
...
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
...
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
  int nResult;                         /* Number of query results */
  char **azResult;                     /* Query result vector */
  Script sScript;                      /* Script parsing status */
  FILE *in;                            /* For reading script */
  char zHash[100];                     /* Storage space for hash results */
  int hashThreshold = DEFAULT_HASH_THRESHOLD;  /* Threshold for hashing res */
  int bHt = 0;                         /* True if -ht command-line option */
  const char *zParam = 0;              /* Argument to -parameters */

  /* Add calls to the registration procedures for new database engine
  ** interfaces here
  */
  registerSqlite();
#ifndef OMIT_ODBC
  registerODBC3();
................................................................................

  /* Scan the command-line and process arguments
  */
  for(i=1; i<argc; i++){
    int n = (int)strlen(argv[i]);
    if( strncmp(argv[i], "-verify",n)==0 ){
      verifyMode = 1;

    }else if( strncmp(argv[i], "-engine",n)==0 ){
      zDbEngine = argv[++i];
    }else if( strncmp(argv[i], "-connection",n)==0 ){
      zConnection = argv[++i];

    }else if( strncmp(argv[i], "-odbc",n)==0 ){
      zDbEngine = "ODBC3";
      zConnection = argv[++i];
    }else if( strncmp(argv[i], "-parameters",n)==0 ){
      zParam = argv[++i];
    }else if( strncmp(argv[i], "-ht",n)==0 ){
      hashThreshold = atoi(argv[++i]);
      bHt = -1;
    }else if( zScriptFile==0 ){
      zScriptFile = argv[i];
    }else{
      fprintf(stderr, "%s: unknown argument: %s\n", argv[0], argv[i]);
................................................................................
  sScript.zScript = zScript;
  sScript.zLine = zScript;
  sScript.iEnd = nScript;
  sScript.copyFlag = !verifyMode;

  /* Open the database engine under test
  */
  rc = pEngine->xConnect(pEngine->pAuxData, zConnection, &pConn, zParam);
  if( rc ){
    fprintf(stderr, "%s: unable to connect to database\n", argv[0]);
    exit(1);
  }

  /* Get the "real" db name
  */
................................................................................
    fprintf(stderr, "%s: disconnection from database failed\n", argv[0]);
    nErr++;
  }

  /* Report the number of errors and quit.
  */
  if( verifyMode || nErr || nSkipped){
    fprintf(stderr, "%d errors out of %d tests in %s - %d skipped.",
            nErr, nCmd, zScriptFile, nSkipped);
    if( zParam ) fprintf(stderr, " [%s]", zParam);
    fprintf(stderr, "\n");
  
  }
  free(zScript);
  return nErr; 
}

Changes to src/sqllogictest.h.

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
** The interface to each database engine is an instance of the
** following structure.
*/
typedef struct DbEngine DbEngine;
struct DbEngine {
  const char *zName;                      /* Name of this engine */
  void *pAuxData;                         /* Aux data passed to xConnect */
  int (*xConnect)(void *pAux, const char *zConnectStr, void **ppConn);
  int (*xGetEngineName)(void*, const char **zName);
  int (*xStatement)(void*, 
                    const char *zSql, 
                    int bQuiet);          /* True to suppress printing errors. */
  int (*xQuery)(void*, const char *zSql, const char *zTypes,
                char ***pazResult, int *pnResult);
  int (*xFreeResults)(void*, char **azResult, int nResult);







|







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
** The interface to each database engine is an instance of the
** following structure.
*/
typedef struct DbEngine DbEngine;
struct DbEngine {
  const char *zName;                      /* Name of this engine */
  void *pAuxData;                         /* Aux data passed to xConnect */
  int (*xConnect)(void*, const char *zCon, void **ppConn, const char *zOpt);
  int (*xGetEngineName)(void*, const char **zName);
  int (*xStatement)(void*, 
                    const char *zSql, 
                    int bQuiet);          /* True to suppress printing errors. */
  int (*xQuery)(void*, const char *zSql, const char *zTypes,
                char ***pazResult, int *pnResult);
  int (*xFreeResults)(void*, char **azResult, int nResult);

Changes to src/sqllogictest.mk.

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

OPTS += -DSQLITE_OMIT_ALTERTABLE
OPTS += -DSQLITE_OMIT_ANALYZE
OPTS += -DSQLITE_OMIT_ATTACH
OPTS += -DSQLITE_OMIT_AUTHORIZATION
OPTS += -DSQLITE_OMIT_AUTOINCREMENT
OPTS += -DSQLITE_OMIT_AUTOVACUUM
OPTS += -DSQLITE_OMIT_BUILTIN_TEST
OPTS += -DSQLITE_OMIT_COMPLETE
OPTS += -DSQLITE_OMIT_CONFLICT_CLAUSE
OPTS += -DSQLITE_OMIT_DATETIME_FUNCS
OPTS += -DSQLITE_OMIT_GET_TABLE
OPTS += -DSQLITE_OMIT_INCRBLOB
OPTS += -DSQLITE_OMIT_LOAD_EXTENSION
OPTS += -DSQLITE_OMIT_MEMORYDB







|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

OPTS += -DSQLITE_OMIT_ALTERTABLE
OPTS += -DSQLITE_OMIT_ANALYZE
OPTS += -DSQLITE_OMIT_ATTACH
OPTS += -DSQLITE_OMIT_AUTHORIZATION
OPTS += -DSQLITE_OMIT_AUTOINCREMENT
OPTS += -DSQLITE_OMIT_AUTOVACUUM
#OPTS += -DSQLITE_OMIT_BUILTIN_TEST
OPTS += -DSQLITE_OMIT_COMPLETE
OPTS += -DSQLITE_OMIT_CONFLICT_CLAUSE
OPTS += -DSQLITE_OMIT_DATETIME_FUNCS
OPTS += -DSQLITE_OMIT_GET_TABLE
OPTS += -DSQLITE_OMIT_INCRBLOB
OPTS += -DSQLITE_OMIT_LOAD_EXTENSION
OPTS += -DSQLITE_OMIT_MEMORYDB