[MXS-76] core/dbusers.c needs better error messages Created: 2015-04-01  Updated: 2015-04-14  Resolved: 2015-04-01

Status: Closed
Project: MariaDB MaxScale
Component/s: None
Affects Version/s: 1.1.0
Fix Version/s: 1.1.0

Type: Bug Priority: Major
Reporter: Kolbe Kegel (Inactive) Assignee: Timofey Turenko
Resolution: Fixed Votes: 0
Labels: None


 Description   

The error messages generated by core/dbusers.c are poor.

Example 1:

2015-03-30 21:17:52   Shard Router: Unable to load database grant information, MaxScale authentication will proceed without including database permissions. To correct this GRANT select permission on msql.db to the user maxuser.

Example 2:

2015-03-30 21:18:28   Shard Router: Unable to load database grant information, MaxScale authentication will proceed without including database permissions. To correct this GRANT select permission on mysql.db to the user maxuser.

It's strange that the same messages are reproduced so many times in the source:

$ grep -Ern 'on m.?sql'
core/dbusers.c:386:                             "on mysql.db to the user %s.",
core/dbusers.c:492:                             "on mysql.db to the user %s.",
core/dbusers.c:768:                            "on msql.db to the user %s.",
core/dbusers.c:1261:                            "on msql.db to the user %s.",

That same message (once with a mis-spelling of mysql as msql) occurs 4 times in the same source file! In some instances, the message doesn't describe the problem accurately at all.

The messages at lines 383 and 489 are generated after executing LOAD_MYSQL_DATABASE_NAMES, which is this query:

core/dbusers.c:#define LOAD_MYSQL_DATABASE_NAMES "SELECT * FROM ( (SELECT COUNT(1) AS ndbs FROM INFORMATION_SCHEMA.SCHEMATA) AS tbl1, (SELECT GRANTEE,PRIVILEGE_TYPE from INFORMATION_SCHEMA.USER_PRIVILEGES WHERE privilege_type='SHOW DATABASES' AND REPLACE(GRANTEE, \'\\'\',\'\')=CURRENT_USER()) AS tbl2)"

That query is actually checking whether the user has the SHOW DATABASES privilege, but the error message itself just refers to the select privilege and says nothing at all about SHOW DATABASES.

This message should obviously be updated to describe the correct privilege.

I really can't understand why the very same logic and errors exist multiple times in this single source file. Surely that could be refactored and consolidated?



 Comments   
Comment by markus makela [ 2015-04-01 ]

Error message is now "%s: Unable to load database grant information, MaxScale authentication will proceed without including database permissions. To correct this GRANT SHOW DATABASES ON *.* privilege to the user %s."

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