An strftime function, and function name question

From: Christopher Masto <chris(at)netmonger(dot)net>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: An strftime function, and function name question
Date: 2001-02-07 16:00:38
Message-ID: 20010207110038.A28372@netmonger.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

First of all, I have attached a simple-minded library I created to wrap
the C strftime() function, since we needed some better date formatting
and it seemed less cumbersome to do it on the server end. I gave up C
for Perl a couple of years ago, so I may be a bit rusty, but I tried to
be careful with the buffers and strings.

In any case, it works for my purposes. I did also create a new typecast:

CREATE FUNCTION int4 (timestamp) RETURNS int4 AS
'SELECT date_part(''epoch'', $1)::int4;' LANGUAGE 'sql';

because I wanted to be able to pass the Unix epoch time in, but I
didn't know what timestamps are internally.

My question is about naming. I would like to be able to call this
function 'strftime'. I've never created libraries before so it may
just be a lack of linker knowledge, but I couldn't see how to do that.
If I call it strftime, it obviously conflicts with the real strftime().
It would be nice if there were something like:

CREATE FUNCTION strftime(int4, varchar) RETURNS varchar AS
'/usr/local/pgsql/lib/strftime.so' LANGUAGE 'c'
USING C FUNCTION 'c_strftime';

I.e. some way to say "here's the name of the function in the library".

If there is, I didn't find it.
--
Christopher Masto Senior Network Monkey NetMonger Communications
chris(at)netmonger(dot)net info(at)netmonger(dot)net http://www.netmonger.net

Free yourself, free your machine, free the daemon -- http://www.freebsd.org/

Attachment Content-Type Size
strftime.c text/plain 1.0 KB

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Dror Matalon 2001-02-07 17:32:13 Re: Re: [INTERFACES] Q on JDBC's resultset
Previous Message Tom Lane 2001-02-07 15:36:18 Re: Re: Postgres and Oracle differences and questions