1mysql_optionsv(3)             MariaDB Connector/C            mysql_optionsv(3)
2
3
4
5   Name
6       mysql_optionsv  - Used to set extra connect options and affect behavior
7       of a connection
8
9   Synopsis
10              #include <mysql.h>
11
12              int mysql_optionsv(MYSQL * mysql,
13                                 enum mysql_option,
14                                 const void * arg,
15                                 ...);
16
17   Description
18       Used to set extra connect options and affect behavior for a connection.
19       This  function  may  be  called  multiple times to set several options.
20       mysql_optionsv() should be called after mysql_init(3).
21
22   Options
23       The following table shows which variable type to use for each option.
24
25       Variable Type                         Values
26       ──────────────────────────────────────────────────────────────────────────
27       my_bool                               MYSQL_OPT_RECONNECT,  MYSQL_OPT_LO‐
28                                             CAL_INFILE,      MYSQL_SECURE_AUTH,
29                                             MYSQL_REPORT_DATA_TRUNCATION,
30                                             MYSQL_OPT_SSL_ENFORCE,
31                                             MYSQL_OPT_SSL_VERIFY_SERVER_CERT
32       unsigned int                          MYSQL_OPT_PORT,      MYSQL_OPT_CON‐
33                                             NECT_TIMEOUT,   MYSQL_OPT_PROTOCOL,
34                                             MYSQL_OPT_READ_TIMEOUT,
35                                             MYSQL_OPT_WRITE_TIMEOUT
36       unsigned long                         MYSQL_OPT_NET_BUFFER_LENGTH,
37                                             MYSQL_OPT_MAX_ALLOWED_PACKET
38       const char *                          MYSQL_INIT_COMMAND,           MARI‐
39                                             ADB_OPT_UNIXSOCKET,           MARI‐
40                                             ADB_OPT_PASSWORD ,  MARIADB_OPT_US‐
41                                             ER,     MARIADB_OPT_HOST,     MARI‐
42                                             ADB_OPT_SCHEMA,  MYSQL_OPT_SSL_KEY,
43                                             MYSQL_OPT_SSL_CERT,
44                                             MYSQL_OPT_SSL_CA, MYSQL_OPT_SSL_CA‐
45                                             PATH,       MYSQL_SET_CHARSET_NAME,
46                                             MYSQL_SET_CHARSET_DIR,
47                                             MYSQL_OPT_SSL_CIPHER,
48                                             MYSQL_SHARED_MEMORY_BASE_NAME,
49                                             MYSQL_PLUGIN_DIR,         MYSQL_DE‐
50                                             FAULT_AUTH,     MARIADB_OPT_SSL_FP,
51                                             MARIADB_OPT_SSL_FP_LIST,      MARI‐
52                                             ADB_OPT_TLS_PASSPHRASE,       MARI‐
53                                             ADB_OPT_TLS_VERSION,
54                                             MYSQL_OPT_BIND,      MYSQL_OPT_CON‐
55                                             NECT_ATTR_DELETE,    MYSQL_OPT_CON‐
56                                             NECT_ATTR_ADD,  MARIADB_OPT_CONNEC‐
57                                             TION_HANDLER,     MYSQL_SERVER_PUB‐
58                                             LIC_KEY
59       -                                     MYSQL_OPT_CONNECT_ATTR_RESET
60
61       • MYSQL_INIT_COMMAND
62       Command(s) which will be executed when connecting and  reconnecting  to
63       the server.
64
65       • MYSQL_OPT_COMPRESS
66       Use  the  compressed  protocol for client server communication.  If the
67       server doesn’t support compressed protocol, the default  protocol  will
68       be used.
69
70       • MYSQL_OPT_CONNECT_TIMEOUT
71       Connect  timeout  in seconds.  This value will be passed as an unsigned
72       ##int## parameter.
73
74       • MYSQL_OPT_LOCAL_INFILE
75       Enable or disable the use of LOAD DATA LOCAL INFILE
76
77       • MYSQL_OPT_NAMED_PIPE
78       For Windows operating systems only: Use named pipes  for  client/server
79       communication.
80
81       • MYSQL_PROGRESS_CALLBACK
82       Specifies  a  callback  function  which  will  be able to visualize the
83       progress of certain long running statements (i.e. LOAD DATA  LOCAL  IN‐
84       FILE  or  ALTER  TABLE).  The callback function must be defined as fol‐
85       lowed:
86
87              static void report_progress(const MYSQL *mysql __attribute__((unused)),
88                                          uint stage, uint max_stage,
89                                          double progress __attribute__((unused)),
90                                          const char *proc_info __attribute__((unused)),
91                                          uint proc_info_length __attribute__((unused)))
92
93       • MYSQL_OPT_PROTOCOL
94       Specify the type  of  client/server  protocol.   Possible  values  are:
95       MYSQL_PROTOCOL_TCP,   MYSQL_PROTOCOL_SOCKET,   MYSQL_PROTOCOL_PIPE  and
96       MYSQL_PROTOCOL_MEMORY.
97
98       • MYSQL_OPT_RECONNECT
99       Enable or disable automatic reconnect.
100
101       • MYSQL_OPT_READ_TIMEOUT
102       Specifies the timeout in seconds for reading packets from the server.
103
104       • MYSQL_OPT_WRITE_TIMEOUT
105       Specifies the timeout in seconds for sending packets to the server.
106
107       • MYSQL_READ_DEFAULT_FILE
108       Read options from named  configuration  file.   To  read  from  default
109       my.cnf  configuration file, a NULL pointer has to be passed with option
110       MYSQL_READ_DEFAULT_GROUP.  Note: MariaDB Connector/C will not read  the
111       configuration  by default.  If MYSQL_READ_DEFAULT_FILE is specified the
112       following sections will be always processed:
113
114       • [client]
115
116       • [client-server]
117
118       • [client-mariadb]
119
120       • MYSQL_READ_DEFAULT_GROUP
121       Read options from the named group from  [[configuring-mariadb-with-myc‐
122       nf|my.cnf]] or the file specified with MYSQL_READ_DEFAULT_FILE.
123
124       • MYSQL_REPORT_DATA_TRUNCATION
125       Enable  or disable reporting data truncation errors for prepared state‐
126       ments.
127
128       • MYSQL_OPT_BIND
129       Specify the network interface from which to connect to MariaDB Server.
130
131       • MYSQL_PLUGIN_DIR
132       Specify the location of client plugins.
133
134       • MYSQL_OPT_NONBLOCK
135       Specify stack size for  non  blocking  operations.   The  argument  for
136       MYSQL_OPT_NONBLOCK is the size of the stack used to save the state of a
137       non-blocking operation while it is waiting for I/O and the  application
138       is  doing  other  processing.   Normally, applications will not have to
139       change this, and it can be passed as zero to use the default value.
140
141       • MARIADB_OPT_CONNECTION_HANDLER
142       Specify the name of a connection handler plugin.
143
144       • MARIADB_OPT_USERDATA
145       Bundle user data to the current connection, e.g. for use in  connection
146       handler  plugins.   This  option requires 4 parameters: connection, op‐
147       tion, key and value:
148
149              mysql_optionsv(mysql, MARIADB_OPT_USERDATA, (void *)"ssh_user", (void *)ssh_user);
150
151       • MARIADB_OPT_CONNECTION_READ_ONLY
152       This option is used by connection handler plugins  and  indicates  that
153       the current connection will be used for read operations only.
154
155       • MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS
156       If  this  option  is  set, the client indicates that it will be able to
157       handle expired passwords by setting the CLIENT_CAN_HANDLE_EXPIRED_PASS‐
158       WORDS capability flag.  If the password has expired and CLIENT_CAN_HAN‐
159       DLE_EXPIRED_PASSWORDS is set, the server will not return an error  when
160       connecting,  but put the connection in sandbox mode, where all commands
161       will return error 1820 (ER_MUST_CHANGE_PASSWORD) unless a new  password
162       was set.  This option was added in MariaDB Connector/C 3.0.4
163
164   TLS/SSL and Security options
165       • MYSQL_OPT_SSL_KEY
166       Specify  the name of a key for a secure connection.  If the key is pro‐
167       tected with a passphrase, the passphrase needs  to  be  specified  with
168       MARIADB_OPT_PASSPHRASE option.
169
170       • MYSQL_OPT_SSL_CERT
171       Specify the name of a certificate for a secure connection.
172
173       • MYSQL_OPT_SSL_CA
174       Specify the name of a file which contains one or more trusted CAs.
175
176       • MYSQL_OPT_SSL_CAPATH
177       Specify the path which contains trusted CAs.
178
179       • MYSQL_OPT_SSL_CIPHER
180       Specify  one  or more (SSLv3, TLSv1.0 or TLSv1.2) cipher suites for TLS
181       encryption.  Even if Connector/C supports TLSv1.3 protocol, it  is  not
182       possible yet to specify TLSv1.3 cipher suites.
183
184       • MYSQL_OPT_SSL_CRL
185       Specify a file with a certificate revocation list.
186
187       • MYSQL_OPT_SSL_CRLPATH
188       Specify  a  directory  with  contains files with certificate revocation
189       lists.
190
191       • MARIADB_OPT_SSL_FP
192       Specify the SHA1 fingerprint of a  server  certificate  for  validation
193       during the TLS handshake.
194
195       • MARIADB_OPT_SSL_FP
196       Specify  a  file which contains one or more SHA1 fingerprints of server
197       certificates for validation during the TLS handshake.
198
199       • MARIADB_OPT_SSL_PASPHRASE
200       Specify a passphrase for a passphrase protected client key.
201
202       • MYSQL_OPT_SSL_VERIFY_SERVER_CERT
203       Enable (or disable) the verification of  the  hostname  against  common
204       name (CN) of the server’s host certificate.
205
206       • MYSQL_SERVER_PUBLIC_KEY
207       Specifies the name of the file which contains the RSA public key of the
208       database server.  The format of this file must be in PEM format.   This
209       option  is  used  by  the caching_sha2_password plugin and was added in
210       Connector/C 3.1.0
211
212       • MARIADB_OPT_TLS_CIPHER_STRENGTH
213       This option is not in use anymore.
214
215   Connection Attributes
216       Connection attributes are stored in the session_connect_attrs and  ses‐
217       sion_account_connect_attrsPerformance Schema tables.  By default, Mari‐
218       aDB Connector/C sends the following connection attributes to the  serv‐
219       er:  *  _client_name: always “libmariadb” * _client_version: version of
220       MariaDB Connector/C * _os: operation system * _pid: process id * _plat‐
221       form:  e.g. x86  or  x64  * _server_host: the hostname (as specified in
222       mysql_real_connect).  This attribute was added in Connector/C 3.0.5
223
224       Note: If the Performance Schema is disabled, connection attributes will
225       not be stored on server.
226
227       • MYSQL_OPT_CONNECT_ATTR_DELETE
228       Deletes a connection attribute for the given key.
229
230       • MYSQL_OPT_CONNECT_ATTR_ADD
231       Adds a key/value pair to connection attributes.
232
233       • MYSQL_OPT_CONNECT_ATTR_RESET
234       Clears the current list of connection attributes.
235
236   See Also
237       mysql_init(3) mysql_real_connect(3)
238
239
240
241Version 3.2.2                                                mysql_optionsv(3)
Impressum