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>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Some more function-default issues
Date: 2009-01-08 18:32:34
Message-ID: 18613.1231439554@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> 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.

I looked around and found that the main issue with doing it the way
I was envisioning is the ii_Expressions and ii_Predicate expression
trees in struct IndexInfo. I wanted to run those trees through
plan_expression() before sticking them into IndexInfo, but the trouble
with that approach is that in UpdateIndexRelation() we expect that we
can use nodeToString() on them to produce the index definitional data
that will get stored into pg_index. We do *not* want to use "planned"
expressions for that --- it would cause function defaults to propagate
into the index definition, which is exactly what we are trying to avoid
by not inserting defaults until plan time.

So it seems like the best solution is to allow ExecPrepareExpr to
call plan_expression(). A look through the callers suggests that
this won't really result in much repeated work because there are few
cases where the results could be re-used anyway. It's still a tad
annoying, but not enough so to justify a lot of code rearrangement
right now.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Smith 2009-01-08 18:37:01 Re: Proposal: new border setting in psql
Previous Message Heikki Linnakangas 2009-01-08 18:30:37 Hot standby, slot ids and stuff