From: Adrian Klaver <adrian.klaver@aklaver.com>
To: eric@aquameta.com
To: pgsql-general@postgresql.org
Subject: Re: express composite type literal as text
Date: Sun, 22 Feb 2015 11:42:32 -0800
Message-ID: <54EA3128.30109@aklaver.com> (raw)
In-Reply-To: <CACnWs=Xu-GtcksqVbt4gTMdMM8_4Wfhwno_70JNOPvXSbh9=2g@mail.gmail.com>
References: <CACnWs=Xu-GtcksqVbt4gTMdMM8_4Wfhwno_70JNOPvXSbh9=2g@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>
On 02/22/2015 10:07 AM, Eric Hanson wrote:
> Hi,
>
> How do I express a composite type literal as text?
>
> I'm trying to use a composite type in a WHERE clause. The examples in
> the docs
>
> http://www.postgresql.org/docs/9.4/static/rowtypes.html
>
> say:
>
> CREATE TYPE complex AS (
> r double precision,
> i double precision
> );
>
> CREATE TYPE inventory_item AS (
> name text,
> supplier_id integer,
> price numeric
> );
>
> CREATE TABLE on_hand (
> item inventory_item,
> count integer
> );
>
> INSERT INTO on_hand VALUES (ROW('fuzzy dice', 42, 1.99), 1000);
>
>
> Now I want to query for that row, specifying the item in the WHERE
> clause. I can't use the ROW() notation, because all values need to be
> represented as text over a REST api. But I can't seem to get the
> text-based syntax to work:
>
> select * from on_hand where item='("fuzzy dice",42,1.99)';
>
> yeilds
>
> ERROR: input of anonymous composite types is not implemented
>
> I've tried various forms of quote escaping and dollar quoting as the
> docs suggest, but they all produce that same error:
>
> select * from on_hand where item='(\\\"fuzzy dice\\\",42,1.99)';
> select * from on_hand where item=$$("fuzzy dice",42,1.99)$$;
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-bugs@postgresql.org
Cc: adrian.klaver@aklaver.com, eric@aquameta.com, pgsql-general@postgresql.org
Subject: Re: express composite type literal as text
In-Reply-To: <54EA3128.30109@aklaver.com>
References: <CACnWs=Xu-GtcksqVbt4gTMdMM8_4Wfhwno_70JNOPvXSbh9=2g@mail.gmail.com> <54EA3128.30109@aklaver.com>
* 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