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