MySQL 8.4.2
Source Code Documentation
s_mysql_mysql_stmt_resultset_metadata Struct Reference

A service that provides the API to get information about a field or column in a result set including get the number of fields, fetch a field and get information of a field. More...

#include <mysql_statement_service.h>

Public Attributes

mysql_service_status_t(* fetch_field )(my_h_statement statement, uint32_t column_index, my_h_field *field)
 Get the field handle by the index. More...
 
mysql_service_status_t(* field_count )(my_h_statement statement, uint32_t *num_fields)
 Get the number of fields in the current result set. More...
 
mysql_service_status_t(* field_info )(my_h_field field, const char *name, void *data)
 Get the information about the field. More...
 

Detailed Description

A service that provides the API to get information about a field or column in a result set including get the number of fields, fetch a field and get information of a field.

More info: https://dev.mysql.com/doc/c-api/8.0/en/mysql-stmt-field-count.html

Usage example:

auto num_fields = uint32_t{}; SERVICE_PLACEHOLDER(mysql_stmt_resultset_metadata)->field_count(statement, &num_fields);

my_h_field field = nullptr; for(size_t field_index = 0; field_index < num_fields; field_index++) { SERVICE_PLACEHOLDER(mysql_stmt_resultset_metadata)->fetch_field(statement, field_index, &field);

char* field_name = nullptr; SERVICE_PLACEHOLDER(mysql_stmt_resultset_metadata)->field_info(field, "col_name", &field_name);

Do similarly for other field metadata }

Member Data Documentation

◆ fetch_field

mysql_service_status_t(* s_mysql_mysql_stmt_resultset_metadata::fetch_field) (my_h_statement statement, uint32_t column_index, my_h_field *field)

Get the field handle by the index.

Parameters
[in]statementA handle to the statement
[in]column_index0-based index of the column
[out]fieldThe field handle
Returns
Status of the performed operation
Return values
falsesuccess
truefailure

◆ field_count

mysql_service_status_t(* s_mysql_mysql_stmt_resultset_metadata::field_count) (my_h_statement statement, uint32_t *num_fields)

Get the number of fields in the current result set.

Parameters
[in]statementA handle to the statement
[out]num_fieldsThe number of fields in this result set
Returns
Status of the performed operation
Return values
falsesuccess
truefailure

◆ field_info

mysql_service_status_t(* s_mysql_mysql_stmt_resultset_metadata::field_info) (my_h_field field, const char *name, void *data)

Get the information about the field.

Parameters
[in]fieldThe field to get information from
[in]nameName of the attributes to get from the field

Currently, following attributes are supported:

  • Column name ("col_name" of the returned const char* type)
  • Original column name ("org_col_name" of the returned const char* type)
  • Database name ("db_name" of the returned const char* type)
  • Table name ("table_name" of the returned const char* type)
  • Original table name ("org_table_name" of the returned const char* type)
  • Field type ("type" of the returned uint64_t type)
  • Charset number ("charsetnr" of the returned uint type)
  • Charset name ("charset_name" of the returned const char* type)
  • Collation name ("collation_name" of the returned const char* type)
  • Field flags ("flags" of the returned uint type)
  • Field decimals ("decimals" of the returned uint type)
  • Whether the field is unsigned ("is_unsigned" of the returned bool type)
  • Whether the field is zerofill ("is_zerofill" of the returned bool type)
Parameters
[out]dataThe returned information
Returns
Status of the performed operation
Return values
falsesuccess
truefailure

The documentation for this struct was generated from the following file: