1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-05 15:55:58 +03:00
Commit Graph

255 Commits

Author SHA1 Message Date
Georg Richter
75439c0f39 CONC-632
When resetting the connection with mysql reset_connection(), the
server_status must be checked and any other resultsets that mayi
exist must be removed.
2023-02-08 11:46:39 +01:00
Georg Richter
d204e83104 Return correct client library version number instead of
server number in mysql_get_client_versio
2023-01-16 14:14:59 +01:00
Georg Richter
d712484dab Set MARIADB_PACKAGE_VERSION instead of
MARIADB_CLIENT_VERSION_STR for obtaining client_info.
2023-01-16 13:56:22 +01:00
Georg Richter
abea2dfa6b Merge branch '3.1' into 3.3 2023-01-15 14:27:41 +01:00
Georg Richter
bf82b2d8cb Fix for CONC-624:
- ER() macro now checks if the error code is known, if not it will return
  "Unknown or undefined error code" (instead of crashing)
- SET_CLIENT_STMT_ERROR now maps to stmt_set_error and accepts variadic
  arguments
2023-01-15 14:11:54 +01:00
Georg Richter
da9bb98c0c CONC-622: Fix double free() if asnyc connect failed
If mysql_real_connect_start/cont failed, we need to
set async->pvio to zero after calling ma_pvio_close
to avoid double free() in mysql_close.
2022-12-27 14:36:44 +01:00
Julius Goryavsky
57852875f1 MDEV-29817: Issues with handling options for SSL CRLs (and some others)
This commit fixes a bug related to reading the value of the ssl_cipher
instead of ssl_crl, and also adds handling of the forgotten tls_version
option.
2022-11-22 15:52:55 +01:00
Georg Richter
1bd8c8bf39 Added missing status callbacks outside of ma_read_ok_packet 2022-08-11 16:56:06 +02:00
Georg Richter
a6665e65c0 Clear error before reading ok packet 2022-08-03 17:57:15 +02:00
Georg Richter
9fe6541507 Windows build fix:
Added missing include file w2tcpip.h for
freeaddrinfo prototype
2022-08-03 11:26:57 +02:00
Georg Richter
64ebd5818a Follow up for status/session_track callback:
- changed data type to MARIADB_CONST_STRING
- allow setting callback function and/or data ptr
2022-08-02 15:19:39 +02:00
Georg Richter
28df8a73b6 Merge branch '3.3-status' into 3.3 2022-08-02 10:20:19 +02:00
Georg Richter
a8832afa2a status and session_tracik callback function:
This feature allows client applications to register a callback function,
which is called as soon as the server status changes or session_track
information was sent by the server.

Registration is handled via mysql_optionsv() API function:

mysql_optionsv(mysql, MARIADB_OPT_STATUS_CALLBACK, function, data)

The callback function must be defined as follws:

void status_callback(void *data, enum enum_mariadb_status_info type, ..)

  Parameters:
    - data  Pointer passed with registration of callback function
            (usually a connection handle)
    - type  Information type  STATUS_TYPE or SESSION_TRACK_TYPE

  Variadic Parameters:

  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

An example can be found in connection.c (test_status_callback)
2022-08-02 10:10:50 +02:00
Georg Richter
274f2face2 Merge pull request #199 from hyung-hwan/3.3
enhanced mysql_close_slow_part() and other related parts to prevent memory leaks in the non-blocking mode
2022-07-25 09:22:04 +02:00
Georg Richter
e8e356e355 Merge branch '3.1' into 3.3 2022-07-18 11:48:33 +02:00
Georg Richter
9a572bc548 Fix for CONC-604 and CONC-605:
This patch fixes a crash when reconnectiong via TLS.
2022-07-18 11:41:46 +02:00
Georg Richter
5f1f517cfa Various typo fixes
Includes fixes from PR-201.
2022-07-03 13:45:37 +02:00
Georg Richter
3f7719c74d Typo fixes (from PR #200) 2022-06-27 13:23:35 +02:00
hyunghwan.chung
c0fea17e2a enhanced mysql_close() and other related parts to prevent memory leaks when terminating an initiated but unestablished connection 2022-06-21 17:49:45 +09:00
Georg Richter
fcce4a8c76 CONC-592: Register replica with host and port
Added new option MARIADB_OPT_RPL_REGISTER_REPLICA which expects
two parameters, host and port. When this option was set, rpl_open
will send a COM_REGISTER_SLAVE command with server_id, host and
port to the connected server. This information can be retrieved
by "SHOW SLAVE STATUS" command.

Example:

rc= mysql_optionsv(mysql, MARIADB_OPT_RPL_REGISTER_REPLICA,
                   "myhost", 123);
2022-05-23 14:05:06 +02:00
Georg Richter
e23035d27a Merge branch '3.2' into 3.3 2022-05-02 17:27:18 +02:00
Georg Richter
ade9bb9c3e Merge branch '3.1' into 3.2 2022-05-02 10:57:27 +02:00
Georg Richter
ab7a81e79e Added new macro OPT_SET_EXTENDED_VALUE_BIN
OPT_SET_EXTENDED_VALUE_BIN can be used to set
binary values for options:
OPT_SET_EXTENDED_VALUE_BIN(options, key, key_len, val, len)
2022-04-30 05:37:31 +02:00
Georg Richter
f75a819efd Post fix for CONC-588
Instead to allocate procy header string the poiter was assigned
to extended options.
2022-04-29 16:30:27 +02:00
Georg Richter
00e5eaf403 Merge branch '3.2' into 3.3 2022-04-20 18:55:58 +02:00
Georg Richter
3ba4c4a613 Merge branch '3.1' into 3.2 2022-04-20 18:55:05 +02:00
Georg Richter
3ce51b0b3e Fix for CONC-587:
Since alerts may happen after handshake (for example with described
test in CONC-587 using TLSv1.3 protocol or by renegotiation) the
tls error message needs to be retrieved if error is a protocol error
(SSL_ERROR_SSL) and/or if errno was not set.
2022-04-20 18:48:54 +02:00
Georg Richter
f192d3d1ba Fix for CONC-588:
Free proxy_header (allocated via MARIADB_OPT_PROXY_HEADER option)
when closing connection.
2022-04-19 06:27:32 +02:00
Georg Richter
c08063a265 Removed bundled ZStandard compression library.
The ZStandard compression plugin will be build only if the
ZStandard libraries and include files are installed on the
builder.
2022-02-04 14:53:42 +01:00
Georg Richter
770cf2286a CONC-575: Support for MySQL zstd compression
ZSTD compression is now supported for connections
to a MySQL Server 8.0.

Compression algorithms are supported via compression
plugins, which can be found in plugins/compress.
2022-01-25 05:02:33 +01:00
Georg Richter
721a41d778 Merge branch '3.2' into 3.3 2022-01-14 20:10:05 +01:00
Georg Richter
c912a46f78 Merge branch '3.1' into 3.2 2022-01-14 20:09:28 +01:00
Georg Richter
141fb0d5fa Test fixes:
- For reconnection/and multi host tests specify also socket location,
since mtr doesn't use default socket for localhost connections

- parse_connection_string now returns NULL for empty password in
  curly braces
2022-01-04 10:37:12 +01:00
Georg Richter
510c7e5dfe New options MARIADB_CONNECTION_BYTES_READ/SENT
Added new options MARIADB_CONNECTION_BYTES_READ and
MARIADB_CONNECTION_BYTES_SENT which can be passed to
mariadb_get_infov() api funcion to obtain the bytes sent
or read to/from database server.
2022-01-02 14:14:39 +01:00
Sergei Golubchik
43b60edc92 use mariadb_connection() to detect whether the server is MariaDB 2021-12-25 17:23:38 +01:00
Georg Richter
a1feead1e1 CONC-365: Failover capabilities
host parameter of mysql_real_connect (and corresponding configuration
settings MYSQL_OPT_HOST for mysql_options() api call and host key in
configuration files) now accepts to specify multiple hosts and ports.

When establishing a connection, the list of specified hosts is run
through until a connection can be established. If no connection
can be established to any of the specified hosts, an error is returned.

Specifications for multiple hosts/ports:

- hostname and port must be seperated by a colon (:)
- IPv6 addresses must be enclosed within square brackets
- hostname:port pairs must be be seperated by a comma (,)
- if only one host:port was specified, the host string needs to end
  with a comma.
- if no port was specified, the default port will be used.

Examples for failover host string:

host=[::1]:3306,192.168.0.1:3306,test.example.com
host=localhost:3306,
2021-11-11 19:08:43 +01:00
Georg Richter
515361df66 CONC-274: connection string support
A connection string contains key/value pairs, separated by a semicolon
as used in ODBC. Supported keys are all configuration options which can
be used in MariaDB configuration files. For a complete list check
https://github.com/mariadb-corporation/mariadb-connector-c/wiki/config_files#configuration-options.
The connection string must contain at least one semicolon, otherwise
it wil be interpreted as hostname. Unknown or invalid keys will be ignored.

To connect via connection string, the following methods might be used:

- by specifing connection option in configuration file:

  connection=host=localhost;ssl_enforce=1;

-  by using mariadb_connect() macro

   mariadb_connect(mysql, "host=localhost;ssl_enforce=1")

-  by passing connection string in host parameter to mysql_real_connect

   mysql_real_connect(mysql, "host=localhost;ssl_enforce=1", NULL, NULL, NULL, 0, NULL, 0)
2021-11-05 06:31:58 +01:00
Georg Richter
52934a1c08 Merge branch '3.2' into 3.3 2021-10-08 10:26:06 +02:00
Georg Richter
0bf84c065e Merge branch '3.1' into 3.2 2021-10-08 10:23:51 +02:00
Georg Richter
f6b8fe10c3 Fix for CONC-568:
If multiple threads attempt to connect to a server using a
dynamically loaded authentication plugin the error
"plugin is already loaded" might occur. This is caused
by a race condition if one thread waits for a lock to
load the plugin, while another process which obtained the lock
already loaded the plugin.

The API function mysql_load_plugin_v() now returns
the plugin handle (instead of raising an error and returning
a NULL handle) even if the plugin was already loaded.
2021-10-08 10:20:23 +02:00
Georg Richter
7e0be5a919 CONC-544: restrict authentication plugins
Added new option MARIADB_OPT_RESTRICTED_AUTH (and corresponding
"restricted-auth" option for configuration files) which specifies
on or more comma spearated authentication plugins which are allowed
for authenication.

If the server asks for an authentication plugin not listed in this
option the connect attempt will fail with error CR_PLUGIN_NOT_ALLOWED.
2021-09-14 06:24:56 +02:00
Georg Richter
73478fd7f4 Method clean up:
- removed unused methods from MYSQL_STMT handle,
  (left over from PHP's mysqlnd)
- Added execute_generate_request method: This will allow
  Connector/Python to prefill the execute buffer without
  numerous GIL acquire/release calls.
2021-07-25 13:06:01 +02:00
Georg Richter
a37b7c3965 CONC-509: mysql_get_client* api functions should return C/C version.
Instead of server version the api functions mysql_get_client_info and
mysql_get_client_version should return MARIADB_PACKAGE_VERSION/ID.
2021-05-31 12:44:51 +02:00
Georg Richter
e4e5b28452 CONC-533: Support for asynchronous statements (binary protocol)
Added a new option MARIADB_OPT_SKIP_READ_RESPONSE which skips automatic
reading of server response after sending a command to the server.

Server packets have to be retrieved by calling the corresponding methods,
e.g:

Send command                         Read method
mysql_real_query/mysql_send_query    db_read_query_result
mysql_stmt_prepare                   db_read_prepare_response
mysql_stmt_execute,
mariadb_stmt_execute_direct          db_read_execute_response
2021-05-13 21:21:43 +02:00
Georg Richter
37bb780bde Merge branch '3.1' into 3.2 2021-04-13 21:42:39 +02:00
Georg Richter
d19c7c6926 Fix for CONC-543 (hash functions conflict with GnuTLS)
To allow static linking with GnuTLS hash lookup functions are now
prefixed with ma_hashtbl_. The files hash.c and hash.h were renamed
to ma_hashtbl.c and ma_hashtbl.h
2021-04-13 21:34:29 +02:00
Georg Richter
ca1ea5c1a2 Fix for CONC-525: Support LOAD * LOCAL INFILE statements in binary protocol
With implementation of MDEV-16708 (support all commands in binary protocol) we
need to check for local infile in text and binary protocol. Therefore the local
infile relevant part from ma_simple_command was moved to mthd_my_send_cmd method.
2021-02-23 07:55:35 +01:00
Marko Mäkelä
375bab0d51 Merge 3.1 into 3.2 2021-02-16 18:44:15 +02:00
Georg Richter
2ff01c121c Fix for CONC-518:
Check if mysql->options.extension was allocated before checking
async_context: this is handled by IS_MYSQL_ASYNC() macro now.
2020-11-27 18:33:06 +01:00
Georg Richter
820faff627 codespell fixes, removed MSDOS preprocessor macros 2020-11-26 09:07:17 +01:00