You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Set partition creation callback to be invoked for each attached or created partition (both HASH and RANGE).
211
+
Set partition creation callback to be invoked for each attached or created partition (both HASH and RANGE). The callback must have the following signature: `part_init_callback(args JSONB) RETURNS VOID`. Parameter `arg` consists of several fields whose presence depends on partitioning type:
212
+
```json
213
+
/* RANGE-partitioned table abc (child abc_4) */
214
+
{
215
+
"parent": "abc",
216
+
"parttype": "2",
217
+
"partition": "abc_4",
218
+
"range_max": "401",
219
+
"range_min": "301"
220
+
}
221
+
222
+
/* HASH-partitioned table abc (child abc_0) */
223
+
{
224
+
"parent": "abc",
225
+
"parttype": "1",
226
+
"partition": "abc_0"
227
+
}
228
+
```
213
229
214
230
## Views and tables
215
231
@@ -221,8 +237,7 @@ CREATE TABLE IF NOT EXISTS pathman_config (
221
237
parttype INTEGERNOT NULL,
222
238
range_interval TEXT,
223
239
224
-
CHECK (parttype IN (1, 2)) /* check for allowed part types */
225
-
);
240
+
CHECK (parttype IN (1, 2)) /* check for allowed part types */ );
226
241
```
227
242
This table stores a list of partitioned tables.
228
243
@@ -232,8 +247,7 @@ CREATE TABLE IF NOT EXISTS pathman_config_params (
232
247
partrel REGCLASS NOT NULLPRIMARY KEY,
233
248
enable_parent BOOLEANNOT NULL DEFAULT TRUE,
234
249
auto BOOLEANNOT NULL DEFAULT TRUE,
235
-
init_callback REGPROCEDURE NOT NULL DEFAULT 0
236
-
);
250
+
init_callback REGPROCEDURE NOT NULL DEFAULT 0);
237
251
```
238
252
This table stores optional parameters which override standard behavior.
239
253
@@ -259,7 +273,7 @@ This view lists all currently running concurrent partitioning tasks.
259
273
#### `pathman_partition_list` --- list of all existing partitions
260
274
```plpgsql
261
275
-- helper SRF function
262
-
CREATE OR REPLACE FUNCTION @extschema@.show_partition_list()
276
+
CREATE OR REPLACEFUNCTIONshow_partition_list()
263
277
RETURNS TABLE (
264
278
parent REGCLASS,
265
279
partition REGCLASS,
@@ -432,6 +446,22 @@ SELECT * FROM pathman_concurrent_part_tasks;
432
446
(1 row)
433
447
```
434
448
449
+
-`pathman_partition_list` in conjunction with `drop_range_partition()` can be used to drop RANGE partitions in a more flexible way compared to good old `DROP TABLE`:
450
+
```plpgsql
451
+
SELECT drop_range_partition(partition, false) /* move data to parent */
452
+
FROM pathman_partition_list
453
+
WHERE parent ='part_test'::regclass AND range_min::int<500;
454
+
NOTICE: 1 rows copied from part_test_11
455
+
NOTICE: 100 rows copied from part_test_1
456
+
NOTICE: 100 rows copied from part_test_2
457
+
drop_range_partition
458
+
----------------------
459
+
dummy_test_11
460
+
dummy_test_1
461
+
dummy_test_2
462
+
(3 rows)
463
+
```
464
+
435
465
### HASH partitioning
436
466
Consider an example of HASH partitioning. First create a table with some integer column:
437
467
```plpgsql
@@ -471,7 +501,7 @@ Notice that the `Append` node contains only one child scan which corresponds to
471
501
> **Important:** pay attention to the fact that `pg_pathman` excludes the parent table from the query plan.
0 commit comments