Re: bitwise again

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: bitwise again
Дата
Msg-id Pine.LNX.4.30.0104021839400.1287-100000@peter.localdomain
обсуждение исходный текст
Ответ на bitwise again  (Alexander Lohse <al@humantouch.de>)
Список pgsql-general
Alexander Lohse writes:

> In MySQL I use following bitwise operation on an INT field:
>
> $q = "select id from my_tbl where aid & 2";
>
> In Postgres I tried the same, but I found no working solution.

Upgrade to 7.1.

> Is it better(or even possible) to use bitwise operator on an int4
> field or shall I prefer the varbit?

If you plan on bit fields larger than 32 bits and/or you need string-like
functions (substring, position), then BIT or BIT VARYING are for you.  If
you plan to use numeric operators (+, sqrt), then use an integer type.

> Using the above as in MySQL, I get an ERROR:
> WHERE clause must return type bool, not type int4

Indeed.  Maybe you meant something like (aid & 2) <> 0.

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/


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

Предыдущее
От: teg@redhat.com (Trond Eivind Glomsrød)
Дата:
Сообщение: Re: Need PostgreSQL startup scripts
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: Need PostgreSQL startup scripts