summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <igor@rurik.mysql.com>2005-11-02 13:44:58 -0800
committerunknown <igor@rurik.mysql.com>2005-11-02 13:44:58 -0800
commit8a80936517515360c432312a05db232a5e4c5dba (patch)
treee01d228045f0098813aa9d95c0580a3a9bf7f8c6 /sql
parent02ac7bef876ba51f13c09174da7a706ea35b6613 (diff)
downloadmariadb-git-8a80936517515360c432312a05db232a5e4c5dba.tar.gz
#view.test#:
new file sql_table.cc, handler.h: Fixed bug #14540. Added error mnemonic code HA_ADMIN_NOT_BASE_TABLE to report that an operation cannot be applied for views. view.test, view.result: Added a test case for bug #14540. errmsg.txt: Fixed bug #14540. Added error ER_CHECK_NOT_BASE_TABLE. mysql-test/r/view.result: Added a test case for bug #14540. mysql-test/t/view.test: Added a test case for bug #14540. sql/handler.h: Fixed bug #14540. Added error mnemonic code HA_ADMIN_NOT_BASE_TABLE to report that an operation cannot be applied for views. sql/share/errmsg.txt: Added error ER_CHECK_NOT_BASE_TABLE. sql/sql_table.cc: Fixed bug #14540. Added error mnemonic code HA_ADMIN_NOT_BASE_TABLE to report that an operation cannot be applied for views.
Diffstat (limited to 'sql')
-rw-r--r--sql/handler.h1
-rw-r--r--sql/share/errmsg.txt2
-rw-r--r--sql/sql_table.cc33
3 files changed, 26 insertions, 10 deletions
diff --git a/sql/handler.h b/sql/handler.h
index af80f021e75..16eb8dc6f02 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -45,6 +45,7 @@
#define HA_ADMIN_REJECT -6
#define HA_ADMIN_TRY_ALTER -7
#define HA_ADMIN_WRONG_CHECKSUM -8
+#define HA_ADMIN_NOT_BASE_TABLE -9
/* Bits in table_flags() to show what database can do */
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index f85bda90e81..0174a1ef98e 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -5421,3 +5421,5 @@ ER_NO_REFERENCED_ROW_2 23000
eng "Cannot add or update a child row: a foreign key constraint fails (%.192s)"
ER_SP_BAD_VAR_SHADOW 42000
eng "Variable '%-.64s' must be quoted with `...`, or renamed"
+ER_CHECK_NOT_BASE_TABLE 4200
+ eng "You cannot apply %s to a view"
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index b635c44c6dc..80b337e61d5 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -2189,7 +2189,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
/* if view are unsupported */
if (table->view && view_operator_func == NULL)
{
- result_code= HA_ADMIN_NOT_IMPLEMENTED;
+ result_code= HA_ADMIN_NOT_BASE_TABLE;
goto send_result;
}
thd->open_options&= ~extra_open_options;
@@ -2324,6 +2324,16 @@ send_result_message:
}
break;
+ case HA_ADMIN_NOT_BASE_TABLE:
+ {
+ char buf[ERRMSGSIZE+20];
+ uint length=my_snprintf(buf, ERRMSGSIZE,
+ ER(ER_CHECK_NOT_BASE_TABLE), operator_name);
+ protocol->store("note", 4, system_charset_info);
+ protocol->store(buf, length, system_charset_info);
+ }
+ break;
+
case HA_ADMIN_OK:
protocol->store("status", 6, system_charset_info);
protocol->store("OK",2, system_charset_info);
@@ -2424,16 +2434,19 @@ send_result_message:
break;
}
}
- if (fatal_error)
- table->table->s->version=0; // Force close of table
- else if (open_for_modify)
+ if (table->table)
{
- pthread_mutex_lock(&LOCK_open);
- remove_table_from_cache(thd, table->table->s->db,
- table->table->s->table_name, RTFC_NO_FLAG);
- pthread_mutex_unlock(&LOCK_open);
- /* May be something modified consequently we have to invalidate cache */
- query_cache_invalidate3(thd, table->table, 0);
+ if (fatal_error)
+ table->table->s->version=0; // Force close of table
+ else if (open_for_modify)
+ {
+ pthread_mutex_lock(&LOCK_open);
+ remove_table_from_cache(thd, table->table->s->db,
+ table->table->s->table_name, RTFC_NO_FLAG);
+ pthread_mutex_unlock(&LOCK_open);
+ /* Something may be modified, that's why we have to invalidate cache */
+ query_cache_invalidate3(thd, table->table, 0);
+ }
}
close_thread_tables(thd);
table->table=0; // For query cache