61c421bf |
1 | puts "================" |
2 | puts "OCC1054" |
3 | puts "================" |
4 | puts "" |
5 | ####################################################################################### |
6 | # Mechanism of transactions' synchronization and mechanizm of nested transactions |
7 | ####################################################################################### |
8 | # Case 2 (nested mode OFF) |
9 | ####################################################################################### |
10 | |
11 | proc OCC1054_Check_dump {IsGood index good_index case} { |
12 | # Check dump |
13 | if { ${index} != ${good_index} } { |
14 | set IsGood 0 |
15 | puts "OCC1054 Error (case ${case} : index = ${index} good_index = ${good_index})" |
16 | } |
17 | return ${IsGood} |
18 | } |
19 | |
20 | proc OCC1054_Check_real_attribute {IsGood doc label good_real case} { |
21 | global ${doc} |
22 | # Check real attribute |
23 | set percent_max 0.1 |
24 | if [catch { set real [GetReal ${doc} ${label}] } message] { |
25 | set IsGood 0 |
26 | puts "OCC1054 Error (case ${case})" |
27 | } else { |
28 | set real_percent [expr abs(${real} - ${good_real}) / double(${good_real}) * 100.] |
29 | if {${real_percent} > ${percent_max}} { |
30 | puts "good_real = ${good_real}" |
31 | puts "real = ${real}" |
32 | puts "real_percent = ${real_percent}" |
33 | puts "OCC1054 Error (case ${case}-2)" |
34 | } |
35 | } |
36 | return ${IsGood} |
37 | } |
38 | |
39 | |
40 | set IsGood 1 |
41 | set Case 0 |
42 | |
43 | NewDocument doc1 |
44 | NewDocument doc2 |
45 | NewDocument doc3 |
46 | mtmCreate 4 |
47 | |
48 | mtmAdd doc1 |
49 | |
50 | mtmOpen |
51 | SetReal doc1 0:1 1 |
52 | mtmCommit tr1 |
53 | |
54 | set list [mtmDump] |
55 | ################################################################################ |
56 | # *** Dump of MTM *** |
57 | # There is one document ( "2809192" ) in the manager |
58 | # Nested transaction mode is off |
59 | # |
60 | # Undo: tr1 - 1 documents ( "2809192" ) < Last action |
61 | # |
62 | # *** End *** |
63 | ################################################################################ |
64 | set docnum0 [lindex ${list} 7] |
65 | set index1 [lsearch -exact ${list} "tr1"] |
66 | set docnum1 [lindex ${list} [expr ${index1} + 2]] |
67 | set index2 [lsearch -exact ${list} "Last"] |
68 | |
69 | # Check dump |
70 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum0} "one" [incr Case]] |
71 | set IsGood [OCC1054_Check_dump ${IsGood} ${index1} 21 [incr Case]] |
72 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum1} 1 [incr Case]] |
73 | set IsGood [OCC1054_Check_dump ${IsGood} ${index2} 29 [incr Case]] |
74 | |
75 | # Check real attributes |
76 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc1} 0:1 1 [incr Case]] |
77 | |
78 | |
79 | mtmAdd doc2 |
80 | |
81 | set list [mtmDump] |
82 | ################################################################################ |
83 | # *** Dump of MTM *** |
84 | # There are 2 documents ( "2809192" "2705536" ) in the manager |
85 | # Nested transaction mode is off |
86 | # |
87 | # Undo: tr1 - 1 documents ( "2809192" ) < Last action |
88 | # |
89 | # *** End *** |
90 | ################################################################################ |
91 | set docnum0 [lindex ${list} 7] |
92 | set index1 [lsearch -exact ${list} "tr1"] |
93 | set docnum1 [lindex ${list} [expr ${index1} + 2]] |
94 | set index2 [lsearch -exact ${list} "Last"] |
95 | |
96 | # Check dump |
97 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum0} 2 [incr Case]] |
98 | set IsGood [OCC1054_Check_dump ${IsGood} ${index1} 22 [incr Case]] |
99 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum1} 1 [incr Case]] |
100 | set IsGood [OCC1054_Check_dump ${IsGood} ${index2} 30 [incr Case]] |
101 | |
102 | # Check real attributes |
103 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc1} 0:1 1 [incr Case]] |
104 | |
105 | mtmOpen |
106 | SetReal doc2 0:1 2 |
107 | mtmCommit tr2 |
108 | |
109 | set list [mtmDump] |
110 | ################################################################################ |
111 | # *** Dump of MTM *** |
112 | # There are 2 documents ( "2809192" "2705536" ) in the manager |
113 | # Nested transaction mode is off |
114 | # |
115 | # Undo: tr1 - 1 documents ( "2809192" ) |
116 | # Undo: tr2 - 1 documents ( "2705536" ) < Last action |
117 | # |
118 | # *** End *** |
119 | ################################################################################ |
120 | set docnum0 [lindex ${list} 7] |
121 | set index1 [lsearch -exact ${list} "tr1"] |
122 | set docnum1 [lindex ${list} [expr ${index1} + 2]] |
123 | set index2 [lsearch -exact ${list} "tr2"] |
124 | set docnum2 [lindex ${list} [expr ${index2} + 2]] |
125 | set index3 [lsearch -exact ${list} "Last"] |
126 | |
127 | # Check dump |
128 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum0} 2 [incr Case]] |
129 | set IsGood [OCC1054_Check_dump ${IsGood} ${index1} 22 [incr Case]] |
130 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum1} 1 [incr Case]] |
131 | set IsGood [OCC1054_Check_dump ${IsGood} ${index2} 30 [incr Case]] |
132 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum2} 1 [incr Case]] |
133 | set IsGood [OCC1054_Check_dump ${IsGood} ${index3} 38 [incr Case]] |
134 | |
135 | # Check real attributes |
136 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc1} 0:1 1 [incr Case]] |
137 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc2} 0:1 2 [incr Case]] |
138 | |
139 | SetReal doc3 0:1 1 |
140 | mtmAdd doc3 |
141 | |
142 | set list [mtmDump] |
143 | ################################################################################ |
144 | # *** Dump of MTM *** |
145 | # There are 3 documents ( "2809192" "2705536" "3095112" ) in the manager |
146 | # Nested transaction mode is off |
147 | # |
148 | # Undo: tr1 - 1 documents ( "2809192" ) |
149 | # Undo: tr2 - 1 documents ( "2705536" ) < Last action |
150 | # |
151 | # *** End *** |
152 | ################################################################################ |
153 | set docnum0 [lindex ${list} 7] |
154 | set index1 [lsearch -exact ${list} "tr1"] |
155 | set docnum1 [lindex ${list} [expr ${index1} + 2]] |
156 | set index2 [lsearch -exact ${list} "tr2"] |
157 | set docnum2 [lindex ${list} [expr ${index2} + 2]] |
158 | set index3 [lsearch -exact ${list} "Last"] |
159 | |
160 | # Check dump |
161 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum0} 3 [incr Case]] |
162 | set IsGood [OCC1054_Check_dump ${IsGood} ${index1} 23 [incr Case]] |
163 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum1} 1 [incr Case]] |
164 | set IsGood [OCC1054_Check_dump ${IsGood} ${index2} 31 [incr Case]] |
165 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum2} 1 [incr Case]] |
166 | set IsGood [OCC1054_Check_dump ${IsGood} ${index3} 39 [incr Case]] |
167 | |
168 | # Check real attributes |
169 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc1} 0:1 1 [incr Case]] |
170 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc2} 0:1 2 [incr Case]] |
171 | |
172 | mtmOpen |
173 | SetReal doc1 0:2 2 |
174 | SetReal doc3 0:2 2 |
175 | mtmCommit tr3 |
176 | |
177 | set list [mtmDump] |
178 | ################################################################################ |
179 | # *** Dump of MTM *** |
180 | # There are 3 documents ( "2809192" "2705536" "3095112" ) in the manager |
181 | # Nested transaction mode is off |
182 | # |
183 | # Undo: tr1 - 1 documents ( "2809192" ) |
184 | # Undo: tr2 - 1 documents ( "2705536" ) |
185 | # Undo: tr3 - 2 documents ( "3095112" "2809192" ) < Last action |
186 | # |
187 | # *** End *** |
188 | ################################################################################ |
189 | set docnum0 [lindex ${list} 7] |
190 | set index1 [lsearch -exact ${list} "tr1"] |
191 | set docnum1 [lindex ${list} [expr ${index1} + 2]] |
192 | set index2 [lsearch -exact ${list} "tr2"] |
193 | set docnum2 [lindex ${list} [expr ${index2} + 2]] |
194 | set index3 [lsearch -exact ${list} "tr3"] |
195 | set docnum3 [lindex ${list} [expr ${index3} + 2]] |
196 | set index4 [lsearch -exact ${list} "Last"] |
197 | |
198 | # Check dump |
199 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum0} 3 [incr Case]] |
200 | set IsGood [OCC1054_Check_dump ${IsGood} ${index1} 23 [incr Case]] |
201 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum1} 1 [incr Case]] |
202 | set IsGood [OCC1054_Check_dump ${IsGood} ${index2} 31 [incr Case]] |
203 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum2} 1 [incr Case]] |
204 | set IsGood [OCC1054_Check_dump ${IsGood} ${index3} 39 [incr Case]] |
205 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum3} 2 [incr Case]] |
206 | set IsGood [OCC1054_Check_dump ${IsGood} ${index4} 48 [incr Case]] |
207 | |
208 | # Check real attributes |
209 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc1} 0:1 1 [incr Case]] |
210 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc1} 0:2 2 [incr Case]] |
211 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc2} 0:1 2 [incr Case]] |
212 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc3} 0:2 2 [incr Case]] |
213 | |
214 | mtmOpen |
215 | SetReal doc2 0:2 2 |
216 | SetReal doc3 0:3 3 |
217 | mtmCommit tr4 |
218 | |
219 | set list [mtmDump] |
220 | ################################################################################ |
221 | # *** Dump of MTM *** |
222 | # There are 3 documents ( "2809192" "2705536" "3095112" ) in the manager |
223 | # Nested transaction mode is off |
224 | # |
225 | # Undo: tr1 - 1 documents ( "2809192" ) |
226 | # Undo: tr2 - 1 documents ( "2705536" ) |
227 | # Undo: tr3 - 2 documents ( "3095112" "2809192" ) |
228 | # Undo: tr4 - 2 documents ( "3095112" "2705536" ) < Last action |
229 | # |
230 | # *** End *** |
231 | ################################################################################ |
232 | set docnum0 [lindex ${list} 7] |
233 | set index1 [lsearch -exact ${list} "tr1"] |
234 | set docnum1 [lindex ${list} [expr ${index1} + 2]] |
235 | set index2 [lsearch -exact ${list} "tr2"] |
236 | set docnum2 [lindex ${list} [expr ${index2} + 2]] |
237 | set index3 [lsearch -exact ${list} "tr3"] |
238 | set docnum3 [lindex ${list} [expr ${index3} + 2]] |
239 | set index4 [lsearch -exact ${list} "tr4"] |
240 | set docnum4 [lindex ${list} [expr ${index4} + 2]] |
241 | set index5 [lsearch -exact ${list} "Last"] |
242 | |
243 | # Check dump |
244 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum0} 3 [incr Case]] |
245 | set IsGood [OCC1054_Check_dump ${IsGood} ${index1} 23 [incr Case]] |
246 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum1} 1 [incr Case]] |
247 | set IsGood [OCC1054_Check_dump ${IsGood} ${index2} 31 [incr Case]] |
248 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum2} 1 [incr Case]] |
249 | set IsGood [OCC1054_Check_dump ${IsGood} ${index3} 39 [incr Case]] |
250 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum3} 2 [incr Case]] |
251 | set IsGood [OCC1054_Check_dump ${IsGood} ${index4} 48 [incr Case]] |
252 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum4} 2 [incr Case]] |
253 | set IsGood [OCC1054_Check_dump ${IsGood} ${index5} 57 [incr Case]] |
254 | |
255 | # Check real attributes |
256 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc1} 0:1 1 [incr Case]] |
257 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc1} 0:2 2 [incr Case]] |
258 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc2} 0:1 2 [incr Case]] |
259 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc2} 0:2 2 [incr Case]] |
260 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc3} 0:2 2 [incr Case]] |
261 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc3} 0:3 3 [incr Case]] |
262 | |
263 | mtmOpen |
264 | SetReal doc1 0:3 3 |
265 | SetReal doc2 0:3 3 |
266 | mtmCommit tr5 |
267 | |
268 | set list [mtmDump] |
269 | ################################################################################ |
270 | # *** Dump of MTM *** |
271 | # There are 3 documents ( "2809192" "2705536" "3095112" ) in the manager |
272 | # Nested transaction mode is off |
273 | # |
274 | # Undo: tr2 - 1 documents ( "2705536" ) |
275 | # Undo: tr3 - 2 documents ( "3095112" "2809192" ) |
276 | # Undo: tr4 - 2 documents ( "3095112" "2705536" ) |
277 | # Undo: tr5 - 2 documents ( "2705536" "2809192" ) < Last action |
278 | # |
279 | # *** End *** |
280 | ################################################################################ |
281 | set docnum0 [lindex ${list} 7] |
282 | set index1 [lsearch -exact ${list} "tr2"] |
283 | set docnum1 [lindex ${list} [expr ${index1} + 2]] |
284 | set index2 [lsearch -exact ${list} "tr3"] |
285 | set docnum2 [lindex ${list} [expr ${index2} + 2]] |
286 | set index3 [lsearch -exact ${list} "tr4"] |
287 | set docnum3 [lindex ${list} [expr ${index3} + 2]] |
288 | set index4 [lsearch -exact ${list} "tr5"] |
289 | set docnum4 [lindex ${list} [expr ${index4} + 2]] |
290 | set index5 [lsearch -exact ${list} "Last"] |
291 | |
292 | # Check dump |
293 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum0} 3 [incr Case]] |
294 | set IsGood [OCC1054_Check_dump ${IsGood} ${index1} 23 [incr Case]] |
295 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum1} 1 [incr Case]] |
296 | set IsGood [OCC1054_Check_dump ${IsGood} ${index2} 31 [incr Case]] |
297 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum2} 2 [incr Case]] |
298 | set IsGood [OCC1054_Check_dump ${IsGood} ${index3} 40 [incr Case]] |
299 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum3} 2 [incr Case]] |
300 | set IsGood [OCC1054_Check_dump ${IsGood} ${index4} 49 [incr Case]] |
301 | set IsGood [OCC1054_Check_dump ${IsGood} ${docnum4} 2 [incr Case]] |
302 | set IsGood [OCC1054_Check_dump ${IsGood} ${index5} 58 [incr Case]] |
303 | |
304 | # Check real attributes |
305 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc1} 0:1 1 [incr Case]] |
306 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc1} 0:2 2 [incr Case]] |
307 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc1} 0:3 3 [incr Case]] |
308 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc2} 0:1 2 [incr Case]] |
309 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc2} 0:2 2 [incr Case]] |
310 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc2} 0:3 3 [incr Case]] |
311 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc3} 0:2 2 [incr Case]] |
312 | set IsGood [OCC1054_Check_real_attribute ${IsGood} ${doc3} 0:3 3 [incr Case]] |
313 | |
314 | if { ${IsGood} == 1 } { |
315 | puts "OCC1054 OK" |
316 | } else { |
317 | puts "OCC1054 Error" |
318 | } |