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.
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.
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>
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.
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.
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)
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
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.
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.
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".
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
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.
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}
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.