1 /* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2017, 2019 Nicira, Inc.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
23 #include "condition.h"
25 #include "openvswitch/json.h"
27 #include "ovsdb-data.h"
28 #include "ovsdb-error.h"
29 #include "ovsdb-parser.h"
36 #include "transaction.h"
38 struct ovsdb_execution
{
40 const struct ovsdb_session
*session
;
41 struct ovsdb_txn
*txn
;
42 struct ovsdb_symbol_table
*symtab
;
48 long long int elapsed_msec
;
49 long long int timeout_msec
;
52 typedef struct ovsdb_error
*ovsdb_operation_executor(struct ovsdb_execution
*,
53 struct ovsdb_parser
*,
56 static ovsdb_operation_executor ovsdb_execute_insert
;
57 static ovsdb_operation_executor ovsdb_execute_select
;
58 static ovsdb_operation_executor ovsdb_execute_update
;
59 static ovsdb_operation_executor ovsdb_execute_mutate
;
60 static ovsdb_operation_executor ovsdb_execute_delete
;
61 static ovsdb_operation_executor ovsdb_execute_wait
;
62 static ovsdb_operation_executor ovsdb_execute_commit
;
63 static ovsdb_operation_executor ovsdb_execute_abort
;
64 static ovsdb_operation_executor ovsdb_execute_comment
;
65 static ovsdb_operation_executor ovsdb_execute_assert
;
67 static ovsdb_operation_executor
*
68 lookup_executor(const char *name
, bool *read_only
)
70 struct ovsdb_operation
{
73 ovsdb_operation_executor
*executor
;
76 static const struct ovsdb_operation operations
[] = {
77 { "insert", false, ovsdb_execute_insert
},
78 { "select", true, ovsdb_execute_select
},
79 { "update", false, ovsdb_execute_update
},
80 { "mutate", false, ovsdb_execute_mutate
},
81 { "delete", false, ovsdb_execute_delete
},
82 { "wait", true, ovsdb_execute_wait
},
83 { "commit", false, ovsdb_execute_commit
},
84 { "abort", true, ovsdb_execute_abort
},
85 { "comment", true, ovsdb_execute_comment
},
86 { "assert", true, ovsdb_execute_assert
},
91 for (i
= 0; i
< ARRAY_SIZE(operations
); i
++) {
92 const struct ovsdb_operation
*c
= &operations
[i
];
93 if (!strcmp(c
->name
, name
)) {
94 *read_only
= c
->read_only
;
101 /* On success, returns a transaction and stores the results to return to the
102 * client in '*resultsp'.
104 * On failure, returns NULL. If '*resultsp' is nonnull, then it is the results
105 * to return to the client. If '*resultsp' is null, then the execution failed
106 * due to an unsatisfied "wait" operation and '*timeout_msec' is the time at
107 * which the transaction will time out. (If 'timeout_msec' is null, this case
108 * never occurs--instead, an unsatisfied "wait" unconditionally fails.) */
110 ovsdb_execute_compose(struct ovsdb
*db
, const struct ovsdb_session
*session
,
111 const struct json
*params
, bool read_only
,
112 const char *role
, const char *id
,
113 long long int elapsed_msec
, long long int *timeout_msec
,
114 bool *durable
, struct json
**resultsp
)
116 struct ovsdb_execution x
;
117 struct ovsdb_error
*error
;
118 struct json
*results
;
123 if (params
->type
!= JSON_ARRAY
125 || params
->array
.elems
[0]->type
!= JSON_STRING
126 || strcmp(params
->array
.elems
[0]->string
, db
->schema
->name
)) {
127 if (params
->type
!= JSON_ARRAY
) {
128 error
= ovsdb_syntax_error(params
, NULL
, "array expected");
130 error
= ovsdb_syntax_error(params
, NULL
, "database name expected "
131 "as first parameter");
134 *resultsp
= ovsdb_error_to_json_free(error
);
140 x
.txn
= ovsdb_txn_create(db
);
141 x
.symtab
= ovsdb_symbol_table_create();
145 x
.elapsed_msec
= elapsed_msec
;
146 x
.timeout_msec
= LLONG_MAX
;
149 results
= json_array_create_empty();
150 n_operations
= params
->array
.n
- 1;
152 for (i
= 1; i
<= n_operations
; i
++) {
153 struct json
*operation
= params
->array
.elems
[i
];
154 struct ovsdb_error
*parse_error
;
155 struct ovsdb_parser parser
;
157 const struct json
*op
;
158 const char *op_name
= NULL
;
161 /* Parse and execute operation. */
162 ovsdb_parser_init(&parser
, operation
,
163 "ovsdb operation %"PRIuSIZE
" of %"PRIuSIZE
, i
,
165 op
= ovsdb_parser_member(&parser
, "op", OP_ID
);
166 result
= json_object_create();
168 op_name
= json_string(op
);
169 ovsdb_operation_executor
*executor
= lookup_executor(op_name
, &ro
);
171 error
= executor(&x
, &parser
, result
);
173 ovsdb_parser_raise_error(&parser
, "No operation \"%s\"",
177 ovs_assert(ovsdb_parser_has_error(&parser
));
180 /* A parse error overrides any other error.
181 * An error overrides any other result. */
182 parse_error
= ovsdb_parser_finish(&parser
);
184 ovsdb_error_destroy(error
);
187 /* Create read-only violation error if there is one. */
190 error
= ovsdb_error("not allowed",
191 "%s operation not allowed when "
192 "database server is in read only mode",
194 } else if (db
->schema
->name
[0] == '_') {
195 error
= ovsdb_error("not allowed",
196 "%s operation not allowed on "
197 "table in reserved database %s",
198 op_name
, db
->schema
->name
);
202 json_destroy(result
);
203 json_array_add(results
, ovsdb_error_to_json(error
));
204 if (!strcmp(ovsdb_error_get_tag(error
), "not supported")
206 *timeout_msec
= x
.timeout_msec
;
207 json_destroy(results
);
213 json_array_add(results
, result
);
215 while (json_array(results
)->n
< n_operations
) {
216 json_array_add(results
, json_null_create());
221 ovsdb_txn_abort(x
.txn
);
224 ovsdb_error_destroy(error
);
227 *durable
= x
.durable
;
228 ovsdb_symbol_table_destroy(x
.symtab
);
234 ovsdb_execute(struct ovsdb
*db
, const struct ovsdb_session
*session
,
235 const struct json
*params
, bool read_only
,
236 const char *role
, const char *id
,
237 long long int elapsed_msec
, long long int *timeout_msec
)
240 struct json
*results
;
241 struct ovsdb_txn
*txn
= ovsdb_execute_compose(
242 db
, session
, params
, read_only
, role
, id
, elapsed_msec
, timeout_msec
,
248 struct ovsdb_error
*error
= ovsdb_txn_propose_commit_block(txn
, durable
);
250 json_array_add(results
, ovsdb_error_to_json(error
));
251 ovsdb_error_destroy(error
);
256 static struct ovsdb_error
*
257 ovsdb_execute_commit(struct ovsdb_execution
*x
, struct ovsdb_parser
*parser
,
258 struct json
*result OVS_UNUSED
)
260 const struct json
*durable
;
262 durable
= ovsdb_parser_member(parser
, "durable", OP_BOOLEAN
);
263 if (durable
&& json_boolean(durable
)) {
269 static struct ovsdb_error
*
270 ovsdb_execute_abort(struct ovsdb_execution
*x OVS_UNUSED
,
271 struct ovsdb_parser
*parser OVS_UNUSED
,
272 struct json
*result OVS_UNUSED
)
274 return ovsdb_error("aborted", "aborted by request");
277 static struct ovsdb_table
*
278 parse_table(struct ovsdb_execution
*x
,
279 struct ovsdb_parser
*parser
, const char *member
)
281 struct ovsdb_table
*table
;
282 const char *table_name
;
283 const struct json
*json
;
285 json
= ovsdb_parser_member(parser
, member
, OP_ID
);
289 table_name
= json_string(json
);
291 table
= shash_find_data(&x
->db
->tables
, table_name
);
293 ovsdb_parser_raise_error(parser
, "No table named %s.", table_name
);
298 static OVS_WARN_UNUSED_RESULT
struct ovsdb_error
*
299 parse_row(const struct json
*json
, const struct ovsdb_table
*table
,
300 struct ovsdb_symbol_table
*symtab
,
301 struct ovsdb_row
**rowp
, struct ovsdb_column_set
*columns
)
303 struct ovsdb_error
*error
;
304 struct ovsdb_row
*row
;
309 return OVSDB_BUG("null table");
312 return OVSDB_BUG("null row");
315 row
= ovsdb_row_create(table
);
316 error
= ovsdb_row_from_json(row
, json
, symtab
, columns
);
318 ovsdb_row_destroy(row
);
326 static struct ovsdb_error
*
327 ovsdb_execute_insert(struct ovsdb_execution
*x
, struct ovsdb_parser
*parser
,
330 struct ovsdb_table
*table
;
331 struct ovsdb_row
*row
= NULL
;
332 const struct json
*uuid_json
, *uuid_name
, *row_json
;
333 struct ovsdb_error
*error
;
334 struct uuid row_uuid
;
336 table
= parse_table(x
, parser
, "table");
337 uuid_json
= ovsdb_parser_member(parser
, "uuid", OP_STRING
| OP_OPTIONAL
);
338 uuid_name
= ovsdb_parser_member(parser
, "uuid-name", OP_ID
| OP_OPTIONAL
);
339 row_json
= ovsdb_parser_member(parser
, "row", OP_OBJECT
);
340 error
= ovsdb_parser_get_error(parser
);
346 if (!uuid_from_string(&row_uuid
, json_string(uuid_json
))) {
347 return ovsdb_syntax_error(uuid_json
, NULL
, "bad uuid");
350 if (!ovsdb_txn_may_create_row(table
, &row_uuid
)) {
351 return ovsdb_syntax_error(uuid_json
, "duplicate uuid",
352 "This UUID would duplicate a UUID "
353 "already present within the table or "
354 "deleted within the same transaction.");
359 struct ovsdb_symbol
*symbol
;
361 symbol
= ovsdb_symbol_table_insert(x
->symtab
, json_string(uuid_name
));
362 if (symbol
->created
) {
363 return ovsdb_syntax_error(uuid_name
, "duplicate uuid-name",
364 "This \"uuid-name\" appeared on an "
365 "earlier \"insert\" operation.");
368 symbol
->uuid
= row_uuid
;
370 row_uuid
= symbol
->uuid
;
372 symbol
->created
= true;
373 } else if (!uuid_json
) {
374 uuid_generate(&row_uuid
);
378 error
= parse_row(row_json
, table
, x
->symtab
, &row
, NULL
);
381 /* Check constraints for columns not included in "row", in case the
382 * default values do not satisfy the constraints. We could check only
383 * the columns that have their default values by supplying an
384 * ovsdb_column_set to parse_row() above, but I suspect that this is
386 const struct shash_node
*node
;
388 SHASH_FOR_EACH (node
, &table
->schema
->columns
) {
389 const struct ovsdb_column
*column
= node
->data
;
390 const struct ovsdb_datum
*datum
= &row
->fields
[column
->index
];
392 /* If there are 0 keys or pairs, there's nothing to check.
393 * If there is 1, it might be a default value.
394 * If there are more, it can't be a default value, so the value has
395 * already been checked. */
397 error
= ovsdb_datum_check_constraints(datum
, &column
->type
);
405 if (!error
&& !ovsdb_rbac_insert(x
->db
, table
, row
, x
->role
, x
->id
)) {
406 error
= ovsdb_perm_error("RBAC rules for client \"%s\" role \"%s\" "
407 "prohibit row insertion into table \"%s\".",
408 x
->id
, x
->role
, table
->schema
->name
);
412 *ovsdb_row_get_uuid_rw(row
) = row_uuid
;
413 ovsdb_txn_row_insert(x
->txn
, row
);
414 json_object_put(result
, "uuid",
415 ovsdb_datum_to_json(&row
->fields
[OVSDB_COL_UUID
],
418 ovsdb_row_destroy(row
);
423 static struct ovsdb_error
*
424 ovsdb_execute_select(struct ovsdb_execution
*x
, struct ovsdb_parser
*parser
,
427 struct ovsdb_table
*table
;
428 const struct json
*where
, *columns_json
, *sort_json
;
429 struct ovsdb_condition condition
= OVSDB_CONDITION_INITIALIZER(&condition
);
430 struct ovsdb_column_set columns
= OVSDB_COLUMN_SET_INITIALIZER
;
431 struct ovsdb_column_set sort
= OVSDB_COLUMN_SET_INITIALIZER
;
432 struct ovsdb_error
*error
;
434 table
= parse_table(x
, parser
, "table");
435 where
= ovsdb_parser_member(parser
, "where", OP_ARRAY
);
436 columns_json
= ovsdb_parser_member(parser
, "columns",
437 OP_ARRAY
| OP_OPTIONAL
);
438 sort_json
= ovsdb_parser_member(parser
, "sort", OP_ARRAY
| OP_OPTIONAL
);
440 error
= ovsdb_parser_get_error(parser
);
442 error
= ovsdb_condition_from_json(table
->schema
, where
, x
->symtab
,
446 error
= ovsdb_column_set_from_json(columns_json
, table
->schema
,
450 error
= ovsdb_column_set_from_json(sort_json
, table
->schema
, &sort
);
453 struct ovsdb_row_set rows
= OVSDB_ROW_SET_INITIALIZER
;
455 ovsdb_query_distinct(table
, &condition
, &columns
, &rows
);
456 ovsdb_row_set_sort(&rows
, &sort
);
457 json_object_put(result
, "rows",
458 ovsdb_row_set_to_json(&rows
, &columns
));
460 ovsdb_row_set_destroy(&rows
);
463 ovsdb_column_set_destroy(&columns
);
464 ovsdb_column_set_destroy(&sort
);
465 ovsdb_condition_destroy(&condition
);
470 struct update_row_cbdata
{
472 struct ovsdb_txn
*txn
;
473 const struct ovsdb_row
*row
;
474 const struct ovsdb_column_set
*columns
;
480 update_row_cb(const struct ovsdb_row
*row
, void *ur_
)
482 struct update_row_cbdata
*ur
= ur_
;
485 if (!ovsdb_row_equal_columns(row
, ur
->row
, ur
->columns
)) {
486 ovsdb_row_update_columns(ovsdb_txn_row_modify(ur
->txn
, row
),
487 ur
->row
, ur
->columns
);
493 static struct ovsdb_error
*
494 ovsdb_execute_update(struct ovsdb_execution
*x
, struct ovsdb_parser
*parser
,
497 struct ovsdb_table
*table
;
498 const struct json
*where
, *row_json
;
499 struct ovsdb_condition condition
= OVSDB_CONDITION_INITIALIZER(&condition
);
500 struct ovsdb_column_set columns
= OVSDB_COLUMN_SET_INITIALIZER
;
501 struct ovsdb_row
*row
= NULL
;
502 struct update_row_cbdata ur
;
503 struct ovsdb_error
*error
;
505 table
= parse_table(x
, parser
, "table");
506 where
= ovsdb_parser_member(parser
, "where", OP_ARRAY
);
507 row_json
= ovsdb_parser_member(parser
, "row", OP_OBJECT
);
508 error
= ovsdb_parser_get_error(parser
);
510 error
= parse_row(row_json
, table
, x
->symtab
, &row
, &columns
);
515 for (i
= 0; i
< columns
.n_columns
; i
++) {
516 const struct ovsdb_column
*column
= columns
.columns
[i
];
518 if (!column
->mutable) {
519 error
= ovsdb_syntax_error(parser
->json
,
520 "constraint violation",
521 "Cannot update immutable column %s "
523 column
->name
, table
->schema
->name
);
529 error
= ovsdb_condition_from_json(table
->schema
, where
, x
->symtab
,
536 ur
.columns
= &columns
;
537 if (ovsdb_rbac_update(x
->db
, table
, &columns
, &condition
, x
->role
,
539 ovsdb_query(table
, &condition
, update_row_cb
, &ur
);
541 error
= ovsdb_perm_error("RBAC rules for client \"%s\" role "
542 "\"%s\" prohibit modification of "
544 x
->id
, x
->role
, table
->schema
->name
);
546 json_object_put(result
, "count", json_integer_create(ur
.n_matches
));
549 ovsdb_row_destroy(row
);
550 ovsdb_column_set_destroy(&columns
);
551 ovsdb_condition_destroy(&condition
);
556 struct mutate_row_cbdata
{
558 struct ovsdb_txn
*txn
;
559 const struct ovsdb_mutation_set
*mutations
;
560 struct ovsdb_error
**error
;
564 mutate_row_cb(const struct ovsdb_row
*row
, void *mr_
)
566 struct mutate_row_cbdata
*mr
= mr_
;
569 *mr
->error
= ovsdb_mutation_set_execute(ovsdb_txn_row_modify(mr
->txn
, row
),
571 return *mr
->error
== NULL
;
574 static struct ovsdb_error
*
575 ovsdb_execute_mutate(struct ovsdb_execution
*x
, struct ovsdb_parser
*parser
,
578 struct ovsdb_table
*table
;
579 const struct json
*where
;
580 const struct json
*mutations_json
;
581 struct ovsdb_condition condition
= OVSDB_CONDITION_INITIALIZER(&condition
);
582 struct ovsdb_mutation_set mutations
= OVSDB_MUTATION_SET_INITIALIZER
;
583 struct mutate_row_cbdata mr
;
584 struct ovsdb_error
*error
;
586 table
= parse_table(x
, parser
, "table");
587 where
= ovsdb_parser_member(parser
, "where", OP_ARRAY
);
588 mutations_json
= ovsdb_parser_member(parser
, "mutations", OP_ARRAY
);
589 error
= ovsdb_parser_get_error(parser
);
591 error
= ovsdb_mutation_set_from_json(table
->schema
, mutations_json
,
592 x
->symtab
, &mutations
);
595 error
= ovsdb_condition_from_json(table
->schema
, where
, x
->symtab
,
601 mr
.mutations
= &mutations
;
603 if (ovsdb_rbac_mutate(x
->db
, table
, &mutations
, &condition
, x
->role
,
605 ovsdb_query(table
, &condition
, mutate_row_cb
, &mr
);
607 error
= ovsdb_perm_error("RBAC rules for client \"%s\" role "
608 "\"%s\" prohibit mutate operation on "
610 x
->id
, x
->role
, table
->schema
->name
);
612 json_object_put(result
, "count", json_integer_create(mr
.n_matches
));
615 ovsdb_mutation_set_destroy(&mutations
);
616 ovsdb_condition_destroy(&condition
);
621 struct delete_row_cbdata
{
623 const struct ovsdb_table
*table
;
624 struct ovsdb_txn
*txn
;
628 delete_row_cb(const struct ovsdb_row
*row
, void *dr_
)
630 struct delete_row_cbdata
*dr
= dr_
;
633 ovsdb_txn_row_delete(dr
->txn
, row
);
638 static struct ovsdb_error
*
639 ovsdb_execute_delete(struct ovsdb_execution
*x
, struct ovsdb_parser
*parser
,
642 struct ovsdb_table
*table
;
643 const struct json
*where
;
644 struct ovsdb_condition condition
= OVSDB_CONDITION_INITIALIZER(&condition
);
645 struct ovsdb_error
*error
;
647 where
= ovsdb_parser_member(parser
, "where", OP_ARRAY
);
648 table
= parse_table(x
, parser
, "table");
649 error
= ovsdb_parser_get_error(parser
);
651 error
= ovsdb_condition_from_json(table
->schema
, where
, x
->symtab
,
655 struct delete_row_cbdata dr
;
661 if (ovsdb_rbac_delete(x
->db
, table
, &condition
, x
->role
, x
->id
)) {
662 ovsdb_query(table
, &condition
, delete_row_cb
, &dr
);
664 error
= ovsdb_perm_error("RBAC rules for client \"%s\" role "
665 "\"%s\" prohibit row deletion from "
667 x
->id
, x
->role
, table
->schema
->name
);
669 json_object_put(result
, "count", json_integer_create(dr
.n_matches
));
672 ovsdb_condition_destroy(&condition
);
677 struct wait_auxdata
{
678 struct ovsdb_row_hash
*actual
;
679 struct ovsdb_row_hash
*expected
;
684 ovsdb_execute_wait_query_cb(const struct ovsdb_row
*row
, void *aux_
)
686 struct wait_auxdata
*aux
= aux_
;
688 if (ovsdb_row_hash_contains(aux
->expected
, row
)) {
689 ovsdb_row_hash_insert(aux
->actual
, row
);
692 /* The query row isn't in the expected result set, so the actual and
693 * expected results sets definitely differ and we can short-circuit the
694 * rest of the query. */
700 static struct ovsdb_error
*
701 ovsdb_execute_wait(struct ovsdb_execution
*x
, struct ovsdb_parser
*parser
,
702 struct json
*result OVS_UNUSED
)
704 struct ovsdb_table
*table
;
705 const struct json
*timeout
, *where
, *columns_json
, *until
, *rows
;
706 struct ovsdb_condition condition
= OVSDB_CONDITION_INITIALIZER(&condition
);
707 struct ovsdb_column_set columns
= OVSDB_COLUMN_SET_INITIALIZER
;
708 struct ovsdb_row_hash expected
= OVSDB_ROW_HASH_INITIALIZER(expected
);
709 struct ovsdb_row_hash actual
= OVSDB_ROW_HASH_INITIALIZER(actual
);
710 struct ovsdb_error
*error
;
711 struct wait_auxdata aux
;
712 long long int timeout_msec
= 0;
715 timeout
= ovsdb_parser_member(parser
, "timeout", OP_INTEGER
| OP_OPTIONAL
);
716 where
= ovsdb_parser_member(parser
, "where", OP_ARRAY
);
717 columns_json
= ovsdb_parser_member(parser
, "columns",
718 OP_ARRAY
| OP_OPTIONAL
);
719 until
= ovsdb_parser_member(parser
, "until", OP_STRING
);
720 rows
= ovsdb_parser_member(parser
, "rows", OP_ARRAY
);
721 table
= parse_table(x
, parser
, "table");
722 error
= ovsdb_parser_get_error(parser
);
724 error
= ovsdb_condition_from_json(table
->schema
, where
, x
->symtab
,
728 error
= ovsdb_column_set_from_json(columns_json
, table
->schema
,
733 timeout_msec
= json_integer(timeout
);
734 if (timeout_msec
< 0) {
735 error
= ovsdb_syntax_error(timeout
, NULL
,
736 "timeout must be nonnegative");
737 } else if (timeout_msec
< x
->timeout_msec
) {
738 x
->timeout_msec
= timeout_msec
;
741 timeout_msec
= LLONG_MAX
;
745 if (strcmp(json_string(until
), "==")
746 && strcmp(json_string(until
), "!=")) {
747 error
= ovsdb_syntax_error(until
, NULL
,
748 "\"until\" must be \"==\" or \"!=\"");
752 /* Parse "rows" into 'expected'. */
753 ovsdb_row_hash_init(&expected
, &columns
);
754 for (i
= 0; i
< rows
->array
.n
; i
++) {
755 struct ovsdb_row
*row
;
757 row
= ovsdb_row_create(table
);
758 error
= ovsdb_row_from_json(row
, rows
->array
.elems
[i
], x
->symtab
,
761 ovsdb_row_destroy(row
);
765 if (!ovsdb_row_hash_insert(&expected
, row
)) {
766 /* XXX Perhaps we should abort with an error or log a
768 ovsdb_row_destroy(row
);
775 ovsdb_row_hash_init(&actual
, &columns
);
776 aux
.actual
= &actual
;
777 aux
.expected
= &expected
;
779 ovsdb_query(table
, &condition
, ovsdb_execute_wait_query_cb
, &aux
);
781 /* We know that every row in 'actual' is also in 'expected'. We
782 * also know that all of the rows in 'actual' are distinct and that
783 * all of the rows in 'expected' are distinct. Therefore, if
784 * 'actual' and 'expected' have the same number of rows, then they
785 * have the same content. */
786 size_t n_actual
= ovsdb_row_hash_count(&actual
);
787 size_t n_expected
= ovsdb_row_hash_count(&expected
);
788 equal
= n_actual
== n_expected
;
790 if (!strcmp(json_string(until
), "==") != equal
) {
791 if (timeout
&& x
->elapsed_msec
>= timeout_msec
) {
792 if (x
->elapsed_msec
) {
793 error
= ovsdb_error("timed out",
794 "\"wait\" timed out after %lld ms",
797 error
= ovsdb_error("timed out",
798 "\"where\" clause test failed");
801 /* ovsdb_execute() will change this, if triggers really are
803 error
= ovsdb_error("not supported", "triggers not supported");
809 ovsdb_row_hash_destroy(&expected
, true);
810 ovsdb_row_hash_destroy(&actual
, false);
811 ovsdb_column_set_destroy(&columns
);
812 ovsdb_condition_destroy(&condition
);
817 static struct ovsdb_error
*
818 ovsdb_execute_comment(struct ovsdb_execution
*x
, struct ovsdb_parser
*parser
,
819 struct json
*result OVS_UNUSED
)
821 const struct json
*comment
;
823 comment
= ovsdb_parser_member(parser
, "comment", OP_STRING
);
827 ovsdb_txn_add_comment(x
->txn
, json_string(comment
));
832 static struct ovsdb_error
*
833 ovsdb_execute_assert(struct ovsdb_execution
*x
, struct ovsdb_parser
*parser
,
834 struct json
*result OVS_UNUSED
)
836 const struct json
*lock_name
;
838 lock_name
= ovsdb_parser_member(parser
, "lock", OP_ID
);
844 const struct ovsdb_lock_waiter
*waiter
;
846 waiter
= ovsdb_session_get_lock_waiter(x
->session
,
847 json_string(lock_name
));
848 if (waiter
&& ovsdb_lock_waiter_is_owner(waiter
)) {
853 return ovsdb_error("not owner", "Asserted lock %s not held.",
854 json_string(lock_name
));