@@ -87,4 +87,64 @@ SELECT pg_tde_is_encrypted('partition_q4_2024');
87
87
(1 row)
88
88
89
89
DROP TABLE partitioned_table;
90
+ -- Partition inherits encryption status from parent table if default is heap and parent is tde_heap
91
+ SET default_table_access_method = "heap";
92
+ CREATE TABLE partition_parent (a int) PARTITION BY RANGE (a) USING tde_heap;
93
+ CREATE TABLE partition_child PARTITION OF partition_parent FOR VALUES FROM (0) TO (9);
94
+ SELECT pg_tde_is_encrypted('partition_child');
95
+ pg_tde_is_encrypted
96
+ ---------------------
97
+ t
98
+ (1 row)
99
+
100
+ DROP TABLE partition_parent;
101
+ RESET default_table_access_method;
102
+ -- Partition inherits encryption status from parent table if default is tde_heap and parent is heap
103
+ SET default_table_access_method = "tde_heap";
104
+ CREATE TABLE partition_parent (a int) PARTITION BY RANGE (a) USING heap;
105
+ CREATE TABLE partition_child PARTITION OF partition_parent FOR VALUES FROM (0) TO (9);
106
+ SELECT pg_tde_is_encrypted('partition_child');
107
+ pg_tde_is_encrypted
108
+ ---------------------
109
+ f
110
+ (1 row)
111
+
112
+ DROP TABLE partition_parent;
113
+ RESET default_table_access_method;
114
+ -- Partition uses default access method to determine encryption status if neither parent nor child have an access method set
115
+ CREATE TABLE partition_parent (a int) PARTITION BY RANGE (a);
116
+ SET default_table_access_method = "tde_heap";
117
+ CREATE TABLE partition_child_tde PARTITION OF partition_parent FOR VALUES FROM (0) TO (9);
118
+ SELECT pg_tde_is_encrypted('partition_child_tde');
119
+ pg_tde_is_encrypted
120
+ ---------------------
121
+ t
122
+ (1 row)
123
+
124
+ SET default_table_access_method = "heap";
125
+ CREATE TABLE partition_child_heap PARTITION OF partition_parent FOR VALUES FROM (10) TO (19);
126
+ SELECT pg_tde_is_encrypted('partition_child_heap');
127
+ pg_tde_is_encrypted
128
+ ---------------------
129
+ f
130
+ (1 row)
131
+
132
+ DROP TABLE partition_parent;
133
+ RESET default_table_access_method;
134
+ -- Enforce encryption GUC is respected when creating partitions even if parent is plain text
135
+ CREATE TABLE partition_parent (a int) PARTITION BY RANGE (a) USING heap;
136
+ SET pg_tde.enforce_encryption = on;
137
+ CREATE TABLE partition_child_inherit PARTITION OF partition_parent FOR VALUES FROM (0) TO (10);
138
+ ERROR: pg_tde.enforce_encryption is ON, only the tde_heap access method is allowed.
139
+ CREATE TABLE partition_child_heap PARTITION OF partition_parent FOR VALUES FROM (11) TO (20) USING heap;
140
+ ERROR: pg_tde.enforce_encryption is ON, only the tde_heap access method is allowed.
141
+ CREATE TABLE partition_child_tde_heap PARTITION OF partition_parent FOR VALUES FROM (11) TO (20) USING tde_heap;
142
+ SELECT pg_tde_is_encrypted('partition_child_tde_heap');
143
+ pg_tde_is_encrypted
144
+ ---------------------
145
+ t
146
+ (1 row)
147
+
148
+ DROP TABLE partition_parent;
149
+ RESET pg_tde.enforce_encryption;
90
150
DROP EXTENSION pg_tde;
0 commit comments