Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbA3a-00079d-1m for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Feb 2017 17:59:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cbA3Z-0005Iz-Fn for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Feb 2017 17:59:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cb9WX-0001WY-Uc for pgsql-bugs@postgresql.org; Tue, 07 Feb 2017 17:25:49 +0000 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cb9WU-0007i8-Ih for pgsql-bugs@postgresql.org; Tue, 07 Feb 2017 17:25:49 +0000 Received: by mail-wm0-x22b.google.com with SMTP id v77so164437347wmv.0 for ; Tue, 07 Feb 2017 09:25:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=Yjj1GKb4D18hZDOsviYmJ6K1JWoKE89bMcmPgCRapKM=; b=cUJqUoivXIqJ5rR17i/4f5+3i4Vfz3qMw11bWI293sTV9KTuup/UqGibZ/1Etc190K eac0ZCuq5Ak+KrAL1UQ04BpNUmsx4gj8jwpH8Pz9H99JIRiUlrk3KhsIOn3V26RwSAl7 h3Q/YSo227xZobj/twDKVpRRtFw411bExhWuKXXl1dyWXyxgv2i3vCddF23GO1CnHS3H o1p2MJt8dluemfrzC81br66EkElQfe77xGRok/ODcxYT0ZclF8d5woRZxXObP07RRZy7 e4IqAgokUHdQTzruDLFtN4C2/TgaQJBlXnq4IVG+ErUqSgm9HWueT8aukixv9MWYywj8 OIEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=Yjj1GKb4D18hZDOsviYmJ6K1JWoKE89bMcmPgCRapKM=; b=FM4rKlCoPxPhAgw3UzXBkPdCiDxaH1qJ2brIlkhwArNbHk0DfdrPSSuwpKxQMyEhoz Ow6Y31q2Va4ngOzppVQyzzXx5xfkV419EBl/opdWn6DwRY3ojOGwk0SGnSHkfCD0BeRD g7zX+86twDTMDaRHHGIEHjeVsLuI8mjFXGX4Oc39Fjo6+pGTDdgnHFZogL7xZW4KXMLX Z2MXeTh8elzqn8/bIN/ZGlRC90AOS7BfyK6PNPr0EdP+tlFp1mts8YY59A5/T+KbBnms iEjtiz+3O1Gqah/j8weZUlW20iTJbg04fUqkrbIGjNL8bGfBM3Iz7XccB817maadC6Ua Y4Uw== X-Gm-Message-State: AMke39kN+B1Fne9m00ChKo8cJOY1UX8MmAN2hDzeZZkXzkvZvKBKL3XByjpWEeCG4Q3zeA== X-Received: by 10.28.55.199 with SMTP id e190mr13093193wma.92.1486488344991; Tue, 07 Feb 2017 09:25:44 -0800 (PST) Received: from [192.168.1.126] (130.237.60.94.rev.vodafone.pt. [94.60.237.130]) by smtp.gmail.com with ESMTPSA id e74sm19885940wmd.2.2017.02.07.09.25.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Feb 2017 09:25:44 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 10.2 \(3259\)) Subject: Re: BUG #14526: no unique or exclusion constraint matching the ON CONFLICT From: Tiago Babo In-Reply-To: Date: Tue, 7 Feb 2017 17:25:43 +0000 Cc: pgsql-bugs@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <166D0A9D-162D-4216-9490-3163533166C1@gmail.com> References: <20170202140701.1401.31196@wrigleys.postgresql.org> To: Peter Geoghegan X-Mailer: Apple Mail (2.3259) X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Here it goes: Table "p= ublic.accounts" Column | Type | = Modifiers | Storage | Stats target | Des= cription ----------------------------------+-----------------------------+----------= ---------------------------------------------+----------+--------------+---= ---------- id | integer | not null d= efault nextval('accounts_id_seq'::regclass) | plain | | type | character varying | = | extended | | identifier | character varying | = | extended | | person_id | integer | = | plain | | business_id | integer | = | plain | | Indexes: "accounts_pkey" PRIMARY KEY, btree (id) "index_accounts_on_type_and_identifier" UNIQUE, btree (type, identifier) "uniq_bank_accounts" UNIQUE, btree (type, identifier) WHERE type::text = =3D 'BankAccount'::text "uniq_business_accounts" UNIQUE, btree (type, business_id) WHERE type::t= ext =3D 'BusinessAccount'::text "uniq_person_accounts" UNIQUE, btree (person_id) WHERE type::text =3D 'P= ersonAccount'::text "index_accounts_on_business_id" btree (business_id) "index_accounts_on_person_id" btree (person_id) Foreign-key constraints: "fk_rails_156241f05a" FOREIGN KEY (business_id) REFERENCES businesses(id) "fk_rails_777d10a224" FOREIGN KEY (person_id) REFERENCES persons(id) > On 7 Feb 2017, at 09:03, Peter Geoghegan wrote: >=20 > On Thu, Feb 2, 2017 at 6:07 AM, wrote: >> INSERT INTO accounts (type, person_id) VALUES ('PersonAccount', 1) ON >> CONFLICT (type, person_id) WHERE type =3D 'PersonAccount' DO UPDATE SET >> updated_at =3D EXCLUDED.updated_at RETURNING * >>=20 >> I also have an unique INDEX: >>=20 >> CREATE UNIQUE INDEX uniq_person_accounts ON accounts USING btree (type, >> person_id) WHERE ((type)::text =3D 'PersonAccount'::text); >=20 > Can you show the table definition? From psql, "\d+ accounts" >=20 >=20 > --=20 > Peter Geoghegan --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs