Coverage report: /home/ellis/comp/core/lib/obj/plan.lisp
Kind | Covered | All | % |
expression | 0 | 9 | 0.0 |
branch | 0 | 0 | nil |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; plan.lisp --- Generic Plans
3
;; This package provides base classes for various 'Plans' such as Query Plans
4
;; in OBJ/QUERY and other various Execution Contexts throughout the core.
6
;; ref: https://github.com/postgres/postgres/tree/master/src/backend/executor
8
#| postgres query processing
10
Query Processing Control Flow
11
-----------------------------
13
This is a sketch of control flow for full query processing:
19
creates per-query context
20
switch to per-query context to run ExecInitNode
21
AfterTriggerBeginQuery
22
ExecInitNode --- recursively scans plan tree
24
recurse into subsidiary nodes
26
creates per-tuple context
30
ExecProcNode --- recursively called in per-query context
31
ExecEvalExpr --- called in per-tuple context
32
ResetExprContext --- to free memory
35
ExecPostprocessPlan --- run any unfinished ModifyTable nodes
39
ExecEndNode --- recursively releases resources
41
frees per-query context and child contexts
48
ASDF systems depend on a PLAN object which specifies the order of execution of
49
a set of actions - the default ordering is sequential. This plan is used to
52
ASDF actions may refer to an associated ACTION-STATUS object which stores the
53
current state of an action's progress:
55
;; STAMP KEEP-P DONE-P NEED-P symbol bitmap previously currently
56
;; not-nil T T T => GOOD 7 up-to-date done (e.g. file previously loaded)
57
;; not-nil T T NIL => HERE 6 up-to-date unplanned yet done
58
;; not-nil T NIL T => REDO 5 up-to-date planned (e.g. file to load)
59
;; not-nil T NIL NIL => SKIP 4 up-to-date unplanned (e.g. file compiled)
60
;; not-nil NIL T T => DONE 3 out-of-date done
61
;; not-nil NIL T NIL => WHAT 2 out-of-date unplanned yet done(?)
62
;; NIL NIL NIL T => TODO 1 out-of-date planned
63
;; NIL NIL NIL NIL => VOID 0 out-of-date unplanned
65
;; Note that a VOID status cannot happen as part of a transitive dependency of a wanted node
66
;; while traversing a node with TRAVERSE-ACTION; it can only happen while checking whether an
67
;; action is up-to-date with ACTION-UP-TO-DATE-P.
69
;; When calling TRAVERSE-ACTION, the +need-bit+ is set,
70
;; unless the action is up-to-date and not needed-in-image (HERE, SKIP).
71
;; When PERFORMing an action, the +done-bit+ is set.
72
;; When the +need-bit+ is set but not the +done-bit+, the level slot indicates which level of
73
;; OPERATE it was last marked needed for; if it happens to be needed at a higher-level, then
74
;; its urgency (and that of its transitive dependencies) must be escalated so that it will be
75
;; done before the end of this level of operate.
77
;; Also, when no ACTION-STATUS is associated to an action yet, NIL serves as a bottom value.
79
(defparameter +keep-bit+ 4)
80
(defparameter +done-bit+ 2)
81
(defparameter +need-bit+ 1)
82
(defparameter +good-bits+ 7)
83
(defparameter +todo-bits+ 1)
84
(defparameter +void-bits+ 0)
86
(defparameter +status-good+
87
(make-instance 'action-status :bits +good-bits+ :stamp t))
88
(defparameter +status-todo+
89
(make-instance 'action-status :bits +todo-bits+ :stamp nil))
90
(defparameter +status-void+
91
(make-instance 'action-status :bits +void-bits+ :stamp nil)))
93
;;;; The four different actual traversals:
94
;; * TRAVERSE-ACTION o c T: Ensure all dependencies are either up-to-date in-image, or planned
95
;; * TRAVERSE-ACTION o c NIL: Ensure all dependencies are up-to-date or planned, in-image or not
96
;; * ACTION-UP-TO-DATE-P: Check whether some (defsystem-depends-on ?) dependencies are up to date
97
;; * COLLECT-ACTION-DEPENDENCIES: Get the dependencies (filtered), don't change any status
99
;;;; High-level interface: make-plan, perform-plan
102
(in-package :obj/plan)
104
;; RESEARCH 2024-10-27: dynamic plans
105
(defclass plan () ())
107
(defclass logical-plan (plan) ())
109
(defclass physical-plan (plan) ())
111
(defclass planner () ())
113
(defgeneric plan-state (self))
114
(defgeneric (setf plan-state) (new-state self))
115
(defgeneric plan-nodes (self))
117
(defgeneric make-physical-plan (plan)
118
(:documentation "Create a physical plan from logical plan."))