List:Commits« Previous MessageNext Message »
From:ramil Date:October 9 2007 2:16pm
Subject:bk commit into 5.1 tree (ramil:1.2582) BUG#29444
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of ram. When ram 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@stripped, 2007-10-09 19:16:39+05:00, ramil@stripped +6 -0
  Fix for bug #29444: crash with partition refering to table in create-select
  
  Problem: creating a partitioned table during name resolution for the 
  partition function we search for column names in all parts of the
  CREATE TABLE query. It is superfluous (and wrong) sometimes.
  
  Fix: launch name resolution for the partition function against
  the table we're creating.

  mysql-test/r/partition.result@stripped, 2007-10-09 19:16:36+05:00, ramil@stripped +20 -0
    Fix for bug #29444: crash with partition refering to table in create-select
      - test result.

  mysql-test/t/partition.test@stripped, 2007-10-09 19:16:36+05:00, ramil@stripped +20 -0
    Fix for bug #29444: crash with partition refering to table in create-select
      - test result.

  sql/item.cc@stripped, 2007-10-09 19:16:36+05:00, ramil@stripped +3 -1
    Fix for bug #29444: crash with partition refering to table in create-select
      - LEX::use_only_table_context introduced, which is used in the 
        Item_field::fix_fields() to resolve names only against
        context->first_name_resolution_table/last_name_resolution_table.

  sql/sql_lex.cc@stripped, 2007-10-09 19:16:36+05:00, ramil@stripped +1 -0
    Fix for bug #29444: crash with partition refering to table in create-select
      - LEX::use_only_table_context introduced, which is used in the 
        Item_field::fix_fields() to resolve names only against
        context->first_name_resolution_table/last_name_resolution_table.

  sql/sql_lex.h@stripped, 2007-10-09 19:16:36+05:00, ramil@stripped +8 -0
    Fix for bug #29444: crash with partition refering to table in create-select
      - LEX::use_only_table_context introduced, which is used in the 
        Item_field::fix_fields() to resolve names only against
        context->first_name_resolution_table/last_name_resolution_table.

  sql/sql_partition.cc@stripped, 2007-10-09 19:16:37+05:00, ramil@stripped +7 -0
    Fix for bug #29444: crash with partition refering to table in create-select
      - set the lex->use_only_table_context before the func_expr->fix_fields()
        call to ensure we're resolving names against the table we're creating;
        then restore it back after the call.

diff -Nrup a/mysql-test/r/partition.result b/mysql-test/r/partition.result
--- a/mysql-test/r/partition.result	2007-07-02 23:11:52 +05:00
+++ b/mysql-test/r/partition.result	2007-10-09 19:16:36 +05:00
@@ -1267,4 +1267,24 @@ ALTER TABLE general_log PARTITION BY RAN
 ERROR HY000: Incorrect usage of PARTITION and log table
 ALTER TABLE general_log ENGINE = CSV;
 SET GLOBAL general_log = default;
+use test;
+create table t2 (b int);
+create table t1 (b int)
+PARTITION BY RANGE (t2.b) (
+PARTITION p1 VALUES LESS THAN (10),
+PARTITION p2 VALUES LESS THAN (20)
+) select * from t2;
+ERROR 42S22: Unknown column 't2.b' in 'partition function'
+create table t1 (a int)
+PARTITION BY RANGE (b) (
+PARTITION p1 VALUES LESS THAN (10),
+PARTITION p2 VALUES LESS THAN (20)
+) select * from t2;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) DEFAULT NULL,
+  `b` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (b) (PARTITION p1 VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION p2 VALUES LESS THAN (20) ENGINE = MyISAM) */
+drop table t1, t2;
 End of 5.1 tests
diff -Nrup a/mysql-test/t/partition.test b/mysql-test/t/partition.test
--- a/mysql-test/t/partition.test	2007-07-02 23:11:52 +05:00
+++ b/mysql-test/t/partition.test	2007-10-09 19:16:36 +05:00
@@ -1493,10 +1493,30 @@ ALTER TABLE general_log PARTITION BY RAN
   (PARTITION p0 VALUES LESS THAN (733144), PARTITION p1 VALUES LESS THAN (3000000));
 ALTER TABLE general_log ENGINE = CSV;
 SET GLOBAL general_log = default;
+use test;
 
 #
 # Bug #27084 partitioning by list seems failing when using case 
 # BUG #18198: Case no longer supported, test case removed
 #
+
+#
+# Bug #29444: crash with partition refering to table in create-select
+#
+
+create table t2 (b int);
+--error 1054
+create table t1 (b int)
+PARTITION BY RANGE (t2.b) (
+  PARTITION p1 VALUES LESS THAN (10),
+  PARTITION p2 VALUES LESS THAN (20)
+) select * from t2;
+create table t1 (a int)
+PARTITION BY RANGE (b) (
+  PARTITION p1 VALUES LESS THAN (10),
+  PARTITION p2 VALUES LESS THAN (20)
+) select * from t2;
+show create table t1;
+drop table t1, t2;
 
 --echo End of 5.1 tests
diff -Nrup a/sql/item.cc b/sql/item.cc
--- a/sql/item.cc	2007-10-05 15:56:22 +05:00
+++ b/sql/item.cc	2007-10-09 19:16:36 +05:00
@@ -3860,7 +3860,9 @@ bool Item_field::fix_fields(THD *thd, It
                                           context->first_name_resolution_table,
                                           context->last_name_resolution_table,
                                           reference,
-                                          IGNORE_EXCEPT_NON_UNIQUE,
+                                          thd->lex->use_only_table_context ?
+                                            REPORT_ALL_ERRORS : 
+                                            IGNORE_EXCEPT_NON_UNIQUE,
                                           !any_privileges,
                                           TRUE)) ==
 	not_found_field)
diff -Nrup a/sql/sql_lex.cc b/sql/sql_lex.cc
--- a/sql/sql_lex.cc	2007-09-19 20:02:56 +05:00
+++ b/sql/sql_lex.cc	2007-10-09 19:16:36 +05:00
@@ -338,6 +338,7 @@ void lex_start(THD *thd)
   lex->query_tables= 0;
   lex->reset_query_tables_list(FALSE);
   lex->expr_allows_subselect= TRUE;
+  lex->use_only_table_context= FALSE;
 
   lex->name.str= 0;
   lex->name.length= 0;
diff -Nrup a/sql/sql_lex.h b/sql/sql_lex.h
--- a/sql/sql_lex.h	2007-09-13 00:44:47 +05:00
+++ b/sql/sql_lex.h	2007-10-09 19:16:36 +05:00
@@ -1693,6 +1693,14 @@ typedef struct st_lex : public Query_tab
   */
   const char *fname_start;
   const char *fname_end;
+  
+  /**
+    During name resolution search only in the table list given by 
+    Name_resolution_context::first_name_resolution_table and
+    Name_resolution_context::last_name_resolution_table
+    (see Item_field::fix_fields()). 
+  */
+  bool use_only_table_context;
 
   LEX_STRING view_body_utf8;
 
diff -Nrup a/sql/sql_partition.cc b/sql/sql_partition.cc
--- a/sql/sql_partition.cc	2007-09-14 15:17:40 +05:00
+++ b/sql/sql_partition.cc	2007-10-09 19:16:37 +05:00
@@ -902,6 +902,7 @@ bool fix_fields_part_func(THD *thd, Item
   const char *save_where;
   char* db_name;
   char db_name_string[FN_REFLEN];
+  bool save_use_only_table_context;
   DBUG_ENTER("fix_fields_part_func");
 
   if (part_info->fixed)
@@ -958,7 +959,13 @@ bool fix_fields_part_func(THD *thd, Item
     This is a tricky call to prepare for since it can have a large number
     of interesting side effects, both desirable and undesirable.
   */
+
+  save_use_only_table_context= thd->lex->use_only_table_context;
+  thd->lex->use_only_table_context= TRUE;
+  
   error= func_expr->fix_fields(thd, (Item**)0);
+
+  thd->lex->use_only_table_context= save_use_only_table_context;
 
   context->table_list= save_table_list;
   context->first_name_resolution_table= save_first_table;
Thread
bk commit into 5.1 tree (ramil:1.2582) BUG#29444ramil9 Oct