/ Check-in [5d95b429]
Login

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

Overview
Comment:Pull the latest trunk changes into the sessions branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sessions
Files: files | file ages | folders
SHA1:5d95b42946b5cf0346164aebe0a8c4f37527bc31
User & Date: drh 2011-06-23 02:11:11
Context
2011-06-23
17:40
Pull the latest version 3.7.7 release-candidate changes into the sessions branch. check-in: 840bf9c2 user: drh tags: sessions
02:11
Pull the latest trunk changes into the sessions branch. check-in: 5d95b429 user: drh tags: sessions
01:42
Provide the SQLITE_MAX_SCHEMA_RETRY compile-time parameter for adjusting the number of reparse attempts after a schema change. check-in: 8dca748b user: drh tags: trunk
2011-06-22
12:01
Update sessions branch with latest trunk changes. check-in: 48d5cab3 user: dan tags: sessions
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3.c.

640
641
642
643
644
645
646



647
648
649
650
651
652
653
      rc = SQLITE_NOMEM;
    }else{
      rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
      if( rc==SQLITE_OK ){
        sqlite3_step(pStmt);
        p->nPgsz = sqlite3_column_int(pStmt, 0);
        rc = sqlite3_finalize(pStmt);



      }
    }
    assert( p->nPgsz>0 || rc!=SQLITE_OK );
    sqlite3_free(zSql);
    *pRc = rc;
  }
}







>
>
>







640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
      rc = SQLITE_NOMEM;
    }else{
      rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
      if( rc==SQLITE_OK ){
        sqlite3_step(pStmt);
        p->nPgsz = sqlite3_column_int(pStmt, 0);
        rc = sqlite3_finalize(pStmt);
      }else if( rc==SQLITE_AUTH ){
        p->nPgsz = 1024;
        rc = SQLITE_OK;
      }
    }
    assert( p->nPgsz>0 || rc!=SQLITE_OK );
    sqlite3_free(zSql);
    *pRc = rc;
  }
}

Changes to src/test1.c.

5513
5514
5515
5516
5517
5518
5519





5520
5521
5522
5523
5524
5525
5526

  if( objc!=2 ){
    Tcl_WrongNumArgs(interp, 1, objv, "STMT");
    return TCL_ERROR;
  }
  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
  rc = printExplainQueryPlan(pStmt);





  Tcl_SetResult(interp, (char *)t1ErrorName(rc), 0);
  return TCL_OK;
}
#endif /* SQLITE_OMIT_EXPLAIN */

/*
** sqlite3_test_control VERB ARGS...







>
>
>
>
>







5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531

  if( objc!=2 ){
    Tcl_WrongNumArgs(interp, 1, objv, "STMT");
    return TCL_ERROR;
  }
  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
  rc = printExplainQueryPlan(pStmt);
  /* This is needed on Windows so that a test case using this 
  ** function can open a read pipe and get the output of
  ** printExplainQueryPlan() immediately.
  */
  fflush(stdout);
  Tcl_SetResult(interp, (char *)t1ErrorName(rc), 0);
  return TCL_OK;
}
#endif /* SQLITE_OMIT_EXPLAIN */

/*
** sqlite3_test_control VERB ARGS...

Changes to src/test_vfs.c.

1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
....
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
      break;
    }

    case CMD_SCRIPT: {
      if( objc==3 ){
        int nByte;
        if( p->pScript ){
          int i;
          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);
................................................................................
  }

  return TCL_OK;
}

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

/*







<







 







<







1066
1067
1068
1069
1070
1071
1072

1073
1074
1075
1076
1077
1078
1079
....
1218
1219
1220
1221
1222
1223
1224

1225
1226
1227
1228
1229
1230
1231
      break;
    }

    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);
................................................................................
  }

  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);
}

/*

Changes to src/vdbeapi.c.

455
456
457
458
459
460
461








462
463
464
465
466
467
468
...
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
    ** caller. Set the error code in the database handle to the same value.
    */ 
    rc = db->errCode = p->rc;
  }
  return (rc&db->errMask);
}









/*
** This is the top-level implementation of sqlite3_step().  Call
** sqlite3Step() to do most of the work.  If a schema error occurs,
** call sqlite3Reprepare() and try again.
*/
int sqlite3_step(sqlite3_stmt *pStmt){
  int rc = SQLITE_OK;      /* Result from sqlite3Step() */
................................................................................

  if( vdbeSafetyNotNull(v) ){
    return SQLITE_MISUSE_BKPT;
  }
  db = v->db;
  sqlite3_mutex_enter(db->mutex);
  while( (rc = sqlite3Step(v))==SQLITE_SCHEMA
         && cnt++ < 5
         && (rc2 = rc = sqlite3Reprepare(v))==SQLITE_OK ){
    sqlite3_reset(pStmt);
    v->expired = 0;
  }
  if( rc2!=SQLITE_OK && ALWAYS(v->isPrepareV2) && ALWAYS(db->pErr) ){
    /* This case occurs after failing to recompile an sql statement. 
    ** The error message from the SQL compiler has already been loaded 







>
>
>
>
>
>
>
>







 







|







455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
...
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
    ** caller. Set the error code in the database handle to the same value.
    */ 
    rc = db->errCode = p->rc;
  }
  return (rc&db->errMask);
}

/*
** The maximum number of times that a statement will try to reparse
** itself before giving up and returning SQLITE_SCHEMA.
*/
#ifndef SQLITE_MAX_SCHEMA_RETRY
# define SQLITE_MAX_SCHEMA_RETRY 5
#endif

/*
** This is the top-level implementation of sqlite3_step().  Call
** sqlite3Step() to do most of the work.  If a schema error occurs,
** call sqlite3Reprepare() and try again.
*/
int sqlite3_step(sqlite3_stmt *pStmt){
  int rc = SQLITE_OK;      /* Result from sqlite3Step() */
................................................................................

  if( vdbeSafetyNotNull(v) ){
    return SQLITE_MISUSE_BKPT;
  }
  db = v->db;
  sqlite3_mutex_enter(db->mutex);
  while( (rc = sqlite3Step(v))==SQLITE_SCHEMA
         && cnt++ < SQLITE_MAX_SCHEMA_RETRY
         && (rc2 = rc = sqlite3Reprepare(v))==SQLITE_OK ){
    sqlite3_reset(pStmt);
    v->expired = 0;
  }
  if( rc2!=SQLITE_OK && ALWAYS(v->isPrepareV2) && ALWAYS(db->pErr) ){
    /* This case occurs after failing to recompile an sql statement. 
    ** The error message from the SQL compiler has already been loaded 

Changes to test/fts4aa.test.

18
19
20
21
22
23
24
25



26
27
28
29
30
31
32
33
34
....
1557
1558
1559
1560
1561
1562
1563































1564
1565

1566
1567
1568
1569
1570
1571
1572
1573
....
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632































































1633

# If SQLITE_ENABLE_FTS3 is defined, omit this file.
ifcapable !fts3 {
  finish_test
  return
}

do_test fts4aa-1.0 {



db eval {
CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
BEGIN TRANSACTION;
INSERT INTO t1(docid,words) VALUES(1001001,'In the beginning God created the heaven and the earth.');
INSERT INTO t1(docid,words) VALUES(1001002,'And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.');
INSERT INTO t1(docid,words) VALUES(1001003,'And God said, Let there be light: and there was light.');
INSERT INTO t1(docid,words) VALUES(1001004,'And God saw the light, that it was good: and God divided the light from the darkness.');
INSERT INTO t1(docid,words) VALUES(1001005,'And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.');
INSERT INTO t1(docid,words) VALUES(1001006,'And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.');
................................................................................
INSERT INTO t1(docid,words) VALUES(1050022,'And Joseph dwelt in Egypt, he, and his father''s house: and Joseph lived an hundred and ten years.');
INSERT INTO t1(docid,words) VALUES(1050023,'And Joseph saw Ephraim''s children of the third generation: the children also of Machir the son of Manasseh were brought up upon Joseph''s knees.');
INSERT INTO t1(docid,words) VALUES(1050024,'And Joseph said unto his brethren, I die: and God will surely visit you, and bring you out of this land unto the land which he sware to Abraham, to Isaac, and to Jacob.');
INSERT INTO t1(docid,words) VALUES(1050025,'And Joseph took an oath of the children of Israel, saying, God will surely visit you, and ye shall carry up my bones from hence.');
INSERT INTO t1(docid,words) VALUES(1050026,'So Joseph died, being an hundred and ten years old: and they embalmed him, and he was put in a coffin in Egypt.');
COMMIT;
}































} {}



do_test fts4aa-1.1 {
  db eval {
    SELECT docid FROM t1 EXCEPT SELECT docid FROM t1_docsize
  }
} {}
do_test fts4aa-1.2 {
  db eval {
................................................................................
  set scan(littleEndian) i*
  set scan(bigEndian) I*
  binary scan $blob $scan($::tcl_platform(byteOrder)) r
  return $r
}
db func mit mit

do_test fts4aa-2.1 {
  db eval {
    SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1 WHERE t1 MATCH 'melchizedek';
  }
} {1014018 {1 1 1 1 1 1533 25 20}}
do_test fts4aa-2.2 {
  db eval {
    SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
     WHERE t1 MATCH 'spake hebrew'
     ORDER BY docid;
  }
} {1039014 {2 1 1 40 40 1 6 6 1533 25 42} 1039017 {2 1 1 40 40 1 6 6 1533 25 26}}
do_test fts4aa-2.3 {
  db eval {
    SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
     WHERE t1 MATCH 'laban overtook jacob'
     ORDER BY docid;
  }
} {1031025 {3 1 2 54 46 1 3 3 2 181 160 1533 25 24}}

do_test fts4aa-9.1 {
  db eval {
    DELETE FROM t1 WHERE docid!=1050026;
    SELECT hex(size) FROM t1_docsize;
    SELECT hex(value) FROM t1_stat;
  }
} {17 01176F}

do_test fts4aa-9.2 {
  db eval {
    SELECT docid FROM t1 EXCEPT SELECT docid FROM t1_docsize
  }
} {}
do_test fts4aa-9.3 {
  db eval {
    SELECT docid FROM t1_docsize EXCEPT SELECT docid FROM t1
  }
} {}
do_test fts4aa-9.4 {
  # Note: Token 'in' is being deferred in the following query. 
  db eval {
    SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
     WHERE t1 MATCH 'joseph died in egypt'
     ORDER BY docid;
  }
} {1050026 {4 1 1 1 1 1 1 1 2 1 1 1 1 1 1 23 23}}
































































finish_test







|
>
>
>

<







 







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


>
|







 







|




|






|







|







|




|




|








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

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

30
31
32
33
34
35
36
....
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
....
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730

# If SQLITE_ENABLE_FTS3 is defined, omit this file.
ifcapable !fts3 {
  finish_test
  return
}

# This procedure fills an existing FTS3/FTS4 table with many entries.
# The table needs to have a single column (other than docid) named "words".
#
proc fts4aa_fill_table {} {
db eval {

BEGIN TRANSACTION;
INSERT INTO t1(docid,words) VALUES(1001001,'In the beginning God created the heaven and the earth.');
INSERT INTO t1(docid,words) VALUES(1001002,'And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.');
INSERT INTO t1(docid,words) VALUES(1001003,'And God said, Let there be light: and there was light.');
INSERT INTO t1(docid,words) VALUES(1001004,'And God saw the light, that it was good: and God divided the light from the darkness.');
INSERT INTO t1(docid,words) VALUES(1001005,'And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.');
INSERT INTO t1(docid,words) VALUES(1001006,'And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.');
................................................................................
INSERT INTO t1(docid,words) VALUES(1050022,'And Joseph dwelt in Egypt, he, and his father''s house: and Joseph lived an hundred and ten years.');
INSERT INTO t1(docid,words) VALUES(1050023,'And Joseph saw Ephraim''s children of the third generation: the children also of Machir the son of Manasseh were brought up upon Joseph''s knees.');
INSERT INTO t1(docid,words) VALUES(1050024,'And Joseph said unto his brethren, I die: and God will surely visit you, and bring you out of this land unto the land which he sware to Abraham, to Isaac, and to Jacob.');
INSERT INTO t1(docid,words) VALUES(1050025,'And Joseph took an oath of the children of Israel, saying, God will surely visit you, and ye shall carry up my bones from hence.');
INSERT INTO t1(docid,words) VALUES(1050026,'So Joseph died, being an hundred and ten years old: and they embalmed him, and he was put in a coffin in Egypt.');
COMMIT;
}
}

# The following is a list of queries to perform against the above
# FTS3/FTS4 database.  We will be trying these queries in various
# configurations to ensure that they always return the same answers.
#
set fts4aa_queries {
  {abraham}
  {the king}
  {"the king"}
  {abraham OR joseph}
  {ab* OR jos*}
  {lived t*}
  {spake hebrew}
  {melchizedek}
  {t* melchizedek}
  {melchizedek t*}
}
unset -nocomplain fts4aa_res

# Set up the baseline results
#
do_test fts4aa-1.0 {
  db eval {
    CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
  }
  fts4aa_fill_table
  foreach q $::fts4aa_queries {
    set r [db eval {SELECT docid FROM t1 WHERE words MATCH $q ORDER BY docid}]
    set ::fts4aa_res($q) $r
  }
} {}

# Legacy test cases
#
do_test fts4aa-1.1 {
  db eval {
    SELECT docid FROM t1 EXCEPT SELECT docid FROM t1_docsize
  }
} {}
do_test fts4aa-1.2 {
  db eval {
................................................................................
  set scan(littleEndian) i*
  set scan(bigEndian) I*
  binary scan $blob $scan($::tcl_platform(byteOrder)) r
  return $r
}
db func mit mit

do_test fts4aa-1.3 {
  db eval {
    SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1 WHERE t1 MATCH 'melchizedek';
  }
} {1014018 {1 1 1 1 1 1533 25 20}}
do_test fts4aa-1.4 {
  db eval {
    SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
     WHERE t1 MATCH 'spake hebrew'
     ORDER BY docid;
  }
} {1039014 {2 1 1 40 40 1 6 6 1533 25 42} 1039017 {2 1 1 40 40 1 6 6 1533 25 26}}
do_test fts4aa-1.5 {
  db eval {
    SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
     WHERE t1 MATCH 'laban overtook jacob'
     ORDER BY docid;
  }
} {1031025 {3 1 2 54 46 1 3 3 2 181 160 1533 25 24}}

do_test fts4aa-1.6 {
  db eval {
    DELETE FROM t1 WHERE docid!=1050026;
    SELECT hex(size) FROM t1_docsize;
    SELECT hex(value) FROM t1_stat;
  }
} {17 01176F}

do_test fts4aa-1.7 {
  db eval {
    SELECT docid FROM t1 EXCEPT SELECT docid FROM t1_docsize
  }
} {}
do_test fts4aa-1.8 {
  db eval {
    SELECT docid FROM t1_docsize EXCEPT SELECT docid FROM t1
  }
} {}
do_test fts4aa-1.9 {
  # Note: Token 'in' is being deferred in the following query. 
  db eval {
    SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
     WHERE t1 MATCH 'joseph died in egypt'
     ORDER BY docid;
  }
} {1050026 {4 1 1 1 1 1 1 1 2 1 1 1 1 1 1 23 23}}

# Should get the same search results from FTS3
#
do_test fts4aa-2.0 {
  db eval {
    DROP TABLE t1;
    CREATE VIRTUAL TABLE t1 USING fts3(words, tokenize porter);
  }
  fts4aa_fill_table
} {}
unset -nocomplain ii
set ii 0
foreach {q r} [array get fts4aa_res] {
  incr ii
  do_test fts4aa-2.$ii {
    db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}
  } $r
}

# Should get the same search results when the page size is very large
#
do_test fts4aa-3.0 {
  db close
  file delete -force test.db
  sqlite3 db test.db
  db eval {
    PRAGMA page_size=65536;
    CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
  }
  fts4aa_fill_table
} {}
unset -nocomplain ii
set ii 0
foreach {q r} [array get fts4aa_res] {
  incr ii
  do_test fts4aa-3.$ii {
    db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}
  } $r
}

# Should get the same search results when an authorizer prevents
# all PRAGMA statements.
#
proc no_pragma_auth {code arg1 arg2 arg3 arg4} {
  if {$code=="SQLITE_PRAGMA"} {return SQLITE_DENY}
  return SQLITE_OK;
}
do_test fts4aa-4.0 {
  db auth ::no_pragma_auth
  db eval {
    DROP TABLE t1;
    CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
  }
  fts4aa_fill_table
} {}
unset -nocomplain ii
set ii 0
foreach {q r} [array get fts4aa_res] {
  incr ii
  do_test fts4aa-4.$ii {
    db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}
  } $r
}

finish_test

Changes to test/oserror.test.

47
48
49
50
51
52
53

54
55
56
57
58
59
60
# Test a failure in open() due to too many files. 
#
# The xOpen() method of the unix VFS calls getcwd() as well as open().
# Although this does not appear to be documented in the man page, on OSX
# a call to getcwd() may fail if there are no free file descriptors. So
# an error may be reported for either open() or getcwd() here.
#

do_test 1.1.1 {
  set ::log [list]
  list [catch {
    for {set i 0} {$i < 2000} {incr i} { sqlite3 dbh_$i test.db -readonly 1 }
  } msg] $msg
} {1 {unable to open database file}}
do_test 1.1.2 {







>







47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Test a failure in open() due to too many files. 
#
# The xOpen() method of the unix VFS calls getcwd() as well as open().
# Although this does not appear to be documented in the man page, on OSX
# a call to getcwd() may fail if there are no free file descriptors. So
# an error may be reported for either open() or getcwd() here.
#
puts "Possible valgrind error about invalid file descriptor follows:"
do_test 1.1.1 {
  set ::log [list]
  list [catch {
    for {set i 0} {$i < 2000} {incr i} { sqlite3 dbh_$i test.db -readonly 1 }
  } msg] $msg
} {1 {unable to open database file}}
do_test 1.1.2 {

Changes to test/triggerC.test.

224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
      INSERT INTO t2 VALUES(10);
      SELECT * FROM t2;
    }
  } $rc
}

do_test triggerC-2.2 {
  execsql {
    CREATE TABLE t22(x);

    CREATE TRIGGER t22a AFTER INSERT ON t22 BEGIN
      INSERT INTO t22 SELECT x + (SELECT max(x) FROM t22) FROM t22;
    END;
    CREATE TRIGGER t22b BEFORE INSERT ON t22 BEGIN
      SELECT CASE WHEN (SELECT count(*) FROM t22) >= 100
                  THEN RAISE(IGNORE)
                  ELSE NULL END;
    END;

    INSERT INTO t22 VALUES(1);
    SELECT count(*) FROM t22;
  }
} {100}

do_test triggerC-2.3 {
  execsql "
    CREATE TABLE t23(x PRIMARY KEY);

    CREATE TRIGGER t23a AFTER INSERT ON t23 BEGIN
      INSERT INTO t23 VALUES(new.x + 1);







|






|






|
|







224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
      INSERT INTO t2 VALUES(10);
      SELECT * FROM t2;
    }
  } $rc
}

do_test triggerC-2.2 {
  execsql "
    CREATE TABLE t22(x);

    CREATE TRIGGER t22a AFTER INSERT ON t22 BEGIN
      INSERT INTO t22 SELECT x + (SELECT max(x) FROM t22) FROM t22;
    END;
    CREATE TRIGGER t22b BEFORE INSERT ON t22 BEGIN
      SELECT CASE WHEN (SELECT count(*) FROM t22) >= [expr $SQLITE_MAX_TRIGGER_DEPTH / 2]
                  THEN RAISE(IGNORE)
                  ELSE NULL END;
    END;

    INSERT INTO t22 VALUES(1);
    SELECT count(*) FROM t22;
  "
} [list [expr $SQLITE_MAX_TRIGGER_DEPTH / 2]]

do_test triggerC-2.3 {
  execsql "
    CREATE TABLE t23(x PRIMARY KEY);

    CREATE TRIGGER t23a AFTER INSERT ON t23 BEGIN
      INSERT INTO t23 VALUES(new.x + 1);

Changes to test/wal5.test.

231
232
233
234
235
236
237






238

239
240
241
242
243
244
245
    } {}
    do_test 2.3.$tn.2 { file_page_counts } {1 5 1 5}
    do_test 2.3.$tn.3 { sql2 { BEGIN; SELECT * FROM t1 } } {1 2}
    do_test 2.3.$tn.4 { sql1 { INSERT INTO t1 VALUES(3, 4) } } {}
    do_test 2.3.$tn.5 { sql1 { INSERT INTO t2 VALUES(3, 4) } } {}
    do_test 2.3.$tn.6 { file_page_counts } {1 7 1 7}
    do_test 2.3.$tn.7 { code1 { do_wal_checkpoint db -mode full } } {1 7 5}






    do_test 2.3.$tn.8 { file_page_counts } {1 7 2 7}

  }

  # Check that checkpoints block on the correct locks. And respond correctly
  # if they cannot obtain those locks. There are three locks that a checkpoint
  # may block on (in the following order):
  #
  #   1. The writer lock: FULL and RESTART checkpoints block until any writer







>
>
>
>
>
>
|
>







231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
    } {}
    do_test 2.3.$tn.2 { file_page_counts } {1 5 1 5}
    do_test 2.3.$tn.3 { sql2 { BEGIN; SELECT * FROM t1 } } {1 2}
    do_test 2.3.$tn.4 { sql1 { INSERT INTO t1 VALUES(3, 4) } } {}
    do_test 2.3.$tn.5 { sql1 { INSERT INTO t2 VALUES(3, 4) } } {}
    do_test 2.3.$tn.6 { file_page_counts } {1 7 1 7}
    do_test 2.3.$tn.7 { code1 { do_wal_checkpoint db -mode full } } {1 7 5}
    if {$tcl_platform(platform) == "windows"} {
        # on unix, the size_hint is a no-op if no chunk size is set.
        # the windows implementation does not have a similar check,
        # and because of this, the db file size has an extra page.
        do_test 2.3.$tn.8 { file_page_counts } {2 7 2 7}
    } {
        do_test 2.3.$tn.8 { file_page_counts } {1 7 2 7}
    }
  }

  # Check that checkpoints block on the correct locks. And respond correctly
  # if they cannot obtain those locks. There are three locks that a checkpoint
  # may block on (in the following order):
  #
  #   1. The writer lock: FULL and RESTART checkpoints block until any writer

Changes to tool/omittest.tcl.

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
..
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
..
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
...
115
116
117
118
119
120
121

122
123
124
125
126
127
128
129
130
131
132
133
134
135





136
137
138
139
140
141
142
...
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
...
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
  * The makefile should support the "testfixture" target.
  * The makefile should support the "test" target.
  * The makefile should support the variable "OPTS" as a way to pass
    options from the make command line to lemon and the C compiler.

More precisely, the following two invocations must be supported:

  make -f $::MAKEFILE testfixture OPTS="-DSQLITE_OMIT_ALTERTABLE=1"
  make -f $::MAKEFILE test

Makefiles generated by the sqlite configure program cannot be used as
they do not respect the OPTS variable.
}


# Build a testfixture executable and run quick.test using it. The first
................................................................................
  puts -nonewline "Building $dir..."
  flush stdout
catch {
  file copy -force ./config.h $dir
  file copy -force ./libtool $dir
}
  set rc [catch {
    exec make -C $dir -f $::MAKEFILE $target OPTS=$opts >& $dir/build.log
  }]
  if {$rc} {
    puts "No good. See $dir/build.log."
    return
  } else {
    puts "Ok"
  }
................................................................................
  if {$::SKIP_RUN} {
      puts "Skip testing $dir."
  } else {
    # Run the test suite.
    puts -nonewline "Testing $dir..."
    flush stdout
    set rc [catch {
      exec make -C $dir -f $::MAKEFILE test OPTS=$opts >& $dir/test.log
    }]
    if {$rc} {
      puts "No good. See $dir/test.log."
    } else {
      puts "Ok"
    }
  }
................................................................................

# This proc processes the command line options passed to this script.
# Currently the only option supported is "-makefile", default
# "../Makefile.linux-gcc". Set the ::MAKEFILE variable to the value of this
# option.
#
proc process_options {argv} {

  if {$::tcl_platform(platform)=="windows" || $::tcl_platform(platform)=="os2"} {
    set ::MAKEFILE ./Makefile               ;# Default value
  } else {
    set ::MAKEFILE ./Makefile.linux-gcc     ;# Default value
  }
  set ::SKIP_RUN 0                          ;# Default to attempt test

  for {set i 0} {$i < [llength $argv]} {incr i} {
    switch -- [lindex $argv $i] {
      -makefile {
        incr i
        set ::MAKEFILE [lindex $argv $i]
      }
  





      -skip_run {
        set ::SKIP_RUN 1
      }

      default {
        if {[info exists ::SYMBOL]} {
          puts stderr [string trim $::USAGE_MESSAGE]
................................................................................
    set sym $::SYMBOL

    if {[lsearch $::OMIT_SYMBOLS $sym]<0 && [lsearch $::ENABLE_SYMBOLS $sym]<0} {
      puts stderr "No such symbol: $sym"
      exit -1
    }

    set dirname "test_[string range $sym 7 end]"
    run_quick_test $dirname $sym
  } else {
    # First try a test with all OMIT symbols except SQLITE_OMIT_FLOATING_POINT 
    # and SQLITE_OMIT_PRAGMA defined. The former doesn't work (causes segfaults)
    # and the latter is currently incompatible with the test suite (this should
    # be fixed, but it will be a lot of work).
    set allsyms [list]
................................................................................
    }
    run_quick_test test_OMIT_EVERYTHING $allsyms
  
    # Now try one quick.test with each of the OMIT symbols defined. Included
    # are the OMIT_FLOATING_POINT and OMIT_PRAGMA symbols, even though we
    # know they will fail. It's good to be reminded of this from time to time.
    foreach sym $::OMIT_SYMBOLS {
      set dirname "test_[string range $sym 7 end]"
      run_quick_test $dirname $sym
    }
  
    # Try the ENABLE/DISABLE symbols one at a time.  
    # We don't do them all at once since some are conflicting.
    foreach sym $::ENABLE_SYMBOLS {
      set dirname "test_[string range $sym 7 end]"
      run_quick_test $dirname $sym
    }
  }
}

main $argv







|
|







 







|







 







|







 







>

|












>
>
>
>
>







 







|







 







|






|






27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
..
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
..
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
...
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
...
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
...
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
  * The makefile should support the "testfixture" target.
  * The makefile should support the "test" target.
  * The makefile should support the variable "OPTS" as a way to pass
    options from the make command line to lemon and the C compiler.

More precisely, the following two invocations must be supported:

  $::MAKEBIN -f $::MAKEFILE testfixture OPTS="-DSQLITE_OMIT_ALTERTABLE=1"
  $::MAKEBIN -f $::MAKEFILE test

Makefiles generated by the sqlite configure program cannot be used as
they do not respect the OPTS variable.
}


# Build a testfixture executable and run quick.test using it. The first
................................................................................
  puts -nonewline "Building $dir..."
  flush stdout
catch {
  file copy -force ./config.h $dir
  file copy -force ./libtool $dir
}
  set rc [catch {
    exec $::MAKEBIN -C $dir -f $::MAKEFILE clean $target OPTS=$opts >& $dir/build.log
  }]
  if {$rc} {
    puts "No good. See $dir/build.log."
    return
  } else {
    puts "Ok"
  }
................................................................................
  if {$::SKIP_RUN} {
      puts "Skip testing $dir."
  } else {
    # Run the test suite.
    puts -nonewline "Testing $dir..."
    flush stdout
    set rc [catch {
      exec $::MAKEBIN -C $dir -f $::MAKEFILE test OPTS=$opts >& $dir/test.log
    }]
    if {$rc} {
      puts "No good. See $dir/test.log."
    } else {
      puts "Ok"
    }
  }
................................................................................

# This proc processes the command line options passed to this script.
# Currently the only option supported is "-makefile", default
# "../Makefile.linux-gcc". Set the ::MAKEFILE variable to the value of this
# option.
#
proc process_options {argv} {
  set ::MAKEBIN make                        ;# Default value
  if {$::tcl_platform(platform)=="windows" || $::tcl_platform(platform)=="os2"} {
    set ::MAKEFILE ./Makefile               ;# Default value on Windows and OS2
  } else {
    set ::MAKEFILE ./Makefile.linux-gcc     ;# Default value
  }
  set ::SKIP_RUN 0                          ;# Default to attempt test

  for {set i 0} {$i < [llength $argv]} {incr i} {
    switch -- [lindex $argv $i] {
      -makefile {
        incr i
        set ::MAKEFILE [lindex $argv $i]
      }
  
      -nmake {
        set ::MAKEBIN nmake
        set ::MAKEFILE ./Makefile.msc
      }

      -skip_run {
        set ::SKIP_RUN 1
      }

      default {
        if {[info exists ::SYMBOL]} {
          puts stderr [string trim $::USAGE_MESSAGE]
................................................................................
    set sym $::SYMBOL

    if {[lsearch $::OMIT_SYMBOLS $sym]<0 && [lsearch $::ENABLE_SYMBOLS $sym]<0} {
      puts stderr "No such symbol: $sym"
      exit -1
    }

    set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
    run_quick_test $dirname $sym
  } else {
    # First try a test with all OMIT symbols except SQLITE_OMIT_FLOATING_POINT 
    # and SQLITE_OMIT_PRAGMA defined. The former doesn't work (causes segfaults)
    # and the latter is currently incompatible with the test suite (this should
    # be fixed, but it will be a lot of work).
    set allsyms [list]
................................................................................
    }
    run_quick_test test_OMIT_EVERYTHING $allsyms
  
    # Now try one quick.test with each of the OMIT symbols defined. Included
    # are the OMIT_FLOATING_POINT and OMIT_PRAGMA symbols, even though we
    # know they will fail. It's good to be reminded of this from time to time.
    foreach sym $::OMIT_SYMBOLS {
      set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
      run_quick_test $dirname $sym
    }
  
    # Try the ENABLE/DISABLE symbols one at a time.  
    # We don't do them all at once since some are conflicting.
    foreach sym $::ENABLE_SYMBOLS {
      set dirname "test_[regsub -nocase {^x*SQLITE_} $sym {}]"
      run_quick_test $dirname $sym
    }
  }
}

main $argv