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

truncating a partitioned table with cstore_fdw partitions fail #200

Open
mtuncer opened this issue Dec 14, 2018 · 1 comment
Open

truncating a partitioned table with cstore_fdw partitions fail #200

mtuncer opened this issue Dec 14, 2018 · 1 comment

Comments

@mtuncer
Copy link
Member

mtuncer commented Dec 14, 2018

That is probably due to us handling truncate command via process utility.

Note : Postgres does support truncating foreign tables. So we hook into process utility and modify truncate command to remove any cstore_fdw tables in it. Then we do our internal truncation.

Repro steps

create table pp(a int, b int) partition by range(a);
create table p1 partition of pp for values from (1) to (10);
create foreign table c1 partition of pp for values from (10) to (20) server cstore_server;
insert into pp values (1,1);
select * from pp;
truncate pp; -- will fail with ERROR:  "c1" is not a table
-- see truncate on regular table partition is not performed either
select * from pp;
@mtuncer
Copy link
Member Author

mtuncer commented Dec 14, 2018

It is postgresql

truncatecmds.c::truncate_check_rel() throws the error.

What happens is that
cstore_fdw taps into utility hook, finds that it is not a cstore_table, and lets the standard utility handle the rest.

standard utiliy calls ExecuteTruncate() in tablecmds.c, it first checks if it can perform truncate using truncate_check_rel().

Afterwards ExecuteTruncate extracts inheritors and calls truncate_check_rel() for each of them.
This is where we got "c" is not a table error".

I think cstore_fdw can do nothing about this other than attempting to implement truncate ourselves.

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

1 participant