C API Function Descriptions
2187
An unknown error occurred.
20.6.6.66.
mysql_sqlstate()
const char *mysql_sqlstate(MYSQL *mysql)
Description
Returns a null-terminated string containing the SQLSTATE error code for the most recently executed
SQL statement. The error code consists of five characters.
'00000'
means “no error.” The values are
specified by ANSI SQL and ODBC. For a list of possible values, see
Appendix C, Errors, Error Codes,
and Common Problems
.
SQLSTATE values returned by
mysql_sqlstate()
differ from MySQL-specific error numbers
returned by
mysql_errno()
. For example, the
mysql
client program displays errors using the
following format, where
1146
is the
mysql_errno()
value and
'42S02'
is the corresponding
mysql_sqlstate()
value:
shell>
SELECT * FROM no_such_table;
ERROR 1146 (42S02): Table 'test.no_such_table' doesn't exist
Not all MySQL error numbers are mapped to SQLSTATE error codes. The value
'HY000'
(general
error) is used for unmapped error numbers.
If you call
mysql_sqlstate()
after
mysql_real_connect()
fails,
mysql_sqlstate()
might not
return a useful value. For example, this happens if a host is blocked by the server and the connection is
closed without any SQLSTATE value being sent to the client.
Return Values
A null-terminated character string containing the SQLSTATE error code.
See Also
See
Section 20.6.6.14, “
mysql_errno()
”
,
Section 20.6.6.15, “
mysql_error()
”
, and
Section 20.6.10.26, “
mysql_stmt_sqlstate()
”
.
20.6.6.67.
mysql_ssl_set()
my_bool mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, const
char *ca, const char *capath, const char *cipher)
Description
mysql_ssl_set()
is used for establishing secure connections using SSL. It must be called before
mysql_real_connect()
.
mysql_ssl_set()
does nothing unless SSL support is enabled in the client library.
mysql
is the connection handler returned from
mysql_init()
. The other parameters are specified as
follows:
•
key
is the path name to the key file.
•
cert
is the path name to the certificate file.
•
ca
is the path name to the certificate authority file.
•
capath
is the path name to a directory that contains trusted SSL CA certificates in PEM format.
•
cipher
is a list of permissible ciphers to use for SSL encryption.
Any unused SSL parameters may be given as
NULL
.
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 ...