ovsdb: Add support for weak references.
[sliver-openvswitch.git] / tests / ovsdb-execution.at
1 AT_BANNER([OVSDB -- execution])
2
3 m4_define([ORDINAL_SCHEMA],
4   [[{"name": "ordinals",
5      "tables": {
6        "ordinals": {
7          "columns": {
8            "number": {"type": "integer"},
9            "name": {"type": "string"}}}}}]])
10
11 m4_define([CONSTRAINT_SCHEMA],
12   [[{"name": "constraints",
13      "tables": {
14        "a": {
15          "columns": {
16            "a": {"type": "integer"},
17            "a2a": {"type": {"key": {"type": "uuid", "refTable": "a"},
18                             "min": 0, "max": "unlimited"}},
19            "a2b": {"type": {"key": {"type": "uuid", "refTable": "b"},
20                             "min": 0, "max": "unlimited"}}}},
21        "b": {
22          "columns": {
23            "b": {"type": "integer"},
24            "b2a": {"type": {"key": {"type": "uuid", "refTable": "a"},
25                             "min": 0, "max": "unlimited"}},
26            "b2b": {"type": {"key": {"type": "uuid", "refTable": "b"},
27                             "min": 0, "max": "unlimited"}}}},
28        "constrained": {
29          "columns": {
30            "positive": {"type": {"key": {"type": "integer",
31                                          "minInteger": 1}}}}}}}]])
32
33 m4_define([WEAK_SCHEMA],
34   [[{"name": "weak",
35      "tables": {
36        "a": {
37          "columns": {
38            "a": {"type": "integer"},
39            "a2a": {"type": {"key": {"type": "uuid",
40                                     "refTable": "a",
41                                     "refType": "weak"},
42                             "min": 0, "max": "unlimited"}},
43            "a2a1": {"type": {"key": {"type": "uuid",
44                                      "refTable": "a",
45                                      "refType": "weak"}}},
46            "a2b": {"type": {"key": {"type": "uuid",
47                                     "refTable": "b",
48                                     "refType": "weak"}}}}},
49        "b": {
50          "columns": {
51            "b": {"type": "integer"},
52            "b2a": {"type": {"key": {"type": "uuid",
53                                     "refTable": "a",
54                                     "refType": "weak"},
55                             "min": 0, "max": "unlimited"}}}}}}]])
56
57 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
58 #
59 # Runs "test-ovsdb execute" with the given SCHEMA and each of the
60 # TRANSACTIONS (which should be a quoted list of quoted strings).
61 #
62 # Checks that the overall output is OUTPUT, but UUIDs in the output
63 # are replaced by markers of the form <N> where N is a number.  The
64 # first unique UUID is replaced by <0>, the next by <1>, and so on.
65 # If a given UUID appears more than once it is always replaced by the
66 # same marker.
67 #
68 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
69 m4_define([OVSDB_CHECK_EXECUTION], 
70   [AT_SETUP([$1])
71    AT_KEYWORDS([ovsdb execute execution positive $5])
72    AT_CHECK([test-ovsdb execute '$2' m4_foreach([txn], [$3], [ 'txn'])],
73      [0], [stdout], [])
74    AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [$4])
75    AT_CLEANUP])
76
77 m4_define([EXECUTION_EXAMPLES], [
78 dnl At one point the "commit" code ignored new rows with all-default values,
79 dnl so this checks for that problem.
80 OVSDB_CHECK_EXECUTION([insert default row, query table],
81   [ORDINAL_SCHEMA], 
82   [[[["ordinals",
83       {"op": "insert",
84        "table": "ordinals",
85        "row": {}}]]],
86    [[["ordinals",
87       {"op": "select",
88        "table": "ordinals",
89        "where": []}]]]],
90   [[[{"uuid":["uuid","<0>"]}]
91 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"","number":0}]}]
92 ]])
93
94 OVSDB_CHECK_EXECUTION([insert row, query table],
95   [ORDINAL_SCHEMA], 
96   [[[["ordinals",
97       {"op": "insert",
98        "table": "ordinals",
99        "row": {"number": 0, "name": "zero"}}]]],
100    [[["ordinals",
101       {"op": "select",
102        "table": "ordinals",
103        "where": []}]]]],
104   [[[{"uuid":["uuid","<0>"]}]
105 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]}]
106 ]])
107
108 OVSDB_CHECK_EXECUTION([insert rows, query by value],
109   [ORDINAL_SCHEMA],
110   [[[["ordinals",
111       {"op": "insert",
112        "table": "ordinals",
113        "row": {"number": 0, "name": "zero"}}]]],
114    [[["ordinals",
115       {"op": "insert",
116        "table": "ordinals",
117        "row": {"number": 1, "name": "one"}}]]],
118    [[["ordinals",
119       {"op": "select",
120        "table": "ordinals",
121        "where": [["name", "==", "zero"]]}]]],
122    [[["ordinals",
123       {"op": "select",
124        "table": "ordinals",
125        "where": [["name", "==", "one"]]}]]]],
126   [[[{"uuid":["uuid","<0>"]}]
127 [{"uuid":["uuid","<1>"]}]
128 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]}]
129 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
130 ]])
131
132 OVSDB_CHECK_EXECUTION([insert rows, query by named-uuid],
133   [ORDINAL_SCHEMA],
134   [[[["ordinals",
135       {"op": "insert",
136        "table": "ordinals",
137        "row": {"number": 0, "name": "zero"},
138        "uuid-name": "first"},
139       {"op": "insert",
140        "table": "ordinals",
141        "row": {"number": 1, "name": "one"},
142        "uuid-name": "second"},
143       {"op": "select",
144        "table": "ordinals",
145        "where": [["_uuid", "==", ["named-uuid", "first"]]]},
146       {"op": "select",
147        "table": "ordinals",
148        "where": [["_uuid", "==", ["named-uuid", "second"]]]}]]]],
149   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]},{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
150 ]])
151
152 OVSDB_CHECK_EXECUTION([insert rows, update rows by value],
153   [ORDINAL_SCHEMA],
154   [[[["ordinals",
155       {"op": "insert",
156        "table": "ordinals",
157        "row": {"number": 0, "name": "zero"},
158        "uuid-name": "first"}]]],
159    [[["ordinals",
160       {"op": "insert",
161        "table": "ordinals",
162        "row": {"number": 1, "name": "one"},
163        "uuid-name": "first"}]]],
164    [[["ordinals",
165       {"op": "update",
166        "table": "ordinals",
167        "where": [["name", "==", "zero"]],
168        "row": {"name": "nought"}}]]],
169    [[["ordinals",
170       {"op": "select",
171        "table": "ordinals",
172        "where": [],
173        "sort": ["number"]}]]]],
174   [[[{"uuid":["uuid","<0>"]}]
175 [{"uuid":["uuid","<1>"]}]
176 [{"count":1}]
177 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"nought","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
178 ]])
179
180 OVSDB_CHECK_EXECUTION([insert rows, mutate rows],
181   [ORDINAL_SCHEMA],
182   [[[["ordinals",
183       {"op": "insert",
184        "table": "ordinals",
185        "row": {"number": 0, "name": "zero"},
186        "uuid-name": "first"}]]],
187    [[["ordinals",
188       {"op": "insert",
189        "table": "ordinals",
190        "row": {"number": 1, "name": "one"},
191        "uuid-name": "first"}]]],
192    [[["ordinals",
193       {"op": "mutate",
194        "table": "ordinals",
195        "where": [["name", "==", "zero"]],
196        "mutations": [["number", "+=", 2]]}]]],
197    [[["ordinals",
198       {"op": "select",
199        "table": "ordinals",
200        "where": [],
201        "sort": ["number"]}]]]],
202   [[[{"uuid":["uuid","<0>"]}]
203 [{"uuid":["uuid","<1>"]}]
204 [{"count":1}]
205 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1},{"_uuid":["uuid","<0>"],"_version":["uuid","<3>"],"name":"zero","number":2}]}]
206 ]])
207
208 OVSDB_CHECK_EXECUTION([insert rows, delete by named-uuid],
209   [ORDINAL_SCHEMA],
210   [[[["ordinals",
211       {"op": "insert",
212        "table": "ordinals",
213        "row": {"number": 0, "name": "zero"},
214        "uuid-name": "first"},
215       {"op": "insert",
216        "table": "ordinals",
217        "row": {"number": 1, "name": "one"},
218        "uuid-name": "second"},
219       {"op": "delete",
220        "table": "ordinals",
221        "where": [["_uuid", "==", ["named-uuid", "first"]]]},
222       {"op": "select",
223        "table": "ordinals",
224        "where": [],
225        "columns": ["name","number"]}]]]],
226   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":1},{"rows":[{"name":"one","number":1}]}]
227 ]])
228
229 OVSDB_CHECK_EXECUTION([insert rows, delete rows by value],
230   [ORDINAL_SCHEMA],
231   [[[["ordinals",
232       {"op": "insert",
233        "table": "ordinals",
234        "row": {"number": 0, "name": "zero"},
235        "uuid-name": "first"}]]],
236    [[["ordinals",
237       {"op": "insert",
238        "table": "ordinals",
239        "row": {"number": 1, "name": "one"},
240        "uuid-name": "first"}]]],
241    [[["ordinals",
242       {"op": "delete",
243        "table": "ordinals",
244        "where": [["name", "==", "zero"]]}]]],
245    [[["ordinals",
246       {"op": "select",
247        "table": "ordinals",
248        "where": []}]]]],
249   [[[{"uuid":["uuid","<0>"]}]
250 [{"uuid":["uuid","<1>"]}]
251 [{"count":1}]
252 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1}]}]
253 ]])
254
255 OVSDB_CHECK_EXECUTION([insert rows, delete by (non-matching) value],
256   [ORDINAL_SCHEMA],
257   [[[["ordinals",
258       {"op": "insert",
259        "table": "ordinals",
260        "row": {"number": 0, "name": "zero"},
261        "uuid-name": "first"}]]],
262    [[["ordinals",
263       {"op": "insert",
264        "table": "ordinals",
265        "row": {"number": 1, "name": "one"},
266        "uuid-name": "first"}]]],
267    [[["ordinals",
268       {"op": "delete",
269        "table": "ordinals",
270        "where": [["name", "==", "nought"]]}]]],
271    [[["ordinals",
272       {"op": "select",
273        "table": "ordinals",
274        "where": [],
275        "sort": ["number"]}]]]],
276   [[[{"uuid":["uuid","<0>"]}]
277 [{"uuid":["uuid","<1>"]}]
278 [{"count":0}]
279 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
280 ]])
281
282 OVSDB_CHECK_EXECUTION([insert rows, delete all],
283   [ORDINAL_SCHEMA],
284   [[[["ordinals",
285       {"op": "insert",
286        "table": "ordinals",
287        "row": {"number": 0, "name": "zero"},
288        "uuid-name": "first"},
289       {"op": "insert",
290        "table": "ordinals",
291        "row": {"number": 1, "name": "one"},
292        "uuid-name": "second"},
293       {"op": "delete",
294        "table": "ordinals",
295        "where": []},
296       {"op": "select",
297        "table": "ordinals",
298        "where": [],
299        "columns": ["name","number"]}]]]],
300   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":2},{"rows":[]}]
301 ]])
302
303 OVSDB_CHECK_EXECUTION([insert row, query table, commit],
304   [ORDINAL_SCHEMA],
305   [[[["ordinals",
306       {"op": "insert",
307        "table": "ordinals",
308        "row": {"number": 0, "name": "zero"}},
309       {"op": "select",
310        "table": "ordinals",
311        "where": []},
312       {"op": "commit",
313        "durable": false}]]]],
314   [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
315 ]])
316
317 OVSDB_CHECK_EXECUTION([insert row, query table, commit durably],
318   [ORDINAL_SCHEMA],
319   [[[["ordinals",
320       {"op": "insert",
321        "table": "ordinals",
322        "row": {"number": 0, "name": "zero"}},
323       {"op": "select",
324        "table": "ordinals",
325        "where": []},
326       {"op": "commit",
327        "durable": true}]]]],
328   [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
329 ]])
330
331 OVSDB_CHECK_EXECUTION([equality wait with correct rows],
332   [ORDINAL_SCHEMA],
333   [[[["ordinals",
334       {"op": "insert",
335        "table": "ordinals",
336        "row": {"number": 0, "name": "zero"}},
337       {"op": "insert",
338        "table": "ordinals",
339        "row": {"number": 1, "name": "one"}},
340       {"op": "wait",
341        "timeout": 0,
342        "table": "ordinals",
343        "where": [],
344        "columns": ["name", "number"],
345        "until": "==",
346        "rows": [{"name": "zero", "number": 0},
347                 {"name": "one", "number": 1}]}]]]],
348   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
349 ]])
350
351 OVSDB_CHECK_EXECUTION([equality wait with extra row],
352   [ORDINAL_SCHEMA],
353   [[[["ordinals",
354       {"op": "insert",
355        "table": "ordinals",
356        "row": {"number": 0, "name": "zero"}},
357       {"op": "insert",
358        "table": "ordinals",
359        "row": {"number": 1, "name": "one"}},
360       {"op": "wait",
361        "timeout": 0,
362        "table": "ordinals",
363        "where": [],
364        "columns": ["name", "number"],
365        "until": "==",
366        "rows": [{"name": "zero", "number": 0},
367                 {"name": "one", "number": 1},
368                 {"name": "two", "number": 2}]}]]]],
369   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
370 ]])
371
372 OVSDB_CHECK_EXECUTION([equality wait with missing row],
373   [ORDINAL_SCHEMA],
374   [[[["ordinals",
375       {"op": "insert",
376        "table": "ordinals",
377        "row": {"number": 0, "name": "zero"}},
378       {"op": "insert",
379        "table": "ordinals",
380        "row": {"number": 1, "name": "one"}},
381       {"op": "wait",
382        "timeout": 0,
383        "table": "ordinals",
384        "where": [],
385        "columns": ["name", "number"],
386        "until": "==",
387        "rows": [{"name": "one", "number": 1}]}]]]],
388   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
389 ]])
390
391 OVSDB_CHECK_EXECUTION([inequality wait with correct rows],
392   [ORDINAL_SCHEMA],
393   [[[["ordinals",
394       {"op": "insert",
395        "table": "ordinals",
396        "row": {"number": 0, "name": "zero"}},
397       {"op": "insert",
398        "table": "ordinals",
399        "row": {"number": 1, "name": "one"}},
400       {"op": "wait",
401        "timeout": 0,
402        "table": "ordinals",
403        "where": [],
404        "columns": ["name", "number"],
405        "until": "!=",
406        "rows": [{"name": "zero", "number": 0},
407                 {"name": "one", "number": 1}]}]]]],
408   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
409 ]])
410
411 OVSDB_CHECK_EXECUTION([inequality wait with extra row],
412   [ORDINAL_SCHEMA],
413   [[[["ordinals",
414       {"op": "insert",
415        "table": "ordinals",
416        "row": {"number": 0, "name": "zero"}},
417       {"op": "insert",
418        "table": "ordinals",
419        "row": {"number": 1, "name": "one"}},
420       {"op": "wait",
421        "timeout": 0,
422        "table": "ordinals",
423        "where": [],
424        "columns": ["name", "number"],
425        "until": "!=",
426        "rows": [{"name": "zero", "number": 0},
427                 {"name": "one", "number": 1},
428                 {"name": "two", "number": 2}]}]]]],
429   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
430 ]])
431
432 OVSDB_CHECK_EXECUTION([inequality wait with missing row],
433   [ORDINAL_SCHEMA],
434   [[[["ordinals",
435       {"op": "insert",
436        "table": "ordinals",
437        "row": {"number": 0, "name": "zero"}},
438       {"op": "insert",
439        "table": "ordinals",
440        "row": {"number": 1, "name": "one"}},
441       {"op": "wait",
442        "timeout": 0,
443        "table": "ordinals",
444        "where": [],
445        "columns": ["name", "number"],
446        "until": "!=",
447        "rows": [{"name": "one", "number": 1}]}]]]],
448   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
449 ]])
450
451 OVSDB_CHECK_EXECUTION([insert and update constraints],
452   [CONSTRAINT_SCHEMA],
453   [[[["constraints",
454       {"op": "insert",
455        "table": "constrained",
456        "row": {}}]]],
457    [[["constraints",
458       {"op": "insert",
459        "table": "constrained",
460        "row": {"positive": -1}}]]],
461    [[["constraints",
462       {"op": "update",
463        "table": "constrained",
464        "where": [],
465        "row": {"positive": -2}}]]]],
466   [[[{"details":"0 is less than minimum allowed value 1","error":"constraint violation"}]
467 [{"details":"-1 is less than minimum allowed value 1","error":"constraint violation"}]
468 [{"details":"-2 is less than minimum allowed value 1","error":"constraint violation"}]
469 ]])
470
471 OVSDB_CHECK_EXECUTION([referential integrity -- simple],
472   [CONSTRAINT_SCHEMA],
473   [[[["constraints",
474       {"op": "insert",
475        "table": "b",
476        "row": {"b": 1},
477        "uuid-name": "brow"},
478       {"op": "insert",
479        "table": "a",
480        "row": {"a": 0,
481                "a2b": ["set", [["named-uuid", "brow"]]]}},
482       {"op": "insert",
483        "table": "a",
484        "row": {"a": 1,
485                "a2b": ["set", [["named-uuid", "brow"]]]}},
486       {"op": "insert",
487        "table": "a",
488        "row": {"a": 2,
489                "a2b": ["set", [["named-uuid", "brow"]]]}}]]],
490    [[["constraints",
491       {"op": "delete",
492        "table": "b",
493        "where": []}]]],
494    [[["constraints",
495       {"op": "delete",
496        "table": "a",
497        "where": [["a", "==", 0]]}]]],
498    [[["constraints",
499       {"op": "delete",
500        "table": "b",
501        "where": []}]]],
502    [[["constraints",
503       {"op": "delete",
504        "table": "a",
505        "where": [["a", "==", 1]]}]]],
506    [[["constraints",
507       {"op": "delete",
508        "table": "b",
509        "where": []}]]],
510    [[["constraints",
511       {"op": "delete",
512        "table": "a",
513        "where": [["a", "==", 2]]}]]],
514    [[["constraints",
515       {"op": "delete",
516        "table": "b",
517        "where": []}]]]],
518   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]
519 [{"count":1},{"details":"cannot delete b row <0> because of 3 remaining reference(s)","error":"referential integrity violation"}]
520 [{"count":1}]
521 [{"count":1},{"details":"cannot delete b row <0> because of 2 remaining reference(s)","error":"referential integrity violation"}]
522 [{"count":1}]
523 [{"count":1},{"details":"cannot delete b row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
524 [{"count":1}]
525 [{"count":1}]
526 ]])
527
528 OVSDB_CHECK_EXECUTION([referential integrity -- mutual references],
529   [CONSTRAINT_SCHEMA],
530   [[[["constraints",
531       {"op": "insert",
532        "table": "a",
533        "row": {"a": 0,
534                "a2b": ["set", [["named-uuid", "row2"]]],
535                "a2a": ["set", [["named-uuid", "row1"]]]},
536        "uuid-name": "row1"},
537       {"op": "insert",
538        "table": "b",
539        "row": {"b": 1,
540                "b2b": ["set", [["named-uuid", "row2"]]],
541                "b2a": ["set", [["named-uuid", "row1"]]]},
542        "uuid-name": "row2"}]]],
543    [[["constraints",
544       {"op": "insert",
545        "table": "a",
546        "row": {"a2b": ["set", [["uuid", "b516b960-5b19-4fc2-bb82-fe1cbd6d0241"]]]}}]]],
547    [[["constraints",
548       {"op": "delete",
549        "table": "a",
550        "where": [["a", "==", 0]]}]]],
551    [[["constraints",
552       {"op": "delete",
553        "table": "b",
554        "where": [["b", "==", 1]]}]]],
555    dnl Try the deletions again to make sure that the refcounts got rolled back.
556    [[["constraints",
557       {"op": "delete",
558        "table": "a",
559        "where": [["a", "==", 0]]}]]],
560    [[["constraints",
561       {"op": "delete",
562        "table": "b",
563        "where": [["b", "==", 1]]}]]],
564    [[["constraints",
565       {"op": "delete",
566        "table": "a",
567        "where": [["a", "==", 0]]},
568       {"op": "delete",
569        "table": "b",
570        "where": [["b", "==", 1]]}]]]],
571   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]
572 [{"uuid":["uuid","<2>"]},{"details":"reference to nonexistent row <3>","error":"referential integrity violation"}]
573 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
574 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
575 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
576 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
577 [{"count":1},{"count":1}]
578 ]])
579
580 OVSDB_CHECK_EXECUTION([weak references],
581   [WEAK_SCHEMA],
582   [[[["weak",
583       {"op": "insert",
584        "table": "a",
585        "row": {"a": 0,
586                "a2a": ["set", [["named-uuid", "row1"],
587                                ["named-uuid", "row2"],
588                                ["uuid", "0e767b36-6822-4044-8307-d58467e04669"]]],
589                "a2a1": ["named-uuid", "row1"],
590                "a2b": ["named-uuid", "row3"]},
591        "uuid-name": "row1"},
592       {"op": "insert",
593        "table": "a",
594        "row": {"a": 1,
595                "a2a": ["set", [["named-uuid", "row1"],
596                                ["named-uuid", "row2"]]],
597                "a2a1": ["named-uuid", "row2"],
598                "a2b": ["named-uuid", "row3"]},
599        "uuid-name": "row2"},
600       {"op": "insert",
601        "table": "a",
602        "row": {"a": 2,
603                "a2a": ["set", [["named-uuid", "row1"],
604                                ["named-uuid", "row2"]]],
605                "a2a1": ["named-uuid", "row2"],
606                "a2b": ["named-uuid", "row4"]}},
607       {"op": "insert",
608        "table": "b",
609        "row": {"b": 2,
610                "b2a": ["named-uuid", "row1"]},
611        "uuid-name": "row3"},
612       {"op": "insert",
613        "table": "b",
614        "row": {"b": 3,
615                "b2a": ["named-uuid", "row2"]},
616        "uuid-name": "row4"}]]],
617    dnl Check that the nonexistent row UUID we added to row a0 was deleted,
618    dnl and that other rows were inserted as requested.
619    [[["weak",
620       {"op": "select",
621        "table": "a",
622        "where": [],
623        "columns": ["_uuid", "a2a", "a2a1", "a2b"],
624        "sort": ["a"]}]]],
625    [[["weak",
626       {"op": "select",
627        "table": "b",
628        "where": [],
629        "columns": ["_uuid", "b", "b2a"],
630        "sort": ["b"]}]]],
631    dnl Try to insert invalid all-zeros weak reference (the default) into
632    dnl "a2b", which requires exactly one value.
633    [[["weak",
634       {"op": "insert",
635        "table": "a",
636        "row": {}}]]],
637    dnl Try to delete row from "b" that is referred to by weak references
638    dnl from "a" table "a2b" column that requires exactly one value.
639    [[["weak",
640       {"op": "delete",
641        "table": "b",
642        "where": [["b", "==", 3]]}]]],
643    dnl Try to delete row from "a" that is referred to by weak references
644    dnl from "a" table "a2a1" column that requires exactly one value.
645    [[["weak",
646       {"op": "delete",
647        "table": "a",
648        "where": [["a", "==", 1]]}]]],
649    dnl Delete the row that had the reference that caused the previous
650    dnl deletion to fail, then check that other rows are unchanged.
651    [[["weak",
652       {"op": "delete",
653        "table": "a",
654        "where": [["a", "==", 2]]}]]],
655    [[["weak",
656       {"op": "select",
657        "table": "a",
658        "where": [],
659        "columns": ["_uuid", "a2a", "a2a1", "a2b"],
660        "sort": ["a"]}]]],
661    [[["weak",
662       {"op": "select",
663        "table": "b",
664        "where": [],
665        "columns": ["_uuid", "b", "b2a"],
666        "sort": ["b"]}]]],
667    dnl Delete row a0 then check that references to it were removed.
668    [[["weak",
669       {"op": "delete",
670        "table": "a",
671        "where": [["a", "==", 0]]}]]],
672    [[["weak",
673       {"op": "select",
674        "table": "a",
675        "where": [],
676        "columns": ["_uuid", "a2a", "a2a1", "a2b"],
677        "sort": ["a"]}]]],
678    [[["weak",
679       {"op": "select",
680        "table": "b",
681        "where": [],
682        "columns": ["_uuid", "b", "b2a"],
683        "sort": ["b"]}]]],
684    dnl Delete row a1 then check that references to it were removed.
685    [[["weak",
686       {"op": "delete",
687        "table": "a",
688        "where": [["a", "==", 1]]}]]],
689    [[["weak",
690       {"op": "select",
691        "table": "a",
692        "where": [],
693        "columns": ["_uuid", "a2a", "a2a1", "a2b"],
694        "sort": ["a"]}]]],
695    [[["weak",
696       {"op": "select",
697        "table": "b",
698        "where": [],
699        "columns": ["_uuid", "b", "b2a"],
700        "sort": ["b"]}]]]],
701   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]},{"uuid":["uuid","<4>"]}]
702 [{"rows":[{"_uuid":["uuid","<0>"],"a2a":["set",[["uuid","<0>"],["uuid","<1>"]]],"a2a1":["uuid","<0>"],"a2b":["uuid","<3>"]},{"_uuid":["uuid","<1>"],"a2a":["set",[["uuid","<0>"],["uuid","<1>"]]],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]},{"_uuid":["uuid","<2>"],"a2a":["set",[["uuid","<0>"],["uuid","<1>"]]],"a2a1":["uuid","<1>"],"a2b":["uuid","<4>"]}]}]
703 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
704 [{"uuid":["uuid","<5>"]},{"details":"Weak reference column \"a2b\" in \"a\" row <5> (inserted within this transaction) contained all-zeros UUID (probably as the default value for this column) but deleting this value caused a constraint volation because this column is not allowed to be empty.","error":"constraint violation"}]
705 [{"count":1},{"details":"Deletion of 1 weak reference(s) to deleted (or never-existing) rows from column \"a2b\" in \"a\" row <2> caused this column to become empty, but constraints on this column disallow an empty column.","error":"constraint violation"}]
706 [{"count":1},{"details":"Deletion of 1 weak reference(s) to deleted (or never-existing) rows from column \"a2a1\" in \"a\" row <2> caused this column to become empty, but constraints on this column disallow an empty column.","error":"constraint violation"}]
707 [{"count":1}]
708 [{"rows":[{"_uuid":["uuid","<0>"],"a2a":["set",[["uuid","<0>"],["uuid","<1>"]]],"a2a1":["uuid","<0>"],"a2b":["uuid","<3>"]},{"_uuid":["uuid","<1>"],"a2a":["set",[["uuid","<0>"],["uuid","<1>"]]],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]}]}]
709 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
710 [{"count":1}]
711 [{"rows":[{"_uuid":["uuid","<1>"],"a2a":["uuid","<1>"],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]}]}]
712 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
713 [{"count":1}]
714 [{"rows":[]}]
715 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["set",[]]}]}]
716 ]])])
717
718 EXECUTION_EXAMPLES