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

Commit 06fe1d1

Browse files
author
Commitfest Bot
committed
[CF 5708] v2 - don't generate fake alias names, only fake eref names
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/5708 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/CA+TgmoYt1eKQvER4eua3KAkLNPpjQdBM=iTy7OtSKNWtn=eVbQ@mail.gmail.com Author(s): Robert Haas
2 parents 2c6469d + 108e4ba commit 06fe1d1

File tree

9 files changed

+32
-35
lines changed

9 files changed

+32
-35
lines changed

contrib/postgres_fdw/expected/postgres_fdw.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5077,13 +5077,13 @@ SELECT ft1.c1 FROM ft1 JOIN ft2 on ft1.c1 = ft2.c1 WHERE
50775077
-- ===================================================================
50785078
EXPLAIN (verbose, costs off)
50795079
INSERT INTO ft2 (c1,c2,c3) SELECT c1+1000,c2+100, c3 || c3 FROM ft2 LIMIT 20;
5080-
QUERY PLAN
5081-
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
5080+
QUERY PLAN
5081+
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
50825082
Insert on public.ft2
50835083
Remote SQL: INSERT INTO "S 1"."T 1"("C 1", c2, c3, c4, c5, c6, c7, c8) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
50845084
Batch Size: 1
5085-
-> Subquery Scan on "*SELECT*"
5086-
Output: "*SELECT*"."?column?", "*SELECT*"."?column?_1", NULL::integer, "*SELECT*"."?column?_2", NULL::timestamp with time zone, NULL::timestamp without time zone, NULL::character varying(10), 'ft2 '::character(10), NULL::user_enum
5085+
-> Subquery Scan on unnamed_subquery
5086+
Output: unnamed_subquery."?column?", unnamed_subquery."?column?_1", NULL::integer, unnamed_subquery."?column?_2", NULL::timestamp with time zone, NULL::timestamp without time zone, NULL::character varying(10), 'ft2 '::character(10), NULL::user_enum
50875087
-> Foreign Scan on public.ft2 ft2_1
50885088
Output: (ft2_1.c1 + 1000), (ft2_1.c2 + 100), (ft2_1.c3 || ft2_1.c3)
50895089
Remote SQL: SELECT "C 1", c2, c3 FROM "S 1"."T 1" LIMIT 20::bigint

src/backend/executor/functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2455,7 +2455,7 @@ check_sql_stmt_retval(List *queryTreeList,
24552455
rte = makeNode(RangeTblEntry);
24562456
rte->rtekind = RTE_SUBQUERY;
24572457
rte->subquery = parse;
2458-
rte->eref = rte->alias = makeAlias("*SELECT*", colnames);
2458+
rte->eref = makeAlias("unnamed_subquery", colnames);
24592459
rte->lateral = false;
24602460
rte->inh = false;
24612461
rte->inFromCl = true;

src/backend/optimizer/plan/subselect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ convert_ANY_sublink_to_join(PlannerInfo *root, SubLink *sublink,
13971397
*/
13981398
nsitem = addRangeTableEntryForSubquery(pstate,
13991399
subselect,
1400-
makeAlias("ANY_subquery", NIL),
1400+
NULL,
14011401
use_lateral,
14021402
false);
14031403
rte = nsitem->p_rte;

src/backend/parser/analyze.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
862862
*/
863863
nsitem = addRangeTableEntryForSubquery(pstate,
864864
selectQuery,
865-
makeAlias("*SELECT*", NIL),
865+
NULL,
866866
false,
867867
false);
868868
addNSItemToQuery(pstate, nsitem, true, false, false);
@@ -2185,7 +2185,6 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt,
21852185
{
21862186
/* Process leaf SELECT */
21872187
Query *selectQuery;
2188-
char selectName[32];
21892188
ParseNamespaceItem *nsitem;
21902189
RangeTblRef *rtr;
21912190
ListCell *tl;
@@ -2241,11 +2240,9 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt,
22412240
/*
22422241
* Make the leaf query be a subquery in the top-level rangetable.
22432242
*/
2244-
snprintf(selectName, sizeof(selectName), "*SELECT* %d",
2245-
list_length(pstate->p_rtable) + 1);
22462243
nsitem = addRangeTableEntryForSubquery(pstate,
22472244
selectQuery,
2248-
makeAlias(selectName, NIL),
2245+
NULL,
22492246
false,
22502247
false);
22512248

src/backend/rewrite/rewriteSearchCycle.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ rewriteSearchAndCycle(CommonTableExpr *cte)
282282

283283
newrte = makeNode(RangeTblEntry);
284284
newrte->rtekind = RTE_SUBQUERY;
285-
newrte->alias = makeAlias("*TLOCRN*", cte->ctecolnames);
286-
newrte->eref = newrte->alias;
285+
newrte->alias = NULL;
286+
newrte->eref = makeAlias("*TLOCRN*", cte->ctecolnames);
287287
newsubquery = copyObject(rte1->subquery);
288288
IncrementVarSublevelsUp((Node *) newsubquery, 1, 1);
289289
newrte->subquery = newsubquery;
@@ -379,8 +379,8 @@ rewriteSearchAndCycle(CommonTableExpr *cte)
379379
ewcl = lappend(ewcl, makeString(cte->cycle_clause->cycle_mark_column));
380380
ewcl = lappend(ewcl, makeString(cte->cycle_clause->cycle_path_column));
381381
}
382-
newrte->alias = makeAlias("*TROCRN*", ewcl);
383-
newrte->eref = newrte->alias;
382+
newrte->alias = NULL;
383+
newrte->eref = makeAlias("*TROCRN*", ewcl);
384384

385385
/*
386386
* Find the reference to the recursive CTE in the right UNION subquery's

src/test/regress/expected/partition_prune.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4758,7 +4758,7 @@ select min(a) over (partition by a order by a) from part_abc where a >= stable_o
47584758
QUERY PLAN
47594759
----------------------------------------------------------------------------------------------
47604760
Append
4761-
-> Subquery Scan on "*SELECT* 1_1"
4761+
-> Subquery Scan on unnamed_subquery_2
47624762
-> WindowAgg
47634763
Window: w1 AS (PARTITION BY part_abc.a ORDER BY part_abc.a)
47644764
-> Append
@@ -4775,7 +4775,7 @@ select min(a) over (partition by a order by a) from part_abc where a >= stable_o
47754775
-> Index Scan using part_abc_3_2_a_idx on part_abc_3_2 part_abc_4
47764776
Index Cond: (a >= (stable_one() + 1))
47774777
Filter: (d <= stable_one())
4778-
-> Subquery Scan on "*SELECT* 2"
4778+
-> Subquery Scan on unnamed_subquery_1
47794779
-> WindowAgg
47804780
Window: w1 AS (PARTITION BY part_abc_5.a ORDER BY part_abc_5.a)
47814781
-> Append

src/test/regress/expected/rangefuncs.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,10 +2130,10 @@ select testrngfunc();
21302130

21312131
explain (verbose, costs off)
21322132
select * from testrngfunc();
2133-
QUERY PLAN
2134-
----------------------------------------------------------
2135-
Subquery Scan on "*SELECT*"
2136-
Output: "*SELECT*"."?column?", "*SELECT*"."?column?_1"
2133+
QUERY PLAN
2134+
----------------------------------------------------------------------
2135+
Subquery Scan on unnamed_subquery
2136+
Output: unnamed_subquery."?column?", unnamed_subquery."?column?_1"
21372137
-> Unique
21382138
Output: (1), (2)
21392139
-> Sort

src/test/regress/expected/subselect.out

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,14 +1467,14 @@ select * from int4_tbl o where (f1, f1) in
14671467
-------------------------------------------------------------------
14681468
Nested Loop Semi Join
14691469
Output: o.f1
1470-
Join Filter: (o.f1 = "ANY_subquery".f1)
1470+
Join Filter: (o.f1 = unnamed_subquery.f1)
14711471
-> Seq Scan on public.int4_tbl o
14721472
Output: o.f1
14731473
-> Materialize
1474-
Output: "ANY_subquery".f1, "ANY_subquery".g
1475-
-> Subquery Scan on "ANY_subquery"
1476-
Output: "ANY_subquery".f1, "ANY_subquery".g
1477-
Filter: ("ANY_subquery".f1 = "ANY_subquery".g)
1474+
Output: unnamed_subquery.f1, unnamed_subquery.g
1475+
-> Subquery Scan on unnamed_subquery
1476+
Output: unnamed_subquery.f1, unnamed_subquery.g
1477+
Filter: (unnamed_subquery.f1 = unnamed_subquery.g)
14781478
-> Result
14791479
Output: i.f1, ((generate_series(1, 50)) / 10)
14801480
-> ProjectSet
@@ -2642,8 +2642,8 @@ ON B.hundred in (SELECT min(c.hundred) FROM tenk2 C WHERE c.odd = b.odd);
26422642
-> Memoize
26432643
Cache Key: b.hundred, b.odd
26442644
Cache Mode: binary
2645-
-> Subquery Scan on "ANY_subquery"
2646-
Filter: (b.hundred = "ANY_subquery".min)
2645+
-> Subquery Scan on unnamed_subquery
2646+
Filter: (b.hundred = unnamed_subquery.min)
26472647
-> Result
26482648
InitPlan 1
26492649
-> Limit

src/test/regress/expected/union.out

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ SELECT q1 FROM int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1;
942942
ERROR: column "q2" does not exist
943943
LINE 1: ... int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1...
944944
^
945-
DETAIL: There is a column named "q2" in table "*SELECT* 2", but it cannot be referenced from this part of the query.
945+
DETAIL: There is a column named "q2" in table "unnamed_subquery", but it cannot be referenced from this part of the query.
946946
-- But this should work:
947947
SELECT q1 FROM int8_tbl EXCEPT (((SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1))) ORDER BY 1;
948948
q1
@@ -1338,14 +1338,14 @@ where q2 = q2;
13381338
----------------------------------------------------------
13391339
Unique
13401340
-> Merge Append
1341-
Sort Key: "*SELECT* 1".q1
1342-
-> Subquery Scan on "*SELECT* 1"
1341+
Sort Key: unnamed_subquery.q1
1342+
-> Subquery Scan on unnamed_subquery
13431343
-> Unique
13441344
-> Sort
13451345
Sort Key: i81.q1, i81.q2
13461346
-> Seq Scan on int8_tbl i81
13471347
Filter: (q2 IS NOT NULL)
1348-
-> Subquery Scan on "*SELECT* 2"
1348+
-> Subquery Scan on unnamed_subquery_1
13491349
-> Unique
13501350
-> Sort
13511351
Sort Key: i82.q1, i82.q2
@@ -1374,14 +1374,14 @@ where -q1 = q2;
13741374
--------------------------------------------------------
13751375
Unique
13761376
-> Merge Append
1377-
Sort Key: "*SELECT* 1".q1
1378-
-> Subquery Scan on "*SELECT* 1"
1377+
Sort Key: unnamed_subquery.q1
1378+
-> Subquery Scan on unnamed_subquery
13791379
-> Unique
13801380
-> Sort
13811381
Sort Key: i81.q1, i81.q2
13821382
-> Seq Scan on int8_tbl i81
13831383
Filter: ((- q1) = q2)
1384-
-> Subquery Scan on "*SELECT* 2"
1384+
-> Subquery Scan on unnamed_subquery_1
13851385
-> Unique
13861386
-> Sort
13871387
Sort Key: i82.q1, i82.q2

0 commit comments

Comments
 (0)