1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-07 02:42:49 +03:00

286 Commits

Author SHA1 Message Date
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
Vladislav Vaintroub
6a763b9000 MDEV-19237 - do not resend prepared statement metadata unnecessarily
fix warnings
2020-10-20 14:58:37 +02:00
Georg Richter
b2966c05e4 Revert "MDEV-19237 - do not resend prepared statement metadata unnecessarily":
This reverts commit ed4d747510.
2020-10-20 14:57:22 +02:00
Vladislav Vaintroub
ed4d747510 MDEV-19237 - do not resend prepared statement metadata unnecessarily
fix warnings
2020-10-15 22:25:09 +02:00
Vladislav Vaintroub
c0837c3b8d MDEV-21612 Remove COM_MULTI.
The server command code 254 is now reserved,
as well as corresponding protocol flag.

Do not reuse them.
2020-09-22 17:26:04 +02:00
xantares
9d7c233e8d Fix include on case-sensitive fs
shlwapi is lowercase on case-sensitive file-systems
2020-09-12 14:29:56 +02:00
Georg Richter
29a3396456 CONC-302: Added support for SESSION_TRACK_GTIDS (MySQL server) 2020-09-12 10:58:33 +02:00
Georg Richter
3e699a1738 CONC-496: Added support for SESSION_TRACK_TRANSACTION_STATE in ok packet 2020-09-10 14:03:00 +02:00
Dianne Skoll
73dfd1ee48 Clear out free'd pointers for safety. 2020-08-13 14:16:29 -04:00
Sergei Golubchik
2759b87d72 sanity checks for client-supplied OK packet content
reported by Matthias Kaiser, Apple Information Security
2020-05-07 15:06:32 +02:00
Sergei Golubchik
ca8f94f727 BUG#29597896 - NULL POINTER DEREFERENCE IN LIBMYSQL
CONC version of server commit e8e67bd4a4c
2020-05-04 09:14:45 +02:00
Marko Mäkelä
7a2c052ffc MemorySanitizer: Avoid calling uninstrumented getservbyname() 2020-03-28 20:12:43 +02:00
Georg Richter
8c773db1fb Fix for CONC-441:
Instead of getlogin() we first try to determine the current user of the process
by calling getpwuid(). If for some reaon getpwuid() will fail, we will use getlogin() instead.
2020-03-12 18:09:40 +01:00
Georg Richter
f9a50468cd Merge pull request #129 from ottok/3.1-fix-spelling
Fix typo in output string: inital -> initial
2020-03-11 08:25:59 +01:00
Alexander Barkov
6632cb69d7 MDEV-17832 Protocol: extensions for Pluggable types and JSON, GEOMETRY 2020-03-10 17:02:59 +04:00
Georg Richter
d4f75481f6 Fix for CONC-458:
Fixed crash in mysql_get_timeout and mysql_get_timeout_ms functions,
which happened when no asynchronous context was set before.
2020-03-05 09:50:12 +01:00
Otto Kekäläinen
c0d5d7d15b Fix typo in output string: inital -> initial 2020-03-04 20:05:56 +02:00
Georg Richter
6a0c8ff2e5 Fix for CONC-457:
mysql_list_processlists was marked as deprecated in MySQL 4.0 and not
updated anymore. It exists still in latest MySQL and MariaDB connectors.
It now supports the 4.1 protocol, using 7 instead of 5 fields.

The following functions are now marked deprecated in source:
* mysql_list_dbs
* mysql_list_tables
* mysql_list_processes
2020-02-28 12:56:37 +01:00
Georg Richter
1218ffac1a Fix for CONC-452 and CONC-453:
Various coverity scan fixes, including CONC-452 and CONC-453.
Special thanks to Lukas Javorsky for fixing numerous covscan
issues (This patch includes part of his pull request #126).

Coverity scan build was using the following cmake parameters:
-WITH_EXTERNAL_ZLIB=ON -DWITH_UNIT_TESTS=OFF.

CWE-416 (use after free) in dtoa.c (from netlib) is still open.
2020-02-14 09:52:21 +01:00
Georg Richter
17ba6affa9 Fix for mysql_set_character_set:
Give a more detailled error information, in case SET NAMES failed.
2020-02-06 10:08:32 +01:00