On 2021-Nov-01, Tom Lane wrote:
> PG Bug reporting form <noreply@postgresql.org> writes:
> > It is possible to break foreign key referential integrity when the FK
> > columns have different types and updates are cascaded from the parent
> > relation to the child relation.
>
> I'm not really sure what you'd consider such an FK relationship to mean.
> I can't get too excited about it when there doesn't seem to be a well
> defined semantics for it.
Yeah, I was thinking that a possible fix might be to reject the creation
of such an FK, but I'm not sure what would be a good test to determine
acceptability. It's not as easy as rejecting different typmods, in
general: for example, rejecting FKs of varchars because their max
lengths are different would be inappropriate.
For numeric perhaps we could get away with saying that the referencing
column must have a scale that's at least as large as the referenced
column. But I wouldn't want to get in the business of having
type-specific rules for this, because that seems messy and
overcomplicated for little useful gain.
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/