...one of the most highly
regarded and expertly designed C++ library projects in the
world. — Herb Sutter and Andrei
In the context of this library, metadata refers to information describing a
column retrieved by the execution of a SQL query. The
class contains information about an individual column.
You may access metadata using
There is a
per column retrieved by the query. The metadata objects are present even if
no row was returned by the query (e.g. a
on an empty table).
objects have an associated
that describes how to handle metadata when running a query or a statement:
metadata_mode::minimal(the default), the library will retain the minimal amout of data required to run the operation. Additional information, like column names, won't be retained. Unless you are using metadata explicitly, you should keep this default, as it consumes slightly less memory.
metadata_mode::full, the library will retain all the information provided by the server, including column names.
members that are strings (database, table and field names) are affected by
this setting. You may change this setting using
// By default, a connection has metadata_mode::minimal results result; conn.execute("SELECT 1 AS my_field", result); string_view colname = result.meta().column_name(); // colname will be empty because conn.meta_mode() == metadata_mode::minimal ASSERT(colname == ""); // If you are using metadata names, set the connection's metadata_mode conn.set_meta_mode(metadata_mode::full); conn.execute("SELECT 1 AS my_field", result); colname = result.meta().column_name(); ASSERT(colname == "my_field");