Subject: documentation for WITH RECURSIVE

From: Andreas Kretschmer <[email-masked]>
Date: Mon, 18 Nov 2019 15:36:24 +0100

Hi,

One of our customers had problems with the syntax of WITH RECURSIVE. He 
suggested that the documentation should be improved, maybe with this 
sentence:

"If any of the CTEs is recursive, the recursive keywork must be present 
after with", so to make sure that it does not refer to just one of the 
named subqueries.

Regards, Andreas

-- 
2ndQuadrant - The PostgreSQL Support Company.
www.2ndQuadrant.com

---

From: Tom Lane <[email-masked]>
Date: Mon, 18 Nov 2019 12:32:08 -0500

> after with", so to make sure that it does not refer to just one of the 

Hm, was this intended for the SELECT man page (presumably in the
"WITH Clause" section), or for section 7.8?

In the SELECT page, I'd be inclined to put it after the para about
"queries need not be ordered" and phrase it more like

  If there are multiple queries in the WITH clause, RECURSIVE can
  be written only once, immediately after WITH.  It applies to all
  queries in the WITH clause (but has no effect on queries that do
  not use either of these features).

			regards, tom lane

---

From: Andreas Kretschmer <[email-masked]>
Date: Mon, 18 Nov 2019 20:12:09 +0100

>    not use either of these features).

yeah, sounds good to me, thx Tom.

Regards, Andreas

---

From: Andreas Kretschmer <[email-masked]>
Date: Tue, 19 Nov 2019 13:29:39 +0100

>> "WITH Clause" section), or for section 7.8?

Hi Tom,

it would be good if we can also add this to chapter 7.8, wouldn't it?

Regards, Andreas

---

From: Tom Lane <[email-masked]>
Date: Tue, 19 Nov 2019 14:47:16 -0500

> it would be good if we can also add this to chapter 7.8, wouldn't it?

I don't feel a need to.  7.8 isn't attempting to define the syntax
precisely.  Moreover, we've had this feature since 8.4, and this
is the first I've heard of somebody misinterpreting the syntax;
so it doesn't seem like it's a huge problem that requires multiple
explanations.

I've pushed a patch for the SELECT reference page.

			regards, tom lane