function bit(integer)

Started by Samer Abukhaitalmost 21 years ago5 messagesgeneral
Jump to latest
#1Samer Abukhait
abukhait@gmail.com

whats the story of the function bit?
was it out there some previous versions and got removed lately??

My 8.0.2 PG hasn't this function, if i found this function any where
in previous code, shall i replace it with INT::bit(32) ??

#2Michael Fuhr
mike@fuhr.org
In reply to: Samer Abukhait (#1)
Re: function bit(integer)

On Sun, May 15, 2005 at 01:30:05PM +0200, Samer Abukhait wrote:

whats the story of the function bit?
was it out there some previous versions and got removed lately??

My 8.0.2 PG hasn't this function, if i found this function any where
in previous code, shall i replace it with INT::bit(32) ??

I don't see the bit() function in the 8.0.3 documentation, so you
might want to stick with documented functionality. In any case,
it looks like the signature has changed. Here's what 8.0.3 has:

test=> \df bit
List of functions
Schema | Name | Result data type | Argument data types
------------+------+------------------+-----------------------
pg_catalog | bit | bit | bigint, integer
pg_catalog | bit | bit | bit, integer, boolean
pg_catalog | bit | bit | integer, integer
(3 rows)

Here's what 7.4.8 has:

test=> \df bit
List of functions
Schema | Name | Result data type | Argument data types
------------+------+------------------+-----------------------
pg_catalog | bit | bit | bigint
pg_catalog | bit | bit | bit, integer, boolean
pg_catalog | bit | bit | integer
(3 rows)

See also the 8.0 Release Notes to see how casting to bit(n) has
changed.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Michael Fuhr (#2)
Re: function bit(integer)

Michael Fuhr <mike@fuhr.org> writes:

On Sun, May 15, 2005 at 01:30:05PM +0200, Samer Abukhait wrote:

whats the story of the function bit?

I don't see the bit() function in the 8.0.3 documentation, so you
might want to stick with documented functionality.

bit(n) is a type name, not a function call, and always has been AFAIR.
The functions Michael lists are intended to be invoked via casts, not
directly as functions.

What is it you're trying to do exactly?

regards, tom lane

#4Samer Abukhait
abukhait@gmail.com
In reply to: Tom Lane (#3)
Re: function bit(integer)

I have some code that uses this "type name" and the 8.0.3 is not recognizing it

-- Executing query:
select "bit"(1);

ERROR: function bit(integer) does not exist
HINT: No function matches the given name and argument types. You may
need to add explicit type casts.

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Samer Abukhait (#4)
Re: function bit(integer)

Samer Abukhait <abukhait@gmail.com> writes:

select "bit"(1);
ERROR: function bit(integer) does not exist

Try
select 1::bit(32);
or if you prefer
select cast(1 as bit(32));

What you have above is essentially a direct invocation of the int-to-bit
cast function; which you can do if you like, but it's deprecated for
precisely the reason that we don't promise it'll remain stable.

regards, tom lane