[MDEV-12990] Error Message not displayed correctly in some clients Created: 2017-06-04  Updated: 2017-06-27  Resolved: 2017-06-26

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients
Affects Version/s: 10.2
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: CARME Antoine Assignee: Sergei Golubchik
Resolution: Won't Fix Votes: 0
Labels: None


 Description   

Hello,

When using a model with too many CTEs, I get the error

Code: 4003 SQL State: HY000 — Too many WITH elements in WITH clause

when doing an explain but the python client/driver (MySQLdb) I am using does not display it and it displayed an cryptic error (''error totally whack').

A deeper source code analysis shows that the python code expects an error code to be below CR_MAX_ERROR which is defined by mariadb as ,

../server/include/errmsg.h:#define CR_MAX_ERROR 2999

Did this number increase without being updated ? it is no longer used in mariadb-server but still by some clients (to my knowledge : mysqladmin and python)

Regards,

Antoine



 Comments   
Comment by Elena Stepanova [ 2017-06-04 ]

I would guess it's because 400x are "MariaDB extra errors" (server errors) and supposedly shouldn't have had to do much with a max number for client errors, but apparently this is faulty logic, if existing clients have a problem with it.

Assigning to serg to decide what should be done about it.

Comment by CARME Antoine [ 2017-06-05 ]

Thanks a lot Elena for the quick response.

Your analysis makes sense. I made a first investigation too be sure that this is not a bug in the SQL I generated (5 other different databases , oracle, mssql, etc where happy with a similar code

The code indeed contains a lot of CTEs by design, but that's another problem I just wanted to mention the behavior difference between clients regarding error messages.

Let's wait and see what Sergei will do with it.

Cheers
Antoine

Comment by Sergei Golubchik [ 2017-06-26 ]

It's a bug in python connector MySQLdb.

Since at least 1999 and up to MariaDB 10.1 and MySQL 5.6, server error codes with in the range of 1000-1999 and client errors were in the range 2000-2999 (from CR_MIN_ERROR to CR_MAX_ERROR).

Eventually we've used up all 999 server error codes. MySQL 5.7 puts new error messages in the 3000-3999 range, MariaDB 10.2 puts new error messages in the 4000-4999 range.

Your MySQLdb version apparently expects no error message, client or server, to be above CR_MAX_ERROR. This doesn't work either with MariaDB 10.2 nor with MySQL 5.7. May be you're using an old version of MySQLdb?

Comment by CARME Antoine [ 2017-06-26 ]

Thanks a lot Sergei for this feedback.

I will investigate the versions I use (mine is an improbable mix of debian and python packages .

Do you know who is responsible of python driver ? The last official version of mysqldb is available here :

https://pypi.python.org/pypi/mysqlclient

and it contains the same piece of code (there is a source.tar.gz file) in the file _mysql.c:

```
merr = mysql_errno(&(c->connection));
if (!merr)
e = _mysql_InterfaceError;
else if (merr > CR_MAX_ERROR)

{ PyTuple_SET_ITEM(t, 0, PyInt_FromLong(-1L)); PyTuple_SET_ITEM(t, 1, PyString_FromString("error totally whack")); PyErr_SetObject(_mysql_InterfaceError, t); Py_DECREF(t); return NULL; }

```

Regards,

Antoine

Comment by CARME Antoine [ 2017-06-26 ]

Sergei,

It's me again. I removed all the versions of mysqldb and installed the last dev one from github (https://github.com/PyMySQL/mysqlclient-python).

I still get the same error.

Will file an issue on github about this.

Antoine

Comment by CARME Antoine [ 2017-06-26 ]

FYI,

Added https://github.com/PyMySQL/mysqlclient-python/issues/187

Comment by CARME Antoine [ 2017-06-27 ]

This problem was solved at the python driver level (github issue mentioned above) with the help of Sergei.

Now the python driver displays correctly the messages coming from mariadb (and mysql)

Many thanks to the python driver developer and the mariadb team.

You made a happy mariadb user

Antoine

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