Re: Array comparison - subset - Mailing list pgsql-general

From Michael Fuhr
Subject Re: Array comparison - subset
Date
Msg-id 20060903044809.GA65544@winnie.fuhr.org
Whole thread Raw
In response to Array comparison - subset  ("Christopher Murtagh" <christopher.murtagh@gmail.com>)
Responses Re: Array comparison - subset  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Array comparison - subset  ("Christopher Murtagh" <christopher.murtagh@gmail.com>)
List pgsql-general
On Fri, Sep 01, 2006 at 11:55:32AM -0400, Christopher Murtagh wrote:
> I've got a function that returns and array $foo, and an array $bar.
> Is there an elegant way to test if $bar is a subset of $foo? I've been
> looking through the docs and haven't found anything. Am I missing
> something obvious, or am I out of luck?

In the specific case of integer arrays you could use contrib/intarray.

test=> SELECT ARRAY[1, 2, 3, 4] @ ARRAY[1, 3];
 ?column?
----------
 t
(1 row)

test=> SELECT ARRAY[1, 2, 3, 4] @ ARRAY[1, 5];
 ?column?
----------
 f
(1 row)

In 8.2 the above example will work in the stock installation for
arrays of any type (i.e., with operands of type anyarray).

--
Michael Fuhr

pgsql-general by date:

Previous
From: "Keith Hutchison"
Date:
Subject: Re: Compiling libpqddll.lib win32 mingw msys
Next
From: Tom Lane
Date:
Subject: Re: Array comparison - subset