Commit Graph

40 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
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
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
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
b0366fa108 Performance fix:
Rewrote parameter type checks for text protocol in cpython.
2023-04-17 09:51:41 +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
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
5420fe39d9 Various fixes:
- removed utf8 part of parser, instead we use python binary
  object for parameter substituton (text mode)
- removed memory leaks
- fixed crash when reusing cursor with different number of
  placeholders
2022-06-08 13:43:20 +02:00
30c8f33b08 CONPY-205: Inconsistent exceptions
- All parameter exceptions are now ProgrammingErrors
- A dictionary now might contain more keys than
  placeholders in statement
- Fixed unhandled exception when using dictionary as parameter
2022-05-25 18:47:03 +02:00
a839827f59 CONPY-189: Windows build fix for Visual Studio 2022
- Build parameters are now written to config_win.h instead of passing
  them as command line parameters
- Fixed several compiler warnings
2021-12-21 08:21:04 +01:00
2e7dcde73b Removed converter from C Code 2021-08-16 10:41:07 +02:00
fc32956109 Check server capabilities at the beginning of function 2021-08-16 09:29:55 +02:00
5a81686f4c Documentation work 2021-07-26 06:54:38 +02:00
5870f5d4d7 cursor:
added keyword quote_sequences (default=true)

connection:

moved tpc functions to native python
moved autocommit to native python
2021-07-22 14:15:53 +02:00
8ee02ac7e3 Cursor fixes for execute, implemented execute_direct 2021-07-14 22:14:52 +02:00
84df56ce40 connection and cursor class are now written in
native python
2021-07-12 09:46:05 +02:00
7df428ecf8 Moved Objects from c to python code
Indicator, BINARY, NUMBER, STRING and DATE objects were moved
to python code
2020-11-30 16:49:16 +01:00
e8d7854fef codespell typo fixes 2020-11-25 13:44:18 +01:00
26ca93492f Test fixes for testing against MySQL server 2020-11-18 16:42:35 +01:00
3b2edf5b35 Fix for CONPY-115:
Replaced the obsolete ULONG_LONG_MAX definition by
ULLONG_MAX.
2020-10-19 08:11:32 +02:00
d30042b01a Fixed build error
According to the documentation (but also setup.py) the minimum
required version of MariaDB Connector/C is 3.1.5. Since extended
field_types were added in 3.1,8, we need to check the version
of MariaDB Connector/C.
2020-10-13 08:44:33 +02:00
cbd51decc6 When converting parameters also check subtype of a Python Object 2020-10-02 12:54:21 +02:00
08673bbdf4 Small "workaround" for MDEV-23481:
Don't set the unsigned flag if the value will fit into signed integer.
2020-09-29 14:14:02 +02:00
8ff03334c2 Fixed conversion of Integer parameters:
If bits of PyLong are > 32 we will always use MYSQL_TYPE_LONGLONG.
2020-09-29 13:46:13 +02:00
3f95456824 CONPY-117: Added converter support
The connect() method now accepts an addtional parameter
converter which points to a dictionary, containing one or more conversions.
A conversion must be specified in the form {FIELD_TYOE : conversion_function}
2020-09-29 13:21:13 +02:00
5d4a8d5d62 Fix for CONPY-116: Wrong type reported for SQL type JSON
Beginning of MariaDB 10.5 metadata for JSON columns is stored
in extended field information, and the reported type is MYSQL_TYPE_BLOB.
We now check extended field information to return correct type and for
fetching values in correct format.
2020-09-29 11:43:47 +02:00
6fcb9a5642 more compiler warning fixes 2020-09-19 15:32:50 +02:00
bd560c2bb9 Fix for CONPY-108 (memory leak):
- initialize datetime API only once per object file
- don't reparse same statement
2020-08-29 12:20:52 +02:00
92eaf17fd5 Follow up fix for CONPY-107:
Support also insert/update/delete with PyDateTime_Delta objects
2020-08-16 07:30:58 +02:00
e078e26a18 Fix for CONPY-107:
Since Python is not able to handle negative values, a column defined as TIME will
now be converted to datetime.timedelta instead of datetime.time.
2020-08-15 19:00:40 +02:00
021c4e6aaa Allow different decimal types in executemany():
It is now possible to use different decimal types for the same column
in cursors executemany() method.
2020-08-14 19:55:41 +02:00
067a78dd13 Fix for CONPY68 (jsonfield returning as bytes):
When a value is returned as binary type (BLOB) but has a non binary collation,
it will be converted now as a unicode string and the binary flag will be ignored.
2020-08-10 14:59:16 +02:00
a749c53859 Fix for CONPY-98:
If a string has a binary collation/charset it needs to be converted
to a Binary instead of Unicode.
2020-08-07 14:45:50 +02:00
c59313604e Fix for CONPY-95
Added support for MYSQL_TYPE_BIT: Bit field type will be converted
to PyByte object.
2020-08-06 18:26:44 +02:00
bfd71e2fa1 Fix for CONPY-94:
Don't check for exact type but also for subtype.
2020-08-06 15:03:48 +02:00
01053e0d4a Fix for CONPY-93:
When releasing the GIL we need to unblock/block in callback functions (mariadb_codecs.c)
2020-08-05 18:54:19 +02:00
29b05e3b09 Various fixes and changes for SQLAlchemy support:
- added a thin python wrapper around mariadb module
- added constansts under mariadb.constants (CLIENT, CURSOR, INDICATOR)
- bench and test are now in testing subdirectory
- updated documentation
2020-07-24 12:13:31 +02:00