From: Adrian Klaver <adrian.klaver@gmail.com>
To: zoulx1982 <zoulx1982@163.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: type cast about int to bit
Date: Mon, 6 Feb 2012 19:28:55 -0800
Message-ID: <201202061928.56405.adrian.klaver@gmail.com> (raw)
In-Reply-To: <706e3124.7b69.13555b11cc6.Coremail.zoulx1982@163.com>
References: <201202061719.12213.adrian.klaver@gmail.com>
<18656bf8.13415.13551499b55.Coremail.zoulx1982@163.com>
<706e3124.7b69.13555b11cc6.Coremail.zoulx1982@163.com>
On Monday, February 06, 2012 6:42:45 pm zoulx1982 wrote:
> you mean there is no cast function for int to varchar ?
> i see sure it is.
>
That is why I said my guess:) If you want to see what is actually going on take
a look at:
http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/utils/adt/varbit.c;h=adb0836...
The ERROR though is coming further up, in the parser , if I am following
correctly. This because as you have found out there is no direct cast from
integer to varbit. Why that is for someone else to answer, as I don't know.
Though a little playing around got this, not pretty but it seems to work:
test(5432)aklaver=>SELECT 10::bit(3)::varbit(3);
varbit
--------
010
(1 row)
test(5432)aklaver=>SELECT 10::bit(3)::varbit(4);
varbit
--------
010
(1 row)
test(5432)aklaver=>SELECT 10::bit(4)::varbit(4);
varbit
--------
1010
(1 row)
test(5432)aklaver=>SELECT 10::bit(4)::varbit(3);
varbit
--------
101
--
Adrian Klaver
adrian.klaver@gmail.com
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: adrian.klaver@gmail.com, zoulx1982@163.com
Subject: Re: type cast about int to bit
In-Reply-To: <201202061928.56405.adrian.klaver@gmail.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