X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=ovsdb%2Fovsdb-server.c;h=919575a57b7f79e515c2f3c42439b7911c7453bf;hb=fb6de52cd7054053f745a880f09607628fc3b7cd;hp=f992e5900f3b026d7596da959a62a052f20ed6df;hpb=eeb36a52b4dbec1fb2ebdc13edf0f3d37fa216f4;p=sliver-openvswitch.git diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c index f992e5900..919575a57 100644 --- a/ovsdb/ovsdb-server.c +++ b/ovsdb/ovsdb-server.c @@ -339,7 +339,7 @@ parse_db_column__(const struct shash *all_dbs, const struct ovsdb_table **tablep, const struct ovsdb_column **columnp) { - const char *table_name, *column_name; + const char *db_name, *table_name, *column_name; const struct ovsdb_column *column; const struct ovsdb_table *table; const char *tokens[3]; @@ -354,30 +354,17 @@ parse_db_column__(const struct shash *all_dbs, tokens[0] = strtok_r(NULL, ",", &save_ptr); tokens[1] = strtok_r(NULL, ",", &save_ptr); tokens[2] = strtok_r(NULL, ",", &save_ptr); - if (!tokens[0] || !tokens[1]) { + if (!tokens[0] || !tokens[1] || !tokens[2]) { return xasprintf("\"%s\": invalid syntax", name_); } - if (tokens[2]) { - const char *db_name = tokens[0]; - table_name = tokens[1]; - column_name = tokens[2]; - - db = find_db(all_dbs, tokens[0]); - if (!db) { - return xasprintf("\"%s\": no database named %s", name_, db_name); - } - } else { - struct shash_node *node; - if (shash_count(all_dbs) > 1) { - return xasprintf("\"%s\": database name must be specified " - "(because multiple databases are configured)", - name_); - } - table_name = tokens[0]; - column_name = tokens[1]; - node = shash_first(all_dbs); - db = (struct db *)node->data; + db_name = tokens[0]; + table_name = tokens[1]; + column_name = tokens[2]; + + db = find_db(all_dbs, tokens[0]); + if (!db) { + return xasprintf("\"%s\": no database named %s", name_, db_name); } table = ovsdb_get_table(db->db, table_name);