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

Commit2a31969

Browse files
committed
add parameter 'lock_parent' to function replace_hash_partition()
1 parentdc0a854 commit2a31969

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

‎hash.sql

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,14 @@ SET client_min_messages = WARNING;
5959

6060
/*
6161
* Replace hash partition with another one. It could be useful in case when
62-
* someone wants to attach foreign table as a partition
62+
* someone wants to attach foreign table as a partition.
63+
*
64+
* lock_parent - should we take an exclusive lock?
6365
*/
6466
CREATEOR REPLACE FUNCTION @extschema@.replace_hash_partition(
6567
old_partitionREGCLASS,
66-
new_partitionREGCLASS)
68+
new_partitionREGCLASS,
69+
lock_parentBOOL DEFAULT TRUE)
6770
RETURNS REGCLASSAS
6871
$$
6972
DECLARE
@@ -81,8 +84,13 @@ BEGIN
8184
/* Parent relation*/
8285
parent_relid := @extschema@.get_parent_of_partition(old_partition);
8386

84-
/* Acquire lock on parent*/
85-
PERFORM @extschema@.lock_partitioned_relation(parent_relid);
87+
IF lock_parent THEN
88+
/* Acquire data modification lock (prevent further modifications)*/
89+
PERFORM @extschema@.prevent_relation_modification(parent_relid);
90+
ELSE
91+
/* Acquire lock on parent*/
92+
PERFORM @extschema@.lock_partitioned_relation(parent_relid);
93+
END IF;
8694

8795
/* Acquire data modification lock (prevent further modifications)*/
8896
PERFORM @extschema@.prevent_relation_modification(old_partition);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp