File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ GINKGO_FLAGS := -r --keep-going --no-color
88GIT_VERSION := $(shell git describe --tags | perl -pe 's/(.* ) -([0-9]*)-(g[0-9a-f]*)/\1+dev.\2.\3/')
99VERSION_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/
1212GINKGO =$(shell go env GOPATH) /bin/ginkgo
1313GOIMPORTS =$(shell go env GOPATH) /bin/goimports
1414
Original file line number Diff line number Diff 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
1818type Table struct {
@@ -27,9 +27,19 @@ func (t Table) SkipDataBackup() bool {
2727
2828func (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 {}) {
You can’t perform that action at this time.
0 commit comments