Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YPcVV-0007Uf-6I for pgsql-general@arkaria.postgresql.org; Sun, 22 Feb 2015 19:48:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YPcVU-0006Bl-LS for pgsql-general@arkaria.postgresql.org; Sun, 22 Feb 2015 19:48:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YPcVT-0006Bf-ME for pgsql-general@postgresql.org; Sun, 22 Feb 2015 19:47:59 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YPcVQ-00044F-D8 for pgsql-general@postgresql.org; Sun, 22 Feb 2015 19:47:58 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t1MJlq7B031377; Sun, 22 Feb 2015 14:47:52 -0500 From: Tom Lane To: eric@aquameta.com, Eric Hanson cc: pgsql-general@postgresql.org Subject: Re: express composite type literal as text In-reply-to: References: Comments: In-reply-to Eric Hanson message dated "Sun, 22 Feb 2015 10:07:52 -0800" Date: Sun, 22 Feb 2015 14:47:52 -0500 Message-ID: <31376.1424634472@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) 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 Eric Hanson 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