Re: pre-MED

From: David Fetter <david(at)fetter(dot)org>
To: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pre-MED
Date: 2008-10-31 14:48:55
Message-ID: 20081031144852.GF15545@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Oct 29, 2008 at 09:40:00AM -0700, David Fetter wrote:
> Folks,
>
> Please find enclosed a WIP patch to add the ability for functions to
> see the qualifiers of the query in which they're called. It's not
> working just yet, and I'm not sure how best to get it working, but I'd
> like to see this as part of 8.4, as SQL/MED is just way too ambitious
> given the time frame.
>
> Any tips, hints, pointers, etc. would be much appreciated.
>
> Also, PL/Perl shouldn't be the only language to have this capability.
> How might we add similar capabilities to PL/PythonU and PL/Tcl? To
> the rest of the PLs? Would it make any sense to have it in SQL
> language functions?

Please find attached a patch which works in PL/Perl, the work having
been done by Andrew (RhodiumToad) Gierth. It's not clear to me how
this would be generally surface-able to SQL, though. Any ideas?

CREATE OR REPLACE FUNCTION show_qual()
RETURNS TEXT
LANGUAGE plperl
AS $$
return $_QUAL->{qual_string};
$$;

postgres=# SELECT * FROM show_qual() s(a) where a like '%';
a
------------------
(a ~~ '%'::text)

However, there are little lacunæ like this:

SELECT * FROM show_qual() s(a)
WHERE A NOT IN (
SELECT 'foo' UNION ALL SELECT 'bar'
);
a
------------------------
(NOT (hashed subplan))

Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

Attachment Content-Type Size
premed_02.diff text/plain 6.0 KB

In response to

  • pre-MED at 2008-10-29 16:40:00 from David Fetter

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nikhil Sontakke 2008-10-31 14:50:46 Re: Fwd: [PATCHES] Auto Partitioning Patch - WIP version 1
Previous Message Tom Lane 2008-10-31 14:21:59 Re: PG_PAGE_LAYOUT_VERSION 5 - time for change