summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorgluh@gluh.mysql.r18.ru <>2004-12-06 19:03:39 +0300
committergluh@gluh.mysql.r18.ru <>2004-12-06 19:03:39 +0300
commit2686161c00a4129ddf6c6dc74e16079086af83da (patch)
tree92d0cb833f92c817940a85c5c56b58dd8e43e683 /sql
parentf6209be015f7938a5eadf099f992f714c48a0c25 (diff)
parent0282d03215e367e5fac4624fa9e9edcedf6938eb (diff)
downloadmariadb-git-2686161c00a4129ddf6c6dc74e16079086af83da.tar.gz
Merge sgluhov@bk-internal.mysql.com:/home/bk/mysql-4.1
into gluh.mysql.r18.ru:/home/gluh/MySQL-BUGS/mysql-4.1.6840
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_parse.cc18
-rw-r--r--sql/sql_yacc.yy11
2 files changed, 20 insertions, 9 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 3d1df80c37b..1e18771ad15 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -3184,9 +3184,15 @@ purposes internal to the MySQL server", MYF(0));
}
case SQLCOM_ALTER_DB:
{
- if (!strip_sp(lex->name) || check_db_name(lex->name))
+ char *db= lex->name ? lex->name : thd->db;
+ if (!db)
{
- net_printf(thd, ER_WRONG_DB_NAME, lex->name);
+ send_error(thd, ER_NO_DB_ERROR);
+ goto error;
+ }
+ if (!strip_sp(db) || check_db_name(db))
+ {
+ net_printf(thd, ER_WRONG_DB_NAME, db);
break;
}
/*
@@ -3198,21 +3204,21 @@ purposes internal to the MySQL server", MYF(0));
*/
#ifdef HAVE_REPLICATION
if (thd->slave_thread &&
- (!db_ok(lex->name, replicate_do_db, replicate_ignore_db) ||
- !db_ok_with_wild_table(lex->name)))
+ (!db_ok(db, replicate_do_db, replicate_ignore_db) ||
+ !db_ok_with_wild_table(db)))
{
my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
break;
}
#endif
- if (check_access(thd,ALTER_ACL,lex->name,0,1,0))
+ if (check_access(thd, ALTER_ACL, db, 0, 1, 0))
break;
if (thd->locked_tables || thd->active_transaction())
{
send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION);
goto error;
}
- res=mysql_alter_db(thd,lex->name,&lex->create_info);
+ res= mysql_alter_db(thd, db, &lex->create_info);
break;
}
case SQLCOM_SHOW_CREATE_DB:
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 49e567ab54b..e525fb2478a 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -609,7 +609,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <simple_string>
remember_name remember_end opt_ident opt_db text_or_password
- opt_constraint constraint
+ opt_constraint constraint ident_or_empty
%type <string>
text_string opt_gconcat_separator
@@ -1870,7 +1870,7 @@ alter:
}
alter_list
{}
- | ALTER DATABASE ident
+ | ALTER DATABASE ident_or_empty
{
Lex->create_info.default_table_charset= NULL;
Lex->create_info.used_fields= 0;
@@ -1879,10 +1879,15 @@ alter:
{
LEX *lex=Lex;
lex->sql_command=SQLCOM_ALTER_DB;
- lex->name=$3.str;
+ lex->name= $3;
};
+ident_or_empty:
+ /* empty */ { $$= 0; }
+ | ident { $$= $1.str; };
+
+
alter_list:
| DISCARD TABLESPACE { Lex->alter_info.tablespace_op= DISCARD_TABLESPACE; }
| IMPORT TABLESPACE { Lex->alter_info.tablespace_op= IMPORT_TABLESPACE; }