JavaScript Editor Source code editor     What Is Ajax 


Main Page

Chapter 22. APIs and Libraries

Table of Contents

22.1. libmysqld, the Embedded MySQL Server Library
22.2. MySQL C API
22.2.1. C API Data types
22.2.2. C API Function Overview
22.2.3. C API Function Descriptions
22.2.4. C API Prepared Statements
22.2.5. C API Prepared Statement Data types
22.2.6. C API Prepared Statement Function Overview
22.2.7. C API Prepared Statement Function Descriptions
22.2.8. C API Prepared statement problems
22.2.9. C API Handling of Multiple Statement Execution
22.2.10. C API Handling of Date and Time Values
22.2.11. C API Threaded Function Descriptions
22.2.12. C API Embedded Server Function Descriptions
22.2.13. Controlling Automatic Reconnect Behavior
22.2.14. Common Questions and Problems When Using the C API
22.2.15. Building Client Programs
22.2.16. How to Make a Threaded Client
22.3. MySQL PHP API
22.3.1. Common Problems with MySQL and PHP
22.3.2. Enabling Both mysql and mysqli in PHP
22.4. MySQL Perl API
22.5. MySQL C++ API
22.6. MySQL Python API
22.7. MySQL Tcl API
22.8. MySQL Eiffel Wrapper
22.9. MySQL Program Development Utilities
22.9.1. msql2mysql — Convert mSQL Programs for Use with MySQL
22.9.2. mysql_config — Get Compile Options for Compiling Clients

This chapter describes the APIs available for MySQL, where to get them, and how to use them. The C API is the most extensively covered, because it was developed by the MySQL team, and is the basis for most of the other APIs. This chapter also covers some programs that are useful for application developers.

22.1. libmysqld, the Embedded MySQL Server Library

The embedded MySQL server library is NOT part of MySQL 5.0. It is part of previous editions and will be included in future versions, starting with MySQL 5.1. You can find appropriate documentation in the corresponding manuals for these versions. In this manual, only an overview of the embedded library is provided.

The embedded MySQL server library makes it possible to run a full-featured MySQL server inside a client application. The main benefits are increased speed and more simple management for embedded applications.

The embedded server library is based on the client/server version of MySQL, which is written in C/C++. Consequently, the embedded server also is written in C/C++. There is no embedded server available in other languages.

The API is identical for the embedded MySQL version and the client/server version. To change an old threaded application to use the embedded library, you normally only have to add calls to the following functions:

FunctionWhen to Call
mysql_library_init()Should be called before any other MySQL function is called, preferably early in the main() function.
mysql_library_end()Should be called before your program exits.
mysql_thread_init()Should be called in each thread you create that accesses MySQL.
mysql_thread_end()Should be called before calling pthread_exit()

Then you must 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 allow you to change between the embedded and the client/server version by just linking your application with the right library. See Section 22.2.3.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.

JavaScript Editor Source code editor     What Is Ajax