Re: Timestamp conversion can't use index

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: thomas(at)pgsql(dot)com, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Timestamp conversion can't use index
Date: 2001-12-27 00:04:03
Message-ID: 200112270004.fBR043R06802@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Thomas Lockhart <lockhart(at)fourpalms(dot)org> writes:
> > timestamp('stringy time')
> > may not be good, but I would think that
> > timestamp 'timey time'
> > should let the optimizer use indices just fine.
>
> Yup. Possibly this should be noted in the FAQ?
>
> Actually,
> timestamp('stringy time')
> doesn't work at all anymore in 7.2, unless you doublequote the name:
>
> regression=# select timestamp('now');
> ERROR: parser: parse error at or near "'"
> regression=# select "timestamp"('now');
> timestamp
> ----------------------------
> 2001-12-26 12:18:07.008337
> (1 row)

I have updated HISTORY and release.sgml Migration sections:

* The timestamp() function is no longer available. Use timestamp
"string" instead, or CAST.

>
> Another interesting factoid is that "timestamp"('now') does indeed
> produce a constant in 7.2, not a runtime evaluation of text_timestamp.
> text_timestamp is still considered noncachable, but the expression is
> considered to represent timestamp 'now' and not a call of text_timestamp,
> presumably because of this change:
>
> 2001-10-04 18:06 tgl
>
> * doc/src/sgml/typeconv.sgml, src/backend/commands/indexcmds.c,
> src/backend/parser/parse_func.c, src/include/parser/parse_func.h:
> Consider interpreting a function call as a trivial
> (binary-compatible) type coercion after failing to find an exact
> match in pg_proc, but before considering interpretations that
> involve a function call with one or more argument type coercions.
> This avoids surprises wherein what looks like a type coercion is
> interpreted as coercing to some third type and then to the
> destination type, as in Dave Blasby's bug report of 3-Oct-01. See
> subsequent discussion in pghackers.
>
> So there's more here than meets the eye, but the syntax change from
> 7.1 to 7.2 is definitely going to warrant a FAQ entry, IMHO.

Added to same files:

datatype(const,...) function calls now evaluated earlier

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Serguei Mokhov 2001-12-27 00:18:47 Smbd's bits moved somewhere far..
Previous Message Bruce Momjian 2001-12-26 23:53:49 Re: Timestamp conversion can't use index