Re: Some more function-default issues

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Some more function-default issues
Date: 2009-01-06 14:56:44
Message-ID: 9143.1231253804@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> writes:
> That seems ok to me. Calling eval_const_expressions() in ALTER COLUMN
> and elsewhere is a good idea for performance reasons as well.

Yeah, probably so.

> I can only find one more call to fix_opfuncids, where we're not already
> calling eval_const_expressions(): GetDomainConstraints(). Adding a
> eval_const_expressions() call to ExecPrepareExpr() would take care of
> the ALTER COLUMN and many other cases where we have a problem now.

I'd prefer not to have ExecPrepareExpr do it, though; that's supposed
to be working from a read-only expression tree supplied by the caller.
(The fix_opfuncids call in it is already pushing the bounds of that
concept.)

From a structural point of view the right thing would be to introduce
a concept of "expression planning", along the lines of

expr = plan_expression(expr);

which callers would be required to invoke before ExecPrepareExpr.
Right now this would do the fix_opfuncids bit and
eval_const_expressions, but I could see someday allowing SubLinks
in standalone expressions because we'd have the ability to invoke
the full planner from inside here.

The trick is to get the attention of third-party code about the need
to make this change. Removing fix_opfuncids from ExecPrepareExpr
wouldn't really help much, because in very many common cases it's
a no-op anyway; so unless their testing is quite thorough they would
not see a failure before shipping.

The only idea I have at the moment is to rename ExecPrepareExpr to
something else, but it's not clear if that will persuade people to read
its header comment or not ...

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2009-01-06 14:57:10 Re: QuickLZ compression algorithm (Re: Inclusion in the PostgreSQL backend for toasting rows)
Previous Message Tom Lane 2009-01-06 14:44:48 Re: Bugs during ProcessCatchupEvent()