Looks Good to me. On Tue, Mar 1, 2011 at 2:19 PM, Ben Pfaff <[email protected]> wrote: > 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>. > --- > lib/ovsdb-data.c | 5 +++++ > ovsdb/SPECS | 2 +- > tests/ovsdb-execution.at | 19 +++++++++++++++++++ > 3 files changed, 25 insertions(+), 1 deletions(-) > > diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c > index c373be9..1a07524 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 <id>"); > + } > return NULL; > } > ovsdb_error_destroy(error1); > diff --git a/ovsdb/SPECS b/ovsdb/SPECS > index 2c83cf2..d64812a 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 <id> 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 <named-uuid> > diff --git a/tests/ovsdb-execution.at b/tests/ovsdb-execution.at > index d4f2380..47be193 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 <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], [ > dnl At one point the "commit" code ignored new rows with all-default values, > dnl so this checks for that problem. > -- > 1.7.1 > > > _______________________________________________ > dev mailing list > [email protected] > http://openvswitch.org/mailman/listinfo/dev_openvswitch.org >
_______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev_openvswitch.org
