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 1fSKDp-0007Kf-4x for pgsql-general@arkaria.postgresql.org; Mon, 11 Jun 2018 10:38:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fSKDn-0007Qh-RP for pgsql-general@arkaria.postgresql.org; Mon, 11 Jun 2018 10:38:47 +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 1fSKDn-0007QX-FU for pgsql-general@lists.postgresql.org; Mon, 11 Jun 2018 10:38:47 +0000 Received: from mx.nsu.ru ([84.237.50.39]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fSKDk-0005Ur-SY for pgsql-general@lists.postgresql.org; Mon, 11 Jun 2018 10:38:46 +0000 Received: from Debian-exim by mx.nsu.ru with local (Exim 4.72) (envelope-from ) id 1fSKDh-0000cE-BE for pgsql-general@lists.postgresql.org; Mon, 11 Jun 2018 17:38:41 +0700 Received: from [84.237.50.47] (helo=regency.nsu.ru) by mx.nsu.ru with esmtp (Exim 4.72) (envelope-from ) id 1fSKDh-0000Zn-8f; Mon, 11 Jun 2018 17:38:41 +0700 Received: from regency.nsu.ru (localhost [127.0.0.1]) by regency.nsu.ru (8.14.2/8.14.2) with ESMTP id w5BAwewJ048538; Mon, 11 Jun 2018 16:58:40 +0600 (NOVT) (envelope-from danfe@regency.nsu.ru) Received: (from danfe@localhost) by regency.nsu.ru (8.14.2/8.14.2/Submit) id w5BAwYbT048454; Mon, 11 Jun 2018 17:58:34 +0700 (+07) (envelope-from danfe) Date: Mon, 11 Jun 2018 17:58:34 +0700 From: Alexey Dokuchaev To: Thomas Kellerer Cc: pgsql-general@lists.postgresql.org Subject: Re: Catching unique_violation exception on specific column/index Message-ID: <20180611105834.GA47390@regency.nsu.ru> References: <20180611101033.GA40332@regency.nsu.ru> <0fa3bd50-3ce2-2038-29da-48fa0a1f6b19@gmx.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0fa3bd50-3ce2-2038-29da-48fa0a1f6b19@gmx.net> User-Agent: Mutt/1.4.2.1i X-KLMS-Rule-ID: 3 X-KLMS-Message-Action: skipped X-KLMS-AntiSpam-Status: not scanned, whitelist X-KLMS-AntiPhishing: not scanned, whitelist X-KLMS-AntiVirus: Kaspersky Security 8.0 for Linux Mail Server, version 8.0.1.705, not scanned, whitelist List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Jun 11, 2018 at 12:30:13PM +0200, Thomas Kellerer wrote: > Alexey Dokuchaev schrieb am 11.06.2018 um 12:10: > > I have a table with several UNIQUE and CHECK constraints. One of these > > UNIQUE constraints actually *can* be violated -- not on the table level, > > of course, but on the application level -- meaning, if the entry with > > particular foo_key is already in there, do not throw an exception, just > > silently do nothing. > > What's wrong with: > > INSERT ... > ON CONFLICT (foo_key) DO NOTHING Nothing I guess, except that it is available since 9.5 (right?), and I try to stay compatible with 9.3. Sorry for not saying this in the first place. ./danfe