1 /*-------------------------------------------------------------------------
4 * All node routines more complicated than simple access/modification
6 * Copyright (c) 1994, Regents of the University of California
10 * $Header: /cvsroot/pgsql/src/backend/nodes/nodeFuncs.c,v 1.4 1997/09/07 04:42:49 momjian Exp $
12 *-------------------------------------------------------------------------
15 #include <sys/types.h>
19 #include "nodes/primnodes.h"
20 #include "nodes/plannodes.h"
21 #include "nodes/pg_list.h"
22 #include "nodes/relation.h"
23 #include "nodes/nodeFuncs.h"
24 #include "utils/lsyscache.h"
26 static bool var_is_inner(Var * var);
30 * Returns t if node corresponds to a single-noded expression
33 single_node(Node * node)
35 if (IsA(node, Ident) || IsA(node, Const) || IsA(node, Var) || IsA(node, Param))
41 /*****************************************************************************
43 *****************************************************************************/
51 * Returns t iff the var node corresponds to (respectively):
52 * the outer relation in a join
53 * the inner relation of a join
54 * a materialized relation
55 * a base relation (i.e., not an attribute reference, a variable from
56 * some lower join level, or a sort result)
57 * var node is an array reference
61 var_is_outer(Var * var)
63 return ((bool) (var->varno == OUTER));
67 var_is_inner(Var * var)
69 return ((bool) (var->varno == INNER));
76 ! (var_is_inner(var) || var_is_outer(var));
79 /*****************************************************************************
81 *****************************************************************************/
86 * Given a oper node, resets the opfid field with the
87 * procedure OID (regproc id).
89 * Returns the modified oper node.
93 replace_opid(Oper * oper)
95 oper->opid = get_opcode(oper->opno);
96 oper->op_fcache = NULL;
100 /*****************************************************************************
101 * constant (CONST, PARAM) nodes
102 *****************************************************************************/
106 * Returns t if the node is a non-null constant, e.g., if the node has a
107 * valid `constvalue' field.
114 if (IsA(c, Const) && !((Const *) c)->constisnull)