Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Specifying TAM for partiotion table #698

Closed
2 tasks done
reshke opened this issue Nov 1, 2024 · 6 comments
Closed
2 tasks done

[Bug] Specifying TAM for partiotion table #698

reshke opened this issue Nov 1, 2024 · 6 comments

Comments

@reshke
Copy link
Contributor

reshke commented Nov 1, 2024

Cloudberry Database version

No response

What happened

the behavior of creating partitioned table inconsistently handles Table Access Method clause, because of

https://github.com/cloudberrydb/cloudberrydb/blob/main/src/backend/commands/tablecmds.c#L840

if dont really understand this if condition. In my opinion, we should not disallow this. Newly created partitions should inherit partition root TAM, aren't they? So we need a way to specify it.

What you think should happen instead

No response

How to reproduce


db3=# create table t(i int) partition by range (i) (start (10) end (11)) using ao_row distributed by (i) ;
CREATE TABLE
db3=# drop table t;
DROP TABLE
db3=# create table t(i int) partition by range (i)  using ao_row distributed by (i) ;
ERROR:  specifying a table access method is not supported on a partitioned table

Operating System

any

Anything else

No response

Are you willing to submit PR?

  • Yes, I am willing to submit a PR!

Code of Conduct

@reshke reshke added the type: Bug Something isn't working label Nov 1, 2024
@reshke
Copy link
Contributor Author

reshke commented Nov 1, 2024

In both cases relkind = 'p' relation will be created.

@reshke
Copy link
Contributor Author

reshke commented Nov 1, 2024

To be clear: #695 does not fix this. In only handles how new partition will be created by saving into root partition pg_class.relam, not root partition definition. (this also would fail after 695 merged)

@gfphoenix78
Copy link
Contributor

There are two kinds of partition tables in cloudberry. One is from greenplum, the other one inherits from postgres. The gp-style partition tables appear earlier than pg partition tables. When greenplum upgrade its kernel, the gp-style partition tables tends to implement with the pg partition code. The principle is that the behavior of partition tables try to follow the pg upstream, but also keep the legacy(gp-style) partition behaviors for existing customers.

db3=# create table t(i int) partition by range (i)  using ao_row distributed by (i) ;
ERROR:  specifying a table access method is not supported on a partitioned table

The syntax is from pg upstream, and the behavior is exactly the same as pg upstream. The root partition doesn't have access method, so the child can't inherit the access method from its parent.

When creating the gp-style partition tables, we try to keep the behavior, to allow the child partition inherits access method and other options from its parent partition. The result is that the root partition table saves its access method in pg_class.relam.

We don't plan to mix all things together to increase complexity.

@gfphoenix78 gfphoenix78 removed the type: Bug Something isn't working label Nov 1, 2024
@reshke
Copy link
Contributor Author

reshke commented Nov 1, 2024

There are two kinds of partition tables in cloudberry. One is from greenplum, the other one inherits from postgres. The gp-style partition tables appear earlier than pg partition tables. When greenplum upgrade its kernel, the gp-style partition tables tends to implement with the pg partition code. The principle is that the behavior of partition tables try to follow the pg upstream, but also keep the legacy(gp-style) partition behaviors for existing customers.

Sure, I know.

The syntax is from pg upstream, and the behavior is exactly the same as pg upstream. The root partition doesn't have access method, so the child can't inherit the access method from its parent.

Thats not true, and this is why this issue is created.


db2=# select version();
                                                 version
----------------------------------------------------------------------------------------------------------
 PostgreSQL 18devel on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit
(1 row)

db2=# create access method am1 TYPE table HANDLER heap_tableam_handler;
CREATE ACCESS METHOD
db2=#
db2=# create table tt(i int) partition by range ( i ) using am1;
CREATE TABLE
db2=# select relam from pg_class where oid = 'tt'::regclass::oid;
 relam
-------
 16478
(1 row)

db2=# create table tt_p partition of tt
DEFAULT     FOR VALUES
db2=# create table tt_p partition of tt default ;
CREATE TABLE
db2=# select relam from pg_class where oid = 'tt_p'::regclass::oid;
 relam
-------
 16478
(1 row)

db2=#

@gfphoenix78
Copy link
Contributor

There are two kinds of partition tables in cloudberry. One is from greenplum, the other one inherits from postgres. The gp-style partition tables appear earlier than pg partition tables. When greenplum upgrade its kernel, the gp-style partition tables tends to implement with the pg partition code. The principle is that the behavior of partition tables try to follow the pg upstream, but also keep the legacy(gp-style) partition behaviors for existing customers.

Sure, I know.

The syntax is from pg upstream, and the behavior is exactly the same as pg upstream. The root partition doesn't have access method, so the child can't inherit the access method from its parent.

Thats not true, and this is why this issue is created.


db2=# select version();
                                                 version
----------------------------------------------------------------------------------------------------------
 PostgreSQL 18devel on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit
(1 row)

db2=# create access method am1 TYPE table HANDLER heap_tableam_handler;
CREATE ACCESS METHOD
db2=#
db2=# create table tt(i int) partition by range ( i ) using am1;
CREATE TABLE
db2=# select relam from pg_class where oid = 'tt'::regclass::oid;
 relam
-------
 16478
(1 row)

db2=# create table tt_p partition of tt
DEFAULT     FOR VALUES
db2=# create table tt_p partition of tt default ;
CREATE TABLE
db2=# select relam from pg_class where oid = 'tt_p'::regclass::oid;
 relam
-------
 16478
(1 row)

db2=#

The feature was first introduced in postgres 17. Before pg 17, the partition table isn't allowed to have table access method.
Normally, we'll have these features(from higher pg upstream) by upgrading the kernel.

@gfphoenix78
Copy link
Contributor

Fixed by #695

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants