-/* Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
+/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <stdlib.h>
#include "bitmap.h"
+#include "coverage.h"
#include "dynamic-string.h"
#include "fatal-signal.h"
#include "json.h"
VLOG_DEFINE_THIS_MODULE(ovsdb_idl);
+COVERAGE_DEFINE(txn_uncommitted);
+COVERAGE_DEFINE(txn_unchanged);
+COVERAGE_DEFINE(txn_incomplete);
+COVERAGE_DEFINE(txn_aborted);
+COVERAGE_DEFINE(txn_success);
+COVERAGE_DEFINE(txn_try_again);
+COVERAGE_DEFINE(txn_not_locked);
+COVERAGE_DEFINE(txn_error);
+
/* An arc from one idl_row to another. When row A contains a UUID that
* references row B, this is represented by an arc from A (the source) to B
* (the destination).
return ovsdb_idl_read(row, column);
}
+/* Returns true if the field represented by 'column' in 'row' may be modified,
+ * false if it is immutable.
+ *
+ * Normally, whether a field is mutable is controlled by its column's schema.
+ * However, an immutable column can be set to any initial value at the time of
+ * insertion, so if 'row' is a new row (one that is being added as part of the
+ * current transaction, supposing that a transaction is in progress) then even
+ * its "immutable" fields are actually mutable. */
+bool
+ovsdb_idl_is_mutable(const struct ovsdb_idl_row *row,
+ const struct ovsdb_idl_column *column)
+{
+ return column->mutable || (row->new && !row->old);
+}
+
/* Returns false if 'row' was obtained from the IDL, true if it was initialized
* to all-zero-bits by some other entity. If 'row' was set up some other way
* then the return value is indeterminate. */
bool any_updates;
if (txn != txn->idl->txn) {
- return txn->status;
+ goto coverage_out;
}
/* If we need a lock but don't have it, give up quickly. */
if (txn->idl->lock_name && !ovsdb_idl_has_lock(txn->idl)) {
txn->status = TXN_NOT_LOCKED;
- ovsdb_idl_txn_disassemble(txn);
- return txn->status;
+ goto disassemble_out;
}
operations = json_array_create_1(
txn->status = TXN_TRY_AGAIN;
}
+disassemble_out:
ovsdb_idl_txn_disassemble(txn);
+coverage_out:
+ switch (txn->status) {
+ case TXN_UNCOMMITTED: COVERAGE_INC(txn_uncommitted); break;
+ case TXN_UNCHANGED: COVERAGE_INC(txn_unchanged); break;
+ case TXN_INCOMPLETE: COVERAGE_INC(txn_incomplete); break;
+ case TXN_ABORTED: COVERAGE_INC(txn_aborted); break;
+ case TXN_SUCCESS: COVERAGE_INC(txn_success); break;
+ case TXN_TRY_AGAIN: COVERAGE_INC(txn_try_again); break;
+ case TXN_NOT_LOCKED: COVERAGE_INC(txn_not_locked); break;
+ case TXN_ERROR: COVERAGE_INC(txn_error); break;
+ }
+
return txn->status;
}