1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

Fix the xfer optimization for generated columns, so that VACUUM works again.

FossilOrigin-Name: 8f67b89b04622c1509dc102a83be7a80057dc791625804fc2c294089c98b97e4
This commit is contained in:
drh
2019-10-17 16:16:34 +00:00
parent 8a53ce2ff8
commit ae3977a8f3
3 changed files with 18 additions and 8 deletions

View File

@@ -2289,6 +2289,10 @@ static int xferOptimization(
return 0; /* Neither table may have __hidden__ columns */
}
#endif
if( (pDestCol->colFlags & COLFLAG_GENERATED) !=
(pSrcCol->colFlags & COLFLAG_GENERATED) ){
return 0; /* Both columns have the same generated type */
}
if( pDestCol->affinity!=pSrcCol->affinity ){
return 0; /* Affinity must be the same on all columns */
}
@@ -2299,7 +2303,7 @@ static int xferOptimization(
return 0; /* tab2 must be NOT NULL if tab1 is */
}
/* Default values for second and subsequent columns need to match. */
if( i>0 ){
if( (pDestCol->colFlags & COLFLAG_GENERATED)==0 && i>0 ){
assert( pDestCol->pDflt==0 || pDestCol->pDflt->op==TK_SPAN );
assert( pSrcCol->pDflt==0 || pSrcCol->pDflt->op==TK_SPAN );
if( (pDestCol->pDflt==0)!=(pSrcCol->pDflt==0)
@@ -2309,6 +2313,12 @@ static int xferOptimization(
return 0; /* Default values must be the same for all columns */
}
}
/* Generator expressions for generated columns must match */
if( (pDestCol->colFlags & COLFLAG_GENERATED)!=0 ){
if( sqlite3ExprCompare(0, pSrcCol->pDflt, pDestCol->pDflt, -1)!=0 ){
return 0; /* Different generator expressions */
}
}
}
for(pDestIdx=pDest->pIndex; pDestIdx; pDestIdx=pDestIdx->pNext){
if( IsUniqueIndex(pDestIdx) ){