C API Prepared Statement Data Structures
2196
•
MYSQL_TYPE_BLOB
indicates binary input string data. The value is treated as having the
binary
character set. That is, it is treated as a byte string and no conversion occurs.
The following table shows the permissible values for the
buffer_type
member of
MYSQL_BIND
structures for output values received from the server. The table shows the SQL types of received
values, the corresponding type codes that such values have in result set metadata, and the
recommended C language data types to bind to the
MYSQL_BIND
structure to receive the SQL values
without conversion. Choose the
buffer_type
value according to the data type of the C language
variable that you are binding. For the integer types, you should also set the
is_unsigned
member to
indicate whether the variable is signed or unsigned.
SQL Type of Received
Value
buffer_type
Value
Output Variable C Type
TINYINT
MYSQL_TYPE_TINY
signed char
SMALLINT
MYSQL_TYPE_SHORT
short int
MEDIUMINT
MYSQL_TYPE_INT24
int
INT
MYSQL_TYPE_LONG
int
BIGINT
MYSQL_TYPE_LONGLONG
long long int
FLOAT
MYSQL_TYPE_FLOAT
float
DOUBLE
MYSQL_TYPE_DOUBLE
double
DECIMAL
MYSQL_TYPE_NEWDECIMAL
char[]
YEAR
MYSQL_TYPE_SHORT
short int
TIME
MYSQL_TYPE_TIME
MYSQL_TIME
DATE
MYSQL_TYPE_DATE
MYSQL_TIME
DATETIME
MYSQL_TYPE_DATETIME
MYSQL_TIME
TIMESTAMP
MYSQL_TYPE_TIMESTAMP
MYSQL_TIME
CHAR
,
BINARY
MYSQL_TYPE_STRING
char[]
VARCHAR
,
VARBINARY
MYSQL_TYPE_VAR_STRING
char[]
TINYBLOB
,
TINYTEXT
MYSQL_TYPE_TINY_BLOB
char[]
BLOB
,
TEXT
MYSQL_TYPE_BLOB
char[]
MEDIUMBLOB
,
MEDIUMTEXT
MYSQL_TYPE_MEDIUM_BLOB
char[]
LONGBLOB
,
LONGTEXT
MYSQL_TYPE_LONG_BLOB
char[]
BIT
MYSQL_TYPE_BIT
char[]
20.6.8.2. C API Prepared Statement Type Conversions
Prepared statements transmit data between the client and server using C language variables on the
client side that correspond to SQL values on the server side. If there is a mismatch between the C
variable type on the client side and the corresponding SQL value type on the server side, MySQL
performs implicit type conversions in both directions.
MySQL knows the type code for the SQL value on the server side. The
buffer_type
value in the
MYSQL_BIND
structure indicates the type code of the C variable that holds the value on the client
side. The two codes together tell MySQL what conversion must be performed, if any. Here are some
examples:
• If you use
MYSQL_TYPE_LONG
with an
int
variable to pass an integer value to the server that is to
be stored into a
FLOAT
column, MySQL converts the value to floating-point format before storing it.
• If you fetch an SQL
MEDIUMINT
column value, but specify a
buffer_type
value of
MYSQL_TYPE_LONGLONG
and use a C variable of type
long long int
as the destination buffer,
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...