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

Commit eec4e1d

Browse files
authored
Merge pull request #248 from postgrespro/PGPRO-6538
Changed lock order for MERGE of range partitions + change for issue #247
2 parents e57e04d + 66543e7 commit eec4e1d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

‎src/pl_range_funcs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,9 +683,6 @@ merge_range_partitions(PG_FUNCTION_ARGS)
683683
/* Extract partition Oids from array */
684684
parts[i] = DatumGetObjectId(datums[i]);
685685

686-
/* Prevent modification of partitions */
687-
LockRelationOid(parts[i], AccessExclusiveLock);
688-
689686
/* Check if all partitions are from the same parent */
690687
cur_parent = get_parent_of_partition(parts[i]);
691688

@@ -708,6 +705,10 @@ merge_range_partitions(PG_FUNCTION_ARGS)
708705
/* Prevent changes in partitioning scheme */
709706
LockRelationOid(parent, ShareUpdateExclusiveLock);
710707

708+
/* Prevent modification of partitions */
709+
for (i = 0; i < nparts; i++)
710+
LockRelationOid(parts[i], AccessExclusiveLock);
711+
711712
/* Emit an error if it is not partitioned by RANGE */
712713
prel = get_pathman_relation_info(parent);
713714
shout_if_prel_is_invalid(parent, prel, PT_RANGE);

‎src/utility_stmt_hooking.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ is_pathman_related_copy(Node *parsetree)
114114
(copy_stmt->is_from ?
115115
PATHMAN_COPY_WRITE_LOCK :
116116
PATHMAN_COPY_READ_LOCK),
117-
false);
117+
true);
118+
119+
/* Skip relation if it does not exist (for Citus compatibility) */
120+
if (!OidIsValid(parent_relid))
121+
return false;
118122

119123
/* Check that relation is partitioned */
120124
if (has_pathman_relation_info(parent_relid))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /