Skip to content

Commit bd91f26

Browse files
committed
Merge commit 'ac5a2bb086937740fce7ecee791cf329d9fafbd2' into PGPRO9_5
2 parents de4d22d + ac5a2bb commit bd91f26

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

contrib/pg_pathman/init.sql

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -530,36 +530,37 @@ BEGIN
530530
DELETE FROM @extschema@.pathman_config_params WHERE partrel = parent_relid;
531531

532532
IF conf_num_del = 0 THEN
533-
RAISE EXCEPTION 'relation "%" has no partitions', parent_relid::text;
533+
RAISE EXCEPTION 'relation "%" has no partitions', parent_relid::TEXT;
534534
END IF;
535535

536-
FOR v_rec IN (SELECT inhrelid::regclass::text AS tbl
536+
FOR v_rec IN (SELECT inhrelid::REGCLASS AS tbl
537537
FROM pg_catalog.pg_inherits
538538
WHERE inhparent::regclass = parent_relid)
539539
LOOP
540540
IF NOT delete_data THEN
541541
EXECUTE format('WITH part_data AS (DELETE FROM %s RETURNING *)
542542
INSERT INTO %s SELECT * FROM part_data',
543-
v_rec.tbl,
543+
v_rec.tbl::TEXT,
544544
parent_relid::text);
545545
GET DIAGNOSTICS v_rows = ROW_COUNT;
546546

547547
/* Show number of copied rows */
548-
RAISE NOTICE '% rows copied from %', v_rows, v_rec.tbl;
548+
RAISE NOTICE '% rows copied from %', v_rows, v_rec.tbl::TEXT;
549549
END IF;
550550

551+
SELECT relkind FROM pg_catalog.pg_class
552+
WHERE oid = v_rec.tbl
553+
INTO v_relkind;
554+
551555
/*
552556
* Determine the kind of child relation. It can be either regular
553557
* table (r) or foreign table (f). Depending on relkind we use
554-
* DROP TABLE or DROP FOREIGN TABLE
558+
* DROP TABLE or DROP FOREIGN TABLE.
555559
*/
556-
EXECUTE format('SELECT relkind FROM pg_class WHERE oid = ''%s''::regclass', v_rec.tbl)
557-
INTO v_relkind;
558-
559560
IF v_relkind = 'f' THEN
560-
EXECUTE format('DROP FOREIGN TABLE %s', v_rec.tbl);
561+
EXECUTE format('DROP FOREIGN TABLE %s', v_rec.tbl::TEXT);
561562
ELSE
562-
EXECUTE format('DROP TABLE %s', v_rec.tbl);
563+
EXECUTE format('DROP TABLE %s', v_rec.tbl::TEXT);
563564
END IF;
564565

565566
v_part_count := v_part_count + 1;

contrib/pg_pathman/range.sql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,7 @@ $$
10661066
DECLARE
10671067
v_attname TEXT;
10681068
rel_persistence CHAR;
1069+
v_init_callback REGPROCEDURE;
10691070

10701071
BEGIN
10711072
/* Acquire lock on parent */
@@ -1105,6 +1106,20 @@ BEGIN
11051106
p_start_value,
11061107
p_end_value));
11071108

1109+
/* Fetch init_callback from 'params' table */
1110+
WITH stub_callback(stub) as (values (0))
1111+
SELECT coalesce(init_callback, 0::REGPROCEDURE)
1112+
FROM stub_callback
1113+
LEFT JOIN @extschema@.pathman_config_params AS params
1114+
ON params.partrel = parent_relid
1115+
INTO v_init_callback;
1116+
1117+
PERFORM @extschema@.invoke_on_partition_created_callback(parent_relid,
1118+
p_partition,
1119+
v_init_callback,
1120+
p_start_value,
1121+
p_end_value);
1122+
11081123
/* Invalidate cache */
11091124
PERFORM @extschema@.on_update_partitions(parent_relid);
11101125

contrib/pg_pathman/src/copy_stmt_hooking.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ is_pathman_related_copy(Node *parsetree)
5454
CopyStmt *copy_stmt = (CopyStmt *) parsetree;
5555
Oid partitioned_table;
5656

57+
Assert(IsPathmanReady());
58+
5759
if (!IsOverrideCopyEnabled())
5860
{
5961
elog(DEBUG1, "COPY statement hooking is disabled");

contrib/pg_pathman/src/hooks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,9 @@ pathman_process_utility_hook(Node *parsetree,
611611
dest, completionTag);
612612

613613
/* Override standard COPY statement if needed */
614-
if (is_pathman_related_copy(parsetree))
614+
if (IsPathmanReady() && is_pathman_related_copy(parsetree))
615615
{
616-
uint64 processed;
616+
uint64 processed;
617617

618618
PathmanDoCopy((CopyStmt *) parsetree, queryString, &processed);
619619
if (completionTag)

0 commit comments

Comments
 (0)