pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: eric@aquameta.com
To: Eric Hanson <elhanson@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: express composite type literal as text
Date: Sun, 22 Feb 2015 14:47:52 -0500
Message-ID: <31376.1424634472@sss.pgh.pa.us> (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>

Eric Hanson <elhanson@gmail.com> writes:
> How do I express a composite type literal as text?

The rules are given in the manual ...

> 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

That message isn't telling you that you've got a problem with the data
syntax, it's telling you that you need to cast the literal to a named
composite data type.  This works:

# select * from on_hand where item='("fuzzy dice",42,1.99)'::inventory_item;
          item          | count 
------------------------+-------
 ("fuzzy dice",42,1.99) |  1000
(1 row)

Now, I'm not too sure *why* it's making you do that --- seems like the
default assumption ought to be that the literal is the same type as
the variable it's being compared to.  Perhaps there's a bug in there,
or perhaps there's no easy way to avoid this requirement.  But that's
what the requirement is today.

			regards, tom lane


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



view thread (9+ messages)  latest in thread

Message-ID: <31376.1424634472@sss.pgh.pa.us>
Permalink:  ../31376.1424634472@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/31376.1424634472@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, eric@aquameta.com, elhanson@gmail.com, pgsql-general@postgresql.org
  Subject: Re: express composite type literal as text
  In-Reply-To: <31376.1424634472@sss.pgh.pa.us>
  References: <CACnWs=Xu-GtcksqVbt4gTMdMM8_4Wfhwno_70JNOPvXSbh9=2g@mail.gmail.com> <31376.1424634472@sss.pgh.pa.us>

* 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