Re: [HACKERS] Re: TO_CHAR() - Mailing list pgsql-hackers

From Thomas Lockhart
Subject Re: [HACKERS] Re: TO_CHAR()
Date
Msg-id 37F4CB35.429C8003@alumni.caltech.edu
Whole thread Raw
In response to Re: [HACKERS] Re: TO_CHAR()  (Zakkr <zakkr@zf.jcu.cz>)
Responses Re: [HACKERS] Re: TO_CHAR()  (wieck@debis.com (Jan Wieck))
List pgsql-hackers
> > > this is my new (experimental) TO_CHAR() function (compatible with oracle),
> > > it is available on: ftp://ftp2.zf.jcu.cz/users/zakkr/pg/TO_CHAR-0.1.tar.gz.
> > > Any comments ?
> > Nice! So, there is a routine to go the other way in Oracle
> > (format()??) and if we have both then we're cookin'
> Thank! But.. sorry, I don't understand you. What other way in the Oracle
> (format()??) ?

Ah, something to go from a random character string to an internal
date/time type. We have a fairly generic way to do this already, but
since to_char() can insert random garbage at the user's behest then it
would be nice to have a related routine which can be told how to
decode a string containing random garbage. I'm pretty sure that Oracle
has such a beast, but I don't have the docs. I would think that it
could be done as a thin layer on top of datetime_in().

> What make with this code next? Is it interesting for developers (hmm, to this
> discussion join you (Thomas) and me only, but others probably needn't
> TO_CHAR, TO_NUMBER, TO_DATE) ..?

People have requested to_char(), or at least inquired about it, though
of course there are always ways to work around not having it. After
all, it *is* non-standard ;) But we already have some Oracle
compatibility functions, and a few more won't hurt.

There are two possibilities:

1) we incorporate it into the main tree
2) we distribute it as a contrib package

I'd prefer the former, though right now the code has problems since it
converts input to timestamp to take advantage of localtime(). Can you
look at, and perhaps use directly, datetime2tm()? That should get you
the structure you need to work with, and it is not limited to just
Unix system time ranges. Just be aware that the year field contains a
real year, not year modulo 1900 as in a real Unix tm structure.

Let me know if this is possible.
                     - Thomas

-- 
Thomas Lockhart                lockhart@alumni.caltech.edu
South Pasadena, California


pgsql-hackers by date:

Previous
From: SAKAIDA Masaaki
Date:
Subject: Re: [HACKERS] pgbash-1.1.1 release
Next
From: Thomas Lockhart
Date:
Subject: Re: [HACKERS] are subtransactions not nestable?