List:Commits« Previous MessageNext Message »
From:gluh Date:January 26 2007 12:46pm
Subject:bk commit into 5.1 tree (gluh:1.2410)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of gluh. When gluh 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-01-26 16:46:01+04:00, gluh@eagle.(none) +9 -0
  Merge mysql.com:/home/gluh/MySQL/Merge/5.1-opt
  into  mysql.com:/home/gluh/MySQL/Merge/5.1
  MERGE: 1.2401.1.7

  mysql-test/r/view.result@stripped, 2007-01-26 16:45:57+04:00, gluh@eagle.(none) +0 -0
    Auto merged
    MERGE: 1.197.1.2

  mysql-test/t/innodb.test@stripped, 2007-01-26 16:45:57+04:00, gluh@eagle.(none) +0 -0
    Auto merged
    MERGE: 1.153.1.1

  mysql-test/t/view.test@stripped, 2007-01-26 16:45:57+04:00, gluh@eagle.(none) +0 -0
    Auto merged
    MERGE: 1.177.1.3

  sql/item.h@stripped, 2007-01-26 16:45:57+04:00, gluh@eagle.(none) +0 -0
    Auto merged
    MERGE: 1.219.1.1

  sql/mysqld.cc@stripped, 2007-01-26 16:45:57+04:00, gluh@eagle.(none) +0 -0
    Auto merged
    MERGE: 1.606.1.3

  sql/sql_class.cc@stripped, 2007-01-26 16:45:57+04:00, gluh@eagle.(none) +0 -0
    Auto merged
    MERGE: 1.308.1.2

  sql/sql_insert.cc@stripped, 2007-01-26 16:45:57+04:00, gluh@eagle.(none) +0 -0
    Auto merged
    MERGE: 1.239.1.7

  sql/sql_table.cc@stripped, 2007-01-26 16:45:57+04:00, gluh@eagle.(none) +0 -0
    Auto merged
    MERGE: 1.382.2.2

  sql/sql_update.cc@stripped, 2007-01-26 16:45:58+04:00, gluh@eagle.(none) +0 -0
    Auto merged
    MERGE: 1.216.1.2

# 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:	gluh
# Host:	eagle.(none)
# Root:	/home/gluh/MySQL/Merge/5.1/RESYNC

--- 1.220/sql/item.h	2007-01-24 11:34:51 +04:00
+++ 1.221/sql/item.h	2007-01-26 16:45:57 +04:00
@@ -477,7 +477,8 @@ public:
   Item *next;
   uint32 max_length;
   uint name_length;                     /* Length of name */
-  uint8 marker, decimals;
+  int8 marker;
+  uint8 decimals;
   my_bool maybe_null;			/* If item may be null */
   my_bool null_value;			/* if item is null */
   my_bool unsigned_flag;
@@ -2367,6 +2368,9 @@ public:
   bool fix_fields(THD *, Item **);
   void print(String *str);
   table_map used_tables() const { return (table_map)0L; }
+  Field *get_tmp_table_field() { return 0; }
+  Item *copy_or_same(THD *thd) { return this; }
+  Item *get_tmp_table_item(THD *thd) { return copy_or_same(thd); }
   void cleanup();
 
 private:

--- 1.609/sql/mysqld.cc	2007-01-25 12:26:03 +04:00
+++ 1.610/sql/mysqld.cc	2007-01-26 16:45:57 +04:00
@@ -524,10 +524,13 @@ char *mysqld_unix_port, *opt_mysql_tmpdi
 const char **errmesg;			/* Error messages */
 const char *myisam_recover_options_str="OFF";
 const char *myisam_stats_method_str="nulls_unequal";
+
 /* name of reference on left espression in rewritten IN subquery */
 const char *in_left_expr_name= "<left expr>";
 /* name of additional condition */
 const char *in_additional_cond= "<IN COND>";
+const char *in_having_cond= "<IN HAVING>";
+
 my_decimal decimal_zero;
 /* classes for comparation parsing/processing */
 Eq_creator eq_creator;

--- 1.242/sql/sql_insert.cc	2007-01-25 01:39:48 +04:00
+++ 1.243/sql/sql_insert.cc	2007-01-26 16:45:57 +04:00
@@ -81,6 +81,65 @@ static bool check_view_insertability(THD
 #define my_safe_afree(ptr, size, min_length) if (size > min_length) my_free(ptr,MYF(0))
 #endif
 
+/*
+  Check that insert/update fields are from the same single table of a view.
+
+  SYNOPSIS
+    check_view_single_update()
+    fields            The insert/update fields to be checked.
+    view              The view for insert.
+    map     [in/out]  The insert table map.
+
+  DESCRIPTION
+    This function is called in 2 cases:
+    1. to check insert fields. In this case *map will be set to 0.
+       Insert fields are checked to be all from the same single underlying
+       table of the given view. Otherwise the error is thrown. Found table
+       map is returned in the map parameter.
+    2. to check update fields of the ON DUPLICATE KEY UPDATE clause.
+       In this case *map contains table_map found on the previous call of
+       the function to check insert fields. Update fields are checked to be
+       from the same table as the insert fields.
+
+  RETURN
+    0   OK
+    1   Error
+*/
+
+bool check_view_single_update(List<Item> &fields, TABLE_LIST *view,
+                              table_map *map)
+{
+  /* it is join view => we need to find the table for update */
+  List_iterator_fast<Item> it(fields);
+  Item *item;
+  TABLE_LIST *tbl= 0;            // reset for call to check_single_table()
+  table_map tables= 0;
+
+  while ((item= it++))
+    tables|= item->used_tables();
+
+  /* Check found map against provided map */
+  if (*map)
+  {
+    if (tables != *map)
+      goto error;
+    return FALSE;
+  }
+
+  if (view->check_single_table(&tbl, tables, view) || tbl == 0)
+    goto error;
+
+  view->table= tbl->table;
+  *map= tables;
+
+  return FALSE;
+
+error:
+  my_error(ER_VIEW_MULTIUPDATE, MYF(0),
+           view->view_db.str, view->view_name.str);
+  return TRUE;
+}
+
 
 /*
   Check if insert fields are correct.
@@ -105,7 +164,7 @@ static bool check_view_insertability(THD
 
 static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
                                List<Item> &fields, List<Item> &values,
-                               bool check_unique)
+                               bool check_unique, table_map *map)
 {
   TABLE *table= table_list->table;
 
@@ -183,21 +242,9 @@ static int check_insert_fields(THD *thd,
 
     if (table_list->effective_algorithm == VIEW_ALGORITHM_MERGE)
     {
-      /* it is join view => we need to find table for update */
-      List_iterator_fast<Item> it(fields);
-      Item *item;
-      TABLE_LIST *tbl= 0;            // reset for call to check_single_table()
-      table_map map= 0;
-
-      while ((item= it++))
-        map|= item->used_tables();
-      if (table_list->check_single_table(&tbl, map, table_list) || tbl == 0)
-      {
-        my_error(ER_VIEW_MULTIUPDATE, MYF(0),
-                 table_list->view_db.str, table_list->view_name.str);
+      if (check_view_single_update(fields, table_list, map))
         return -1;
-      }
-      table_list->table= table= tbl->table;
+      table= table_list->table;
     }
 
     if (check_unique && thd->dup_field)
@@ -255,7 +302,7 @@ static int check_insert_fields(THD *thd,
 */
 
 static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list,
-                               List<Item> &update_fields)
+                               List<Item> &update_fields, table_map *map)
 {
   TABLE *table= insert_table_list->table;
   my_bool timestamp_mark;
@@ -276,6 +323,10 @@ static int check_update_fields(THD *thd,
   if (setup_fields(thd, 0, update_fields, MARK_COLUMNS_WRITE, 0, 0))
     return -1;
 
+  if (insert_table_list->effective_algorithm == VIEW_ALGORITHM_MERGE &&
+      check_view_single_update(update_fields, insert_table_list, map))
+    return -1;
+
   if (table->timestamp_field)
   {
     /* Don't set timestamp column if this is modified. */
@@ -892,6 +943,7 @@ bool mysql_prepare_insert(THD *thd, TABL
   Name_resolution_context_state ctx_state;
   bool insert_into_view= (table_list->view != 0);
   bool res= 0;
+  table_map map= 0;
   DBUG_ENTER("mysql_prepare_insert");
   DBUG_PRINT("enter", ("table_list 0x%lx, table 0x%lx, view %d",
 		       (ulong)table_list, (ulong)table,
@@ -940,12 +992,12 @@ bool mysql_prepare_insert(THD *thd, TABL
   /* Prepare the fields in the statement. */
   if (values &&
       !(res= check_insert_fields(thd, context->table_list, fields, *values,
-                                 !insert_into_view) ||
+                                 !insert_into_view, &map) ||
         setup_fields(thd, 0, *values, MARK_COLUMNS_READ, 0, 0)) &&
       duplic == DUP_UPDATE)
   {
     select_lex->no_wrap_view_item= TRUE;
-    res= check_update_fields(thd, context->table_list, update_fields);
+    res= check_update_fields(thd, context->table_list, update_fields, &map);
     select_lex->no_wrap_view_item= FALSE;
     /*
       When we are not using GROUP BY we can refer to other tables in the
@@ -2404,6 +2456,7 @@ select_insert::prepare(List<Item> &value
 {
   LEX *lex= thd->lex;
   int res;
+  table_map map= 0;
   SELECT_LEX *lex_current_select_save= lex->current_select;
   DBUG_ENTER("select_insert::prepare");
 
@@ -2416,7 +2469,7 @@ select_insert::prepare(List<Item> &value
   */
   lex->current_select= &lex->select_lex;
   res= check_insert_fields(thd, table_list, *fields, values,
-                           !insert_into_view) ||
+                           !insert_into_view, &map) ||
        setup_fields(thd, 0, values, MARK_COLUMNS_READ, 0, 0);
 
   if (info.handle_duplicates == DUP_UPDATE)
@@ -2434,7 +2487,7 @@ select_insert::prepare(List<Item> &value
 
     lex->select_lex.no_wrap_view_item= TRUE;
     res= res || check_update_fields(thd, context->table_list,
-                                    *info.update_fields);
+                                    *info.update_fields, &map);
     lex->select_lex.no_wrap_view_item= FALSE;
     /*
       When we are not using GROUP BY we can refer to other tables in the

--- 1.385/sql/sql_table.cc	2007-01-25 15:58:41 +04:00
+++ 1.386/sql/sql_table.cc	2007-01-26 16:45:57 +04:00
@@ -6712,7 +6712,7 @@ copy_data_between_tables(TABLE *from,TAB
   Copy_field *copy,*copy_end;
   ulong found_count,delete_count;
   THD *thd= current_thd;
-  uint length;
+  uint length= 0;
   SORT_FIELD *sortorder;
   READ_RECORD info;
   TABLE_LIST   tables;

--- 1.219/sql/sql_update.cc	2007-01-03 13:28:52 +04:00
+++ 1.220/sql/sql_update.cc	2007-01-26 16:45:58 +04:00
@@ -318,7 +318,7 @@ int mysql_update(THD *thd,
 	to update
         NOTE: filesort will call table->prepare_for_position()
       */
-      uint         length;
+      uint         length= 0;
       SORT_FIELD  *sortorder;
       ha_rows examined_rows;
 

--- 1.200/mysql-test/r/view.result	2007-01-23 04:00:24 +04:00
+++ 1.201/mysql-test/r/view.result	2007-01-26 16:45:57 +04:00
@@ -2060,17 +2060,6 @@ CALL p1();
 DROP PROCEDURE p1;
 DROP VIEW v1;
 DROP TABLE t1;
-create table t1 (f1 tinyint(1), f2 char(1), f3 varchar(1), f4 geometry, f5 datetime);
-create view v1 as select * from t1;
-desc v1;
-Field	Type	Null	Key	Default	Extra
-f1	tinyint(1)	YES		NULL	
-f2	char(1)	YES		NULL	
-f3	varchar(1)	YES		NULL	
-f4	geometry	YES		NULL	
-f5	datetime	YES		NULL	
-drop view v1;
-drop table t1;
 create table t1(f1 datetime);
 insert into t1 values('2005.01.01 12:0:0');
 create view v1 as select f1, subtime(f1, '1:1:1') as sb from t1;
@@ -2972,16 +2961,6 @@ UPDATE t1 SET i= f1();
 DROP FUNCTION f1;
 DROP VIEW v1;
 DROP TABLE t1;
-CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, val INT UNSIGNED NOT NULL);
-CREATE VIEW v1 AS SELECT id, val FROM t1 WHERE val >= 1 AND val <= 5 WITH CHECK OPTION;
-INSERT INTO v1 (val) VALUES (2);
-INSERT INTO v1 (val) VALUES (4);
-INSERT INTO v1 (val) VALUES (6);
-ERROR HY000: CHECK OPTION failed 'test.v1'
-UPDATE v1 SET val=6 WHERE id=2;
-ERROR HY000: CHECK OPTION failed 'test.v1'
-DROP VIEW v1;
-DROP TABLE t1;
 DROP VIEW IF EXISTS v1, v2;
 DROP TABLE IF EXISTS t1;
 CREATE TABLE t1 (i INT AUTO_INCREMENT PRIMARY KEY, j INT);
@@ -3016,6 +2995,17 @@ i	j
 6	3
 DROP VIEW v1, v2;
 DROP TABLE t1;
+CREATE VIEW v AS SELECT !0 * 5 AS x FROM DUAL;
+SHOW CREATE VIEW v;
+View	Create View
+v	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select ((not(0)) * 5) AS `x`
+SELECT !0 * 5 AS x FROM DUAL;
+x
+5
+SELECT * FROM v;
+x
+5
+DROP VIEW v;
 DROP VIEW IF EXISTS v1;
 CREATE VIEW v1 AS SELECT 'The\ZEnd';
 SELECT * FROM v1;
@@ -3026,6 +3016,50 @@ View	Create View
 v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _latin1'The\ZEnd' AS `TheEnd`
 DROP VIEW v1;
 End of 5.0 tests.
+CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, val INT UNSIGNED NOT NULL);
+CREATE VIEW v1 AS SELECT id, val FROM t1 WHERE val >= 1 AND val <= 5 WITH CHECK OPTION;
+INSERT INTO v1 (val) VALUES (2);
+INSERT INTO v1 (val) VALUES (4);
+INSERT INTO v1 (val) VALUES (6);
+ERROR HY000: CHECK OPTION failed 'test.v1'
+UPDATE v1 SET val=6 WHERE id=2;
+ERROR HY000: CHECK OPTION failed 'test.v1'
+DROP VIEW v1;
+DROP TABLE t1;
+DROP VIEW IF EXISTS v1, v2;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (i INT AUTO_INCREMENT PRIMARY KEY, j INT);
+CREATE VIEW v1 AS SELECT j FROM t1;
+CREATE VIEW v2 AS SELECT * FROM t1;
+INSERT INTO t1 (j) VALUES (1);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+1
+INSERT INTO v1 (j) VALUES (2);
+# LAST_INSERT_ID() should not change.
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+1
+INSERT INTO v2 (j) VALUES (3);
+# LAST_INSERT_ID() should be updated.
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+3
+INSERT INTO v1 (j) SELECT j FROM t1;
+# LAST_INSERT_ID() should not change.
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+3
+SELECT * FROM t1;
+i	j
+1	1
+2	2
+3	3
+4	1
+5	2
+6	3
+DROP VIEW v1, v2;
+DROP TABLE t1;
 DROP DATABASE IF EXISTS `d-1`;
 CREATE DATABASE `d-1`;
 USE `d-1`;

--- 1.180/mysql-test/t/view.test	2007-01-23 04:00:24 +04:00
+++ 1.181/mysql-test/t/view.test	2007-01-26 16:45:57 +04:00
@@ -1879,15 +1879,6 @@ DROP VIEW v1;
 DROP TABLE t1;
 
 #
-# Bug #11335 View redefines column types
-#
-create table t1 (f1 tinyint(1), f2 char(1), f3 varchar(1), f4 geometry, f5 datetime);
-create view v1 as select * from t1;
-desc v1;
-drop view v1;
-drop table t1;
-
-#
 # Bug #11760 Typo in Item_func_add_time::print() results in NULLs returned
 #             subtime() in view
 create table t1(f1 datetime);
@@ -2909,6 +2900,71 @@ DROP VIEW v1;
 DROP TABLE t1;
 
 #
+# BUG#22584: last_insert_id not updated after inserting a record
+# through a updatable view
+#
+# We still do not update LAST_INSERT_ID if AUTO_INCREMENT column is
+# not accessible through a view.  However, we do not reset the value
+# of LAST_INSERT_ID, but keep it unchanged.
+#
+--disable_warnings
+DROP VIEW IF EXISTS v1, v2;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (i INT AUTO_INCREMENT PRIMARY KEY, j INT);
+CREATE VIEW v1 AS SELECT j FROM t1;
+CREATE VIEW v2 AS SELECT * FROM t1;
+
+INSERT INTO t1 (j) VALUES (1);
+SELECT LAST_INSERT_ID();
+
+INSERT INTO v1 (j) VALUES (2);
+--echo # LAST_INSERT_ID() should not change.
+SELECT LAST_INSERT_ID();
+
+INSERT INTO v2 (j) VALUES (3);
+--echo # LAST_INSERT_ID() should be updated.
+SELECT LAST_INSERT_ID();
+
+INSERT INTO v1 (j) SELECT j FROM t1;
+--echo # LAST_INSERT_ID() should not change.
+SELECT LAST_INSERT_ID();
+
+SELECT * FROM t1;
+
+DROP VIEW v1, v2;
+DROP TABLE t1;
+
+#
+# Bug #25580: !0 as an operand in a select expression of a view
+#
+
+CREATE VIEW v AS SELECT !0 * 5 AS x FROM DUAL;
+SHOW CREATE VIEW v;
+
+SELECT !0 * 5 AS x FROM DUAL;
+SELECT * FROM v;
+
+DROP VIEW v;
+
+#                                                                                                        
+# BUG#24293: '\Z' token is not handled correctly in views                                                
+#                                                                                                        
+                                                                                                         
+--disable_warnings                                                                                       
+DROP VIEW IF EXISTS v1;                                                                                  
+--enable_warnings                                                                                        
+                                                                                                         
+CREATE VIEW v1 AS SELECT 'The\ZEnd';                                                                     
+SELECT * FROM v1;                                                                                        
+                                                                                                         
+SHOW CREATE VIEW v1;                                                                                     
+                                                                                                         
+DROP VIEW v1;
+
+--echo End of 5.0 tests.
+
 # Bug #16813 (WITH CHECK OPTION doesn't work with UPDATE)
 #
 CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, val INT UNSIGNED NOT NULL);
@@ -2958,23 +3014,6 @@ SELECT * FROM t1;
 
 DROP VIEW v1, v2;
 DROP TABLE t1;
-
-#
-# BUG#24293: '\Z' token is not handled correctly in views
-#
-
---disable_warnings
-DROP VIEW IF EXISTS v1;
---enable_warnings
-
-CREATE VIEW v1 AS SELECT 'The\ZEnd';
-SELECT * FROM v1;
-
-SHOW CREATE VIEW v1;
-
-DROP VIEW v1;
-
---echo End of 5.0 tests.
 
 #
 # Bug#21370 View renaming lacks tablename_to_filename encoding

--- 1.154/mysql-test/t/innodb.test	2007-01-22 21:08:44 +04:00
+++ 1.155/mysql-test/t/innodb.test	2007-01-26 16:45:57 +04:00
@@ -2489,12 +2489,6 @@ SELECT p0.a FROM t2 p0 WHERE BINARY p0.b
 drop table t2, t1;
 
 #
-# Bug #15680 (SPATIAL key in innodb)
-#
---error ER_TABLE_CANT_HANDLE_SPKEYS
-create table t1 (g geometry not null, spatial gk(g)) engine=innodb;
-
-#
 # Test optimize on table with open transaction
 #
 
Thread
bk commit into 5.1 tree (gluh:1.2410)gluh26 Jan