mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into rakia.(none):/home/kgeorge/mysql/autopush/B11551-5.0-opt
This commit is contained in:
@ -193,7 +193,7 @@ c d
|
|||||||
2 5
|
2 5
|
||||||
3 10
|
3 10
|
||||||
drop view v100;
|
drop view v100;
|
||||||
ERROR 42S02: Unknown table 'test.v100'
|
ERROR 42S02: Unknown table 'v100'
|
||||||
drop view t1;
|
drop view t1;
|
||||||
ERROR HY000: 'test.t1' is not VIEW
|
ERROR HY000: 'test.t1' is not VIEW
|
||||||
drop table v1;
|
drop table v1;
|
||||||
@ -2831,3 +2831,22 @@ b
|
|||||||
c
|
c
|
||||||
DROP VIEW v1, v2;
|
DROP VIEW v1, v2;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
CREATE TABLE t1 (id INT);
|
||||||
|
CREATE VIEW v1 AS SELECT id FROM t1;
|
||||||
|
SHOW TABLES;
|
||||||
|
Tables_in_test
|
||||||
|
t1
|
||||||
|
v1
|
||||||
|
DROP VIEW v2,v1;
|
||||||
|
ERROR 42S02: Unknown table 'v2'
|
||||||
|
SHOW TABLES;
|
||||||
|
Tables_in_test
|
||||||
|
t1
|
||||||
|
CREATE VIEW v1 AS SELECT id FROM t1;
|
||||||
|
DROP VIEW t1,v1;
|
||||||
|
ERROR HY000: 'test.t1' is not VIEW
|
||||||
|
SHOW TABLES;
|
||||||
|
Tables_in_test
|
||||||
|
t1
|
||||||
|
DROP TABLE t1;
|
||||||
|
DROP VIEW IF EXISTS v1;
|
||||||
|
@ -2697,3 +2697,24 @@ INSERT INTO v2 (col) VALUES ('c');
|
|||||||
SELECT s1 FROM t1;
|
SELECT s1 FROM t1;
|
||||||
DROP VIEW v1, v2;
|
DROP VIEW v1, v2;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #11551: Asymmetric + undocumented behaviour of DROP VIEW and DROP TABLE
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (id INT);
|
||||||
|
CREATE VIEW v1 AS SELECT id FROM t1;
|
||||||
|
SHOW TABLES;
|
||||||
|
|
||||||
|
--error 1051
|
||||||
|
DROP VIEW v2,v1;
|
||||||
|
SHOW TABLES;
|
||||||
|
|
||||||
|
CREATE VIEW v1 AS SELECT id FROM t1;
|
||||||
|
--error 1347
|
||||||
|
DROP VIEW t1,v1;
|
||||||
|
SHOW TABLES;
|
||||||
|
|
||||||
|
DROP TABLE t1;
|
||||||
|
--disable_warnings
|
||||||
|
DROP VIEW IF EXISTS v1;
|
||||||
|
--enable_warnings
|
||||||
|
@ -1282,8 +1282,11 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
|
|||||||
DBUG_ENTER("mysql_drop_view");
|
DBUG_ENTER("mysql_drop_view");
|
||||||
char path[FN_REFLEN];
|
char path[FN_REFLEN];
|
||||||
TABLE_LIST *view;
|
TABLE_LIST *view;
|
||||||
bool type= 0;
|
frm_type_enum type;
|
||||||
db_type not_used;
|
db_type not_used;
|
||||||
|
String non_existant_views;
|
||||||
|
char *wrong_object_db= NULL, *wrong_object_name= NULL;
|
||||||
|
bool error= FALSE;
|
||||||
|
|
||||||
for (view= views; view; view= view->next_local)
|
for (view= views; view; view= view->next_local)
|
||||||
{
|
{
|
||||||
@ -1291,8 +1294,9 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
|
|||||||
view->table_name, reg_ext, NullS);
|
view->table_name, reg_ext, NullS);
|
||||||
(void) unpack_filename(path, path);
|
(void) unpack_filename(path, path);
|
||||||
VOID(pthread_mutex_lock(&LOCK_open));
|
VOID(pthread_mutex_lock(&LOCK_open));
|
||||||
|
type= FRMTYPE_ERROR;
|
||||||
if (access(path, F_OK) ||
|
if (access(path, F_OK) ||
|
||||||
(type= (mysql_frm_type(thd, path, ¬_used) != FRMTYPE_VIEW)))
|
FRMTYPE_VIEW != (type= mysql_frm_type(thd, path, ¬_used)))
|
||||||
{
|
{
|
||||||
char name[FN_REFLEN];
|
char name[FN_REFLEN];
|
||||||
my_snprintf(name, sizeof(name), "%s.%s", view->db, view->table_name);
|
my_snprintf(name, sizeof(name), "%s.%s", view->db, view->table_name);
|
||||||
@ -1304,25 +1308,46 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
|
|||||||
VOID(pthread_mutex_unlock(&LOCK_open));
|
VOID(pthread_mutex_unlock(&LOCK_open));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (type)
|
if (type == FRMTYPE_TABLE)
|
||||||
my_error(ER_WRONG_OBJECT, MYF(0), view->db, view->table_name, "VIEW");
|
{
|
||||||
|
if (!wrong_object_name)
|
||||||
|
{
|
||||||
|
wrong_object_db= view->db;
|
||||||
|
wrong_object_name= view->table_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
my_error(ER_BAD_TABLE_ERROR, MYF(0), name);
|
{
|
||||||
goto err;
|
if (non_existant_views.length())
|
||||||
|
non_existant_views.append(',');
|
||||||
|
non_existant_views.append(String(view->table_name,system_charset_info));
|
||||||
|
}
|
||||||
|
VOID(pthread_mutex_unlock(&LOCK_open));
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (my_delete(path, MYF(MY_WME)))
|
if (my_delete(path, MYF(MY_WME)))
|
||||||
goto err;
|
error= TRUE;
|
||||||
query_cache_invalidate3(thd, view, 0);
|
query_cache_invalidate3(thd, view, 0);
|
||||||
sp_cache_invalidate();
|
sp_cache_invalidate();
|
||||||
VOID(pthread_mutex_unlock(&LOCK_open));
|
VOID(pthread_mutex_unlock(&LOCK_open));
|
||||||
}
|
}
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
DBUG_RETURN(TRUE);
|
||||||
|
}
|
||||||
|
if (wrong_object_name)
|
||||||
|
{
|
||||||
|
my_error(ER_WRONG_OBJECT, MYF(0), wrong_object_db, wrong_object_name,
|
||||||
|
"VIEW");
|
||||||
|
DBUG_RETURN(TRUE);
|
||||||
|
}
|
||||||
|
if (non_existant_views.length())
|
||||||
|
{
|
||||||
|
my_error(ER_BAD_TABLE_ERROR, MYF(0), non_existant_views.c_ptr());
|
||||||
|
DBUG_RETURN(TRUE);
|
||||||
|
}
|
||||||
send_ok(thd);
|
send_ok(thd);
|
||||||
DBUG_RETURN(FALSE);
|
DBUG_RETURN(FALSE);
|
||||||
|
|
||||||
err:
|
|
||||||
VOID(pthread_mutex_unlock(&LOCK_open));
|
|
||||||
DBUG_RETURN(TRUE);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user