hex integer input

Started by Jeremy Drakealmost 19 years ago6 messages
#1Jeremy Drake
pgsql@jdrake.com

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.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jeremy Drake (#1)
Re: hex integer input

Jeremy Drake <pgsql@jdrake.com> writes:

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.

regression=# select x'abcd'::int;
int4
-------
43981
(1 row)

regards, tom lane

#3Jeremy Drake
pgsql@jdrake.com
In reply to: Tom Lane (#2)
Re: hex integer input

On Fri, 2 Mar 2007, Tom Lane wrote:

Jeremy Drake <pgsql@jdrake.com> writes:

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.

regression=# select x'abcd'::int;
int4
-------
43981
(1 row)

Hmm. I actually used the bit(N) type on a project quite some time ago,
but it did not occur to me to use the bit string input syntax to input an
integer.

Well, I guess there is a way after all. So in the immortal words of Emily
Litella, "Never mind."

--
In an organization, each person rises to the level of his own
incompetency
-- The Peter Principle

#4Vishal Arora
aroravishal22@hotmail.com
In reply to: Jeremy Drake (#3)
xlogViewer / xlogdump

Hi

Does anyone has an idea how xlogdump works with Windows installation of
Postgres.
I have postgres 8.2.x installed on my windows PC.

How do we install it on Linux box with existing postgres 8.2.x installation

Thanks

Vishal

_________________________________________________________________
Find a local pizza place, movie theater, and more�.then map the best route!
http://maps.live.com/?icid=hmtag1&amp;FORM=MGAC01

#5Vishal Arora
aroravishal22@hotmail.com
In reply to: Vishal Arora (#4)
Re: xlogViewer / xlogdump

I am getting a following error while make install for xlogdump -

[root@localhost xlogdump]# make install
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing xlogdump.o
.../../src/port/sprompt.o ../../src/backend/utils/hash/pg_crc.o
-L../../src/port -lpgport -L../../src/interfaces/libpq -lpq -L../../src/port
-Wl,-rpath,'/usr/local/pgsql/lib' -lpgport -lz -lreadline -ltermcap
-lcrypt -ldl -lm -o xlogdumpxlogdump.o(.text+0x163f): In function
`dumpXLog':
: undefined reference to `__stack_chk_fail'
collect2: ld returned 1 exit status
make: *** [xlogdump] Error 1

Please anyone can help in the same

From: "Vishal Arora" <aroravishal22@hotmail.com>
To: pgsql-hackers@postgresql.org
Subject: [HACKERS] xlogViewer / xlogdump
Date: Fri, 02 Mar 2007 08:54:07 +0000

Hi

Does anyone has an idea how xlogdump works with Windows installation of
Postgres.
I have postgres 8.2.x installed on my windows PC.

Thanks

Vishal

_________________________________________________________________
Find a local pizza place, movie theater, and more�.then map the best route!
http://maps.live.com/?icid=hmtag1&amp;FORM=MGAC01

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

_________________________________________________________________
With tax season right around the corner, make sure to follow these few
simple tips.
http://articles.moneycentral.msn.com/Taxes/PreparationTips/PreparationTips.aspx?icid=HMFebtagline

#6Jonah H. Harris
jonah.harris@gmail.com
In reply to: Vishal Arora (#5)
Re: xlogViewer / xlogdump

On 3/2/07, Vishal Arora <aroravishal22@hotmail.com> wrote:

I am getting a following error while make install for xlogdump -

For some reason, Diogo kept his already-built code in there, so you
need to do a make clean && make install

--
Jonah H. Harris, Software Architect | phone: 732.331.1324
EnterpriseDB Corporation | fax: 732.331.1301
33 Wood Ave S, 3rd Floor | jharris@enterprisedb.com
Iselin, New Jersey 08830 | http://www.enterprisedb.com/