head 1.13; access; symbols Version_2_1:1.9 C_Demo_1:1.7 Retrieve_x_qual:1.5 Retrieve_x_all:1.4 Retrieve_x_1:1.3; locks; strict; comment @ * @; 1.13 date 92.03.31.23.14.40; author mer; state Exp; branches; next 1.12; 1.12 date 91.11.17.20.36.34; author mer; state Exp; branches; next 1.11; 1.11 date 91.10.16.23.13.42; author mer; state Exp; branches; next 1.10; 1.10 date 91.05.23.18.40.55; author kemnitz; state Exp; branches; next 1.9; 1.9 date 90.09.25.16.38.33; author kemnitz; state Exp; branches; next 1.8; 1.8 date 90.05.30.18.57.08; author cimarron; state Exp; branches; next 1.7; 1.7 date 89.09.05.17.19.07; author mao; state C_Demo_1; branches; next 1.6; 1.6 date 89.08.23.16.01.36; author ong; state Exp; branches; next 1.5; 1.5 date 89.08.04.14.30.31; author goh; state Exp; branches; next 1.4; 1.4 date 89.08.04.13.29.43; author goh; state Exp; branches; next 1.3; 1.3 date 89.08.01.14.32.52; author goh; state Exp; branches; next 1.2; 1.2 date 89.07.19.14.05.52; author goh; state Exp; branches; next 1.1; 1.1 date 89.07.19.14.05.44; author goh; state Exp; branches; next ; desc @@ 1.13 log @change accessor functions into macros @ text @/* * FILE * indexnode * * DESCRIPTION * Routines to find all indices on a relation * $Header: /users/mer/pg/src/planner/util/RCS/indexnode.c,v 1.12 1991/11/17 20:36:34 mer Exp mer $ */ /* * EXPORTS * find-relation-indices */ /* declare (localf (find_secondary_index)); */ #include "tmp/postgres.h" #include "parser/parse.h" #include "nodes/plannodes.h" #include "nodes/relation.h" #include "nodes/relation.a.h" #include "planner/internal.h" #include "planner/indexnode.h" #include "planner/cfi.h" /* * find-relation-indices * * Returns a list of index nodes containing appropriate information for * each (secondary) index defined on a relation. * */ /* .. find-rel-paths */ LispValue find_relation_indices (rel) Rel rel ; { /* XXX Cheap temporary hack: if the relation is the result relation, */ /* don't use an index to update it! */ if (equal((Node)_query_result_relation_,(Node)get_relids (rel)) && (_query_command_type_ != RETRIEVE )) { return (LispNil); } else if (get_indexed (rel)) { LispValue temp = CAR(get_relids(rel)); if (IsA(temp,LispInt)) return(find_secondary_index (false,CInteger(temp))); } else { return (LispNil); } return (LispNil); } /* * find-secondary-index * * Creates a list of index path nodes containing information for each * secondary index defined on a relation by searching through the index * catalog. * * 'notfirst' is 0 if this is the first call to find-secondary-index * 'relid' is the OID of the relation for which indices are being located * * Returns a list of new index nodes. * */ /* .. find-relation-indices, find-secondary-index */ LispValue find_secondary_index (notfirst,relid) bool notfirst; ObjectId relid ; { LispValue indexinfo = index_info (notfirst,relid); if ( consp (indexinfo)) { Rel indexnode = RMakeRel(); set_relids (indexnode,lispCons(CAR(indexinfo),LispNil)); set_pages (indexnode,CInteger(CADR (indexinfo))); set_tuples (indexnode,CInteger(nth (2,indexinfo))); set_indexkeys (indexnode,nth (3,indexinfo)); set_ordering (indexnode,nth (4,indexinfo)); set_classlist (indexnode,nth (5,indexinfo)); set_indproc(indexnode, CInteger(nth(6,indexinfo))); set_indexed(indexnode,false); /* XXX should it be true instead */ set_size (indexnode,0); set_width(indexnode,0); set_targetlist(indexnode,LispNil); set_pathlist(indexnode,LispNil); set_unorderedpath(indexnode,(PathPtr)NULL); set_cheapestpath(indexnode,(PathPtr)NULL); set_clauseinfo(indexnode,LispNil); set_joininfo(indexnode,LispNil); set_innerjoin(indexnode,LispNil); return(lispCons((LispValue)indexnode, find_secondary_index (true,relid))); } else return(LispNil); } @ 1.12 log @prototyping @ text @d7 1 a7 1 * $Header: /users/mer/postgres/src/planner/util/RCS/indexnode.c,v 1.11 1991/10/16 23:13:42 mer Exp mer $ d98 2 a99 2 set_unorderedpath(indexnode,(Path)NULL); set_cheapestpath(indexnode,(Path)NULL); @ 1.11 log @add support for functional indices @ text @d7 1 a7 1 * $Header: /users/mer/postgres/src/planner/util/RCS/indexnode.c,v 1.10 1991/05/23 18:40:55 kemnitz Exp mer $ a27 7 /* ---------------- * Rel creator declaration * ---------------- */ extern Rel RMakeRel(); d47 1 a47 1 if (equal(_query_result_relation_,get_relids (rel)) && d104 2 a105 1 return(lispCons (indexnode,find_secondary_index (true,relid))); @ 1.10 log @got rid of lint warning "has return(e); and return;" @ text @d7 1 a7 1 * $Header: RCS/indexnode.c,v 1.9 90/09/25 16:38:33 kemnitz Exp Locker: kemnitz $ d98 1 @ 1.9 log @Updating from revision 1.8 to revision 1.9 @ text @d7 1 a7 1 * $Header: RCS/indexnode.c,v 1.9 90/08/14 13:17:58 cimarron Exp $ d64 2 @ 1.8 log @CreateNode(Foo) --> RMakeFoo() change @ text @d7 1 a7 1 * $Header: RCS/indexnode.c,v 1.7 89/09/05 17:19:07 mao C_Demo_1 $ d16 8 a24 1 #include "parse.h" a25 3 #include "plannodes.h" #include "relation.h" #include "relation.a.h" @ 1.7 log @Working version of C-only demo @ text @d7 1 a7 1 * $Header: RCS/indexnode.c,v 1.6 89/08/23 16:01:36 ong Exp Locker: ong $ d24 5 d85 1 a85 1 Rel indexnode = CreateNode(Rel); a103 3 indexnode->printFunc = PrintRel; indexnode->equalFunc = EqualRel; @ 1.6 log @planner supports all but rules and mergesort @ text @d7 1 a7 1 * $Header: RCS/indexnode.c,v 1.5 89/08/04 14:30:31 goh Exp Locker: ong $ @ 1.5 log @reorganised header files @ text @d7 1 a7 1 * $Header: indexnode.c,v 1.4 89/08/04 13:29:43 goh Locked $ d45 1 a45 1 if ((_query_result_relation_ == (LispValue)get_relids (rel)) && d49 3 a51 4 Relid temp = (Relid) get_relids(rel); if (IsA(temp,LispInt)) find_secondary_index (0,CInteger(temp)); d60 1 a60 1 * Creates a list of index nodes containing information for each d71 3 a73 3 /* .. find-relation-indices, find-secondary-index */ LispValue d75 2 a76 2 LispValue notfirst; int relid ; d79 5 a83 5 if /*when */ ( consp (indexinfo)) { IndexScan indexnode = CreateNode(IndexScan); set_indexid (indexnode,lispCons(CAR(indexinfo),LispNil)); set_pages (indexnode,nth (1,indexinfo)); set_tuples (indexnode,nth (2,indexinfo)); d87 16 a102 1 return(lispCons (indexnode,find_secondary_index (1,relid))); @ 1.4 log @checkin for retrieve (x.all) @ text @d7 1 a7 1 * $Header: indexnode.c,v 1.3 89/08/01 14:32:52 goh Locked $ d16 1 a16 1 #include "internal.h" d18 1 a18 1 #include "indexnode.h" d22 1 a23 2 extern LispValue index_info(); /* XXX - #include "cfi.h" when M.Yatabe finishes planner/sys */ @ 1.3 log @retrieve (x=1) checkin @ text @d7 1 a7 1 * $Header: indexnode.c,v 1.2 89/07/19 14:05:52 goh Locked $ d20 2 d40 1 a40 1 LispValue rel ; d50 4 a53 1 find_secondary_index (0,get_relid (rel)); @ 1.2 log @phase 2 checkin @ text @a0 1 d7 1 a7 1 * $Header: /usr6/postgres/goh/newpost/src/planner/util/RCS/indexnode.c,v 1.1 89/07/19 14:05:44 goh Exp $ d44 1 a44 1 if ((_query_result_relation_ == get_relid (rel)) && d78 1 a78 1 set_indexid (indexnode,list (nth (0,indexinfo))); d83 1 a83 1 set_class (indexnode,nth (5,indexinfo)); @ 1.1 log @Initial revision @ text @d8 1 a8 1 * $Header:$ @