mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Support window functions a la SQL:2008.
Hitoshi Harada, with some kibitzing from Heikki and Tom.
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.416 2008/12/19 16:25:17 petere Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.417 2008/12/28 18:53:55 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -668,6 +668,32 @@ _copyAgg(Agg *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyWindowAgg
|
||||
*/
|
||||
static WindowAgg *
|
||||
_copyWindowAgg(WindowAgg *from)
|
||||
{
|
||||
WindowAgg *newnode = makeNode(WindowAgg);
|
||||
|
||||
CopyPlanFields((Plan *) from, (Plan *) newnode);
|
||||
|
||||
COPY_SCALAR_FIELD(partNumCols);
|
||||
if (from->partNumCols > 0)
|
||||
{
|
||||
COPY_POINTER_FIELD(partColIdx, from->partNumCols * sizeof(AttrNumber));
|
||||
COPY_POINTER_FIELD(partOperators, from->partNumCols * sizeof(Oid));
|
||||
}
|
||||
COPY_SCALAR_FIELD(ordNumCols);
|
||||
if (from->ordNumCols > 0)
|
||||
{
|
||||
COPY_POINTER_FIELD(ordColIdx, from->ordNumCols * sizeof(AttrNumber));
|
||||
COPY_POINTER_FIELD(ordOperators, from->ordNumCols * sizeof(Oid));
|
||||
}
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyUnique
|
||||
*/
|
||||
@ -931,6 +957,25 @@ _copyAggref(Aggref *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyWindowFunc
|
||||
*/
|
||||
static WindowFunc *
|
||||
_copyWindowFunc(WindowFunc *from)
|
||||
{
|
||||
WindowFunc *newnode = makeNode(WindowFunc);
|
||||
|
||||
COPY_SCALAR_FIELD(winfnoid);
|
||||
COPY_SCALAR_FIELD(wintype);
|
||||
COPY_NODE_FIELD(args);
|
||||
COPY_SCALAR_FIELD(winref);
|
||||
COPY_SCALAR_FIELD(winstar);
|
||||
COPY_SCALAR_FIELD(winagg);
|
||||
COPY_LOCATION_FIELD(location);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyArrayRef
|
||||
*/
|
||||
@ -1729,6 +1774,21 @@ _copySortGroupClause(SortGroupClause *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static WindowClause *
|
||||
_copyWindowClause(WindowClause *from)
|
||||
{
|
||||
WindowClause *newnode = makeNode(WindowClause);
|
||||
|
||||
COPY_STRING_FIELD(name);
|
||||
COPY_STRING_FIELD(refname);
|
||||
COPY_NODE_FIELD(partitionClause);
|
||||
COPY_NODE_FIELD(orderClause);
|
||||
COPY_SCALAR_FIELD(winref);
|
||||
COPY_SCALAR_FIELD(copiedOrder);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static RowMarkClause *
|
||||
_copyRowMarkClause(RowMarkClause *from)
|
||||
{
|
||||
@ -1850,6 +1910,7 @@ _copyFuncCall(FuncCall *from)
|
||||
COPY_SCALAR_FIELD(agg_star);
|
||||
COPY_SCALAR_FIELD(agg_distinct);
|
||||
COPY_SCALAR_FIELD(func_variadic);
|
||||
COPY_NODE_FIELD(over);
|
||||
COPY_LOCATION_FIELD(location);
|
||||
|
||||
return newnode;
|
||||
@ -1940,6 +2001,20 @@ _copySortBy(SortBy *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static WindowDef *
|
||||
_copyWindowDef(WindowDef *from)
|
||||
{
|
||||
WindowDef *newnode = makeNode(WindowDef);
|
||||
|
||||
COPY_STRING_FIELD(name);
|
||||
COPY_STRING_FIELD(refname);
|
||||
COPY_NODE_FIELD(partitionClause);
|
||||
COPY_NODE_FIELD(orderClause);
|
||||
COPY_LOCATION_FIELD(location);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static RangeSubselect *
|
||||
_copyRangeSubselect(RangeSubselect *from)
|
||||
{
|
||||
@ -2081,6 +2156,7 @@ _copyQuery(Query *from)
|
||||
COPY_SCALAR_FIELD(resultRelation);
|
||||
COPY_NODE_FIELD(intoClause);
|
||||
COPY_SCALAR_FIELD(hasAggs);
|
||||
COPY_SCALAR_FIELD(hasWindowFuncs);
|
||||
COPY_SCALAR_FIELD(hasSubLinks);
|
||||
COPY_SCALAR_FIELD(hasDistinctOn);
|
||||
COPY_SCALAR_FIELD(hasRecursive);
|
||||
@ -2091,6 +2167,7 @@ _copyQuery(Query *from)
|
||||
COPY_NODE_FIELD(returningList);
|
||||
COPY_NODE_FIELD(groupClause);
|
||||
COPY_NODE_FIELD(havingQual);
|
||||
COPY_NODE_FIELD(windowClause);
|
||||
COPY_NODE_FIELD(distinctClause);
|
||||
COPY_NODE_FIELD(sortClause);
|
||||
COPY_NODE_FIELD(limitOffset);
|
||||
@ -2153,6 +2230,7 @@ _copySelectStmt(SelectStmt *from)
|
||||
COPY_NODE_FIELD(whereClause);
|
||||
COPY_NODE_FIELD(groupClause);
|
||||
COPY_NODE_FIELD(havingClause);
|
||||
COPY_NODE_FIELD(windowClause);
|
||||
COPY_NODE_FIELD(withClause);
|
||||
COPY_NODE_FIELD(valuesLists);
|
||||
COPY_NODE_FIELD(sortClause);
|
||||
@ -3440,6 +3518,9 @@ copyObject(void *from)
|
||||
case T_Agg:
|
||||
retval = _copyAgg(from);
|
||||
break;
|
||||
case T_WindowAgg:
|
||||
retval = _copyWindowAgg(from);
|
||||
break;
|
||||
case T_Unique:
|
||||
retval = _copyUnique(from);
|
||||
break;
|
||||
@ -3480,6 +3561,9 @@ copyObject(void *from)
|
||||
case T_Aggref:
|
||||
retval = _copyAggref(from);
|
||||
break;
|
||||
case T_WindowFunc:
|
||||
retval = _copyWindowFunc(from);
|
||||
break;
|
||||
case T_ArrayRef:
|
||||
retval = _copyArrayRef(from);
|
||||
break;
|
||||
@ -3951,6 +4035,9 @@ copyObject(void *from)
|
||||
case T_SortBy:
|
||||
retval = _copySortBy(from);
|
||||
break;
|
||||
case T_WindowDef:
|
||||
retval = _copyWindowDef(from);
|
||||
break;
|
||||
case T_RangeSubselect:
|
||||
retval = _copyRangeSubselect(from);
|
||||
break;
|
||||
@ -3984,6 +4071,9 @@ copyObject(void *from)
|
||||
case T_SortGroupClause:
|
||||
retval = _copySortGroupClause(from);
|
||||
break;
|
||||
case T_WindowClause:
|
||||
retval = _copyWindowClause(from);
|
||||
break;
|
||||
case T_RowMarkClause:
|
||||
retval = _copyRowMarkClause(from);
|
||||
break;
|
||||
|
@ -22,7 +22,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.341 2008/12/19 16:25:17 petere Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.342 2008/12/28 18:53:56 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -191,6 +191,20 @@ _equalAggref(Aggref *a, Aggref *b)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalWindowFunc(WindowFunc *a, WindowFunc *b)
|
||||
{
|
||||
COMPARE_SCALAR_FIELD(winfnoid);
|
||||
COMPARE_SCALAR_FIELD(wintype);
|
||||
COMPARE_NODE_FIELD(args);
|
||||
COMPARE_SCALAR_FIELD(winref);
|
||||
COMPARE_SCALAR_FIELD(winstar);
|
||||
COMPARE_SCALAR_FIELD(winagg);
|
||||
COMPARE_LOCATION_FIELD(location);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalArrayRef(ArrayRef *a, ArrayRef *b)
|
||||
{
|
||||
@ -839,6 +853,7 @@ _equalQuery(Query *a, Query *b)
|
||||
COMPARE_SCALAR_FIELD(resultRelation);
|
||||
COMPARE_NODE_FIELD(intoClause);
|
||||
COMPARE_SCALAR_FIELD(hasAggs);
|
||||
COMPARE_SCALAR_FIELD(hasWindowFuncs);
|
||||
COMPARE_SCALAR_FIELD(hasSubLinks);
|
||||
COMPARE_SCALAR_FIELD(hasDistinctOn);
|
||||
COMPARE_SCALAR_FIELD(hasRecursive);
|
||||
@ -849,6 +864,7 @@ _equalQuery(Query *a, Query *b)
|
||||
COMPARE_NODE_FIELD(returningList);
|
||||
COMPARE_NODE_FIELD(groupClause);
|
||||
COMPARE_NODE_FIELD(havingQual);
|
||||
COMPARE_NODE_FIELD(windowClause);
|
||||
COMPARE_NODE_FIELD(distinctClause);
|
||||
COMPARE_NODE_FIELD(sortClause);
|
||||
COMPARE_NODE_FIELD(limitOffset);
|
||||
@ -903,6 +919,7 @@ _equalSelectStmt(SelectStmt *a, SelectStmt *b)
|
||||
COMPARE_NODE_FIELD(whereClause);
|
||||
COMPARE_NODE_FIELD(groupClause);
|
||||
COMPARE_NODE_FIELD(havingClause);
|
||||
COMPARE_NODE_FIELD(windowClause);
|
||||
COMPARE_NODE_FIELD(withClause);
|
||||
COMPARE_NODE_FIELD(valuesLists);
|
||||
COMPARE_NODE_FIELD(sortClause);
|
||||
@ -1894,6 +1911,7 @@ _equalFuncCall(FuncCall *a, FuncCall *b)
|
||||
COMPARE_SCALAR_FIELD(agg_star);
|
||||
COMPARE_SCALAR_FIELD(agg_distinct);
|
||||
COMPARE_SCALAR_FIELD(func_variadic);
|
||||
COMPARE_NODE_FIELD(over);
|
||||
COMPARE_LOCATION_FIELD(location);
|
||||
|
||||
return true;
|
||||
@ -1980,6 +1998,18 @@ _equalSortBy(SortBy *a, SortBy *b)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalWindowDef(WindowDef *a, WindowDef *b)
|
||||
{
|
||||
COMPARE_STRING_FIELD(name);
|
||||
COMPARE_STRING_FIELD(refname);
|
||||
COMPARE_NODE_FIELD(partitionClause);
|
||||
COMPARE_NODE_FIELD(orderClause);
|
||||
COMPARE_LOCATION_FIELD(location);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalRangeSubselect(RangeSubselect *a, RangeSubselect *b)
|
||||
{
|
||||
@ -2106,6 +2136,19 @@ _equalSortGroupClause(SortGroupClause *a, SortGroupClause *b)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalWindowClause(WindowClause *a, WindowClause *b)
|
||||
{
|
||||
COMPARE_STRING_FIELD(name);
|
||||
COMPARE_STRING_FIELD(refname);
|
||||
COMPARE_NODE_FIELD(partitionClause);
|
||||
COMPARE_NODE_FIELD(orderClause);
|
||||
COMPARE_SCALAR_FIELD(winref);
|
||||
COMPARE_SCALAR_FIELD(copiedOrder);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalRowMarkClause(RowMarkClause *a, RowMarkClause *b)
|
||||
{
|
||||
@ -2311,6 +2354,9 @@ equal(void *a, void *b)
|
||||
case T_Aggref:
|
||||
retval = _equalAggref(a, b);
|
||||
break;
|
||||
case T_WindowFunc:
|
||||
retval = _equalWindowFunc(a, b);
|
||||
break;
|
||||
case T_ArrayRef:
|
||||
retval = _equalArrayRef(a, b);
|
||||
break;
|
||||
@ -2769,6 +2815,9 @@ equal(void *a, void *b)
|
||||
case T_SortBy:
|
||||
retval = _equalSortBy(a, b);
|
||||
break;
|
||||
case T_WindowDef:
|
||||
retval = _equalWindowDef(a, b);
|
||||
break;
|
||||
case T_RangeSubselect:
|
||||
retval = _equalRangeSubselect(a, b);
|
||||
break;
|
||||
@ -2802,6 +2851,9 @@ equal(void *a, void *b)
|
||||
case T_SortGroupClause:
|
||||
retval = _equalSortGroupClause(a, b);
|
||||
break;
|
||||
case T_WindowClause:
|
||||
retval = _equalWindowClause(a, b);
|
||||
break;
|
||||
case T_RowMarkClause:
|
||||
retval = _equalRowMarkClause(a, b);
|
||||
break;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/nodeFuncs.c,v 1.35 2008/10/21 20:42:52 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/nodeFuncs.c,v 1.36 2008/12/28 18:53:56 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -52,6 +52,9 @@ exprType(Node *expr)
|
||||
case T_Aggref:
|
||||
type = ((Aggref *) expr)->aggtype;
|
||||
break;
|
||||
case T_WindowFunc:
|
||||
type = ((WindowFunc *) expr)->wintype;
|
||||
break;
|
||||
case T_ArrayRef:
|
||||
{
|
||||
ArrayRef *arrayref = (ArrayRef *) expr;
|
||||
@ -548,6 +551,8 @@ expression_returns_set_walker(Node *node, void *context)
|
||||
/* Avoid recursion for some cases that can't return a set */
|
||||
if (IsA(node, Aggref))
|
||||
return false;
|
||||
if (IsA(node, WindowFunc))
|
||||
return false;
|
||||
if (IsA(node, DistinctExpr))
|
||||
return false;
|
||||
if (IsA(node, ScalarArrayOpExpr))
|
||||
@ -634,6 +639,10 @@ exprLocation(Node *expr)
|
||||
/* function name should always be the first thing */
|
||||
loc = ((Aggref *) expr)->location;
|
||||
break;
|
||||
case T_WindowFunc:
|
||||
/* function name should always be the first thing */
|
||||
loc = ((WindowFunc *) expr)->location;
|
||||
break;
|
||||
case T_ArrayRef:
|
||||
/* just use array argument's location */
|
||||
loc = exprLocation((Node *) ((ArrayRef *) expr)->refexpr);
|
||||
@ -868,6 +877,9 @@ exprLocation(Node *expr)
|
||||
/* just use argument's location (ignore operator, if any) */
|
||||
loc = exprLocation(((SortBy *) expr)->node);
|
||||
break;
|
||||
case T_WindowDef:
|
||||
loc = ((WindowDef *) expr)->location;
|
||||
break;
|
||||
case T_TypeName:
|
||||
loc = ((TypeName *) expr)->location;
|
||||
break;
|
||||
@ -1045,6 +1057,16 @@ expression_tree_walker(Node *node,
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case T_WindowFunc:
|
||||
{
|
||||
WindowFunc *expr = (WindowFunc *) node;
|
||||
|
||||
/* recurse directly on List */
|
||||
if (expression_tree_walker((Node *) expr->args,
|
||||
walker, context))
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case T_ArrayRef:
|
||||
{
|
||||
ArrayRef *aref = (ArrayRef *) node;
|
||||
@ -1221,6 +1243,16 @@ expression_tree_walker(Node *node,
|
||||
case T_Query:
|
||||
/* Do nothing with a sub-Query, per discussion above */
|
||||
break;
|
||||
case T_WindowClause:
|
||||
{
|
||||
WindowClause *wc = (WindowClause *) node;
|
||||
|
||||
if (walker(wc->partitionClause, context))
|
||||
return true;
|
||||
if (walker(wc->orderClause, context))
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case T_CommonTableExpr:
|
||||
{
|
||||
CommonTableExpr *cte = (CommonTableExpr *) node;
|
||||
@ -1539,6 +1571,16 @@ expression_tree_mutator(Node *node,
|
||||
return (Node *) newnode;
|
||||
}
|
||||
break;
|
||||
case T_WindowFunc:
|
||||
{
|
||||
WindowFunc *wfunc = (WindowFunc *) node;
|
||||
WindowFunc *newnode;
|
||||
|
||||
FLATCOPY(newnode, wfunc, WindowFunc);
|
||||
MUTATE(newnode->args, wfunc->args, List *);
|
||||
return (Node *) newnode;
|
||||
}
|
||||
break;
|
||||
case T_ArrayRef:
|
||||
{
|
||||
ArrayRef *arrayref = (ArrayRef *) node;
|
||||
@ -1848,6 +1890,17 @@ expression_tree_mutator(Node *node,
|
||||
case T_Query:
|
||||
/* Do nothing with a sub-Query, per discussion above */
|
||||
return node;
|
||||
case T_WindowClause:
|
||||
{
|
||||
WindowClause *wc = (WindowClause *) node;
|
||||
WindowClause *newnode;
|
||||
|
||||
FLATCOPY(newnode, wc, WindowClause);
|
||||
MUTATE(newnode->partitionClause, wc->partitionClause, List *);
|
||||
MUTATE(newnode->orderClause, wc->orderClause, List *);
|
||||
return (Node *) newnode;
|
||||
}
|
||||
break;
|
||||
case T_CommonTableExpr:
|
||||
{
|
||||
CommonTableExpr *cte = (CommonTableExpr *) node;
|
||||
@ -2280,6 +2333,8 @@ raw_expression_tree_walker(Node *node, bool (*walker) (), void *context)
|
||||
return true;
|
||||
if (walker(stmt->havingClause, context))
|
||||
return true;
|
||||
if (walker(stmt->windowClause, context))
|
||||
return true;
|
||||
if (walker(stmt->withClause, context))
|
||||
return true;
|
||||
if (walker(stmt->valuesLists, context))
|
||||
@ -2318,6 +2373,8 @@ raw_expression_tree_walker(Node *node, bool (*walker) (), void *context)
|
||||
|
||||
if (walker(fcall->args, context))
|
||||
return true;
|
||||
if (walker(fcall->over, context))
|
||||
return true;
|
||||
/* function name is deemed uninteresting */
|
||||
}
|
||||
break;
|
||||
@ -2365,6 +2422,16 @@ raw_expression_tree_walker(Node *node, bool (*walker) (), void *context)
|
||||
break;
|
||||
case T_SortBy:
|
||||
return walker(((SortBy *) node)->node, context);
|
||||
case T_WindowDef:
|
||||
{
|
||||
WindowDef *wd = (WindowDef *) node;
|
||||
|
||||
if (walker(wd->partitionClause, context))
|
||||
return true;
|
||||
if (walker(wd->orderClause, context))
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case T_RangeSubselect:
|
||||
{
|
||||
RangeSubselect *rs = (RangeSubselect *) node;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.346 2008/12/01 21:06:12 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.347 2008/12/28 18:53:56 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Every node type that can appear in stored rules' parsetrees *must*
|
||||
@ -566,6 +566,36 @@ _outAgg(StringInfo str, Agg *node)
|
||||
WRITE_LONG_FIELD(numGroups);
|
||||
}
|
||||
|
||||
static void
|
||||
_outWindowAgg(StringInfo str, WindowAgg *node)
|
||||
{
|
||||
int i;
|
||||
|
||||
WRITE_NODE_TYPE("WINDOWAGG");
|
||||
|
||||
_outPlanInfo(str, (Plan *) node);
|
||||
|
||||
WRITE_INT_FIELD(partNumCols);
|
||||
|
||||
appendStringInfo(str, " :partColIdx");
|
||||
for (i = 0; i < node->partNumCols; i++)
|
||||
appendStringInfo(str, " %d", node->partColIdx[i]);
|
||||
|
||||
appendStringInfo(str, " :partOperations");
|
||||
for (i = 0; i < node->partNumCols; i++)
|
||||
appendStringInfo(str, " %u", node->partOperators[i]);
|
||||
|
||||
WRITE_INT_FIELD(ordNumCols);
|
||||
|
||||
appendStringInfo(str, " :ordColIdx");
|
||||
for (i = 0; i< node->ordNumCols; i++)
|
||||
appendStringInfo(str, " %d", node->ordColIdx[i]);
|
||||
|
||||
appendStringInfo(str, " :ordOperations");
|
||||
for (i = 0; i < node->ordNumCols; i++)
|
||||
appendStringInfo(str, " %u", node->ordOperators[i]);
|
||||
}
|
||||
|
||||
static void
|
||||
_outGroup(StringInfo str, Group *node)
|
||||
{
|
||||
@ -798,6 +828,20 @@ _outAggref(StringInfo str, Aggref *node)
|
||||
WRITE_LOCATION_FIELD(location);
|
||||
}
|
||||
|
||||
static void
|
||||
_outWindowFunc(StringInfo str, WindowFunc *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("WINDOWFUNC");
|
||||
|
||||
WRITE_OID_FIELD(winfnoid);
|
||||
WRITE_OID_FIELD(wintype);
|
||||
WRITE_NODE_FIELD(args);
|
||||
WRITE_UINT_FIELD(winref);
|
||||
WRITE_BOOL_FIELD(winstar);
|
||||
WRITE_BOOL_FIELD(winagg);
|
||||
WRITE_LOCATION_FIELD(location);
|
||||
}
|
||||
|
||||
static void
|
||||
_outArrayRef(StringInfo str, ArrayRef *node)
|
||||
{
|
||||
@ -1440,6 +1484,7 @@ _outPlannerInfo(StringInfo str, PlannerInfo *node)
|
||||
WRITE_NODE_FIELD(placeholder_list);
|
||||
WRITE_NODE_FIELD(query_pathkeys);
|
||||
WRITE_NODE_FIELD(group_pathkeys);
|
||||
WRITE_NODE_FIELD(window_pathkeys);
|
||||
WRITE_NODE_FIELD(distinct_pathkeys);
|
||||
WRITE_NODE_FIELD(sort_pathkeys);
|
||||
WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
|
||||
@ -1722,6 +1767,7 @@ _outSelectStmt(StringInfo str, SelectStmt *node)
|
||||
WRITE_NODE_FIELD(whereClause);
|
||||
WRITE_NODE_FIELD(groupClause);
|
||||
WRITE_NODE_FIELD(havingClause);
|
||||
WRITE_NODE_FIELD(windowClause);
|
||||
WRITE_NODE_FIELD(withClause);
|
||||
WRITE_NODE_FIELD(valuesLists);
|
||||
WRITE_NODE_FIELD(sortClause);
|
||||
@ -1744,6 +1790,7 @@ _outFuncCall(StringInfo str, FuncCall *node)
|
||||
WRITE_BOOL_FIELD(agg_star);
|
||||
WRITE_BOOL_FIELD(agg_distinct);
|
||||
WRITE_BOOL_FIELD(func_variadic);
|
||||
WRITE_NODE_FIELD(over);
|
||||
WRITE_LOCATION_FIELD(location);
|
||||
}
|
||||
|
||||
@ -1866,6 +1913,7 @@ _outQuery(StringInfo str, Query *node)
|
||||
WRITE_INT_FIELD(resultRelation);
|
||||
WRITE_NODE_FIELD(intoClause);
|
||||
WRITE_BOOL_FIELD(hasAggs);
|
||||
WRITE_BOOL_FIELD(hasWindowFuncs);
|
||||
WRITE_BOOL_FIELD(hasSubLinks);
|
||||
WRITE_BOOL_FIELD(hasDistinctOn);
|
||||
WRITE_BOOL_FIELD(hasRecursive);
|
||||
@ -1876,6 +1924,7 @@ _outQuery(StringInfo str, Query *node)
|
||||
WRITE_NODE_FIELD(returningList);
|
||||
WRITE_NODE_FIELD(groupClause);
|
||||
WRITE_NODE_FIELD(havingQual);
|
||||
WRITE_NODE_FIELD(windowClause);
|
||||
WRITE_NODE_FIELD(distinctClause);
|
||||
WRITE_NODE_FIELD(sortClause);
|
||||
WRITE_NODE_FIELD(limitOffset);
|
||||
@ -1895,6 +1944,19 @@ _outSortGroupClause(StringInfo str, SortGroupClause *node)
|
||||
WRITE_BOOL_FIELD(nulls_first);
|
||||
}
|
||||
|
||||
static void
|
||||
_outWindowClause(StringInfo str, WindowClause *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("WINDOWCLAUSE");
|
||||
|
||||
WRITE_STRING_FIELD(name);
|
||||
WRITE_STRING_FIELD(refname);
|
||||
WRITE_NODE_FIELD(partitionClause);
|
||||
WRITE_NODE_FIELD(orderClause);
|
||||
WRITE_UINT_FIELD(winref);
|
||||
WRITE_BOOL_FIELD(copiedOrder);
|
||||
}
|
||||
|
||||
static void
|
||||
_outRowMarkClause(StringInfo str, RowMarkClause *node)
|
||||
{
|
||||
@ -2171,6 +2233,18 @@ _outSortBy(StringInfo str, SortBy *node)
|
||||
WRITE_LOCATION_FIELD(location);
|
||||
}
|
||||
|
||||
static void
|
||||
_outWindowDef(StringInfo str, WindowDef *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("WINDOWDEF");
|
||||
|
||||
WRITE_STRING_FIELD(name);
|
||||
WRITE_STRING_FIELD(refname);
|
||||
WRITE_NODE_FIELD(partitionClause);
|
||||
WRITE_NODE_FIELD(orderClause);
|
||||
WRITE_LOCATION_FIELD(location);
|
||||
}
|
||||
|
||||
static void
|
||||
_outRangeSubselect(StringInfo str, RangeSubselect *node)
|
||||
{
|
||||
@ -2347,6 +2421,9 @@ _outNode(StringInfo str, void *obj)
|
||||
case T_Agg:
|
||||
_outAgg(str, obj);
|
||||
break;
|
||||
case T_WindowAgg:
|
||||
_outWindowAgg(str, obj);
|
||||
break;
|
||||
case T_Group:
|
||||
_outGroup(str, obj);
|
||||
break;
|
||||
@ -2392,6 +2469,9 @@ _outNode(StringInfo str, void *obj)
|
||||
case T_Aggref:
|
||||
_outAggref(str, obj);
|
||||
break;
|
||||
case T_WindowFunc:
|
||||
_outWindowFunc(str, obj);
|
||||
break;
|
||||
case T_ArrayRef:
|
||||
_outArrayRef(str, obj);
|
||||
break;
|
||||
@ -2616,6 +2696,9 @@ _outNode(StringInfo str, void *obj)
|
||||
case T_SortGroupClause:
|
||||
_outSortGroupClause(str, obj);
|
||||
break;
|
||||
case T_WindowClause:
|
||||
_outWindowClause(str, obj);
|
||||
break;
|
||||
case T_RowMarkClause:
|
||||
_outRowMarkClause(str, obj);
|
||||
break;
|
||||
@ -2661,6 +2744,9 @@ _outNode(StringInfo str, void *obj)
|
||||
case T_SortBy:
|
||||
_outSortBy(str, obj);
|
||||
break;
|
||||
case T_WindowDef:
|
||||
_outWindowDef(str, obj);
|
||||
break;
|
||||
case T_RangeSubselect:
|
||||
_outRangeSubselect(str, obj);
|
||||
break;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.217 2008/11/15 19:43:46 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.218 2008/12/28 18:53:56 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Path and Plan nodes do not have any readfuncs support, because we
|
||||
@ -153,6 +153,7 @@ _readQuery(void)
|
||||
READ_INT_FIELD(resultRelation);
|
||||
READ_NODE_FIELD(intoClause);
|
||||
READ_BOOL_FIELD(hasAggs);
|
||||
READ_BOOL_FIELD(hasWindowFuncs);
|
||||
READ_BOOL_FIELD(hasSubLinks);
|
||||
READ_BOOL_FIELD(hasDistinctOn);
|
||||
READ_BOOL_FIELD(hasRecursive);
|
||||
@ -163,6 +164,7 @@ _readQuery(void)
|
||||
READ_NODE_FIELD(returningList);
|
||||
READ_NODE_FIELD(groupClause);
|
||||
READ_NODE_FIELD(havingQual);
|
||||
READ_NODE_FIELD(windowClause);
|
||||
READ_NODE_FIELD(distinctClause);
|
||||
READ_NODE_FIELD(sortClause);
|
||||
READ_NODE_FIELD(limitOffset);
|
||||
@ -217,6 +219,24 @@ _readSortGroupClause(void)
|
||||
READ_DONE();
|
||||
}
|
||||
|
||||
/*
|
||||
* _readWindowClause
|
||||
*/
|
||||
static WindowClause *
|
||||
_readWindowClause(void)
|
||||
{
|
||||
READ_LOCALS(WindowClause);
|
||||
|
||||
READ_STRING_FIELD(name);
|
||||
READ_STRING_FIELD(refname);
|
||||
READ_NODE_FIELD(partitionClause);
|
||||
READ_NODE_FIELD(orderClause);
|
||||
READ_UINT_FIELD(winref);
|
||||
READ_BOOL_FIELD(copiedOrder);
|
||||
|
||||
READ_DONE();
|
||||
}
|
||||
|
||||
/*
|
||||
* _readRowMarkClause
|
||||
*/
|
||||
@ -402,6 +422,25 @@ _readAggref(void)
|
||||
READ_DONE();
|
||||
}
|
||||
|
||||
/*
|
||||
* _readWindowFunc
|
||||
*/
|
||||
static WindowFunc *
|
||||
_readWindowFunc(void)
|
||||
{
|
||||
READ_LOCALS(WindowFunc);
|
||||
|
||||
READ_OID_FIELD(winfnoid);
|
||||
READ_OID_FIELD(wintype);
|
||||
READ_NODE_FIELD(args);
|
||||
READ_UINT_FIELD(winref);
|
||||
READ_BOOL_FIELD(winstar);
|
||||
READ_BOOL_FIELD(winagg);
|
||||
READ_LOCATION_FIELD(location);
|
||||
|
||||
READ_DONE();
|
||||
}
|
||||
|
||||
/*
|
||||
* _readArrayRef
|
||||
*/
|
||||
@ -1091,6 +1130,8 @@ parseNodeString(void)
|
||||
return_value = _readQuery();
|
||||
else if (MATCH("SORTGROUPCLAUSE", 15))
|
||||
return_value = _readSortGroupClause();
|
||||
else if (MATCH("WINDOWCLAUSE", 12))
|
||||
return_value = _readWindowClause();
|
||||
else if (MATCH("ROWMARKCLAUSE", 13))
|
||||
return_value = _readRowMarkClause();
|
||||
else if (MATCH("COMMONTABLEEXPR", 15))
|
||||
@ -1111,6 +1152,8 @@ parseNodeString(void)
|
||||
return_value = _readParam();
|
||||
else if (MATCH("AGGREF", 6))
|
||||
return_value = _readAggref();
|
||||
else if (MATCH("WINDOWFUNC", 10))
|
||||
return_value = _readWindowFunc();
|
||||
else if (MATCH("ARRAYREF", 8))
|
||||
return_value = _readArrayRef();
|
||||
else if (MATCH("FUNCEXPR", 8))
|
||||
|
Reference in New Issue
Block a user