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

126 Commits

Author SHA1 Message Date
Oleksandr Byelkin
b5a2c9f3c2 Merge branch '3.3' into 3.4 2025-04-20 10:49:16 +02:00
Oleksandr Byelkin
55abb32038 Merge branch '3.1' into 3.3-merge 2025-04-20 10:16:30 +02:00
Georg Richter
28a1e4b599 Fix for CONC-762: Always set is_null and length in bind structure to avoid
msan errors
2025-03-31 11:02:35 +02:00
Georg Richter
3794a86544 CONC-691: Obtain sql statement from statement handle
Added an option STMT_ATTR_SQL_STATEMENT in API function
mariadb_stmt_attr_get which returns a MARIADB_CONST_STRING
structure which contains SQL statement from last
mysql_stmt_prepare() call.
2024-12-12 12:07:34 +01:00
Georg Richter
6a55b15520 Merge pull request #262 from markus456/3.4
CONC-741: Check that MYSQL_STMT is not null
2024-11-28 07:18:57 +01:00
Georg Richter
3590fe6e8b Merge branch '3.3' into 3.4 2024-11-27 16:17:12 +01:00
Georg Richter
662a966056 CONC-702: Fix statement status
If a resultset in binary protpcpl doesn't contain data
(fields equal zero) and there are no more pending
result sets we need to change the statement status to
FETCH_DONE, otherwise it will be impossible to execute
other commands until the statement was closed.
2024-11-18 07:15:42 +01:00
Markus Mäkelä
8dce8dba85 CONC-741: Check that MYSQL_STMT is not null
The code now again allows null MYSQL_STMT handles to be passed to
mysql_stmt_close(). Added a sanity check test case that should guard
against this happening in the future.
2024-11-07 07:34:12 +02:00
Georg Richter
ba137a4f5c Exclude server side cursors when checking for pending results 2024-05-06 14:32:31 +02:00
Georg Richter
20fbb3c3b9 Avoid possible crash if connection was closed
Before checking pending result sets in prepared statements,
we need to check if the connection was already closed or
resetted by checking stmt->mysql. In case of NULL we return
false, since there are no more pending result sets.
2024-04-29 10:57:12 +02:00
Georg Richter
f4e8c085fc Fix compiler warnings 2024-04-24 11:05:26 +02:00
Georg Richter
fef3e4ed6d CONC-683: Check pending results when closing statement.
Similiar to fix for CONC-667 we need to check if other
statements have a pending result set before we can close
a statement handle.
2024-03-23 12:53:24 +01:00
Georg Richter
b64282a9dd CONC-667: Fix statement handling when unbuffered results are pending.
Resetting a statement will result in an error, if another (different)
statement has a pending unbuffered result set (CR_COMMANDS_OUT_OF_SYNC).

Freeing a statement result set will return an error, if the statement
has no result set or was not executed (CR_STMT_NO_RESULT).
2024-03-23 12:27:55 +01:00
rusher
abce07da2a [MDEV-30366] Bulk unitary result flag client implementation part.
With MDEV-30366, server now permit to send a result-set containing generated id and Affected rows for each bulk operation. This feature can be enabled with option MARIADB_OPT_BULK_UNIT_RESULTS when server supports it.
2024-03-06 16:03:55 +01:00
Vladislav Vaintroub
463a50e973 Merge remote-tracking branch 'origin/3.1' into 3.3
# Conflicts:
#	include/ma_crypt.h
#	libmariadb/mariadb_lib.c
2023-09-21 23:45:35 +02:00
Georg Richter
9f37c27bc8 Fix for CONC-668:
Fix build error on 32-bit systems.
2023-09-18 16:05:00 +02:00
Marko Mäkelä
5af90f00ff Merge 3.1 into 3.3 2023-06-26 16:28:51 +03:00
Marko Mäkelä
d543bed61b Fix GCC 13 -Wmaybe-uninitialized 2023-06-26 10:59:14 +03:00
Georg Richter
dd8962a4b5 Merge branch '3.1' into 3.3 2023-04-25 15:08:28 +02:00
Georg Richter
2000b06183 Replace SET_CLIENT_STMT_ERROR by stmt_set_error(). 2023-04-11 18:31:19 +02:00
Georg Richter
e4417e725e Merge branch '3.1' into 3.3 2023-02-09 08:57:48 +01:00
Georg Richter
669726a1d9 Fix for CONC-633:
If prepare step failed in mariadb_stmt_execute_direct now both
mysql_stmt_error and mysql_error return the error message from
prepare step instead of error message of execute.
2023-02-08 12:21:22 +01:00
Georg Richter
12bd1d5511 Merge branch '3.1' into 3.3 2023-01-16 12:12:46 +01:00
Georg Richter
895235815c Fix for CONC-627:
Don't substitute parameters in server error messages in
prepeated statement error handler function.
2023-01-16 11:13:00 +01:00
Georg Richter
bb5abd096d Merge branch '3.1' into 3.3 2023-01-16 08:16:13 +01:00
Georg Richter
173112ceaf Fix for CONC-626:
Fixed possible memory leak in mariadb_stmt_execute if realloc of
data buffer failed.
2023-01-16 08:11:02 +01:00
Georg Richter
5f6133653d Fix for CONC-623:
If callback function returns a non zero return code, execute
will now abort with error CR_ERR_STMT_PARAM_CALLBACK.
2023-01-15 15:12:38 +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
c15a973016 Fixed crash
Fixed crash which was introduced by 1bd8c8bf39
2022-08-25 16:20:48 +02:00
Georg Richter
1bd8c8bf39 Added missing status callbacks outside of ma_read_ok_packet 2022-08-11 16:56:06 +02:00
Georg Richter
6dbd953420 Merge branch '3.1' into 3.3 2022-07-24 10:52:52 +02:00
Georg Richter
cdb6e90c35 Fix for CONC-608: Replace server error codes
Since Connector/C is not able to retrieve
error strings for server error codes, the following
error codes were replaced:

- ER_NET_PACKET_TOO_LARFE by CR_NET_PACKET_TOO_LARGE
- ER_OUT_OF_RESOURCES by CR_OUT_OF_MEMORY
- ER_NET_WRITE_ERROR by CR_ERR_NET_WRITE (new constant)
- ER_NET_UNCOMPRESS_ERROR by CR_ERR_NET_UNCOMPRESS (new constant)
2022-07-21 09:11:29 +02:00
Georg Richter
3f7719c74d Typo fixes (from PR #200) 2022-06-27 13:23:35 +02:00
Georg Richter
3fe2f50545 Merge branch '3.1' into 3.2 2022-01-25 03:51:45 +01:00
Georg Richter
dce4b8a89d Fix/replacement for PR 107:
Instead of calculating size with packlen for date/time types,
we need to use the max. value of the corresponding type.
2022-01-24 07:34:30 +01:00
Georg Richter
2933a1ca75 Merge branch '3.1' into 3.2 2021-10-05 15:19:59 +02:00
Georg Richter
9c02505474 Fixed for MDEV-26761:
If mariadb_stmt_execute_direct fails, we need to set the number
of parameters (obtained by response packet of mysql_stmt_prepare)
back to the number of prebinded parameters to avoid memory
overrun.

This fix also includes several adress-sanitizer bugs in unit tests
of Connector/C.
2021-10-05 14:50:32 +02:00
Georg Richter
62c93c9029 Merge branch '3.1' into 3.2 2021-09-27 13:30:31 +02:00
Georg Richter
410d64d8de Fix length calculation
When calculating the length of buffer for prepared statement
executiong a maximum length of 5 for length encoded types was
used. This should be 9, since length encoded types starting
with 0xFE are followed by length of 8 bytes.
2021-09-27 13:27:40 +02:00
Georg Richter
18f7cf423f Merge branch '3.1' into 3.2 2021-09-25 16:28:04 +02:00
Georg Richter
4b9379b2aa Fix for CONC-566:
If cursor type is set to read only, and SERVER_STATUS_CURSOR_EXISTS
flag was not set in the server_status of EOF packet, the assumption
was made that a single result set will follow which will be stored
by a call to mysql_stmt_store_result().

As the example in the bug report shows, this is not always the case,
since a stored procedure call might also unset the CURSOR flag and
will always return multiple result sets. In this case it will be
handled now as "normal" unbuffered result set.
2021-09-25 16:07:24 +02:00
Georg Richter
ffa3451fa5 Merge branch '3.1' into 3.2 2021-09-21 14:49:06 +02:00
Georg Richter
b99172386a Followup of fix for CONC-565
(patch provided by Monty)
2021-09-21 14:39:17 +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
f999686968 Set param_count to the specified prebind value.
When reusing a statement handle in C/Python,
the number of prebinded parameters also has
to be assigned to stmt->param_count.
2021-07-12 10:14:30 +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
Marko Mäkelä
375bab0d51 Merge 3.1 into 3.2 2021-02-16 18:44:15 +02:00
Georg Richter
ef3d315796 Test case fix:
unittests always reset the default connection (and depending statements)
which might end up in an error when trying to close a statement which was
not prepared before.
In this case mysql_stmt_reset only needs to set statement status to
MYSQL_STMT_PREPARE if the statement id was set before.
2021-01-18 18:23: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