Re: Inconsistent ::bit(N) and get_bit()?

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: Inconsistent ::bit(N) and get_bit()?
Дата
Msg-id AANLkTi=Dmc_uCn8jAcj0v4cAArXGhp-VsQsbHe2Lfnyb@mail.gmail.com
обсуждение исходный текст
Ответ на Inconsistent ::bit(N) and get_bit()?  (Boszormenyi Zoltan <zb@cybertec.at>)
Ответы Re: Inconsistent ::bit(N) and get_bit()?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
2010/8/11 Boszormenyi Zoltan <zb@cybertec.at>:
> Shouldn't it at least be documented in more depth? Say, get_bit(, N)
> provides the Nth bit (0-based) counting from the leftmost bit?
> I would certainly appreciate a warning spelled out about this
> so if you convert a number to bitstring of length N and you want the
> Mth bit (according to any programming language) then you need to use
> get_bit(..., N-1-M).

The fact that bit-strings subscript from the left rather than from the
right seems pretty odd to me, but it is documented.  I wouldn't object
to adding a note to somewhere around here, if we can think of a
suitable way to word it:

http://www.postgresql.org/docs/9.0/static/functions-bitstring.html

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


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Regression tests versus the buildfarm environment
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: assertions and constraint triggers