[CONPY-221] mariadb.DataError (1265) is not raised Created: 2022-08-25  Updated: 2022-08-27  Resolved: 2022-08-25

Status: Closed
Project: MariaDB Connector/Python
Component/s: DBAPI 2.0
Affects Version/s: 1.0.11
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Brad Chin (Inactive) Assignee: Georg Richter
Resolution: Won't Fix Votes: 0
Labels: None
Environment:

CentOS 7 w/ python 3.9.5 w/ Connector/C 3.2.3 w/ Connector/python 1.0.11


Python Version: python 3.9.5

 Description   

Here is the repro:

delimiter //

drop function if exists func5073//
CREATE FUNCTION func5073(arg ENUM('a', 'b')) RETURNS ENUM('c', 'd') DETERMINISTIC
BEGIN
RETURN arg;
END//

delimiter ;
SELECT func5073(1);

This is what happens on the MariaDB client

MariaDB [test]> SELECT func5073(1);
ERROR 1265 (01000): Data truncated for column 'func5073(1)' at row 1
MariaDB [test]> SELECT version();
+----------------+
| version()      |
+----------------+
| 10.6.9-MariaDB |
+----------------+

We get an error about our silly stored function.

Here is what the python connector does:

import mariadb
import mariadb.constants.CLIENT as CLIENT
 
dut_cfg = {"host": "vqc004a", "port": 60190,
            "user": "root", "passwd": "",
            "db": "test", "autocommit": True,
            "connect_timeout": 60,
            "client_flag": CLIENT.MULTI_STATEMENTS}
 
conn = mariadb.connect(**dut_cfg)
dut_cur = conn.cursor()
 
sql0="SELECT func5073(1)"
 
for cursor in (dut_cur, ):
    cursor.execute(sql0)
    print(cursor.fetchall())

Let's run this.

[root@vqc004a 5073]# python foo.py
[]
[root@vqc004a 5073]#

There isn't any exception that is raised. I expected a mariadb.DataError exception to be raised.



 Comments   
Comment by Georg Richter [ 2022-08-25 ]

MariaDB Connector/Python 1.0.x is discontinued - please upgrade to 1.1

$ python3.9 -c "import mariadb;print(mariadb.__version__)"
1.1.4
$ python3.9 conpy-221.py 
Traceback (most recent call last):
  File "/home/georg/work/test/conpy-221.py", line 9, in <module>
    cursor.execute(sql0)
  File "/usr/local/lib/python3.9/site-packages/mariadb-1.1.4-py3.9-linux-x86_64.egg/mariadb/cursors.py", line 314, in execute
    self._initresult()
mariadb.DataError: Data truncated for column 'func5073(1)' at row 0

Generated at Thu Feb 08 03:31:09 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.