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

Commit 0c1af2c

Browse files
committed
Rename PathKeyInfo to GroupByOrdering
0452b46 made optimizer explore alternative orderings of group-by pathkeys. The PathKeyInfo data structure was used to store the particular ordering of group-by pathkeys and corresponding clauses. It turns out that PathKeyInfo is not the best name for that purpose. This commit renames this data structure to GroupByOrdering, and revises its comment. Discussion: https://postgr.es/m/db0fc3a4-966c-4cec-a136-94024d39212d%40postgrespro.ru Reported-by: Tom Lane Author: Andrei Lepikhov Reviewed-by: Alexander Korotkov, Pavel Borisov
1 parent 91143c0 commit 0c1af2c

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

src/backend/optimizer/path/pathkeys.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ group_keys_reorder_by_pathkeys(List *pathkeys, List **group_pathkeys,
450450
/*
451451
* pathkeys_are_duplicate
452452
* Check if give pathkeys are already contained the list of
453-
* PathKeyInfo's.
453+
* GroupByOrdering's.
454454
*/
455455
static bool
456456
pathkeys_are_duplicate(List *infos, List *pathkeys)
@@ -459,7 +459,7 @@ pathkeys_are_duplicate(List *infos, List *pathkeys)
459459

460460
foreach(lc, infos)
461461
{
462-
PathKeyInfo *info = lfirst_node(PathKeyInfo, lc);
462+
GroupByOrdering *info = lfirst_node(GroupByOrdering, lc);
463463

464464
if (compare_pathkeys(pathkeys, info->pathkeys) == PATHKEYS_EQUAL)
465465
return true;
@@ -471,7 +471,7 @@ pathkeys_are_duplicate(List *infos, List *pathkeys)
471471
* get_useful_group_keys_orderings
472472
* Determine which orderings of GROUP BY keys are potentially interesting.
473473
*
474-
* Returns a list of PathKeyInfo items, each representing an interesting
474+
* Returns a list of GroupByOrdering items, each representing an interesting
475475
* ordering of GROUP BY keys. Each item stores pathkeys and clauses in the
476476
* matching order.
477477
*
@@ -486,13 +486,13 @@ get_useful_group_keys_orderings(PlannerInfo *root, Path *path)
486486
{
487487
Query *parse = root->parse;
488488
List *infos = NIL;
489-
PathKeyInfo *info;
489+
GroupByOrdering *info;
490490

491491
List *pathkeys = root->group_pathkeys;
492492
List *clauses = root->processed_groupClause;
493493

494494
/* always return at least the original pathkeys/clauses */
495-
info = makeNode(PathKeyInfo);
495+
info = makeNode(GroupByOrdering);
496496
info->pathkeys = pathkeys;
497497
info->clauses = clauses;
498498
infos = lappend(infos, info);
@@ -528,7 +528,7 @@ get_useful_group_keys_orderings(PlannerInfo *root, Path *path)
528528
(enable_incremental_sort || n == root->num_groupby_pathkeys) &&
529529
!pathkeys_are_duplicate(infos, pathkeys))
530530
{
531-
info = makeNode(PathKeyInfo);
531+
info = makeNode(GroupByOrdering);
532532
info->pathkeys = pathkeys;
533533
info->clauses = clauses;
534534

@@ -553,7 +553,7 @@ get_useful_group_keys_orderings(PlannerInfo *root, Path *path)
553553
(enable_incremental_sort || n == list_length(root->sort_pathkeys)) &&
554554
!pathkeys_are_duplicate(infos, pathkeys))
555555
{
556-
info = makeNode(PathKeyInfo);
556+
info = makeNode(GroupByOrdering);
557557
info->pathkeys = pathkeys;
558558
info->clauses = clauses;
559559

@@ -563,7 +563,7 @@ get_useful_group_keys_orderings(PlannerInfo *root, Path *path)
563563

564564
#ifdef USE_ASSERT_CHECKING
565565
{
566-
PathKeyInfo *pinfo = linitial_node(PathKeyInfo, infos);
566+
GroupByOrdering *pinfo = linitial_node(GroupByOrdering, infos);
567567
ListCell *lc;
568568

569569
/* Test consistency of info structures */
@@ -572,7 +572,7 @@ get_useful_group_keys_orderings(PlannerInfo *root, Path *path)
572572
ListCell *lc1,
573573
*lc2;
574574

575-
info = lfirst_node(PathKeyInfo, lc);
575+
info = lfirst_node(GroupByOrdering, lc);
576576

577577
Assert(list_length(info->clauses) == list_length(pinfo->clauses));
578578
Assert(list_length(info->pathkeys) == list_length(pinfo->pathkeys));

src/backend/optimizer/plan/planner.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -6917,7 +6917,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
69176917

69186918
foreach(lc2, pathkey_orderings)
69196919
{
6920-
PathKeyInfo *info = (PathKeyInfo *) lfirst(lc2);
6920+
GroupByOrdering *info = (GroupByOrdering *) lfirst(lc2);
69216921

69226922
/* restore the path (we replace it in the loop) */
69236923
path = path_save;
@@ -6998,7 +6998,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
69986998
/* process all potentially interesting grouping reorderings */
69996999
foreach(lc2, pathkey_orderings)
70007000
{
7001-
PathKeyInfo *info = (PathKeyInfo *) lfirst(lc2);
7001+
GroupByOrdering *info = (GroupByOrdering *) lfirst(lc2);
70027002

70037003
/* restore the path (we replace it in the loop) */
70047004
path = path_save;
@@ -7249,7 +7249,7 @@ create_partial_grouping_paths(PlannerInfo *root,
72497249
/* process all potentially interesting grouping reorderings */
72507250
foreach(lc2, pathkey_orderings)
72517251
{
7252-
PathKeyInfo *info = (PathKeyInfo *) lfirst(lc2);
7252+
GroupByOrdering *info = (GroupByOrdering *) lfirst(lc2);
72537253

72547254
/* restore the path (we replace it in the loop) */
72557255
path = path_save;
@@ -7305,7 +7305,7 @@ create_partial_grouping_paths(PlannerInfo *root,
73057305
/* process all potentially interesting grouping reorderings */
73067306
foreach(lc2, pathkey_orderings)
73077307
{
7308-
PathKeyInfo *info = (PathKeyInfo *) lfirst(lc2);
7308+
GroupByOrdering *info = (GroupByOrdering *) lfirst(lc2);
73097309

73107310

73117311
/* restore the path (we replace it in the loop) */

src/include/nodes/pathnodes.h

+10-3
Original file line numberDiff line numberDiff line change
@@ -1468,14 +1468,21 @@ typedef struct PathKey
14681468
} PathKey;
14691469

14701470
/*
1471-
* Combines the information about pathkeys and the associated clauses.
1471+
* Contains an order of group-by clauses and the corresponding list of
1472+
* pathkeys.
1473+
*
1474+
* The elements of 'clauses' list should have the same order as the head of
1475+
* 'pathkeys' list. The tleSortGroupRef of the clause should be equal to
1476+
* ec_sortref of the pathkey equivalence class. If there are redundant
1477+
* clauses with the same tleSortGroupRef, they must be grouped together.
14721478
*/
1473-
typedef struct PathKeyInfo
1479+
typedef struct GroupByOrdering
14741480
{
14751481
NodeTag type;
1482+
14761483
List *pathkeys;
14771484
List *clauses;
1478-
} PathKeyInfo;
1485+
} GroupByOrdering;
14791486

14801487
/*
14811488
* VolatileFunctionStatus -- allows nodes to cache their

src/tools/pgindent/typedefs.list

+1-1
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,7 @@ GrantRoleStmt
10561056
GrantStmt
10571057
GrantTargetType
10581058
Group
1059+
GroupByOrdering
10591060
GroupClause
10601061
GroupPath
10611062
GroupPathExtraData
@@ -2067,7 +2068,6 @@ PathClauseUsage
20672068
PathCostComparison
20682069
PathHashStack
20692070
PathKey
2070-
PathKeyInfo
20712071
PathKeysComparison
20722072
PathTarget
20732073
PatternInfo

0 commit comments

Comments
 (0)