Re: about type cast

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: about type cast
Дата
Msg-id CA+Tgmobk4TAguq_-sViN-pcbsnaN2Rxuy3C2Gz8ivUS7vDM+Tg@mail.gmail.com
обсуждение исходный текст
Ответ на about type cast  (zoulx1982 <zoulx1982@163.com>)
Ответы Re: about type cast  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
2012/2/6 zoulx1982 <zoulx1982@163.com>:
> hi,
> there is a problem about type cast that i don't understand, follow is my
> test.
>
> postgres=# select 10::bit(3);
>  bit
> -----
>  010
> (1 row)
> postgres=# select 10::bit varying(3);
> ERROR:  cannot cast type integer to bit varying
> LINE 1: select 10::bit varying(3);
>                  ^
> postgres=#
>
> my question is why int can cast to bit , but bot for bit varying?
> i want to know the reason.
> thank you for your timing.

Off the top of my head, I'm guessing that it's just a case of nobody
having implemented it.  You can do this:

rhaas=# select 10::bit(3)::varbit;varbit
--------010
(1 row)

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


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

Предыдущее
От: Marko Kreen
Дата:
Сообщение: Re: ecpglib use PQconnectdbParams
Следующее
От: Tom Lane
Дата:
Сообщение: Re: about type cast