Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#23064] YSQL: pg_partman: disable p_retention_schema parameter
Summary: In drop_partition_id and drop_partition_time pg_partman functions which is used to drop child tables from a id-based or time-based partition set, there is parameter `p_retention_schema` which if set moves a child table to another schema instead of dropping it. If set, then these two functions executes an `ALTER TABLE SET SCHEMA` to move the child partition to new schema. Currently `ALTER TABLE SET SCHEMA ` is not supported in YB therefore returning error if set. ``` yugabyte=# create table tab(a int); CREATE TABLE yugabyte=# create schema new_schema; CREATE SCHEMA yugabyte=# alter table tab set schema new_schema;; ERROR: ALTER TABLE SET SCHEMA not supported yet LINE 1: alter table tab set schema new_schema; ^ HINT: Please report the issue on https://github.com/YugaByte/yugabyte-db/issues ``` If the drop_partition_time and drop_partition_id are not early exited when `p_retention_schema` is not NULL that could cause detaching of child partitions. There is this logic in both functions that detaches child tables if `p_retention_schema` is not NULL. ``` IF v_retention_keep_table = true OR v_retention_schema IS NOT NULL THEN -- No need to detach partition before dropping since it's going away anyway -- Avoids issue of FKs not allowing detachment (Github Issue #294). IF v_partition_type = 'native' THEN v_sql := format('ALTER TABLE %I.%I DETACH PARTITION %I.%I' , v_parent_schema , v_parent_tablename , v_row.partition_schemaname , v_row.partition_tablename); EXECUTE v_sql; ELSE EXECUTE format('ALTER TABLE %I.%I NO INHERIT %I.%I' , v_row.partition_schemaname , v_row.partition_tablename , v_parent_schema , v_parent_tablename); ``` So if retention_schema is not null in parameters, child partition would be detached , there is later this call to move it to new schema ``` ELSE -- Move to new schema IF v_jobmon_schema IS NOT NULL THEN v_step_id := add_step(v_job_id, format('Moving table %s.%s to schema %s' , v_row.partition_schemaname , v_row.partition_tablename , v_retention_schema)); END IF; EXECUTE format('ALTER TABLE %I.%I SET SCHEMA %I', v_row.partition_schemaname, v_row.partition_tablename, v_retention_schema); ``` So, if we allow procedure to fail here instead of early exiting, the child table would be actually detached even if the stored procedure errors out. Given YugabyteDB don't have transactional DDL support yet, the detach call we not be rolled back. Jira: DB-12001 Test Plan: jenkins: compile only Reviewers: skumar, hsunder, jason Reviewed By: jason Subscribers: yql Differential Revision: https://phorge.dev.yugabyte.com/D36427
- Loading branch information