head 1.22; access; symbols Version_2_1:1.16 Version_2:1.11 C_Demo_1:1.8; locks; strict; comment @ * @; 1.22 date 92.07.04.04.03.38; author mao; state Exp; branches; next 1.21; 1.21 date 92.04.01.01.49.23; author mer; state Exp; branches; next 1.20; 1.20 date 91.11.15.16.18.38; author hong; state Exp; branches; next 1.19; 1.19 date 91.11.14.14.51.27; author jolly; state Exp; branches; next 1.18; 1.18 date 91.08.15.17.57.07; author caetta; state Exp; branches; next 1.17; 1.17 date 91.03.27.13.12.49; author choi; state Exp; branches; next 1.16; 1.16 date 91.01.15.19.34.05; author sp; state Exp; branches; next 1.15; 1.15 date 90.12.27.19.18.17; author sp; state Exp; branches; next 1.14; 1.14 date 90.12.19.13.36.34; author sp; state Exp; branches; next 1.13; 1.13 date 90.11.12.11.26.49; author kemnitz; state Exp; branches; next 1.12; 1.12 date 90.08.14.09.29.42; author cimarron; state Exp; branches; next 1.11; 1.11 date 90.05.17.23.12.13; author kemnitz; state Version_2; branches; next 1.10; 1.10 date 90.04.30.12.24.43; author sp; state Exp; branches; next 1.9; 1.9 date 89.10.17.13.45.20; author cimarron; state Exp; branches; next 1.8; 1.8 date 89.09.05.17.14.53; author mao; state C_Demo_1; branches; next 1.7; 1.7 date 89.08.25.14.50.00; author cimarron; state Exp; branches; next 1.6; 1.6 date 89.08.25.14.34.11; author ong; state Exp; branches; next 1.5; 1.5 date 89.08.10.00.53.44; author hirohama; state Exp; branches; next 1.4; 1.4 date 89.08.09.18.16.41; author cimarron; state Exp; branches; next 1.3; 1.3 date 89.08.05.20.41.51; author goh; state Exp; branches; next 1.2; 1.2 date 89.08.01.14.21.09; author goh; state Exp; branches; next 1.1; 1.1 date 89.07.21.08.55.20; author goh; state Exp; branches; next ; desc @various node type functions @ 1.22 log @fixes for arrays, array refs, and nested dots @ text @ /* * nodeFuncs * * All node routines more complicated than simple access/modification * $Header: /private/mao/postgres/src/lib/C/RCS/nodeFuncs.c,v 1.21 1992/04/01 01:49:23 mer Exp mao $ */ #include "tmp/c.h" RcsId("$Header: /private/mao/postgres/src/lib/C/RCS/nodeFuncs.c,v 1.21 1992/04/01 01:49:23 mer Exp mao $"); #include "nodes/primnodes.h" #include "nodes/plannodes.h" #include "nodes/nodes.h" #include "nodes/pg_lisp.h" #include "nodes/relation.h" #include "tmp/nodeFuncs.h" #include "planner/keys.h" /* * single_node * * Returns t if node corresponds to a single-noded expression * */ /* .. contains-not, fix-opid, flatten-tlistentry, nested-clause-p * .. pull_var_clause, relation-level-clause-p, replace-clause-joinvar-refs * .. replace-clause-nestvar-refs, replace-clause-resultvar-refs * .. valid-or-clause */ bool single_node (node) Node node ; { if(atom (node) || IsA(node,Const) || IsA(node,Var) || IsA(node,Param)) return(true); else return(false); } /* ========= * VAR nodes * ========= */ /* * 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 * */ /* .. ExecEvalVar, switch_outer, var_is_rel */ bool var_is_outer (var) Var var ; { return((bool)(get_varno (var) == OUTER)); } /* .. ExecEvalVar, var_is_rel */ bool var_is_inner (var) Var var ; { return ( (bool) (get_varno (var) == INNER)); } /* .. get_relattval, get_relsatts */ /* XXX - completely bogus, Var needs an extra flags that is "materialized ?" */ bool var_is_mat (var) Var var ; { return (false); /* return((bool)listp (get_varno(var))); */ } /* .. ExecEvalVar */ bool var_is_rel (var) Var var ; { return (bool) ! (var_is_inner (var) || var_is_outer (var)); } /* ========== * OPER nodes * ========== */ /* * replace_opid * * Given a oper node, resets the opfid field with the * procedure OID (regproc id). * * Returns the modified oper node. * */ /* .. fix-opid, index-outerjoin-references, replace-clause-joinvar-refs * .. replace-clause-resultvar-refs */ Oper replace_opid (oper) Oper oper ; { set_opid (oper,get_opcode (get_opno (oper))); set_op_fcache(oper, NULL); return(oper); } /* ============================= * constant (CONST, PARAM) nodes * ============================= */ /* * constant-p * * Returns t iff the argument is a constant or a parameter. * */ /* .. get_relattval, match-index-orclause, qual-clause-p, single_node */ bool constant_p (node) Expr node ; { if ( IsA(node,Const) || IsA(node,Param) ) return(true); else return(false); } /* * non_null * * Returns t if the node is a non-null constant, e.g., if the node has a * valid `constvalue' field. * */ /* .. MakeAttlist, best-or-subclause-index, get_relattval, is_null */ bool non_null (c) Expr c; { if ( IsA(c,Const) && !get_constisnull ((Const)c) ) return(true); else return(false); } /* * is_null * * Returns t if the node is anything but a non-null constant (has no valid * `constvalue' field). * */ /* .. ExecEvalNot, ExecEvalOr, ExecIsNull, ExecQual1, print_const */ bool is_null (constant) Expr constant ; { if (!non_null (constant)) return(true); else return(false); } /* ========== * PLAN nodes * ========== */ /* .. print_subplan, set-tlist-references */ bool join_p (node) Node node ; { if( IsA(node,NestLoop) || IsA(node,HashJoin) || IsA(node,MergeJoin)) return(true); else return(false); } /* .. print_subplan */ bool scan_p (node) Node node ; { if( IsA(node,SeqScan) || IsA(node,IndexScan)) return(true); else return(false); } /* .. print_subplan, query_planner, set-tlist-references */ bool temp_p (node) Node node ; { if ( IsA(node,Sort) || IsA(node,Hash)) return(true); else return(false); } bool plan_p (node) Node node ; { if ( IsA(node,Result) || IsA(node,Existential)) return(true); else return(false); } @ 1.21 log @accessors now turned into macros (some casts needed) @ text @d6 1 a6 1 * $Header: /u/mer/pg.opt/src/lib/C/RCS/nodeFuncs.c,v 1.20 1991/11/15 16:18:38 hong Exp mer $ d11 1 a11 1 RcsId("$Header: /u/mer/pg.opt/src/lib/C/RCS/nodeFuncs.c,v 1.20 1991/11/15 16:18:38 hong Exp mer $"); a54 1 * var_is_array a104 51 } bool var_is_array (var) Var var; { return((bool) (var->vararraylist != NULL)); } /* .. consider_vararraylist, nested-clause-p, new-level-tlist * .. relation-sortkeys, replace-nestvar-refs, var_equal */ bool var_is_nested (var) Var var ; { if ( get_vardotfields (var) != NULL) return(true); else return(false); } /* .. consider_vararraylist, numlevels */ bool varid_indexes_into_array (var) Var var ; { return((bool)listp (last_element ((LispValue)(get_varid (var))))); } /* .. add_tl_element, replace-nestvar-refs */ List varid_array_index (var) Var var ; { return(CAR (last_element ((LispValue)(get_varid (var))))); } /* .. add_tl_element, replace-nestvar-refs */ bool consider_vararrayindex (var) Var var ; { if (!var_is_nested (var) && varid_indexes_into_array (var)) return(true); else return(false); @ 1.20 log @for prototyping @ text @d6 1 a6 1 * $Header: RCS/nodeFuncs.c,v 1.19 91/11/14 14:51:27 jolly Exp Locker: hong $ d11 1 a11 1 RcsId("$Header: RCS/nodeFuncs.c,v 1.19 91/11/14 14:51:27 jolly Exp Locker: hong $"); d228 1 a228 1 if ( IsA(c,Const) && !get_constisnull (c) ) @ 1.19 log @cleaned up for function prototyping @ text @d6 1 a6 1 * $Header: RCS/nodeFuncs.c,v 1.18 91/08/15 17:57:07 caetta Exp Locker: jolly $ d11 1 a11 1 RcsId("$Header: RCS/nodeFuncs.c,v 1.18 91/08/15 17:57:07 caetta Exp Locker: jolly $"); d17 1 d142 1 a142 1 LispValue var ; @ 1.18 log @more ordinary agg stuff @ text @d6 1 a6 1 * $Header: lib/C/RCS/nodeFuncs.c,v 1.17 91/03/27 13:12:49 choi Exp Locker: caetta $ d11 1 a11 1 RcsId("$Header: lib/C/RCS/nodeFuncs.c,v 1.17 91/03/27 13:12:49 choi Exp Locker: caetta $"); a20 2 /* XXX - find what this really means */ extern LispValue last_element(); a21 1 d134 1 a134 1 return((bool)listp (last_element (get_varid (var)))); d143 1 a143 1 return(CAR (last_element (get_varid (var)))); d247 2 a248 2 is_null (const) Expr const ; d250 1 a250 1 if (!non_null (const)) @ 1.17 log @varnode->vararrayindex became vanode->vararraylist @ text @d6 1 a6 1 * $Header: RCS/nodeFuncs.c,v 1.16 91/01/15 19:34:05 sp Exp Locker: choi $ d11 1 a11 1 RcsId("$Header: RCS/nodeFuncs.c,v 1.16 91/01/15 19:34:05 sp Exp Locker: choi $"); d14 1 d41 1 a41 1 if(atom (node) || IsA(node,Const) || IsA(node,Var) || IsA(node,Param)) @ 1.16 log @Removed obsolete function 'param_is_attr' @ text @d6 1 a6 1 * $Header: RCS/nodeFuncs.c,v 1.15 90/12/27 19:18:17 sp Exp $ d11 1 a11 1 RcsId("$Header: RCS/nodeFuncs.c,v 1.15 90/12/27 19:18:17 sp Exp $"); d114 1 a114 1 return((bool) (var->vararrayindex != (Index) 0)); d117 1 a117 1 /* .. consider_vararrayindex, nested-clause-p, new-level-tlist d130 1 a130 1 /* .. consider_vararrayindex, numlevels @ 1.15 log @Oper nodes now have a new field (opid) where the oid of the regproc is stored (that used to be stored in 'opno' overriding the pg_operator oid). @ text @d6 1 a6 1 * $Header: RCS/nodeFuncs.c,v 1.14 90/12/19 13:36:34 sp Exp Locker: sp $ d11 1 a11 1 RcsId("$Header: RCS/nodeFuncs.c,v 1.14 90/12/19 13:36:34 sp Exp Locker: sp $"); a185 22 } /* =========== * PARAM nodes * =========== */ /* * param_is_attr * * Returns t iff the argument is a parameter of the $.name type. * */ bool param_is_attr (param) Param param ; { if ( stringp (get_paramid (param))) return(true); else return(false); @ 1.14 log @the 'fcache' attribute of Func & Oper nodes should be initialized to NULL. 'init_fcache' should only be called by the executor... @ text @d6 1 a6 1 * $Header: RCS/nodeFuncs.c,v 1.13 90/11/12 11:26:49 kemnitz Exp Locker: sp $ d11 1 a11 1 RcsId("$Header: RCS/nodeFuncs.c,v 1.13 90/11/12 11:26:49 kemnitz Exp Locker: sp $"); d168 1 a168 1 * Given a oper node, resets the opno (operator OID) field with the d183 1 a183 1 set_opno (oper,get_opcode (get_opno (oper))); @ 1.13 log @Added call to init_fcache in reset_oper() @ text @d6 1 a6 1 * $Header: RCS/nodeFuncs.c,v 1.12 90/08/14 09:29:42 cimarron Exp Locker: kemnitz $ d11 1 a11 1 RcsId("$Header: RCS/nodeFuncs.c,v 1.12 90/08/14 09:29:42 cimarron Exp Locker: kemnitz $"); d184 1 a184 1 set_op_fcache(oper, init_fcache(get_opno(oper))); @ 1.12 log @added pathnames to include statements @ text @d6 1 a6 1 * $Header: RCS/nodeFuncs.c,v 1.11 90/05/17 23:12:13 kemnitz Version_2 Locker: cimarron $ d11 1 a11 1 RcsId("$Header$"); d184 1 @ 1.11 log @Added var_is_array_ref to check for array ref varnodes. @ text @d6 1 a6 1 * $Header: RCS/nodeFuncs.c,v 1.10 90/04/30 12:24:43 sp Exp $ d9 9 a17 5 #include "c.h" #include "primnodes.h" #include "nodes.h" #include "pg_lisp.h" #include "nodeFuncs.h" @ 1.10 log @single_atom() now treats Param nodes as single atoms too... @ text @d6 1 a6 1 * $Header: RCS/nodeFuncs.c,v 1.9 89/10/17 13:45:20 cimarron Exp Locker: sp $ d52 1 d60 1 d103 8 @ 1.9 log @changes to support MergeJoins in the executor. @ text @d6 1 a6 1 * $Header: RCS/nodeFuncs.c,v 1.8 89/09/05 17:14:53 mao C_Demo_1 $ d36 1 a36 1 if(atom (node) || IsA(node,Const) || IsA(node,Var)) @ 1.8 log @Working version of C-only demo @ text @d6 1 a6 1 * $Header: RCS/nodeFuncs.c,v 1.7 89/08/25 14:50:00 cimarron Exp $ d277 1 a277 1 if( IsA(node,NestLoop) || IsA(node,HashJoin) || IsA(node,MergeSort)) @ 1.7 log @fixed var_is_rel @ text @d6 1 a6 1 * $Header: RCS/nodeFuncs.c,v 1.6 89/08/25 14:34:11 ong Exp Locker: ong $ @ 1.6 log @commented out stuff which is not implemented yet. @ text @d6 1 a6 1 * $Header: /n/postgres/a/postgres/ong/postgres/src/lib/l-lisp/RCS/nodeFuncs.c,v 1.3 89/08/05 20:41:51 goh Exp $ d99 2 a100 3 return ((bool) (atom (get_varno (var)) && ! (var_is_inner (var) || var_is_outer (var)))); @ 1.5 log @keys.h -> planner/keys.h @ text @d1 1 d6 1 a6 1 * $Header: nodeFuncs.c,v 1.4 89/08/09 18:16:41 hirohama Locked $ d62 1 a62 2 /* .. ExecEvalVar, switch_outer, var_is_rel */ d71 2 a72 2 /* .. ExecEvalVar, var_is_rel */ d80 4 a83 2 /* .. get_relattval, get_relsatts */ d89 2 a90 1 return((bool)listp (get_varno (var))); d93 2 a94 2 /* .. ExecEvalVar */ d233 1 a233 1 non_null(c) a235 5 if (! IsA(c,Const)) return false; if (!get_constisnull(c)) return true; d237 6 a242 1 return false; @ 1.4 log @fixed not_null() -cim @ text @d5 1 a5 1 * $Header: /usr6/postgres/cimarron/postgres3/src/lib/l-lisp/RCS/nodeFuncs.c,v 1.2 89/08/01 14:21:09 goh Exp $ d13 1 a13 1 #include "keys.h" @ 1.3 log @fixed include path problem @ text @a0 1 d5 1 a5 1 * $Header: nodeFuncs.c,v 1.2 89/08/01 14:21:09 goh Locked $ d13 1 a13 1 #include "planner/keys.h" d230 2 a231 2 non_null (const) Expr const ; d233 7 a239 5 /* if ( IsA(const,Const) && !get_constisnull (const) ) return(true); else return(false); */ @ 1.2 log @*** empty log message *** @ text @d6 1 a6 1 * $Header: nodeFuncs.c,v 1.1 89/07/21 08:55:20 goh Locked $ d14 1 a14 1 #include "keys.h" @ 1.1 log @Initial revision @ text @d6 1 a6 1 * $Header:$ d36 1 a36 1 if(atom (node) || constant_p (node) || var_p (node)) d126 1 a126 1 bool d128 1 a128 1 LispValue var ; d130 1 a130 4 if ( CAR (last_element (get_varid (var)))) return(true); else return(false); d213 1 a213 1 if ( const_p (node) || param_p (node) ) d234 1 a234 1 if (const_p (const) && !get_constisnull (const) ) d238 1 d274 1 a274 1 if(nestloop_p (node) || hashjoin_p (node) || mergesort_p (node)) d287 1 a287 1 if(seqscan_p (node) || indexscan_p (node)) d299 1 a299 1 if (sort_p (node) || hash_p (node)) d309 1 a309 1 if (result_p (node) || existential_p (node)) @