Re: WITH clause

From: david(at)fetter(dot)org (David Fetter)
To: alvherre(at)dcc(dot)uchile(dot)cl (Alvaro Herrera Munoz), pgsql-hackers(at)postgresql(dot)org
Subject: Re: WITH clause
Date: 2003-12-12 19:36:26
Message-ID: 200312121936.hBCJaQAJ022349@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

In article <20031212190754(dot)GA11548(at)dcc(dot)uchile(dot)cl> you wrote:
> On Fri, Dec 12, 2003 at 10:13:56AM -0800, David Fetter wrote:
>
>> I'm looking to the SQL WITH clause as a way to get better regex
>> support in PostgreSQL. I've been chatting a little bit about this,
>> and here's an idea for a behavior. Implementation details TBD.

> I think you could be rather looking at keeping the regmatch_t * from
> RE_compile_and_execute somewhere in the TopTransactionContext, and
> create accessor functions to it. You could do

> BEGIN;
> SELECT ... x ~ '([0-9]+)x([0-9]+)';
> SELECT regex_parens(1), regex_parens(2);
> COMMIT;

> Etc, you get the idea. Of course you could only access the captured
> expressions from the last regex, and only within the same
> transaction block.

A couple of little issues with this:

1. It's assuming there will be exactly one regular expression with
associated atoms. This is probably fixable by making the function
take two arguments, and it would be really, really nice if these were
nameable. F'rex, regex_matches(regex => 1, match => 2) or
regex_matches(regex => 'the_one_i_wanted', match => 'post')

2. It doesn't allow for the regex atoms to be used in the SQL
statement.

BTW, I should have said "row-level environment variables" rather than
"statement-level environment variables," although some of the latter
would be nice, too :)

Cheers,
D
--
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100 cell: +1 415 235 3778

Sophomoric (adj.) The itch to be unique.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2003-12-12 19:41:48 Re: Resurrecting pg_upgrade
Previous Message Roderick A. Anderson 2003-12-12 19:24:38 Re: 7.4 build problem on Linux Vserver