| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
1803
|
use 5.008001; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
45
|
|
|
2
|
1
|
|
|
1
|
|
6
|
use utf8; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
3
|
1
|
|
|
1
|
|
25
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
38
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings FATAL => 'all'; |
|
|
1
|
|
|
|
|
13
|
|
|
|
1
|
|
|
|
|
44
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
56
|
use Muldis::DB::Interface; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Muldis::DB::Engine::Example::Operators; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
########################################################################### |
|
10
|
|
|
|
|
|
|
########################################################################### |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
{ package Muldis::DB::Engine::Example; # module |
|
13
|
|
|
|
|
|
|
our $VERSION = 0.004000; |
|
14
|
|
|
|
|
|
|
# Note: This given version applies to all of this file's packages. |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
########################################################################### |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new_dbms { |
|
19
|
|
|
|
|
|
|
my ($class, $args) = @_; |
|
20
|
|
|
|
|
|
|
my ($dbms_config) = @{$args}{'dbms_config'}; |
|
21
|
|
|
|
|
|
|
return Muldis::DB::Engine::Example::Public::DBMS->new({ |
|
22
|
|
|
|
|
|
|
'dbms_config' => $dbms_config }); |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
########################################################################### |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
} # module Muldis::DB::Engine::Example |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
########################################################################### |
|
30
|
|
|
|
|
|
|
########################################################################### |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
{ package Muldis::DB::Engine::Example::Public::DBMS; # class |
|
33
|
|
|
|
|
|
|
use base 'Muldis::DB::Interface::DBMS'; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use Carp; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# User-supplied config data for this DBMS object / virtual machine. |
|
38
|
|
|
|
|
|
|
# For the moment, the Example Engine doesn't actually have anything |
|
39
|
|
|
|
|
|
|
# that can be configured in this way, so input $dbms_config is ignored. |
|
40
|
|
|
|
|
|
|
my $ATTR_DBMS_CONFIG = 'dbms_config'; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Lists of user-held objects associated with parts of this DBMS. |
|
43
|
|
|
|
|
|
|
# For each of these, Hash keys are obj .WHERE/addrs, vals the objs. |
|
44
|
|
|
|
|
|
|
# These should be weak obj-refs, so objs disappear from here |
|
45
|
|
|
|
|
|
|
my $ATTR_ASSOC_VARS = 'assoc_vars'; |
|
46
|
|
|
|
|
|
|
my $ATTR_ASSOC_FUNC_BINDINGS = 'assoc_func_bindings'; |
|
47
|
|
|
|
|
|
|
my $ATTR_ASSOC_PROC_BINDINGS = 'assoc_proc_bindings'; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Maintain actual state of the this DBMS' virtual machine. |
|
50
|
|
|
|
|
|
|
# TODO: the VM itself should be in another file, this attr with it. |
|
51
|
|
|
|
|
|
|
my $ATTR_TRANS_NEST_LEVEL = 'trans_nest_level'; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
########################################################################### |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub new { |
|
56
|
|
|
|
|
|
|
my ($class, $args) = @_; |
|
57
|
|
|
|
|
|
|
my $self = bless {}, $class; |
|
58
|
|
|
|
|
|
|
$self->_build( $args ); |
|
59
|
|
|
|
|
|
|
return $self; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _build { |
|
63
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
64
|
|
|
|
|
|
|
my ($dbms_config) = @{$args}{'dbms_config'}; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$self->{$ATTR_DBMS_CONFIG} = $dbms_config; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
$self->{$ATTR_ASSOC_VARS} = {}; |
|
69
|
|
|
|
|
|
|
$self->{$ATTR_ASSOC_FUNC_BINDINGS} = {}; |
|
70
|
|
|
|
|
|
|
$self->{$ATTR_ASSOC_PROC_BINDINGS} = {}; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$self->{$ATTR_TRANS_NEST_LEVEL} = 0; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
return; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub DESTROY { |
|
78
|
|
|
|
|
|
|
my ($self) = @_; |
|
79
|
|
|
|
|
|
|
# TODO: check for active trans and rollback ... or member VM does it. |
|
80
|
|
|
|
|
|
|
# Likewise with closing open files or whatever. |
|
81
|
|
|
|
|
|
|
return; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
########################################################################### |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub new_var { |
|
87
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
88
|
|
|
|
|
|
|
my ($decl_type) = @{$args}{'decl_type'}; |
|
89
|
|
|
|
|
|
|
return Muldis::DB::Engine::Example::Public::Var->new({ |
|
90
|
|
|
|
|
|
|
'dbms' => $self, 'decl_type' => $decl_type }); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub assoc_vars { |
|
94
|
|
|
|
|
|
|
my ($self) = @_; |
|
95
|
|
|
|
|
|
|
return [values %{$self->{$ATTR_ASSOC_VARS}}]; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub new_func_binding { |
|
99
|
|
|
|
|
|
|
my ($self) = @_; |
|
100
|
|
|
|
|
|
|
return Muldis::DB::Engine::Example::Public::FuncBinding->new({ |
|
101
|
|
|
|
|
|
|
'dbms' => $self }); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub assoc_func_bindings { |
|
105
|
|
|
|
|
|
|
my ($self) = @_; |
|
106
|
|
|
|
|
|
|
return [values %{$self->{$ATTR_ASSOC_FUNC_BINDINGS}}]; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub new_proc_binding { |
|
110
|
|
|
|
|
|
|
my ($self) = @_; |
|
111
|
|
|
|
|
|
|
return Muldis::DB::Engine::Example::Public::ProcBinding->new({ |
|
112
|
|
|
|
|
|
|
'dbms' => $self }); |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub assoc_proc_bindings { |
|
116
|
|
|
|
|
|
|
my ($self) = @_; |
|
117
|
|
|
|
|
|
|
return [values %{$self->{$ATTR_ASSOC_PROC_BINDINGS}}]; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
########################################################################### |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub call_func { |
|
123
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
124
|
|
|
|
|
|
|
my ($func_name, $f_args) = @{$args}{'func_name', 'args'}; |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# my $f = Muldis::DB::Engine::Example::Public::FuncBinding->new({ |
|
127
|
|
|
|
|
|
|
# 'dbms' => $self }); |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my $result = Muldis::DB::Engine::Example::Public::Var->new({ |
|
130
|
|
|
|
|
|
|
'dbms' => $self, 'decl_type' => 'sys.Core.Universal.Universal' }); |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# $f->bind_func({ 'func_name' => $func_name }); |
|
133
|
|
|
|
|
|
|
# $f->bind_result({ 'var' => $result }); |
|
134
|
|
|
|
|
|
|
# $f->bind_params({ 'args' => $f_args }); |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# $f->call(); |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
return $result; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
########################################################################### |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub call_proc { |
|
144
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
145
|
|
|
|
|
|
|
my ($proc_name, $upd_args, $ro_args) |
|
146
|
|
|
|
|
|
|
= @{$args}{'proc_name', 'upd_args', 'ro_args'}; |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# my $p = Muldis::DB::Engine::Example::Public::FuncBinding->new({ |
|
149
|
|
|
|
|
|
|
# 'dbms' => $self }); |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# $p->bind_proc({ 'proc_name' => $proc_name }); |
|
152
|
|
|
|
|
|
|
# $p->bind_upd_params({ 'args' => $upd_args }); |
|
153
|
|
|
|
|
|
|
# $p->bind_ro_params({ 'args' => $ro_args }); |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# $p->call(); |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
return; |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
########################################################################### |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub trans_nest_level { |
|
163
|
|
|
|
|
|
|
my ($self) = @_; |
|
164
|
|
|
|
|
|
|
return $self->{$ATTR_TRANS_NEST_LEVEL}; |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub start_trans { |
|
168
|
|
|
|
|
|
|
my ($self) = @_; |
|
169
|
|
|
|
|
|
|
# TODO: the actual work. |
|
170
|
|
|
|
|
|
|
$self->{$ATTR_TRANS_NEST_LEVEL} ++; |
|
171
|
|
|
|
|
|
|
return; |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub commit_trans { |
|
175
|
|
|
|
|
|
|
my ($self) = @_; |
|
176
|
|
|
|
|
|
|
confess q{commit_trans(): Could not commit a transaction;} |
|
177
|
|
|
|
|
|
|
. q{ none are currently active.} |
|
178
|
|
|
|
|
|
|
if $self->{$ATTR_TRANS_NEST_LEVEL} == 0; |
|
179
|
|
|
|
|
|
|
# TODO: the actual work. |
|
180
|
|
|
|
|
|
|
$self->{$ATTR_TRANS_NEST_LEVEL} --; |
|
181
|
|
|
|
|
|
|
return; |
|
182
|
|
|
|
|
|
|
} |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub rollback_trans { |
|
185
|
|
|
|
|
|
|
my ($self) = @_; |
|
186
|
|
|
|
|
|
|
confess q{rollback_trans(): Could not rollback a transaction;} |
|
187
|
|
|
|
|
|
|
. q{ none are currently active.} |
|
188
|
|
|
|
|
|
|
if $self->{$ATTR_TRANS_NEST_LEVEL} == 0; |
|
189
|
|
|
|
|
|
|
# TODO: the actual work. |
|
190
|
|
|
|
|
|
|
$self->{$ATTR_TRANS_NEST_LEVEL} --; |
|
191
|
|
|
|
|
|
|
return; |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
########################################################################### |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
} # class Muldis::DB::Engine::Example::Public::DBMS |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
########################################################################### |
|
199
|
|
|
|
|
|
|
########################################################################### |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
{ package Muldis::DB::Engine::Example::Public::Var; # class |
|
202
|
|
|
|
|
|
|
use base 'Muldis::DB::Interface::Var'; |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
use Carp; |
|
205
|
|
|
|
|
|
|
use Scalar::Util qw( refaddr weaken ); |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
my $ATTR_DBMS = 'dbms'; |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
my $ATTR_VAR = 'var'; |
|
210
|
|
|
|
|
|
|
# TODO: cache Perl-Hosted Muldis D version of $!var. |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
# Allow Var objs to update DBMS' "assoc" list re themselves. |
|
213
|
|
|
|
|
|
|
my $DBMS_ATTR_ASSOC_VARS = 'assoc_vars'; |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
########################################################################### |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
sub new { |
|
218
|
|
|
|
|
|
|
my ($class, $args) = @_; |
|
219
|
|
|
|
|
|
|
my $self = bless {}, $class; |
|
220
|
|
|
|
|
|
|
$self->_build( $args ); |
|
221
|
|
|
|
|
|
|
return $self; |
|
222
|
|
|
|
|
|
|
} |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
sub _build { |
|
225
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
226
|
|
|
|
|
|
|
my ($dbms, $decl_type) = @{$args}{'dbms', 'decl_type'}; |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
$self->{$ATTR_DBMS} = $dbms; |
|
229
|
|
|
|
|
|
|
$dbms->{$DBMS_ATTR_ASSOC_VARS}->{refaddr $self} = $self; |
|
230
|
|
|
|
|
|
|
weaken $dbms->{$DBMS_ATTR_ASSOC_VARS}->{refaddr $self}; |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
# $self->{$ATTR_VAR} = Muldis::DB::Engine::Example::VM::Var->new({ |
|
233
|
|
|
|
|
|
|
# 'decl_type' => $decl_type }); # TODO; or some such |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
return; |
|
236
|
|
|
|
|
|
|
} |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
sub DESTROY { |
|
239
|
|
|
|
|
|
|
my ($self) = @_; |
|
240
|
|
|
|
|
|
|
delete $self->{$ATTR_DBMS}->{$DBMS_ATTR_ASSOC_VARS}->{refaddr $self}; |
|
241
|
|
|
|
|
|
|
return; |
|
242
|
|
|
|
|
|
|
} |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
########################################################################### |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
sub fetch_ast { |
|
247
|
|
|
|
|
|
|
my ($self) = @_; |
|
248
|
|
|
|
|
|
|
# return $self->{$ATTR_VAR}->as_phmd(); # TODO; or some such |
|
249
|
|
|
|
|
|
|
return; |
|
250
|
|
|
|
|
|
|
} |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
########################################################################### |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
sub store_ast { |
|
255
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
256
|
|
|
|
|
|
|
my ($ast) = @{$args}{'ast'}; |
|
257
|
|
|
|
|
|
|
# $self->{$ATTR_VAR} = from_phmd( $ast ); # TODO; or some such |
|
258
|
|
|
|
|
|
|
return; |
|
259
|
|
|
|
|
|
|
} |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
########################################################################### |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
} # class Muldis::DB::Engine::Example::Public::Var |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
########################################################################### |
|
266
|
|
|
|
|
|
|
########################################################################### |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
{ package Muldis::DB::Engine::Example::Public::FuncBinding; # class |
|
269
|
|
|
|
|
|
|
use base 'Muldis::DB::Interface::FuncBinding'; |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
use Carp; |
|
272
|
|
|
|
|
|
|
use Scalar::Util qw( refaddr weaken ); |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
########################################################################### |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
# TODO. |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
########################################################################### |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
} # class Muldis::DB::Engine::Example::Public::FuncBinding |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
########################################################################### |
|
283
|
|
|
|
|
|
|
########################################################################### |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
{ package Muldis::DB::Engine::Example::Public::ProcBinding; # class |
|
286
|
|
|
|
|
|
|
use base 'Muldis::DB::Interface::ProcBinding'; |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
use Carp; |
|
289
|
|
|
|
|
|
|
use Scalar::Util qw( refaddr weaken ); |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
########################################################################### |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
# TODO. |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
########################################################################### |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
} # class Muldis::DB::Engine::Example::Public::ProcBinding |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
########################################################################### |
|
300
|
|
|
|
|
|
|
########################################################################### |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
1; # Magic true value required at end of a reusable file's code. |
|
303
|
|
|
|
|
|
|
__END__ |