C API Data Structures
2138
• To check for
BLOB
or
TIMESTAMP
values, check whether
type
is
MYSQL_TYPE_BLOB
or
MYSQL_TYPE_TIMESTAMP
. (The
BLOB_FLAG
and
TIMESTAMP_FLAG
flags are unneeded.)
•
ENUM
and
SET
values are returned as strings. For these, check that the
type
value is
MYSQL_TYPE_STRING
and that the
ENUM_FLAG
or
SET_FLAG
flag is set in the
flags
value.
NUM_FLAG
indicates that a column is numeric. This includes columns with a type of
MYSQL_TYPE_DECIMAL
,
MYSQL_TYPE_TINY
,
MYSQL_TYPE_SHORT
,
MYSQL_TYPE_LONG
,
MYSQL_TYPE_FLOAT
,
MYSQL_TYPE_DOUBLE
,
MYSQL_TYPE_NULL
,
MYSQL_TYPE_LONGLONG
,
MYSQL_TYPE_INT24
, and
MYSQL_TYPE_YEAR
.
NO_DEFAULT_VALUE_FLAG
indicates that a column has no
DEFAULT
clause in its definition.
This does not apply to
NULL
columns (because such columns have a default of
NULL
), or to
AUTO_INCREMENT
columns (which have an implied default value).
NO_DEFAULT_VALUE_FLAG
was
added in MySQL 5.0.2.
The following example illustrates a typical use of the
flags
value:
if (field->flags & NOT_NULL_FLAG)
printf("Field can't be null\n");
You may use the convenience macros shown in the following table to determine the boolean status
of the
flags
value.
Flag Status
Description
IS_NOT_NULL(flags)
True if this field is defined as
NOT NULL
IS_PRI_KEY(flags)
True if this field is a primary key
IS_BLOB(flags)
True if this field is a
BLOB
or
TEXT
(deprecated; test
field->type
instead)
•
unsigned int decimals
The number of decimals for numeric fields.
•
unsigned int charsetnr
An ID number that indicates the character set/collation pair for the field.
To distinguish between binary and nonbinary data for string data types, check whether the
charsetnr
value is 63. If so, the character set is
binary
, which indicates binary rather than
nonbinary data. This enables you to distinguish
BINARY
from
CHAR
,
VARBINARY
from
VARCHAR
, and
the
BLOB
types from the
TEXT
types.
charsetnr
values are the same as those displayed in the
Id
column of the
SHOW COLLATION
statement or the
ID
column of the
INFORMATION_SCHEMA
COLLATIONS
table. You can use those
information sources to see which character set and collation specific
charsetnr
values indicate:
mysql>
SHOW COLLATION WHERE Id = 63;
+-----------+---------+----+---------+----------+---------+
| Collation | Charset | Id | Default | Compiled | Sortlen |
+-----------+---------+----+---------+----------+---------+
| binary | binary | 63 | Yes | Yes | 1 |
+-----------+---------+----+---------+----------+---------+
mysql>
SELECT COLLATION_NAME, CHARACTER_SET_NAME
->
FROM INFORMATION_SCHEMA.COLLATIONS WHERE ID = 33;
+-----------------+--------------------+
| COLLATION_NAME | CHARACTER_SET_NAME |
+-----------------+--------------------+
| utf8_general_ci | utf8 |
+-----------------+--------------------+
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...