Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
1.1.0
-
None
-
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?