Common table expression - parsing questions - Mailing list pgsql-sql

From the6campbells
Subject Common table expression - parsing questions
Date
Msg-id 22431f1b0909281954t21cffc94o291002fe6b545494@mail.gmail.com
Whole thread Raw
Responses Re: Common table expression - parsing questions  (Thomas Kellerer <spam_eater@gmx.net>)
List pgsql-sql
Couple of questions:
 
1. Why does Postgres not throw a parsing error during sqlPrepare for this statement vs at sqlExecute
 
with t_cte ( c1, ctr ) as (
select 1,0 from tversion union
select 2,0 from tversion union all
select c1, ctr + 1 from t_cte where c1=1 and ctr < 5 union all
select c1, ctr + 1 from t_cte where c1=2 and ctr < 5)
select c1, ctr from t_cte
 
2. Do you intend to remove the requirement to include the recursive keyword - as other vendors allow

3. Is it a documented restriction that you can only have one reference to the CTE .. see above example which fails while this modified version works. The former
works in other vendors.
 
with recursive t_cte ( c1, ctr ) as (
select 1,0 from tversion union
select 2,0 from tversion union all
select c1, ctr + 1 from t_cte where c1=1 and ctr < 5 )
select c1, ctr from t_cte

pgsql-sql by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: Need magic for a moving statistic
Next
From: Andreas
Date:
Subject: Need even more magic. Now for tricky counts.