pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David G. Johnston <david.g.johnston@gmail.com>
To: Rafal Pietrak <rafal@ztk-rp.eu>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: FK v.s unique indexes
Date: Tue, 3 Jul 2018 15:55:37 -0700
Message-ID: <CAKFQuwZLmmG5p-DDBPu6oeLe2UkbRNps4HKPv3Bc8Moo-Gh16w@mail.gmail.com> (raw)
In-Reply-To: <d9f85c60-3cdd-2504-cc6e-83fee0e19384@ztk-rp.eu>
References: <d9f85c60-3cdd-2504-cc6e-83fee0e19384@ztk-rp.eu>

On Tuesday, July 3, 2018, Rafal Pietrak <rafal@ztk-rp.eu> wrote:

>
> ERROR:  there is no unique constraint matching given keys for referenced
> table "test2"
> ----------------------------
>
> I cannot see any reasons why this functionality is blocked.
>
> In particular, contrary to what the ERROR says, the target table *does
> have* a "unique constraint matching given keys", admittedly only
> partial.
>

You are making the common error of confusing the distinct concepts of
constraints and indexs.  Table constraints cannot be partial by definition,
and are a logical concept constraining the data model.  Indexes are
physical objects that only aid in the execution of queries.  The only
crossover is that the implementation of a unique table constraint uses a
full unique index as an implementation detail.

The error says 'constraint' and indeed you have nit defined a relevant
constraint in your schema, just indexes.

David J.

view thread (14+ messages)  latest in thread

Message-ID: <CAKFQuwZLmmG5p-DDBPu6oeLe2UkbRNps4HKPv3Bc8Moo-Gh16w@mail.gmail.com>
Permalink:  ../CAKFQuwZLmmG5p-DDBPu6oeLe2UkbRNps4HKPv3Bc8Moo-Gh16w@mail.gmail.com/
Also on:    postgresql.org/message-id/CAKFQuwZLmmG5p-DDBPu6oeLe2UkbRNps4HKPv3Bc8Moo-Gh16w@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: david.g.johnston@gmail.com, rafal@ztk-rp.eu
  Subject: Re: FK v.s unique indexes
  In-Reply-To: <CAKFQuwZLmmG5p-DDBPu6oeLe2UkbRNps4HKPv3Bc8Moo-Gh16w@mail.gmail.com>
  References: <d9f85c60-3cdd-2504-cc6e-83fee0e19384@ztk-rp.eu> <CAKFQuwZLmmG5p-DDBPu6oeLe2UkbRNps4HKPv3Bc8Moo-Gh16w@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox