mSQL C API

The mSQL C API has remained relatively stable between mSQL Versions 1 and 2. However, several new functions have been added, and there have been a few changes in the existing function. Wherever a function or feature can only be used with mSQL 2, it is noted.

Datatypes

The mSQL C API uses a few defined datatypes beyond the standard C types. These types are defined in the `msql.h’ header file that must be included when compiling any program that uses the MySQL library.

m_result

A structure containing the results of a SELECT (or SHOW) statement. The actual output of the query must be accessed through m_row elements of this structure.

m_row

A single row of data returned from a SELECT query. Output of all mSQL datatypes are stored in this type (as an array of character strings).

m_field

A structure containing all of the information concerning a specific field in the table. The elements of the m_field structure can be directly examined and are as follows:

char *name

The name of the field.

char *table

The name of the table containing the field. This is a null value if the result set does not correspond to a real table.

int type

The type of the field. This is an integer corresponding to the mSQL SQL datatypes defined in the msql.h header file.

int length

The byte length of the field.

int flags

Zero or more option flags. The flags are accessed through the following macros:

IS_PRI_KEY(flags)

Returns true if the field is a primary key.

IS_NOT_NULL(flags)

Returns true if the field is defined as NOT ...

Get MySQL and mSQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.