Re: bit strings - anyone working on them?
От | Tom Lane |
---|---|
Тема | Re: bit strings - anyone working on them? |
Дата | |
Msg-id | 3499.1051027684@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: bit strings - anyone working on them? (Philip Warner <pjw@rhyme.com.au>) |
Ответы |
Re: bit strings - anyone working on them?
|
Список | pgsql-hackers |
Philip Warner <pjw@rhyme.com.au> writes: > At least in 7.3.2 we can't cast int to varbit. Worse still (and maybe I am > missing something): > # select cast(8 as bit(10)); > bit > ------------ > 0000000000 Not sure we have a lot of choice there. The basic cast is to bit(32). We have regression=# select cast(8 as bit(32)); bit ----------------------------------00000000000000000000000000001000 (1 row) regression=# select cast(8 as bit(32)) :: bit(10); bit ------------0000000000 (1 row) If you make the direct cast do something different, it'll be inconsistent. What is perhaps needed is a bitstring length adjustment operation that allows padding or truncation to occur at the left instead of the right. The semantics of cast are already spoken for, but we could provide this as a function. As for int->varbit, you can get there easily enough: regression=# select cast(8 as bit(32)) :: varbit; varbit ----------------------------------00000000000000000000000000001000 (1 row) regards, tom lane
В списке pgsql-hackers по дате отправления: