From: Ben Pfaff Date: Mon, 28 Feb 2011 23:43:29 +0000 (-0800) Subject: ovsdb-data: Verify that named-uuid string is an . X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d198c4beee03741670d046baf0179ac5583305bb;p=openvswitch ovsdb-data: Verify that named-uuid string is an . The "uuid-name" that creates symbols must be an but we weren't verifying the same constraint on the "named-uuid"s that refer to symbols, which was a bit confusing in writing transactions by hand. This commit fixes the inconsistency and updates the SPECS file to clarify that a named-uuid string has to be an . --- diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c index c373be9a..1a075244 100644 --- a/lib/ovsdb-data.c +++ b/lib/ovsdb-data.c @@ -26,6 +26,7 @@ #include "dynamic-string.h" #include "hash.h" #include "ovsdb-error.h" +#include "ovsdb-parser.h" #include "json.h" #include "shash.h" #include "sort.h" @@ -307,6 +308,10 @@ ovsdb_atom_parse_uuid(struct uuid *uuid, const struct json *json, ovsdb_error_destroy(error0); *uuid = ovsdb_symbol_table_insert(symtab, name)->uuid; + if (!ovsdb_parser_is_id(json_string(value))) { + return ovsdb_syntax_error(json, NULL, "named-uuid string is " + "not a valid "); + } return NULL; } ovsdb_error_destroy(error1); diff --git a/ovsdb/SPECS b/ovsdb/SPECS index 2c83cf2a..d64812ae 100644 --- a/ovsdb/SPECS +++ b/ovsdb/SPECS @@ -679,7 +679,7 @@ Notation for the Wire Protocol A 2-element JSON array that represents the UUID of a row inserted in an "insert" operation within the same transaction. The first element of the array must be the string "named-uuid" and the - second element should be the string specified as the "uuid-name" + second element should be the specified as the "uuid-name" for an "insert" operation within the same transaction. For example, if an "insert" operation within this transaction specifies a "uuid-name" of "myrow", the following diff --git a/tests/ovsdb-execution.at b/tests/ovsdb-execution.at index d4f2380f..47be1935 100644 --- a/tests/ovsdb-execution.at +++ b/tests/ovsdb-execution.at @@ -77,6 +77,25 @@ m4_define([OVSDB_CHECK_EXECUTION], AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [$4]) AT_CLEANUP]) +OVSDB_CHECK_EXECUTION([uuid-name must be ], + [CONSTRAINT_SCHEMA], + [[[["constraints", + {"op": "insert", + "table": "a", + "row": {}, + "uuid-name": "0"}]]]], + [[[{"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\"}"}] +]]) + +OVSDB_CHECK_EXECUTION([named-uuid must be ], + [CONSTRAINT_SCHEMA], + [[[["constraints", + {"op": "insert", + "table": "a", + "row": {"a2a": ["named-uuid", "0"]}}]]]], + [[[{"details":"named-uuid string is not a valid ","error":"syntax error","syntax":"[\"named-uuid\",\"0\"]"}] +]]) + m4_define([EXECUTION_EXAMPLES], [ dnl At one point the "commit" code ignored new rows with all-default values, dnl so this checks for that problem.