Skip site navigation (1) Skip section navigation (2)

Re: pre-MED

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Alex Hunsaker" <badalex(at)gmail(dot)com>
Cc: "David Fetter" <david(at)fetter(dot)org>, "Hannu Krosing" <hannu(at)krosing(dot)net>, "PG Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pre-MED
Date: 2008-11-04 17:23:55
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
"Alex Hunsaker" <badalex(at)gmail(dot)com> writes:
> On Thu, Oct 30, 2008 at 05:16, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Surely they all have a way to call a SQL function that returns text.

> Sure but when you call that function you get *that* functions
> qualifier.  And unless there already is a way to grab the "parent"
> query qualifiers, the PL specific hacks seem not so bad and very
> similar to how we have to build trigger arguments for every PL
> already.

The PL hacks are awful :-(, not least because that path leads to
randomly different syntax in each PL for exactly the same functionality.

As I see it, there are two big problem areas in this patch:
1. How to get the information about restriction clauses to the place
where we'd use it;
2. What to do with it once we've got it.

We already went over #2 in some detail: the existing ruleutils.c code
just isn't very suitable for this purpose.  This could probably be
worked around, eg drop restriction clauses that contain subplans or
outer-relation variables; though I'm quite unsure about the issue of
which names to use for the column variables.

As for #1, the patch proposes to pass the Plan node (more or less, but
that's the key thing) via a new field in ReturnSetInfo.  The first
problem with that is that it only makes the information available to
set-returning functions occurring at the top level of a FunctionScan
node.  The second problem is that any layer of code we want to pass the
information down through has to explicitly know about it, and we have
to invent some new API for each one of those layers.

ISTM that a saner way to approach this would be to set up a global way
to find out "what's the currently executing Plan node?".  Then this
particular problem could be solved by just grabbing the qual field from
that node.  Infrastructure like that could be useful for instrumentation
and debugging purposes as well.  I'm not sure about the overhead
involved, though.  The obvious implementation would add three lines of
code to ExecProcNode:

	PlanState *save_ActivePlanNode = ActivePlanNode;

	ActivePlanNode = node;


	ActivePlanNode = save_ActivePlanNode;

which doesn't seem like it would amount to anything compared to the
total execution of a plan node, but we do know that ExecProcNode
is a hot spot in some usages.

			regards, tom lane

In response to

  • Re: pre-MED at 2008-11-04 03:08:06 from Alex Hunsaker


pgsql-hackers by date

Next:From: Bernd HelmleDate: 2008-11-04 17:55:17
Previous:From: Tom LaneDate: 2008-11-04 16:57:18
Subject: Re: some strange bugs related to upgrade from 8.1 to 8.3

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group