truncating a partitioned table with cstore_fdw partitions fail
mtuncer opened this issue · 1 comments
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;
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.