From: Tom Lane <tgl@sss.pgh.pa.us>
To: George Pavlov <gpavlov@mynewplace.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: DISTINCT with NULLs and INT fields
Date: Wed, 28 Dec 2005 22:03:19 -0500
Message-ID: <3362.1135825399@sss.pgh.pa.us> (raw)
In-Reply-To: <CCB89282FCE1024EA3DCE687A96A5164039EC89C@ehost010-6.exch010.intermedia.net>
References: <CCB89282FCE1024EA3DCE687A96A5164039EC89C@ehost010-6.exch010.intermedia.net>
"George Pavlov" <gpavlov@mynewplace.com> writes:
> the interesting thing here is that 4::int gets into a text
> field whereas 4::text does not get into an integer field. seems to me
> like there is an implicit int-to-text cast (without a symmetrical
> text-to-int one)
Yeah, there is. You can easily see the list of implicit casts for
yourself:
select castsource::regtype, casttarget::regtype from pg_cast
where castcontext = 'i' and castsource != casttarget;
There's 90 of them in current CVS tip, and most of 'em are unsurprising
within-type-category casts, such as implicit promotion of int to bigint.
However we have about a dozen implicit casts to text from the numeric
and datetime type categories. Personally I would dearly love to get
rid of these, because they are accidents waiting to happen (and they
do regularly bite people, see the mail list archives for evidence).
But it seems people expect to be able to do things like
number || ' string'
without explicitly casting the number to text.
regards, tom lane
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: tgl@sss.pgh.pa.us, gpavlov@mynewplace.com
Subject: Re: DISTINCT with NULLs and INT fields
In-Reply-To: <3362.1135825399@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