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

Commitcd3b01e

Browse files
committed
create_single_range_partition() function fix
1 parentfa1429e commitcd3b01e

File tree

4 files changed

+26
-20
lines changed

4 files changed

+26
-20
lines changed

‎expected/pathman_basic.out

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,34 +1912,34 @@ NOTICE: sequence "index_on_childs_seq" does not exist, skipping
19121912
0
19131913
(1 row)
19141914

1915-
SELECT add_range_partition('test.index_on_childs', 1, 1000, 'test.index_on_childs_1_1K');
1915+
SELECT add_range_partition('test.index_on_childs', 1, 1000, 'test.index_on_childs_1_1k');
19161916
add_range_partition
19171917
---------------------------
1918-
test.index_on_childs_1_1K
1918+
test.index_on_childs_1_1k
19191919
(1 row)
19201920

1921-
SELECT append_range_partition('test.index_on_childs', 'test.index_on_childs_1K_2K');
1921+
SELECT append_range_partition('test.index_on_childs', 'test.index_on_childs_1k_2k');
19221922
append_range_partition
19231923
----------------------------
1924-
test.index_on_childs_1K_2K
1924+
test.index_on_childs_1k_2k
19251925
(1 row)
19261926

1927-
SELECT append_range_partition('test.index_on_childs', 'test.index_on_childs_2K_3K');
1927+
SELECT append_range_partition('test.index_on_childs', 'test.index_on_childs_2k_3k');
19281928
append_range_partition
19291929
----------------------------
1930-
test.index_on_childs_2K_3K
1930+
test.index_on_childs_2k_3k
19311931
(1 row)
19321932

1933-
SELECT append_range_partition('test.index_on_childs', 'test.index_on_childs_3K_4K');
1933+
SELECT append_range_partition('test.index_on_childs', 'test.index_on_childs_3k_4k');
19341934
append_range_partition
19351935
----------------------------
1936-
test.index_on_childs_3K_4K
1936+
test.index_on_childs_3k_4k
19371937
(1 row)
19381938

1939-
SELECT append_range_partition('test.index_on_childs', 'test.index_on_childs_4K_5K');
1939+
SELECT append_range_partition('test.index_on_childs', 'test.index_on_childs_4k_5k');
19401940
append_range_partition
19411941
----------------------------
1942-
test.index_on_childs_4K_5K
1942+
test.index_on_childs_4k_5k
19431943
(1 row)
19441944

19451945
SELECT set_enable_parent('test.index_on_childs', true);

‎range.sql

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ CREATE OR REPLACE FUNCTION @extschema@.create_single_range_partition(
460460
end_valueANYELEMENT,
461461
partition_nameTEXT DEFAULTNULL,
462462
tablespaceTEXT DEFAULTNULL)
463-
RETURNSTEXTAS
463+
RETURNSREGCLASSAS
464464
$$
465465
DECLARE
466466
v_part_numINT;
@@ -472,7 +472,7 @@ DECLARE
472472
v_child_relname_existsBOOL;
473473
v_seq_nameTEXT;
474474
v_init_callbackREGPROCEDURE;
475-
475+
v_result REGCLASS;
476476
BEGIN
477477
v_attname := attnameFROM @extschema@.pathman_config
478478
WHERE partrel= parent_relid;
@@ -535,13 +535,20 @@ BEGIN
535535
ONparams.partrel= parent_relid
536536
INTO v_init_callback;
537537

538+
/*
539+
* Save the regclass value because in callback user may want to rename
540+
* partition
541+
*/
542+
v_result := v_child_relname::regclass;
543+
544+
/* Invoke callback*/
538545
PERFORM @extschema@.invoke_on_partition_created_callback(parent_relid,
539546
v_child_relname::REGCLASS,
540547
v_init_callback,
541548
start_value,
542549
end_value);
543550

544-
RETURNv_child_relname;
551+
RETURNv_result;
545552
END
546553
$$ LANGUAGE plpgsql
547554
SET client_min_messages= WARNING;

‎sql/pathman_basic.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,11 @@ CREATE TABLE test.index_on_childs(c1 integer not null, c2 integer);
498498
CREATEINDEXONtest.index_on_childs(c2);
499499
INSERT INTOtest.index_on_childsSELECT i, (random()*10000)::integerFROM generate_series(1,10000) i;
500500
SELECT create_range_partitions('test.index_on_childs','c1',1,1000,0, false);
501-
SELECT add_range_partition('test.index_on_childs',1,1000,'test.index_on_childs_1_1K');
502-
SELECT append_range_partition('test.index_on_childs','test.index_on_childs_1K_2K');
503-
SELECT append_range_partition('test.index_on_childs','test.index_on_childs_2K_3K');
504-
SELECT append_range_partition('test.index_on_childs','test.index_on_childs_3K_4K');
505-
SELECT append_range_partition('test.index_on_childs','test.index_on_childs_4K_5K');
501+
SELECT add_range_partition('test.index_on_childs',1,1000,'test.index_on_childs_1_1k');
502+
SELECT append_range_partition('test.index_on_childs','test.index_on_childs_1k_2k');
503+
SELECT append_range_partition('test.index_on_childs','test.index_on_childs_2k_3k');
504+
SELECT append_range_partition('test.index_on_childs','test.index_on_childs_3k_4k');
505+
SELECT append_range_partition('test.index_on_childs','test.index_on_childs_4k_5k');
506506
SELECT set_enable_parent('test.index_on_childs', true);
507507
VACUUM ANALYZEtest.index_on_childs;
508508
EXPLAIN (COSTS OFF)SELECT*FROMtest.index_on_childsWHERE c1>100AND c1<2500AND c2=500;

‎src/pg_pathman.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,7 @@ spawn_partitions(Oid partitioned_rel,/* parent's Oid */
582582
char*query;
583583

584584
/* Create querty statement */
585-
query=psprintf("SELECT part::regclass "
586-
"FROM %s.create_single_range_partition($1, $2, $3) AS part",
585+
query=psprintf("SELECT %s.create_single_range_partition($1, $2, $3) AS part",
587586
get_namespace_name(get_pathman_schema()));
588587

589588
/* Execute comparison function cmp(value, cur_part_leading) */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp