Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YPcQL-0007Iz-OH for pgsql-general@arkaria.postgresql.org; Sun, 22 Feb 2015 19:42:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YPcQL-0003V3-77 for pgsql-general@arkaria.postgresql.org; Sun, 22 Feb 2015 19:42:41 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YPcQJ-0003Ue-QF for pgsql-general@postgresql.org; Sun, 22 Feb 2015 19:42:40 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YPcQG-0003d5-9y for pgsql-general@postgresql.org; Sun, 22 Feb 2015 19:42:38 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 9ACEA204DC for ; Sun, 22 Feb 2015 14:42:33 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute2.internal (MEProxy); Sun, 22 Feb 2015 14:42:34 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=aklaver.com; h= x-sasl-enc:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; s=mesmtp; bh=mJRxhY5W1VUpsZDQpzjdWvoQnPg=; b=Z1ZC5AI/G0sq/FpDzT rBgbUas086/tfWs10TEZqIVxtOfATkF0mtxahfPqJcHqtNr2jRRYxL2//WBbkF6w R1k+P6/6nyz9FUdxb0nJSidLTgrjh6SNH/dMkxP4Lf5o4omcBP04qbUf2I1gssYF FRIoyPGw/Go4arDYab0A4hQBs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:message-id:date:from :mime-version:to:subject:references:in-reply-to:content-type :content-transfer-encoding; s=smtpout; bh=mJRxhY5W1VUpsZDQpzjdWv oQnPg=; b=m2QJVYiBXXsBdGErlCfQMekaez7QbN5Q4Ng5mf1hIpKdlBeh9oczOI nAak479VxaGD96VLnbByhClayO2DlKSE0xqWHi2yguwUj4qIeKhYqDNrPmG4Ucbh 60M8wVSjPZLmdaebvAM7zr2G7rdciLnVkU/g4+xGRRzxzxdvCfXsA= X-Sasl-enc: IGbXe4HAbS9O9cnAc5zKD95V5eGmyNNkEySBru2FqrNr 1424634154 Received: from [192.168.1.4] (unknown [174.21.191.40]) by mail.messagingengine.com (Postfix) with ESMTPA id C77EFC0028C; Sun, 22 Feb 2015 14:42:33 -0500 (EST) Message-ID: <54EA3128.30109@aklaver.com> Date: Sun, 22 Feb 2015 11:42:32 -0800 From: Adrian Klaver User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: eric@aquameta.com, pgsql-general@postgresql.org Subject: Re: express composite type literal as text References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) 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 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)$$;