Commit Graph

54 Commits

Author SHA1 Message Date
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
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
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
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
0c844879fd Fix for CONPY-251
Check if stmt was already initialized in cursor method
nextset().
2023-02-12 08:26:37 +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
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
d70be504e3 Fix for CONPY-225:
Set value for affected_rows.
2022-10-07 08:47:48 +02:00
37ea27cf86 Fix for CONPY-224:
If a bulk operation is executed and the statement doesn't need to
be reprepared, only array size has to be updated, since setting
the number of parameters (STMT_ATTR_PREBIND_PARAMS) will reset the
statement in Connector/C.
2022-09-22 07:26:46 +02:00
71614ab159 Merge branch '1.1-status' into 1.1 2022-08-09 16:09:22 +02:00
a9ad1fcaee First implementation for status callback 2022-08-05 14:41:43 +02:00
275aaf3ee1 Fix for CONPY-214:
Replace cursor iterator by native python __iter__() method.
2022-07-06 22:57:58 +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
55ce15a1aa Minor documentation fixes 2022-04-03 07:03:32 +02:00
70ed9b47de Added missing docstring for cursor.paramcount 2022-04-02 20:02:52 +02:00
1d74599d47 Fix for CONPY-194:
Since executemany() returns a result set if the insert, update,
delete or replace statement contains returning directive, we
need to check if execute returned number of fiels and allocate
a result set.
2022-02-20 04:42:28 +01:00
4bcfd6a58e CONPY-88
Extended cursor->description:

The descriptor now contains 11 elements:
descriptor[8]: table name
descriptor[9]: original column name
descriptor[10]: original table name
2022-01-25 05:35:45 +01: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
263f428213 CONPY-184
Display status of connection, cursor and pool class in
string representation.

If an object (cursor, class, connection pool) was closed, the
string representation (tp_repr) now shows the status of the object.

Example:

>>> import mariadb
>>> connection=mariadb.connect()
>>> connection
<mariadb.connection connected to 'localhost' at 0x7f94d77c3b40>
>>> connection.close()
>>> connection
<mariadb.connection (closed) at 0x7f94d77c3b40>
2021-12-13 05:55:10 +01:00
5831a69721 Fix for CONC-178:
When a cursor was not properly cleared (all results weren't
fetched) the clear_result routine has to free result sets only
if field_count > 0.
2021-11-25 06:06:48 +01:00
daab5ee987 CONPY-164:
Reset array_size before executing statement.
2021-09-07 08:45:41 +02:00
2e7dcde73b Removed converter from C Code 2021-08-16 10:41:07 +02:00
1d201f10e3 Removed refrence decrement in tuple construct. 2021-08-05 08:52:32 +02:00
8cd33d55c1 Fixed memory leak in parser 2021-08-03 11:31:31 +02:00
47ca11d921 Documentation update 2021-08-01 10:31:10 +02:00
5a81686f4c Documentation work 2021-07-26 06:54:38 +02:00
2bd40ca1de Test fixes 2021-07-18 18:16:38 +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
27730cd018 Moved more methods and propertys from C to Python code 2021-03-21 22:44:42 +01:00
e8d7854fef codespell typo fixes 2020-11-25 13:44:18 +01:00
a1c709b0e8 Fix for CONPY-133:
Extended parser for supporting MariaDB comment syntax
(https://mariadb.com/kb/en/comment-syntax/)
2020-11-24 14:00:56 +01:00
312ba15173 Follow up of fix for CONC-130:
Workaround for #21066 (https://bugs.python.org/issue20066)
2020-11-16 14:58:59 +01:00
4a5d02a1b1 Fix for CONPY-130: DeprecationWarning: builtin type Row has no _module_ attribute
Changed sequence description from Row to mariadb.Row.

This patch also includes a followup fix for CONP-131:

PyStrustSequenceNew will be used only for Python versions > 3.6
2020-11-16 07:33:53 +01:00
f6be6ba512 Fix for CONPY-131:
Instead of using PyStructSequence_New (broken in Python3.6) use a
static struct which will be initialized voa PyStructSequence_Init()
call.
2020-11-16 07:07:50 +01:00
020017ee33 Fix for CONPY123: Free pending result sets when closing cursor
When using text protocol pending result sets weren't properly freed,
so executing another command on the same connection resulted in an error
"commands out of sync".
2020-10-12 09:05:49 +02:00
21c9afc13f Removed reference increment in cursor.description 2020-10-04 12:34:41 +02:00
8944cb889a Error handling fixes:
Instead of OperationalException and IntegrityException will be raised
for the following eror types:
ER_BAD_NULL_ERROR, ER_DATA_OUT_OF_RANGE, ER_CONSTRAINT_FAILED, ER_DUP_CONSTRAINT_NAME
2020-10-04 11:35:40 +02:00
846c0d0fdb Fix for CONPY-119: Fixed memory leak
When creating a cursor with result set type named_tuple
or dictionary, references were not decremented correctly.

For named tuples we don't use a static variable anymore, instead
of it will be created by PyStructSequence_NewType.
2020-10-03 16:41:29 +02:00
bce98d74cd Fix for CONPY-118: Leak when using text protocol
Removed statement allocation from the cursor init function and
allocate it only in executemany and execute if paraemters were
supplied.
2020-10-02 12:52:09 +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
23678b31ca removed redundant callproc method entry 2020-09-19 15:37:54 +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
3c264b2d2a Fix memory leak in fetchmany (same bug as CONPY-99) 2020-08-20 18:12:58 +02:00
837a36ea15 Fix rowcount calculation for emulated bulk operations 2020-08-16 15:10:26 +02:00
74933240ba Fix for CONPY-99:
Decrement reference to row after adding it to lit to prevent
memory leakage
2020-08-16 09:40:10 +02:00
afea681910 Fix for CONPY-105: Change behavior of cursor->rowcount and cursor->lastrowid
rowcount:
In case of an error, or if statement wasn't executed rowcount should be -1 (see PEP-249)

    For DML statements the number of affected rows returned in OK packet by server:
        > 0 for DML statements which modify or insert, e.g. ALTER TABLE or CREATE TABLE .. SELECT FROM
        otherwise 0
    For DQL statement
        if field_count > 0: number of rows returned
        otherwise affected rows returned in OK packet by server.

lastrowid:

    if server returns no value (0) for last_insert_id, lastrowid should be None.
    if last_insert_id is > 0, return it's value
2020-08-14 16:44:13 +02:00