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

Commit46e2a18

Browse files
committed
Fix thinko in construction of old_conpfeqop list.
This should lappend the OIDs, not lcons them; the existing code produceda list in reversed order. This is harmless for single-key FKs or FKswhere all the key columns are of the same type, which probably explainshow it went unnoticed. But if those conditions are not met,ATAddForeignKeyConstraint would make the wrong decision about whether anexisting FK needs to be revalidated. I think it would almost always errin the safe direction by revalidating a constraint that didn't need it.You could imagine scenarios where the pfeqop check was fooled byswapping the types of two FK columns in one ALTER TABLE, but that casewould probably be rejected by other tests, so it might be impossible toget to the worst-case scenario where an FK should be revalidated andisn't. (And even then, it's likely to be fine, unless there are weirdinconsistencies in the equality behavior of the replacement types.)However, this is a performance bug at least.Noted while poking around to see whether lcons calls could be convertedto lappend.This bug is old, dating to commitcb3a7c2, so back-patch to allsupported branches.
1 parentc83067d commit46e2a18

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7697,7 +7697,6 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
76977697
new_castfunc==old_castfunc&&
76987698
(!IsPolymorphicType(pfeqop_right)||
76997699
new_fktype==old_fktype));
7700-
77017700
}
77027701

77037702
pfeqoperators[i]=pfeqop;
@@ -10806,7 +10805,7 @@ TryReuseForeignKey(Oid oldId, Constraint *con)
1080610805

1080710806
/* stash a List of the operator Oids in our Constraint node */
1080810807
for (i=0;i<numkeys;i++)
10809-
con->old_conpfeqop=lcons_oid(rawarr[i],con->old_conpfeqop);
10808+
con->old_conpfeqop=lappend_oid(con->old_conpfeqop,rawarr[i]);
1081010809

1081110810
ReleaseSysCache(tup);
1081210811
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp