MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:igor Date:November 2 2005 9:45pm
Subject:bk commit into 5.0 tree (igor:1.1963) BUG#14540
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor 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.1963 05/11/02 13:44:58 igor@stripped +5 -0
  #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.

  sql/sql_table.cc
    1.279 05/11/02 13:44:53 igor@stripped +23 -10
    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
    1.52 05/11/02 13:44:52 igor@stripped +2 -0
    Added error ER_CHECK_NOT_BASE_TABLE.

  sql/handler.h
    1.162 05/11/02 13:44:52 igor@stripped +1 -0
    Fixed bug #14540.
    Added error mnemonic code HA_ADMIN_NOT_BASE_TABLE
    to report that an operation cannot be applied for views.

  mysql-test/t/view.test
    1.118 05/11/02 13:44:52 igor@stripped +15 -0
    Added a test case for bug #14540.

  mysql-test/r/view.result
    1.127 05/11/02 13:44:52 igor@stripped +19 -0
    Added a test case for bug #14540.

# 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:	igor
# Host:	rurik.mysql.com
# Root:	/home/igor/dev/mysql-5.0-0

--- 1.161/sql/handler.h	2005-10-10 11:01:36 -07:00
+++ 1.162/sql/handler.h	2005-11-02 13:44:52 -08:00
@@ -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 */
 

--- 1.278/sql/sql_table.cc	2005-10-28 15:36:53 -07:00
+++ 1.279/sql/sql_table.cc	2005-11-02 13:44:53 -08:00
@@ -2189,7 +2189,7 @@
     /* 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 @@
       }
       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 @@
         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

--- 1.51/sql/share/errmsg.txt	2005-10-27 14:18:11 -07:00
+++ 1.52/sql/share/errmsg.txt	2005-11-02 13:44:52 -08:00
@@ -5421,3 +5421,5 @@
 	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"

--- 1.126/mysql-test/r/view.result	2005-10-28 05:50:29 -07:00
+++ 1.127/mysql-test/r/view.result	2005-11-02 13:44:52 -08:00
@@ -2323,3 +2323,22 @@
 1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	3	Using where
 DROP VIEW v1,v2;
 DROP TABLE t1,t2,t3;
+CREATE TABLE t1(id INT) ENGINE=MyISAM;
+CREATE VIEW v1 AS SELECT id FROM t1;
+OPTIMIZE TABLE v1;
+Table	Op	Msg_type	Msg_text
+test.v1	optimize	note	You cannot apply optimize to a view
+ANALYZE TABLE v1;
+Table	Op	Msg_type	Msg_text
+test.v1	analyze	note	You cannot apply analyze to a view
+REPAIR TABLE v1;
+Table	Op	Msg_type	Msg_text
+test.v1	repair	note	You cannot apply repair to a view
+DROP TABLE t1;
+OPTIMIZE TABLE v1;
+Table	Op	Msg_type	Msg_text
+test.v1	optimize	note	You cannot apply optimize to a view
+Warnings:
+Error	1146	Table 'test.t1' doesn't exist
+Error	1356	View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
+DROP VIEW v1;

--- 1.117/mysql-test/t/view.test	2005-10-28 03:11:24 -07:00
+++ 1.118/mysql-test/t/view.test	2005-11-02 13:44:52 -08:00
@@ -2189,4 +2189,19 @@
 DROP VIEW v1,v2;
 DROP TABLE t1,t2,t3;
 
+#
+# Bug #14540: OPTIMIZE, ANALYZE, REPAIR applied to not a view
+#
+
+CREATE TABLE t1(id INT) ENGINE=MyISAM;
+CREATE VIEW v1 AS SELECT id FROM t1;
+
+OPTIMIZE TABLE v1;
+ANALYZE TABLE v1;
+REPAIR TABLE v1;
+
+DROP TABLE t1;
+OPTIMIZE TABLE v1;
+
+DROP VIEW v1;
 
Thread
bk commit into 5.0 tree (igor:1.1963) BUG#14540igor2 Nov