Re: BUG #11554: Enforce that number and type of both columns involved in fkey are same type - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #11554: Enforce that number and type of both columns involved in fkey are same type
Date
Msg-id 5676.1412290708@sss.pgh.pa.us
Whole thread Raw
In response to BUG #11554: Enforce that number and type of both columns involved in fkey are same type  (gary.weaver@protolabs.com)
Responses Re: BUG #11554: Enforce that number and type of both columns involved in fkey are same type  (Gary Weaver <gary.weaver@protolabs.com>)
List pgsql-bugs
gary.weaver@protolabs.com writes:
> To help adhere to the statement, "Of course, the number and type of the
> constrained columns need to match the number and type of the referenced
> columns." as noted in
> http://www.postgresql.org/docs/9.3/static/ddl-constraints.html shouldn't PG
> enforce that both columns involved in a foreign key constraint are of the
> same number and type (e.g. int != bigint) at time of constraint creation?

No.  SQL92 did say that, but in SQL99 and later, the requirement is only
that the column types be comparable.  Which is what PG enforces.

> The problem is that if you are forced to use a tool that syncs data between
> databases of different types, other databases sometimes enforce that the
> types cannot be different. While this is not a frequent use case, it just
> makes sense in most cases that you'd want the two column types/sizes to be
> the same.

It would be more productive to lobby those other systems to become more
standards-compliant than to ask us to become less so.

In any case, this hardly seems like it would be the dominant problem
if you're trying to make schemas be exactly the same across multiple
products :-(.

            regards, tom lane

pgsql-bugs by date:

Previous
From: David G Johnston
Date:
Subject: Re: BUG #11477: psql -L no stderr
Next
From: Bruce Momjian
Date:
Subject: Re: BUG #11550: Error messages contain not encodable characters (Latin9)