/ Check-in [aef6698c]
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:Merge trunk changes into experimental branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | experimental
Files: files | file ages | folders
SHA1: aef6698c732f3f9e46986f53e63ca2bdf5f7d208
User & Date: dan 2010-08-06 13:53:10
Context
2010-08-06
14:37
Fix some problems with running test scripts with the inmemory_journal permutation. check-in: 7bd8ba08 user: dan tags: experimental
13:53
Merge trunk changes into experimental branch. check-in: aef6698c user: dan tags: experimental
13:50
Do not run some tests in notify3.test with the inmemory_journal permutation. They do not pass as the tests assume that the database schema is not loaded until the first invocation of [db eval]. This is not true with the inmemory_journal permutation. check-in: 698fba82 user: dan tags: trunk
12:00
Further updates to comments in pager.c. check-in: 5f4c17a3 user: dan tags: experimental
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

  5529   5529     int noSync                      /* True to omit the xSync on the db file */
  5530   5530   ){
  5531   5531     int rc = SQLITE_OK;             /* Return code */
  5532   5532   
  5533   5533     assert( pPager->eState==PAGER_WRITER_LOCKED
  5534   5534          || pPager->eState==PAGER_WRITER_CACHEMOD
  5535   5535          || pPager->eState==PAGER_WRITER_DBMOD
  5536         -       || pPager->eState==PAGER_WRITER_ERROR
         5536  +       || pPager->eState==PAGER_ERROR
  5537   5537     );
  5538   5538     assert( assert_pager_state(pPager) );
  5539   5539   
  5540   5540     /* If a prior error occurred, report that error again. */
  5541   5541     if( pPager->errCode ) return pPager->errCode;
  5542   5542   
  5543   5543     PAGERTRACE(("DATABASE SYNC: File=%s zMaster=%s nSize=%d\n", 

Changes to src/sqliteInt.h.

  1352   1352   ** argument to sqlite3VdbeKeyCompare and is used to control the 
  1353   1353   ** comparison of the two index keys.
  1354   1354   */
  1355   1355   struct KeyInfo {
  1356   1356     sqlite3 *db;        /* The database connection */
  1357   1357     u8 enc;             /* Text encoding - one of the TEXT_Utf* values */
  1358   1358     u16 nField;         /* Number of entries in aColl[] */
  1359         -  u8 *aSortOrder;     /* If defined an aSortOrder[i] is true, sort DESC */
         1359  +  u8 *aSortOrder;     /* Sort order for each column.  May be NULL */
  1360   1360     CollSeq *aColl[1];  /* Collating sequence for each term of the key */
  1361   1361   };
  1362   1362   
  1363   1363   /*
  1364   1364   ** An instance of the following structure holds information about a
  1365   1365   ** single index record that has already been parsed out into individual
  1366   1366   ** values.

Changes to src/vdbe.c.

  4345   4345   ** then jump to P2.  Otherwise fall through to the next instruction.
  4346   4346   **
  4347   4347   ** If P5 is non-zero then the key value is increased by an epsilon 
  4348   4348   ** prior to the comparison.  This make the opcode work like IdxGT except
  4349   4349   ** that if the key from register P3 is a prefix of the key in the cursor,
  4350   4350   ** the result is false whereas it would be true with IdxGT.
  4351   4351   */
  4352         -/* Opcode: IdxLT P1 P2 P3 * P5
         4352  +/* Opcode: IdxLT P1 P2 P3 P4 P5
  4353   4353   **
  4354   4354   ** The P4 register values beginning with P3 form an unpacked index 
  4355   4355   ** key that omits the ROWID.  Compare this key value against the index 
  4356   4356   ** that P1 is currently pointing to, ignoring the ROWID on the P1 index.
  4357   4357   **
  4358   4358   ** If the P1 index entry is less than the key value then jump to P2.
  4359   4359   ** Otherwise fall through to the next instruction.

Changes to src/where.c.

  3361   3361       **         If there are no inequality constraints, then N is at
  3362   3362       **         least one.
  3363   3363       **
  3364   3364       **         This case is also used when there are no WHERE clause
  3365   3365       **         constraints but an index is selected anyway, in order
  3366   3366       **         to force the output order to conform to an ORDER BY.
  3367   3367       */  
  3368         -    int aStartOp[] = {
         3368  +    static const u8 aStartOp[] = {
  3369   3369         0,
  3370   3370         0,
  3371   3371         OP_Rewind,           /* 2: (!start_constraints && startEq &&  !bRev) */
  3372   3372         OP_Last,             /* 3: (!start_constraints && startEq &&   bRev) */
  3373   3373         OP_SeekGt,           /* 4: (start_constraints  && !startEq && !bRev) */
  3374   3374         OP_SeekLt,           /* 5: (start_constraints  && !startEq &&  bRev) */
  3375   3375         OP_SeekGe,           /* 6: (start_constraints  &&  startEq && !bRev) */
  3376   3376         OP_SeekLe            /* 7: (start_constraints  &&  startEq &&  bRev) */
  3377   3377       };
  3378         -    int aEndOp[] = {
         3378  +    static const u8 aEndOp[] = {
  3379   3379         OP_Noop,             /* 0: (!end_constraints) */
  3380   3380         OP_IdxGE,            /* 1: (end_constraints && !bRev) */
  3381   3381         OP_IdxLT             /* 2: (end_constraints && bRev) */
  3382   3382       };
  3383         -    int nEq = pLevel->plan.nEq;
         3383  +    int nEq = pLevel->plan.nEq;  /* Number of == or IN terms */
  3384   3384       int isMinQuery = 0;          /* If this is an optimized SELECT min(x).. */
  3385   3385       int regBase;                 /* Base register holding constraint values */
  3386   3386       int r1;                      /* Temp register */
  3387   3387       WhereTerm *pRangeStart = 0;  /* Inequality constraint at range start */
  3388   3388       WhereTerm *pRangeEnd = 0;    /* Inequality constraint at range end */
  3389   3389       int startEq;                 /* True if range start uses ==, >= or <= */
  3390   3390       int endEq;                   /* True if range end uses ==, >= or <= */
  3391   3391       int start_constraints;       /* Start of range is constrained */
  3392   3392       int nConstraint;             /* Number of constraint terms */
  3393         -    Index *pIdx;         /* The index we will be using */
  3394         -    int iIdxCur;         /* The VDBE cursor for the index */
  3395         -    int nExtraReg = 0;   /* Number of extra registers needed */
  3396         -    int op;              /* Instruction opcode */
         3393  +    Index *pIdx;                 /* The index we will be using */
         3394  +    int iIdxCur;                 /* The VDBE cursor for the index */
         3395  +    int nExtraReg = 0;           /* Number of extra registers needed */
         3396  +    int op;                      /* Instruction opcode */
  3397   3397       char *zStartAff;             /* Affinity for start of range constraint */
  3398   3398       char *zEndAff;               /* Affinity for end of range constraint */
  3399   3399   
  3400   3400       pIdx = pLevel->plan.u.pIdx;
  3401   3401       iIdxCur = pLevel->iIdxCur;
  3402   3402       k = pIdx->aiColumn[nEq];     /* Column for inequality constraints */
  3403   3403   

Changes to test/notify3.test.

    88     88   #
    89     89   # This block tests that if the loading of schemas as a result of an
    90     90   # ATTACH fails due to locks on the schema table held by other shared-cache
    91     91   # connections the extended error code is SQLITE_LOCKED_SHAREDCACHE and
    92     92   # it is possible to use the unlock-notify mechanism to determine when
    93     93   # the ATTACH might succeed.
    94     94   #
    95         -foreach {
    96         -  tn
    97         -  db1_loaded
    98         -  db2_loaded
    99         -  enable_extended_errors
   100         -  result
   101         -  error1 error2
   102         -} "
   103         -  0   0 0 0   $err     SQLITE_LOCKED               SQLITE_LOCKED_SHAREDCACHE
   104         -  1   0 0 1   $err     SQLITE_LOCKED_SHAREDCACHE   SQLITE_LOCKED_SHAREDCACHE
   105         -  2   0 1 0   $err     SQLITE_LOCKED               SQLITE_LOCKED_SHAREDCACHE
   106         -  3   0 1 1   $err     SQLITE_LOCKED_SHAREDCACHE   SQLITE_LOCKED_SHAREDCACHE
   107         -  4   1 0 0   $err     SQLITE_LOCKED               SQLITE_LOCKED_SHAREDCACHE
   108         -  5   1 0 1   $err     SQLITE_LOCKED_SHAREDCACHE   SQLITE_LOCKED_SHAREDCACHE
   109         -  6   1 1 0   $noerr   SQLITE_OK                   SQLITE_OK
   110         -  7   1 1 1   $noerr   SQLITE_OK                   SQLITE_OK
   111         -" {
   112         -
   113         -  do_test notify3-2.$tn.1 {
   114         -    catch { db1 close }
   115         -    catch { db2 close }
   116         -    sqlite3 db1 test.db
   117         -    sqlite3 db2 test.db2
   118         -
   119         -    sqlite3_extended_result_codes db1 $enable_extended_errors
   120         -    sqlite3_extended_result_codes db2 $enable_extended_errors
   121         -
   122         -    if { $db1_loaded } { db1 eval "SELECT * FROM sqlite_master" }
   123         -    if { $db2_loaded } { db2 eval "SELECT * FROM sqlite_master" }
   124         -
   125         -    db2 eval "BEGIN EXCLUSIVE"
   126         -    catchsql "ATTACH 'test.db2' AS two" db1
   127         -  } $result
   128         -
   129         -  do_test notify3-2.$tn.2 {
   130         -    list [sqlite3_errcode db1] [sqlite3_extended_errcode db1]
   131         -  } [list $error1 $error2]
   132         -
   133         -  do_test notify3-2.$tn.3 {
   134         -    db1 unlock_notify {set invoked 1}
   135         -    set invoked 0
   136         -    db2 eval commit
   137         -    set invoked
   138         -  } [lindex $result 0]
           95  +# This test does not work for test-permutations that specify SQL to
           96  +# be executed as part of the [sqlite3] command that opens the database.
           97  +# Executing such SQL causes SQLite to load the database schema into memory 
           98  +# earlier than expected, causing test cases to fail.
           99  +#
          100  +if {[presql] == ""} {
          101  +  foreach {
          102  +    tn
          103  +    db1_loaded
          104  +    db2_loaded
          105  +    enable_extended_errors
          106  +    result
          107  +    error1 error2
          108  +  } "
          109  +    0   0 0 0   $err     SQLITE_LOCKED               SQLITE_LOCKED_SHAREDCACHE
          110  +    1   0 0 1   $err     SQLITE_LOCKED_SHAREDCACHE   SQLITE_LOCKED_SHAREDCACHE
          111  +    2   0 1 0   $err     SQLITE_LOCKED               SQLITE_LOCKED_SHAREDCACHE
          112  +    3   0 1 1   $err     SQLITE_LOCKED_SHAREDCACHE   SQLITE_LOCKED_SHAREDCACHE
          113  +    4   1 0 0   $err     SQLITE_LOCKED               SQLITE_LOCKED_SHAREDCACHE
          114  +    5   1 0 1   $err     SQLITE_LOCKED_SHAREDCACHE   SQLITE_LOCKED_SHAREDCACHE
          115  +    6   1 1 0   $noerr   SQLITE_OK                   SQLITE_OK
          116  +    7   1 1 1   $noerr   SQLITE_OK                   SQLITE_OK
          117  +  " {
          118  +  
          119  +    do_test notify3-2.$tn.1 {
          120  +      catch { db1 close }
          121  +      catch { db2 close }
          122  +      sqlite3 db1 test.db
          123  +      sqlite3 db2 test.db2
          124  +  
          125  +      sqlite3_extended_result_codes db1 $enable_extended_errors
          126  +      sqlite3_extended_result_codes db2 $enable_extended_errors
          127  +  
          128  +      if { $db1_loaded } { db1 eval "SELECT * FROM sqlite_master" }
          129  +      if { $db2_loaded } { db2 eval "SELECT * FROM sqlite_master" }
          130  +  
          131  +      db2 eval "BEGIN EXCLUSIVE"
          132  +      catchsql "ATTACH 'test.db2' AS two" db1
          133  +    } $result
          134  +  
          135  +    do_test notify3-2.$tn.2 {
          136  +      list [sqlite3_errcode db1] [sqlite3_extended_errcode db1]
          137  +    } [list $error1 $error2]
          138  +  
          139  +    do_test notify3-2.$tn.3 {
          140  +      db1 unlock_notify {set invoked 1}
          141  +      set invoked 0
          142  +      db2 eval commit
          143  +      set invoked
          144  +    } [lindex $result 0]
          145  +  }
   139    146   }
   140    147   catch { db1 close }
   141    148   catch { db2 close }
   142    149   
   143    150   
   144    151   sqlite3_enable_shared_cache $esc
   145    152   finish_test
   146    153   

Changes to test/tester.tcl.

    66     66   # Commands to help create test files that run with the "WAL" and other
    67     67   # permutations (see file permutations.test):
    68     68   #
    69     69   #      wal_is_wal_mode
    70     70   #      wal_set_journal_mode   ?DB?
    71     71   #      wal_check_journal_mode TESTNAME?DB?
    72     72   #      permutation
           73  +#      presql
    73     74   #
    74     75   
    75     76   # Set the precision of FP arithmatic used by the interpreter. And 
    76     77   # configure SQLite to take database file locks on the page that begins
    77     78   # 64KB into the database file instead of the one 1GB in. This means
    78     79   # the code that handles that special case can be tested without creating
    79     80   # very large database files.
................................................................................
  1145   1146     }
  1146   1147   }
  1147   1148   
  1148   1149   proc permutation {} {
  1149   1150     set perm ""
  1150   1151     catch {set perm $::G(perm:name)}
  1151   1152     set perm
         1153  +}
         1154  +proc presql {} {
         1155  +  set presql ""
         1156  +  catch {set presql $::G(perm:presql)}
         1157  +  set presql
  1152   1158   }
  1153   1159   
  1154   1160   #-------------------------------------------------------------------------
  1155   1161   #
  1156   1162   proc slave_test_script {script} {
  1157   1163   
  1158   1164     # Create the interpreter used to run the test script.