head     1.4;
branch   ;
access   ;
symbols  C_Demo_1:1.4;
locks    ; strict;
comment  @ * @;


1.4
date     89.09.05.17.15.00;  author mao;  state C_Demo_1;
branches ;
next     1.3;

1.3
date     89.01.31.18.04.59;  author goh;  state Stab;
branches ;
next     1.2;

1.2
date     89.01.19.23.11.32;  author aoki;  state Exp;
branches ;
next     1.1;

1.1
date     89.01.17.05.55.44;  author cimarron;  state Exp;
branches ;
next     ;


desc
@@


1.4
log
@Working version of C-only demo
@
text
@;;;
;;;	parsetree.l
;;;
;;;	Routines to access various components and subcomponents of parse trees.
;;;
;;;	XXX These will replaced with defstruct macros in Version 2.
;;;
(defvar *RCS-parsetree*
  "$Header: /usr6/postgres/mao/postgres/src/lib/l-lisp/RCS/parsetree.l,v 1.3 89/01/31 18:04:59 goh Stab $")
;;;

#+opus43 (declare (macros t))
;#+allegro (locally (declare (macros t)))

(provide "parsetree")

(defmacro parse_root (parse)
  `(nth 0 ,parse))

(defmacro parse_targetlist (parse)
  `(nth 1 ,parse))

(defmacro parse_qualification (parse)
  `(nth 2 ,parse))

(defmacro root_numlevels (root)
  `(nth 0 ,root))

(defmacro root_commandtype (root)
  `(nth 1 ,root))

(defmacro root_resultrelation (root)
  `(nth 2 ,root))

;.. subst-rangetable
(defmacro root_rangetable (root)
  `(nth 3 ,root))

(defmacro root_priority (root)
  `(nth 4 ,root))

(defmacro root_ruleinfo (root)
  `(nth 5 ,root))

(defmacro resultrelation_name (resultrelation)
  `(cond ((listp ,resultrelation)
	  (nth 0 ,resultrelation))))

(defmacro resultrelation_archive (resultrelation)
  `(cond ((listp ,resultrelation)
	  (nth 1 ,resultrelation))))

;.. GetIDFromRangeTbl, InitPlan, print_rtentries, print_subplan
;.. print_var
(defmacro rt_relname (rt_entry)
  `(nth 0 ,rt_entry))

;.. ExecutePlan, best-or-subclause-index, create_index_path
;.. exec-set-lock, in-line-lambda%598040865, index-info, index-innerjoin
;.. parameterize, plan-union-queries, plan-union-query
;.. preprocess-targetlist, print_rtentries, print_var, relation-info
;.. translate-relid, write-decorate
(defmacro rt_relid (rt_entry)
  `(nth 1 ,rt_entry))

;.. ExecBeginScan, ExecCreatR, ExecOpenR, InitPlan
;.. in-line-lambda%598040864, print_rtentries
(defmacro rt_time (rt_entry)
  `(nth 2 ,rt_entry))

;.. in-line-lambda%598040864
(defmacro rt_archive_time (rt_entry)
  `(cond ((nth 3 ,rt_entry)
	  (rt_time ,rt_entry))))

;.. in-line-lambda%598040866, plan-union-queries, print_rtentries
(defmacro rt_flags (rt_entry)
  `(nth 3 ,rt_entry))

;.. add-read-locks, exec-make-intermediate-locks, exec-set-lock
;.. make-parameterized-plans, make-rule-locks, print_rtentries
;.. write-decorate
(defmacro rt_rulelocks (rt_entry)
  `(nth 4 ,rt_entry))

;.. ExecCreatR, ExecOpenR, ExecutePlan, InitPlan, add-read-locks
;.. exec-set-lock, plan-union-queries, write-decorate
(defmacro rt_fetch (inhrelid rangetable)
  `(nth (1- ,inhrelid) ,rangetable))

(defmacro rt_store (inhrelid rangetable rt_entry)
  `(setf (nth (1- ,inhrelid) ,rangetable) ,rt_entry))

;.. MakeAttlist, compute-attribute-width, copy-vars, flatten-tlist-vars
;.. in-line-lambda%598040855, new-result-tlist, new-unsorted-tlist
;.. print_tlistentry, relation-sortkeys, replace-resultvar-refs
;.. set-join-tlist-references, sort-level-result
;.. targetlist-resdom-numbers, tlist-member, tlist-temp-references
(defmacro tl_resdom (tl_entry)
  `(nth 0 ,tl_entry))

;.. MakeAttlist, copy-vars, find-tlist-read-vars, flatten-tlist
;.. flatten-tlist-vars, flatten-tlistentry, in-line-lambda%598041218
;.. in-line-lambda%598041219, in-line-lambda%598041221
;.. initialize-targetlist, matching_tlvar, new-join-tlist
;.. new-level-tlist, new-result-tlist, print_tlistentry
;.. relation-sortkeys, set-join-tlist-references, tlist-temp-references
;.. update-relations
(defmacro tl_expr (tl_entry)
  `(nth 1 ,tl_entry))

;.. exec-make-intermediate-locks, exec-set-lock
(defmacro ruleinfo_ruleid (ruleinfo)
  `(nth 0 ,ruleinfo))

;.. exec-make-intermediate-locks, exec-set-lock, make-rule-locks
;.. process-rules
(defmacro ruleinfo_ruletag (ruleinfo)
  `(nth 1 ,ruleinfo))

;;;;
;;;;	NEW STUFF
;;;;

(defstruct (parse (:type #+common list #+opus43 :list)
		  #+opus43 :conc-name :constructor
		  (:constructor new-parse (root
					   targetlist
					   qualification)))
  (root			nil)
  (targetlist		nil)
  (qualification	nil))

(defstruct (root #+common (:type list) #+opus43 (:type :list)
		 #+opus43 :conc-name :constructor
		 (:constructor new-root (levels
					 command-type
					 result-relation
					 rangetable
					 priority
					 ruleinfo)))
  (levels		0)
  (command-type 	nil)
  (result-relation	nil)
  (rangetable		nil)
  (priority		0)
  (ruleinfo		nil))

(defstruct (result-relation (:type #+common list #+opus43 :list)
			    #+opus43 :conc-name :constructor
			    (:constructor new-result-relation (id
							       archive-level)))
  (id			nil)
  (archive-level	nil))

(defstruct (ruleinfo (:type #+common list #+opus43 :list)
		     #+opus43 :conc-name :constructor
		      (:constructor new-ruleinfo (id
						  tag)))
  (id	nil)
  (tag	nil))

(defstruct (rt (:type #+common list #+opus43 :list)
	       #+opus43 :conc-name :constructor
	       (:constructor new-rt (relation-name
				     relation-id
				     time
				     archival-p)))
  (relation-name	"")
  (relation-id		0)
  (time			nil)
  (archival-p		nil))

(defstruct (tl (:type #+common list #+opus43 :list)
	       #+opus43 :conc-name :constructor
	       (:constructor new-tl (resdom
				     expr)))
  (resdom	nil)
  (expr		nil))


;;;
;;;	rt-archival-time
;;;
;;;	Return the archival time range for a rangetable entry.
;;;

(defmacro rt-archival-time (rt)
  `(cond (rt-archival-p ,rt)
	 (rt-time ,rt)))
  

;;;
;;;	rt-fetch
;;;	rt-store
;;;
;;;	Access and (destructively) replace rangetable entries.
;;;

(defmacro rt-fetch (rangetable-index rangetable)
  `(nth (1- ,rangetable-index) ,rangetable))

(defmacro rt-store (rangetable-index rangetable rt)
  `(setf (nth (1- ,rangetable-index) ,rangetable) ,rt))

;;;
;;;	getrelid
;;;	getrelname
;;;
;;;	Given the range index of a relation, return the corresponding
;;;	relation id or relation name.
;;;

;.. best-or-subclause-index, create_index_path, index-info
;.. index-innerjoin, parameterize, preprocess-targetlist, print_var
;.. relation-info, translate-relid, write-decorate
(defmacro getrelid (rangeindex rangetable)
  `(rt_relid (nth (1- ,rangeindex) ,rangetable)))

;.. GetIDFromRangeTbl, print_subplan, print_var
(defmacro getrelname (rangeindex rangetable)
  `(rt_relname (nth (1- ,rangeindex) ,rangetable)))
@


1.3
log
@minor bug fixes -> :conc-name with nil value doesn't work
in allegro
@
text
@d9 1
a9 1
  "$Header: parsetree.l,v 1.2 89/01/19 23:11:32 goh Locked $")
@


1.2
log
@updated lxrefs, support for funcindex, misc. fixes
@
text
@d9 1
a9 1
  "$Header: parsetree.l,v 2.5 88/07/14 02:10:00 aoki Locked $")
d12 2
a13 2
(declare (macros t))
(provide 'parsetree)
d15 2
d126 1
a126 1
		  :conc-name :constructor
d135 1
a135 1
		 :conc-name :constructor
d150 1
a150 1
			    :conc-name :constructor
d157 1
a157 1
		      :conc-name :constructor
d164 1
a164 1
	       :conc-name :constructor
d175 1
a175 1
	       :conc-name :constructor
@


1.1
log
@Initial revision
@
text
@a0 25


;;; 
;;; POSTGRES Data Base Management System
;;; 
;;; Copyright (c) 1988 Regents of the University of California
;;; 
;;; Permission to use, copy, modify, and distribute this software and its
;;; documentation for educational, research, and non-profit purposes and
;;; without fee is hereby granted, provided that the above copyright
;;; notice appear in all copies and that both that copyright notice and
;;; this permission notice appear in supporting documentation, and that
;;; the name of the University of California not be used in advertising
;;; or publicity pertaining to distribution of the software without
;;; specific, written prior permission.  Permission to incorporate this
;;; software into commercial products can be obtained from the Campus
;;; Software Office, 295 Evans Hall, University of California, Berkeley,
;;; Ca., 94720 provided only that the the requestor give the University
;;; of California a free licence to any derived software for educational
;;; and research purposes.  The University of California makes no
;;; representations about the suitability of this software for any
;;; purpose.  It is provided "as is" without express or implied warranty.
;;; 


d9 1
a9 1
  "$Header: parsetree.l,v 1.1 88/11/11 16:38:10 postgres Exp $")
a14 7
(defstruct (parse #+common (:type list) #+opus43 (:type :list)
		  :conc-name :constructor)
  (root nil)
  (targetlist nil)
  (qualification nil))

;.. planner
a17 1
;.. planner
a20 1
;.. planner
a23 10
(defstruct (root #+common (:type list) #+opus43 (:type :list)
		 :conc-name :constructor)
  (levels 0)
  (command-type nil)
  (result-relation nil)
  (rangetable nil)
  (priority 0)
  (ruleinfo nil))

;.. init_query_planner
a26 1
;.. init_query_planner
a29 1
;.. init_query_planner
d33 1
a33 1
;.. init_query_planner, planner, subst_rangetable
d51 1
a51 1
;.. planout_rangetable_elements, print_rtentries, print_subplan
d56 5
a60 4
;.. compute_selec, create_index_path, find_bestindex
;.. find_first_inh_rtentry, get_rel, get_secondary_indices
;.. index_innerjoin, init_query_planner, planner
;.. planout_rangetable_elements, print_rtentries, print_var
d64 2
a65 1
;.. all_non_archival
d69 1
a69 1
;.. all_non_archival
d74 1
d78 3
d84 2
d92 5
a96 3
;.. build_tlist, compute_tuple_width, copy_vars, find_sortkey
;.. find_unused_resnos, fix_targetlist, make_resulttlist
;.. reference_tlist, sort_result, tempref_tlist, tlistentry_member
d100 7
a106 5
;.. add_tl_element, build_tlist, copy_vars, find_sortkey
;.. fix_targetlist, fix_vars, flatten_tlist, get_newtlist, init_tlist
;.. make_newtlist, make_resulttlist, match_var_index_keys, match_varid
;.. matching_tlvar, nottlist_member, query_planner, reference_tlist
;.. target_rangetable, tempref_tlist, tlist_member, tlistentry_member
d110 1
d114 2
d119 61
d181 1
a181 1
;;;	getrelid
d183 1
a183 2
;;;	Given the range index of a relation, return the
;;;	corresponding relation id.
d186 4
a189 5
;.. compute_selec, create_index_path, find_bestindex, get_rel
;.. get_secondary_indices, index_innerjoin, init_query_planner
;.. print_var
(defmacro getrelid (rangeindex rangetable)
  `(rt_relid (nth (1- ,rangeindex) ,rangetable)))
d192 14
d208 2
a209 1
;;;	Given the range index of a relation, return its name.
d212 7
a218 1
;.. print_subplan, print_var
@
