Skip to content

Commit bfabd5e

Browse files
committed
fix: Correct comment statement for external tables on Cloudberry, GPDB 7+
1 parent 1c4b9d1 commit bfabd5e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ GINKGO_FLAGS := -r --keep-going --no-color
88
GIT_VERSION := $(shell git describe --tags | perl -pe 's/(.*)-([0-9]*)-(g[0-9a-f]*)/\1+dev.\2.\3/')
99
VERSION_STR="-X github.com/cloudberry-contrib/cbcopy/utils.Version=$(GIT_VERSION)"
1010

11-
SUBDIRS_HAS_UNIT= meta/builtin/ testutils/ utils/
11+
SUBDIRS_HAS_UNIT= internal/dbconn/ meta/builtin/ testutils/ utils/
1212
GINKGO=$(shell go env GOPATH)/bin/ginkgo
1313
GOIMPORTS=$(shell go env GOPATH)/bin/goimports
1414

meta/builtin/queries_table_defs.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
"fmt"
1111
"strings"
1212

13+
"github.com/apache/cloudberry-go-libs/gplog"
1314
"github.com/cloudberry-contrib/cbcopy/internal/dbconn"
1415
"github.com/cloudberry-contrib/cbcopy/meta/builtin/toc"
15-
"github.com/apache/cloudberry-go-libs/gplog"
1616
)
1717

1818
type Table struct {
@@ -27,9 +27,19 @@ func (t Table) SkipDataBackup() bool {
2727

2828
func (t Table) GetMetadataEntry() (string, toc.MetadataEntry) {
2929
objectType := "TABLE"
30+
// This check identifies genuine foreign tables created with CREATE FOREIGN TABLE.
31+
// It does not apply to external tables, which are identified by the IsExternal flag
32+
// and have their own specific logic for GPDB 7+ below.
3033
if (t.ForeignDef != ForeignTableDefinition{}) {
3134
objectType = "FOREIGN TABLE"
3235
}
36+
37+
// In GPDB 7+ and Cloudberry, external tables are implemented as foreign tables.
38+
// We must set the objectType to "FOREIGN TABLE" so that the generated
39+
// "COMMENT ON" statement is correct, otherwise it would fail during restore.
40+
if t.IsExternal && ((srcDBVersion.IsGPDB() && srcDBVersion.AtLeast("7")) || srcDBVersion.IsCBDBFamily()) {
41+
objectType = "FOREIGN TABLE"
42+
}
3343
// https://github.com/greenplum-db/gpbackup/commit/526b859245dcba8ecc61ea6d305330048b0ddba2
3444
referenceObject := ""
3545
if t.AttachPartitionInfo != (AttachPartitionInfo{}) {

0 commit comments

Comments
 (0)