diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/select.c | 4 | ||||
-rw-r--r-- | src/shell.c.in | 1 | ||||
-rw-r--r-- | src/vdbe.c | 7 | ||||
-rw-r--r-- | src/vdbemem.c | 14 |
4 files changed, 19 insertions, 7 deletions
diff --git a/src/select.c b/src/select.c index 2df79e2e6..375441909 100644 --- a/src/select.c +++ b/src/select.c @@ -5481,7 +5481,9 @@ static struct SrcList_item *isSelfJoinView( ** names in the same FROM clause. */ continue; } - if( sqlite3ExprCompare(0, pThis->pSelect->pWhere, pS1->pWhere, -1) ){ + if( sqlite3ExprCompare(0, pThis->pSelect->pWhere, pS1->pWhere, -1) + || sqlite3ExprCompare(0, pThis->pSelect->pHaving, pS1->pHaving, -1) + ){ /* The view was modified by some other optimization such as ** pushDownWhereTerms() */ continue; diff --git a/src/shell.c.in b/src/shell.c.in index e145a1547..fa8554ad7 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -3877,6 +3877,7 @@ static unsigned char *readHexDb(ShellState *p, int *pnData){ }else{ in = p->in; nLine = p->lineno; + if( in==0 ) in = stdin; } *pnData = 0; nLine++; diff --git a/src/vdbe.c b/src/vdbe.c index 7242b3b1b..1fd49a931 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -256,7 +256,7 @@ static VdbeCursor *allocateCursor( ** is clear. Otherwise, if this is an ephemeral cursor created by ** OP_OpenDup, the cursor will not be closed and will still be part ** of a BtShared.pCursor list. */ - p->apCsr[iCur]->isEphemeral = 0; + if( p->apCsr[iCur]->pBtx==0 ) p->apCsr[iCur]->isEphemeral = 0; sqlite3VdbeFreeCursor(p, p->apCsr[iCur]); p->apCsr[iCur] = 0; } @@ -3723,7 +3723,10 @@ case OP_OpenEphemeral: { if( pCx ){ /* If the ephermeral table is already open, erase all existing content ** so that the table is empty again, rather than creating a new table. */ - rc = sqlite3BtreeClearTable(pCx->pBtx, pCx->pgnoRoot, 0); + assert( pCx->isEphemeral ); + if( pCx->pBtx ){ + rc = sqlite3BtreeClearTable(pCx->pBtx, pCx->pgnoRoot, 0); + } }else{ pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_BTREE); if( pCx==0 ) goto no_mem; diff --git a/src/vdbemem.c b/src/vdbemem.c index d1e6ac4d7..34b7c1f84 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -275,13 +275,19 @@ int sqlite3VdbeMemClearAndResize(Mem *pMem, int szNew){ /* ** It is already known that pMem contains an unterminated string. ** Add the zero terminator. +** +** Three bytes of zero are added. In this way, there is guaranteed +** to be a double-zero byte at an even byte boundary in order to +** terminate a UTF16 string, even if the initial size of the buffer +** is an odd number of bytes. */ static SQLITE_NOINLINE int vdbeMemAddTerminator(Mem *pMem){ - if( sqlite3VdbeMemGrow(pMem, pMem->n+2, 1) ){ + if( sqlite3VdbeMemGrow(pMem, pMem->n+3, 1) ){ return SQLITE_NOMEM_BKPT; } pMem->z[pMem->n] = 0; pMem->z[pMem->n+1] = 0; + pMem->z[pMem->n+2] = 0; pMem->flags |= MEM_Term; return SQLITE_OK; } @@ -355,9 +361,9 @@ int sqlite3VdbeMemNulTerminate(Mem *pMem){ } /* -** Add MEM_Str to the set of representations for the given Mem. Numbers -** are converted using sqlite3_snprintf(). Converting a BLOB to a string -** is a no-op. +** Add MEM_Str to the set of representations for the given Mem. This +** routine is only called if pMem is a number of some kind, not a NULL +** or a BLOB. ** ** Existing representations MEM_Int, MEM_Real, or MEM_IntReal are invalidated ** if bForce is true but are retained if bForce is false. |