1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

OK, folks, here is the pgindent output.

This commit is contained in:
Bruce Momjian
1998-09-01 04:40:42 +00:00
parent af74855a60
commit fa1a8d6a97
574 changed files with 26509 additions and 24033 deletions

View File

@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.16 1998/09/01 03:24:56 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.17 1998/09/01 04:31:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -28,8 +28,7 @@
#include "nodes/plannodes.h"
#include "optimizer/clauses.h"
static void
ResolveNew(RewriteInfo *info, List *targetlist,
static void ResolveNew(RewriteInfo *info, List *targetlist,
Node **node, int sublevels_up);
@ -55,14 +54,18 @@ OffsetVarNodes(Node *node, int offset)
OffsetVarNodes(agg->target, offset);
}
break;
/* This has to be done to make queries using groupclauses work on views */
case T_GroupClause:
{
GroupClause *group = (GroupClause *) node;
OffsetVarNodes((Node *)(group->entry), offset);
/*
* This has to be done to make queries using groupclauses work
* on views
*/
case T_GroupClause:
{
GroupClause *group = (GroupClause *) node;
OffsetVarNodes((Node *) (group->entry), offset);
}
break;
break;
case T_Expr:
{
Expr *expr = (Expr *) node;
@ -90,16 +93,20 @@ OffsetVarNodes(Node *node, int offset)
{
SubLink *sublink = (SubLink *) node;
/* We also have to adapt the variables used in sublink->lefthand
* and sublink->oper */
OffsetVarNodes((Node *)(sublink->lefthand), offset);
/*
* We also have to adapt the variables used in
* sublink->lefthand and sublink->oper
*/
OffsetVarNodes((Node *) (sublink->lefthand), offset);
/* Make sure the first argument of sublink->oper points to the
* same var as sublink->lefthand does otherwise we will
* run into troubles using aggregates (aggno will not be
* set correctly) */
lfirst(((Expr *) lfirst(sublink->oper))->args) =
lfirst(sublink->lefthand);
/*
* Make sure the first argument of sublink->oper points to
* the same var as sublink->lefthand does otherwise we
* will run into troubles using aggregates (aggno will not
* be set correctly)
*/
lfirst(((Expr *) lfirst(sublink->oper))->args) =
lfirst(sublink->lefthand);
}
break;
default:
@ -129,15 +136,19 @@ ChangeVarNodes(Node *node, int old_varno, int new_varno, int sublevels_up)
ChangeVarNodes(agg->target, old_varno, new_varno, sublevels_up);
}
break;
/* This has to be done to make queries using groupclauses work on views */
case T_GroupClause:
{
GroupClause *group = (GroupClause *) node;
ChangeVarNodes((Node *)(group->entry),old_varno, new_varno,
sublevels_up);
/*
* This has to be done to make queries using groupclauses work
* on views
*/
case T_GroupClause:
{
GroupClause *group = (GroupClause *) node;
ChangeVarNodes((Node *) (group->entry), old_varno, new_varno,
sublevels_up);
}
break;
break;
case T_Expr:
{
@ -156,8 +167,9 @@ ChangeVarNodes(Node *node, int old_varno, int new_varno, int sublevels_up)
var->varno = new_varno;
var->varnoold = new_varno;
}
if (var->varlevelsup > 0) OffsetVarNodes((Node *)var,3);
if (var->varlevelsup > 0)
OffsetVarNodes((Node *) var, 3);
}
break;
case T_List:
@ -176,17 +188,24 @@ ChangeVarNodes(Node *node, int old_varno, int new_varno, int sublevels_up)
ChangeVarNodes((Node *) query->qual, old_varno, new_varno,
sublevels_up + 1);
/* We also have to adapt the variables used in sublink->lefthand
* and sublink->oper */
/*
* We also have to adapt the variables used in
* sublink->lefthand and sublink->oper
*/
ChangeVarNodes((Node *) (sublink->lefthand), old_varno, new_varno,
sublevels_up);
/* Make sure the first argument of sublink->oper points to the
* same var as sublink->lefthand does otherwise we will
* run into troubles using aggregates (aggno will not be
* set correctly */
/* lfirst(((Expr *) lfirst(sublink->oper))->args) =
lfirst(sublink->lefthand); */
/*
* Make sure the first argument of sublink->oper points to
* the same var as sublink->lefthand does otherwise we
* will run into troubles using aggregates (aggno will not
* be set correctly
*/
/*
* lfirst(((Expr *) lfirst(sublink->oper))->args) =
* lfirst(sublink->lefthand);
*/
}
break;
default:
@ -218,7 +237,8 @@ AddQual(Query *parsetree, Node *qual)
void
AddHavingQual(Query *parsetree, Node *havingQual)
{
Node *copy, *old;
Node *copy,
*old;
if (havingQual == NULL)
return;
@ -553,18 +573,22 @@ nodeHandleViewRule(Node **nodePtr,
Aggreg *agg = (Aggreg *) node;
nodeHandleViewRule(&(agg->target), rtable, targetlist,
rt_index, modified, sublevels_up);
rt_index, modified, sublevels_up);
}
break;
/* This has to be done to make queries using groupclauses work on views */
case T_GroupClause:
{
GroupClause *group = (GroupClause *) node;
nodeHandleViewRule((Node **) (&(group->entry)), rtable, targetlist,
rt_index, modified, sublevels_up);
/*
* This has to be done to make queries using groupclauses work
* on views
*/
case T_GroupClause:
{
GroupClause *group = (GroupClause *) node;
nodeHandleViewRule((Node **) (&(group->entry)), rtable, targetlist,
rt_index, modified, sublevels_up);
}
break;
break;
case T_Expr:
{
Expr *expr = (Expr *) node;
@ -580,40 +604,39 @@ nodeHandleViewRule(Node **nodePtr,
int this_varno = var->varno;
int this_varlevelsup = var->varlevelsup;
Node *n;
if (this_varno == rt_index &&
this_varlevelsup == sublevels_up)
{
n = FindMatchingTLEntry(targetlist,
get_attname(getrelid(this_varno,
rtable),
var->varattno));
if (n == NULL)
{
*nodePtr = make_null(((Var *) node)->vartype);
}
else
/* This is a hack: The varlevelsup of the orignal
* variable and the new one should be the same.
* Normally we adapt the node by changing a pointer
* to point to a var contained in 'targetlist'.
* In the targetlist all varlevelsups are 0
* so if we want to change it to the original value
* we have to copy the node before! (Maybe this will
* cause troubles with some sophisticated queries on
* views?) */
{
if(this_varlevelsup>0){
*nodePtr = copyObject(n);
this_varlevelsup == sublevels_up)
{
n = FindMatchingTLEntry(targetlist,
get_attname(getrelid(this_varno,
rtable),
var->varattno));
if (n == NULL)
*nodePtr = make_null(((Var *) node)->vartype);
else
/*
* This is a hack: The varlevelsup of the orignal
* variable and the new one should be the same.
* Normally we adapt the node by changing a
* pointer to point to a var contained in
* 'targetlist'. In the targetlist all
* varlevelsups are 0 so if we want to change it
* to the original value we have to copy the node
* before! (Maybe this will cause troubles with
* some sophisticated queries on views?)
*/
{
if (this_varlevelsup > 0)
*nodePtr = copyObject(n);
else
*nodePtr = n;
((Var *) *nodePtr)->varlevelsup = this_varlevelsup;
}
else {
*nodePtr = n;
}
((Var *)*nodePtr)->varlevelsup = this_varlevelsup;
}
*modified = TRUE;
}
*modified = TRUE;
}
break;
}
case T_List:
@ -634,20 +657,24 @@ nodeHandleViewRule(Node **nodePtr,
Query *query = (Query *) sublink->subselect;
nodeHandleViewRule((Node **) &(query->qual), rtable, targetlist,
rt_index, modified, sublevels_up + 1);
/* We also have to adapt the variables used in sublink->lefthand
* and sublink->oper */
nodeHandleViewRule((Node **) &(sublink->lefthand), rtable,
targetlist, rt_index, modified, sublevels_up);
/* Make sure the first argument of sublink->oper points to the
* same var as sublink->lefthand does otherwise we will
* run into troubles using aggregates (aggno will not be
* set correctly */
rt_index, modified, sublevels_up + 1);
/*
* We also have to adapt the variables used in
* sublink->lefthand and sublink->oper
*/
nodeHandleViewRule((Node **) &(sublink->lefthand), rtable,
targetlist, rt_index, modified, sublevels_up);
/*
* Make sure the first argument of sublink->oper points to
* the same var as sublink->lefthand does otherwise we
* will run into troubles using aggregates (aggno will not
* be set correctly
*/
pfree(lfirst(((Expr *) lfirst(sublink->oper))->args));
lfirst(((Expr *) lfirst(sublink->oper))->args) =
lfirst(sublink->lefthand);
lfirst(((Expr *) lfirst(sublink->oper))->args) =
lfirst(sublink->lefthand);
}
break;
default:
@ -667,10 +694,13 @@ HandleViewRule(Query *parsetree,
modified, 0);
nodeHandleViewRule((Node **) (&(parsetree->targetList)), rtable, targetlist,
rt_index, modified, 0);
/* The variables in the havingQual and groupClause also have to be adapted */
/*
* The variables in the havingQual and groupClause also have to be
* adapted
*/
nodeHandleViewRule(&parsetree->havingQual, rtable, targetlist, rt_index,
modified, 0);
nodeHandleViewRule((Node **) (&(parsetree->groupClause)), rtable, targetlist, rt_index,
modified, 0);
}