Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1faUD2-00028P-UJ for pgsql-general@arkaria.postgresql.org; Tue, 03 Jul 2018 22:55:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1faUD0-0004BW-Vk for pgsql-general@arkaria.postgresql.org; Tue, 03 Jul 2018 22:55:42 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1faUD0-0004BP-IF for pgsql-general@lists.postgresql.org; Tue, 03 Jul 2018 22:55:42 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1faUCy-00053J-2Q for pgsql-general@lists.postgresql.org; Tue, 03 Jul 2018 22:55:41 +0000 Received: by mail-ed1-x541.google.com with SMTP id g12-v6so2685484edi.9 for ; Tue, 03 Jul 2018 15:55:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=WYZPdVyTIxwrN8jiYWanOInI+XYCqtCWLdA/MtZfTgE=; b=YItNBxiMjMYAQsNFNP/u1tQTwokvADsZzqhYauuSb3rDS7P9EcWikix6+Oq0RSTHza bWn6spQ5EK+YFiXICxQ8FKzx+hGu+1SsUnatAcExr9ZN7JXVRnNjdTrWinLXC7M8sV3O ET1v4oaikVMOCSdSNX3CqQvXL3G6iDigIDohGgoAmMjBpn/a3Uuhn1fM/lT+9TbLZQja +FYId6DfIlpj6Gw34jU2uZqdNaM3P4+pX6CrSgwe0vPRMLu6OREALYIuyzZZn8vWBhSp N34IBcLMuYOV/rph5ib52/CHL4bkvG94EfXtkD3mjkEmAm4qkQdNxmYPPL3u5Qr0Qz1h h0CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=WYZPdVyTIxwrN8jiYWanOInI+XYCqtCWLdA/MtZfTgE=; b=CS709rZ6h3OOAFCslD4j5Qa51X7RBrWOBfNHc+UZpws3eVpLuI6X067PL++zhLc5NP rpnDW7Edh5lT3C+TDfutqCekgw7xUkkPrv2O3Mg2evefhxfClz1q8jEQae05SFLHPT+X Dy2ZlE+QD0vgpvIYfO/jt2kCq3geZoWfq6L2zgmXgdJ6WsuGKYHCqgjAd6f/vJkXKFH7 ihQ99GR4CcjVTilo2rG0v1iUSIJ6BkoOHP1Xc9cRiiL0oHi6s0dAiq2fzyvTzRLuY1Mr 4kZgFV78zRFxgOVVPquLm0Y8rt90xe80+34vEDMxMNEsVXbBxWyePMysKEsCCT7RGMW0 VKPQ== X-Gm-Message-State: APt69E1Enis9pE1cU8hWVUxrs1r7tZjt2wpCvsM8suChDNFQQ1oCOA02 Bk1w+9kOdJbAAZ0UshPo9txOKF9HkCNbEyHDcPZZ3g== X-Google-Smtp-Source: AAOMgpeNhS+hE843HSeIAsnoTzhTJhCUSMG1u6IN1uesU5R9WhLjHlIw/8axMviWIkX8zL3itID9M6aa92A85U8hreI= X-Received: by 2002:a50:d01a:: with SMTP id j26-v6mr34751edf.15.1530658538390; Tue, 03 Jul 2018 15:55:38 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:aa7:c156:0:0:0:0:0 with HTTP; Tue, 3 Jul 2018 15:55:37 -0700 (PDT) In-Reply-To: References: From: "David G. Johnston" Date: Tue, 3 Jul 2018 15:55:37 -0700 Message-ID: Subject: Re: FK v.s unique indexes To: Rafal Pietrak Cc: "pgsql-general@lists.postgresql.org" Content-Type: multipart/alternative; boundary="00000000000074096a05702036eb" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --00000000000074096a05702036eb Content-Type: text/plain; charset="UTF-8" On Tuesday, July 3, 2018, Rafal Pietrak 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. --00000000000074096a05702036eb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tuesday, July 3, 2018, Rafal Pietrak <rafal@ztk-rp.eu> wrote:

ERROR:=C2=A0 there is no unique constraint matching given keys for referenc= ed
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<= br> partial.

You are making the common error of confusi= ng the distinct concepts of constraints and indexs.=C2=A0 Table constraints= cannot be partial by definition, and are a logical concept constraining th= e data model.=C2=A0 Indexes are physical objects that only aid in the execu= tion of queries.=C2=A0 The only crossover is that the implementation of a u= nique table constraint uses a full unique index as an implementation detail= .

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

David J.

--00000000000074096a05702036eb--