mirror of
https://github.com/sqlite/sqlite.git
synced 2025-09-11 08:30:57 +03:00
Merge in the latest trunk changes, including partial indexes, the MAX_PATH
fix in os_win.c, and the sqlite3_cancel_auto_extension() API. FossilOrigin-Name: 7e1acb390770d1bd189fac7a3a7f96106f96e3a4
This commit is contained in:
25
src/insert.c
25
src/insert.c
@@ -1389,9 +1389,19 @@ void sqlite3GenerateConstraintChecks(
|
||||
for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){
|
||||
int regIdx;
|
||||
int regR;
|
||||
int addrSkipRow = 0;
|
||||
|
||||
if( aRegIdx[iCur]==0 ) continue; /* Skip unused indices */
|
||||
|
||||
if( pIdx->pPartIdxWhere ){
|
||||
sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[iCur]);
|
||||
addrSkipRow = sqlite3VdbeMakeLabel(v);
|
||||
pParse->ckBase = regData;
|
||||
sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, addrSkipRow,
|
||||
SQLITE_JUMPIFNULL);
|
||||
pParse->ckBase = 0;
|
||||
}
|
||||
|
||||
/* Create a key for accessing the index entry */
|
||||
regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn+1);
|
||||
for(i=0; i<pIdx->nColumn; i++){
|
||||
@@ -1411,6 +1421,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
onError = pIdx->onError;
|
||||
if( onError==OE_None ){
|
||||
sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1);
|
||||
sqlite3VdbeResolveLabel(v, addrSkipRow);
|
||||
continue; /* pIdx is not a UNIQUE index */
|
||||
}
|
||||
if( overrideError!=OE_Default ){
|
||||
@@ -1480,6 +1491,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
}
|
||||
}
|
||||
sqlite3VdbeJumpHere(v, j3);
|
||||
sqlite3VdbeResolveLabel(v, addrSkipRow);
|
||||
sqlite3ReleaseTempReg(pParse, regR);
|
||||
}
|
||||
|
||||
@@ -1509,7 +1521,6 @@ void sqlite3CompleteInsertion(
|
||||
){
|
||||
int i;
|
||||
Vdbe *v;
|
||||
int nIdx;
|
||||
Index *pIdx;
|
||||
u8 pik_flags;
|
||||
int regData;
|
||||
@@ -1518,9 +1529,11 @@ void sqlite3CompleteInsertion(
|
||||
v = sqlite3GetVdbe(pParse);
|
||||
assert( v!=0 );
|
||||
assert( pTab->pSelect==0 ); /* This table is not a VIEW */
|
||||
for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}
|
||||
for(i=nIdx-1; i>=0; i--){
|
||||
for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
|
||||
if( aRegIdx[i]==0 ) continue;
|
||||
if( pIdx->pPartIdxWhere ){
|
||||
sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2);
|
||||
}
|
||||
sqlite3VdbeAddOp2(v, OP_IdxInsert, baseCur+i+1, aRegIdx[i]);
|
||||
if( useSeekResult ){
|
||||
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
|
||||
@@ -1622,6 +1635,7 @@ static int xferCompatibleCollation(const char *z1, const char *z2){
|
||||
** * The same DESC and ASC markings occurs on all columns
|
||||
** * The same onError processing (OE_Abort, OE_Ignore, etc)
|
||||
** * The same collating sequence on each column
|
||||
** * The index has the exact same WHERE clause
|
||||
*/
|
||||
static int xferCompatibleIndex(Index *pDest, Index *pSrc){
|
||||
int i;
|
||||
@@ -1644,6 +1658,9 @@ static int xferCompatibleIndex(Index *pDest, Index *pSrc){
|
||||
return 0; /* Different collating sequences */
|
||||
}
|
||||
}
|
||||
if( sqlite3ExprCompare(pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
|
||||
return 0; /* Different WHERE clauses */
|
||||
}
|
||||
|
||||
/* If no test above fails then the indices must be compatible */
|
||||
return 1;
|
||||
@@ -1799,7 +1816,7 @@ static int xferOptimization(
|
||||
}
|
||||
}
|
||||
#ifndef SQLITE_OMIT_CHECK
|
||||
if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck, pDest->pCheck) ){
|
||||
if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){
|
||||
return 0; /* Tables have different CHECK constraints. Ticket #2252 */
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user