Re: WITH clause

Поиск
Список
Период
Сортировка
От Christopher Browne
Тема Re: WITH clause
Дата
Msg-id m3y8thuwgs.fsf@wolfe.cbbrowne.com
обсуждение исходный текст
Ответ на WITH clause  (David Fetter <david@fetter.org>)
Ответы Re: WITH clause  (Dennis Bjorklund <db@zigo.dhs.org>)
Список pgsql-hackers
david@fetter.org (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.
>
> WITH res = match (x.foo, '([0-9]+)x([0-9]+)')
> SELECT *
> FROM x
> WHERE y = res[2]
> OR    y = res[3];

So you're proposing what amounts to the LET function in Lisp:
 (let* ((homepath (user-homedir-pathname))        (maildir (make-pathname :directory (append
                (pathname-directory                                              homepath)
            '("Mail"))))        (mailhome (merge-pathnames maildir homepath)))   (do-something-with-mail mailhome)
(do-something-with-homehomepath))
 

Or the ML let structure...

let a = 1 and b = 2 in a + b;;
- : int = 3

I think this could be a "simply smashing" idea, allowing values to get
declared once, up front, offering the further potential for them to be
reused.

Unfortunately, this doesn't seem to fit with the way WITH is defined
in SQL.

And while the LISP presentation may have "way too many parentheses,"
the ML syntax, being pretty much orthogonal to what SQL currently
offers, strikes me as being preferable.
-- 
select 'cbbrowne' || '@' || 'ntlug.org';
http://www.ntlug.org/~cbbrowne/unix.html
:FATAL ERROR -- ILLEGAL ERROR


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Kurt Roeckx
Дата:
Сообщение: Walker/mutator prototype.
Следующее
От: Dennis Bjorklund
Дата:
Сообщение: Re: WITH clause