[MDEV-5437] DROP TRIGGER command not respecting read_only = 1 setting Created: 2013-12-12  Updated: 2014-11-17  Resolved: 2014-11-16

Status: Closed
Project: MariaDB Server
Component/s: Triggers
Affects Version/s: 5.5.34
Fix Version/s: 5.5.37

Type: Bug Priority: Minor
Reporter: Jonathan Nicol Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: upstream-fixed
Environment:

CentOS 5.10 x86_64



 Description   

(also reported to MySQL here: http://bugs.mysql.com/bug.php?id=71136)

The "read_only" global variable is not respected by the DROP TRIGGER command, even for a non-SUPER user. It does appear to respect read_only for CREATE TRIGGER. This should return an error, not succeed.

MariaDB [foo]> select @@version;
+--------------------+
| @@version          |
+--------------------+
| 5.5.34-MariaDB-log |
+--------------------+
1 row in set (0.00 sec)
 
MariaDB [foo]> select @@read_only;
+-------------+
| @@read_only |
+-------------+
|           1 |
+-------------+
1 row in set (0.00 sec)
 
MariaDB [foo]> show grants for current_user;
+--------------------------------------------------------------------------------+
| Grants for foo@localhost                                                       |
+--------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'foo'@'localhost' IDENTIFIED BY PASSWORD 'redacted'      |
| GRANT SELECT, INSERT, UPDATE, DELETE, TRIGGER ON `foo`.* TO 'foo'@'localhost'  |
+--------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
 
MariaDB [foo]> DROP TRIGGER ins_sum;
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [foo]> CREATE TRIGGER ins_sum BEFORE INSERT ON account  FOR EACH ROW SET @sum = @sum + NEW.amount;
ERROR 1290 (HY000): The MariaDB server is running with the --read-only option so it cannot execute this statement



 Comments   
Comment by Savita Agrawal [ 2014-03-07 ]

A check (lex->sql_command == SQLCOM_DROP_TRIGGER) in function deny_updates_if_read_only_option() in the file sql_parse.cc does the job!
Is it a right approach? If yes, I will be submitting my first patch to mariadb.

Comment by Elena Stepanova [ 2014-11-16 ]

The upstream bug is private, but the log and tests suggest that it was fixed in 5.5.37:

revno: 4572
revision-id: bharathy.x.satish@oracle.com-20140107094105-orxie9xz39mm8esu
parent: laasya.moduludu@oracle.com-20140106104305-j9iznr6wwpva4ifg
committer: Bharathy Satish <bharathy.x.satish@oracle.com>
branch nick: mysql-5.5
timestamp: Tue 2014-01-07 15:11:05 +0530
message:
  Bug #17503460 MYSQL READ ONLY DOESN'T WORK FOR DROP TRIGGER
  
  Problem: Drop Trigger succeeds even after setting read_only 
  variable to ON.
  Fix: Fix is to report the standard error 
  (ER_OPTION_PREVENTS_STATEMENT)when global read_only variable 
  is set to ON.

The fix was merged into MariaDB 5.5.37.

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