Oracle 5.0 Reference Manual page 2184

Table of Contents

Advertisement

In a nonmulti-threaded environment, the call to
will invoke it automatically as necessary. However,
mysql_init()
not thread-safe in a multi-threaded environment, and thus neither is mysql_init(), which calls
mysql_library_init(). You must either call
threads, or else use a mutex to protect the call, whether you invoke
indirectly through mysql_init(). Do this prior to any other client library call.
The
and
arguments are analogous to the arguments to main(), and enable passing of
argc
argv
options to the embedded server. For convenience,
line arguments for the server. This is the usual case for applications intended for use only as regular
(nonembedded) clients, and the call typically is written as
#include <mysql.h>
#include <stdlib.h>
int main(void) {
if (mysql_library_init(0, NULL, NULL)) {
fprintf(stderr, "could not initialize MySQL library\n");
exit(1);
}
/* Use any MySQL API functions here */
mysql_library_end();
return EXIT_SUCCESS;
}
When arguments are to be passed
typically contains the program name).
is safe to destroy
argv
For embedded applications, if you want to connect to an external server without starting the embedded
server, you have to specify a negative value for argc.
The
argument is an array of strings that indicate the groups in option files from which to
groups
read options. See
Section 4.2.3.3, "Using Option
convenience, if the
groups
by default.
#include <mysql.h>
#include <stdlib.h>
static char *server_args[] = {
"this_program",
"--datadir=.",
"--key_buffer_size=32M"
};
static char *server_groups[] = {
"embedded",
"server",
"this_program_SERVER",
(char *)NULL
};
int main(void) {
if (mysql_library_init(sizeof(server_args) / sizeof(char *),
fprintf(stderr, "could not initialize MySQL library\n");
exit(1);
}
/* Use any MySQL API functions here */
mysql_library_end();
return EXIT_SUCCESS;
}
C API Function Descriptions
(argc
is greater than 0), the first element of
mysql_library_init()
or
after the call.
groups
argument itself is NULL, the
/* this string is not used */
server_args, server_groups)) {
2164
mysql_library_init()
mysql_library_init()
mysql_library_init()
mysql_library_init()
may be
(zero) if there are no command-
argc
0
mysql_library_init(0, NULL,
makes a copy of the arguments so it
Files". Make the final entry in the array NULL. For
and
[server]
may be omitted, because
prior to spawning any
is ignored (it
argv
groups are used
[embedded]
is
or
NULL).

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents