pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexey Dokuchaev <danfe@nsu.ru>
To: Thomas Kellerer <spam_eater@gmx.net>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Catching unique_violation exception on specific column/index
Date: Tue, 12 Jun 2018 01:21:00 +0700
Message-ID: <20180611182059.GA60559@regency.nsu.ru> (raw)
In-Reply-To: <6ccb6712-33bb-2f42-c16f-378a337160b6@gmx.net>
References: <20180611101033.GA40332@regency.nsu.ru>
	<0fa3bd50-3ce2-2038-29da-48fa0a1f6b19@gmx.net>
	<20180611105834.GA47390@regency.nsu.ru>
	<6ccb6712-33bb-2f42-c16f-378a337160b6@gmx.net>

On Mon, Jun 11, 2018 at 01:26:16PM +0200, Thomas Kellerer wrote:
> If that functionality is an important part of your code, you should
> consider upgrading to 10 (or 9.6 if your are really conservative)
> rather sooner than later.

Oh well, fair enough.  As much as I'd love to stick to the lowest
supported (and sometimes even unsupported) versions, ON CONFLICT is
indeed very handy, esp. since I have a few UPSERT's implemented the
old way already (via catching the "unique_violation" exception).

Shall I update to 9.6/10, I have a bit off-topic (to the original
subject) question: right now, when I need to get the length of an
array (never multidimensional), I do this:

    coalesce(array_length(foo, 1), 0);

In 9.4+, I can call cardinality().  I'm a bit hesitant: is doing so
semantically correct, or should I still do coalesce(..., 0) in this
case?  This is not about the outcome, it's whether cardinality() is
semantically correct to obtain the number of the array items, or it
was introduced for other means?

./danfe




view thread (8+ messages)  latest in thread

Message-ID: <20180611182059.GA60559@regency.nsu.ru>
Permalink:  ../20180611182059.GA60559@regency.nsu.ru/
Also on:    postgresql.org/message-id/20180611182059.GA60559@regency.nsu.ru

 · 

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: danfe@nsu.ru, spam_eater@gmx.net
  Subject: Re: Catching unique_violation exception on specific column/index
  In-Reply-To: <20180611182059.GA60559@regency.nsu.ru>
  References: <20180611101033.GA40332@regency.nsu.ru> <0fa3bd50-3ce2-2038-29da-48fa0a1f6b19@gmx.net> <20180611105834.GA47390@regency.nsu.ru> <6ccb6712-33bb-2f42-c16f-378a337160b6@gmx.net> <20180611182059.GA60559@regency.nsu.ru>

* 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