+struct ovsdb_table_schema *
+ovsdb_table_schema_clone(const struct ovsdb_table_schema *old)
+{
+ struct ovsdb_table_schema *new;
+ struct shash_node *node;
+ size_t i;
+
+ new = ovsdb_table_schema_create(old->name, old->mutable,
+ old->max_rows, old->is_root);
+ SHASH_FOR_EACH (node, &old->columns) {
+ const struct ovsdb_column *column = node->data;
+
+ if (column->name[0] == '_') {
+ /* Added automatically by ovsdb_table_schema_create(). */
+ continue;
+ }
+
+ add_column(new, ovsdb_column_clone(column));
+ }
+
+ new->n_indexes = old->n_indexes;
+ new->indexes = xmalloc(new->n_indexes * sizeof *new->indexes);
+ for (i = 0; i < new->n_indexes; i++) {
+ const struct ovsdb_column_set *old_index = &old->indexes[i];
+ struct ovsdb_column_set *new_index = &new->indexes[i];
+ size_t j;
+
+ ovsdb_column_set_init(new_index);
+ for (j = 0; j < old_index->n_columns; j++) {
+ const struct ovsdb_column *old_column = old_index->columns[j];
+ const struct ovsdb_column *new_column;
+
+ new_column = ovsdb_table_schema_get_column(new, old_column->name);
+ ovsdb_column_set_add(new_index, new_column);
+ }
+ }
+
+ return new;
+}
+