Bug #110422 | Connector/Python throws UnicodeDecodeError on cursor.execute() | ||
---|---|---|---|
Submitted: | 18 Mar 2023 12:05 | Modified: | 23 Jun 2023 20:13 |
Reporter: | Friedrich Volkmann | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / Python | Severity: | S2 (Serious) |
Version: | 8.0.32 | OS: | Debian |
Assigned to: | CPU Architecture: | Any |
[18 Mar 2023 12:05]
Friedrich Volkmann
[24 Mar 2023 12:29]
MySQL Verification Team
Hello Friedrich Volkmann, Thank you for the bug report. Could you please provide repeatable test case (please make it as private if you prefer) to confirm this issue at our end? Regards, Ashwini Patil
[7 Apr 2023 12:37]
Friedrich Volkmann
sql script for table creation: CREATE TABLE bugtest_table1 ( id int(11) NOT NULL, ort_id int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; CREATE TABLE bugtest_table2 ( id int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; CREATE TABLE bugtest_table3 ( besuch_id int(11) NOT NULL, taxon varchar(30) NOT NULL, epitheton varchar(30) DEFAULT NULL, rang int(1) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; python script (with login data obfuscated): #!/usr/bin/python3 import mysql.connector from mysql.connector import errorcode CONF_DB_NAME='...' CONF_DB_USER='...' CONF_DB_PASS='...' biodb = mysql.connector.connect(database=CONF_DB_NAME, user=CONF_DB_USER, password=CONF_DB_PASS) cursor = biodb.cursor() sqlstr = "select (select group_concat(distinct concat_ws(' ',taxon,ifnull(t3.epitheton, 'sp.')) order by t3.taxon, isnull(t3.epitheton), t3.epitheton separator ', ') from bugtest_table3 t3 where t3.besuch_id=bugtest_table1.id and t3.rang in (1,2) and not exists(select 0 from bugtest_table3 b3)),1,1 from bugtest_table1, bugtest_table2 where bugtest_table2.id=bugtest_table1.ort_id order by bugtest_table1.id" cursor.execute(sqlstr) cursor.close() biodb.close() output: Traceback (most recent call last): File "/home/www/volki.at/fund/mysql-bug/./bugtest.py", line 10, in <module> cursor.execute(sqlstr) File "/home/.local/lib/python3.9/site-packages/mysql/connector/cursor_cext.py", line 330, in execute result = self._cnx.cmd_query( File "/home/.local/lib/python3.9/site-packages/mysql/connector/connection_cext.py", line 632, in cmd_query return self.fetch_eof_columns() File "/home/.local/lib/python3.9/site-packages/mysql/connector/connection_cext.py", line 514, in fetch_eof_columns fields = prep_stmt.fetch_fields() if prep_stmt else self._cmysql.fetch_fields() UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 256: invalid start byte I hope that's repeatable enough. As a sidenote, if I use shorter table names t1,t2,t3 instead of bugtest_table1,bugtest_table2,bugtest_table3, then the error does not occur. That makes the problem seem like an internal string size issue.
[11 Apr 2023 11:43]
MySQL Verification Team
Hello Friedrich Volkmann, Thank you for the bug report. Verified as described. Regards, Ashwini Patil
[23 Jun 2023 20:13]
Philip Olson
Posted by developer: Fixed as of the upcoming MySQL Connector/Python 8.1.0 release, and here's the proposed changelog entry from the documentation team: A UnicodeDecodeError error was raised when using a complex query that produced a long field name alias. Thank you for the bug report.