Re: BUG #11554: Enforce that number and type of both columns involved in fkey are same type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: gary(dot)weaver(at)protolabs(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #11554: Enforce that number and type of both columns involved in fkey are same type
Date: 2014-10-02 22:58:28
Message-ID: 5676.1412290708@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

gary(dot)weaver(at)protolabs(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message bryan_seitz 2014-10-03 00:15:04 BUG #11555: Postgresql
Previous Message David G Johnston 2014-10-02 22:56:52 Re: BUG #11477: psql -L no stderr