diff options
author | drh <> | 2021-03-22 18:53:26 +0000 |
---|---|---|
committer | drh <> | 2021-03-22 18:53:26 +0000 |
commit | e3e8f5ce9c852032ffca77c84d7e056b3ec01b4e (patch) | |
tree | 1729980604d196648c7129ee5daacf45ca8db692 /src | |
parent | 2f2091b10e28fc76a9c30e084a4eb2c466a75674 (diff) | |
parent | f93ff6b9f465dcc24b2655f8eabf28af166a7c03 (diff) | |
download | sqlite-e3e8f5ce9c852032ffca77c84d7e056b3ec01b4e.tar.gz sqlite-e3e8f5ce9c852032ffca77c84d7e056b3ec01b4e.zip |
Merge recent fixes from trunk.
FossilOrigin-Name: 4a343698b4ec3364b0eecb7fa074512ecac8b586aff1f977ca77f215e96e0ce5
Diffstat (limited to 'src')
-rw-r--r-- | src/build.c | 16 | ||||
-rw-r--r-- | src/insert.c | 2 | ||||
-rw-r--r-- | src/shell.c.in | 2 | ||||
-rw-r--r-- | src/vdbe.c | 11 |
4 files changed, 24 insertions, 7 deletions
diff --git a/src/build.c b/src/build.c index 5fcf69e6b..b5ec40909 100644 --- a/src/build.c +++ b/src/build.c @@ -4149,7 +4149,11 @@ void sqlite3CreateIndex( /* Clean up before exiting */ exit_create_index: if( pIndex ) sqlite3FreeIndex(db, pIndex); - if( pTab ){ /* Ensure all REPLACE indexes are at the end of the list */ + if( pTab ){ + /* Ensure all REPLACE indexes on pTab are at the end of the pIndex list. + ** The list was already ordered when this routine was entered, so at this + ** point at most a single index (the newly added index) will be out of + ** order. So we have to reorder at most one index. */ Index **ppFrom = &pTab->pIndex; Index *pThis; for(ppFrom=&pTab->pIndex; (pThis = *ppFrom)!=0; ppFrom=&pThis->pNext){ @@ -4163,6 +4167,16 @@ exit_create_index: } break; } +#ifdef SQLITE_DEBUG + /* Verify that all REPLACE indexes really are now at the end + ** of the index list. In other words, no other index type ever + ** comes after a REPLACE index on the list. */ + for(pThis = pTab->pIndex; pThis; pThis=pThis->pNext){ + assert( pThis->onError!=OE_Replace + || pThis->pNext==0 + || pThis->pNext->onError==OE_Replace ); + } +#endif } sqlite3ExprDelete(db, pPIWhere); sqlite3ExprListDelete(db, pList); diff --git a/src/insert.c b/src/insert.c index 2f91cf474..2fbfcce4a 100644 --- a/src/insert.c +++ b/src/insert.c @@ -2428,7 +2428,7 @@ static void codeWithoutRowidPreupdate( Vdbe *v = pParse->pVdbe; int r = sqlite3GetTempReg(pParse); assert( !HasRowid(pTab) ); - assert( 0==(pParse->db->mDbFlags & DBFLAG_Vacuum) ); + assert( 0==(pParse->db->mDbFlags & DBFLAG_Vacuum) || CORRUPT_DB ); sqlite3VdbeAddOp2(v, OP_Integer, 0, r); sqlite3VdbeAddOp4(v, OP_Insert, iCur, regData, r, (char*)pTab, P4_TABLE); sqlite3VdbeChangeP5(v, OPFLAG_ISNOOP); diff --git a/src/shell.c.in b/src/shell.c.in index 889ed0d16..3e52e256f 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -3063,6 +3063,7 @@ static void exec_prepared_stmt_columnar( if( rc!=SQLITE_ROW ) return; nColumn = sqlite3_column_count(pStmt); nAlloc = nColumn*4; + if( nAlloc<=0 ) nAlloc = 1; azData = sqlite3_malloc64( nAlloc*sizeof(char*) ); if( azData==0 ) shell_out_of_memory(); for(i=0; i<nColumn; i++){ @@ -3102,6 +3103,7 @@ static void exec_prepared_stmt_columnar( if( n>p->actualWidth[j] ) p->actualWidth[j] = n; } if( seenInterrupt ) goto columnar_end; + if( nColumn==0 ) goto columnar_end; switch( p->cMode ){ case MODE_Column: { colSep = " "; diff --git a/src/vdbe.c b/src/vdbe.c index ed1476dbe..080c7eaf8 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -4427,13 +4427,13 @@ seek_not_found: ** ** There are three possible outcomes from this opcode:<ol> ** -** <li> If after This.P1 steps, the cursor is still point to a place that -** is earlier in the btree than the target row, -** then fall through into the subsquence OP_SeekGE opcode. +** <li> If after This.P1 steps, the cursor is still pointing to a place that +** is earlier in the btree than the target row, then fall through +** into the subsquence OP_SeekGE opcode. ** ** <li> If the cursor is successfully moved to the target row by 0 or more ** sqlite3BtreeNext() calls, then jump to This.P2, which will land just -** past the OP_IdxGT opcode that follows the OP_SeekGE. +** past the OP_IdxGT or OP_IdxGE opcode that follows the OP_SeekGE. ** ** <li> If the cursor ends up past the target row (indicating the the target ** row does not exist in the btree) then jump to SeekOP.P2. @@ -4450,7 +4450,8 @@ case OP_SeekScan: { /* pOp->p2 points to the first instruction past the OP_IdxGT that ** follows the OP_SeekGE. */ assert( pOp->p2>=(int)(pOp-aOp)+2 ); - assert( aOp[pOp->p2-1].opcode==OP_IdxGT ); + assert( aOp[pOp->p2-1].opcode==OP_IdxGT || aOp[pOp->p2-1].opcode==OP_IdxGE ); + testcase( aOp[pOp->p2-1].opcode==OP_IdxGE ); assert( pOp[1].p1==aOp[pOp->p2-1].p1 ); assert( pOp[1].p2==aOp[pOp->p2-1].p2 ); assert( pOp[1].p3==aOp[pOp->p2-1].p3 ); |