Commit Graph

185 Commits

Author SHA1 Message Date
f0bbd0882a CONPY-302: fix segfault with threaded
Callback functions for session or fetch callbacks didn't work properly
when passing connection->thread_state in threaded environment.
Instead we acquire and release the GIL explicitly in these callback
functions.
2025-02-13 11:47:02 +01:00
befe7000c9 Follow up for CONPY-299
- Added byteswap function for vector (bigendian)
- Use buffer protocol instead of calling array's
  methods
2025-02-10 13:59:43 +01:00
9508904911 Exceptions: ER_BAD_FIELD_ERROR - wrong exception
ER_BAD_FIELD_ERROR (1054) was not handled and therefore
returned as OperationalError instead of ProgrammingError.
2025-01-30 13:55:34 +01:00
7cfc325feb CONPY-295: Fix unsigned check
Fixed check for signed/unsigned integers when sending parameters
via executemany().
2025-01-30 09:20:57 +01:00
138a02238e CONPY-299: support for VECTOR data type
Implemented support for VECTOR paramter. Beside text representation
(Vec_FromText) or array to byte conversion (array.tobytes) it is now
possible to specify an float array as parameter.

Example:

import mariadb, array

...

sql = """
  CREATE OR REPLACE TABLE test(
     id INT PRIMARY KEY,
     v VECTOR(3) NOT NULL,
      VECTOR INDEX (v))")"""

cursor.execute(sql)

vector= array.array('f', [123.1, 230.9, 981.7])

cursor.execute("INSERT INTO test VALUES (?,?)", (1, vector))

Please note that the opposite way, retrieving a float array is not
supported yet. This will require either a new or extended field
type for vector data type.
2025-01-30 09:02:07 +01:00
abd17eb95d CONPY-300: Fix documentation
kwargs parameter were missing in ConnectionPool documentation.
2025-01-29 09:43:20 +01:00
e86261c121 CONPY-303: Documentation fix for cursor constructor
Fixed documentation for cursor constructor.
Thanks to Witold Czarnecki for the bug report.
2025-01-28 16:16:29 +01:00
60562de225 Buildfix for C/C > 3.4.1
Fixed wrong preprocessor directive.
2024-09-28 04:57:31 +02:00
aa962d01fb Build fix for C/C versions < 3.4.2 2024-09-27 17:55:50 +02:00
5ae028e153 CONPY-289: BIGINT out of range on bulk insert
If a bigint value is > LONGLONG_MAX it must be
indicated that it is an unsigned value
(param->is_unsigned= 1).
2024-09-27 17:14:25 +02:00
fee7f30f42 Added new connection property: tls_peer_cert_info
connection.tls_peer_cert_info returns information about
the peer certificate or None if the connection doesn't
use TLS/SSL.
2024-09-27 16:21:35 +02:00
3d34bb6880 CONPY-293: Fix gcc warnings 2024-09-25 13:35:16 +02:00
1d03be3483 TLS fixes for C/C 3.4.x
- Always set/unset peer certificate verification flag
- Return None (instead of raising an exception) for tls connection
  properties if TLS is not in use
- bumped version number to 1.1.11
2024-09-16 10:13:38 +02:00
afb3ccd778 Check return code of db_generate_bulk_request
When inserting data via parameter callback function, an error
will be raised.
2024-09-14 15:31:57 +02:00
d672551c7d Fix for CONPY-277:
To avoid a syntax error when running under sql_mode ANSI_QUOTES
parameter substitution will be done by using single quotes instead
of double quotes.
2024-02-05 07:02:39 +01:00
7c2134dddb Fix for CONPY-278:
In case of an (automatic) reconnect the connection property
connection_id was not updated, since there is no callback
functionality in Connector/C available to notify the application
that a reconnect occured. Instead of obtaining the connection_id
via MemberDef, connection_id is now implemented as getter function.
2024-01-31 17:21:48 +01:00
28827984bd CONPY-280:
Methods which are defined via PyMemberDef with flag METH_VARARGS
and have only one parameter are using METH_O now: Instead of parsing
and converting parameter via PyArgs_ParseTuple we now check the type
and convert passed python object directly to the corresponding c type.
2024-01-31 15:15:49 +01:00
f00bc261d4 Fix for CONPY-279:
Allow None values for password and database in change_user()
method of connection object.
2024-01-30 15:55:34 +01:00
9952ff09af CONPY-276:
Allow to retrieve data from buffered cursor if the connection
was already closed.
2023-12-20 17:29:28 +01:00
ae34d63986 Fix for CONPY-274:
Instead of releasing non freed objects (cursor and connection)
in tp_dealloc, they need to be freed in tp_finalize to avoid
possible crashes.
2023-12-01 16:01:22 +01:00
f9adb73366 Fix for CONPY-273:
Fixed crash in escape_string method of connection object:
Instead of PyMem_RawCalloc we allocate memory via PyMem_Calloc, since
the memory will be freed by PyMem_Free (instead of PyMem_RawFree).
2023-11-22 13:08:50 +01:00
6a5388ad05 CONPY-272: documentation fix
Fixed documentation: Cursors lastrowid attribute returns None (was
zero).
2023-10-18 08:49:07 +02:00
cfe1d10702 CONPY-271: Added cursor.metadata property
Similiar to description property, this property returns
a dictionary with complete metadata.

The dictionary contains the following keys:
  - catalog:     catalog (always 'def')
  - schema:      current schema
  - field:       alias column name or if no alias was specified
                 column name
  - org_field:   original column name
  - table:       alias table name or if no alias was specified
                 table name
  - org_table:   original table name
  - type:        column type
  - charset:     character set (utf8mb4 or binary)
  - length:      The length of the column
  - max length:  The maximum length of the column
  - decimals:    The numer of decimals
  - flags:       Flags (flags are defined in constants.FIELD_FLAG)
  - ext_type:    Extended data type (types are defined in
                 constants.EXT_FIELD_TYPE)

This fixes also CONPY-270: Instead of checking BINARY_FLAG we now
check character set for binary object types.
2023-10-11 14:50:23 +02:00
91ecc9e3bf Workaround for CONPY-269:
Even if PEP-249 permits operations on a closed cursor, we don't
raise an exception if the cursor or the underlying connection
was closed. Instead rowcount property will return -1.

This is a workaround for pandas, where rowcount will be checked
after the cursor was closed.
2023-09-29 10:34:30 +02:00
67d3062ad5 Added missing documentation for tls_version 2023-07-02 17:12:14 +02:00
d8b337d4ee correct documentation typo CURSOR_TYPE -> CURSOR
There is no CURSOR_TYPE, only CURSOR.
2023-06-30 12:30:36 +10:00
9aedf1c0f8 Handle dicts in check_text_params 2023-04-17 10:26:33 +02:00
b0366fa108 Performance fix:
Rewrote parameter type checks for text protocol in cpython.
2023-04-17 09:51:41 +02:00
658cc0015c Fix for CONPY-256:
Fix indexing when moving a free connection to used connections
to avoid returning the same connection twice.

Kudos and thanks to G.Mech for reporting this bug and providing
the fix.
2023-04-11 09:05:07 +02:00
494d9513da Fix for CONPY-255:
If a connection pool can't return a connection (all connections in use)
a PoolError will be raised instead of returning None object.
2023-04-11 08:37:16 +02:00
6afeaa53d1 CONPY-258: Fixed ValueError exception if ZEROFILL flag is defined
For backwards compatibility PyLong_FromString interprets leading
zeros as octal value which will end up in a value error, if the
number contains 2 or more leading zeros.
2023-04-06 17:22:26 +02:00
3827ae32bd CONPY-253: Add new connection option tls_version
The connection method now offers the option of specifying
the version of the TLS protocol using tls_version:

connection = mariadb.connect(tls_protocol="TLSv1.2")
2023-03-25 15:22:31 +01:00
0c844879fd Fix for CONPY-251
Check if stmt was already initialized in cursor method
nextset().
2023-02-12 08:26:37 +01:00
49b49083a2 Follow up for CONPY-250:
handle None values
2023-02-08 16:14:52 +01:00
9f7fcbb356 Fix for CONPY-250:
With implementation of CONPY-246/247 pool._connections was replaced
by _connections_used and _connections_free to the size should be
calclulated as len(_connections_used + _connections_free)
2023-02-08 16:04:20 +01:00
fad6119fd0 CONPY-248:
If a connection in connection pool was identified as broken (either
COM_PING or reset_connection failed) it will be replaced by a new
connection.
2023-02-05 14:22:46 +01:00
66db4b08c0 CONPY-247:
Added optional parameter "pool_invalidation_interval",
which specifies the validation interval  in milliseconds
after which the status of a connection requested from
the pool is checked.

The default values is 500 milliseconds, a value of 0
means that the status will always be checked.
2023-02-03 11:53:34 +01:00
a48eb1eff6 Fix for CONPY-246:
Rollback transaction if connection pool was created with
pool_reset_connection=False.
2023-02-03 08:07:41 +01:00
7daab2feb5 Fix for CONPY-245:
Instead of iterating through all connections and checking the health
status via ping, used and unused connections were separated in different
lists. This ensures that the last used connection will be always the first.
2023-02-01 09:33:54 +01:00
84967a90ca Follow up for fix of CONPY-244:
Raise a warning instead an exception.
2023-02-01 07:48:42 +01:00
5ce5ca3d15 CONPY-244:
Check that the version of loaded MariaDB Connector/C library is
not less than the version used to build MariaDB Connector/Python.
2023-01-16 14:32:57 +01:00
03b72c6644 Fix for CONPY-240:
Don't overwrite errormessage/stacktrace if an exception was generated
during module initialization.
2022-12-01 06:00:17 +01:00
952a8cfb35 Fix for CONPY-240
If an error occured during module initialization, the exception
now contains more information about possible cause and doesn't
overwrite existing error message.
2022-11-28 06:10:07 +01:00
ea87f4472b Fix required Connector/C version:
Since Connector 3.2.x is discontinued, we need
to bump the miimum required version to 3.3.1.
2022-11-21 11:59:01 +01:00
1919bee85e Build fix for C/C 3.3.1 2022-11-09 09:04:51 +01:00
db9b3b792b CONPY-231: Fix memory leak 2022-11-01 07:22:11 +01:00
80b642b8a1 Fix for CONPY-229:
Pass NULL/None values to converter.
2022-10-19 17:13:27 +02:00
ce228b68da CONPY-227: Replace collections.named_tuple
Replaced collections.named_tuple by C-Pythons PyStruct_Sequence.
All conversion are done now before fetching a row: converting to
other result types than tuple (named tuple or dict) now have less
overhead and are significantly faster.
2022-10-10 09:01:19 +02:00
903bd6e073 Performance optimization
Instead of iterating via fetchone(), fetchall() and fetchmany() methods
now load the data directly at once.
2022-10-10 06:59:16 +02:00
1d700addae Fix for CONPY-226:
Replaced deprecated call to distutils.version.StrictVersion by
packaging.version.Version
2022-10-09 15:05:31 +02:00