2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 01:51:26 +00:00

ovsdb-data: Verify that named-uuid string is an <id>.

The "uuid-name" that creates symbols must be an <id> 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 <id>.
This commit is contained in:
Ben Pfaff 2011-02-28 15:43:29 -08:00
parent acb4f876b8
commit d198c4beee
3 changed files with 25 additions and 1 deletions

View File

@ -26,6 +26,7 @@
#include "dynamic-string.h" #include "dynamic-string.h"
#include "hash.h" #include "hash.h"
#include "ovsdb-error.h" #include "ovsdb-error.h"
#include "ovsdb-parser.h"
#include "json.h" #include "json.h"
#include "shash.h" #include "shash.h"
#include "sort.h" #include "sort.h"
@ -307,6 +308,10 @@ ovsdb_atom_parse_uuid(struct uuid *uuid, const struct json *json,
ovsdb_error_destroy(error0); ovsdb_error_destroy(error0);
*uuid = ovsdb_symbol_table_insert(symtab, name)->uuid; *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 <id>");
}
return NULL; return NULL;
} }
ovsdb_error_destroy(error1); ovsdb_error_destroy(error1);

View File

@ -679,7 +679,7 @@ Notation for the Wire Protocol
A 2-element JSON array that represents the UUID of a row inserted A 2-element JSON array that represents the UUID of a row inserted
in an "insert" operation within the same transaction. The first in an "insert" operation within the same transaction. The first
element of the array must be the string "named-uuid" and the 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 <id> specified as the "uuid-name"
for an "insert" operation within the same transaction. For for an "insert" operation within the same transaction. For
example, if an "insert" operation within this transaction example, if an "insert" operation within this transaction
specifies a "uuid-name" of "myrow", the following <named-uuid> specifies a "uuid-name" of "myrow", the following <named-uuid>

View File

@ -77,6 +77,25 @@ m4_define([OVSDB_CHECK_EXECUTION],
AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [$4]) AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [$4])
AT_CLEANUP]) AT_CLEANUP])
OVSDB_CHECK_EXECUTION([uuid-name must be <id>],
[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 <id>],
[CONSTRAINT_SCHEMA],
[[[["constraints",
{"op": "insert",
"table": "a",
"row": {"a2a": ["named-uuid", "0"]}}]]]],
[[[{"details":"named-uuid string is not a valid <id>","error":"syntax error","syntax":"[\"named-uuid\",\"0\"]"}]
]])
m4_define([EXECUTION_EXAMPLES], [ m4_define([EXECUTION_EXAMPLES], [
dnl At one point the "commit" code ignored new rows with all-default values, dnl At one point the "commit" code ignored new rows with all-default values,
dnl so this checks for that problem. dnl so this checks for that problem.