-
Notifications
You must be signed in to change notification settings - Fork 263
/
Copy pathmysql_optionsv.3
529 lines (525 loc) · 14.2 KB
/
mysql_optionsv.3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
'\" t
.\" Automatically generated by Pandoc 3.5
.\"
.TH "mysql_optionsv" "3" "" "Version 3.4" "MariaDB Connector/C"
.SS Name
mysql_optionsv \- Used to set extra connect options and affect behavior
of a connection
.SS Synopsis
.IP
.EX
#include \f[B]<mysql.h>\f[R]
int mysql_optionsv(MYSQL * mysql,
\f[B]enum\f[R] mysql_option,
const void * arg,
...);
.EE
.SS Description
Used to set extra connect options and affect behavior for a connection.
This function may be called multiple times to set several options.
\f[CR]mysql_optionsv()\f[R] should be called after
\f[B]mysql_init(3)\f[R].
.SS Options
The following table shows which variable type to use for each option.
.PP
.TS
tab(@);
lw(35.0n) lw(35.0n).
T{
Variable Type
T}@T{
Values
T}
_
T{
\f[CR]my_bool\f[R]
T}@T{
\f[CR]MYSQL_OPT_RECONNECT\f[R], \f[CR]MYSQL_SECURE_AUTH\f[R],
\f[CR]MYSQL_REPORT_DATA_TRUNCATION\f[R],
\f[CR]MYSQL_OPT_SSL_ENFORCE\f[R],
\f[CR]MYSQL_OPT_SSL_VERIFY_SERVER_CERT\f[R],
\f[CR]MARIADB_OPT_SKIP_READ_RESPONSE\f[R]
T}
T{
\f[CR]unsigned int\f[R]
T}@T{
\f[CR]MYSQL_OPT_PORT\f[R], \f[CR]MYSQL_OPT_LOCAL_INFILE\f[R],
\f[CR]MYSQL_OPT_CONNECT_TIMEOUT\f[R], \f[CR]MYSQL_OPT_PROTOCOL\f[R],
\f[CR]MYSQL_OPT_READ_TIMEOUT\f[R], \f[CR]MYSQL_OPT_WRITE_TIMEOUT\f[R]
T}
T{
\f[CR]unsigned long\f[R]
T}@T{
\f[CR]MYSQL_OPT_NET_BUFFER_LENGTH\f[R],
\f[CR]MYSQL_OPT_MAX_ALLOWED_PACKET\f[R]
T}
T{
\f[CR]const char *\f[R]
T}@T{
\f[CR]MYSQL_INIT_COMMAND\f[R], \f[CR]MARIADB_OPT_UNIXSOCKET\f[R],
\f[CR]MARIADB_OPT_PASSWORD\f[R] , \f[CR]MARIADB_OPT_USER\f[R],
\f[CR]MARIADB_OPT_HOST\f[R], \f[CR]MARIADB_OPT_SCHEMA\f[R],
\f[CR]MYSQL_OPT_SSL_KEY\f[R], \f[CR]MYSQL_OPT_SSL_CERT\f[R],
\f[CR]MYSQL_OPT_SSL_CA\f[R], \f[CR]MYSQL_OPT_SSL_CAPATH\f[R],
\f[CR]MYSQL_SET_CHARSET_NAME\f[R], \f[CR]MYSQL_SET_CHARSET_DIR\f[R],
\f[CR]MYSQL_OPT_SSL_CIPHER\f[R],
\f[CR]MYSQL_SHARED_MEMORY_BASE_NAME\f[R], \f[CR]MYSQL_PLUGIN_DIR\f[R],
\f[CR]MYSQL_DEFAULT_AUTH\f[R], \f[CR]MARIADB_OPT_SSL_FP\f[R],
\f[CR]MARIADB_OPT_SSL_FP_LIST\f[R],
\f[CR]MARIADB_OPT_TLS_PASSPHRASE\f[R],
\f[CR]MARIADB_OPT_TLS_VERSION\f[R], \f[CR]MYSQL_OPT_BIND\f[R],
\f[CR]MYSQL_OPT_CONNECT_ATTR_DELETE\f[R],
\f[CR]MYSQL_OPT_CONNECT_ATTR_ADD\f[R],
\f[CR]MARIADB_OPT_CONNECTION_HANDLER\f[R],
\f[CR]MYSQL_SERVER_PUBLIC_KEY\f[R],
\f[CR]MARIADB_OPT_RESTRICTED_AUTH\f[R]
T}
T{
\f[CR]const char*, unsigned int\f[R]
T}@T{
\f[CR]MARIADB_OPT_RPL_REGISTER_REPLICA\f[R]
T}
T{
\-
T}@T{
\f[CR]MYSQL_OPT_CONNECT_ATTR_RESET\f[R]
T}
T{
void *
T}@T{
\f[CR]MARIADB_OPT_PROXY_HEADER\f[R]
T}
.TE
.IP \[bu] 2
\f[CR]MYSQL_OPT_SSL_ENFORCE\f[R]
.PD 0
.P
.PD
Enable or disable TLS.
This option can be used to enable TLS without having to provide TLS
certificates, keys or CAs.
.PD 0
.P
.PD
\f[B]Note\f[R]: currenty this does not enforce TLS like the option name
would suggest.
If the server does not support TLS, the protocol will fall back to
unencrypted communication.
To enforce the use of TLS, use
\f[CR]MYSQL_OPT_SSL_VERIFY_SERVER_CERT\f[R] instead.
.IP \[bu] 2
\f[CR]MYSQL_INIT_COMMAND\f[R]
.PD 0
.P
.PD
Command(s) which will be executed when connecting and reconnecting to
the server.
.IP \[bu] 2
\f[CR]MYSQL_OPT_COMPRESS\f[R]
.PD 0
.P
.PD
Use the compressed protocol for client server communication.
If the server doesn\[cq]t support compressed protocol, the default
protocol will be used.
.IP \[bu] 2
\f[CR]MYSQL_OPT_CONNECT_TIMEOUT\f[R]
.PD 0
.P
.PD
Connect timeout in seconds.
This value will be passed as an unsigned ##int## parameter.
.IP \[bu] 2
\f[CR]MYSQL_OPT_LOCAL_INFILE\f[R]
.PD 0
.P
.PD
Enable or disable the use of \f[CR]LOAD DATA LOCAL INFILE\f[R]
.IP \[bu] 2
\f[CR]MYSQL_OPT_NAMED_PIPE\f[R]
.PD 0
.P
.PD
For Windows operating systems only: Use named pipes for client/server
communication.
.IP \[bu] 2
\f[CR]MYSQL_PROGRESS_CALLBACK\f[R]
.PD 0
.P
.PD
Specifies a callback function which will be able to visualize the
progress of certain long running statements
(i.e.\ \f[CR]LOAD DATA LOCAL INFILE\f[R] or \f[CR]ALTER TABLE\f[R]).
The callback function must be defined as followed:
.IP
.EX
static void report_progress(const MYSQL *mysql __attribute__((unused)),
uint stage, uint max_stage,
double progress __attribute__((unused)),
const char *proc_info __attribute__((unused)),
uint proc_info_length __attribute__((unused)))
.EE
.IP \[bu] 2
\f[CR]MYSQL_OPT_PROTOCOL\f[R]
.PD 0
.P
.PD
Specify the type of client/server protocol.
Possible values are: \f[CR]MYSQL_PROTOCOL_TCP\f[R],
\f[CR]MYSQL_PROTOCOL_SOCKET\f[R], \f[CR]MYSQL_PROTOCOL_PIPE\f[R] and
\f[CR]MYSQL_PROTOCOL_MEMORY\f[R].
.IP \[bu] 2
\f[CR]MYSQL_OPT_RECONNECT\f[R]
.PD 0
.P
.PD
Enable or disable automatic reconnect.
.IP \[bu] 2
\f[CR]MYSQL_OPT_READ_TIMEOUT\f[R]
.PD 0
.P
.PD
Specifies the timeout in seconds for reading packets from the server.
.IP \[bu] 2
\f[CR]MYSQL_OPT_WRITE_TIMEOUT\f[R]
.PD 0
.P
.PD
Specifies the timeout in seconds for sending packets to the server.
.IP \[bu] 2
\f[CR]MYSQL_READ_DEFAULT_FILE\f[R]
.PD 0
.P
.PD
Read options from the specified configuration file.
If an empty string is passed, the default configuration files (such as
/etc/my.cnf, /etc/mysql/my.cnf) will be read.
By default, configuration files are not processed unless this option is
specified.
.IP \[bu] 2
\f[CR]MYSQL_READ_DEFAULT_GROUP\f[R] Read options from the specified
group within the default configuration file or the file specified by
MYSQL_READ_DEFAULT_FILE.
Passing an empty string will result in all sections being processed.
If no specific file is provided via MYSQL_READ_DEFAULT_FILE, all
available default configuration files will be considered.
.RS 2
.PP
\f[B]Note:\f[R] In addition to a specified group the following groups
will be always processed:
.IP \[bu] 2
[client]
.IP \[bu] 2
[client\-server]
.IP \[bu] 2
[client\-mariadb]
.RE
.IP \[bu] 2
\f[CR]MYSQL_REPORT_DATA_TRUNCATION\f[R]
.PD 0
.P
.PD
Enable or disable reporting data truncation errors for prepared
statements.
.IP \[bu] 2
\f[CR]MYSQL_OPT_BIND\f[R]
.PD 0
.P
.PD
Specify the network interface from which to connect to MariaDB Server.
.IP \[bu] 2
\f[CR]MYSQL_PLUGIN_DIR\f[R]
.PD 0
.P
.PD
Specify the location of client plugins.
.IP \[bu] 2
\f[CR]MYSQL_OPT_NONBLOCK\f[R]
.PD 0
.P
.PD
Specify stack size for non blocking operations.
The argument for MYSQL_OPT_NONBLOCK is the size of the stack used to
save the state of a non\-blocking operation while it is waiting for I/O
and the application is doing other processing.
Normally, applications will not have to change this, and it can be
passed as zero to use the default value.
.IP \[bu] 2
\f[CR]MYSQL_OPT_NET_BUFFER_LENGTH\f[R]
.PD 0
.P
.PD
Initial network buffer size in bytes.
The default value is 16777216 (16MiB).
.IP \[bu] 2
\f[CR]MYSQL_OPT_MAX_ALLOWED_PACKET\f[R]
.PD 0
.P
.PD
Maximum allowed packet length.
The default value is 1073741824 (1GiB) on the client side.
If the limit is exceeded by a packet sent by the server, an error is
generated.
.IP \[bu] 2
\f[CR]MARIADB_OPT_CONNECTION_HANDLER\f[R]
.PD 0
.P
.PD
Specify the name of a connection handler plugin.
.IP \[bu] 2
\f[CR]MARIADB_OPT_USERDATA\f[R]
.PD 0
.P
.PD
Bundle user data to the current connection, e.g.\ for use in connection
handler plugins.
This option requires 4 parameters: connection, option, key and value:
.IP
.EX
mysql_optionsv(mysql, MARIADB_OPT_USERDATA, (void *)\[dq]my_key\[dq], (void *)value);
.EE
.IP \[bu] 2
\f[CR]MARIADB_OPT_CONNECTION_READ_ONLY\f[R]
.PD 0
.P
.PD
This option is used by connection handler plugins and indicates that the
current connection will be used for read operations only.
.IP \[bu] 2
\f[CR]MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS\f[R]
.PD 0
.P
.PD
If this option is set, the client indicates that it will be able to
handle expired passwords by setting the
\f[CR]CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS\f[R] capability flag.
If the password has expired and
\f[CR]CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS\f[R] is set, the server will
not return an error when connecting, but put the connection in sandbox
mode, where all commands will return error 1820
(\f[CR]ER_MUST_CHANGE_PASSWORD\f[R]) unless a new password was set.
This option was added in MariaDB Connector/C 3.0.4
.IP \[bu] 2
\f[CR]MARIADB_OPT_STATUS_CALLBACK\f[R]
.PD 0
.P
.PD
Specifies a callback function which will be called whenever the server
status changes or the server sent session_track information to the
client:
.IP
.EX
mysql_optionsv(mysql, MARIADB_OPT_STATUS_CALLBACK, function, data)
.EE
.PP
The callback function must be defined as follows:
.IP
.EX
void status_callback(void *data, \f[B]enum\f[R] enum_mariadb_status_info type, ..)
.EE
.PP
Parameters:
.IP
.EX
\- data Pointer passed with registration of callback function
(usually a connection handle)
\- type Information type STATUS_TYPE or SESSION_TRACK_TYPE
.EE
.PP
Variadic Parameters:
.IP
.EX
if (type == STATUS_TYPE):
\- server status (unsigned int)
if (type == SESSION_TRACK_TYPE)
\- enum enum_session_state_type track_type \- session track type
if (track_type == SESSION_TRACK_SYSTEM_VARIABLES)
\- MARIADB_CONST_STRING *key
\- MARIADB_CONST_STRING *value
else
\- MARIADB_CONST_STRING *value
.EE
.PP
\[ga] Note: Specifying a callback function overwrites the internal
session tracking function, so API functions
mysql_session_track_get_first()/next() can\[cq]t be used.
.PP
An example can be found in unittest/libmariadb/connection.c
(test_status_callback)
.PP
Addid in version 3.3.2
.IP \[bu] 2
\f[CR]MARIADB_OPT_SKIP_READ_RESPONSE\f[R]
.PD 0
.P
.PD
Don\[cq]t read response packets in binary protocol.
.PP
Added in version 3.1.13
.SS Replication/Binlog API options
.IP \[bu] 2
\f[CR]MARIADB_OPT_RPL_REGISTER_REPLICA\f[R]
.PD 0
.P
.PD
Specifies host name and port for Binlog/API.
When this option was set, rpl_open() will register replica with
server_id, host and port to the connected server.
This information can be retrieved by \f[CR]SHOW SLAVE STATUS\f[R]
command.
This option was added in version 3.3.1
.SS TLS/SSL and Security options
.IP \[bu] 2
\f[CR]MYSQL_OPT_SSL_KEY\f[R]
.PD 0
.P
.PD
Specify the name of a key for a secure connection.
If the key is protected with a passphrase, the passphrase needs to be
specified with \f[CR]MARIADB_OPT_PASSPHRASE\f[R] option.
.IP \[bu] 2
\f[CR]MYSQL_OPT_SSL_CERT\f[R]
.PD 0
.P
.PD
Specify the name of a certificate for a secure connection.
.IP \[bu] 2
\f[CR]MYSQL_OPT_SSL_CA\f[R]
.PD 0
.P
.PD
Specify the name of a file which contains one or more trusted CAs.
.IP \[bu] 2
\f[CR]MYSQL_OPT_SSL_CAPATH\f[R]
.PD 0
.P
.PD
Specify the path which contains trusted CAs.
.IP \[bu] 2
\f[CR]MYSQL_OPT_SSL_CIPHER\f[R]
.PD 0
.P
.PD
Specify one or more (SSLv3, TLSv1.0 or TLSv1.2) cipher suites for TLS
encryption.
Even if Connector/C supports TLSv1.3 protocol, it is not possible yet to
specify TLSv1.3 cipher suites.
.IP \[bu] 2
\f[CR]MYSQL_OPT_SSL_CRL\f[R]
.PD 0
.P
.PD
Specify a file with a certificate revocation list.
.IP \[bu] 2
\f[CR]MYSQL_OPT_SSL_CRLPATH\f[R]
.PD 0
.P
.PD
Specify a directory with contains files with certificate revocation
lists.
.IP \[bu] 2
\f[CR]MARIADB_OPT_SSL_FP\f[R]
.PD 0
.P
.PD
Specify the fingerprint hash of a server certificate for validation
during the TLS handshake.
For versions prior to 3.4.0 the hash is a SHA1 hash, for versions 3.4.0
and newer SHA256,SHA384 or SHA512.
.IP \[bu] 2
\f[CR]MARIADB_OPT_SSL_FP_LIST\f[R]
.PD 0
.P
.PD
Specify a file which contains one or more fingerprint hashes of server
certificates for validation during the TLS handshake.
For versions prior to 3.4.0 the hash is a SHA1 hash, for versions 3.4.0
and newer SHA256,SHA384 or SHA512.
.IP \[bu] 2
\f[CR]MARIADB_OPT_SSL_PASPHRASE\f[R]
.PD 0
.P
.PD
Specify a passphrase for a passphrase protected client key.
.IP \[bu] 2
\f[CR]MYSQL_OPT_SSL_VERIFY_SERVER_CERT\f[R]
.PD 0
.P
.PD
Enable (or disable) the verification of the host name against common
name (CN) of the server\[cq]s host certificate.
.IP \[bu] 2
\f[CR]MYSQL_SERVER_PUBLIC_KEY\f[R]
.PD 0
.P
.PD
Specifies the name of the file which contains the RSA public key of the
database server.
The format of this file must be in PEM format.
This option is used by the caching_sha2_password plugin and was added in
Connector/C 3.1.0
.IP \[bu] 2
\f[CR]MARIADB_OPT_TLS_CIPHER_STRENGTH\f[R]
.PD 0
.P
.PD
This option is not in use anymore.
.IP \[bu] 2
\f[CR]MARIADB_OPT_RESTRICTED_AUTH\f[R]
.PD 0
.P
.PD
Specifies one or more comma separated authentication plugins which are
allowed for authentication.
If the database server asks for an authentication plugin not listed in
this option, MariaDB Connector/C will return an error.
This option was added in MariaDB Connector/C 3.3.0
.SS Proxy settings
As per the proxy protocol specification, the connecting client can
prefix its first packet with a proxy protocol header.
The server will parse the header and assume the client\[cq]s IP address
is the one set in the proxy header.
* \f[CR]MARIADB_OPT_PROXY_HEADER\f[R] \- specifies the proxy header
which will be prefixed to the first packet.
Parameters are void * for the prefix buffer and size_t for length of the
buffer:
.IP
.EX
const char *hdr=\[dq]PROXY TCP4 192.168.0.1 192.168.0.11 56324 443\[rs]r\[rs]n\[dq];
mysql_optionsv(mysql, MARIADB_OPT_PROXY_HEADER, hdr, strlen(hdr));
.EE
.SS Connection Attributes
Connection attributes are stored in the \f[CR]session_connect_attrs\f[R]
and \f[CR]session_account_connect_attrs\f[R]Performance Schema tables.
By default, MariaDB Connector/C sends the following connection
attributes to the server: * \f[CR]_client_name\f[R]: always
\[lq]libmariadb\[rq] * \f[CR]_client_version\f[R]: version of MariaDB
Connector/C * \f[CR]_os\f[R]: operation system * _pid: process id *
\f[CR]_platform\f[R]: e.g.\ x86 or x64 * \f[CR]_server_host\f[R]: the
host name (as specified in mysql_real_connect).
This attribute was added in Connector/C 3.0.5
.PP
\f[B]Note:\f[R] If the Performance Schema is disabled, connection
attributes will not be stored on server.
.IP \[bu] 2
\f[CR]MYSQL_OPT_CONNECT_ATTR_DELETE\f[R]
.PD 0
.P
.PD
Deletes a connection attribute for the given key.
.IP \[bu] 2
\f[CR]MYSQL_OPT_CONNECT_ATTR_ADD\f[R]
.PD 0
.P
.PD
Adds a key/value pair to connection attributes.
The total length of the stored connection attributes is limited to a
maximum of 65535 bytes.
.IP \[bu] 2
\f[CR]MYSQL_OPT_CONNECT_ATTR_RESET\f[R]
.PD 0
.P
.PD
Clears the current list of connection attributes.
.SS See Also
\f[I]\f[BI]mysql_init(3)\f[I] \f[R]\f[B]mysql_real_connect(3)\f[R]