MySQL C API
2130
Function
When to Call
mysql_thread_init()
Call it in each thread you create that accesses MySQL.
mysql_thread_end()
Call it before calling
pthread_exit()
.
Then, link your code with
libmysqld.a
instead of
libmysqlclient.a
. To ensure binary
compatibility between your application and the server library, be sure to compile your application
against headers for the same series of MySQL that was used to compile the server library. For
example, if
libmysqld
was compiled against MySQL 4.1 headers, do not compile your application
against MySQL 5.1 headers, or vice versa.
The
mysql_library_xxx()
functions are also included in
libmysqlclient.a
to enable you to
change between the embedded and the client/server version by just linking your application with the
right library. See
Section 20.6.6.40, “
mysql_library_init()
”
.
One difference between the embedded server and the standalone server is that for the embedded
server, authentication for connections is disabled by default. To use authentication for the embedded
server, specify the
--with-embedded-privilege-control
option when you invoke
configure
to
configure your MySQL distribution.
20.6. MySQL C API
The C API provides low-level access to the MySQL client/server protocol and enables C programs
to access database contents. The C API code is distributed with MySQL and implemented in the
libmysqlclient
library See
Section 20.6.1, “MySQL C API Implementations”
.
Most other client APIs use the
libmysqlclient
library to communicate with the MySQL server.
(Exceptions are except Connector/J and Connector/Net.) This means that, for example, you can take
advantage of many of the same environment variables that are used by other client programs because
they are referenced from the library. For a list of these variables, see
Section 4.1, “Overview of MySQL
Programs”
.
For instructions on building client programs using the C API, see
Section 20.6.3.1, “Building C API
Client Programs”
. For programming with threads, see
Section 20.6.3.2, “Writing C API Threaded Client
Programs”
. To create a standalone application which includes the "server" and "client" in the same
program (and does not communicate with an external MySQL server), see
Section 20.5, “libmysqld, the
Embedded MySQL Server Library”
.
Note
If, after an upgrade, you experience problems with compiled client programs,
such as
Commands out of sync
or unexpected core dumps, the programs
were probably compiled using old header or library files. In this case, check
the date of the
mysql.h
file and
libmysqlclient.a
library used for
compilation to verify that they are from the new MySQL distribution. If not,
recompile he programs with the new headers and libraries. Recompilation
might also be necessary for programs compiled against the shared client
library if the library major version number has changed (for example, from
libmysqlclient.so.15
to
libmysqlclient.so.16
).
Clients have a maximum communication buffer size. The size of the buffer that is allocated initially
(16KB) is automatically increased up to the maximum size (16MB by default). Because buffer sizes
are increased only as demand warrants, simply increasing the maximum limit does not in itself cause
more resources to be used. This size check is mostly a precaution against erroneous statements and
communication packets.
The communication buffer must be large enough to contain a single SQL statement (for client-to-server
traffic) and one row of returned data (for server-to-client traffic). Each session's communication buffer
is dynamically enlarged to handle any query or row up to the maximum limit. For example, if you have
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 ...