Re: type cast about int to bit

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: type cast about int to bit
Дата
Msg-id 201202061928.56405.adrian.klaver@gmail.com
обсуждение исходный текст
Ответ на type cast about int to bit  (zoulx1982 <zoulx1982@163.com>)
Список pgsql-sql
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=adb08369ed28ab6b52aa2cd5213bcd5b4d8de7ad;hb=HEAD

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


В списке pgsql-sql по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: type cast about int to bit
Следующее
От: rverghese
Дата:
Сообщение: Concurrent Reindex on Primary Key for large table