Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 47E601337B47 for ; Wed, 11 May 2011 14:05:09 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 71876-09 for ; Wed, 11 May 2011 17:05:01 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 4E8541337B69 for ; Wed, 11 May 2011 14:05:00 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p4BH4xpM000571; Wed, 11 May 2011 13:04:59 -0400 (EDT) To: "Skylar Hawk" cc: pgsql-bugs@postgresql.org Subject: Re: BUG #6020: Wrong data type returned after CAST in FROM In-reply-to: <201105102236.p4AMaW5e038211@wwwmaster.postgresql.org> References: <201105102236.p4AMaW5e038211@wwwmaster.postgresql.org> Comments: In-reply-to "Skylar Hawk" message dated "Tue, 10 May 2011 22:36:32 +0000" Date: Wed, 11 May 2011 13:04:59 -0400 Message-ID: <570.1305133499@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/91 X-Sequence-Number: 30230 "Skylar Hawk" writes: > I noticed a strange nuance. When I do a regular select on data that I CAST > as a CHAR(), the data I am returned is of type character() as I would > expect. For example: > SELECT > CAST('abcd' AS CHAR(4)) AS data > This returns 'abcd' where the type is character(4). > However, if I do the cast in the FROM portion of the query such as this: > SELECT > data > FROM > CAST('abcd' AS CHAR(4)) AS data > then I am returned 'abcd' and the type is bpchar. What exactly are you using to identify the type? regards, tom lane