Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc758c4b

Browse files
committed
pathman: plpgsql functions return values
1 parentaf522cd commitc758c4b

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

‎contrib/pg_pathman/expected/pg_pathman.out

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ NOTICE: Copying data to test.range_rel_2 (condition: ((dt >= 'Sun Feb 01 00:00:
3434
NOTICE: Copying data to test.range_rel_1 (condition: ((dt >= 'Thu Jan 01 00:00:00 2015'::timestamp without time zone) AND (dt < 'Sun Feb 01 00:00:00 2015'::timestamp without time zone)))
3535
partition_data
3636
----------------
37-
0
37+
120
3838
(1 row)
3939

4040
CREATE TABLE test.num_range_rel (
@@ -81,9 +81,9 @@ SELECT * FROM test.hash_rel WHERE value = 7;
8181
(1 row)
8282

8383
SELECT pathman.create_range_update_trigger('test.num_range_rel');
84-
create_range_update_trigger
85-
-----------------------------
86-
84+
create_range_update_trigger
85+
------------------------------------------
86+
test.num_range_rel_update_trigger_func()
8787
(1 row)
8888

8989
UPDATE test.num_range_rel SET id = 3001 WHERE id = 1;
@@ -518,7 +518,7 @@ NOTICE: Copying data to hash_rel_1 (condition: ((value % 3) = 1))
518518
NOTICE: Copying data to hash_rel_2 (condition: ((value % 3) = 2))
519519
partition_data
520520
----------------
521-
0
521+
10000
522522
(1 row)
523523

524524
EXPLAIN (COSTS OFF) SELECT * FROM hash_rel WHERE id = 1234;
@@ -562,7 +562,7 @@ NOTICE: Copying data to range_rel_11 (condition: ((dt >= 'Mon Nov 01 00:00:00 2
562562
NOTICE: Copying data to range_rel_12 (condition: ((dt >= 'Wed Dec 01 00:00:00 2010'::timestamp without time zone) AND (dt < 'Sat Jan 01 00:00:00 2011'::timestamp without time zone)))
563563
partition_data
564564
----------------
565-
0
565+
365
566566
(1 row)
567567

568568
SELECT merge_range_partitions('range_rel_1', 'range_rel_2');

‎contrib/pg_pathman/sql/init.sql

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,16 @@ RETURNS ANYARRAY AS 'pg_pathman', 'get_range_by_idx' LANGUAGE C STRICT;
4141
/*
4242
* Copy rows to partitions
4343
*/
44-
CREATEOR REPLACE FUNCTION @extschema@.partition_data(p_parenttext)
45-
RETURNSbigintAS
44+
CREATEOR REPLACE FUNCTION @extschema@.partition_data(p_parenttext, OUT p_totalBIGINT)
45+
AS
4646
$$
4747
DECLARE
4848
rec RECORD;
49+
cntBIGINT :=0;
4950
BEGIN
5051
p_parent := @extschema@.validate_relname(p_parent);
52+
53+
p_total :=0;
5154
FOR recIN (SELECT inhrelidas child_id,pg_constraint.consrc
5255
FROM @extschema@.pathman_configas cfg
5356
JOIN pg_classAS parentONparent.relfilenode=cfg.relname::regclass::oid
@@ -62,8 +65,9 @@ BEGIN
6265
, p_parent
6366
,rec.consrc
6467
,rec.child_id::regclass::text);
68+
GET DIAGNOSTICS cnt= ROW_COUNT;
69+
p_total := p_total+ cnt;
6570
END LOOP;
66-
RETURN0;
6771
END
6872
$$
6973
LANGUAGE plpgsql;

‎contrib/pg_pathman/sql/range.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ BEGIN
262262
END
263263
$$ LANGUAGE plpgsql;
264264

265-
266265
/*
267266
* Split RANGE partition
268267
*/
@@ -596,7 +595,7 @@ $$ LANGUAGE plpgsql;
596595
*/
597596
CREATEOR REPLACE FUNCTION @extschema@.create_range_update_trigger(
598597
IN relationTEXT)
599-
RETURNSVOIDAS
598+
RETURNSTEXTAS
600599
$$
601600
DECLARE
602601
funcTEXT :='
@@ -630,6 +629,7 @@ DECLARE
630629
numINTEGER :=0;
631630
attrTEXT;
632631
BEGIN
632+
relation := @extschema@.validate_relname(relation);
633633
relid := relation::regclass::oid;
634634
SELECT string_agg(attname,','),
635635
string_agg('OLD.'|| attname,','),
@@ -656,6 +656,8 @@ BEGIN
656656
, relation);
657657
num := num+1;
658658
END LOOP;
659+
660+
RETURN format('%s_update_trigger_func()', relation);
659661
END
660662
$$ LANGUAGE plpgsql;
661663

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp