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