pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Lockhart <lockhart@alumni.caltech.edu>
Cc: Jackson, DeJuan <djackson@cpsgroup.com>
Cc: Andrew Merrill <andrew@compclass.com>
Cc: pgsql-sql@hub.org, PGSQL Hackers <pgsql-hackers@hub.org>
Subject: Re: [SQL] indexing a datetime by date
Date: Tue, 30 Mar 1999 11:31:35 -0500
Message-ID: <6913.922811495@sss.pgh.pa.us> (raw)
In-Reply-To: <37006BB5.E5720D9@alumni.caltech.edu>

Thomas Lockhart <lockhart@alumni.caltech.edu> writes:
>> create index when_ndx3 on notes (date(when) date_ops);
>> Which won't work because the date(datetime) function isn't trusted.

> Tom, does this ring a bell with you?

No, and in fact datetime_date *is* marked trusted in pg_proc,
both current sources and 6.4.2.

I see the problem DeJuan is getting at:

play=> create table notes (when datetime);
CREATE
play=> create index when_ndx3 on notes (date(when) date_ops);
CREATE
play=> insert into notes values ('now');
ERROR:  internal error: untrusted function not supported.

This is either a bug or a very poorly worded error message.
I'll look into it.

In the meantime, a workaround is to call the function using its
builtin name:

play=> create table notes (when datetime);
CREATE
play=> create index when_ndx3 on notes (datetime_date(when) date_ops);
CREATE
play=> insert into notes values ('now');
INSERT 1086489 1

In 6.4.2, date() on a datetime is an SQL-language function that just
calls the builtin function datetime_date().  It would seem that 6.4.2
can't cope with an SQL-language function as an index generator.  This
might be a minor bug or it might be difficult to change; I dunno.

In 6.5, date() on a datetime is a true builtin, on par with
datetime_date(), so you'll be able to use either name interchangeably in
that release.  But we may still not be able to do anything with other
SQL-language functions as index generators.

			regards, tom lane



view thread (9+ messages)  latest in thread

Message-ID: <6913.922811495@sss.pgh.pa.us>
Permalink:  ../6913.922811495@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/6913.922811495@sss.pgh.pa.us

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, lockhart@alumni.caltech.edu, djackson@cpsgroup.com, andrew@compclass.com, pgsql-hackers@hub.org
  Subject: Re: [SQL] indexing a datetime by date
  In-Reply-To: <6913.922811495@sss.pgh.pa.us>
  References: <37006BB5.E5720D9@alumni.caltech.edu> <6913.922811495@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