1996-07-09 06:22:35 +00:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-13 23:22:53 +00:00
|
|
|
* nodeFuncs.c
|
1997-09-07 05:04:48 +00:00
|
|
|
* All node routines more complicated than simple access/modification
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
2002-06-20 20:29:54 +00:00
|
|
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
2000-01-26 05:58:53 +00:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2002-12-13 19:46:01 +00:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/nodes/nodeFuncs.c,v 1.21 2002/12/13 19:45:56 tgl Exp $
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1996-10-31 10:42:56 +00:00
|
|
|
#include "postgres.h"
|
1996-07-09 06:22:35 +00:00
|
|
|
|
|
|
|
#include "nodes/nodeFuncs.h"
|
|
|
|
#include "utils/lsyscache.h"
|
|
|
|
|
1997-09-08 21:56:23 +00:00
|
|
|
static bool var_is_inner(Var *var);
|
1997-08-19 21:40:56 +00:00
|
|
|
|
2002-12-12 15:49:42 +00:00
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
/*
|
1996-07-09 06:22:35 +00:00
|
|
|
* single_node -
|
1997-09-07 05:04:48 +00:00
|
|
|
* Returns t if node corresponds to a single-noded expression
|
1996-07-09 06:22:35 +00:00
|
|
|
*/
|
|
|
|
bool
|
1997-09-08 21:56:23 +00:00
|
|
|
single_node(Node *node)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
2002-03-21 16:02:16 +00:00
|
|
|
if (IsA(node, Const) ||
|
|
|
|
IsA(node, Var) ||
|
|
|
|
IsA(node, Param))
|
1998-09-01 03:29:17 +00:00
|
|
|
return true;
|
1997-09-07 05:04:48 +00:00
|
|
|
else
|
1998-09-01 03:29:17 +00:00
|
|
|
return false;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
1997-09-07 05:04:48 +00:00
|
|
|
* VAR nodes
|
1996-07-09 06:22:35 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
/*
|
|
|
|
* var_is_outer
|
|
|
|
* var_is_inner
|
|
|
|
* var_is_mat
|
|
|
|
* var_is_rel
|
|
|
|
*
|
|
|
|
* Returns t iff the var node corresponds to (respectively):
|
|
|
|
* the outer relation in a join
|
|
|
|
* the inner relation of a join
|
|
|
|
* a materialized relation
|
|
|
|
* a base relation (i.e., not an attribute reference, a variable from
|
|
|
|
* some lower join level, or a sort result)
|
|
|
|
* var node is an array reference
|
|
|
|
*
|
1996-07-09 06:22:35 +00:00
|
|
|
*/
|
|
|
|
bool
|
1997-09-08 21:56:23 +00:00
|
|
|
var_is_outer(Var *var)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1998-09-01 03:29:17 +00:00
|
|
|
return (bool) (var->varno == OUTER);
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
1997-09-08 02:41:22 +00:00
|
|
|
static bool
|
1997-09-08 21:56:23 +00:00
|
|
|
var_is_inner(Var *var)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1998-09-01 03:29:17 +00:00
|
|
|
return (bool) (var->varno == INNER);
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
1997-09-08 21:56:23 +00:00
|
|
|
var_is_rel(Var *var)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-07 05:04:48 +00:00
|
|
|
return (bool)
|
2001-10-25 05:50:21 +00:00
|
|
|
!(var_is_inner(var) || var_is_outer(var));
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
1997-09-07 05:04:48 +00:00
|
|
|
* OPER nodes
|
1996-07-09 06:22:35 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
/*
|
2002-12-12 15:49:42 +00:00
|
|
|
* set_opfuncid -
|
1997-09-07 05:04:48 +00:00
|
|
|
*
|
2002-12-12 15:49:42 +00:00
|
|
|
* Set the opfuncid (procedure OID) in an OpExpr node,
|
|
|
|
* if it hasn't been set already.
|
1996-07-09 06:22:35 +00:00
|
|
|
*/
|
2002-12-12 15:49:42 +00:00
|
|
|
void
|
|
|
|
set_opfuncid(OpExpr *opexpr)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
2002-12-12 15:49:42 +00:00
|
|
|
if (opexpr->opfuncid == InvalidOid)
|
|
|
|
opexpr->opfuncid = get_opcode(opexpr->opno);
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|