Re: Timestamp conversion can't use index

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: thomas(at)pgsql(dot)com
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Timestamp conversion can't use index
Date: 2001-12-26 17:35:42
Message-ID: 20342.1009388142@sss.pgh.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)

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.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2001-12-26 23:41:21 Re: Timestamp conversion can't use index
Previous Message Thomas Lockhart 2001-12-26 16:20:24 Re: [JDBC] Remember to register PostgreSQL for JDJ 2002 awards