aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-11-30 16:32:56 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2020-11-30 16:33:09 -0500
commita095e04f63a47ef02ec98577cc1fc4e4542e5ddd (patch)
tree5d5339b7ffe8f3f072df972d089d24225c11b2f7
parent3fe0e7c3fa27de80419de9ce66be2767d2ddae57 (diff)
downloadpostgresql-a095e04f63a47ef02ec98577cc1fc4e4542e5ddd.tar.gz
postgresql-a095e04f63a47ef02ec98577cc1fc4e4542e5ddd.zip
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
-rw-r--r--src/backend/nodes/outfuncs.c23
-rw-r--r--src/backend/optimizer/README1
-rw-r--r--src/backend/optimizer/util/pathnode.c4
-rw-r--r--src/include/nodes/pathnodes.h5
-rw-r--r--src/include/optimizer/pathnode.h12
5 files changed, 34 insertions, 11 deletions
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index e2f177515da..07c93b4737a 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -1955,13 +1955,29 @@ _outProjectSetPath(StringInfo str, const ProjectSetPath *node)
}
static void
+_outSortPathInfo(StringInfo str, const SortPath *node)
+{
+ _outPathInfo(str, (const Path *) node);
+
+ WRITE_NODE_FIELD(subpath);
+}
+
+static void
_outSortPath(StringInfo str, const SortPath *node)
{
WRITE_NODE_TYPE("SORTPATH");
- _outPathInfo(str, (const Path *) node);
+ _outSortPathInfo(str, node);
+}
- WRITE_NODE_FIELD(subpath);
+static void
+_outIncrementalSortPath(StringInfo str, const IncrementalSortPath *node)
+{
+ WRITE_NODE_TYPE("INCREMENTALSORTPATH");
+
+ _outSortPathInfo(str, (const SortPath *) node);
+
+ WRITE_INT_FIELD(nPresortedCols);
}
static void
@@ -4058,6 +4074,9 @@ outNode(StringInfo str, const void *obj)
case T_SortPath:
_outSortPath(str, obj);
break;
+ case T_IncrementalSortPath:
+ _outIncrementalSortPath(str, obj);
+ break;
case T_GroupPath:
_outGroupPath(str, obj);
break;
diff --git a/src/backend/optimizer/README b/src/backend/optimizer/README
index d174b8cb73a..efb52858c88 100644
--- a/src/backend/optimizer/README
+++ b/src/backend/optimizer/README
@@ -387,6 +387,7 @@ RelOptInfo - a relation or joined relations
ProjectionPath - a Result plan node with child (used for projection)
ProjectSetPath - a ProjectSet plan node applied to some sub-path
SortPath - a Sort plan node applied to some sub-path
+ IncrementalSortPath - an IncrementalSort plan node applied to some sub-path
GroupPath - a Group plan node applied to some sub-path
UpperUniquePath - a Unique plan node applied to some sub-path
AggPath - an Agg plan node applied to some sub-path
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c
index c1fc866cbf9..5778f80c01e 100644
--- a/src/backend/optimizer/util/pathnode.c
+++ b/src/backend/optimizer/util/pathnode.c
@@ -2798,7 +2798,7 @@ create_set_projection_path(PlannerInfo *root,
* 'limit_tuples' is the estimated bound on the number of output tuples,
* or -1 if no LIMIT or couldn't estimate
*/
-SortPath *
+IncrementalSortPath *
create_incremental_sort_path(PlannerInfo *root,
RelOptInfo *rel,
Path *subpath,
@@ -2834,7 +2834,7 @@ create_incremental_sort_path(PlannerInfo *root,
sort->nPresortedCols = presorted_keys;
- return pathnode;
+ return sort;
}
/*
diff --git a/src/include/nodes/pathnodes.h b/src/include/nodes/pathnodes.h
index 8d1ad3339f2..10f0a149e91 100644
--- a/src/include/nodes/pathnodes.h
+++ b/src/include/nodes/pathnodes.h
@@ -1650,7 +1650,10 @@ typedef struct SortPath
} SortPath;
/*
- * IncrementalSortPath
+ * IncrementalSortPath represents an incremental sort step
+ *
+ * This is like a regular sort, except some leading key columns are assumed
+ * to be ordered already.
*/
typedef struct IncrementalSortPath
{
diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h
index 715a24ad29a..3bd7072ae8c 100644
--- a/src/include/optimizer/pathnode.h
+++ b/src/include/optimizer/pathnode.h
@@ -184,17 +184,17 @@ extern ProjectSetPath *create_set_projection_path(PlannerInfo *root,
RelOptInfo *rel,
Path *subpath,
PathTarget *target);
-extern SortPath *create_incremental_sort_path(PlannerInfo *root,
- RelOptInfo *rel,
- Path *subpath,
- List *pathkeys,
- int presorted_keys,
- double limit_tuples);
extern SortPath *create_sort_path(PlannerInfo *root,
RelOptInfo *rel,
Path *subpath,
List *pathkeys,
double limit_tuples);
+extern IncrementalSortPath *create_incremental_sort_path(PlannerInfo *root,
+ RelOptInfo *rel,
+ Path *subpath,
+ List *pathkeys,
+ int presorted_keys,
+ double limit_tuples);
extern GroupPath *create_group_path(PlannerInfo *root,
RelOptInfo *rel,
Path *subpath,