Skip to content

Commit 548c7ca

Browse files
committedMay 18, 2016
fix syntax error in create database with read_only in comments
Summary: With `[SUPER_]READ_ONLY` in the comment section of `create database` statement, the create will fail with syntax error (because the comment starting with !version is parsed). The patch fixes it by ignoring the read_only keyword. Database shouldn't be created in read_only state. In addition, `[SUPER_]READ_ONLY` without assignment in `alter database` is also ignored. Test Plan: Added regression test cases. Reviewers: jkedgar Reviewed By: jkedgar Subscribers: dreif, webscalesql-eng Differential Revision: https://reviews.facebook.net/D58353
1 parent 9661bb1 commit 548c7ca

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed
 

‎mysql-test/r/db_read_only.result

+18
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,24 @@ show create database test_db_opt;
791791
Database Create Database
792792
test_db_opt CREATE DATABASE `test_db_opt` /*!40100 DEFAULT CHARACTER SET latin1 READ_ONLY */
793793
drop database test_db_opt;
794+
create database test_db_opt /*!40100 DEFAULT CHARACTER SET latin1 READ_ONLY*/;
795+
show create database test_db_opt;
796+
Database Create Database
797+
test_db_opt CREATE DATABASE `test_db_opt` /*!40100 DEFAULT CHARACTER SET latin1 */
798+
alter database test_db_opt read_only;
799+
show create database test_db_opt;
800+
Database Create Database
801+
test_db_opt CREATE DATABASE `test_db_opt` /*!40100 DEFAULT CHARACTER SET latin1 */
802+
drop database test_db_opt;
803+
create database test_db_opt /*!40100 DEFAULT CHARACTER SET latin1 SUPER_READ_ONLY*/;
804+
show create database test_db_opt;
805+
Database Create Database
806+
test_db_opt CREATE DATABASE `test_db_opt` /*!40100 DEFAULT CHARACTER SET latin1 */
807+
alter database test_db_opt super_read_only;
808+
show create database test_db_opt;
809+
Database Create Database
810+
test_db_opt CREATE DATABASE `test_db_opt` /*!40100 DEFAULT CHARACTER SET latin1 */
811+
drop database test_db_opt;
794812
connection default;
795813
alter database test read_only = false;
796814
show create database test;

‎mysql-test/t/db_read_only.test

+16
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,22 @@ alter database test_db_opt default collate = default;
197197
show create database test_db_opt;
198198
drop database test_db_opt;
199199

200+
#
201+
# [super_]read_only is ignored in create database comment
202+
# and is ignored in alter without assignment
203+
#
204+
create database test_db_opt /*!40100 DEFAULT CHARACTER SET latin1 READ_ONLY*/;
205+
show create database test_db_opt;
206+
alter database test_db_opt read_only;
207+
show create database test_db_opt;
208+
drop database test_db_opt;
209+
210+
create database test_db_opt /*!40100 DEFAULT CHARACTER SET latin1 SUPER_READ_ONLY*/;
211+
show create database test_db_opt;
212+
alter database test_db_opt super_read_only;
213+
show create database test_db_opt;
214+
drop database test_db_opt;
215+
200216
#
201217
# cleanup
202218
#

‎sql/sql_yacc.yy

+2-1
Original file line numberDiff line numberDiff line change
@@ -6496,7 +6496,8 @@ default_collation:
64966496
;
64976497

64986498
db_read_only:
6499-
read_only_opt equal boolean_val
6499+
read_only_opt { /* Ignored */ }
6500+
| read_only_opt equal boolean_val
65006501
{
65016502
/* read_only = false */
65026503
Lex->create_info.db_read_only= enum_db_read_only::DB_READ_ONLY_NO;

0 commit comments

Comments
 (0)