List:Internals« Previous MessageNext Message »
From:sanja Date:April 3 2005 12:23am
Subject:bk commit into 5.0 tree (bell:1.1855) BUG#8703
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of bell. When bell 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.1855 05/04/03 01:23:45 bell@stripped +4 -0
  - stackoverflow check added for view of view processing
  - fixed bug in join view processing
  - postreview fixes (BUG#9398 & BUG#8703)

  sql/table.h
    1.95 05/04/03 01:23:41 bell@stripped +2 -1
    comment fixed
    new method for underlying base table finding

  sql/table.cc
    1.158 05/04/03 01:23:41 bell@stripped +32 -1
    comment fixed
    stack overflow check added
    new method for underlying base table finding

  sql/sql_view.cc
    1.39 05/04/03 01:23:41 bell@stripped +4 -4
    fixed bug of assigning select_lex for join view

  sql/sql_base.cc
    1.232 05/04/03 01:23:40 bell@stripped +24 -21
    used original TABLE object to get correct name of table and 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:	bell
# Host:	sanja.is.com.ua
# Root:	/home/bell/mysql/bk/work-multi-5.0

--- 1.231/sql/sql_base.cc	Mon Mar 28 15:12:28 2005
+++ 1.232/sql/sql_base.cc	Sun Apr  3 01:23:40 2005
@@ -724,31 +724,34 @@
 TABLE_LIST* unique_table(TABLE_LIST *table, TABLE_LIST *table_list)
 {
   TABLE_LIST *res;
-  const char *d_name= table->db, *t_name= table->table_name;
-  char d_name_buff[MAX_ALIAS_NAME], t_name_buff[MAX_ALIAS_NAME];
+  const char *d_name, *t_name;
   DBUG_ENTER("unique_table");
   DBUG_PRINT("enter", ("table alias: %s", table->alias));
-  /* temporary table is always unique */
-  if (table->table && table->table->s->tmp_table != NO_TMP_TABLE)
-    DBUG_RETURN(0);
-  if (table->view)
+
+  /*
+    If this function called for query which update table (INSERT/UPDATE/...)
+    then we have in table->table pointer to TABLE object which we are
+    updating even if it is VIEW so we need TABLE_LIST of this TABLE object
+    to get right names (even if lower_case_table_names used).
+
+    If this function called for CREATE command that we have not opened table
+    (table->table equal to 0) and right names is in current TABLE_LIST
+    object.
+  */
+  if (table->table)
   {
-    /* it is view and table opened */
-    if (lower_case_table_names)
-    {
-      strmov(t_name_buff, table->table->alias);
-      my_casedn_str(files_charset_info, t_name_buff);
-      t_name= t_name_buff;
-      strmov(d_name_buff, table->table->s->db);
-      my_casedn_str(files_charset_info, d_name_buff);
-      d_name= d_name_buff;
-    }
-    else
-    {
-      d_name= table->table->s->db;
-      t_name= table->table->alias;
-    }
+    /* temporary table is always unique */
+    if (table->table && table->table->s->tmp_table != NO_TMP_TABLE)
+      DBUG_RETURN(0);
+    table= table->find_underlying_table(table->table);
+    /*
+      as far as we have table->table we have to find real TABLE_LIST of
+      it in underlying tables
+    */
+    DBUG_ASSERT(table);
   }
+  d_name= table->db;
+  t_name= table->table_name;
 
   DBUG_PRINT("info", ("real table: %s.%s", d_name, t_name));
   for(;;)

--- 1.157/sql/table.cc	Wed Mar 23 10:32:42 2005
+++ 1.158/sql/table.cc	Sun Apr  3 01:23:41 2005
@@ -1716,7 +1716,7 @@
     check_opt_type  - WHITH CHECK OPTION type (VIEW_CHECK_NONE,
                       VIEW_CHECK_LOCAL, VIEW_CHECK_CASCADED)
   NOTES
-    ancestor is list of tables and views used by view
+    ancestor is list of tables and views used by view (underlying tables/views)
 
   DESCRIPTION
     It is:
@@ -1750,6 +1750,9 @@
   bool res= FALSE;
   DBUG_ENTER("st_table_list::setup_ancestor");
 
+  if (check_stack_overrun(thd, (char *)&res))
+    return TRUE;
+
   for (tbl= ancestor; tbl; tbl= tbl->next_local)
   {
     if (tbl->ancestor &&
@@ -1985,6 +1988,34 @@
   DBUG_RETURN(res);
 }
 
+
+/*
+  Find underlying base tables (TABLE_LIST) which represent given
+  table_to_find (TABLE)
+
+  SYNOPSIS
+    st_table_list::find_underlying_table()
+    table_to_find table to find
+
+  RETURN
+    0  table is not found
+    found table reference
+*/
+
+st_table_list *st_table_list::find_underlying_table(TABLE *table_to_find)
+{
+  /* is this real table and table which we are looking for? */
+  if (table == table_to_find && ancestor == 0)
+    return this;
+
+  for (TABLE_LIST *tbl= ancestor; tbl; tbl= tbl->next_local)
+  {
+    TABLE_LIST *result;
+    if ((result= tbl->find_underlying_table(table_to_find)))
+      return result;
+  }
+  return 0;
+}
 
 /*
   cleunup items belonged to view fields translation table

--- 1.94/sql/table.h	Thu Mar 31 10:39:43 2005
+++ 1.95/sql/table.h	Sun Apr  3 01:23:41 2005
@@ -376,7 +376,7 @@
   st_select_lex	*select_lex;
   st_lex	*view;			/* link on VIEW lex for merging */
   Field_translator *field_translation;	/* array of VIEW fields */
-  /* ancestor of this table (VIEW merge algorithm) */
+  /* list of ancestor(s) of this table (underlying table(s)/view(s) */
   st_table_list	*ancestor;
   /* most upper view this table belongs to */
   st_table_list	*belong_to_view;
@@ -448,6 +448,7 @@
   void restore_want_privilege();
   bool check_single_table(st_table_list **table, table_map map);
   bool set_insert_values(MEM_ROOT *mem_root);
+  st_table_list *find_underlying_table(TABLE *table);
 } TABLE_LIST;
 
 class Item;

--- 1.38/sql/sql_view.cc	Fri Apr  1 02:13:23 2005
+++ 1.39/sql/sql_view.cc	Sun Apr  3 01:23:41 2005
@@ -755,17 +755,17 @@
 
       table->ancestor= view_tables;
 
-      /* next table should include SELECT_LEX under this table SELECT_LEX */
-      table->ancestor->select_lex= table->select_lex;
-
       /*
         Process upper level tables of view. As far as we do noy suport union
         here we can go through local tables of view most upper SELECT
       */
-      for(tbl= (TABLE_LIST*)view_select->table_list.first;
+      for(tbl= view_tables;
           tbl;
           tbl= tbl->next_local)
       {
+        /* next table should include SELECT_LEX under this table SELECT_LEX */
+        tbl->select_lex= table->select_lex;
+
         /*
           move lock type (TODO: should we issue error in case of TMPTABLE
           algorithm and non-read locking)?
Thread
bk commit into 5.0 tree (bell:1.1855) BUG#8703sanja3 Apr