Index: src/pager.c ================================================================== --- src/pager.c +++ src/pager.c @@ -5531,11 +5531,11 @@ int rc = SQLITE_OK; /* Return code */ assert( pPager->eState==PAGER_WRITER_LOCKED || pPager->eState==PAGER_WRITER_CACHEMOD || pPager->eState==PAGER_WRITER_DBMOD - || pPager->eState==PAGER_WRITER_ERROR + || pPager->eState==PAGER_ERROR ); assert( assert_pager_state(pPager) ); /* If a prior error occurred, report that error again. */ if( pPager->errCode ) return pPager->errCode; Index: src/sqliteInt.h ================================================================== --- src/sqliteInt.h +++ src/sqliteInt.h @@ -1354,11 +1354,11 @@ */ struct KeyInfo { sqlite3 *db; /* The database connection */ u8 enc; /* Text encoding - one of the TEXT_Utf* values */ u16 nField; /* Number of entries in aColl[] */ - u8 *aSortOrder; /* If defined an aSortOrder[i] is true, sort DESC */ + u8 *aSortOrder; /* Sort order for each column. May be NULL */ CollSeq *aColl[1]; /* Collating sequence for each term of the key */ }; /* ** An instance of the following structure holds information about a Index: src/vdbe.c ================================================================== --- src/vdbe.c +++ src/vdbe.c @@ -4347,11 +4347,11 @@ ** If P5 is non-zero then the key value is increased by an epsilon ** prior to the comparison. This make the opcode work like IdxGT except ** that if the key from register P3 is a prefix of the key in the cursor, ** the result is false whereas it would be true with IdxGT. */ -/* Opcode: IdxLT P1 P2 P3 * P5 +/* Opcode: IdxLT P1 P2 P3 P4 P5 ** ** The P4 register values beginning with P3 form an unpacked index ** key that omits the ROWID. Compare this key value against the index ** that P1 is currently pointing to, ignoring the ROWID on the P1 index. ** Index: src/where.c ================================================================== --- src/where.c +++ src/where.c @@ -3363,39 +3363,39 @@ ** ** This case is also used when there are no WHERE clause ** constraints but an index is selected anyway, in order ** to force the output order to conform to an ORDER BY. */ - int aStartOp[] = { + static const u8 aStartOp[] = { 0, 0, OP_Rewind, /* 2: (!start_constraints && startEq && !bRev) */ OP_Last, /* 3: (!start_constraints && startEq && bRev) */ OP_SeekGt, /* 4: (start_constraints && !startEq && !bRev) */ OP_SeekLt, /* 5: (start_constraints && !startEq && bRev) */ OP_SeekGe, /* 6: (start_constraints && startEq && !bRev) */ OP_SeekLe /* 7: (start_constraints && startEq && bRev) */ }; - int aEndOp[] = { + static const u8 aEndOp[] = { OP_Noop, /* 0: (!end_constraints) */ OP_IdxGE, /* 1: (end_constraints && !bRev) */ OP_IdxLT /* 2: (end_constraints && bRev) */ }; - int nEq = pLevel->plan.nEq; + int nEq = pLevel->plan.nEq; /* Number of == or IN terms */ int isMinQuery = 0; /* If this is an optimized SELECT min(x).. */ int regBase; /* Base register holding constraint values */ int r1; /* Temp register */ WhereTerm *pRangeStart = 0; /* Inequality constraint at range start */ WhereTerm *pRangeEnd = 0; /* Inequality constraint at range end */ int startEq; /* True if range start uses ==, >= or <= */ int endEq; /* True if range end uses ==, >= or <= */ int start_constraints; /* Start of range is constrained */ int nConstraint; /* Number of constraint terms */ - Index *pIdx; /* The index we will be using */ - int iIdxCur; /* The VDBE cursor for the index */ - int nExtraReg = 0; /* Number of extra registers needed */ - int op; /* Instruction opcode */ + Index *pIdx; /* The index we will be using */ + int iIdxCur; /* The VDBE cursor for the index */ + int nExtraReg = 0; /* Number of extra registers needed */ + int op; /* Instruction opcode */ char *zStartAff; /* Affinity for start of range constraint */ char *zEndAff; /* Affinity for end of range constraint */ pIdx = pLevel->plan.u.pIdx; iIdxCur = pLevel->iIdxCur; Index: test/notify3.test ================================================================== --- test/notify3.test +++ test/notify3.test @@ -90,54 +90,61 @@ # ATTACH fails due to locks on the schema table held by other shared-cache # connections the extended error code is SQLITE_LOCKED_SHAREDCACHE and # it is possible to use the unlock-notify mechanism to determine when # the ATTACH might succeed. # -foreach { - tn - db1_loaded - db2_loaded - enable_extended_errors - result - error1 error2 -} " - 0 0 0 0 $err SQLITE_LOCKED SQLITE_LOCKED_SHAREDCACHE - 1 0 0 1 $err SQLITE_LOCKED_SHAREDCACHE SQLITE_LOCKED_SHAREDCACHE - 2 0 1 0 $err SQLITE_LOCKED SQLITE_LOCKED_SHAREDCACHE - 3 0 1 1 $err SQLITE_LOCKED_SHAREDCACHE SQLITE_LOCKED_SHAREDCACHE - 4 1 0 0 $err SQLITE_LOCKED SQLITE_LOCKED_SHAREDCACHE - 5 1 0 1 $err SQLITE_LOCKED_SHAREDCACHE SQLITE_LOCKED_SHAREDCACHE - 6 1 1 0 $noerr SQLITE_OK SQLITE_OK - 7 1 1 1 $noerr SQLITE_OK SQLITE_OK -" { - - do_test notify3-2.$tn.1 { - catch { db1 close } - catch { db2 close } - sqlite3 db1 test.db - sqlite3 db2 test.db2 - - sqlite3_extended_result_codes db1 $enable_extended_errors - sqlite3_extended_result_codes db2 $enable_extended_errors - - if { $db1_loaded } { db1 eval "SELECT * FROM sqlite_master" } - if { $db2_loaded } { db2 eval "SELECT * FROM sqlite_master" } - - db2 eval "BEGIN EXCLUSIVE" - catchsql "ATTACH 'test.db2' AS two" db1 - } $result - - do_test notify3-2.$tn.2 { - list [sqlite3_errcode db1] [sqlite3_extended_errcode db1] - } [list $error1 $error2] - - do_test notify3-2.$tn.3 { - db1 unlock_notify {set invoked 1} - set invoked 0 - db2 eval commit - set invoked - } [lindex $result 0] +# This test does not work for test-permutations that specify SQL to +# be executed as part of the [sqlite3] command that opens the database. +# Executing such SQL causes SQLite to load the database schema into memory +# earlier than expected, causing test cases to fail. +# +if {[presql] == ""} { + foreach { + tn + db1_loaded + db2_loaded + enable_extended_errors + result + error1 error2 + } " + 0 0 0 0 $err SQLITE_LOCKED SQLITE_LOCKED_SHAREDCACHE + 1 0 0 1 $err SQLITE_LOCKED_SHAREDCACHE SQLITE_LOCKED_SHAREDCACHE + 2 0 1 0 $err SQLITE_LOCKED SQLITE_LOCKED_SHAREDCACHE + 3 0 1 1 $err SQLITE_LOCKED_SHAREDCACHE SQLITE_LOCKED_SHAREDCACHE + 4 1 0 0 $err SQLITE_LOCKED SQLITE_LOCKED_SHAREDCACHE + 5 1 0 1 $err SQLITE_LOCKED_SHAREDCACHE SQLITE_LOCKED_SHAREDCACHE + 6 1 1 0 $noerr SQLITE_OK SQLITE_OK + 7 1 1 1 $noerr SQLITE_OK SQLITE_OK + " { + + do_test notify3-2.$tn.1 { + catch { db1 close } + catch { db2 close } + sqlite3 db1 test.db + sqlite3 db2 test.db2 + + sqlite3_extended_result_codes db1 $enable_extended_errors + sqlite3_extended_result_codes db2 $enable_extended_errors + + if { $db1_loaded } { db1 eval "SELECT * FROM sqlite_master" } + if { $db2_loaded } { db2 eval "SELECT * FROM sqlite_master" } + + db2 eval "BEGIN EXCLUSIVE" + catchsql "ATTACH 'test.db2' AS two" db1 + } $result + + do_test notify3-2.$tn.2 { + list [sqlite3_errcode db1] [sqlite3_extended_errcode db1] + } [list $error1 $error2] + + do_test notify3-2.$tn.3 { + db1 unlock_notify {set invoked 1} + set invoked 0 + db2 eval commit + set invoked + } [lindex $result 0] + } } catch { db1 close } catch { db2 close } Index: test/tester.tcl ================================================================== --- test/tester.tcl +++ test/tester.tcl @@ -68,10 +68,11 @@ # # wal_is_wal_mode # wal_set_journal_mode ?DB? # wal_check_journal_mode TESTNAME?DB? # permutation +# presql # # Set the precision of FP arithmatic used by the interpreter. And # configure SQLite to take database file locks on the page that begins # 64KB into the database file instead of the one 1GB in. This means @@ -1147,10 +1148,15 @@ proc permutation {} { set perm "" catch {set perm $::G(perm:name)} set perm +} +proc presql {} { + set presql "" + catch {set presql $::G(perm:presql)} + set presql } #------------------------------------------------------------------------- # proc slave_test_script {script} {