Commit 1401f63d authored by Bruce Momjian's avatar Bruce Momjian

Agg/Aggreg cleanup and datetime.sql patch.

parent 247b3f90
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.40 1999/01/24 00:28:18 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.41 1999/01/25 18:02:13 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -67,7 +67,7 @@ bool execConstByVal; ...@@ -67,7 +67,7 @@ bool execConstByVal;
int execConstLen; int execConstLen;
/* static functions decls */ /* static functions decls */
static Datum ExecEvalAggref(Aggref *agg, ExprContext *econtext, bool *isNull); static Datum ExecEvalAggref(Aggref *aggref, ExprContext *econtext, bool *isNull);
static Datum ExecEvalArrayRef(ArrayRef *arrayRef, ExprContext *econtext, static Datum ExecEvalArrayRef(ArrayRef *arrayRef, ExprContext *econtext,
bool *isNull, bool *isDone); bool *isNull, bool *isDone);
static Datum ExecEvalAnd(Expr *andExpr, ExprContext *econtext, bool *isNull); static Datum ExecEvalAnd(Expr *andExpr, ExprContext *econtext, bool *isNull);
...@@ -192,10 +192,10 @@ ExecEvalArrayRef(ArrayRef *arrayRef, ...@@ -192,10 +192,10 @@ ExecEvalArrayRef(ArrayRef *arrayRef,
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
static Datum static Datum
ExecEvalAggref(Aggref *agg, ExprContext *econtext, bool *isNull) ExecEvalAggref(Aggref *aggref, ExprContext *econtext, bool *isNull)
{ {
*isNull = econtext->ecxt_nulls[agg->aggno]; *isNull = econtext->ecxt_nulls[aggref->aggno];
return econtext->ecxt_values[agg->aggno]; return econtext->ecxt_values[aggref->aggno];
} }
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
......
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.54 1999/01/24 00:28:19 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.55 1999/01/25 18:02:14 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -506,7 +506,7 @@ _copyAgg(Agg *from) ...@@ -506,7 +506,7 @@ _copyAgg(Agg *from)
CopyPlanFields((Plan *) from, (Plan *) newnode); CopyPlanFields((Plan *) from, (Plan *) newnode);
newnode->aggs = set_agg_tlist_references(newnode); newnode->aggs = get_agg_tlist_references(newnode);
Node_Copy(from, newnode, aggstate); Node_Copy(from, newnode, aggstate);
return newnode; return newnode;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.37 1999/01/25 12:01:04 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.38 1999/01/25 18:02:15 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -249,7 +249,7 @@ union_planner(Query *parse) ...@@ -249,7 +249,7 @@ union_planner(Query *parse)
{ {
int old_length=0, new_length=0; int old_length=0, new_length=0;
/* Create the AGG node but use 'tlist' not 'new_tlist' as target list because we /* Create the Agg node but use 'tlist' not 'new_tlist' as target list because we
* don't want the additional attributes (only used for the havingQual, see above) * don't want the additional attributes (only used for the havingQual, see above)
* to show up in the result */ * to show up in the result */
result_plan = (Plan *) make_agg(tlist, result_plan); result_plan = (Plan *) make_agg(tlist, result_plan);
...@@ -259,7 +259,7 @@ union_planner(Query *parse) ...@@ -259,7 +259,7 @@ union_planner(Query *parse)
* the result tuple of the subplans. * the result tuple of the subplans.
*/ */
((Agg *) result_plan)->aggs = ((Agg *) result_plan)->aggs =
set_agg_tlist_references((Agg *) result_plan); get_agg_tlist_references((Agg *) result_plan);
/***S*H***/ /***S*H***/
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.32 1999/01/24 00:28:20 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.33 1999/01/25 18:02:18 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -700,7 +700,7 @@ OperandIsInner(Node *opnd, int inner_relid) ...@@ -700,7 +700,7 @@ OperandIsInner(Node *opnd, int inner_relid)
/*--------------------------------------------------------- /*---------------------------------------------------------
* *
* set_agg_tlist_references - * get_agg_tlist_references -
* changes the target list of an Agg node so that it points to * changes the target list of an Agg node so that it points to
* the tuples returned by its left tree subplan. * the tuples returned by its left tree subplan.
* *
...@@ -708,7 +708,7 @@ OperandIsInner(Node *opnd, int inner_relid) ...@@ -708,7 +708,7 @@ OperandIsInner(Node *opnd, int inner_relid)
* *
*/ */
List * List *
set_agg_tlist_references(Agg *aggNode) get_agg_tlist_references(Agg *aggNode)
{ {
List *aggTargetList; List *aggTargetList;
List *subplanTargetList; List *subplanTargetList;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.15 1999/01/24 00:28:30 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.16 1999/01/25 18:02:18 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -68,9 +68,9 @@ nodeThisLockWasTriggered(Node *node, int varno, AttrNumber attnum, ...@@ -68,9 +68,9 @@ nodeThisLockWasTriggered(Node *node, int varno, AttrNumber attnum,
break; break;
case T_Aggref: case T_Aggref:
{ {
Aggref *agg = (Aggref *) node; Aggref *aggref = (Aggref *) node;
return nodeThisLockWasTriggered(agg->target, varno, attnum, return nodeThisLockWasTriggered(aggref->target, varno, attnum,
sublevels_up); sublevels_up);
} }
break; break;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.31 1999/01/25 12:01:14 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.32 1999/01/25 18:02:20 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -162,10 +162,10 @@ rangeTableEntry_used(Node *node, int rt_index, int sublevels_up) ...@@ -162,10 +162,10 @@ rangeTableEntry_used(Node *node, int rt_index, int sublevels_up)
case T_Aggref: case T_Aggref:
{ {
Aggref *agg = (Aggref *)node; Aggref *aggref = (Aggref *)node;
return rangeTableEntry_used( return rangeTableEntry_used(
(Node *)(agg->target), (Node *)(aggref->target),
rt_index, rt_index,
sublevels_up); sublevels_up);
} }
...@@ -398,10 +398,10 @@ attribute_used(Node *node, int rt_index, int attno, int sublevels_up) ...@@ -398,10 +398,10 @@ attribute_used(Node *node, int rt_index, int attno, int sublevels_up)
case T_Aggref: case T_Aggref:
{ {
Aggref *agg = (Aggref *)node; Aggref *aggref = (Aggref *)node;
return attribute_used( return attribute_used(
(Node *)(agg->target), (Node *)(aggref->target),
rt_index, rt_index,
attno, attno,
sublevels_up); sublevels_up);
...@@ -607,10 +607,10 @@ modifyAggrefUplevel(Node *node) ...@@ -607,10 +607,10 @@ modifyAggrefUplevel(Node *node)
case T_Aggref: case T_Aggref:
{ {
Aggref *agg = (Aggref *)node; Aggref *aggref = (Aggref *)node;
modifyAggrefUplevel( modifyAggrefUplevel(
(Node *)(agg->target)); (Node *)(aggref->target));
} }
break; break;
...@@ -743,10 +743,10 @@ modifyAggrefChangeVarnodes(Node **nodePtr, int rt_index, int new_index, int subl ...@@ -743,10 +743,10 @@ modifyAggrefChangeVarnodes(Node **nodePtr, int rt_index, int new_index, int subl
case T_Aggref: case T_Aggref:
{ {
Aggref *agg = (Aggref *)node; Aggref *aggref = (Aggref *)node;
modifyAggrefChangeVarnodes( modifyAggrefChangeVarnodes(
(Node **)(&(agg->target)), (Node **)(&(aggref->target)),
rt_index, rt_index,
new_index, new_index,
sublevels_up); sublevels_up);
...@@ -933,12 +933,12 @@ modifyAggrefDropQual(Node **nodePtr, Node *orignode, Expr *expr) ...@@ -933,12 +933,12 @@ modifyAggrefDropQual(Node **nodePtr, Node *orignode, Expr *expr)
case T_Aggref: case T_Aggref:
{ {
Aggref *agg = (Aggref *)node; Aggref *aggref = (Aggref *)node;
Aggref *oagg = (Aggref *)orignode; Aggref *oaggref = (Aggref *)orignode;
modifyAggrefDropQual( modifyAggrefDropQual(
(Node **)(&(agg->target)), (Node **)(&(aggref->target)),
(Node *)(oagg->target), (Node *)(oaggref->target),
expr); expr);
} }
break; break;
...@@ -1378,10 +1378,10 @@ apply_RIR_adjust_sublevel(Node *node, int sublevels_up) ...@@ -1378,10 +1378,10 @@ apply_RIR_adjust_sublevel(Node *node, int sublevels_up)
case T_Aggref: case T_Aggref:
{ {
Aggref *agg = (Aggref *)node; Aggref *aggref = (Aggref *)node;
apply_RIR_adjust_sublevel( apply_RIR_adjust_sublevel(
(Node *)(agg->target), (Node *)(aggref->target),
sublevels_up); sublevels_up);
} }
break; break;
...@@ -1527,10 +1527,10 @@ apply_RIR_view(Node **nodePtr, int rt_index, RangeTblEntry *rte, List *tlist, in ...@@ -1527,10 +1527,10 @@ apply_RIR_view(Node **nodePtr, int rt_index, RangeTblEntry *rte, List *tlist, in
case T_Aggref: case T_Aggref:
{ {
Aggref *agg = (Aggref *)node; Aggref *aggref = (Aggref *)node;
apply_RIR_view( apply_RIR_view(
(Node **)(&(agg->target)), (Node **)(&(aggref->target)),
rt_index, rt_index,
rte, rte,
tlist, tlist,
...@@ -1928,10 +1928,10 @@ fireRIRonSubselect(Node *node) ...@@ -1928,10 +1928,10 @@ fireRIRonSubselect(Node *node)
case T_Aggref: case T_Aggref:
{ {
Aggref *agg = (Aggref *)node; Aggref *aggref = (Aggref *)node;
fireRIRonSubselect( fireRIRonSubselect(
(Node *)(agg->target)); (Node *)(aggref->target));
} }
break; break;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.25 1999/01/24 00:28:31 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.26 1999/01/25 18:02:22 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -55,10 +55,10 @@ OffsetVarNodes(Node *node, int offset, int sublevels_up) ...@@ -55,10 +55,10 @@ OffsetVarNodes(Node *node, int offset, int sublevels_up)
case T_Aggref: case T_Aggref:
{ {
Aggref *agg = (Aggref *)node; Aggref *aggref = (Aggref *)node;
OffsetVarNodes( OffsetVarNodes(
(Node *)(agg->target), (Node *)(aggref->target),
offset, offset,
sublevels_up); sublevels_up);
} }
...@@ -273,10 +273,10 @@ ChangeVarNodes(Node *node, int rt_index, int new_index, int sublevels_up) ...@@ -273,10 +273,10 @@ ChangeVarNodes(Node *node, int rt_index, int new_index, int sublevels_up)
case T_Aggref: case T_Aggref:
{ {
Aggref *agg = (Aggref *)node; Aggref *aggref = (Aggref *)node;
ChangeVarNodes( ChangeVarNodes(
(Node *)(agg->target), (Node *)(aggref->target),
rt_index, rt_index,
new_index, new_index,
sublevels_up); sublevels_up);
...@@ -748,9 +748,9 @@ nodeHandleRIRAttributeRule(Node **nodePtr, ...@@ -748,9 +748,9 @@ nodeHandleRIRAttributeRule(Node **nodePtr,
break; break;
case T_Aggref: case T_Aggref:
{ {
Aggref *agg = (Aggref *) node; Aggref *aggref = (Aggref *) node;
nodeHandleRIRAttributeRule(&agg->target, rtable, targetlist, nodeHandleRIRAttributeRule(&aggref->target, rtable, targetlist,
rt_index, attr_num, modified, badsql, rt_index, attr_num, modified, badsql,
sublevels_up); sublevels_up);
} }
...@@ -913,9 +913,9 @@ nodeHandleViewRule(Node **nodePtr, ...@@ -913,9 +913,9 @@ nodeHandleViewRule(Node **nodePtr,
break; break;
case T_Aggref: case T_Aggref:
{ {
Aggref *agg = (Aggref *) node; Aggref *aggref = (Aggref *) node;
nodeHandleViewRule(&(agg->target), rtable, targetlist, nodeHandleViewRule(&(aggref->target), rtable, targetlist,
rt_index, modified, sublevels_up); rt_index, modified, sublevels_up);
} }
break; break;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* out of it's tuple * out of it's tuple
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.7 1999/01/24 00:28:32 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.8 1999/01/25 18:02:23 momjian Exp $
* *
* This software is copyrighted by Jan Wieck - Hamburg. * This software is copyrighted by Jan Wieck - Hamburg.
* *
...@@ -1247,13 +1247,13 @@ get_rule_expr(QryHier *qh, int rt_index, Node *node, bool varprefix) ...@@ -1247,13 +1247,13 @@ get_rule_expr(QryHier *qh, int rt_index, Node *node, bool varprefix)
case T_Aggref: case T_Aggref:
{ {
Aggref *agg = (Aggref *) node; Aggref *aggref = (Aggref *) node;
strcat(buf, "\""); strcat(buf, "\"");
strcat(buf, agg->aggname); strcat(buf, aggref->aggname);
strcat(buf, "\"("); strcat(buf, "\"(");
strcat(buf, get_rule_expr(qh, rt_index, strcat(buf, get_rule_expr(qh, rt_index,
(Node *) (agg->target), varprefix)); (Node *) (aggref->target), varprefix));
strcat(buf, ")"); strcat(buf, ")");
return pstrdup(buf); return pstrdup(buf);
} }
...@@ -1729,10 +1729,10 @@ check_if_rte_used(int rt_index, Node *node, int sup) ...@@ -1729,10 +1729,10 @@ check_if_rte_used(int rt_index, Node *node, int sup)
case T_Aggref: case T_Aggref:
{ {
Aggref *agg = (Aggref *) node; Aggref *aggref = (Aggref *) node;
return check_if_rte_used(rt_index, return check_if_rte_used(rt_index,
(Node *) (agg->target), sup); (Node *) (aggref->target), sup);
} }
break; break;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: planmain.h,v 1.17 1998/10/08 18:30:34 momjian Exp $ * $Id: planmain.h,v 1.18 1999/01/25 18:02:28 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -54,7 +54,7 @@ extern List *join_references(List *clauses, List *outer_tlist, ...@@ -54,7 +54,7 @@ extern List *join_references(List *clauses, List *outer_tlist,
List *inner_tlist); List *inner_tlist);
extern List *index_outerjoin_references(List *inner_indxqual, extern List *index_outerjoin_references(List *inner_indxqual,
List *outer_tlist, Index inner_relid); List *outer_tlist, Index inner_relid);
extern List *set_agg_tlist_references(Agg *aggNode); extern List *get_agg_tlist_references(Agg *aggNode);
extern void set_agg_agglist_references(Agg *aggNode); extern void set_agg_agglist_references(Agg *aggNode);
extern void del_agg_tlist_references(List *tlist); extern void del_agg_tlist_references(List *tlist);
extern List *check_having_qual_for_aggs(Node *clause, extern List *check_having_qual_for_aggs(Node *clause,
......
...@@ -10,6 +10,9 @@ SELECT ('tomorrow'::datetime = ('yesterday'::datetime + '2 days'::timespan)) as ...@@ -10,6 +10,9 @@ SELECT ('tomorrow'::datetime = ('yesterday'::datetime + '2 days'::timespan)) as
SELECT ('current'::datetime = 'now'::datetime) as "True"; SELECT ('current'::datetime = 'now'::datetime) as "True";
SELECT ('now'::datetime - 'current'::datetime) AS "ZeroSecs"; SELECT ('now'::datetime - 'current'::datetime) AS "ZeroSecs";
SET DateStyle = 'Postgres,noneuropean';
SELECT datetime('1994-01-01', '11:00') AS "Jan_01_1994_11am";
CREATE TABLE DATETIME_TBL( d1 datetime); CREATE TABLE DATETIME_TBL( d1 datetime);
INSERT INTO DATETIME_TBL VALUES ('current'); INSERT INTO DATETIME_TBL VALUES ('current');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment