WITH support

Started by Edwin Ramirezabout 19 years ago15 messages
#1Edwin Ramirez
edwin.ramirez@mssm.edu

Hello,

What is the status of supporting the "WITH" keyword?

--
Edwin S. Ramirez, Senior Developer
Information Technology Department - ITDC
Mount Sinai Medical Center
edwin.ramirez@mssm.edu * 646-217-3112

#2Bruce Momjian
bruce@momjian.us
In reply to: Edwin Ramirez (#1)
Re: WITH support

Edwin Ramirez wrote:

Hello,

What is the status of supporting the "WITH" keyword?

I see these TODO items:

* Add SQL99 WITH clause to SELECT
* Add SQL:2003 WITH RECURSIVE (hierarchical) queries to SELECT

Are they the same item? Someone has said they will do RECURSIVE for
8.3, but there is no guarantee.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#3Hubert FONGARNAND
informatique.internet@fiducial.fr
In reply to: Bruce Momjian (#2)
Re: WITH support

Hello,

I can see : WITH RECURSIVE hierarchical queries (Jonah H. Harris) in :

http://developer.postgresql.org/index.php/Todo:WishlistFor83

GREAT!!!

Such feature is very important, because it is supported in most of
commercial database
SQL Server 2003 support WITH RECURSIVE
DB2 support it too (WITH RECURSIVE has been invented by IBM)
Oracle support CONNECT BY (which is not standard, but very easier to use
compare to WITH RECURSIVE)

PostGreSQL would be the first opensource database supporting
hierarchical queries...

Today we use the "CONNECT BY" patch made by evgen potemkin
http://gppl.moonbone.ru/, it works well on 8.1...
But we are ready to drop it if WITH RECURSIVE is integrated!!!

It would be great to open a page on the developper wiki on this subject?

Sincerely

Hubert FONGARNAND

_____ _ _ _ _ ____ _ __ __ _
| ___(_) __| |_ _ ___(_) __ _| | / ___|| |_ __ _ / _|/ _(_)_ __ __ _
| |_ | |/ _` | | | |/ __| |/ _` | | \___ \| __/ _` | |_| |_| | '_ \ / _` |
| _| | | (_| | |_| | (__| | (_| | | ___) | || (_| | _| _| | | | | (_| |
|_| |_|\__,_|\__,_|\___|_|\__,_|_| |____/ \__\__,_|_| |_| |_|_| |_|\__, |
|___/

Le jeudi 28 décembre 2006 à 22:52 -0500, Bruce Momjian a écrit :

Edwin Ramirez wrote:

Hello,

What is the status of supporting the "WITH" keyword?

I see these TODO items:

* Add SQL99 WITH clause to SELECT
* Add SQL:2003 WITH RECURSIVE (hierarchical) queries to SELECT

Are they the same item? Someone has said they will do RECURSIVE for
8.3, but there is no guarantee.

_______________________________________________
Ce message et les �ventuels documents joints peuvent contenir des informations confidentielles.
Au cas o� il ne vous serait pas destin�, nous vous remercions de bien vouloir le supprimer et en aviser imm�diatement l'exp�diteur. Toute utilisation de ce message non conforme � sa destination, toute diffusion ou publication, totale ou partielle et quel qu'en soit le moyen est formellement interdite.
Les communications sur internet n'�tant pas s�curis�es, l'int�grit� de ce message n'est pas assur�e et la soci�t� �mettrice ne peut �tre tenue pour responsable de son contenu.

#4David Fetter
david@fetter.org
In reply to: Bruce Momjian (#2)
Re: WITH support

On Thu, Dec 28, 2006 at 10:52:45PM -0500, Bruce Momjian wrote:

Edwin Ramirez wrote:

Hello,

What is the status of supporting the "WITH" keyword?

I see these TODO items:

* Add SQL99 WITH clause to SELECT
* Add SQL:2003 WITH RECURSIVE (hierarchical) queries to SELECT

Are they the same item?

Not exactly. There is a WITH in the SQL:2003 spec (T121 and T122)
which doesn't include RECURSIVE, but they're related to the RECURSIVE
one (T131).

Someone has said they will do RECURSIVE for 8.3, but there is no
guarantee.

Is there code for this yet? Who's the someone? :)

Cheers,
D
--
David Fetter <david@fetter.org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter

Remember to vote!

#5Bruce Momjian
bruce@momjian.us
In reply to: David Fetter (#4)
Re: WITH support

David Fetter wrote:

On Thu, Dec 28, 2006 at 10:52:45PM -0500, Bruce Momjian wrote:

Edwin Ramirez wrote:

Hello,

What is the status of supporting the "WITH" keyword?

I see these TODO items:

* Add SQL99 WITH clause to SELECT
* Add SQL:2003 WITH RECURSIVE (hierarchical) queries to SELECT

Are they the same item?

Not exactly. There is a WITH in the SQL:2003 spec (T121 and T122)
which doesn't include RECURSIVE, but they're related to the RECURSIVE
one (T131).

Someone has said they will do RECURSIVE for 8.3, but there is no
guarantee.

Is there code for this yet? Who's the someone? :)

No code yet, and I don't remember who said they were working on it.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#6Edwin S. Ramirez
ramirez@idconcepts.org
In reply to: Bruce Momjian (#5)
Re: WITH Support

The WITH that I am thinking about, lets you define and reuse queries which are executed once. For example:

WITH
MySummary AS (*SELECT b.dept_name, Sum(Salary) AS total_sal FROM emp a join dept b on (a.dept_id = b.dept_id)
GROUP BY b.dept_name*)
SELECT dept_name, total_sal //FROM MySummary
WHERE total_sal > (
SELECT SUM (total_sal) * 1/12
FROM MySummary)
ORDER BY total_sal

You can introduce multiple "aliases" and use them within any subsequent queries.

WITH
alias1 as (...)
alias2 as (...)
alias3 as (...)
SELECT ....

Thanks,

Show quoted text

Edwin Ramirez wrote:

Hello,

What is the status of supporting the "WITH" keyword?

I see these TODO items:

* Add SQL99 WITH clause to SELECT
* Add SQL:2003 WITH RECURSIVE (hierarchical) queries to SELECT

Are they the same item?

#7Jonah H. Harris
jonah.harris@gmail.com
In reply to: Bruce Momjian (#5)
Re: WITH support

On 12/29/06, Bruce Momjian <bruce@momjian.us> wrote:

No code yet, and I don't remember who said they were working on it.

I'm still waiting to hear from Mark Cave-Ayland on whether he's going
to pick it up or whether I'll just do it. One way or another, there
should be some movement regarding design discussion within a week or
two.

--
Jonah H. Harris, Software Architect | phone: 732.331.1324
EnterpriseDB Corporation | fax: 732.331.1301
33 Wood Ave S, 3rd Floor | jharris@enterprisedb.com
Iselin, New Jersey 08830 | http://www.enterprisedb.com/

#8Mark Cave-Ayland
mark.cave-ayland@ilande.co.uk
In reply to: Jonah H. Harris (#7)
Re: WITH support

On Sat, 2006-12-30 at 00:49 -0500, Jonah H. Harris wrote:

On 12/29/06, Bruce Momjian <bruce@momjian.us> wrote:

No code yet, and I don't remember who said they were working on it.

I'm still waiting to hear from Mark Cave-Ayland on whether he's going
to pick it up or whether I'll just do it. One way or another, there
should be some movement regarding design discussion within a week or
two.

Hi everyone,

Sorry to come in late on this discussion - I've been playing catch-up
with emails over the festive season...

The situation regarding WITH support is that it's something which I am
picking up in my spare time (out of work hours) and so unfortunately
progress isn't as rapid as I would like. See here for my last meaningful
patch and Tom's feedback:
http://archives.postgresql.org/pgsql-patches/2006-09/msg00260.php. The
idea was to first implement just the WITH clause itself as a first
patch, and then extend to include the recursive features with a
secondary patch.

In short, if people don't mind waiting for my free cycles to come along
then I will continue to chip away at it; otherwise if it's considered an
essential for 8.3 with an April deadline then I will happily hand over
to Jonah.

Kind regards,

Mark.

#9Jonah H. Harris
jonah.harris@gmail.com
In reply to: Mark Cave-Ayland (#8)
Re: WITH support

On 12/30/06, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote:

In short, if people don't mind waiting for my free cycles to come along
then I will continue to chip away at it; otherwise if it's considered an
essential for 8.3 with an April deadline then I will happily hand over
to Jonah.

I'd say it's probably essential given my last, shall we say, "mishap".
So I guess I'll start up discussion on the design again soon. I'm
leaving in a couple days to travel up to NJ so expect discussion to
start again on Tuesday of next week.

As always, I too wouldn't have a problem if someone else is going to
see it through for 8.3.

--
Jonah H. Harris, Software Architect | phone: 732.331.1324
EnterpriseDB Corporation | fax: 732.331.1301
33 Wood Ave S, 3rd Floor | jharris@enterprisedb.com
Iselin, New Jersey 08830 | http://www.enterprisedb.com/

#10Hubert FONGARNAND
informatique.internet@fiducial.fr
In reply to: Jonah H. Harris (#9)
Re: WITH support

Le mardi 02 janvier 2007 à 18:08 -0700, Jonah H. Harris a écrit :

On 12/30/06, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote:

In short, if people don't mind waiting for my free cycles to come along
then I will continue to chip away at it; otherwise if it's considered an
essential for 8.3 with an April deadline then I will happily hand over
to Jonah.

I'd say it's probably essential given my last, shall we say, "mishap".
So I guess I'll start up discussion on the design again soon. I'm
leaving in a couple days to travel up to NJ so expect discussion to
start again on Tuesday of next week.

As always, I too wouldn't have a problem if someone else is going to
see it through for 8.3.

Why not looking at http://gppl.moonbone.ru/ evgen potemkin. has ever
made a patch for WITH and CONNECT BY?

I'm ready to test these features... (RECURSIVE) when they'll land in
CVS...

Hubert FONGARNAND
_______________________________________________
Ce message et les �ventuels documents joints peuvent contenir des informations confidentielles.
Au cas o� il ne vous serait pas destin�, nous vous remercions de bien vouloir le supprimer et en aviser imm�diatement l'exp�diteur. Toute utilisation de ce message non conforme � sa destination, toute diffusion ou publication, totale ou partielle et quel qu'en soit le moyen est formellement interdite.
Les communications sur internet n'�tant pas s�curis�es, l'int�grit� de ce message n'est pas assur�e et la soci�t� �mettrice ne peut �tre tenue pour responsable de son contenu.

#11Mark Cave-Ayland
mark.cave-ayland@ilande.co.uk
In reply to: Hubert FONGARNAND (#10)
Re: WITH support

On Wed, 2007-01-03 at 09:45 +0100, Hubert FONGARNAND wrote:

Why not looking at http://gppl.moonbone.ru/ evgen potemkin. has ever
made a patch for WITH and CONNECT BY?

I'm ready to test these features... (RECURSIVE) when they'll land in
CVS...

Hi Hubert,

IIRC there were two issues - firstly the license for the patch was GPL
as opposed to BSD used for PostgreSQL, and secondly I believe Tom and
some of the other developers were not happy with some of the internal
changes made by the patch. Fortunately it looks as if Jonah can commit
some serious time to this, so your offer of helping to test when the
code hits CVS is gratefully received :)

Kind regards,

Mark.

#12Jonah H. Harris
jonah.harris@gmail.com
In reply to: Hubert FONGARNAND (#10)
Re: WITH support

On 1/3/07, Hubert FONGARNAND <informatique.internet@fiducial.fr> wrote:

Why not looking at http://gppl.moonbone.ru/ evgen potemkin. has ever made a
patch for WITH and CONNECT BY?

Nope, no good. This is what I started with last time and the
refactoring attempt at WITH is just too massive. As for CONNECT BY,
PostgreSQL does not want the syntax, they want ANSI/ISO WITH
[RECURSIVE]... so even starting there isn't great.

This is really something that needs to be decided on before
implementation... or it will probably never get in.

--
Jonah H. Harris, Software Architect | phone: 732.331.1324
EnterpriseDB Corporation | fax: 732.331.1301
33 Wood Ave S, 3rd Floor | jharris@enterprisedb.com
Iselin, New Jersey 08830 | http://www.enterprisedb.com/

#13Jonah H. Harris
jonah.harris@gmail.com
In reply to: Mark Cave-Ayland (#11)
Re: WITH support

On 1/3/07, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote:

IIRC there were two issues - firstly the license for the patch was GPL
as opposed to BSD used for PostgreSQL

Yes, however Evgen was kind enough to grant me a BSD license for it
should I get it committed into PostgreSQL. However, with the amount
of refactoring and community design decisions to be made, I doubt any
of the patch would be usable.

... secondly I believe Tom and some of the other developers were not
happy with some of the internal changes made by the patch.

Yes, there are numerous bug reports from patched versions especially
on Gentoo. As for the WITH support, it was written for PostgreSQL
7.2/7.3 and was a basic preliminary proof-of-concept.

--
Jonah H. Harris, Software Architect | phone: 732.331.1324
EnterpriseDB Corporation | fax: 732.331.1301
33 Wood Ave S, 3rd Floor | jharris@enterprisedb.com
Iselin, New Jersey 08830 | http://www.enterprisedb.com/

#14David Fetter
david@fetter.org
In reply to: Jonah H. Harris (#12)
Re: WITH support

On Wed, Jan 03, 2007 at 04:19:19PM -0700, Jonah H. Harris wrote:

On 1/3/07, Hubert FONGARNAND <informatique.internet@fiducial.fr> wrote:

Why not looking at http://gppl.moonbone.ru/ evgen potemkin. has
ever made a patch for WITH and CONNECT BY?

Nope, no good. This is what I started with last time and the
refactoring attempt at WITH is just too massive. As for CONNECT BY,
PostgreSQL does not want the syntax, they want ANSI/ISO WITH
[RECURSIVE]... so even starting there isn't great.

This is really something that needs to be decided on before
implementation... or it will probably never get in.

As I recall, it was decided long ago, and the conclusions were:

* Only BSD-compatibly licensed code goes in PostgreSQL's code base,

and

* PostgreSQL will only support the SQL:2003 standard WITH (RECURSIVE)
syntax in the main line code.

Cheers,
D
--
David Fetter <david@fetter.org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter

Remember to vote!

#15Jonah H. Harris
jonah.harris@gmail.com
In reply to: David Fetter (#14)
Re: WITH support

On 1/3/07, David Fetter <david@fetter.org> wrote:

As I recall, it was decided long ago, and the conclusions were:
* Only BSD-compatibly licensed code goes in PostgreSQL's code base,
* PostgreSQL will only support the SQL:2003 standard WITH (RECURSIVE)
syntax in the main line code.

Yes, see later response :)

--
Jonah H. Harris, Software Architect | phone: 732.331.1324
EnterpriseDB Corporation | fax: 732.331.1301
33 Wood Ave S, 3rd Floor | jharris@enterprisedb.com
Iselin, New Jersey 08830 | http://www.enterprisedb.com/