diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/insert.c | 16 | ||||
-rw-r--r-- | src/select.c | 3 |
2 files changed, 10 insertions, 9 deletions
diff --git a/src/insert.c b/src/insert.c index d96780663..6823a72cb 100644 --- a/src/insert.c +++ b/src/insert.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle INSERT statements in SQLite. ** -** $Id: insert.c,v 1.173 2007/02/13 15:01:11 drh Exp $ +** $Id: insert.c,v 1.174 2007/02/24 13:23:52 drh Exp $ */ #include "sqliteInt.h" @@ -1305,7 +1305,7 @@ static int xferCompatibleIndex(Index *pDest, Index *pSrc){ ** This optimization is only attempted if ** ** (1) tab1 and tab2 have identical schemas including all the -** same indices +** same indices and constraints ** ** (2) tab1 and tab2 are different tables ** @@ -1382,18 +1382,15 @@ static int xferOptimization( if( pSelect->pOrderBy ){ return 0; /* SELECT may not have an ORDER BY clause */ } - if( pSelect->pHaving ){ - return 0; /* SELECT may not have a HAVING clause */ - } + /* Do not need to test for a HAVING clause. If HAVING is present but + ** there is no ORDER BY, we will get an error. */ if( pSelect->pGroupBy ){ return 0; /* SELECT may not have a GROUP BY clause */ } if( pSelect->pLimit ){ return 0; /* SELECT may not have a LIMIT clause */ } - if( pSelect->pOffset ){ - return 0; /* SELECT may not have an OFFSET clause */ - } + assert( pSelect->pOffset==0 ); /* Must be so if pLimit==0 */ if( pSelect->pPrior ){ return 0; /* SELECT may not be a compound query */ } @@ -1455,6 +1452,9 @@ static int xferOptimization( return 0; /* pDestIdx has no corresponding index in pSrc */ } } + if( !sqlite3ExprCompare(pSrc->pCheck, pDest->pCheck) ){ + return 0; /* Tables have different CHECK constraints. Ticket #2252 */ + } /* If we get this far, it means either: ** diff --git a/src/select.c b/src/select.c index 84e054658..c8f655687 100644 --- a/src/select.c +++ b/src/select.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** -** $Id: select.c,v 1.328 2007/02/24 11:52:54 drh Exp $ +** $Id: select.c,v 1.329 2007/02/24 13:23:53 drh Exp $ */ #include "sqliteInt.h" @@ -68,6 +68,7 @@ Select *sqlite3SelectNew( pNew->pOrderBy = pOrderBy; pNew->isDistinct = isDistinct; pNew->op = TK_SELECT; + assert( pOffset==0 || pLimit!=0 ); pNew->pLimit = pLimit; pNew->pOffset = pOffset; pNew->iLimit = -1; |