struct ovsdb_parser *,
struct json *result);
-static struct ovsdb_error *do_commit(struct ovsdb_execution *);
static ovsdb_operation_executor ovsdb_execute_insert;
static ovsdb_operation_executor ovsdb_execute_select;
static ovsdb_operation_executor ovsdb_execute_update;
}
if (!error) {
- /* Commit transaction. Bail if commit encounters error. */
- error = do_commit(&x);
+ error = ovsdb_txn_commit(x.txn, x.durable);
if (error) {
json_array_add(results, ovsdb_error_to_json(error));
}
return ovsdb_error("aborted", "aborted by request");
}
-static struct ovsdb_error *
-do_commit(struct ovsdb_execution *x)
-{
- if (x->db->file) {
- struct ovsdb_error *error;
- struct json *json;
-
- json = ovsdb_txn_to_json(x->txn);
- if (!json) {
- /* Nothing to commit. */
- return NULL;
- }
-
- error = ovsdb_file_write(x->db->file, json);
- json_destroy(json);
- if (error) {
- return ovsdb_wrap_error(error, "writing transaction failed");
- }
-
- if (x->durable) {
- error = ovsdb_file_commit(x->db->file);
- if (error) {
- return ovsdb_wrap_error(error,
- "committing transaction failed");
- }
- }
- }
-
- ovsdb_txn_commit(x->txn);
- return NULL;
-}
-
static struct ovsdb_table *
parse_table(struct ovsdb_execution *x,
struct ovsdb_parser *parser, const char *member)
struct ovsdb_row *row = NULL;
const struct json *uuid_name;
struct ovsdb_error *error;
+ struct uuid row_uuid;
table = parse_table(x, parser, "table");
uuid_name = ovsdb_parser_member(parser, "uuid-name", OP_ID | OP_OPTIONAL);
error = ovsdb_parser_get_error(parser);
+
+ uuid_generate(&row_uuid);
+ if (uuid_name) {
+ ovsdb_symbol_table_put(x->symtab, json_string(uuid_name), &row_uuid);
+ }
+
if (!error) {
error = parse_row(parser, "row", table, x->symtab, &row, NULL);
}
if (!error) {
- uuid_generate(ovsdb_row_get_uuid_rw(row));
- if (uuid_name) {
- ovsdb_symbol_table_put(x->symtab, json_string(uuid_name),
- ovsdb_row_get_uuid(row));
- }
+ *ovsdb_row_get_uuid_rw(row) = row_uuid;
ovsdb_txn_row_insert(x->txn, row);
json_object_put(result, "uuid",
ovsdb_datum_to_json(&row->fields[OVSDB_COL_UUID],