Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V9Xo3-0005oM-Bj for pgsql-general@arkaria.postgresql.org; Wed, 14 Aug 2013 09:55:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1V9Xo2-0006xk-MY for pgsql-general@arkaria.postgresql.org; Wed, 14 Aug 2013 09:55:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V9Xo1-0006xO-AJ for pgsql-general@postgresql.org; Wed, 14 Aug 2013 09:55:53 +0000 Received: from mail-ee0-x233.google.com ([2a00:1450:4013:c00::233]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V9Xnx-0000OP-Kl for pgsql-general@postgresql.org; Wed, 14 Aug 2013 09:55:52 +0000 Received: by mail-ee0-f51.google.com with SMTP id c1so4717610eek.24 for ; Wed, 14 Aug 2013 02:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=ldJIbT755BXg8vFVFHN0AC/2DduiTaHvXouaR9WFgRY=; b=UunDoaj4zvTizsI2m/l0+TD7DUlhSogg6qcJmlKQ/8j6kj4cXrHBt0hyeDUYyMdexC K3DwcNk7IDgN5/w3YbPrwtbyxD50oDiBwFWL48eOTQeD+Ppk7bYPULTeu0h+BKDueQKQ 3L13byfOonPxi5PtsOXn9vKz7Ukf6H9NMVnpZ3ghv88phAcbm7EAUUTC7s0EFmcQsQqq Dwrd8KdyQvbMN69pUEIGc+nEfKKhBZXz6TGrWaxGSo8/DCSZPn5PyWkBzjBWA2LcmWl+ +dDTeuC2QANLCF4hlxnfyAJk1cXTrm2RPL/PNk9DXSnr0hqHsdCEzirYdA51dwEe4sTs mmYg== X-Received: by 10.14.115.69 with SMTP id d45mr1925322eeh.70.1376474148012; Wed, 14 Aug 2013 02:55:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.14.143.196 with HTTP; Wed, 14 Aug 2013 02:55:07 -0700 (PDT) In-Reply-To: References: From: Pavel Stehule Date: Wed, 14 Aug 2013 11:55:07 +0200 Message-ID: Subject: Re: WHERE 'Something%' LIKE ANY (array_field) To: Tim Kane Cc: PostgreSQL mailing lists Content-Type: multipart/alternative; boundary=001a11c1b402a2b15004e3e55cca X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org --001a11c1b402a2b15004e3e55cca Content-Type: text/plain; charset=UTF-8 Hello http://postgres.cz/wiki/PostgreSQL_SQL_Tricks#LIKE_to_list_of_patterns Regards Pavel Stehule 2013/8/14 Tim Kane > Hi all, > > It seems like it isn't possible to perform a wildcard LIKE evaluation > against array objects. Is this a bug, or just unsupported? > > > See the queries in bold, that I would have expected to return a value. > Postgres 9.1.9 > > > =# create temp table ids (id varchar(12)[]); > CREATE TABLE > Time: 185.516 ms > =# insert into ids values ('{s1,s452334,s89}'); > INSERT 0 1 > Time: 0.728 ms > =# insert into ids values ('{s89}'); > INSERT 0 1 > Time: 0.300 ms > =# insert into ids values ('{s9323,s893}'); > INSERT 0 1 > Time: 0.133 ms > =# insert into ids values ('{s9323,s893,s89}'); > INSERT 0 1 > Time: 0.110 ms > =# select * from ids; > id > ------------------ > {s1,s452334,s89} > {s89} > {s9323,s893} > {s9323,s893,s89} > (4 rows) > > Time: 0.155 ms > =# select * from ids where 's89' = ANY (id); > id > ------------------ > {s1,s452334,s89} > {s89} > {s9323,s893,s89} > (3 rows) > > Time: 0.121 ms > *clone=# select * from ids where 's45%' LIKE ANY (id);* > id > ---- > (0 rows) > > Time: 0.124 ms > > *clone=# select * from ids where 's452334%' LIKE ANY (id);* > id > ---- > (0 rows) > > Time: 0.278 ms > clone=# select * from ids where 's452334' LIKE ANY (id); > id > ------------------ > {s1,s452334,s89} > (1 row) > > Time: 0.134 ms > clone=# select * from ids where 's452334' = ANY (id); > id > ------------------ > {s1,s452334,s89} > (1 row) > --001a11c1b402a2b15004e3e55cca Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


2013/8/14 Tim Kane <tim.kane@gmail.com>
Hi all,

It seems like it isn't possible to perfor= m a wildcard LIKE evaluation against array objects. Is this a bug, or just = unsupported?


See the queries in bold, that I would have expected to return a value.
Postgres 9.1.9


=3D# creat= e temp table ids (id varchar(12)[]);
CREATE T= ABLE
Time: 185.516 ms
=3D# insert into ids values ('{s1,s452334= ,s89}');
INSERT 0 1
Time: 0.728 ms
=3D# insert into ids values ('{s= 89}');
INSERT 0 1
Time: 0.300 ms
=3D# insert into ids values ('{s= 9323,s893}');
INSERT 0= 1
Time: 0.133 ms
=3D# insert into ids values ('{s9323,s893,s= 89}');
INSERT 0= 1
Time: 0.110 ms
=3D# select * from ids;
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 id
------------------
=C2=A0{s1,s452334,s89}
=C2=A0{s= 89}
=C2=A0{s9323,s893}
=C2=A0{s9323,s893,s89}
(4 rows)=

Time: 0.155 ms
=3D# select * from ids where 's89' =3D ANY (id);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 id
--------= ----------
=C2=A0{s1,s452334,s89}
=C2=A0{s89}
=C2=A0{s= 9323,s893,s89}
(3 rows)

Time: 0.121 ms
clone=3D# select * from ids where 's45%&= #39; LIKE ANY (id);
=C2=A0id=
----
(0 rows)

Time: 0.124 ms

clone=3D# select * from ids where 's452334%' LIKE ANY (id);=
=C2=A0id
----
(0 rows)

Time: 0.278 ms
clone=3D# select * from ids where 's452334'= LIKE ANY (id);
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 id
------------------
=C2=A0{s1,s452334,s89}
(1 row)<= /font>

Time: 0.134 ms
clone=3D= # select * from ids where 's452334' =3D ANY (id);
=C2=A0 =C2=A0= =C2=A0 =C2=A0 id
--------= ----------
=C2=A0{s1,s452334,s89}
(1 row)

--001a11c1b402a2b15004e3e55cca--