74 Commits

Author SHA1 Message Date
eca2345fcd Merge pull request #20 from mhasadi78/patch-1
Fixed a typo
2022-05-21 08:35:09 +02:00
f57e2223bc Windows build fix 2022-04-12 04:19:44 +02:00
ebbfea0abe Fix for CONPY-198:
Use CLOCK_MONOTONIC instead of CLOCK_MONOTOIC_RAW constant. The latter
one exists for Linux only.
2022-04-05 18:50:29 +02:00
2bad21412f Fix for CONPY-196:
When closing a cursor object, the reference for the corresponding
connection object must be decremented to prevent leakage.
2022-03-24 05:22:57 +01:00
31048c64ab 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:38:01 +01:00
4855a7b21d Fix for CONPY-191:
When connected to a database server which doesn't support bulk
execution, we need to set bind.is_null instead of changing the buffer
type to MYSQL_TYPE_NULL. This will keep the original buffer type.
2022-02-08 22:30:30 +01:00
b540af04b3 Fixed a typo 2022-02-08 19:52:37 +03:30
7b63daa9c1 CONPY-188:
When a connection or cursor was closed, an exception will be returned
if a method or property of closed object will be called.
2022-01-18 21:07:10 +01:00
cfd2b87fe4 Merge branch 'master' of https://github.com/mariadb-corporation/mariadb-connector-python 2021-12-13 05:57:14 +01:00
e9032ede8e 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-12 08:19:35 +01:00
815374c26b Fixed warnings when building with VS2022 (Windows) 2021-11-25 18:28:17 +01:00
c90977316b Fix for CONPY-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:01:18 +01:00
5ed872fb00 Fix for CONPY-175:
Since memory for stack allocation is limited, we need to allocate
memory from the heap, otherwise in case of large strings escape_string
method might crash.
2021-10-28 10:53:00 +02:00
9bb4e374ac CONPY-155: segmentation fault on calling connection.get_server_version()
Check if connection is still active and increment reference counter for
server_version.
2021-06-06 11:56:57 +02:00
88dcf20ebc Merge pull request #15 from tuxmaster5000/file_perm
Remove x bit from source file.
2021-04-07 09:58:52 +02:00
e34b7adb89 Merge pull request #17 from niekbosch/patch-1
Importing (and thus exporting) class `connection`
2021-04-07 09:55:49 +02:00
8b5f9abb2e Fix for CONPY-150:
Since Python complains about invalid date types (year, month or day=0),
they need to converted to NULL instead of PyDate* object.
2021-04-06 11:21:38 +02:00
fdee5137d5 Fix for CONPY-144: Segfault in connection pool
Due to wrong reference count connection was closed by gc, after
obtaining the same connection from ConnectionPool operations ended
into a seg fault.
Additionally 2 smaller memleaks were fixed.
2021-03-10 07:46:07 +01:00
f5da77b959 bump version number (1.0.7) 2021-03-01 18:49:38 +01:00
f633103914 Fix for CONC-139:
When using binary protocol, convert data to binary object only if the
character set is BINARY (63), not if the flag was set.
2021-02-14 15:29:58 +01:00
5f03209a53 Fix for CONPY-142:
When closing connection object the reference of server_version_info
needs to be decremented to prevent memory leakage.
2021-02-09 20:28:44 +01:00
ae65e34d1e Importing (and thus exporting) class connection 2021-01-24 18:06:24 +01:00
16a35c3008 Remove x bit from source file. 2021-01-12 08:46:48 +01:00
e8d7854fef codespell typo fixes 2020-11-25 13:44:18 +01:00
5718305c3b Windows build fix 2020-11-24 15:54:15 +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
6a832099b1 Fixed base class for exceptions 2020-11-24 14:00:15 +01:00
0f0468a085 Fix for CONC-132: Fix leak in connection pool
When closing a connection pool the allocated buffer for pool_name
was not freed in a proper way.
2020-11-23 15:15:13 +01:00
fab2a6d810 Fixed bug in pooling:
Due to missing reference count incrementation the default configuration
was removed/overwritten.
2020-11-22 20:38:26 +01:00
26ca93492f Test fixes for testing against MySQL server 2020-11-18 16:42:35 +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
acf9f9190e Fix for CONPY-127: Let connector accept None values
Fix implementation of connection method: String values
now additionally except None values which will be
internally transformed to NULL.
2020-11-16 11:15:22 +01:00
a47d3e5d76 Implementation of CONPY-129:
Added connection attribute server_version_info and (for compatibiliry)
get_server_version() method.
Both return a tuple, describing the version number of connected server
in following format: (MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)
2020-11-16 10:03:05 +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
37864dd831 Fix for CONPY-126
Connection attributes in PyMember definition will be accessed as
string constants instead of Python Object, so the object will be
created only if the member will be accessed in python code and it's
reference count doesn't need to be decrement when the connection
class will be deallocated.
2020-11-01 09:14:11 +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
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
cbd51decc6 When converting parameters also check subtype of a Python Object 2020-10-02 12:54:21 +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
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
6ab09b21f1 Fixed parser bug 2020-09-22 07:01:07 +02:00
23678b31ca removed redundant callproc method entry 2020-09-19 15:37:54 +02:00