WITH clause

From: David Fetter <david(at)fetter(dot)org>
To: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: WITH clause
Date: 2003-12-12 18:13:56
Message-ID: 20031212181356.GV1859@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100 cell: +1 415 235 3778

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2003-12-12 18:47:26 Re: WITH clause
Previous Message Tom Lane 2003-12-12 17:04:15 Re: Use of 'cp -r' in CREATE DATABASE