head 1.16; access; symbols Version_2_1:1.11 C_Demo_1:1.9 Retrieve_x_qual:1.5 Retrieve_x_all:1.4 Retrieve_x_1:1.3; locks; strict; comment @ * @; 1.16 date 92.08.10.21.46.25; author mer; state Exp; branches; next 1.15; 1.15 date 92.07.14.23.27.03; author joey; state Exp; branches; next 1.14; 1.14 date 92.07.08.05.04.41; author joey; state Exp; branches; next 1.13; 1.13 date 91.11.17.20.36.34; author mer; state Exp; branches; next 1.12; 1.12 date 91.11.02.21.43.49; author hong; state Exp; branches; next 1.11; 1.11 date 90.09.25.16.38.39; author kemnitz; state Exp; branches; next 1.10; 1.10 date 89.10.13.18.02.13; author hong; state Exp; branches; next 1.9; 1.9 date 89.09.05.17.19.12; author mao; state C_Demo_1; branches; next 1.8; 1.8 date 89.08.25.16.02.49; author mao; state Exp; branches; next 1.7; 1.7 date 89.08.23.16.01.38; author ong; state Exp; branches; next 1.6; 1.6 date 89.08.11.09.39.55; author ong; state Exp; branches; next 1.5; 1.5 date 89.08.04.14.31.14; author goh; state Exp; branches; next 1.4; 1.4 date 89.08.04.13.29.52; author goh; state Exp; branches; next 1.3; 1.3 date 89.08.01.14.33.13; author goh; state Exp; branches; next 1.2; 1.2 date 89.07.19.18.22.08; author goh; state Exp; branches; next 1.1; 1.1 date 89.06.23.16.01.57; author goh; state Exp; branches; next ; desc @only one routine here ! should be moved to somewhere more appropriate @ 1.16 log @fix up save/restore globals hack, we use it for xfunc processing now @ text @ /* * FILE * internal * * DESCRIPTION * Definitions required throughout the query optimizer. * */ /* RcsId ("$Header: /private/mer/pg/src/planner/util/RCS/internal.c,v 1.15 1992/07/14 23:27:03 joey Exp mer $"); */ /* */ /* * ---------- SHARED MACROS * * Macros common to modules for creating, accessing, and modifying * query tree and query plan components. * Shared with the executor. * */ #include "planner/internal.h" #include "nodes/relation.h" #include "nodes/plannodes.h" #include "nodes/primnodes.h" #include "utils/log.h" /* * ---------- GLOBAL VARIABLES * * These *should* disappear eventually...shouldn't they? * */ /* from the parse tree: */ LispValue _query_result_relation_; /* relid of the result relation */ int _query_command_type_ = 0; /* command type as a symbol */ int _query_max_level_ = 0; /* max query nesting level */ LispValue _query_range_table_; /* relations to be scanned */ /* internal to planner: */ List _base_relation_list_; /* base relation list */ List _join_relation_list_; /* list of relations generated by joins */ bool _query_is_archival_; /* archival query flag */ /* (defmacro with_saved_globals (&rest,body) XXX fix me */ typedef struct { LispValue qrr; int qct; int qml; LispValue qrt; LispValue brl; LispValue jrl; int qia; } planner_globals_hack; char * save_globals () { planner_globals_hack *pghP; pghP = (planner_globals_hack *)palloc(sizeof(planner_globals_hack)); pghP->qrr = _query_result_relation_; pghP->qct = _query_command_type_; pghP->qml = _query_max_level_; pghP->qrt = _query_range_table_; pghP->brl = _base_relation_list_; pghP->jrl = _join_relation_list_; pghP->qia = _query_is_archival_; return (char *)pghP; } void restore_globals(pgh) char *pgh; { planner_globals_hack *pghP = (planner_globals_hack *)pgh; _query_result_relation_ = pghP->qrr; _query_command_type_ = pghP->qct; _query_max_level_ = pghP->qml; _query_range_table_ = pghP->qrt; _base_relation_list_ = pghP->brl; _join_relation_list_ = pghP->jrl; _query_is_archival_ = pghP->qia; pfree(pgh); return; } List joinmethod_clauses(method) JoinMethod method; { return(method->clauses); } List joinmethod_keys(method) JoinMethod method; { return(method->jmkeys); } /* XXX - these should go away once spyros turns in some code */ Node rule_lock_plan() { return((Node)NULL); } Node make_rule_lock() { return((Node)NULL); } Node rule_lock_type() { return((Node)NULL); } Node rule_lock_attribute() { return((Node)NULL); } Node rule_lock_relation() { return((Node)NULL); } Node rule_lock_var() { return((Node)NULL); } int _rule_lock_type_alist_ = 0; int _rule_type_alist_ = 0; TLE MakeTLE(foo,bar) Resdom foo; Expr bar; { return(lispCons((LispValue)foo,lispCons((LispValue)bar,LispNil))); } void set_joinlist(foo,bar) TL foo; List bar; { CDR(foo) = bar; } Var get_expr (foo) TLE foo; { Assert(!null(foo)); Assert(!null(CDR(foo))); /* Assert(IsA(foo,LispValue)); */ return((Var)CADR(foo)); } Resdom get_resdom (foo) TLE foo; { /* Assert(IsA(foo,LispValue)); */ return((Resdom)CAR(foo)); } TLE get_entry(foo) TL foo; { /* Assert(IsA(foo,LispValue)); */ return(CAR(foo)); } void set_entry(node,foo) TL node; TLE foo; { CAR(node) = foo; } List get_joinlist(foo) TL foo; { /* Assert(IsA(foo,LispValue)); */ return (CDR(foo)); } void init_planner() { _query_result_relation_ = LispNil; _query_command_type_ = 0; _query_max_level_ = 1; _query_range_table_ = LispNil; _base_relation_list_ = LispNil; _join_relation_list_ = LispNil; _query_is_archival_ = false; } @ 1.15 log @remove planner_VarnoGetRelname, which didn't work right anyway @ text @d10 1 a10 1 /* RcsId ("$Header: /private/joey/pg/src/planner/util/RCS/internal.c,v 1.14 1992/07/08 05:04:41 joey Exp joey $"); */ a49 1 /* .. init-query-planner */ d51 1 d53 9 a61 1 /* (defmacro with_saved_globals (&rest,body) XXX fix me */ d63 1 a63 1 void d66 1 a66 8 /* LispValue qrr = _base_result_relation_; LispValue qtt = lispInteger(_query_command_type_); LispValue qml = lispInteger(_query_max_level_); LispValue qrt = _query_range_table_; LispValue qrl = _base_relation_list_; LispValue qia = lispInteger(_query_is_archival_); LispValue foo; d68 9 a76 1 /* saved_global_list = nappend1(saved_global_list,foo); */ d80 2 a81 1 restore_globals() d83 1 a83 7 /* _query_result_relation_ = nth (0,global_save); _query_command_type_ = CInteger(nth (1,global_save)); _query_max_level_ = CInteger(nth (2,global_save)); _query_range_table_ = nth (3,global_save); _base_relation_list_ = nth (4,global_save); _query_is_archival_ = (bool) CInteger(nth (5,global_save)); d85 9 a93 2 return(body_result); */ @ 1.14 log @added the function planner_VarnoGetRelname @ text @d10 1 a10 1 /* RcsId ("$Header: /private/joey/pg/src/planner/util/RCS/internal.c,v 1.13 1991/11/17 20:36:34 mer Exp joey $"); */ a208 16 } /* The parser has VarnoGetRelname, but its global variable for the range table is gone by planning time, so we need our own version -- JMH, 7/7/92 ... xfunc_width */ Name planner_VarnoGetRelname( vnum ) int vnum; { int i; LispValue p_rtable = _query_range_table_; LispValue temp = p_rtable; for( i = 1; i < vnum ; i++) temp = CDR(temp); return((Name)CString(CAR(CDR(CAR(temp))))); @ 1.13 log @prototyping @ text @d10 1 a10 1 /* RcsId ("$Header: /users/mer/postgres/src/planner/util/RCS/internal.c,v 1.12 1991/11/02 21:43:49 hong Exp mer $"); */ d209 16 @ 1.12 log @code cleaning up to support bushy tree plan generation @ text @d10 1 a10 1 /* RcsId ("$Header: RCS/internal.c,v 1.11 90/09/25 16:38:39 kemnitz Exp Locker: hong $"); */ d145 1 a145 1 return(lispCons(foo,lispCons(bar,LispNil))); @ 1.11 log @Updating from revision 1.10 to revision 1.11 @ text @d10 1 a10 1 /* RcsId ("$Header: RCS/internal.c,v 1.11 90/08/14 13:17:30 cimarron Exp $"); */ d46 2 a47 1 LispValue _query_relation_list_; /* global relation list */ d59 1 a59 1 LispValue qrr = _query_result_relation_; d63 1 a63 1 LispValue qrl = _query_relation_list_; d78 1 a78 1 _query_relation_list_ = nth (4,global_save); d206 2 a207 1 _query_relation_list_ = LispNil; @ 1.10 log @fixes for mergejoins @ text @d10 1 a10 1 /* RcsId ("$Header: RCS/internal.c,v 1.9 89/09/05 17:19:12 mao C_Demo_1 Locker: hong $"); */ d25 4 a28 4 #include "relation.h" #include "plannodes.h" #include "primnodes.h" #include "log.h" @ 1.9 log @Working version of C-only demo @ text @d10 1 a10 1 /* RcsId ("$Header: RCS/internal.c,v 1.8 89/08/25 16:02:49 mao Exp $"); */ d86 1 a86 1 joinmethod method; d93 1 a93 1 joinmethod method; d95 1 a95 1 return(method->keys); @ 1.8 log @remove {get,set}_unorderedpath, since they're in the generated file relation.c, now. @ text @d10 1 a10 1 /* RcsId ("$Header: RCS/internal.c,v 1.7 89/08/23 16:01:38 ong Exp Locker: mao $"); */ @ 1.7 log @planner supports all but rules and mergesort @ text @d10 1 a10 1 /* RcsId ("$Header: internal.c,v 1.6 89/08/11 09:39:55 ong Locked $"); */ a81 16 } void set_unorderedpath(node,path) Rel node; Path path; { AssertArg(IsA(node,Rel)); (Path)(node->unorderedpath) = path; } Path get_unorderedpath(node) Rel node; { return((Path)(node->unorderedpath)); @ 1.6 log @added #include primnodes.h" @ text @d10 1 a10 1 /* RcsId ("$Header: /n/postgres/a/postgres/ong/postgres/src/planner/util/RCS/internal.c,v 1.5 89/08/04 14:31:14 goh Exp $"); */ d104 1 a104 1 return(method->clauses); @ 1.5 log @reorganised header files @ text @d10 1 a10 1 /* RcsId ("$Header: internal.c,v 1.4 89/08/04 13:29:52 goh Locked $"); */ d27 1 d210 1 a210 1 elog(WARN,"not sure about get_joinlist"); @ 1.4 log @checkin for retrieve (x.all) @ text @d10 1 a10 1 /* RcsId ("$Header: internal.c,v 1.3 89/08/01 14:33:13 goh Locked $"); */ d24 1 a24 1 #include "internal.h" @ 1.3 log @retrieve (x=1) checkin @ text @d10 1 a10 1 /* RcsId ("$Header: internal.c,v 1.2 89/07/19 18:22:08 goh Exp $"); */ d27 1 d53 2 a54 3 LispValue with_saved_globals (body) LispValue (* body)(); a55 1 LispValue global_save; d57 15 a71 8 global_save = list (lispInteger(_query_result_relation_), lispInteger(_query_command_type_), lispInteger(_query_max_level_), _query_range_table_, _query_relation_list_, _query_is_archival_); */ LispValue body_result = (* body)(); d80 1 d167 55 a221 1 CADR(foo) = bar; @ 1.2 log @*** empty log message *** @ text @d10 1 a10 1 /* RcsId ("$Header: internal.c,v 1.1 89/06/23 16:01:57 goh Exp $"); */ d25 2 d36 2 a37 1 int _query_result_relation = 0; d45 1 a45 1 LispValue _query_is_archival_; /* archival query flag */ d56 3 a58 1 LispValue global_save = list (lispInteger(_query_result_relation_), d64 1 d66 1 a66 1 _query_result_relation_ = CInteger(nth (0,global_save)); d71 1 a71 1 _query_is_archival_ = nth (5,global_save); d74 87 @ 1.1 log @Initial revision @ text @d10 1 a10 1 /* RcsId ("$Header: internal.h,v 1.1 89/06/23 14:41:20 goh Locked $"); */ d34 1 a34 1 LispValue _query_result_relation_ = LispNil; d36 3 a38 3 LispValue _query_command_type_ = LispNil; /* command type as a symbol */ LispValue _query_max_level_ = LispNil; /* max query nesting level */ LispValue _query_range_table_; /* relations to be scanned */ d51 1 a51 1 LispValue body; d53 3 a55 5 LispValue global_save = gensym (); LispValue body_result = gensym (); LispValue global_save = list (_query_result_relation_, _query_command_type_, _query_max_level_, d59 4 a62 4 LispValue body_result = body; _query_result_relation_ = nth (0,global_save); _query_command_type_ = nth (1,global_save); _query_max_level_ = nth (2,global_save); @