From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Josh Berkus" <josh(at)agliodbs(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Timestamp operator error |
Date: | 2002-02-26 05:31:29 |
Message-ID: | 27580.1014701489@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
"Josh Berkus" <josh(at)agliodbs(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2002-02-26 05:42:04 | Re: Timestamp operator error |
Previous Message | Josh Berkus | 2002-02-26 05:20:02 | Re: Timestamp operator error |