"positive": {"type": {"key": {"type": "integer",
"minInteger": 1}}}}}}}]])
+m4_define([WEAK_SCHEMA],
+ [[{"name": "weak",
+ "tables": {
+ "a": {
+ "columns": {
+ "a": {"type": "integer"},
+ "a2a": {"type": {"key": {"type": "uuid",
+ "refTable": "a",
+ "refType": "weak"},
+ "min": 0, "max": "unlimited"}},
+ "a2a1": {"type": {"key": {"type": "uuid",
+ "refTable": "a",
+ "refType": "weak"}}},
+ "a2b": {"type": {"key": {"type": "uuid",
+ "refTable": "b",
+ "refType": "weak"}}}}},
+ "b": {
+ "columns": {
+ "b": {"type": "integer"},
+ "b2a": {"type": {"key": {"type": "uuid",
+ "refTable": "a",
+ "refType": "weak"},
+ "min": 0, "max": "unlimited"}}}}}}]])
+
# OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
#
# Runs "test-ovsdb execute" with the given SCHEMA and each of the
[{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
[{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
[{"count":1},{"count":1}]
+]])
+
+OVSDB_CHECK_EXECUTION([weak references],
+ [WEAK_SCHEMA],
+ [[[["weak",
+ {"op": "insert",
+ "table": "a",
+ "row": {"a": 0,
+ "a2a": ["set", [["named-uuid", "row1"],
+ ["named-uuid", "row2"],
+ ["uuid", "0e767b36-6822-4044-8307-d58467e04669"]]],
+ "a2a1": ["named-uuid", "row1"],
+ "a2b": ["named-uuid", "row3"]},
+ "uuid-name": "row1"},
+ {"op": "insert",
+ "table": "a",
+ "row": {"a": 1,
+ "a2a": ["set", [["named-uuid", "row1"],
+ ["named-uuid", "row2"]]],
+ "a2a1": ["named-uuid", "row2"],
+ "a2b": ["named-uuid", "row3"]},
+ "uuid-name": "row2"},
+ {"op": "insert",
+ "table": "a",
+ "row": {"a": 2,
+ "a2a": ["set", [["named-uuid", "row1"],
+ ["named-uuid", "row2"]]],
+ "a2a1": ["named-uuid", "row2"],
+ "a2b": ["named-uuid", "row4"]}},
+ {"op": "insert",
+ "table": "b",
+ "row": {"b": 2,
+ "b2a": ["named-uuid", "row1"]},
+ "uuid-name": "row3"},
+ {"op": "insert",
+ "table": "b",
+ "row": {"b": 3,
+ "b2a": ["named-uuid", "row2"]},
+ "uuid-name": "row4"}]]],
+ dnl Check that the nonexistent row UUID we added to row a0 was deleted,
+ dnl and that other rows were inserted as requested.
+ [[["weak",
+ {"op": "select",
+ "table": "a",
+ "where": [],
+ "columns": ["_uuid", "a2a", "a2a1", "a2b"],
+ "sort": ["a"]}]]],
+ [[["weak",
+ {"op": "select",
+ "table": "b",
+ "where": [],
+ "columns": ["_uuid", "b", "b2a"],
+ "sort": ["b"]}]]],
+ dnl Try to insert invalid all-zeros weak reference (the default) into
+ dnl "a2b", which requires exactly one value.
+ [[["weak",
+ {"op": "insert",
+ "table": "a",
+ "row": {}}]]],
+ dnl Try to delete row from "b" that is referred to by weak references
+ dnl from "a" table "a2b" column that requires exactly one value.
+ [[["weak",
+ {"op": "delete",
+ "table": "b",
+ "where": [["b", "==", 3]]}]]],
+ dnl Try to delete row from "a" that is referred to by weak references
+ dnl from "a" table "a2a1" column that requires exactly one value.
+ [[["weak",
+ {"op": "delete",
+ "table": "a",
+ "where": [["a", "==", 1]]}]]],
+ dnl Delete the row that had the reference that caused the previous
+ dnl deletion to fail, then check that other rows are unchanged.
+ [[["weak",
+ {"op": "delete",
+ "table": "a",
+ "where": [["a", "==", 2]]}]]],
+ [[["weak",
+ {"op": "select",
+ "table": "a",
+ "where": [],
+ "columns": ["_uuid", "a2a", "a2a1", "a2b"],
+ "sort": ["a"]}]]],
+ [[["weak",
+ {"op": "select",
+ "table": "b",
+ "where": [],
+ "columns": ["_uuid", "b", "b2a"],
+ "sort": ["b"]}]]],
+ dnl Delete row a0 then check that references to it were removed.
+ [[["weak",
+ {"op": "delete",
+ "table": "a",
+ "where": [["a", "==", 0]]}]]],
+ [[["weak",
+ {"op": "select",
+ "table": "a",
+ "where": [],
+ "columns": ["_uuid", "a2a", "a2a1", "a2b"],
+ "sort": ["a"]}]]],
+ [[["weak",
+ {"op": "select",
+ "table": "b",
+ "where": [],
+ "columns": ["_uuid", "b", "b2a"],
+ "sort": ["b"]}]]],
+ dnl Delete row a1 then check that references to it were removed.
+ [[["weak",
+ {"op": "delete",
+ "table": "a",
+ "where": [["a", "==", 1]]}]]],
+ [[["weak",
+ {"op": "select",
+ "table": "a",
+ "where": [],
+ "columns": ["_uuid", "a2a", "a2a1", "a2b"],
+ "sort": ["a"]}]]],
+ [[["weak",
+ {"op": "select",
+ "table": "b",
+ "where": [],
+ "columns": ["_uuid", "b", "b2a"],
+ "sort": ["b"]}]]]],
+ [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]},{"uuid":["uuid","<4>"]}]
+[{"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>"]}]}]
+[{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
+[{"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"}]
+[{"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"}]
+[{"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"}]
+[{"count":1}]
+[{"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>"]}]}]
+[{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
+[{"count":1}]
+[{"rows":[{"_uuid":["uuid","<1>"],"a2a":["uuid","<1>"],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]}]}]
+[{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
+[{"count":1}]
+[{"rows":[]}]
+[{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["set",[]]}]}]
]])])
EXECUTION_EXAMPLES