diff options
author | Ben Pfaff <blp@nicira.com> | 2012-09-05 10:35:20 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2012-09-05 10:35:20 -0700 |
commit | 341c4e59f50a842a2974d06e448a57af372a7edd (patch) | |
tree | 35f92730f035ab655e76334bdb19f771c042d10a /ovsdb/execution.c | |
parent | c22c56bd746352f5c70a0d99bb3f548d03cfd105 (diff) | |
download | openvswitch-341c4e59f50a842a2974d06e448a57af372a7edd.tar.gz |
ovsdb: Enforce immutability of immutable columns.
OVSDB has always had the ability to mark a column as "immutable", so that
its value cannot be changed in a given row after that row is initially
inserted. However, we discovered recently that ovsdb-server has never
enforced this constraint. This commit implements enforcement.
Reported-by: Paul Ingram <paul@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
Diffstat (limited to 'ovsdb/execution.c')
-rw-r--r-- | ovsdb/execution.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ovsdb/execution.c b/ovsdb/execution.c index 1aff0c51e..300c247a3 100644 --- a/ovsdb/execution.c +++ b/ovsdb/execution.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009, 2010, 2011 Nicira, Inc. +/* Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -435,6 +435,22 @@ ovsdb_execute_update(struct ovsdb_execution *x, struct ovsdb_parser *parser, error = parse_row(row_json, table, x->symtab, &row, &columns); } if (!error) { + size_t i; + + for (i = 0; i < columns.n_columns; i++) { + const struct ovsdb_column *column = columns.columns[i]; + + if (!column->mutable) { + error = ovsdb_syntax_error(parser->json, + "constraint violation", + "Cannot update immutable column %s " + "in table %s.", + column->name, table->schema->name); + break; + } + } + } + if (!error) { error = ovsdb_condition_from_json(table->schema, where, x->symtab, &condition); } |