Skip site navigation (1) Skip section navigation (2)

hex integer input

From: Jeremy Drake <pgsql(at)jdrake(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: hex integer input
Date: 2007-03-02 07:29:18
Message-ID: Pine.BSO.4.64.0703012312080.18849@resin.csoft.net (view raw or flat)
Thread:
Lists: pgsql-hackers
On several occasions I have wanted to input integers in hexadecimal rather
than in decimal in PostgreSQL.  I notice that there is a to_hex function,
but there is not (AFAIK) a way to provide an integer in hexadecimal.

I have written a pure-sql implementation of some functions to input
integers in hexadecimal
(http://postgresql.jdrake.com/hex-int-in.sql.html), but it is less than
efficient ;)

Is there some reason why hex input is not currently supported?  What would
be the preferred way to implement it?

1. A function (or one for each int[248]), essentially from_hex(text)

2. Support in the input functions for int[248] for integers that start
with '0[Xx]' as with strtol with base set to 0.

3. Support in the grammar for integral constants 0[Xx][0-9A-Fa-f]+

Thoughts?  Is this a legitimate TODO?

-- 
Mr. Cole's Axiom:
	The sum of the intelligence on the planet is a constant; the
	population is growing.

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2007-03-02 07:38:34
Subject: Re: hex integer input
Previous:From: Tatsuo IshiiDate: 2007-03-02 07:11:42
Subject: Re: HOT - preliminary results

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group