Skip to content

Commit 71e45cc

Browse files
committed
fix: remove fillfactor from appendonly tables for GPDB7 or CBDB compatibility
Closes #22
1 parent 6deb372 commit 71e45cc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

meta/builtin/predata_relations.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ func PrintRegularTableCreateStatement(metadataFile *utils.FileWithByteCount, toc
270270
}
271271

272272
if table.StorageOpts != "" {
273+
if strings.Contains(table.StorageOpts, "appendonly=true") {
274+
table.StorageOpts = removeFillFactor(table.StorageOpts)
275+
}
276+
273277
if destDBVersion.IsHDW() && destDBVersion.Is("3") {
274278
metadataFile.MustPrintf("WITH (%s) ", rewriteAppendonly(rewriteCompressAlgorithm(replaceBlocksize(table.StorageOpts))))
275279
} else {
@@ -305,6 +309,18 @@ func PrintRegularTableCreateStatement(metadataFile *utils.FileWithByteCount, toc
305309
}
306310
}
307311

312+
func removeFillFactor(storageOpts string) string {
313+
opts := strings.Split(storageOpts, ",")
314+
newOpts := make([]string, 0, len(opts))
315+
for _, opt := range opts {
316+
trimmedOpt := strings.TrimSpace(opt)
317+
if !strings.HasPrefix(trimmedOpt, "fillfactor=") {
318+
newOpts = append(newOpts, trimmedOpt)
319+
}
320+
}
321+
return strings.Join(newOpts, ", ")
322+
}
323+
308324
func replaceTableSpace(content string) string {
309325
results := ""
310326
format := regexp.MustCompile(`(.+)TABLESPACE ([^,]+)(,| |$)`)

0 commit comments

Comments
 (0)