Re: WHERE col = ANY($1) extended to 2 or more columns? - Mailing list pgsql-general

From Alban Hertroys
Subject Re: WHERE col = ANY($1) extended to 2 or more columns?
Date
Msg-id 024441B3-5505-42FB-A665-8DE93B54A1C7@gmail.com
Whole thread Raw
In response to WHERE col = ANY($1) extended to 2 or more columns?  (Dominique Devienne <ddevienne@gmail.com>)
Responses Re: WHERE col = ANY($1) extended to 2 or more columns?  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
> On 9 Feb 2023, at 16:41, Dominique Devienne <ddevienne@gmail.com> wrote:
>
> Hi. We are implementing an API which takes a list of row keys, and must return info about those rows. To implement
thatefficiently, in as few round-trips as possible, we bind a (binary) array of keys (ints, uuids, or strings) and that
worksgreat, but only if the key is a scalar one. 
>
> Now we'd like to do the same for composite keys, and I don't know how to do that.
> Is it possible? Could someone please help out or demo such a thing?
> We are doing it in C++ using libpq, but a pure SQL or PL/pgSQL demo would still help (I think).

This works:

=> select (1, 'one'::text) in ((1, 'two'::text), (2, 'one'::text), (1, 'one'::text), (2, 'two'::text));
 ?column?
----------
 t
(1 row)

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.




pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: WHERE col = ANY($1) extended to 2 or more columns?
Next
From: "David G. Johnston"
Date:
Subject: Re: WHERE col = ANY($1) extended to 2 or more columns?