1 | /* |
2 | * PROGRAM: JRD Access Method |
3 | * MODULE: exe_proto.h |
4 | * DESCRIPTION: Prototype header file for exe.cpp |
5 | * |
6 | * The contents of this file are subject to the Interbase Public |
7 | * License Version 1.0 (the "License"); you may not use this file |
8 | * except in compliance with the License. You may obtain a copy |
9 | * of the License at http://www.Inprise.com/IPL.html |
10 | * |
11 | * Software distributed under the License is distributed on an |
12 | * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express |
13 | * or implied. See the License for the specific language governing |
14 | * rights and limitations under the License. |
15 | * |
16 | * The Original Code was created by Inprise Corporation |
17 | * and its predecessors. Portions created by Inprise Corporation are |
18 | * Copyright (C) Inprise Corporation. |
19 | * |
20 | * All Rights Reserved. |
21 | * Contributor(s): ______________________________________. |
22 | */ |
23 | |
24 | #ifndef JRD_EXE_PROTO_H |
25 | #define JRD_EXE_PROTO_H |
26 | |
27 | #include "../jrd/cmp_proto.h" |
28 | |
29 | namespace Jrd { |
30 | class jrd_req; |
31 | class jrd_tra; |
32 | class AssignmentNode; |
33 | } |
34 | |
35 | void EXE_assignment(Jrd::thread_db*, const Jrd::AssignmentNode*); |
36 | void EXE_assignment(Jrd::thread_db*, const Jrd::ValueExprNode*, const Jrd::ValueExprNode*); |
37 | void EXE_assignment(Jrd::thread_db* tdbb, const Jrd::ValueExprNode* to, dsc* from_desc, bool from_null, |
38 | const Jrd::ValueExprNode* missing_node, const Jrd::ValueExprNode* missing2_node); |
39 | |
40 | void EXE_execute_db_triggers(Jrd::thread_db*, Jrd::jrd_tra*, enum Jrd::jrd_req::req_ta); |
41 | void EXE_execute_ddl_triggers(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction, |
42 | bool preTriggers, int action); |
43 | const Jrd::StmtNode* EXE_looper(Jrd::thread_db* tdbb, Jrd::jrd_req* request, |
44 | const Jrd::StmtNode* in_node); |
45 | |
46 | void EXE_execute_triggers(Jrd::thread_db*, Jrd::trig_vec**, Jrd::record_param*, Jrd::record_param*, |
47 | Jrd::jrd_req::req_ta, Jrd::StmtNode::WhichTrigger); |
48 | |
49 | void EXE_receive(Jrd::thread_db*, Jrd::jrd_req*, USHORT, ULONG, UCHAR*, bool = false); |
50 | void EXE_release(Jrd::thread_db*, Jrd::jrd_req*); |
51 | void EXE_send(Jrd::thread_db*, Jrd::jrd_req*, USHORT, ULONG, const UCHAR*); |
52 | void EXE_start(Jrd::thread_db*, Jrd::jrd_req*, Jrd::jrd_tra*); |
53 | void EXE_unwind(Jrd::thread_db*, Jrd::jrd_req*); |
54 | void EXE_verb_cleanup(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction); |
55 | |
56 | namespace Jrd |
57 | { |
58 | // ASF: To make this class MT-safe in SS for v3, it should be AutoCacheRequest::release job to |
59 | // inform CMP that the request is available for subsequent usage. |
60 | class AutoCacheRequest |
61 | { |
62 | public: |
63 | AutoCacheRequest(thread_db* tdbb, USHORT aId, USHORT aWhich) |
64 | : id(aId), |
65 | which(aWhich), |
66 | request(tdbb->getAttachment()->findSystemRequest(tdbb, id, which)) |
67 | { |
68 | } |
69 | |
70 | AutoCacheRequest() |
71 | : id(0), |
72 | which(0), |
73 | request(NULL) |
74 | { |
75 | } |
76 | |
77 | ~AutoCacheRequest() |
78 | { |
79 | release(); |
80 | } |
81 | |
82 | public: |
83 | void reset(thread_db* tdbb, USHORT aId, USHORT aWhich) |
84 | { |
85 | release(); |
86 | |
87 | id = aId; |
88 | which = aWhich; |
89 | request = tdbb->getAttachment()->findSystemRequest(tdbb, id, which); |
90 | } |
91 | |
92 | void compile(thread_db* tdbb, const UCHAR* blr, ULONG blrLength) |
93 | { |
94 | if (request) |
95 | return; |
96 | |
97 | request = CMP_compile2(tdbb, blr, blrLength, true); |
98 | cacheRequest(); |
99 | } |
100 | |
101 | jrd_req* operator ->() |
102 | { |
103 | return request; |
104 | } |
105 | |
106 | operator jrd_req*() |
107 | { |
108 | return request; |
109 | } |
110 | |
111 | bool operator !() const |
112 | { |
113 | return !request; |
114 | } |
115 | |
116 | private: |
117 | inline void release() |
118 | { |
119 | if (request) |
120 | { |
121 | EXE_unwind(JRD_get_thread_data(), request); |
122 | request = NULL; |
123 | } |
124 | } |
125 | |
126 | inline void cacheRequest() |
127 | { |
128 | Jrd::Attachment* att = JRD_get_thread_data()->getAttachment(); |
129 | |
130 | if (which == IRQ_REQUESTS) |
131 | att->att_internal[id] = request->getStatement(); |
132 | else if (which == DYN_REQUESTS) |
133 | att->att_dyn_req[id] = request->getStatement(); |
134 | else |
135 | { |
136 | fb_assert(false); |
137 | } |
138 | } |
139 | |
140 | private: |
141 | USHORT id; |
142 | USHORT which; |
143 | jrd_req* request; |
144 | }; |
145 | |
146 | class AutoRequest |
147 | { |
148 | public: |
149 | AutoRequest() |
150 | : request(NULL) |
151 | { |
152 | } |
153 | |
154 | ~AutoRequest() |
155 | { |
156 | release(); |
157 | } |
158 | |
159 | public: |
160 | void reset() |
161 | { |
162 | release(); |
163 | } |
164 | |
165 | void compile(thread_db* tdbb, const UCHAR* blr, ULONG blrLength) |
166 | { |
167 | if (request) |
168 | return; |
169 | |
170 | request = CMP_compile2(tdbb, blr, blrLength, true); |
171 | } |
172 | |
173 | jrd_req* operator ->() |
174 | { |
175 | return request; |
176 | } |
177 | |
178 | operator jrd_req*() |
179 | { |
180 | return request; |
181 | } |
182 | |
183 | bool operator !() const |
184 | { |
185 | return !request; |
186 | } |
187 | |
188 | private: |
189 | inline void release() |
190 | { |
191 | if (request) |
192 | { |
193 | CMP_release(JRD_get_thread_data(), request); |
194 | request = NULL; |
195 | } |
196 | } |
197 | |
198 | private: |
199 | jrd_req* request; |
200 | }; |
201 | } |
202 | |
203 | #endif // JRD_EXE_PROTO_H |
204 | |