summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <serg@janus.mylan>2007-04-17 12:32:40 +0200
committerunknown <serg@janus.mylan>2007-04-17 12:32:40 +0200
commitd9a964365ba6f7f83962e2101e6297d9661bf4bb (patch)
tree8f0cbafeab82402384c011a45e2e72e9b4107aeb
parent6c98456f65424ed6787aaa9bfa52e58779bc0651 (diff)
parent5234f5adb786718c90bc96280ad598467da69e69 (diff)
downloadmariadb-git-d9a964365ba6f7f83962e2101e6297d9661bf4bb.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-5.0-build
into janus.mylan:/usr/home/serg/Abk/mysql-5.0
-rw-r--r--mysql-test/r/truncate.result26
-rw-r--r--mysql-test/t/truncate.test31
-rw-r--r--sql/sql_delete.cc9
-rw-r--r--sql/sql_lex.cc1
4 files changed, 14 insertions, 53 deletions
diff --git a/mysql-test/r/truncate.result b/mysql-test/r/truncate.result
index 6c21db0e2b8..b194f9b7dc6 100644
--- a/mysql-test/r/truncate.result
+++ b/mysql-test/r/truncate.result
@@ -57,26 +57,6 @@ create table t1 (s1 int);
insert into t1 (s1) values (1), (2), (3), (4), (5);
create view v1 as select * from t1;
truncate table v1;
-select count(*) from t1;
-count(*)
-0
-insert into t1 (s1) values (1), (2), (3), (4), (5);
-create view v2 as select * from t1 where s1 > 3;
-truncate table v2;
-select * from t1;
-s1
-1
-2
-3
-select * from v2;
-s1
-delete from t1;
-create table t2 (s1 int, s2 int);
-create view v3 as select a.s1, b.s2 from t1 a join t2 b on a.s1 = b.s1 where a.s1 > 3;
-truncate table v3;
-ERROR HY000: Can not delete from join view 'test.v3'
-create view v4 as select * from t1 limit 1,1;
-truncate table v4;
-ERROR HY000: The target table v4 of the TRUNCATE is not updatable
-drop view v1, v2, v3, v4;
-drop table t1, t2;
+ERROR 42S02: Table 'test.v1' doesn't exist
+drop view v1;
+drop table t1;
diff --git a/mysql-test/t/truncate.test b/mysql-test/t/truncate.test
index c52260124cb..ba5364bd324 100644
--- a/mysql-test/t/truncate.test
+++ b/mysql-test/t/truncate.test
@@ -54,33 +54,18 @@ drop table t1;
# End of 4.1 tests
# Test for Bug#5507 "TRUNCATE should work with views"
+#
+# when it'll be fixed, the error should become 1347
+# (test.v1' is not BASE TABLE)
+#
create table t1 (s1 int);
-
insert into t1 (s1) values (1), (2), (3), (4), (5);
create view v1 as select * from t1;
+--error 1146
truncate table v1;
-select count(*) from t1;
-
-insert into t1 (s1) values (1), (2), (3), (4), (5);
-create view v2 as select * from t1 where s1 > 3;
-truncate table v2;
-select * from t1;
-select * from v2;
-delete from t1;
-
-# The following should fail
-create table t2 (s1 int, s2 int);
-create view v3 as select a.s1, b.s2 from t1 a join t2 b on a.s1 = b.s1 where a.s1 > 3;
---error 1395
-truncate table v3;
-
-# The following should fail
-create view v4 as select * from t1 limit 1,1;
---error 1288
-truncate table v4;
-
-drop view v1, v2, v3, v4;
-drop table t1, t2;
+drop view v1;
+drop table t1;
# End of 5.0 tests
+
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 6956e5cfe91..19f3135c594 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -369,8 +369,6 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
{
Item *fake_conds= 0;
SELECT_LEX *select_lex= &thd->lex->select_lex;
- const char *operation = thd->lex->sql_command == SQLCOM_TRUNCATE ?
- "TRUNCATE" : "DELETE";
DBUG_ENTER("mysql_prepare_delete");
List<Item> all_fields;
@@ -385,14 +383,14 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
DBUG_RETURN(TRUE);
if (!table_list->updatable || check_key_in_view(thd, table_list))
{
- my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, operation);
+ my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "DELETE");
DBUG_RETURN(TRUE);
}
{
TABLE_LIST *duplicate;
if ((duplicate= unique_table(thd, table_list, table_list->next_global, 0)))
{
- update_non_unique_table_error(table_list, operation, duplicate);
+ update_non_unique_table_error(table_list, "DELETE", duplicate);
DBUG_RETURN(TRUE);
}
}
@@ -897,8 +895,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
if (!dont_send_ok)
{
db_type table_type;
- if (mysql_frm_type(thd, path, &table_type) == FRMTYPE_VIEW)
- goto trunc_by_del;
+ mysql_frm_type(thd, path, &table_type);
if (table_type == DB_TYPE_UNKNOWN)
{
my_error(ER_NO_SUCH_TABLE, MYF(0),
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 4be0aca3ea7..3be844b6761 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1834,7 +1834,6 @@ bool st_lex::can_use_merged()
case SQLCOM_UPDATE_MULTI:
case SQLCOM_DELETE:
case SQLCOM_DELETE_MULTI:
- case SQLCOM_TRUNCATE:
case SQLCOM_INSERT:
case SQLCOM_INSERT_SELECT:
case SQLCOM_REPLACE: