Skip to content

Commit 2e62516

Browse files
committed
fix: add additional parent table properties for child inheritance
1 parent 06d17cb commit 2e62516

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ NEW FEATURES
99
- Do not create partitions during a maintenance run that aren't going to be kept as part of retention anyway. (Github Issue #649)
1010
- Removed `default_table` column from `part_config` table. It's only necessary in `part_config_sub` to determine whether future sub-partition parents should have defaults made. Adjusted other code to look up whether a default table actually exists to determine its behavior. (Github Issue #637)
1111
- Allow the control column to be NULL. This is not advised without very careful review and an explicit use-case defined as it can cause unexpected behavior or excessive data in the DEFAULT child partition. A new flag `p_control_not_null` has been added to the `create_parent()` and `create_sub_parent()` functions.
12+
- Include the following additional parent table properties on newly created child tables: COMPRESSION, STORAGE, and STATISTICS. Note this is only for newly created child tables. Existing child tables will have to be updated manually. (Github Issue #683)
1213

1314
BUG FIXES
1415
---------

sql/functions/create_parent.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ IF p_default_table THEN
610610
*/
611611

612612
-- Same INCLUDING list is used in create_partition_*(). INDEXES is handled when partition is attached if it's supported.
613-
v_sql := v_sql || format(' TABLE %I.%I (LIKE %I.%I INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING STORAGE INCLUDING COMMENTS INCLUDING GENERATED)'
613+
v_sql := v_sql || format(' TABLE %I.%I (LIKE %I.%I INCLUDING COMMENTS INCLUDING COMPRESSION INCLUDING CONSTRAINTS INCLUDING DEFAULTS INCLUDING GENERATED INCLUDING STATISTICS INCLUDING STORAGE)'
614614
, v_parent_schema, v_default_partition, v_parent_schema, v_parent_tablename);
615615
IF v_parent_tablespace IS NOT NULL THEN
616616
v_sql := format('%s TABLESPACE %I ', v_sql, v_parent_tablespace);

sql/functions/create_partition_id.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,8 @@ FOREACH v_id IN ARRAY p_partition_ids LOOP
126126
v_step_id := add_step(v_job_id, 'Creating new partition '||v_partition_name||' with interval from '||v_id||' to '||(v_id + v_partition_interval)-1);
127127
END IF;
128128

129-
-- Close parentheses on LIKE are below due to differing requirements of subpartitioning
130129
-- Same INCLUDING list is used in create_parent()
131-
v_sql := format('CREATE TABLE %I.%I (LIKE %I.%I INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING STORAGE INCLUDING COMMENTS INCLUDING GENERATED) '
130+
v_sql := format('CREATE TABLE %I.%I (LIKE %I.%I INCLUDING COMMENTS INCLUDING COMPRESSION INCLUDING CONSTRAINTS INCLUDING DEFAULTS INCLUDING GENERATED INCLUDING STATISTICS INCLUDING STORAGE) '
132131
, v_parent_schema
133132
, v_partition_name
134133
, v_parent_schema

sql/functions/create_partition_time.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ FOREACH v_time IN ARRAY p_partition_times LOOP
186186
*/
187187

188188
-- Same INCLUDING list is used in create_parent()
189-
v_sql := v_sql || format(' TABLE %I.%I (LIKE %I.%I INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING STORAGE INCLUDING COMMENTS INCLUDING GENERATED) '
189+
v_sql := v_sql || format(' TABLE %I.%I (LIKE %I.%I INCLUDING COMMENTS INCLUDING COMPRESSION INCLUDING CONSTRAINTS INCLUDING DEFAULTS INCLUDING GENERATED INCLUDING STATISTICS INCLUDING STORAGE) '
190190
, v_parent_schema
191191
, v_partition_name
192192
, v_parent_schema

test/test-dump-definition.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ E'SELECT partman.create_parent(
8080
p_template_table := ''partman.template_partman_test_declarative_objects'',
8181
p_jobmon := ''t'',
8282
p_date_trunc_interval := NULL,
83-
p_control_not_null := ''t''
83+
p_control_not_null := ''t''
8484
);
8585
UPDATE partman.part_config SET
8686
optimize_constraint = 30,

updates/pg_partman--5.1.0--5.2.0.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
-- TODO - add test for PR#650 - not creating partitions that aren't being retained anyway
22
-- - add test to ensure sub partitioning preserves default table settings and not null enforcement
3+
-- - add test for constraint exclusion with integer-based partitioning
34

45
-- TODO PRESERVE PRIVILEGES
56
DROP FUNCTION @[email protected]_parent(text, text, text, text, text, int, text, boolean, text, text[], text, boolean, text);
@@ -2383,7 +2384,7 @@ IF p_default_table THEN
23832384
*/
23842385

23852386
-- Same INCLUDING list is used in create_partition_*(). INDEXES is handled when partition is attached if it's supported.
2386-
v_sql := v_sql || format(' TABLE %I.%I (LIKE %I.%I INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING STORAGE INCLUDING COMMENTS INCLUDING GENERATED)'
2387+
v_sql := v_sql || format(' TABLE %I.%I (LIKE %I.%I INCLUDING COMMENTS INCLUDING COMPRESSION INCLUDING CONSTRAINTS INCLUDING DEFAULTS INCLUDING GENERATED INCLUDING STATISTICS INCLUDING STORAGE)'
23872388
, v_parent_schema, v_default_partition, v_parent_schema, v_parent_tablename);
23882389
IF v_parent_tablespace IS NOT NULL THEN
23892390
v_sql := format('%s TABLESPACE %I ', v_sql, v_parent_tablespace);
@@ -2794,9 +2795,8 @@ FOREACH v_id IN ARRAY p_partition_ids LOOP
27942795
v_step_id := add_step(v_job_id, 'Creating new partition '||v_partition_name||' with interval from '||v_id||' to '||(v_id + v_partition_interval)-1);
27952796
END IF;
27962797

2797-
-- Close parentheses on LIKE are below due to differing requirements of subpartitioning
27982798
-- Same INCLUDING list is used in create_parent()
2799-
v_sql := format('CREATE TABLE %I.%I (LIKE %I.%I INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING STORAGE INCLUDING COMMENTS INCLUDING GENERATED) '
2799+
v_sql := format('CREATE TABLE %I.%I (LIKE %I.%I INCLUDING COMMENTS INCLUDING COMPRESSION INCLUDING CONSTRAINTS INCLUDING DEFAULTS INCLUDING GENERATED INCLUDING STATISTICS INCLUDING STORAGE) '
28002800
, v_parent_schema
28012801
, v_partition_name
28022802
, v_parent_schema
@@ -3171,7 +3171,7 @@ FOREACH v_time IN ARRAY p_partition_times LOOP
31713171
*/
31723172

31733173
-- Same INCLUDING list is used in create_parent()
3174-
v_sql := v_sql || format(' TABLE %I.%I (LIKE %I.%I INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING STORAGE INCLUDING COMMENTS INCLUDING GENERATED) '
3174+
v_sql := v_sql || format(' TABLE %I.%I (LIKE %I.%I INCLUDING COMMENTS INCLUDING COMPRESSION INCLUDING CONSTRAINTS INCLUDING DEFAULTS INCLUDING GENERATED INCLUDING STATISTICS INCLUDING STORAGE) '
31753175
, v_parent_schema
31763176
, v_partition_name
31773177
, v_parent_schema

0 commit comments

Comments
 (0)