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

Commit38921d1

Browse files
committed
Assign constraint name when cloning FK definition for partitions
This is for example used when attaching a partition to a partitionedtable which includes foreign keys, and in this case the constraint namehas been missing in the data cloned. This could lead to hard crashes,as when validating the foreign key constraint, the constraint name isalways expected. Particularly, when using log_min_messages >= DEBUG1, alog message would be generated with this unassigned constraint name,leading to an assertion failure on HEAD.While on it, rename a variable in ATExecAttachPartition which wasdeclared twice with the same name.Author: Michael PaquierReviewed-by: Álvaro HerreraDiscussion:https://postgr.es/m/20181005042236.GG1629@paquier.xyzBackpatch-through: 11
1 parent6eb612f commit38921d1

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

‎src/backend/catalog/pg_constraint.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ CloneForeignKeyConstraints(Oid parentId, Oid relationId, List **cloned)
574574

575575
fkconstraint=makeNode(Constraint);
576576
/* for now this is all we need */
577+
fkconstraint->conname=pstrdup(NameStr(constrForm->conname));
577578
fkconstraint->fk_upd_action=constrForm->confupdtype;
578579
fkconstraint->fk_del_action=constrForm->confdeltype;
579580
fkconstraint->deferrable=constrForm->condeferrable;

‎src/backend/commands/tablecmds.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14275,21 +14275,21 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
1427514275
RelationGetRelid(attachrel),&cloned);
1427614276
foreach(l,cloned)
1427714277
{
14278-
ClonedConstraint*cloned=lfirst(l);
14278+
ClonedConstraint*clonedcon=lfirst(l);
1427914279
NewConstraint*newcon;
1428014280
Relationclonedrel;
1428114281
AlteredTableInfo*parttab;
1428214282

14283-
clonedrel=relation_open(cloned->relid,NoLock);
14283+
clonedrel=relation_open(clonedcon->relid,NoLock);
1428414284
parttab=ATGetQueueEntry(wqueue,clonedrel);
1428514285

1428614286
newcon= (NewConstraint*)palloc0(sizeof(NewConstraint));
14287-
newcon->name=cloned->constraint->conname;
14287+
newcon->name=clonedcon->constraint->conname;
1428814288
newcon->contype=CONSTR_FOREIGN;
14289-
newcon->refrelid=cloned->refrelid;
14290-
newcon->refindid=cloned->conindid;
14291-
newcon->conid=cloned->conid;
14292-
newcon->qual= (Node*)cloned->constraint;
14289+
newcon->refrelid=clonedcon->refrelid;
14290+
newcon->refindid=clonedcon->conindid;
14291+
newcon->conid=clonedcon->conid;
14292+
newcon->qual= (Node*)clonedcon->constraint;
1429314293

1429414294
parttab->constraints=lappend(parttab->constraints,newcon);
1429514295

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp