Below is the list of changes that have just been committed into a local
5.0 repository of gluh. When gluh does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1940 05/06/01 22:50:47 gluh@stripped +13 -0
Fix for bug#10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA,
bug#9683 INFORMATION_SCH: Creation of temporary table allowed in
Information_schema DB,
added new parameter to check_db_name
code cleanup
added information schema specific error handling
added new error message
sql/table.cc
1.166 05/06/01 22:49:45 gluh@stripped +10 -2
Fix for bug#10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA,
bug#9683 INFORMATION_SCH: Creation of temporary table allowed in
Information_schema DB,
sql/sql_yacc.yy
1.384 05/06/01 22:49:45 gluh@stripped +7 -1
Fix for bug#10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA,
bug#9683 INFORMATION_SCH: Creation of temporary table allowed in
Information_schema DB,
sql/sql_table.cc
1.247 05/06/01 22:49:45 gluh@stripped +5 -3
Fix for bug#10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA,
bug#9683 INFORMATION_SCH: Creation of temporary table allowed in
Information_schema DB,
sql/sql_show.cc
1.249 05/06/01 22:49:45 gluh@stripped +0 -6
Fix for bug#10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA,
bug#9683 INFORMATION_SCH: Creation of temporary table allowed in
Information_schema DB,
sql/sql_parse.cc
1.439 05/06/01 22:49:45 gluh@stripped +69 -12
Fix for bug#10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA,
bug#9683 INFORMATION_SCH: Creation of temporary table allowed in
Information_schema DB,
sql/sql_db.cc
1.110 05/06/01 22:49:44 gluh@stripped +4 -5
Fix for bug#10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA,
bug#9683 INFORMATION_SCH: Creation of temporary table allowed in
Information_schema DB,
sql/sql_class.h
1.233 05/06/01 22:49:44 gluh@stripped +2 -0
Fix for bug#10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA,
bug#9683 INFORMATION_SCH: Creation of temporary table allowed in
Information_schema DB,
sql/sql_class.cc
1.181 05/06/01 22:49:44 gluh@stripped +1 -0
Fix for bug#10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA,
bug#9683 INFORMATION_SCH: Creation of temporary table allowed in
Information_schema DB,
sql/sp.cc
1.77 05/06/01 22:49:44 gluh@stripped +6 -8
Fix for bug#10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA,
bug#9683 INFORMATION_SCH: Creation of temporary table allowed in
Information_schema DB,
sql/share/errmsg.txt
1.32 05/06/01 22:49:44 gluh@stripped +2 -0
Fix for bug#10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA,
bug#9683 INFORMATION_SCH: Creation of temporary table allowed in
Information_schema DB,
sql/mysql_priv.h
1.303 05/06/01 22:49:44 gluh@stripped +1 -1
Fix for bug#10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA,
bug#9683 INFORMATION_SCH: Creation of temporary table allowed in
Information_schema DB,
mysql-test/t/information_schema.test
1.37 05/06/01 22:49:44 gluh@stripped +37 -0
Fix for bug#10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA,
bug#9683 INFORMATION_SCH: Creation of temporary table allowed in
Information_schema DB,
mysql-test/r/information_schema.result
1.54 05/06/01 22:49:44 gluh@stripped +28 -0
Fix for bug#10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA,
bug#9683 INFORMATION_SCH: Creation of temporary table allowed in
Information_schema DB,
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: gluh
# Host: eagle.intranet.mysql.r18.ru
# Root: /home/gluh/MySQL/Bugs/5.0.10708
--- 1.302/sql/mysql_priv.h Mon May 30 21:56:06 2005
+++ 1.303/sql/mysql_priv.h Wed Jun 1 22:49:44 2005
@@ -1273,7 +1273,7 @@
HA_CREATE_INFO *create_info, uint keys);
void update_create_info_from_table(HA_CREATE_INFO *info, TABLE *form);
int rename_file_ext(const char * from,const char * to,const char * ext);
-bool check_db_name(char *db);
+bool check_db_name(char *name, bool *is_schema_db);
bool check_column_name(const char *name);
bool check_table_name(const char *name, uint length);
char *get_field(MEM_ROOT *mem, Field *field);
--- 1.180/sql/sql_class.cc Thu May 26 22:54:26 2005
+++ 1.181/sql/sql_class.cc Wed Jun 1 22:49:44 2005
@@ -169,6 +169,7 @@
backup_arena= 0;
#endif
host= user= priv_user= db= ip= 0;
+ schema_db_used= 0;
catalog= (char*)"std"; // the only catalog we have for now
host_or_ip= "connecting host";
locked=some_tables_deleted=no_errors=password= 0;
--- 1.232/sql/sql_class.h Fri May 27 00:01:46 2005
+++ 1.233/sql/sql_class.h Wed Jun 1 22:49:44 2005
@@ -975,6 +975,7 @@
db - currently selected database
catalog - currently selected catalog
ip - client IP
+ schema_db_used - TRUE if currently selected database is information_schema db
WARNING: some members of THD (currently 'db', 'catalog' and 'query') are
set and alloced by the slave SQL thread (for the THD of that thread); that
thread is (and must remain, for now) the only responsible for freeing these
@@ -985,6 +986,7 @@
*/
char *host,*user,*priv_user,*db,*catalog,*ip;
char priv_host[MAX_HOSTNAME];
+ bool schema_db_used;
/* remote (peer) port */
uint16 peer_port;
/*
--- 1.109/sql/sql_db.cc Sat May 21 02:31:13 2005
+++ 1.110/sql/sql_db.cc Wed Jun 1 22:49:44 2005
@@ -1023,7 +1023,7 @@
char *dbname=my_strdup((char*) name,MYF(MY_WME));
char path[FN_REFLEN];
HA_CREATE_INFO create;
- bool schema_db= 0;
+ bool schema_db;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
ulong db_access;
#endif
@@ -1036,16 +1036,15 @@
MYF(0)); /* purecov: inspected */
DBUG_RETURN(1); /* purecov: inspected */
}
- if (check_db_name(dbname))
+ if (check_db_name(dbname, &schema_db))
{
my_error(ER_WRONG_DB_NAME, MYF(0), dbname);
x_free(dbname);
DBUG_RETURN(1);
}
DBUG_PRINT("info",("Use database: %s", dbname));
- if (!my_strcasecmp(system_charset_info, dbname, information_schema_name.str))
+ if (schema_db)
{
- schema_db= 1;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
db_access= SELECT_ACL;
#endif
@@ -1090,7 +1089,7 @@
#ifndef NO_EMBEDDED_ACCESS_CHECKS
thd->db_access=db_access;
#endif
- if (schema_db)
+ if ((thd->schema_db_used= schema_db))
{
thd->db_charset= system_charset_info;
thd->variables.collation_database= system_charset_info;
--- 1.438/sql/sql_parse.cc Mon May 30 21:56:08 2005
+++ 1.439/sql/sql_parse.cc Wed Jun 1 22:49:45 2005
@@ -1281,6 +1281,7 @@
TABLE* table;
TABLE_LIST* table_list;
int error = 0;
+ bool is_schema_db;
DBUG_ENTER("mysql_table_dump");
db = (db && db[0]) ? db : thd->db;
if (!(table_list = (TABLE_LIST*) thd->calloc(sizeof(TABLE_LIST))))
@@ -1290,7 +1291,7 @@
table_list->lock_type= TL_READ_NO_INSERT;
table_list->prev_global= &table_list; // can be removed after merge with 4.1
- if (!db || check_db_name(db))
+ if (check_db_name(db, &is_schema_db))
{
my_error(ER_WRONG_DB_NAME ,MYF(0), db ? db : "NULL");
goto err;
@@ -1788,15 +1789,22 @@
{
char *db=thd->strdup(packet), *alias;
HA_CREATE_INFO create_info;
+ bool is_schema_db;
statistic_increment(thd->status_var.com_stat[SQLCOM_CREATE_DB],
&LOCK_status);
// null test to handle EOM
- if (!db || !(alias= thd->strdup(db)) || check_db_name(db))
+ if (!db || !(alias= thd->strdup(db)) || check_db_name(db, &is_schema_db))
{
my_error(ER_WRONG_DB_NAME, MYF(0), db ? db : "NULL");
break;
}
+ if (is_schema_db)
+ {
+ my_error(ER_WRONG_OPERATION_FOR_I_S, MYF(0));
+ break;
+ }
+
if (check_access(thd,CREATE_ACL,db,0,1,0))
break;
mysql_log.write(thd,command,packet);
@@ -1810,12 +1818,18 @@
statistic_increment(thd->status_var.com_stat[SQLCOM_DROP_DB],
&LOCK_status);
char *db=thd->strdup(packet);
+ bool is_schema_db;
/* null test to handle EOM */
- if (!db || check_db_name(db))
+ if (check_db_name(db, &is_schema_db))
{
my_error(ER_WRONG_DB_NAME, MYF(0), db ? db : "NULL");
break;
}
+ if (is_schema_db)
+ {
+ my_error(ER_WRONG_OPERATION_FOR_I_S, MYF(0));
+ break;
+ }
if (check_access(thd,DROP_ACL,db,0,1,0))
break;
if (thd->locked_tables || thd->active_transaction())
@@ -2087,6 +2101,7 @@
#else
{
char *db= lex->select_lex.db ? lex->select_lex.db : thd->db;
+ bool is_schema_db;
if (!db)
{
my_message(ER_NO_DB_ERROR,
@@ -2094,7 +2109,7 @@
DBUG_RETURN(1); /* purecov: inspected */
}
remove_escape(db); // Fix escaped '_'
- if (check_db_name(db))
+ if (check_db_name(db, &is_schema_db))
{
my_error(ER_WRONG_DB_NAME, MYF(0), db);
DBUG_RETURN(1);
@@ -2747,6 +2762,11 @@
TABLE_LIST *create_table= lex->unlink_first_table(&link_to_local);
TABLE_LIST *select_tables= lex->query_tables;
+ if (first_table->schema_table)
+ {
+ my_error(ER_WRONG_OPERATION_FOR_I_S, MYF(0));
+ goto unsent_create_error;
+ }
if ((res= create_table_precheck(thd, select_tables, create_table)))
goto unsent_create_error;
@@ -2910,6 +2930,11 @@
#else
{
ulong priv=0;
+ if (first_table->schema_table)
+ {
+ my_error(ER_WRONG_OPERATION_FOR_I_S, MYF(0));
+ goto error;
+ }
if (lex->name && (!lex->name[0] || strlen(lex->name) >
NAME_LEN))
{
my_error(ER_WRONG_TABLE_NAME, MYF(0), lex->name);
@@ -3439,7 +3464,9 @@
case SQLCOM_CREATE_DB:
{
char *alias;
- if (!(alias=thd->strdup(lex->name)) || check_db_name(lex->name))
+ bool is_schema_db;
+ if (!(alias=thd->strdup(lex->name)) ||
+ check_db_name(lex->name, &is_schema_db))
{
my_error(ER_WRONG_DB_NAME, MYF(0), lex->name);
break;
@@ -3468,11 +3495,17 @@
}
case SQLCOM_DROP_DB:
{
- if (check_db_name(lex->name))
+ bool is_schema_db;
+ if (check_db_name(lex->name, &is_schema_db))
{
my_error(ER_WRONG_DB_NAME, MYF(0), lex->name);
break;
}
+ if (is_schema_db)
+ {
+ my_error(ER_WRONG_OPERATION_FOR_I_S, MYF(0));
+ break;
+ }
/*
If in a slave thread :
DROP DATABASE DB may not be preceded by USE DB.
@@ -3502,17 +3535,23 @@
}
case SQLCOM_ALTER_DB:
{
+ bool is_schema_db;
char *db= lex->name ? lex->name : thd->db;
if (!db)
{
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
break;
}
- if (!strip_sp(db) || check_db_name(db))
+ if (!strip_sp(db) || check_db_name(db, &is_schema_db))
{
my_error(ER_WRONG_DB_NAME, MYF(0), lex->name);
break;
}
+ if (is_schema_db)
+ {
+ my_error(ER_WRONG_OPERATION_FOR_I_S, MYF(0));
+ break;
+ }
/*
If in a slave thread :
ALTER DATABASE DB may not be preceded by USE DB.
@@ -3542,8 +3581,12 @@
}
case SQLCOM_SHOW_CREATE_DB:
{
- if (!strip_sp(lex->name) || check_db_name(lex->name))
+ bool is_schema_db;
+ if (!strip_sp(lex->name) || check_db_name(lex->name, &is_schema_db))
{
+ /*
+ TODO: add fix for bug #9434 SHOW CREATE DATABASE `information_schema`
+ */
my_error(ER_WRONG_DB_NAME, MYF(0), lex->name);
break;
}
@@ -3941,9 +3984,23 @@
uint namelen;
char *name, *db;
int result;
+ bool is_schema_db;
DBUG_ASSERT(lex->sphead != 0);
-
+ if (check_db_name(lex->sphead->m_db.str, &is_schema_db))
+ {
+ my_error(ER_WRONG_DB_NAME, MYF(0), db);
+ delete lex->sphead;
+ lex->sphead= 0;
+ goto error;
+ }
+ if (is_schema_db || !lex->sphead->m_db.str && thd->schema_db_used)
+ {
+ my_error(ER_WRONG_OPERATION_FOR_I_S, MYF(0));
+ delete lex->sphead;
+ lex->sphead= 0;
+ goto error;
+ }
if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str, 0, 0, 0))
{
delete lex->sphead;
@@ -5811,13 +5868,14 @@
register TABLE_LIST *ptr;
char *alias_str;
LEX *lex= thd->lex;
+ bool is_schema_db= FALSE;
DBUG_ENTER("add_table_to_list");
if (!table)
DBUG_RETURN(0); // End of memory
alias_str= alias ? alias->str : table->table.str;
if (check_table_name(table->table.str,table->table.length) ||
- table->db.str && check_db_name(table->db.str))
+ check_db_name(table->db.str, &is_schema_db))
{
my_error(ER_WRONG_TABLE_NAME, MYF(0), table->table.str);
DBUG_RETURN(0);
@@ -5865,8 +5923,7 @@
ptr->force_index= test(table_options & TL_OPTION_FORCE_INDEX);
ptr->ignore_leaves= test(table_options & TL_OPTION_IGNORE_LEAVES);
ptr->derived= table->sel;
- if (!my_strcasecmp(system_charset_info, ptr->db,
- information_schema_name.str))
+ if (is_schema_db || (thd->schema_db_used && !table->db.str))
{
ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, ptr->table_name);
if (!schema_table ||
--- 1.248/sql/sql_show.cc Tue May 31 13:15:18 2005
+++ 1.249/sql/sql_show.cc Wed Jun 1 22:49:45 2005
@@ -427,12 +427,6 @@
Protocol *protocol=thd->protocol;
DBUG_ENTER("mysql_show_create_db");
- if (check_db_name(dbname))
- {
- my_error(ER_WRONG_DB_NAME, MYF(0), dbname);
- DBUG_RETURN(TRUE);
- }
-
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (test_all_bits(thd->master_access,DB_ACLS))
db_access=DB_ACLS;
--- 1.246/sql/sql_table.cc Wed May 25 20:33:31 2005
+++ 1.247/sql/sql_table.cc Wed Jun 1 22:49:45 2005
@@ -2541,10 +2541,11 @@
char src_path[FN_REFLEN], dst_path[FN_REFLEN];
char *db= table->db;
char *table_name= table->table_name;
- char *src_db= thd->db;
+ char *src_db;
char *src_table= table_ident->table.str;
int err;
bool res= TRUE;
+ bool is_schema_db;
TABLE_LIST src_tables_list;
DBUG_ENTER("mysql_create_like_table");
@@ -2554,14 +2555,15 @@
if (table_ident->table.length > NAME_LEN ||
(table_ident->table.length &&
check_table_name(src_table,table_ident->table.length)) ||
- table_ident->db.str && check_db_name((src_db= table_ident->db.str)))
+ check_db_name(table_ident->db.str, &is_schema_db))
{
my_error(ER_WRONG_TABLE_NAME, MYF(0), src_table);
DBUG_RETURN(TRUE);
}
bzero((gptr)&src_tables_list, sizeof(src_tables_list));
- src_tables_list.db= table_ident->db.str ? table_ident->db.str : thd->db;
+ src_db= src_tables_list.db= (table_ident->db.str ?
+ table_ident->db.str : thd->db);
src_tables_list.table_name= table_ident->table.str;
if (lock_and_wait_for_table_name(thd, &src_tables_list))
--- 1.383/sql/sql_yacc.yy Fri May 27 15:38:28 2005
+++ 1.384/sql/sql_yacc.yy Wed Jun 1 22:49:45 2005
@@ -3476,12 +3476,18 @@
| RENAME opt_to table_ident
{
LEX *lex=Lex;
+ bool is_schema_db;
lex->select_lex.db=$3->db.str;
lex->name= $3->table.str;
if (check_table_name($3->table.str,$3->table.length) ||
- $3->db.str && check_db_name($3->db.str))
+ check_db_name($3->db.str, &is_schema_db))
{
my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.str);
+ YYABORT;
+ }
+ if (is_schema_db || !$3->db.str && lex->thd->schema_db_used)
+ {
+ my_error(ER_WRONG_OPERATION_FOR_I_S, MYF(0));
YYABORT;
}
lex->alter_info.flags|= ALTER_RENAME;
--- 1.165/sql/table.cc Thu May 26 16:00:43 2005
+++ 1.166/sql/table.cc Wed Jun 1 22:49:45 2005
@@ -1513,6 +1513,8 @@
SYNPOSIS
check_db_name()
name Name of database
+ is_schema_db return 1 if db is information_schema
+ otherwise return 0
NOTES
If lower_case_table_names is set then database is converted to lower case
@@ -1522,12 +1524,14 @@
1 error
*/
-bool check_db_name(char *name)
+bool check_db_name(char *name, bool *is_schema_db)
{
char *start=name;
/* Used to catch empty names and names with end space */
bool last_char_is_space= TRUE;
+ if (!name)
+ return 0;
if (lower_case_table_names && name != any_db)
my_casedn_str(files_charset_info, name);
@@ -1553,7 +1557,11 @@
return 1;
name++;
}
- return last_char_is_space || (uint) (name - start) > NAME_LEN;
+ if (last_char_is_space || (uint) (name - start) > NAME_LEN)
+ return 1;
+ *is_schema_db= !my_strcasecmp(system_charset_info, start,
+ information_schema_name.str);
+ return 0;
}
--- 1.31/sql/share/errmsg.txt Thu May 12 12:16:07 2005
+++ 1.32/sql/share/errmsg.txt Wed Jun 1 22:49:44 2005
@@ -5356,3 +5356,5 @@
eng "You can't execute a prepared statement which has an open cursor associated with it.
Reset the statement to re-execute it."
ER_STMT_HAS_NO_OPEN_CURSOR
eng "The statement (%d) has no open cursor."
+ER_WRONG_OPERATION_FOR_I_S
+ eng "This operation cannot be done on the information_schema database"
--- 1.53/mysql-test/r/information_schema.result Tue May 31 13:15:18 2005
+++ 1.54/mysql-test/r/information_schema.result Wed Jun 1 22:49:44 2005
@@ -752,3 +752,31 @@
table_schema count(*)
information_schema 15
mysql 17
+alter table t1 rename information_schema.tables;
+ERROR HY000: This operation cannot be done on the information_schema database
+use information_schema;
+alter table test.t1 rename tables;
+ERROR HY000: This operation cannot be done on the information_schema database
+use test;
+drop database information_schema;
+ERROR HY000: This operation cannot be done on the information_schema database
+alter database information_schema;
+ERROR HY000: This operation cannot be done on the information_schema database
+create table t1(f1 int);
+create temporary table information_schema.tables like t1;
+ERROR HY000: This operation cannot be done on the information_schema database
+alter table information_schema.tables;
+ERROR HY000: This operation cannot be done on the information_schema database
+drop table t1;
+USE information_schema |
+CREATE PROCEDURE p1 ()
+BEGIN
+SELECT 'foo' FROM DUAL;
+END |
+ERROR HY000: This operation cannot be done on the information_schema database
+CREATE PROCEDURE information_schema.p1 ()
+BEGIN
+SELECT 'foo' FROM DUAL;
+END |
+ERROR HY000: This operation cannot be done on the information_schema database
+use test;
--- 1.36/mysql-test/t/information_schema.test Mon May 9 22:21:39 2005
+++ 1.37/mysql-test/t/information_schema.test Wed Jun 1 22:49:44 2005
@@ -493,3 +493,40 @@
#
SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
+--error 1422
+alter table t1 rename information_schema.tables;
+use information_schema;
+--error 1422
+alter table test.t1 rename tables;
+use test;
+
+--error 1422
+drop database information_schema;
+--error 1422
+alter database information_schema;
+
+# Bug #9683 INFORMATION_SCH: Creation of temporary table allowed in Information_schema
DB
+create table t1(f1 int);
+--error 1422
+create temporary table information_schema.tables like t1;
+--error 1422
+alter table information_schema.tables;
+drop table t1;
+
+# Bug #10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA
+delimiter |;
+USE information_schema |
+--error 1422
+CREATE PROCEDURE p1 ()
+BEGIN
+ SELECT 'foo' FROM DUAL;
+END |
+--error 1422
+CREATE PROCEDURE information_schema.p1 ()
+BEGIN
+ SELECT 'foo' FROM DUAL;
+END |
+
+delimiter ;|
+use test;
+
--- 1.76/sql/sp.cc Mon May 30 21:54:30 2005
+++ 1.77/sql/sp.cc Wed Jun 1 22:49:44 2005
@@ -1346,19 +1346,17 @@
char *dbname=my_strdup((char*) name,MYF(MY_WME));
char path[FN_REFLEN];
HA_CREATE_INFO create;
+ bool is_schema_db;
DBUG_ENTER("sp_change_db");
DBUG_PRINT("enter", ("db: %s, no_access_check: %d", name, no_access_check));
- db_length= (!dbname ? 0 : strip_sp(dbname));
- if (dbname && db_length)
+ if (check_db_name(dbname, &is_schema_db))
{
- if ((db_length > NAME_LEN) || check_db_name(dbname))
- {
- my_error(ER_WRONG_DB_NAME, MYF(0), dbname);
- x_free(dbname);
- DBUG_RETURN(1);
- }
+ my_error(ER_WRONG_DB_NAME, MYF(0), dbname);
+ x_free(dbname);
+ DBUG_RETURN(1);
}
+ db_length= (!dbname ? 0 : strip_sp(dbname));
if (dbname && db_length)
{
| Thread |
|---|
| • bk commit into 5.0 tree (gluh:1.1940) BUG#9683 | gluh | 1 Jun |