Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbUDw-00045f-IE for pgsql-bugs@arkaria.postgresql.org; Wed, 08 Feb 2017 15:32:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cbUDv-0006bO-Rv for pgsql-bugs@arkaria.postgresql.org; Wed, 08 Feb 2017 15:31:59 +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 1cbUCj-0006Vi-Oa for pgsql-bugs@postgresql.org; Wed, 08 Feb 2017 15:30:45 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cbUCg-0008G4-9c for pgsql-bugs@postgresql.org; Wed, 08 Feb 2017 15:30:45 +0000 Received: by mail-wm0-x243.google.com with SMTP id c85so33808563wmi.1 for ; Wed, 08 Feb 2017 07:30:41 -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=ouyPza+upSEZO8/ZTRIiukEOPw10zmU8BmziHVtra+w=; b=iEn5Pzo1w+OORjhfjgmGBqPfS2iPUupStDoMZ+3PEg2lUYRV15Mm2f9n9CeE1ayIHg 1ykgmfGWYma1Rxo0I4utI48Xq8p9HHsb/2ytv9YTT9NuOnCJa24ZyapCkotcb49S4rg/ lRGpijPWxCetnDj762BT5AcuILhs/QGhBvg1e922kSSr6REd7XGCfGF1agEAewxzu0AS hvKtHXlEivYRTAxnvQSxGJ/z5bHc8OYolLwkiqCGt9rDmhil6AQ0vb+pp4J83uReiWhu Ujj+Vfeq9yw/qLX3c8n40Ns9ZJInVwKb/TQwNzEk/yt5Kq1I8+EWAqsDdQzJDYUGwFjN krHQ== 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=ouyPza+upSEZO8/ZTRIiukEOPw10zmU8BmziHVtra+w=; b=sb2iagKSGkeRWGvm/9WgtpFbGEEVpM5lD2OEhWHiWeKS6jqgsK7fsDac+rlb+xAIPA izVuYMe3ex5KPzAI1wsAxITlTLc3gkNq4+i3CZo2ugBiYu318CbyGFfbCjO30rsDtnGi fuBsMlKd2daXQyqbOrm7KrcMcw8HXu/YNPU++qXkgzWHPYDMUiyDzSDkZ7kRdrantEET i80ZnLPLQFANyPilkMtR4OsyKcb+4XLV3JhHJZnGx3TwwFwNQP0RJxqovnp/6SRc8knE qNWRLWOw5bGPQidBjwZrJnFWmkRxFgaA7y/gcQZCTmzTft4tTvQt42s1NIScQT3Pfhz1 2hgg== X-Gm-Message-State: AMke39nAdqicHudOhGeV4TTDN/+RErnzniw95M64kczxWiY6TQgYt1YMfjEIR0LUzyzKdQ== X-Received: by 10.28.98.2 with SMTP id w2mr19724312wmb.66.1486567840945; Wed, 08 Feb 2017 07:30:40 -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 123sm3921406wml.6.2017.02.08.07.30.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Feb 2017 07:30:40 -0800 (PST) Content-Type: text/plain; charset=utf-8 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: Wed, 8 Feb 2017 15:30:38 +0000 Cc: Tom Lane , pgsql-bugs@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <2205EBF5-5095-4389-9D6B-1469EE60A0AD@gmail.com> References: <20170202140701.1401.31196@wrigleys.postgresql.org> <166D0A9D-162D-4216-9490-3163533166C1@gmail.com> <14575.1486493671@sss.pgh.pa.us> <499844AD-291B-40F5-9892-E5591736FD2E@gmail.com> <22106.1486500247@sss.pgh.pa.us> <31235.1486511840@sss.pgh.pa.us> 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 Hi, again. After some testing, I was able to reproduce this error with the = following code: CREATE TABLE test ( type character varying, id integer ); CREATE UNIQUE INDEX uniq_id_test ON test USING btree (type, id) WHERE (type= =3D 'Test'); PREPARE test (text, int, text) AS INSERT INTO test (type, id) VALUES ($1, $2) ON CONFLICT (type, id) WHERE type =3D $3 DO UPDATE SET id =3D EXCLUDED.id; EXECUTE test('Test', 1, 'Test'); EXECUTE test('Test', 2, 'Test'); EXECUTE test('Test', 3, 'Test'); EXECUTE test('Test', 4, 'Test'); EXECUTE test('Test', 5, 'Test'); EXECUTE test('Test', 6, 'Test=E2=80=99); It gives the error when trying to execute the last statement. > On 8 Feb 2017, at 01:48, Peter Geoghegan wrote: >=20 > On Tue, Feb 7, 2017 at 5:41 PM, Peter Geoghegan wrote: >> It won't work with deferrable constraints (even when immediate >> enforcement is in effect, so obscure reasons). Enforcement occurs in >> the executor -- see ExecCheckIndexConstraints(). >=20 > Note also that it needs to happen in the executor, because > infer_arbiter_indexes() may return immediately when ON CONFLICT DO > NOTHING is used without the user specifying which particular > constraint to use as an arbiter. (This is forbidden with ON CONFLICT > DO UPDATE, since it doesn't make sense to not have an arbiter in mind > there.) >=20 > This is actually noted directly within infer_arbiter_indexes(), about > half way down: >=20 > /* > * Extract info from the relation descriptor for the index. We know > * that this is a target, so get lock type it is known will ultimately > * be required by the executor. > * > * Let executor complain about !indimmediate case directly, because > * enforcement needs to occur there anyway when an inference clause is > * omitted. > */ >=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