From: Tom Lane <tgl@sss.pgh.pa.us>
To: Josh Berkus <josh@agliodbs.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Timestamp operator error
Date: Tue, 26 Feb 2002 00:31:29 -0500
Message-ID: <27580.1014701489@sss.pgh.pa.us> (raw)
In-Reply-To: <web-810172@davinci.ethosmedia.com>
References: <web-810172@davinci.ethosmedia.com>
"Josh Berkus" <josh@agliodbs.com> writes:
> FMI, though, how difficult is defining an operator if I paid a C
> programmer to do it?
Pretty trivial when it's only the commutation of an existing operator...
Actually you don't even need any C code. You could limp along at some
sacrifice of performance with an SQL function definition. Say
regression=# create function interval_plus_timestamp(interval,timestamp)
regression-# returns timestamp as '
regression'# select $2 + $1;
regression'# ' language 'sql';
CREATE
regression=# create operator + (procedure = interval_plus_timestamp,
regression(# leftarg = interval,
regression(# rightarg = timestamp);
CREATE
et voila:
regression=# select ('6 days'::INTERVAL + current_timestamp);
?column?
-------------------------------
2002-03-04 00:28:30.230026-05
(1 row)
I'd not want to make an index depend on this operator, but for
occasional query use it should do fine ...
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, josh@agliodbs.com
Subject: Re: Timestamp operator error
In-Reply-To: <27580.1014701489@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox