This is an automated email from the ASF dual-hosted git repository.
gfphoenix78 pushed a commit to branch sync-with-upstream
in repository https://gitbox.apache.org/repos/asf/cloudberry-gpbackup.git
The following commit(s) were added to refs/heads/sync-with-upstream by this
push:
new 93f7821f fix(test): Adapt base type creation test for Cloudberry (#30)
93f7821f is described below
commit 93f7821f7bbb16c8b815320c8cd07413844785b7
Author: Robert Mu <[email protected]>
AuthorDate: Thu Aug 28 20:44:25 2025 +0800
fix(test): Adapt base type creation test for Cloudberry (#30)
This commit resolves an integration test failure for
PrintCreateBaseTypeStatement when running against Cloudberry, which is
based on PostgreSQL 14.
PostgreSQL 14 enforces stricter validation for `CREATE TYPE`. It now
requires that a type specified with an `ELEMENT` parameter must also
have an associated subscripting function. This requirement is not
enforced in PostgreSQL 12 (on which GPDB 7 is based), which allowed
`ELEMENT` as a metadata-only attribute.
To ensure compatibility, this change conditionally modifies the `baseType`
struct in the `BeforeEach` block. When running on Cloudberry, the
`Element` field is set to an empty string. This ensures that the
auto-generated `CREATE TYPE` statement is valid for PostgreSQL 14,
allowing the test to pass while preserving the original logic for GPDB 7.
---
integration/predata_types_create_test.go | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/integration/predata_types_create_test.go
b/integration/predata_types_create_test.go
index 939c9429..ab63b11e 100644
--- a/integration/predata_types_create_test.go
+++ b/integration/predata_types_create_test.go
@@ -34,6 +34,21 @@ var _ = Describe("backup integration create statement
tests", func() {
Send: "", ModIn: "", ModOut: "",
InternalLength: 4, IsPassedByValue: true, Alignment: "i", Storage: "p",
DefaultVal: "default", Element: "text",
Category: "U", Preferred: false, Delimiter: ";", StorageOptions:
"compresstype=zlib, compresslevel=1, blocksize=32768",
}
+ /*
+ * In PostgreSQL 14 (which Cloudberry is based on), the
validation for CREATE TYPE has become stricter.
+ * The 'ELEMENT' parameter can only be specified if a
'subscripting function' is also
+ * provided for the type.
+ *
+ * PostgreSQL 12 (GPDB 7 is based on) was more lenient
and allowed specifying 'ELEMENT'
+ * as a metadata-only attribute without enforcing the
presence of a subscripting
+ * function, even though the type would not actually
support subscripting.
+ *
+ * To make this test compatible, we conditionally
remove the ELEMENT attribute from the
+ * baseType struct when running against Cloudberry.
+ */
+ if connectionPool.Version.IsCBDB() {
+ baseType.Element = ""
+ }
rangeType = backup.RangeType{
Oid: 0,
Schema: "public",
@@ -114,6 +129,13 @@ var _ = Describe("backup integration create statement
tests", func() {
baseType.Preferred = true
baseType.Collatable = true
}
+ /*
+ * To make this test compatible, we
conditionally remove the ELEMENT attribute from the
+ * input struct just for this test case when
running against Cloudberry.
+ */
+ if connectionPool.Version.IsCBDB() {
+ baseType.Element = ""
+ }
metadata :=
testutils.DefaultMetadata(toc.OBJ_TYPE, false, true, true,
includeSecurityLabels)
backup.PrintCreateBaseTypeStatement(backupfile,
tocfile, baseType, metadata)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]