Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 46f2971

Browse files
committed
Revert "Propagate CTE property flags when copying a CTE list into a rule."
This reverts commit ed29089 and equivalent back-branch commits. The issue is subtler than I thought, and it's far from new, so just before a release deadline is no time to be fooling with it. We'll consider what to do at a bit more leisure. Discussion: https://postgr.es/m/CAJcOf-fAdj=nDKMsRhQzndm-O13NY4dL6xGcEvdX5Xvbbi0V7g@mail.gmail.com
1 parent 2a7664a commit 46f2971

File tree

3 files changed

+0
-49
lines changed

3 files changed

+0
-49
lines changed

src/backend/rewrite/rewriteHandler.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,6 @@ rewriteRuleAction(Query *parsetree,
530530
*
531531
* This could possibly be fixed by using some sort of internally
532532
* generated ID, instead of names, to link CTE RTEs to their CTEs.
533-
* However, decompiling the results would be quite confusing; note the
534-
* merge of hasRecursive flags below, which could change the apparent
535-
* semantics of such redundantly-named CTEs.
536533
*/
537534
foreach(lc, parsetree->cteList)
538535
{
@@ -554,9 +551,6 @@ rewriteRuleAction(Query *parsetree,
554551
/* OK, it's safe to combine the CTE lists */
555552
sub_action->cteList = list_concat(sub_action->cteList,
556553
copyObject(parsetree->cteList));
557-
/* ... and don't forget about the associated flags */
558-
sub_action->hasRecursive |= parsetree->hasRecursive;
559-
sub_action->hasModifyingCTE |= parsetree->hasModifyingCTE;
560554
}
561555

562556
/*

src/test/regress/expected/with.out

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,33 +1672,6 @@ SELECT * FROM bug6051_2;
16721672
3
16731673
(3 rows)
16741674

1675-
-- silly example to verify that hasModifyingCTE flag is propagated
1676-
CREATE TEMP TABLE bug6051_3 AS
1677-
select a from generate_series(11,13) as a;
1678-
CREATE RULE bug6051_3_ins AS ON INSERT TO bug6051_3 DO INSTEAD
1679-
SELECT i FROM bug6051_2;
1680-
BEGIN; SET LOCAL force_parallel_mode = on;
1681-
WITH t1 AS ( DELETE FROM bug6051_3 RETURNING * )
1682-
INSERT INTO bug6051_3 SELECT * FROM t1;
1683-
i
1684-
---
1685-
1
1686-
2
1687-
3
1688-
1
1689-
2
1690-
3
1691-
1
1692-
2
1693-
3
1694-
(9 rows)
1695-
1696-
COMMIT;
1697-
SELECT * FROM bug6051_3;
1698-
a
1699-
---
1700-
(0 rows)
1701-
17021675
-- a truly recursive CTE in the same list
17031676
WITH RECURSIVE t(a) AS (
17041677
SELECT 0

src/test/regress/sql/with.sql

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -773,22 +773,6 @@ INSERT INTO bug6051 SELECT * FROM t1;
773773
SELECT * FROM bug6051;
774774
SELECT * FROM bug6051_2;
775775

776-
-- silly example to verify that hasModifyingCTE flag is propagated
777-
CREATE TEMP TABLE bug6051_3 AS
778-
select a from generate_series(11,13) as a;
779-
780-
CREATE RULE bug6051_3_ins AS ON INSERT TO bug6051_3 DO INSTEAD
781-
SELECT i FROM bug6051_2;
782-
783-
BEGIN; SET LOCAL force_parallel_mode = on;
784-
785-
WITH t1 AS ( DELETE FROM bug6051_3 RETURNING * )
786-
INSERT INTO bug6051_3 SELECT * FROM t1;
787-
788-
COMMIT;
789-
790-
SELECT * FROM bug6051_3;
791-
792776
-- a truly recursive CTE in the same list
793777
WITH RECURSIVE t(a) AS (
794778
SELECT 0

0 commit comments

Comments
 (0)