aboutsummaryrefslogtreecommitdiff
path: root/src/insert.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2019-10-17 16:16:34 +0000
committerdrh <drh@noemail.net>2019-10-17 16:16:34 +0000
commitae3977a8f30bb859b858c36d03f07319ba210615 (patch)
treec368a4b4601adbd94c4d9c0edbbaa13bd0724b6f /src/insert.c
parent8a53ce2ff8a1e7e3fe867662568e13680cbb0e5e (diff)
downloadsqlite-ae3977a8f30bb859b858c36d03f07319ba210615.tar.gz
sqlite-ae3977a8f30bb859b858c36d03f07319ba210615.zip
Fix the xfer optimization for generated columns, so that VACUUM works again.
FossilOrigin-Name: 8f67b89b04622c1509dc102a83be7a80057dc791625804fc2c294089c98b97e4
Diffstat (limited to 'src/insert.c')
-rw-r--r--src/insert.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/insert.c b/src/insert.c
index 1c628c670..0abe244b3 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -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) ){