SQLite

Check-in [a42db19d52]
Login

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

Overview
Comment:Merge the branch-3.7.2 changes into the stat3-3.7.2 subbranch. Also fix some test script issues.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | stat3-3.7.2
Files: files | file ages | folders
SHA1: a42db19d52b679e5f3ce6970883903816e75a4e4
User & Date: drh 2011-08-26 18:04:52.302
Context
2011-08-26
18:28
Veryquick and min.rc tests now passing. (Closed-Leaf check-in: a7e1846882 user: drh tags: stat3-3.7.2)
18:04
Merge the branch-3.7.2 changes into the stat3-3.7.2 subbranch. Also fix some test script issues. (check-in: a42db19d52 user: drh tags: stat3-3.7.2)
17:17
Cherrypick the recursion fix to test_vfs.c from [065e5a5ea4f82]. Also fix the nan.test module to handle upper/lower case changes in TCL. (check-in: 41b5f86971 user: drh tags: branch-3.7.2)
15:51
Get stat3 working after import from trunk-based the stat3-enhancement branch. There is still a problem in the wal2 test. (check-in: 01cc4ff6af user: drh tags: stat3-3.7.2)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/test_vfs.c.
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
*/
struct Testvfs {
  char *zName;                    /* Name of this VFS */
  sqlite3_vfs *pParent;           /* The VFS to use for file IO */
  sqlite3_vfs *pVfs;              /* The testvfs registered with SQLite */
  Tcl_Interp *interp;             /* Interpreter to run script in */
  Tcl_Obj *pScript;               /* Script to execute */
  int nScript;                    /* Number of elements in array apScript */
  Tcl_Obj **apScript;             /* Array version of pScript */
  TestvfsBuffer *pBuffer;         /* List of shared buffers */
  int isNoshm;

  int mask;                       /* Mask controlling [script] and [ioerr] */

  TestFaultInject ioerr_err;
  TestFaultInject full_err;







<
<







77
78
79
80
81
82
83


84
85
86
87
88
89
90
*/
struct Testvfs {
  char *zName;                    /* Name of this VFS */
  sqlite3_vfs *pParent;           /* The VFS to use for file IO */
  sqlite3_vfs *pVfs;              /* The testvfs registered with SQLite */
  Tcl_Interp *interp;             /* Interpreter to run script in */
  Tcl_Obj *pScript;               /* Script to execute */


  TestvfsBuffer *pBuffer;         /* List of shared buffers */
  int isNoshm;

  int mask;                       /* Mask controlling [script] and [ioerr] */

  TestFaultInject ioerr_err;
  TestFaultInject full_err;
264
265
266
267
268
269
270
271
272
273
274
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
318
319
  Testvfs *p, 
  const char *zMethod,
  Tcl_Obj *arg1,
  Tcl_Obj *arg2,
  Tcl_Obj *arg3
){
  int rc;                         /* Return code from Tcl_EvalObj() */
  int nArg;                       /* Elements in eval'd list */
  int nScript;
  Tcl_Obj ** ap;

  assert( p->pScript );

  if( !p->apScript ){
    int nByte;
    int i;
    if( TCL_OK!=Tcl_ListObjGetElements(p->interp, p->pScript, &nScript, &ap) ){
      Tcl_BackgroundError(p->interp);
      Tcl_ResetResult(p->interp);
      return;
    }
    p->nScript = nScript;
    nByte = (nScript+TESTVFS_MAX_ARGS)*sizeof(Tcl_Obj *);
    p->apScript = (Tcl_Obj **)ckalloc(nByte);
    memset(p->apScript, 0, nByte);
    for(i=0; i<nScript; i++){
      p->apScript[i] = ap[i];
    }
  }

  p->apScript[p->nScript] = Tcl_NewStringObj(zMethod, -1);
  p->apScript[p->nScript+1] = arg1;
  p->apScript[p->nScript+2] = arg2;
  p->apScript[p->nScript+3] = arg3;

  for(nArg=p->nScript; p->apScript[nArg]; nArg++){
    Tcl_IncrRefCount(p->apScript[nArg]);




  }

  rc = Tcl_EvalObjv(p->interp, nArg, p->apScript, TCL_EVAL_GLOBAL);
  if( rc!=TCL_OK ){
    Tcl_BackgroundError(p->interp);
    Tcl_ResetResult(p->interp);
  }

  for(nArg=p->nScript; p->apScript[nArg]; nArg++){
    Tcl_DecrRefCount(p->apScript[nArg]);
    p->apScript[nArg] = 0;
  }
}


/*
** Close an tvfs-file.
*/
static int tvfsClose(sqlite3_file *pFile){







<
<
|
<


<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
|
<
<
|
|

|
|
>
>
>
>
|
|
<




<
<
<
<
<







262
263
264
265
266
267
268


269

270
271






272









273


274
275
276
277
278
279
280
281
282
283
284

285
286
287
288





289
290
291
292
293
294
295
  Testvfs *p, 
  const char *zMethod,
  Tcl_Obj *arg1,
  Tcl_Obj *arg2,
  Tcl_Obj *arg3
){
  int rc;                         /* Return code from Tcl_EvalObj() */


  Tcl_Obj *pEval;

  assert( p->pScript );







  assert( zMethod );









  assert( p );


  assert( arg2==0 || arg1!=0 );
  assert( arg3==0 || arg2!=0 );

  pEval = Tcl_DuplicateObj(p->pScript);
  Tcl_IncrRefCount(p->pScript);
  Tcl_ListObjAppendElement(p->interp, pEval, Tcl_NewStringObj(zMethod, -1));
  if( arg1 ) Tcl_ListObjAppendElement(p->interp, pEval, arg1);
  if( arg2 ) Tcl_ListObjAppendElement(p->interp, pEval, arg2);
  if( arg3 ) Tcl_ListObjAppendElement(p->interp, pEval, arg3);

  rc = Tcl_EvalObjEx(p->interp, pEval, TCL_EVAL_GLOBAL);

  if( rc!=TCL_OK ){
    Tcl_BackgroundError(p->interp);
    Tcl_ResetResult(p->interp);
  }





}


/*
** Close an tvfs-file.
*/
static int tvfsClose(sqlite3_file *pFile){
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
    }

    case CMD_SCRIPT: {
      if( objc==3 ){
        int nByte;
        if( p->pScript ){
          Tcl_DecrRefCount(p->pScript);
          ckfree((char *)p->apScript);
          p->apScript = 0;
          p->nScript = 0;
          p->pScript = 0;
        }
        Tcl_GetStringFromObj(objv[2], &nByte);
        if( nByte>0 ){
          p->pScript = Tcl_DuplicateObj(objv[2]);
          Tcl_IncrRefCount(p->pScript);
        }







<
<
<







1046
1047
1048
1049
1050
1051
1052



1053
1054
1055
1056
1057
1058
1059
    }

    case CMD_SCRIPT: {
      if( objc==3 ){
        int nByte;
        if( p->pScript ){
          Tcl_DecrRefCount(p->pScript);



          p->pScript = 0;
        }
        Tcl_GetStringFromObj(objv[2], &nByte);
        if( nByte>0 ){
          p->pScript = Tcl_DuplicateObj(objv[2]);
          Tcl_IncrRefCount(p->pScript);
        }
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
  return TCL_OK;
}

static void testvfs_obj_del(ClientData cd){
  Testvfs *p = (Testvfs *)cd;
  if( p->pScript ) Tcl_DecrRefCount(p->pScript);
  sqlite3_vfs_unregister(p->pVfs);
  ckfree((char *)p->apScript);
  ckfree((char *)p->pVfs);
  ckfree((char *)p);
}

/*
** Usage:  testvfs VFSNAME ?SWITCHES?
**







<







1199
1200
1201
1202
1203
1204
1205

1206
1207
1208
1209
1210
1211
1212
  return TCL_OK;
}

static void testvfs_obj_del(ClientData cd){
  Testvfs *p = (Testvfs *)cd;
  if( p->pScript ) Tcl_DecrRefCount(p->pScript);
  sqlite3_vfs_unregister(p->pVfs);

  ckfree((char *)p->pVfs);
  ckfree((char *)p);
}

/*
** Usage:  testvfs VFSNAME ?SWITCHES?
**
Changes to test/analyze3.test.
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
  }
} {}
do_eqp_test analyze3-1.2.2 {
  SELECT sum(y) FROM t2 WHERE x>1 AND x<2
} {0 0 0 {SEARCH TABLE t2 USING INDEX i2 (x>? AND x<?) (~196 rows)}}
do_eqp_test analyze3-1.2.3 {
  SELECT sum(y) FROM t2 WHERE x>0 AND x<99
} {0 0 0 {SEARCH TABLE t2 USING INDEX i2 (x>? AND x<?) (~982 rows)}}
do_test analyze3-1.2.4 {
  sf_execsql { SELECT sum(y) FROM t2 WHERE x>12 AND x<20 }
} {161 0 4760}
do_test analyze3-1.2.5 {
  set l [string range "12" 0 end]
  set u [string range "20" 0 end]
  sf_execsql {SELECT typeof($l), typeof($u), sum(y) FROM t2 WHERE x>$l AND x<$u}







|







145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
  }
} {}
do_eqp_test analyze3-1.2.2 {
  SELECT sum(y) FROM t2 WHERE x>1 AND x<2
} {0 0 0 {SEARCH TABLE t2 USING INDEX i2 (x>? AND x<?) (~196 rows)}}
do_eqp_test analyze3-1.2.3 {
  SELECT sum(y) FROM t2 WHERE x>0 AND x<99
} {0 0 0 {SEARCH TABLE t2 USING INDEX i2 (x>? AND x<?) (~968 rows)}}
do_test analyze3-1.2.4 {
  sf_execsql { SELECT sum(y) FROM t2 WHERE x>12 AND x<20 }
} {161 0 4760}
do_test analyze3-1.2.5 {
  set l [string range "12" 0 end]
  set u [string range "20" 0 end]
  sf_execsql {SELECT typeof($l), typeof($u), sum(y) FROM t2 WHERE x>$l AND x<$u}
Changes to test/nan.test.
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
75
76
77
78
79
80
  db eval {SELECT x, typeof(x) FROM t1}
} {{} null}
if {$tcl_platform(platform) != "symbian"} {
  do_test nan-1.1.2 {
    sqlite3_bind_double $::STMT 1 +Inf
    sqlite3_step $::STMT
    sqlite3_reset $::STMT
    db eval {SELECT x, typeof(x) FROM t1}
  } {{} null inf real}
  do_test nan-1.1.3 {
    sqlite3_bind_double $::STMT 1 -Inf
    sqlite3_step $::STMT
    sqlite3_reset $::STMT
    db eval {SELECT x, typeof(x) FROM t1}
  } {{} null inf real -inf real}
  do_test nan-1.1.4 {
    sqlite3_bind_double $::STMT 1 -NaN
    sqlite3_step $::STMT
    sqlite3_reset $::STMT
    db eval {SELECT x, typeof(x) FROM t1}
  } {{} null inf real -inf real {} null}
  do_test nan-1.1.5 {
    sqlite3_bind_double $::STMT 1 NaN0
    sqlite3_step $::STMT
    sqlite3_reset $::STMT
    db eval {SELECT x, typeof(x) FROM t1}
  } {{} null inf real -inf real {} null {} null}
  do_test nan-1.1.6 {
    sqlite3_bind_double $::STMT 1 -NaN0
    sqlite3_step $::STMT
    sqlite3_reset $::STMT
    db eval {SELECT x, typeof(x) FROM t1}
  } {{} null inf real -inf real {} null {} null {} null}
  do_test nan-1.1.7 {
    db eval {
      UPDATE t1 SET x=x-x;
      SELECT x, typeof(x) FROM t1;
    }
  } {{} null {} null {} null {} null {} null {} null}







|





|





|





|





|







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
75
76
77
78
79
80
  db eval {SELECT x, typeof(x) FROM t1}
} {{} null}
if {$tcl_platform(platform) != "symbian"} {
  do_test nan-1.1.2 {
    sqlite3_bind_double $::STMT 1 +Inf
    sqlite3_step $::STMT
    sqlite3_reset $::STMT
    string tolower [db eval {SELECT x, typeof(x) FROM t1}]
  } {{} null inf real}
  do_test nan-1.1.3 {
    sqlite3_bind_double $::STMT 1 -Inf
    sqlite3_step $::STMT
    sqlite3_reset $::STMT
    string tolower [db eval {SELECT x, typeof(x) FROM t1}]
  } {{} null inf real -inf real}
  do_test nan-1.1.4 {
    sqlite3_bind_double $::STMT 1 -NaN
    sqlite3_step $::STMT
    sqlite3_reset $::STMT
    string tolower [db eval {SELECT x, typeof(x) FROM t1}]
  } {{} null inf real -inf real {} null}
  do_test nan-1.1.5 {
    sqlite3_bind_double $::STMT 1 NaN0
    sqlite3_step $::STMT
    sqlite3_reset $::STMT
    string tolower [db eval {SELECT x, typeof(x) FROM t1}]
  } {{} null inf real -inf real {} null {} null}
  do_test nan-1.1.6 {
    sqlite3_bind_double $::STMT 1 -NaN0
    sqlite3_step $::STMT
    sqlite3_reset $::STMT
    string tolower [db eval {SELECT x, typeof(x) FROM t1}]
  } {{} null inf real -inf real {} null {} null {} null}
  do_test nan-1.1.7 {
    db eval {
      UPDATE t1 SET x=x-x;
      SELECT x, typeof(x) FROM t1;
    }
  } {{} null {} null {} null {} null {} null {} null}
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
if {$tcl_platform(platform) != "symbian"} {
  # Do not run these tests on Symbian, as the Tcl port doesn't like to
  # convert from floating point value "-inf" to a string.
  #
  do_test nan-4.7 {
    db eval {DELETE FROM t1}
    db eval "INSERT INTO t1 VALUES([string repeat 9 309].0)"
    db eval {SELECT x, typeof(x) FROM t1}
  } {inf real}
  do_test nan-4.8 {
    db eval {DELETE FROM t1}
    db eval "INSERT INTO t1 VALUES(-[string repeat 9 309].0)"
    db eval {SELECT x, typeof(x) FROM t1}
  } {-inf real}
}
do_test nan-4.9 {
  db eval {DELETE FROM t1}
  db eval "INSERT INTO t1 VALUES([string repeat 9 309].0)"
  db eval {SELECT CAST(x AS text), typeof(x) FROM t1}
} {Inf real}







|




|







230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
if {$tcl_platform(platform) != "symbian"} {
  # Do not run these tests on Symbian, as the Tcl port doesn't like to
  # convert from floating point value "-inf" to a string.
  #
  do_test nan-4.7 {
    db eval {DELETE FROM t1}
    db eval "INSERT INTO t1 VALUES([string repeat 9 309].0)"
    string tolower [db eval {SELECT x, typeof(x) FROM t1}]
  } {inf real}
  do_test nan-4.8 {
    db eval {DELETE FROM t1}
    db eval "INSERT INTO t1 VALUES(-[string repeat 9 309].0)"
    string tolower [db eval {SELECT x, typeof(x) FROM t1}]
  } {-inf real}
}
do_test nan-4.9 {
  db eval {DELETE FROM t1}
  db eval "INSERT INTO t1 VALUES([string repeat 9 309].0)"
  db eval {SELECT CAST(x AS text), typeof(x) FROM t1}
} {Inf real}
313
314
315
316
317
318
319
320
321
322
323
324
325
  db eval {SELECT CAST(x AS text), typeof(x) FROM t1}
} {-9.88131291682493e-324 real}

do_test nan-4.20 {
  db eval {DELETE FROM t1}
  set big [string repeat 9 10000].0e-9000
  db eval "INSERT INTO t1 VALUES($big)"
  db eval {SELECT x, typeof(x) FROM t1}
} {inf real}



finish_test







|





313
314
315
316
317
318
319
320
321
322
323
324
325
  db eval {SELECT CAST(x AS text), typeof(x) FROM t1}
} {-9.88131291682493e-324 real}

do_test nan-4.20 {
  db eval {DELETE FROM t1}
  set big [string repeat 9 10000].0e-9000
  db eval "INSERT INTO t1 VALUES($big)"
  string tolower [db eval {SELECT x, typeof(x) FROM t1}]
} {inf real}



finish_test
Changes to test/types3.test.
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# A variable with only a string representation comes in as TEXT
do_test types3-1.1 {
  set V {}
  append V {}
  concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
} {string text}

# A variable with an integer representation comes in as INTEGER
do_test types3-1.2 {
  set V [expr {int(1+2)}]
  concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]







|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# A variable with only a string representation comes in as TEXT
do_test types3-1.1 {
  set V {}
  append V x
  concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
} {string text}

# A variable with an integer representation comes in as INTEGER
do_test types3-1.2 {
  set V [expr {int(1+2)}]
  concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
Changes to test/where3.test.
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
    CREATE INDEX t301c ON t301(c);
    INSERT INTO t301 VALUES(1,2,3);
    CREATE TABLE t302(x, y);
    ANALYZE;
    explain query plan
    SELECT * FROM t302, t301 WHERE t302.x=5 AND t301.a=t302.y;
  }
} {0 0 0 {SCAN TABLE t302 (~1 rows)} 0 1 1 {SEARCH TABLE t301 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
do_test where3-3.1 {
  execsql {
    explain query plan
    SELECT * FROM t301, t302 WHERE t302.x=5 AND t301.a=t302.y;
  }
} {0 0 1 {SCAN TABLE t302 (~1 rows)} 0 1 0 {SEARCH TABLE t301 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}

# Verify that when there are multiple tables in a join which must be
# full table scans that the query planner attempts put the table with
# the fewest number of output rows as the outer loop.
#
do_test where3-4.0 {
  execsql {







|





|







223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
    CREATE INDEX t301c ON t301(c);
    INSERT INTO t301 VALUES(1,2,3);
    CREATE TABLE t302(x, y);
    ANALYZE;
    explain query plan
    SELECT * FROM t302, t301 WHERE t302.x=5 AND t301.a=t302.y;
  }
} {0 0 0 {SCAN TABLE t302 (~100000 rows)} 0 1 1 {SEARCH TABLE t301 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
do_test where3-3.1 {
  execsql {
    explain query plan
    SELECT * FROM t301, t302 WHERE t302.x=5 AND t301.a=t302.y;
  }
} {0 0 1 {SCAN TABLE t302 (~100000 rows)} 0 1 0 {SEARCH TABLE t301 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}

# Verify that when there are multiple tables in a join which must be
# full table scans that the query planner attempts put the table with
# the fewest number of output rows as the outer loop.
#
do_test where3-4.0 {
  execsql {