MySQL :: MySQL 8.4 C API Developer Guide :: 9.2.4 mysql_load_plugin() (original) (raw)

9.2.4 mysql_load_plugin()

struct st_mysql_client_plugin *
mysql_load_plugin(MYSQL *mysql,
                  const char *name,
                  int type,
                  int argc,
                  ...)

Description

Loads a MySQL client plugin, specified by name and type. An error occurs if the type is invalid or the plugin cannot be loaded.

It is not possible to load multiple plugins of the same type. An error occurs if you try to load a plugin of a type already loaded.

Specify the arguments as follows:

Another way to cause plugins to be loaded is to set theLIBMYSQL_PLUGINS environment variable to a list of semicolon-separated plugin names. For example:

export LIBMYSQL_PLUGINS="myplugin1;myplugin2"

Plugins named by LIBMYSQL_PLUGINS are loaded when the client program callsmysql_library_init(). No error is reported if problems occur loading these plugins.

The LIBMYSQL_PLUGIN_DIR environment variable can be set to the path name of the directory in which to look for client plugins. This variable is used in two ways:

Return Values

A pointer to the plugin if it was loaded successfully.NULL if an error occurred.

Example

MYSQL mysql;

if(!mysql_load_plugin(&mysql, "myplugin",
                      MYSQL_CLIENT_AUTHENTICATION_PLUGIN, 0))
{
    fprintf(stderr, "Error: %s\n", mysql_error(&mysql));
    exit(-1);
}