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

Commit a095e04

Browse files
committed
Fix missing outfuncs.c support for IncrementalSortPath.
For debugging purposes, Path nodes are supposed to have outfuncs support, but this was overlooked in the original incremental sort patch. While at it, clean up a couple other minor oversights, as well as bizarre choice of return type for create_incremental_sort_path(). (All the existing callers just cast it to "Path *" immediately, so they don't care, but some future caller might care.) outfuncs.c fix by Zhijie Hou, the rest by me Discussion: https://postgr.es/m/324c4d81d8134117972a5b1f6cdf9560@G08CNEXMBPEKD05.g08.fujitsu.local
1 parent 3fe0e7c commit a095e04

File tree

5 files changed

+34
-11
lines changed

5 files changed

+34
-11
lines changed

src/backend/nodes/outfuncs.c

+21-2
Original file line numberDiff line numberDiff line change
@@ -1954,14 +1954,30 @@ _outProjectSetPath(StringInfo str, const ProjectSetPath *node)
19541954
WRITE_NODE_FIELD(subpath);
19551955
}
19561956

1957+
static void
1958+
_outSortPathInfo(StringInfo str, const SortPath *node)
1959+
{
1960+
_outPathInfo(str, (const Path *) node);
1961+
1962+
WRITE_NODE_FIELD(subpath);
1963+
}
1964+
19571965
static void
19581966
_outSortPath(StringInfo str, const SortPath *node)
19591967
{
19601968
WRITE_NODE_TYPE("SORTPATH");
19611969

1962-
_outPathInfo(str, (const Path *) node);
1970+
_outSortPathInfo(str, node);
1971+
}
19631972

1964-
WRITE_NODE_FIELD(subpath);
1973+
static void
1974+
_outIncrementalSortPath(StringInfo str, const IncrementalSortPath *node)
1975+
{
1976+
WRITE_NODE_TYPE("INCREMENTALSORTPATH");
1977+
1978+
_outSortPathInfo(str, (const SortPath *) node);
1979+
1980+
WRITE_INT_FIELD(nPresortedCols);
19651981
}
19661982

19671983
static void
@@ -4058,6 +4074,9 @@ outNode(StringInfo str, const void *obj)
40584074
case T_SortPath:
40594075
_outSortPath(str, obj);
40604076
break;
4077+
case T_IncrementalSortPath:
4078+
_outIncrementalSortPath(str, obj);
4079+
break;
40614080
case T_GroupPath:
40624081
_outGroupPath(str, obj);
40634082
break;

src/backend/optimizer/README

+1
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ RelOptInfo - a relation or joined relations
387387
ProjectionPath - a Result plan node with child (used for projection)
388388
ProjectSetPath - a ProjectSet plan node applied to some sub-path
389389
SortPath - a Sort plan node applied to some sub-path
390+
IncrementalSortPath - an IncrementalSort plan node applied to some sub-path
390391
GroupPath - a Group plan node applied to some sub-path
391392
UpperUniquePath - a Unique plan node applied to some sub-path
392393
AggPath - an Agg plan node applied to some sub-path

src/backend/optimizer/util/pathnode.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2798,7 +2798,7 @@ create_set_projection_path(PlannerInfo *root,
27982798
* 'limit_tuples' is the estimated bound on the number of output tuples,
27992799
* or -1 if no LIMIT or couldn't estimate
28002800
*/
2801-
SortPath *
2801+
IncrementalSortPath *
28022802
create_incremental_sort_path(PlannerInfo *root,
28032803
RelOptInfo *rel,
28042804
Path *subpath,
@@ -2834,7 +2834,7 @@ create_incremental_sort_path(PlannerInfo *root,
28342834

28352835
sort->nPresortedCols = presorted_keys;
28362836

2837-
return pathnode;
2837+
return sort;
28382838
}
28392839

28402840
/*

src/include/nodes/pathnodes.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,10 @@ typedef struct SortPath
16501650
} SortPath;
16511651

16521652
/*
1653-
* IncrementalSortPath
1653+
* IncrementalSortPath represents an incremental sort step
1654+
*
1655+
* This is like a regular sort, except some leading key columns are assumed
1656+
* to be ordered already.
16541657
*/
16551658
typedef struct IncrementalSortPath
16561659
{

src/include/optimizer/pathnode.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,17 @@ extern ProjectSetPath *create_set_projection_path(PlannerInfo *root,
184184
RelOptInfo *rel,
185185
Path *subpath,
186186
PathTarget *target);
187-
extern SortPath *create_incremental_sort_path(PlannerInfo *root,
188-
RelOptInfo *rel,
189-
Path *subpath,
190-
List *pathkeys,
191-
int presorted_keys,
192-
double limit_tuples);
193187
extern SortPath *create_sort_path(PlannerInfo *root,
194188
RelOptInfo *rel,
195189
Path *subpath,
196190
List *pathkeys,
197191
double limit_tuples);
192+
extern IncrementalSortPath *create_incremental_sort_path(PlannerInfo *root,
193+
RelOptInfo *rel,
194+
Path *subpath,
195+
List *pathkeys,
196+
int presorted_keys,
197+
double limit_tuples);
198198
extern GroupPath *create_group_path(PlannerInfo *root,
199199
RelOptInfo *rel,
200200
Path *subpath,

0 commit comments

Comments
 (0)