1-- Copyright (c) 2018 MariaDB Foundation
2--
3-- This program is free software; you can redistribute it and/or modify
4-- it under the terms of the GNU General Public License as published by
5-- the Free Software Foundation; version 2 of the License.
6--
7-- This program is distributed in the hope that it will be useful,
8-- but WITHOUT ANY WARRANTY; without even the implied warranty of
9-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10-- GNU General Public License for more details.
11--
12-- You should have received a copy of the GNU General Public License
13-- along with this program; if not, write to the Free Software
14-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
15
16CREATE DATABASE IF NOT EXISTS test CHARACTER SET latin1 COLLATE latin1_swedish_ci;
17
18-- Fill "db" table with default grants for anyone to
19-- access database 'test' and 'test_%' if "db" table didn't exist
20CREATE TEMPORARY TABLE tmp_db LIKE db;
21INSERT INTO tmp_db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y','Y');
22INSERT INTO tmp_db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y','Y');
23INSERT INTO db SELECT * FROM tmp_db WHERE @had_db_table=0;
24DROP TABLE tmp_db;
25
26-- Anonymous user with no privileges.
27CREATE TEMPORARY TABLE tmp_user_anonymous LIKE global_priv;
28INSERT INTO tmp_user_anonymous (host,user) VALUES ('localhost','');
29INSERT INTO tmp_user_anonymous (host,user) SELECT @current_hostname,'' FROM dual WHERE @current_hostname != 'localhost';
30INSERT INTO global_priv SELECT * FROM tmp_user_anonymous WHERE @had_user_table=0;
31DROP TABLE tmp_user_anonymous;
32