Re: Determining if an hstore is empty

From: Sergey Konoplev <gray(dot)ru(at)gmail(dot)com>
To: Wells Oliver <wellsoliver(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Determining if an hstore is empty
Date: 2013-02-14 00:44:18
Message-ID: CAL_0b1vDrXFiQtQTfffwSnPoj_K0c+zHQ27=bxnQE9PaxXRHNg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Feb 11, 2013 at 11:36 AM, Wells Oliver <wellsoliver(at)gmail(dot)com> wrote:
> What's the canonical way of doing this? Various failed attempts include:

Just compare an empty hstore with yours.

[local]:5432 grayhemp(at)grayhemp=# select ''::hstore = ''::hstore,
''::hstore = '{a=>1}'::hstore;
?column? | ?column?
----------+----------
t | f
(1 row)

>
> select array_length(%%'a=>1'::hstore - 'a=>1'::hstore, 1)
>
> select array_length(%%('a=>1'::hstore - 'a=>1'::hstore), 1)
>
> select array_length(avals('a=>1'::hstore - 'a=>1'::hstore), 1);
>
> select array_length(akeys('a=>1'::hstore - 'a=>1'::hstore), 1);
>
> select skeys('a=>1'::hstore - 'a=>1'::hstore) is null
>
> select 'a=>1'::hstore - 'a=>1'::hstore is null
>
> Etc.
>
> --
> Wells Oliver
> wellsoliver(at)gmail(dot)com

--
Sergey Konoplev
Database and Software Architect
http://www.linkedin.com/in/grayhemp

Phones:
USA +1 415 867 9984
Russia, Moscow +7 901 903 0499
Russia, Krasnodar +7 988 888 1979

Skype: gray-hemp
Jabber: gray(dot)ru(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2013-02-14 01:01:06 trying to use CLUSTER
Previous Message Sergey Konoplev 2013-02-14 00:21:12 Re: Failing backups, canceling statement due to conflict with recovery