Skip to content

Commit 7b3b260

Browse files
committed
Cleanup old CREATE INDEX stuff
1 parent a0f3d3b commit 7b3b260

File tree

2 files changed

+10
-103
lines changed

2 files changed

+10
-103
lines changed

src/backend/optimizer/plan/planner.c

Lines changed: 4 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ static bool choose_hashed_distinct(PlannerInfo *root,
108108
static List *make_subplanTargetList(PlannerInfo *root, List *tlist,
109109
AttrNumber **groupColIdx, bool *need_tlist_eval);
110110
static int get_grouping_column_index(Query *parse, TargetEntry *tle);
111-
static int get_sort_column_index(Query *parse, TargetEntry *tle);
112111
static void locate_grouping_columns(PlannerInfo *root,
113112
List *tlist,
114113
List *sub_tlist,
@@ -2460,13 +2459,6 @@ grouping_planner(PlannerInfo *root, double tuple_fraction)
24602459
parse->limitCount,
24612460
offset_est,
24622461
count_est);
2463-
if (parse->sortClause && tlist != result_plan->targetlist)
2464-
{
2465-
result_plan = (Plan *) make_result(root,
2466-
tlist,
2467-
NULL,
2468-
result_plan);
2469-
}
24702462
}
24712463

24722464
/*
@@ -4033,8 +4025,8 @@ make_subplanTargetList(PlannerInfo *root,
40334025
bool *need_tlist_eval)
40344026
{
40354027
Query *parse = root->parse;
4036-
List *sub_tlist = NIL;
4037-
List *non_group_cols = NIL;
4028+
List *sub_tlist;
4029+
List *non_group_cols;
40384030
List *non_group_vars;
40394031
int numCols;
40404032

@@ -4047,61 +4039,6 @@ make_subplanTargetList(PlannerInfo *root,
40474039
if (!parse->hasAggs && !parse->groupClause && !parse->groupingSets && !root->hasHavingQual &&
40484040
!parse->hasWindowFuncs)
40494041
{
4050-
if (parse->sortClause && limit_needed(parse)) {
4051-
ListCell *tl;
4052-
bool contains_non_vars = false;
4053-
*need_tlist_eval = false; /* only eval if not flat tlist */
4054-
foreach(tl, tlist)
4055-
{
4056-
TargetEntry *tle = (TargetEntry *) lfirst(tl);
4057-
int colno;
4058-
4059-
colno = get_sort_column_index(parse, tle);
4060-
if (colno >= 0)
4061-
{
4062-
TargetEntry *newtle;
4063-
4064-
newtle = makeTargetEntry(tle->expr,
4065-
list_length(sub_tlist) + 1,
4066-
NULL,
4067-
false);
4068-
sub_tlist = lappend(sub_tlist, newtle);
4069-
if (!(newtle->expr && IsA(newtle->expr, Var)))
4070-
*need_tlist_eval = true; /* tlist contains non Vars */
4071-
}
4072-
else
4073-
{
4074-
/*
4075-
* Non-sorting column, so just remember the expression for
4076-
* later call to pull_var_clause. There's no need for
4077-
* pull_var_clause to examine the TargetEntry node itself.
4078-
*/
4079-
non_group_cols = lappend(non_group_cols, tle->expr);
4080-
contains_non_vars |= !(tle->expr && IsA(tle->expr, Var));
4081-
}
4082-
}
4083-
4084-
if (non_group_cols) /* there are some columns not used in order by */
4085-
{
4086-
non_group_vars = pull_var_clause((Node *) non_group_cols,
4087-
PVC_RECURSE_AGGREGATES,
4088-
PVC_INCLUDE_PLACEHOLDERS);
4089-
sub_tlist = add_to_flat_tlist(sub_tlist, non_group_vars);
4090-
/* clean up cruft */
4091-
list_free(non_group_vars);
4092-
list_free(non_group_cols);
4093-
4094-
if (contains_non_vars )
4095-
{
4096-
/*
4097-
* This optimization makes sense only if target list contains some complex expressions,
4098-
* for example functions calls. May be it is better to check cost of this expressions,
4099-
* but right now just apply this optimization if there are non-vars columns
4100-
*/
4101-
return sub_tlist;
4102-
}
4103-
}
4104-
}
41054042
*need_tlist_eval = true;
41064043
return tlist;
41074044
}
@@ -4110,6 +4047,8 @@ make_subplanTargetList(PlannerInfo *root,
41104047
* Otherwise, we must build a tlist containing all grouping columns, plus
41114048
* any other Vars mentioned in the targetlist and HAVING qual.
41124049
*/
4050+
sub_tlist = NIL;
4051+
non_group_cols = NIL;
41134052
*need_tlist_eval = false; /* only eval if not flat tlist */
41144053

41154054
numCols = list_length(parse->groupClause);
@@ -4231,37 +4170,6 @@ get_grouping_column_index(Query *parse, TargetEntry *tle)
42314170
return -1;
42324171
}
42334172

4234-
/*
4235-
* get_sort_column_index
4236-
* Get the ORDER BY column position, if any, of a targetlist entry.
4237-
*
4238-
* Returns the index (counting from 0) of the TLE in the ORDER BY list, or -1
4239-
* if it's not a sorting column. Note: the result is unique because the
4240-
* parser won't make multiple sortClause entries for the same TLE.
4241-
*/
4242-
static int
4243-
get_sort_column_index(Query *parse, TargetEntry *tle)
4244-
{
4245-
int colno = 0;
4246-
Index ressortgroupref = tle->ressortgroupref;
4247-
ListCell *gl;
4248-
4249-
/* No need to search groupClause if TLE hasn't got a sortgroupref */
4250-
if (ressortgroupref == 0)
4251-
return -1;
4252-
4253-
foreach(gl, parse->sortClause)
4254-
{
4255-
SortGroupClause *sortcl = (SortGroupClause *) lfirst(gl);
4256-
4257-
if (sortcl->tleSortGroupRef == ressortgroupref)
4258-
return colno;
4259-
colno++;
4260-
}
4261-
4262-
return -1;
4263-
}
4264-
42654173
/*
42664174
* locate_grouping_columns
42674175
* Locate grouping columns in the tlist chosen by create_plan.

src/test/regress/expected/create_index.out

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,13 +1208,12 @@ SELECT * FROM gpolygon_tbl ORDER BY f1 <-> '(0,0)'::point LIMIT 10;
12081208

12091209
EXPLAIN (COSTS OFF)
12101210
SELECT circle_center(f1), round(radius(f1)) as radius FROM gcircle_tbl ORDER BY f1 <-> '(200,300)'::point LIMIT 10;
1211-
QUERY PLAN
1212-
---------------------------------------------------------
1213-
Result
1214-
-> Limit
1215-
-> Index Scan using ggcircleind on gcircle_tbl
1216-
Order By: (f1 <-> '(200,300)'::point)
1217-
(4 rows)
1211+
QUERY PLAN
1212+
---------------------------------------------------
1213+
Limit
1214+
-> Index Scan using ggcircleind on gcircle_tbl
1215+
Order By: (f1 <-> '(200,300)'::point)
1216+
(3 rows)
12181217

12191218
SELECT circle_center(f1), round(radius(f1)) as radius FROM gcircle_tbl ORDER BY f1 <-> '(200,300)'::point LIMIT 10;
12201219
circle_center | radius

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy