BUG #4277: Feature request inet type cast numeric values

Started by PG Bug reporting formalmost 18 years ago3 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following bug has been logged online:

Bug reference: 4277
Logged by: x
Email address: noreply@postgresql.org
PostgreSQL version: n/a
Operating system: n/a
Description: Feature request inet type cast numeric values
Details:

SELECT inet 2130706433;

Should return:
?column?
--------
127.0.0.1

This would emulate the functionality:
CREATE OR REPLACE FUNCTION inet_ntoa(bigint) RETURNS text AS '
SELECT (($1>>24) & 255::int8) || ''.'' ||
(($1>>16) & 255::int8) || ''.'' ||
(($1>>8) & 255::int8) || ''.'' ||
($1 & 255::int8) as result
'
LANGUAGE 'SQL';

#2Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: PG Bug reporting form (#1)
Re: BUG #4277: Feature request inet type cast numeric values

x wrote:

Description: Feature request inet type cast numeric values
Details:

SELECT inet 2130706433;

Should return:
?column?
--------
127.0.0.1

This would emulate the functionality:
CREATE OR REPLACE FUNCTION inet_ntoa(bigint) RETURNS text AS '
SELECT (($1>>24) & 255::int8) || ''.'' ||
(($1>>16) & 255::int8) || ''.'' ||
(($1>>8) & 255::int8) || ''.'' ||
($1 & 255::int8) as result
'
LANGUAGE 'SQL';

You can create the cast yourself if you want to, see CREATE CAST.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Heikki Linnakangas (#2)
Re: BUG #4277: Feature request inet type cast numeric values

"Heikki Linnakangas" <heikki@enterprisedb.com> writes:

Description: Feature request inet type cast numeric values

You can create the cast yourself if you want to, see CREATE CAST.

The proposed cast seems rather inappropriate in an IPv6 world anyway.
If you want IPv4-only functionality, I think the inet4 type on
pgfoundry has this behavior already.

regards, tom lane