Обсуждение: Changes in functions bittoint4 and bitfromint4 - Function bit does not work

Поиск
Список
Период
Сортировка

Changes in functions bittoint4 and bitfromint4 - Function bit does not work

От
Kenji Sugita
Дата:
Functions bittoint4 and bitfromint4 are renamed to int4 and bit respectively.
Int4 works well, but bit conflicts with type bit.

    =# select int4(B'111');
     int4
    ------
        7
    (1 row)

    =# select bit(7);
    ERROR:  parser: parse error at or near ";" at character 14
    =#

Following trial change of bki enables 'bit' function.

    insert OID = 1683 ( bitx 11 1 12 f f t f i 1 1560 "23" bitfromint4 - _null_ )


    =# select bitx(7);
           bitx
    ----------------------------------
     00000000000000000000000000000111
    (1 row)

    =#


Kenji Sugita

Re: Changes in functions bittoint4 and bitfromint4 - Function bit does not work

От
Tom Lane
Дата:
Kenji Sugita <sugita@srapc1327.sra.co.jp> writes:
> Functions bittoint4 and bitfromint4 are renamed to int4 and bit respectively.
> Int4 works well, but bit conflicts with type bit.

Spell it with quotes, or use cast syntax.

regression=# select "bit"(44);
               bit
----------------------------------
 00000000000000000000000000101100
(1 row)

regression=# select 44::bit(32);
               bit
----------------------------------
 00000000000000000000000000101100
(1 row)

This is not different from the situation with casts to numeric,
timestamp, interval, char, etc: if you want to use the function syntax
then you need quotes.

> [proposes]
>     =# select bitx(7);

We aren't going to use a name that doesn't follow the standard
convention for conversion functions.  As I recall, these two functions
already caused some trouble because they weren't named per convention
before 7.3 --- that caused Peter to miss them when looking for entries
to make in pg_cast.

            regards, tom lane