SQLite4
Check-in [731841907a]
Not logged in

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

Overview
SHA1 Hash:731841907adbea47b86a8e4d73b2fd834f4df0f3
Date: 2013-06-27 17:40:13
User: dan
Comment:Run some more legacy test cases.
Tags And Properties
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbeapi.c

145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
  return (int)sqlite4VdbeIntValue((Mem*)pVal);
}
sqlite4_int64 sqlite4_value_int64(sqlite4_value *pVal){
  return sqlite4VdbeIntValue((Mem*)pVal);
}
const char *sqlite4_value_text(sqlite4_value *pVal, int *pnByte){
  const char *zRet = (const char *)sqlite4ValueText(pVal, SQLITE4_UTF8);
  if( pnByte ) *pnByte = ((Mem *)pVal)->n;
  return zRet;
}
#ifndef SQLITE4_OMIT_UTF16
const void *sqlite4_value_text16(sqlite4_value* pVal, int *pnByte){
  const void *pRet = sqlite4ValueText(pVal, SQLITE4_UTF16NATIVE);
  if( pnByte ) *pnByte = ((Mem *)pVal)->n;
  return pRet;
}
const void *sqlite4_value_text16be(sqlite4_value *pVal, int *pnByte){
  const void *pRet = sqlite4ValueText(pVal, SQLITE4_UTF16BE);
  if( pnByte ) *pnByte = ((Mem *)pVal)->n;
  return pRet;
}
const void *sqlite4_value_text16le(sqlite4_value *pVal, int *pnByte){
  const void *pRet = sqlite4ValueText(pVal, SQLITE4_UTF16LE);
  if( pnByte ) *pnByte = ((Mem *)pVal)->n;
  return pRet;
}
#endif /* SQLITE4_OMIT_UTF16 */
int sqlite4_value_type(sqlite4_value* pVal){
  return pVal->type;
}








|





|




|




|







145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
  return (int)sqlite4VdbeIntValue((Mem*)pVal);
}
sqlite4_int64 sqlite4_value_int64(sqlite4_value *pVal){
  return sqlite4VdbeIntValue((Mem*)pVal);
}
const char *sqlite4_value_text(sqlite4_value *pVal, int *pnByte){
  const char *zRet = (const char *)sqlite4ValueText(pVal, SQLITE4_UTF8);
  if( pnByte ) *pnByte = (zRet ? ((Mem *)pVal)->n : 0);
  return zRet;
}
#ifndef SQLITE4_OMIT_UTF16
const void *sqlite4_value_text16(sqlite4_value* pVal, int *pnByte){
  const void *pRet = sqlite4ValueText(pVal, SQLITE4_UTF16NATIVE);
  if( pnByte ) *pnByte = (pRet ? ((Mem *)pVal)->n : 0);
  return pRet;
}
const void *sqlite4_value_text16be(sqlite4_value *pVal, int *pnByte){
  const void *pRet = sqlite4ValueText(pVal, SQLITE4_UTF16BE);
  if( pnByte ) *pnByte = (pRet ? ((Mem *)pVal)->n : 0);
  return pRet;
}
const void *sqlite4_value_text16le(sqlite4_value *pVal, int *pnByte){
  const void *pRet = sqlite4ValueText(pVal, SQLITE4_UTF16LE);
  if( pnByte ) *pnByte = (pRet ? ((Mem *)pVal)->n : 0);
  return pRet;
}
#endif /* SQLITE4_OMIT_UTF16 */
int sqlite4_value_type(sqlite4_value* pVal){
  return pVal->type;
}

Changes to test/capi3.test

345
346
347
348
349
350
351

352
353
354
355
356
357
358
...
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
...
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
...
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
do_test $test.2 {
  set ints [list]
  foreach i $idxlist {lappend ints [sqlite4_column_int64 $STMT $i]}
  set ints
} $ints

# Blob

do_test $test.5 {
  set utf8 [list]
  foreach i $idxlist {lappend utf8 [sqlite4_column_blob $STMT $i]}
  set utf8
} $strings

# UTF-8
................................................................................
  set utf8 [list]
  foreach i $idxlist {lappend utf8 [sqlite4_column_double $STMT $i]}
  set utf8
} $doubles

# UTF-16
ifcapable {utf16} {
breakpoint
  do_test $test.8 {
    set utf8 [list]
    foreach i $idxlist {lappend utf8 [utf8 [sqlite4_column_text16 $STMT $i]]}
    set utf8
  } $strings
}

................................................................................

# This procedure returns the value of the file-format in file 'test.db'.
# 
proc get_file_format {{fname test.db}} {
  return [hexio_get_int [hexio_read $fname 44 4]]
}

if {![sqlite4 -has-codec]} {
  # Test what happens when the library encounters a newer file format.
  do_test capi3-7.1 {
    set_file_format 5
  } {}
  do_test capi3-7.2 {
    catch { sqlite4 db test.db }
    catchsql {
      SELECT * FROM sqlite_master;
    }
  } {1 {unsupported file format}}
  db close
}

if {![sqlite4 -has-codec]} {
  # Now test that the library correctly handles bogus entries in the
  # sqlite_master table (schema corruption).
  do_test capi3-8.1 {
    forcedelete test.db test.db-journal
    sqlite4 db test.db
    execsql {
................................................................................
} {0 {}}
do_test capi3-11.3.2 {
  sqlite4_errcode $DB
} {SQLITE4_OK}
do_test capi3-11.3.3 {
  sqlite4_db_transaction_status $DB
} 0
do_test capi3-11.3.4 {
  db eval {PRAGMA lock_status}
} {main shared temp closed}

do_test capi3-11.4 {
  sqlite4_step $STMT
} {SQLITE4_ERROR}
do_test capi3-11.5 {
  sqlite4_finalize $STMT
} {SQLITE4_ERROR}







>







 







<







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







<
<
<







345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
...
368
369
370
371
372
373
374

375
376
377
378
379
380
381
...
534
535
536
537
538
539
540














541
542
543
544
545
546
547
...
694
695
696
697
698
699
700



701
702
703
704
705
706
707
do_test $test.2 {
  set ints [list]
  foreach i $idxlist {lappend ints [sqlite4_column_int64 $STMT $i]}
  set ints
} $ints

# Blob
if {$test == "capi3-5.7"} breakpoint
do_test $test.5 {
  set utf8 [list]
  foreach i $idxlist {lappend utf8 [sqlite4_column_blob $STMT $i]}
  set utf8
} $strings

# UTF-8
................................................................................
  set utf8 [list]
  foreach i $idxlist {lappend utf8 [sqlite4_column_double $STMT $i]}
  set utf8
} $doubles

# UTF-16
ifcapable {utf16} {

  do_test $test.8 {
    set utf8 [list]
    foreach i $idxlist {lappend utf8 [utf8 [sqlite4_column_text16 $STMT $i]]}
    set utf8
  } $strings
}

................................................................................

# This procedure returns the value of the file-format in file 'test.db'.
# 
proc get_file_format {{fname test.db}} {
  return [hexio_get_int [hexio_read $fname 44 4]]
}















if {![sqlite4 -has-codec]} {
  # Now test that the library correctly handles bogus entries in the
  # sqlite_master table (schema corruption).
  do_test capi3-8.1 {
    forcedelete test.db test.db-journal
    sqlite4 db test.db
    execsql {
................................................................................
} {0 {}}
do_test capi3-11.3.2 {
  sqlite4_errcode $DB
} {SQLITE4_OK}
do_test capi3-11.3.3 {
  sqlite4_db_transaction_status $DB
} 0




do_test capi3-11.4 {
  sqlite4_step $STMT
} {SQLITE4_ERROR}
do_test capi3-11.5 {
  sqlite4_finalize $STMT
} {SQLITE4_ERROR}

Changes to test/check.test

113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
...
144
145
146
147
148
149
150


151
152
153
154
155
156
157
158
159
160
161
162
...
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
    SELECT * FROM t1;
  }
} {4 11.0}

do_test check-2.1 {
  execsql {
    CREATE TABLE t2(
      x INTEGER CHECK( typeof(coalesce(x,0))=="integer" ),
      y REAL CHECK( typeof(coalesce(y,0.1))=='real' ),
      z TEXT CHECK( typeof(coalesce(z,''))=='text' )
    );
  }
} {}
do_test check-2.2 {
  execsql {
................................................................................
} {1 {constraint failed}}
do_test check-2.5 {
  catchsql {
    INSERT INTO t2 VALUES(NULL, 5, NULL);
  }
} {1 {constraint failed}}
do_test check-2.6 {


  catchsql {
    INSERT INTO t2 VALUES(NULL, NULL, 3.14159);
  }
} {1 {constraint failed}}

ifcapable subquery {
  do_test check-3.1 {
    catchsql {
      CREATE TABLE t3(
        x, y, z,
        CHECK( x<(SELECT min(x) FROM t1) )
      );
................................................................................
} {0 1}
do_test check-4.9 {
  catchsql {
    PRAGMA ignore_check_constraints=OFF;
    UPDATE t4 SET x=0, y=2;
  }
} {1 {constraint failed}}
ifcapable vacuum {
  do_test check_4.10 {
    catchsql {
      VACUUM
    }
  } {0 {}}
}

do_test check-5.1 {
  catchsql {
    CREATE TABLE t5(x, y,
      CHECK( x*y<:abc )
    );
  }







|







 







>
>



|
<







 







<
<
<
<
<
<
<







113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
...
144
145
146
147
148
149
150
151
152
153
154
155
156

157
158
159
160
161
162
163
...
271
272
273
274
275
276
277







278
279
280
281
282
283
284
    SELECT * FROM t1;
  }
} {4 11.0}

do_test check-2.1 {
  execsql {
    CREATE TABLE t2(
      x INTEGER CHECK( typeof(coalesce(x,0))=='integer' ),
      y REAL CHECK( typeof(coalesce(y,0.1))=='real' ),
      z TEXT CHECK( typeof(coalesce(z,''))=='text' )
    );
  }
} {}
do_test check-2.2 {
  execsql {
................................................................................
} {1 {constraint failed}}
do_test check-2.5 {
  catchsql {
    INSERT INTO t2 VALUES(NULL, 5, NULL);
  }
} {1 {constraint failed}}
do_test check-2.6 {
  # This does not fail with src4. As CHECK constraints are evaluated after
  # affinities are applied.
  catchsql {
    INSERT INTO t2 VALUES(NULL, NULL, 3.14159);
  }
} {0 {}}

ifcapable subquery {
  do_test check-3.1 {
    catchsql {
      CREATE TABLE t3(
        x, y, z,
        CHECK( x<(SELECT min(x) FROM t1) )
      );
................................................................................
} {0 1}
do_test check-4.9 {
  catchsql {
    PRAGMA ignore_check_constraints=OFF;
    UPDATE t4 SET x=0, y=2;
  }
} {1 {constraint failed}}








do_test check-5.1 {
  catchsql {
    CREATE TABLE t5(x, y,
      CHECK( x*y<:abc )
    );
  }

Changes to test/coalesce.test

65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
  db eval {
    SELECT ifnull(nullif(a,4),99)
      FROM t1 ORDER BY a;
  }
} {1 2 3 99 5 6 7 8}
do_test coalesce-1.8 {
  db eval {
pragma vdbe_listing=on;
    SELECT coalesce(
      CASE WHEN b=2 THEN 123 END,
      CASE WHEN b=3 THEN 234 END,
      CASE WHEN c=3 THEN 345 WHEN c=33 THEN 456 END,
      d
    )
    FROM t1 ORDER BY a;
  }
} {{} 123 345 4 {} 99 456 44}


finish_test







<












65
66
67
68
69
70
71

72
73
74
75
76
77
78
79
80
81
82
83
  db eval {
    SELECT ifnull(nullif(a,4),99)
      FROM t1 ORDER BY a;
  }
} {1 2 3 99 5 6 7 8}
do_test coalesce-1.8 {
  db eval {

    SELECT coalesce(
      CASE WHEN b=2 THEN 123 END,
      CASE WHEN b=3 THEN 234 END,
      CASE WHEN c=3 THEN 345 WHEN c=33 THEN 456 END,
      d
    )
    FROM t1 ORDER BY a;
  }
} {{} 123 345 4 {} 99 456 44}


finish_test

Changes to test/createtab.test

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  } {4}

  set isUtf16 0
  ifcapable utf16 { 
    set isUtf16 [expr {[execsql {PRAGMA encoding}] != "UTF-8"}]
  }

  do_test createtab-$av.2 {
    file size test.db
  } [expr {1024*(4+($av!=0)+(${isUtf16}*2))}]
  
  # Start reading the table
  #
  do_test createtab-$av.3 {
    set STMT [sqlite4_prepare db {SELECT x FROM t1} -1 TAIL]
    sqlite4_step $STMT
  } {SQLITE4_ROW}







|
|
|







47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  } {4}

  set isUtf16 0
  ifcapable utf16 { 
    set isUtf16 [expr {[execsql {PRAGMA encoding}] != "UTF-8"}]
  }

  #do_test createtab-$av.2 {
  #  file size test.db
  #} [expr {1024*(4+($av!=0)+(${isUtf16}*2))}]
  
  # Start reading the table
  #
  do_test createtab-$av.3 {
    set STMT [sqlite4_prepare db {SELECT x FROM t1} -1 TAIL]
    sqlite4_step $STMT
  } {SQLITE4_ROW}

Changes to test/descidx1.test

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
...
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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# Verify that the file format starts as 4.
#
do_test descidx1-1.1 {
  execsql {
    CREATE TABLE t1(a,b);
    CREATE INDEX i1 ON t1(b ASC);
  }
  get_file_format
} {4}
do_test descidx1-1.2 {
  execsql {
    CREATE INDEX i2 ON t1(a DESC);
  }
  get_file_format
} {4}

# Put some information in the table and verify that the descending
# index actually works.
#
do_test descidx1-2.1 {
  execsql {
    INSERT INTO t1 VALUES(1,1);
................................................................................
  }
} {000 001 010 011 100 101 110 111 sort}
do_test descidx1-5.9 {
  cksort {
    SELECT a||b||c FROM t3 WHERE d=0 ORDER BY a DESC, b DESC, c ASC
  }
} {110 111 100 101 010 011 000 001 sort}

# Test the legacy_file_format pragma here because we have access to
# the get_file_format command.
#
ifcapable legacyformat {
  do_test descidx1-6.1 {
    db close
    forcedelete test.db test.db-journal
    sqlite4 db test.db
    execsql {PRAGMA legacy_file_format}
  } {1}
} else {
  do_test descidx1-6.1 {
    db close
    forcedelete test.db test.db-journal
    sqlite4 db test.db
    execsql {PRAGMA legacy_file_format}
  } {0}
}
do_test descidx1-6.2 {
  execsql {PRAGMA legacy_file_format=YES}
  execsql {PRAGMA legacy_file_format}
} {1}
do_test descidx1-6.3 {
  execsql {
    CREATE TABLE t1(a,b,c);
  }
  get_file_format
} {1}
ifcapable vacuum {
  # Verify that the file format is preserved across a vacuum.
  do_test descidx1-6.3.1 {
    execsql {VACUUM}
    get_file_format
  } {1}
}
do_test descidx1-6.4 {
  db close
  forcedelete test.db test.db-journal
  sqlite4 db test.db
  execsql {PRAGMA legacy_file_format=NO}
  execsql {PRAGMA legacy_file_format}
} {0}
do_test descidx1-6.5 {
  execsql {
    CREATE TABLE t1(a,b,c);
    CREATE INDEX i1 ON t1(a ASC, b DESC, c ASC);
    INSERT INTO t1 VALUES(1,2,3);
    INSERT INTO t1 VALUES(1,1,0);
    INSERT INTO t1 VALUES(1,2,1);
    INSERT INTO t1 VALUES(1,3,4);
  }
  get_file_format
} {4}
ifcapable vacuum {
  # Verify that the file format is preserved across a vacuum.
  do_test descidx1-6.6 {
    execsql {VACUUM}
    get_file_format
  } {4}
  do_test descidx1-6.7 {
    execsql {
      PRAGMA legacy_file_format=ON;
      VACUUM;
    }
    get_file_format
  } {4}
} 



finish_test







<
|




<
|







 








<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

45
46
47
48
49
50
51

52
53
54
55
56

57
58
59
60
61
62
63
64
...
284
285
286
287
288
289
290
291






































































292
# Verify that the file format starts as 4.
#
do_test descidx1-1.1 {
  execsql {
    CREATE TABLE t1(a,b);
    CREATE INDEX i1 ON t1(b ASC);
  }

} {}
do_test descidx1-1.2 {
  execsql {
    CREATE INDEX i2 ON t1(a DESC);
  }

} {}

# Put some information in the table and verify that the descending
# index actually works.
#
do_test descidx1-2.1 {
  execsql {
    INSERT INTO t1 VALUES(1,1);
................................................................................
  }
} {000 001 010 011 100 101 110 111 sort}
do_test descidx1-5.9 {
  cksort {
    SELECT a||b||c FROM t3 WHERE d=0 ORDER BY a DESC, b DESC, c ASC
  }
} {110 111 100 101 010 011 000 001 sort}







































































finish_test

Changes to test/descidx2.test

7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
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
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
110
111
112
113
114
115
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#*************************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is descending indices.
#
# $Id: descidx2.test,v 1.5 2008/03/19 00:21:31 drh Exp $
#

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

# Do not use a codec for tests in this file, as the database file is
# manipulated directly using tcl scripts (using the [hexio_write] command).
#
do_not_use_codec


db eval {PRAGMA legacy_file_format=OFF}

# This procedure sets the value of the file-format in file 'test.db'
# to $newval. Also, the schema cookie is incremented.
# 
proc set_file_format {newval} {
  hexio_write test.db 44 [hexio_render_int32 $newval]
  set schemacookie [hexio_get_int [hexio_read test.db 40 4]]
  incr schemacookie
  hexio_write test.db 40 [hexio_render_int32 $schemacookie]
  return {}
}

# This procedure returns the value of the file-format in file 'test.db'.
# 
proc get_file_format {{fname test.db}} {
  return [hexio_get_int [hexio_read $fname 44 4]]
}


# Verify that the file format starts as 4
#
do_test descidx2-1.1 {
  execsql {
    CREATE TABLE t1(a,b);
    CREATE INDEX i1 ON t1(b ASC);
  }
  get_file_format
} {4}
do_test descidx2-1.2 {
  execsql {
    CREATE INDEX i2 ON t1(a DESC);
  }
  get_file_format
} {4}

# Before adding any information to the database, set the file format
# back to three.  Then close and reopen the database.  With the file
# format set to three, SQLite should ignore the DESC argument on the
# index.
#
do_test descidx2-2.0 {
  set_file_format 3
  db close
  sqlite4 db test.db
  get_file_format
} {3}

# Put some information in the table and verify that the DESC
# on the index is ignored.
#
do_test descidx2-2.1 {
  execsql {
    INSERT INTO t1 VALUES(1,1);
    INSERT INTO t1 VALUES(2,2);
    INSERT INTO t1 SELECT a+2, a+2 FROM t1;
    INSERT INTO t1 SELECT a+4, a+4 FROM t1;
    SELECT b FROM t1 WHERE a>3 AND a<7;
  }
} {4 5 6}
do_test descidx2-2.2 {
  execsql {
    SELECT a FROM t1 WHERE b>3 AND b<7;
  }
} {4 5 6}
do_test descidx2-2.3 {
  execsql {
    SELECT b FROM t1 WHERE a>=3 AND a<7;
  }
} {3 4 5 6}
do_test descidx2-2.4 {
  execsql {
    SELECT b FROM t1 WHERE a>3 AND a<=7;
  }
} {4 5 6 7}
do_test descidx2-2.5 {
  execsql {
    SELECT b FROM t1 WHERE a>=3 AND a<=7;
  }
} {3 4 5 6 7}
do_test descidx2-2.6 {
  execsql {
    SELECT a FROM t1 WHERE b>=3 AND b<=7;
  }
} {3 4 5 6 7}

# This procedure executes the SQL.  Then it checks to see if the OP_Sort
# opcode was executed.  If an OP_Sort did occur, then "sort" is appended
# to the result.  If no OP_Sort happened, then "nosort" is appended.
#







<
<




<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








<
|




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










|




|




|




|




|




|







7
8
9
10
11
12
13


14
15
16
17

























18
19
20
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#*************************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is descending indices.
#



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



























# Verify that the file format starts as 4
#
do_test descidx2-1.1 {
  execsql {
    CREATE TABLE t1(a,b);
    CREATE INDEX i1 ON t1(b ASC);
  }

} {}
do_test descidx2-1.2 {
  execsql {
    CREATE INDEX i2 ON t1(a DESC);
  }

} {}













# Put some information in the table and verify that the DESC
# on the index is ignored.
#
do_test descidx2-2.1 {
  execsql {
    INSERT INTO t1 VALUES(1,1);
    INSERT INTO t1 VALUES(2,2);
    INSERT INTO t1 SELECT a+2, a+2 FROM t1;
    INSERT INTO t1 SELECT a+4, a+4 FROM t1;
    SELECT b FROM t1 WHERE a>3 AND a<7 ORDER BY b ASC;
  }
} {4 5 6}
do_test descidx2-2.2 {
  execsql {
    SELECT a FROM t1 WHERE b>3 AND b<7 ORDER BY a ASC;
  }
} {4 5 6}
do_test descidx2-2.3 {
  execsql {
    SELECT b FROM t1 WHERE a>=3 AND a<7 ORDER BY b ASC;
  }
} {3 4 5 6}
do_test descidx2-2.4 {
  execsql {
    SELECT b FROM t1 WHERE a>3 AND a<=7 ORDER BY b ASC;
  }
} {4 5 6 7}
do_test descidx2-2.5 {
  execsql {
    SELECT b FROM t1 WHERE a>=3 AND a<=7 ORDER BY b ASC;
  }
} {3 4 5 6 7}
do_test descidx2-2.6 {
  execsql {
    SELECT a FROM t1 WHERE b>=3 AND b<=7 ORDER BY a ASC;
  }
} {3 4 5 6 7}

# This procedure executes the SQL.  Then it checks to see if the OP_Sort
# opcode was executed.  If an OP_Sort did occur, then "sort" is appended
# to the result.  If no OP_Sort happened, then "nosort" is appended.
#

Changes to test/descidx3.test

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
56
57
58
59
60
61
62
63
64
#
do_not_use_codec

ifcapable !bloblit {
  finish_test
  return
}
db eval {PRAGMA legacy_file_format=OFF}

# This procedure sets the value of the file-format in file 'test.db'
# to $newval. Also, the schema cookie is incremented.
# 
proc set_file_format {newval} {
  hexio_write test.db 44 [hexio_render_int32 $newval]
  set schemacookie [hexio_get_int [hexio_read test.db 40 4]]
  incr schemacookie
  hexio_write test.db 40 [hexio_render_int32 $schemacookie]
  return {}
}

# This procedure returns the value of the file-format in file 'test.db'.
# 
proc get_file_format {{fname test.db}} {
  return [hexio_get_int [hexio_read $fname 44 4]]
}

# Verify that the file format starts as 4.
#
do_test descidx3-1.1 {
  execsql {
    CREATE TABLE t1(i INTEGER PRIMARY KEY,a,b,c,d);
    CREATE INDEX t1i1 ON t1(a DESC, b ASC, c DESC);
    CREATE INDEX t1i2 ON t1(b DESC, c ASC, d DESC);
  }
  get_file_format
} {4}

# Put some information in the table and verify that the descending
# index actually works.
#
do_test descidx3-2.1 {
  execsql {
    INSERT INTO t1 VALUES(1, NULL, NULL, NULL, NULL);







<

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






<
|







22
23
24
25
26
27
28

29



















30
31
32
33
34
35

36
37
38
39
40
41
42
43
#
do_not_use_codec

ifcapable !bloblit {
  finish_test
  return
}





















do_test descidx3-1.1 {
  execsql {
    CREATE TABLE t1(i INTEGER PRIMARY KEY,a,b,c,d);
    CREATE INDEX t1i1 ON t1(a DESC, b ASC, c DESC);
    CREATE INDEX t1i2 ON t1(b DESC, c ASC, d DESC);
  }

} {}

# Put some information in the table and verify that the descending
# index actually works.
#
do_test descidx3-2.1 {
  execsql {
    INSERT INTO t1 VALUES(1, NULL, NULL, NULL, NULL);

Changes to test/permutations.test

152
153
154
155
156
157
158

159
160
161

162
163

164
165
166

167

168
169
170
171
172
173
174
  between.test
  bigrow.test
  bind.test
  blob.test
  boundary1.test boundary2.test boundary3.test boundary4.test
  capi2.test
  cast.test

  coalesce.test 
  collate1.test collate2.test collate3.test collate4.test collate5.test
  collate6.test collate7.test collate8.test collate9.test collateA.test

  conflict.test 
  count.test

  cse.test
  ctime.test
  date.test

  delete.test delete2.test

  distinct.test distinctagg.test
  enc.test enc4.test
  exists.test
  e_droptrigger.test e_dropview.test
  e_resolve.test e_dropview.test
  e_select2.test
  fkey1.test fkey2.test fkey3.test fkey4.test







>



>


>



>
|
>







152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
  between.test
  bigrow.test
  bind.test
  blob.test
  boundary1.test boundary2.test boundary3.test boundary4.test
  capi2.test
  cast.test
  check.test
  coalesce.test 
  collate1.test collate2.test collate3.test collate4.test collate5.test
  collate6.test collate7.test collate8.test collate9.test collateA.test
  collateerr.test
  conflict.test 
  count.test
  createtab.test
  cse.test
  ctime.test
  date.test
  default.test
  delete.test delete2.test delete3.test
  descidx1.test descidx2.test descidx3.test 
  distinct.test distinctagg.test
  enc.test enc4.test
  exists.test
  e_droptrigger.test e_dropview.test
  e_resolve.test e_dropview.test
  e_select2.test
  fkey1.test fkey2.test fkey3.test fkey4.test

Changes to www/porting.wiki

75
76
77
78
79
80
81
82









    /* pError now points to a buffer containing the current error message
    ** encoded using native byte-order UTF-16. Do something with it! */
  }

  /* Free the contents of the buffer (and hence pError) */
  sqlite4_buffer_clear(&buf);
</pre>


















>
>
>
>
>
>
>
>
>
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
    /* pError now points to a buffer containing the current error message
    ** encoded using native byte-order UTF-16. Do something with it! */
  }

  /* Free the contents of the buffer (and hence pError) */
  sqlite4_buffer_clear(&buf);
</pre>

<h3> CHECK Constraint Evaluation </h3>

<p>
In SQLite4, CHECK constraints are evaluated after affinities are applied
to new column values. In SQLite3, the CHECK constraints are evaluated before
affinities are applied.