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