Re: about type cast

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: zoulx1982 <zoulx1982(at)163(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: about type cast
Date: 2012-02-06 16:57:30
Message-ID: CA+Tgmobk4TAguq_-sViN-pcbsnaN2Rxuy3C2Gz8ivUS7vDM+Tg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2012/2/6 zoulx1982 <zoulx1982(at)163(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-02-06 17:08:01 Re: about type cast
Previous Message Marko Kreen 2012-02-06 16:50:44 Re: ecpglib use PQconnectdbParams