[MDEV-10119] mysql_install_db creates GIS procedures with invalid definer Created: 2016-05-24  Updated: 2016-06-27  Resolved: 2016-06-27

Status: Closed
Project: MariaDB Server
Component/s: Authentication and Privilege System, Data Definition - Procedure
Affects Version/s: 10.1.14
Fix Version/s: 10.1.16

Type: Bug Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: Alexey Botchkov
Resolution: Fixed Votes: 0
Labels: procedure, roles

Sprint: 10.1.15

 Description   

mysql_install_db creates the GIS stored procedures with the following definer values:

MariaDB [(none)]> select db, name, definer from mysql.proc;
+------+--------------------+---------+
| db   | name               | definer |
+------+--------------------+---------+
| test | AddGeometryColumn  | @       |
| test | DropGeometryColumn | @       |
+------+--------------------+---------+
2 rows in set (0.00 sec)

SHOW CREATE PROCEDURE interprets this definer in the following way:

MariaDB [(none)]> SHOW CREATE PROCEDURE test.AddGeometryColumn;
+-------------------+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+
| Procedure         | sql_mode | Create Procedure                                                                                                                                                                                                                                                                                                                                      | character_set_client | collation_connection | Database Collation |
+-------------------+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+
| AddGeometryColumn |          | CREATE DEFINER=`` PROCEDURE `AddGeometryColumn`(catalog varchar(64), t_schema varchar(64),
   t_name varchar(64), geometry_column varchar(64), t_srid int)
begin
  set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' ADD ', geometry_column,' GEOMETRY REF_SYSTEM_ID=', t_srid); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end | latin1               | latin1_swedish_ci    | latin1_swedish_ci  |
+-------------------+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+
1 row in set (0.00 sec)

But if I try to run this statement, MariaDB actually rejects this definer value:

MariaDB [(none)]> create database db1;
Query OK, 1 row affected (0.00 sec)
 
MariaDB [(none)]> use db1;
Database changed
MariaDB [db1]> delimiter //
MariaDB [db1]> CREATE DEFINER=`` PROCEDURE `AddGeometryColumn`(catalog varchar(64), t_schema varchar(64),
    ->    t_name varchar(64), geometry_column varchar(64), t_srid int)
    -> begin
    ->   set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' ADD ', geometry_column,' GEOMETRY REF_SYSTEM_ID=', t_srid); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end //
ERROR 1959 (OP000): Invalid role specification ``.

Since mysqldump uses SHOW CREATE PROCEDURE to back up procedures, this also breaks things when trying to restore a backup created with mysqldump:

> mysql -u root < master1.sql
ERROR 1959 (OP000) at line 1212: Invalid role specification ``.



 Comments   
Comment by Alexey Botchkov [ 2016-06-27 ]

Fixing patch: http://lists.askmonty.org/pipermail/commits/2016-June/009504.html

Generated at Thu Feb 08 07:39:49 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.