Data Types
The MySQL C API uses several defined data types beyond the standard C types. These types are defined in the mysql.h header file that must be included when compiling any program that uses the MySQL library.
-
MYSQL A structure representing a connection to the database server. The program allocates a variable of this type, initializes the variable through the
mysql_initcall, and passes the variable to subsequent calls. The elements of the structure contain the name of the current database and information about the client connection, among other things.-
MYSQL_FIELD A structure containing all the information concerning a specific field in the table. Of all the types created for MySQL, this is the only one with member variables accessed directly from client programs. Therefore, you need to know the layout of the structure:
-
char *name The name of the field.
-
char *table The name of the table containing this field. For result sets that do not correspond to real tables, this value is null.
-
char *def The default value of this field, if one exists. This value is always null unless
mysql_list_fieldsis called, after which it is the correct value for fields that have defaults.-
enum enum_field_types type The type of the field. The type is one of the internal MySQL SQL data types. The following field types (along with their corresponding common MySQL SQL data types) are currently defined:
FIELD_TYPE_TINY(TINYINT)FIELD_TYPE_SHORT(SMALLINT)FIELD_TYPE_LONG(INTEGER) ...
-
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access