WITH clause - Mailing list pgsql-hackers

From David Fetter
Subject WITH clause
Date
Msg-id 20031212181356.GV1859@fetter.org
Whole thread Raw
Responses Re: WITH clause
Re: WITH clause
Re: WITH clause
Re: WITH clause
List pgsql-hackers
Kind people,

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.

WITH res = match (x.foo, '([0-9]+)x([0-9]+)')
SELECT *
FROM x
WHERE y = res[2]
OR    y = res[3];

Here res[1] would be the whole pattern match, res[2] & res[3] would be
the set of digits before x and the set of digits after x,
respectively.

Ideally, there could also be (optionally) res[pre] and res[post] which
would refer to the stuff in foo that preceds the match and stuff in
foo that follows the match, respectively.

Perl weenies may think of $&, $1, ... $n, $` and $'.

Comments, ideas, brickbats, and "you're on crack" comments welcome. :)

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


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Use of 'cp -r' in CREATE DATABASE
Next
From: Peter Eisentraut
Date:
Subject: Re: WITH clause