From: Dean Gibson (DB Administrator) <postgresql@ultimeth.com>
To: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: FUNCTIONs and CASTs
Date: Fri, 15 Feb 2008 16:45:58 -0800
Message-ID: <47B63246.9070104@ultimeth.com> (raw)
In-Reply-To: <47B61A26.4060806@ultimeth.com>
References: <47B4C9E4.8090002@ultimeth.com>
<20670.1203031191@sss.pgh.pa.us>
<47B4EF3E.4090608@ultimeth.com>
<47B55DA1.1060706@archonet.com>
<47B5D790.4090509@ultimeth.com>
<655.1203114745@sss.pgh.pa.us>
<47B61A26.4060806@ultimeth.com>
On 2008-02-15 15:03, Dean Gibson (DB Administrator) wrote:
> On 2008-02-15 14:32, Tom Lane wrote:
>
> Casing a TEXT item to a CHAR( 9 ) item isn't a no-op. I've seen this
> before in "EXPLAIN ..." output, where a search on an indexed column
> will be sequential because the planner treats the search value as TEXT
> rather than CHAR( 9 ).
>
> Are you saying that no one believes there is a performance
> difference? Amazing ...
>
> Tom, I've privately eMailed you access instructions to one of my DB
> servers, so you can see for yourself.
>
OK, it must have been late at 2am when I last ran the tests, as it now
seems to work. By "work", I mean that the casting in the function body
is (in the particular case I was having an issue with) apparently
unnecessary if the types are proper (which includes the
table.column%TYPE notation).
I'm happy to find that out, since now I can use the table.column%TYPE
notation to advantage.
What helped confuse me is that the following function apparently DOES
need an internal cast:
CREATE OR REPLACE FUNCTION zzz( aaa CHAR(1) ) RETURNS CHAR(1) LANGUAGE
SQL AS 'SELECT $1';
SELECT zzz( 'abc' );
returns "abc", not "a". Apparently declarations of CHAR(n) are treated
as BPCHAR in function prototypes???
-- Dean
--
Mail to my list address MUST be sent via the mailing list.
All other mail to my list address will bounce.
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: postgresql@ultimeth.com
Subject: Re: FUNCTIONs and CASTs
In-Reply-To: <47B63246.9070104@ultimeth.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