- " create DB SCHEMA create DB with the given SCHEMA\n"
- " compact DB [DST] compact DB in-place (or to DST)\n"
- " convert DB SCHEMA [DST] convert DB to SCHEMA (to DST)\n"
- " db-version DB report version of schema used by DB\n"
- " db-cksum DB report checksum of schema used by DB\n"
- " schema-version SCHEMA report SCHEMA's schema version\n"
- " schema-cksum SCHEMA report SCHEMA's checksum\n"
- " query DB TRNS execute read-only transaction on DB\n"
- " transact DB TRNS execute read/write transaction on DB\n"
- " show-log DB prints information about DB's log entries\n",
- program_name, program_name);
+ " create [DB [SCHEMA]] create DB with the given SCHEMA\n"
+ " compact [DB [DST]] compact DB in-place (or to DST)\n"
+ " convert [DB [SCHEMA [DST]]] convert DB to SCHEMA (to DST)\n"
+ " db-version [DB] report version of schema used by DB\n"
+ " db-cksum [DB] report checksum of schema used by DB\n"
+ " schema-version [SCHEMA] report SCHEMA's schema version\n"
+ " schema-cksum [SCHEMA] report SCHEMA's checksum\n"
+ " query [DB] TRNS execute read-only transaction on DB\n"
+ " transact [DB] TRNS execute read/write transaction on DB\n"
+ " [-m]... show-log [DB] print DB's log entries\n"
+ "The default DB is %s.\n"
+ "The default SCHEMA is %s.\n",
+ program_name, program_name, default_db(), default_schema());
- check_ovsdb_error(ovsdb_schema_from_file(schema_file_name, &new_schema));
- compact_or_convert(argv[1], argv[3], new_schema,
- "converted by ovsdb-tool "VERSION BUILDNR);
+ check_ovsdb_error(ovsdb_schema_from_file(schema, &new_schema));
+ compact_or_convert(db, target, new_schema,
+ "converted by ovsdb-tool "VERSION);
struct json *request, *result;
struct ovsdb *db;
check_ovsdb_error(ovsdb_file_open(db_file_name, read_only, &db, NULL));
request = parse_json(transaction);
struct json *request, *result;
struct ovsdb *db;
check_ovsdb_error(ovsdb_file_open(db_file_name, read_only, &db, NULL));
request = parse_json(transaction);
}
if (columns->type == JSON_OBJECT) {
if (show_log_verbosity > 1) {
SHASH_FOR_EACH (n3, json_object(columns)) {
const char *column = n3->name;
}
if (columns->type == JSON_OBJECT) {
if (show_log_verbosity > 1) {
SHASH_FOR_EACH (n3, json_object(columns)) {
const char *column = n3->name;
- char *value_string;
-
- value_string = json_to_string(value, JSSF_SORT);
+ char *value_string = NULL;
+
+ column_schema =
+ (table_schema
+ ? shash_find_data(&table_schema->columns, column)
+ : NULL);
+ if (column_schema) {
+ const struct ovsdb_error *error;
+ const struct ovsdb_type *type;
+ struct ovsdb_datum datum;
+
+ type = &column_schema->type;
+ error = ovsdb_datum_from_json(&datum, type,
+ value, NULL);
+ if (!error) {
+ struct ds s;
+
+ ds_init(&s);
+ ovsdb_datum_to_string(&datum, type, &s);
+ value_string = ds_steal_cstr(&s);
+ }
+ }
+ if (!value_string) {
+ value_string = json_to_string(value, JSSF_SORT);
+ }
- { "create", 2, 2, do_create },
- { "compact", 1, 2, do_compact },
- { "convert", 2, 3, do_convert },
- { "needs-conversion", 2, 2, do_needs_conversion },
- { "db-version", 1, 1, do_db_version },
- { "db-cksum", 1, 1, do_db_cksum },
- { "schema-version", 1, 1, do_schema_version },
- { "schema-cksum", 1, 1, do_schema_cksum },
- { "query", 2, 2, do_query },
- { "transact", 2, 2, do_transact },
- { "show-log", 1, 1, do_show_log },
+ { "create", 0, 2, do_create },
+ { "compact", 0, 2, do_compact },
+ { "convert", 0, 3, do_convert },
+ { "needs-conversion", 0, 2, do_needs_conversion },
+ { "db-version", 0, 1, do_db_version },
+ { "db-cksum", 0, 1, do_db_cksum },
+ { "schema-version", 0, 1, do_schema_version },
+ { "schema-cksum", 0, 1, do_schema_cksum },
+ { "query", 1, 2, do_query },
+ { "transact", 1, 2, do_transact },
+ { "show-log", 0, 1, do_show_log },