From 90887925206f585db65ae8872f197a97543f2860 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 3 Mar 2010 09:54:43 -0800 Subject: [PATCH 1/1] ovsdb-idl: Improve check in ovsdb_idl_row_is_orphan(). When a transaction is in progress, newly inserted rows have NULL 'old' values. These rows are not orphans, so ovsdb_idl_row_is_orphan() should not treat them as such. I do not believe that this changes behavior at all, because I have not been able to find a case where ovsdb_idl_row_is_orphan() is called while a transaction is in progress. It is a code cleanup. --- lib/ovsdb-idl.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index cc9deac91..f60ec4b10 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -541,10 +541,21 @@ ovsdb_idl_row_update(struct ovsdb_idl_row *row, const struct json *row_json) } } +/* When a row A refers to row B through a column with a "refTable" constraint, + * but row B does not exist, row B is called an "orphan row". Orphan rows + * should not persist, because the database enforces referential integrity, but + * they can appear transiently as changes from the database are received (the + * database doesn't try to topologically sort them and circular references mean + * it isn't always possible anyhow). + * + * This function returns true if 'row' is an orphan row, otherwise false. + */ static bool ovsdb_idl_row_is_orphan(const struct ovsdb_idl_row *row) { - return !row->old; + return !row->old && !row->new; +} + /* Returns true if 'row' is conceptually part of the database as modified by * the current transaction (if any), false otherwise. * -- 2.45.2