This is an automated email from the ASF dual-hosted git repository.
maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
The following commit(s) were added to refs/heads/main by this push:
new 2161ec2c89 Allow using table access method when creating partition
table
2161ec2c89 is described below
commit 2161ec2c893d2fd65e91476890f5659226bcf7c5
Author: Hao Wu <[email protected]>
AuthorDate: Wed Dec 11 01:41:07 2024 +0000
Allow using table access method when creating partition table
The pg upstream doesn't support specifying table access method
on partition table until version 17. While the GPDB still supports
specifying table access method on partition table.
The current behavior is supporting table access method on gp-style
partition table, not supporting it on pg-style partition table.
It might be confusing. For some external tools, it still requires
the capability of specifying table access method on both partition
types.
This commit relaxes the constraint to allow specifying table
access method on both parition types.
---
src/backend/commands/tablecmds.c | 11 ++++++++++-
src/test/regress/expected/create_am.out | 4 ++--
src/test/regress/expected/create_am_optimizer.out | 4 ++--
src/test/regress/sql/create_am.sql | 3 ++-
src/test/singlenode_regress/expected/create_am.out | 4 ++--
src/test/singlenode_regress/sql/create_am.sql | 3 ++-
6 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index b189105703..254045a3e6 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -836,11 +836,20 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid
ownerId,
{
accessMethod = stmt->accessMethod;
+ /*
+ * CBDB: Allow specifying table access method to be compatible with
+ * gp-style partition table.
+ * Please KEEP the macro switch to reduce upgrade conflict.
+ * NOTE: The upstream also supports table access method for partition
+ * tables in higher(17) version
+ */
+#if 0
/* Only to allow access method when the partition is gp style
partition */
- if (partitioned && Gp_role != GP_ROLE_EXECUTE &&
!stmt->partspec->gpPartDef)
+ if (partitioned && Gp_role != GP_ROLE_EXECUTE)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("specifying a table access
method is not supported on a partitioned table")));
+#endif
}
else if (relkind == RELKIND_DIRECTORY_TABLE)
diff --git a/src/test/regress/expected/create_am.out
b/src/test/regress/expected/create_am.out
index 663897f734..f842676418 100644
--- a/src/test/regress/expected/create_am.out
+++ b/src/test/regress/expected/create_am.out
@@ -188,8 +188,8 @@ SELECT f1 FROM tableam_tblmv_heap2 ORDER BY f1;
(1 row)
-- CREATE TABLE .. PARTITION BY doesn't not support USING
-CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a) USING
heap2;
-ERROR: specifying a table access method is not supported on a partitioned
table
+-- CBDB ignore: allow table access method
+-- CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a)
USING heap2;
CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a);
-- new partitions will inherit from the current default, rather the partition
root
SET default_table_access_method = 'heap';
diff --git a/src/test/regress/expected/create_am_optimizer.out
b/src/test/regress/expected/create_am_optimizer.out
index 1daf2d99f8..3ad8c194ca 100644
--- a/src/test/regress/expected/create_am_optimizer.out
+++ b/src/test/regress/expected/create_am_optimizer.out
@@ -189,8 +189,8 @@ SELECT f1 FROM tableam_tblmv_heap2 ORDER BY f1;
(1 row)
-- CREATE TABLE .. PARTITION BY doesn't not support USING
-CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a) USING
heap2;
-ERROR: specifying a table access method is not supported on a partitioned
table
+-- CBDB ignore: allow table access method
+-- CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a)
USING heap2;
CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a);
-- new partitions will inherit from the current default, rather the partition
root
SET default_table_access_method = 'heap';
diff --git a/src/test/regress/sql/create_am.sql
b/src/test/regress/sql/create_am.sql
index 9a359466ce..0be89dabf7 100644
--- a/src/test/regress/sql/create_am.sql
+++ b/src/test/regress/sql/create_am.sql
@@ -125,7 +125,8 @@ CREATE MATERIALIZED VIEW tableam_tblmv_heap2 USING heap2 AS
SELECT * FROM tablea
SELECT f1 FROM tableam_tblmv_heap2 ORDER BY f1;
-- CREATE TABLE .. PARTITION BY doesn't not support USING
-CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a) USING
heap2;
+-- CBDB ignore: allow table access method
+-- CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a)
USING heap2;
CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a);
-- new partitions will inherit from the current default, rather the partition
root
diff --git a/src/test/singlenode_regress/expected/create_am.out
b/src/test/singlenode_regress/expected/create_am.out
index c1b7b2a612..716c295510 100644
--- a/src/test/singlenode_regress/expected/create_am.out
+++ b/src/test/singlenode_regress/expected/create_am.out
@@ -179,8 +179,8 @@ SELECT f1 FROM tableam_tblmv_heap2 ORDER BY f1;
(1 row)
-- CREATE TABLE .. PARTITION BY doesn't not support USING
-CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a) USING
heap2;
-ERROR: specifying a table access method is not supported on a partitioned
table
+-- CBDB ignore: allow table access method
+-- CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a)
USING heap2;
CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a);
-- new partitions will inherit from the current default, rather the partition
root
SET default_table_access_method = 'heap';
diff --git a/src/test/singlenode_regress/sql/create_am.sql
b/src/test/singlenode_regress/sql/create_am.sql
index 9a359466ce..0be89dabf7 100644
--- a/src/test/singlenode_regress/sql/create_am.sql
+++ b/src/test/singlenode_regress/sql/create_am.sql
@@ -125,7 +125,8 @@ CREATE MATERIALIZED VIEW tableam_tblmv_heap2 USING heap2 AS
SELECT * FROM tablea
SELECT f1 FROM tableam_tblmv_heap2 ORDER BY f1;
-- CREATE TABLE .. PARTITION BY doesn't not support USING
-CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a) USING
heap2;
+-- CBDB ignore: allow table access method
+-- CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a)
USING heap2;
CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a);
-- new partitions will inherit from the current default, rather the partition
root
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]