List:Commits« Previous MessageNext Message »
From:Gleb Shchepa Date:September 18 2008 11:13am
Subject:bzr push into mysql-6.0 branch (gshchepa:2835 to 2836)
View as plain text  
 2836 Gleb Shchepa	2008-09-18 [merge]
      merge 5.1-5.1.29-rc --> 6.0-5.1.29-rc
modified:
  client/mysqldump.c
  mysql-test/r/events_2.result
  mysql-test/r/mysqldump-max.result
  mysql-test/r/mysqldump.result
  mysql-test/r/user_var.result
  mysql-test/t/events_2.test
  mysql-test/t/mysqldump-max.test
  mysql-test/t/user_var.test
  sql/event_db_repository.cc
  sql/event_parse_data.cc
  sql/event_parse_data.h
  sql/item_func.cc
  sql/item_func.h
  sql/sql_base.cc
  sql/sql_lex.cc
  sql/sql_lex.h
  sql/sql_yacc.yy

 2835 Georgi Kodinov	2008-09-12
       Bug#38342 -backup_myisam1 test fails on Windows
       The problem is that  this test, uses file locking and myisam unlocks 
       the same file region twice. Unix my_lock implementation based on fcntl() 
       does not return error in this case, but Windows UnlockFile() returns 
       ERROR_NOT_LOCKED.
            
       Fixed by ignoring ERROR_NOT_LOCKED from UnlockFile(). This fix does 
       not make myisam  better, but at least the implementation of my_lock() 
       compatible to *nix.
modified:
  mysys/my_lock.c

=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2008-05-29 15:44:11 +0000
+++ b/client/mysqldump.c	2008-09-18 09:06:39 +0000
@@ -2446,8 +2446,15 @@ static uint get_table_structure(char *ta
             fprintf(sql_file, ",\n  %s %s",
                     quote_name(row[0], name_buff, 0), row[1]);
           }
+
+          /*
+            Stand-in tables are always MyISAM tables as the default
+            engine might have a column-limit that's lower than the
+            number of columns in the view, and MyISAM support is
+            guaranteed to be in the server anyway.
+          */
           fprintf(sql_file,
-                  "\n) */;\n"
+                  "\n) ENGINE=MyISAM */;\n"
                   "SET character_set_client = @saved_cs_client;\n");
 
           check_io(sql_file);

=== modified file 'mysql-test/r/events_2.result'
--- a/mysql-test/r/events_2.result	2008-05-13 12:06:32 +0000
+++ b/mysql-test/r/events_2.result	2008-08-18 11:05:51 +0000
@@ -328,4 +328,81 @@ create event
 ����������_����������_��������_66
 on schedule every 2 year do select 1;
 ERROR 42000: Identifier name '�������������_����������������' is too long
+create event event_35981 on schedule every 6 month on completion preserve
+disable
+do
+select 1;
+The following SELECTs should all give 1
+select  count(*) from information_schema.events
+where   event_schema = database() and event_name = 'event_35981' and
+on_completion = 'PRESERVE';
+count(*)
+1
+alter   event event_35981 enable;
+select  count(*) from information_schema.events
+where   event_schema = database() and event_name = 'event_35981' and
+on_completion = 'PRESERVE';
+count(*)
+1
+alter   event event_35981 on completion not preserve;
+select  count(*) from information_schema.events
+where   event_schema = database() and event_name = 'event_35981' and
+on_completion = 'NOT PRESERVE';
+count(*)
+1
+alter   event event_35981 disable;
+select  count(*) from information_schema.events
+where   event_schema = database() and event_name = 'event_35981' and
+on_completion = 'NOT PRESERVE';
+count(*)
+1
+alter   event event_35981 on completion preserve;
+select  count(*) from information_schema.events
+where   event_schema = database() and event_name = 'event_35981' and
+on_completion = 'PRESERVE';
+count(*)
+1
+drop event event_35981;
+create event event_35981 on schedule every 6 month disable
+do
+select 1;
+select  count(*) from information_schema.events
+where   event_schema = database() and event_name = 'event_35981' and
+on_completion = 'NOT PRESERVE';
+count(*)
+1
+drop event event_35981;
+create event event_35981 on schedule every 1 hour starts current_timestamp
+on completion not preserve
+do
+select 1;
+alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00'
+  ends '1999-01-02 00:00:00';
+ERROR HY000: Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation.
+drop event event_35981;
+create event event_35981 on schedule every 1 hour starts current_timestamp
+on completion not preserve
+do
+select 1;
+alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00'
+  ends '1999-01-02 00:00:00' on completion preserve;
+Warnings:
+Note	1544	Event execution time is in the past. Event has been disabled
+drop event event_35981;
+create event event_35981 on schedule every 1 hour starts current_timestamp
+on completion preserve
+do
+select 1;
+alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00'
+  ends '1999-01-02 00:00:00';
+Warnings:
+Note	1544	Event execution time is in the past. Event has been disabled
+alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00'
+  ends '1999-01-02 00:00:00' on completion not preserve;
+ERROR HY000: Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation.
+alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00'
+  ends '1999-01-02 00:00:00' on completion preserve;
+Warnings:
+Note	1544	Event execution time is in the past. Event has been disabled
+drop event event_35981;
 drop database events_test;

=== modified file 'mysql-test/r/mysqldump-max.result'
--- a/mysql-test/r/mysqldump-max.result	2007-07-27 17:30:43 +0000
+++ b/mysql-test/r/mysqldump-max.result	2008-09-11 06:14:19 +0000
@@ -277,3 +277,16 @@ drop table t3;
 drop table t4;
 drop table t5;
 drop table t6;
+SELECT @@global.storage_engine INTO @old_engine;
+SET GLOBAL storage_engine=InnoDB;
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 VALUES();
+SELECT COUNT(*) FROM v1;
+COUNT(*)
+1
+SELECT COUNT(*) FROM v1;
+COUNT(*)
+1
+DROP VIEW  v1;
+DROP TABLE t1;
+SET GLOBAL storage_engine=@old_engine;

=== modified file 'mysql-test/r/mysqldump.result'
--- a/mysql-test/r/mysqldump.result	2008-06-28 11:00:59 +0000
+++ b/mysql-test/r/mysqldump.result	2008-09-18 09:06:39 +0000
@@ -2000,7 +2000,7 @@ SET @saved_cs_client     = @@character_s
 SET character_set_client = utf8;
 /*!50001 CREATE TABLE `v2` (
   `a` varchar(30)
-) */;
+) ENGINE=MyISAM */;
 SET character_set_client = @saved_cs_client;
 /*!50001 DROP TABLE `v2`*/;
 /*!50001 DROP VIEW IF EXISTS `v2`*/;
@@ -2097,7 +2097,7 @@ SET @saved_cs_client     = @@character_s
 SET character_set_client = utf8;
 /*!50001 CREATE TABLE `v1` (
   `a` int(11)
-) */;
+) ENGINE=MyISAM */;
 SET character_set_client = @saved_cs_client;
 /*!50001 DROP TABLE `v1`*/;
 /*!50001 DROP VIEW IF EXISTS `v1`*/;
@@ -2171,7 +2171,7 @@ SET @saved_cs_client     = @@character_s
 SET character_set_client = utf8;
 /*!50001 CREATE TABLE `v2` (
   `a` varchar(30)
-) */;
+) ENGINE=MyISAM */;
 SET character_set_client = @saved_cs_client;
 /*!50001 DROP TABLE `v2`*/;
 /*!50001 DROP VIEW IF EXISTS `v2`*/;
@@ -2287,7 +2287,7 @@ SET character_set_client = utf8;
   `a` int(11),
   `b` int(11),
   `c` varchar(30)
-) */;
+) ENGINE=MyISAM */;
 SET character_set_client = @saved_cs_client;
 DROP TABLE IF EXISTS `v2`;
 /*!50001 DROP VIEW IF EXISTS `v2`*/;
@@ -2295,7 +2295,7 @@ SET @saved_cs_client     = @@character_s
 SET character_set_client = utf8;
 /*!50001 CREATE TABLE `v2` (
   `a` int(11)
-) */;
+) ENGINE=MyISAM */;
 SET character_set_client = @saved_cs_client;
 DROP TABLE IF EXISTS `v3`;
 /*!50001 DROP VIEW IF EXISTS `v3`*/;
@@ -2305,7 +2305,7 @@ SET character_set_client = utf8;
   `a` int(11),
   `b` int(11),
   `c` varchar(30)
-) */;
+) ENGINE=MyISAM */;
 SET character_set_client = @saved_cs_client;
 /*!50001 DROP TABLE `v1`*/;
 /*!50001 DROP VIEW IF EXISTS `v1`*/;
@@ -3042,7 +3042,7 @@ SET character_set_client = utf8;
   `a` int(11),
   `b` varchar(32),
   `c` varchar(32)
-) */;
+) ENGINE=MyISAM */;
 SET character_set_client = @saved_cs_client;
 DROP TABLE IF EXISTS `v1`;
 /*!50001 DROP VIEW IF EXISTS `v1`*/;
@@ -3052,7 +3052,7 @@ SET character_set_client = utf8;
   `a` int(11),
   `b` varchar(32),
   `c` varchar(32)
-) */;
+) ENGINE=MyISAM */;
 SET character_set_client = @saved_cs_client;
 DROP TABLE IF EXISTS `v2`;
 /*!50001 DROP VIEW IF EXISTS `v2`*/;
@@ -3062,7 +3062,7 @@ SET character_set_client = utf8;
   `a` int(11),
   `b` varchar(32),
   `c` varchar(32)
-) */;
+) ENGINE=MyISAM */;
 SET character_set_client = @saved_cs_client;
 
 USE `test`;
@@ -3442,7 +3442,7 @@ SET @saved_cs_client     = @@character_s
 SET character_set_client = utf8;
 /*!50001 CREATE TABLE `v1` (
   `id` int(11)
-) */;
+) ENGINE=MyISAM */;
 SET character_set_client = @saved_cs_client;
 
 USE `mysqldump_test_db`;
@@ -3502,7 +3502,7 @@ SET @saved_cs_client     = @@character_s
 SET character_set_client = utf8;
 /*!50001 CREATE TABLE `nasishnasifu` (
   `id` bigint(20) unsigned
-) */;
+) ENGINE=MyISAM */;
 SET character_set_client = @saved_cs_client;
 
 USE `mysqldump_tables`;
@@ -3960,7 +3960,7 @@ SET @saved_cs_client     = @@character_s
 SET character_set_client = utf8;
 /*!50001 CREATE TABLE `v1` (
   `id` int(11)
-) */;
+) ENGINE=MyISAM */;
 SET character_set_client = @saved_cs_client;
 
 USE `mysqldump_test_db`;

=== modified file 'mysql-test/r/user_var.result'
--- a/mysql-test/r/user_var.result	2007-12-13 12:59:16 +0000
+++ b/mysql-test/r/user_var.result	2008-09-18 09:06:39 +0000
@@ -121,8 +121,8 @@ select @a:=0;
 select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i;
 @a+0	@a:=@a+0+count(*)	count(*)	@a+0
 0	1	1	0
-1	3	2	0
-3	6	3	0
+0	2	2	0
+0	3	3	0
 set @a=0;
 select @a,@a:="hello",@a,@a:=3,@a,@a:="hello again" from t1 group by i;
 @a	@a:="hello"	@a	@a:=3	@a	@a:="hello again"
@@ -370,4 +370,33 @@ select @rownum := @rownum + 1 as row,
 @prev_score := a as score
 from t1 order by score desc;
 drop table t1;
+create table t1(b bigint);
+insert into t1 (b) values (10), (30), (10);
+set @var := 0;
+select if(b=@var, 999, b) , @var := b from t1  order by b;
+if(b=@var, 999, b)	@var := b
+10	10
+999	10
+30	30
+drop table t1;
+create temporary table t1 (id int);
+insert into t1 values (2), (3), (3), (4);
+set @lastid=-1;
+select @lastid != id, @lastid, @lastid := id from t1;
+@lastid != id	@lastid	@lastid := id
+1	-1	2
+1	2	3
+0	3	3
+1	3	4
+drop table t1;
+create temporary table t1 (id bigint);
+insert into t1 values (2), (3), (3), (4);
+set @lastid=-1;
+select @lastid != id, @lastid, @lastid := id from t1;
+@lastid != id	@lastid	@lastid := id
+1	-1	2
+1	2	3
+0	3	3
+1	3	4
+drop table t1;
 End of 5.1 tests

=== modified file 'mysql-test/t/events_2.test'
--- a/mysql-test/t/events_2.test	2008-05-13 12:06:32 +0000
+++ b/mysql-test/t/events_2.test	2008-08-18 11:05:51 +0000
@@ -411,6 +411,108 @@ create event
 ����������_��_66
 on schedule every 2 year do select 1;
 
+#
+# Bug#35981: ALTER EVENT causes the server to change the PRESERVE option.
+#
+
+create event event_35981 on schedule every 6 month on completion preserve
+disable
+do
+  select 1;
+
+echo The following SELECTs should all give 1;
+
+# show current ON_COMPLETION
+select  count(*) from information_schema.events
+where   event_schema = database() and event_name = 'event_35981' and
+        on_completion = 'PRESERVE';
+
+# show ON_COMPLETION remains "PRESERVE" when not given in ALTER EVENT
+alter   event event_35981 enable;
+select  count(*) from information_schema.events
+where   event_schema = database() and event_name = 'event_35981' and
+        on_completion = 'PRESERVE';
+
+# show we can change ON_COMPLETION
+alter   event event_35981 on completion not preserve;
+select  count(*) from information_schema.events
+where   event_schema = database() and event_name = 'event_35981' and
+        on_completion = 'NOT PRESERVE';
+
+# show ON_COMPLETION remains "NOT PRESERVE" when not given in ALTER EVENT
+alter   event event_35981 disable;
+select  count(*) from information_schema.events
+where   event_schema = database() and event_name = 'event_35981' and
+        on_completion = 'NOT PRESERVE';
+
+# show we can change ON_COMPLETION
+alter   event event_35981 on completion preserve;
+select  count(*) from information_schema.events
+where   event_schema = database() and event_name = 'event_35981' and
+        on_completion = 'PRESERVE';
+
+
+drop event event_35981;
+
+create event event_35981 on schedule every 6 month disable
+do
+  select 1;
+
+# show that the defaults for CREATE EVENT are still correct (NOT PRESERVE)
+select  count(*) from information_schema.events
+where   event_schema = database() and event_name = 'event_35981' and
+        on_completion = 'NOT PRESERVE';
+
+drop event event_35981;
+
+
+# show that backdating doesn't break
+
+create event event_35981 on schedule every 1 hour starts current_timestamp
+  on completion not preserve
+do
+  select 1;
+
+# should fail thanks to above's NOT PRESERVE
+--error ER_EVENT_CANNOT_ALTER_IN_THE_PAST
+alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00'
+  ends '1999-01-02 00:00:00';
+
+drop event event_35981;
+
+create event event_35981 on schedule every 1 hour starts current_timestamp
+  on completion not preserve
+do
+  select 1;
+
+# succeed with warning
+alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00'
+  ends '1999-01-02 00:00:00' on completion preserve;
+
+drop event event_35981;
+
+
+
+create event event_35981 on schedule every 1 hour starts current_timestamp
+  on completion preserve
+do
+  select 1;
+
+# this should succeed thanks to above PRESERVE! give a warning though.
+alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00'
+  ends '1999-01-02 00:00:00';
+
+# this should fail, as the event would have passed already
+--error ER_EVENT_CANNOT_ALTER_IN_THE_PAST
+alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00'
+  ends '1999-01-02 00:00:00' on completion not preserve;
+
+# should succeed giving a warning
+alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00'
+  ends '1999-01-02 00:00:00' on completion preserve;
+
+drop event event_35981;
+
 # 
 # End of tests
 #

=== modified file 'mysql-test/t/mysqldump-max.test'
--- a/mysql-test/t/mysqldump-max.test	2006-10-24 15:54:45 +0000
+++ b/mysql-test/t/mysqldump-max.test	2008-09-11 06:14:19 +0000
@@ -66,3 +66,1061 @@ drop table t3; 
 drop table t4; 
 drop table t5; 
 drop table t6; 
+
+
+#
+# Bug#31434 - mysqldump dumps view as table
+#
+
+# Show that mysqldump's stand-in tables for views are always of MyISAM
+# type to avoid Inno's column-number limits (~1000 columns) etc.
+# Here because it needs Inno-engine.
+
+SELECT @@global.storage_engine INTO @old_engine;
+SET GLOBAL storage_engine=InnoDB;
+
+--disable_query_log
+CREATE TABLE `t1` (
+  `col_0` tinyint(1) default NULL,
+  `col_1` tinyint(1) default NULL,
+  `col_2` tinyint(1) default NULL,
+  `col_3` tinyint(1) default NULL,
+  `col_4` tinyint(1) default NULL,
+  `col_5` tinyint(1) default NULL,
+  `col_6` tinyint(1) default NULL,
+  `col_7` tinyint(1) default NULL,
+  `col_8` tinyint(1) default NULL,
+  `col_9` tinyint(1) default NULL,
+  `col_10` tinyint(1) default NULL,
+  `col_11` tinyint(1) default NULL,
+  `col_12` tinyint(1) default NULL,
+  `col_13` tinyint(1) default NULL,
+  `col_14` tinyint(1) default NULL,
+  `col_15` tinyint(1) default NULL,
+  `col_16` tinyint(1) default NULL,
+  `col_17` tinyint(1) default NULL,
+  `col_18` tinyint(1) default NULL,
+  `col_19` tinyint(1) default NULL,
+  `col_20` tinyint(1) default NULL,
+  `col_21` tinyint(1) default NULL,
+  `col_22` tinyint(1) default NULL,
+  `col_23` tinyint(1) default NULL,
+  `col_24` tinyint(1) default NULL,
+  `col_25` tinyint(1) default NULL,
+  `col_26` tinyint(1) default NULL,
+  `col_27` tinyint(1) default NULL,
+  `col_28` tinyint(1) default NULL,
+  `col_29` tinyint(1) default NULL,
+  `col_30` tinyint(1) default NULL,
+  `col_31` tinyint(1) default NULL,
+  `col_32` tinyint(1) default NULL,
+  `col_33` tinyint(1) default NULL,
+  `col_34` tinyint(1) default NULL,
+  `col_35` tinyint(1) default NULL,
+  `col_36` tinyint(1) default NULL,
+  `col_37` tinyint(1) default NULL,
+  `col_38` tinyint(1) default NULL,
+  `col_39` tinyint(1) default NULL,
+  `col_40` tinyint(1) default NULL,
+  `col_41` tinyint(1) default NULL,
+  `col_42` tinyint(1) default NULL,
+  `col_43` tinyint(1) default NULL,
+  `col_44` tinyint(1) default NULL,
+  `col_45` tinyint(1) default NULL,
+  `col_46` tinyint(1) default NULL,
+  `col_47` tinyint(1) default NULL,
+  `col_48` tinyint(1) default NULL,
+  `col_49` tinyint(1) default NULL,
+  `col_50` tinyint(1) default NULL,
+  `col_51` tinyint(1) default NULL,
+  `col_52` tinyint(1) default NULL,
+  `col_53` tinyint(1) default NULL,
+  `col_54` tinyint(1) default NULL,
+  `col_55` tinyint(1) default NULL,
+  `col_56` tinyint(1) default NULL,
+  `col_57` tinyint(1) default NULL,
+  `col_58` tinyint(1) default NULL,
+  `col_59` tinyint(1) default NULL,
+  `col_60` tinyint(1) default NULL,
+  `col_61` tinyint(1) default NULL,
+  `col_62` tinyint(1) default NULL,
+  `col_63` tinyint(1) default NULL,
+  `col_64` tinyint(1) default NULL,
+  `col_65` tinyint(1) default NULL,
+  `col_66` tinyint(1) default NULL,
+  `col_67` tinyint(1) default NULL,
+  `col_68` tinyint(1) default NULL,
+  `col_69` tinyint(1) default NULL,
+  `col_70` tinyint(1) default NULL,
+  `col_71` tinyint(1) default NULL,
+  `col_72` tinyint(1) default NULL,
+  `col_73` tinyint(1) default NULL,
+  `col_74` tinyint(1) default NULL,
+  `col_75` tinyint(1) default NULL,
+  `col_76` tinyint(1) default NULL,
+  `col_77` tinyint(1) default NULL,
+  `col_78` tinyint(1) default NULL,
+  `col_79` tinyint(1) default NULL,
+  `col_80` tinyint(1) default NULL,
+  `col_81` tinyint(1) default NULL,
+  `col_82` tinyint(1) default NULL,
+  `col_83` tinyint(1) default NULL,
+  `col_84` tinyint(1) default NULL,
+  `col_85` tinyint(1) default NULL,
+  `col_86` tinyint(1) default NULL,
+  `col_87` tinyint(1) default NULL,
+  `col_88` tinyint(1) default NULL,
+  `col_89` tinyint(1) default NULL,
+  `col_90` tinyint(1) default NULL,
+  `col_91` tinyint(1) default NULL,
+  `col_92` tinyint(1) default NULL,
+  `col_93` tinyint(1) default NULL,
+  `col_94` tinyint(1) default NULL,
+  `col_95` tinyint(1) default NULL,
+  `col_96` tinyint(1) default NULL,
+  `col_97` tinyint(1) default NULL,
+  `col_98` tinyint(1) default NULL,
+  `col_99` tinyint(1) default NULL,
+  `col_100` tinyint(1) default NULL,
+  `col_101` tinyint(1) default NULL,
+  `col_102` tinyint(1) default NULL,
+  `col_103` tinyint(1) default NULL,
+  `col_104` tinyint(1) default NULL,
+  `col_105` tinyint(1) default NULL,
+  `col_106` tinyint(1) default NULL,
+  `col_107` tinyint(1) default NULL,
+  `col_108` tinyint(1) default NULL,
+  `col_109` tinyint(1) default NULL,
+  `col_110` tinyint(1) default NULL,
+  `col_111` tinyint(1) default NULL,
+  `col_112` tinyint(1) default NULL,
+  `col_113` tinyint(1) default NULL,
+  `col_114` tinyint(1) default NULL,
+  `col_115` tinyint(1) default NULL,
+  `col_116` tinyint(1) default NULL,
+  `col_117` tinyint(1) default NULL,
+  `col_118` tinyint(1) default NULL,
+  `col_119` tinyint(1) default NULL,
+  `col_120` tinyint(1) default NULL,
+  `col_121` tinyint(1) default NULL,
+  `col_122` tinyint(1) default NULL,
+  `col_123` tinyint(1) default NULL,
+  `col_124` tinyint(1) default NULL,
+  `col_125` tinyint(1) default NULL,
+  `col_126` tinyint(1) default NULL,
+  `col_127` tinyint(1) default NULL,
+  `col_128` tinyint(1) default NULL,
+  `col_129` tinyint(1) default NULL,
+  `col_130` tinyint(1) default NULL,
+  `col_131` tinyint(1) default NULL,
+  `col_132` tinyint(1) default NULL,
+  `col_133` tinyint(1) default NULL,
+  `col_134` tinyint(1) default NULL,
+  `col_135` tinyint(1) default NULL,
+  `col_136` tinyint(1) default NULL,
+  `col_137` tinyint(1) default NULL,
+  `col_138` tinyint(1) default NULL,
+  `col_139` tinyint(1) default NULL,
+  `col_140` tinyint(1) default NULL,
+  `col_141` tinyint(1) default NULL,
+  `col_142` tinyint(1) default NULL,
+  `col_143` tinyint(1) default NULL,
+  `col_144` tinyint(1) default NULL,
+  `col_145` tinyint(1) default NULL,
+  `col_146` tinyint(1) default NULL,
+  `col_147` tinyint(1) default NULL,
+  `col_148` tinyint(1) default NULL,
+  `col_149` tinyint(1) default NULL,
+  `col_150` tinyint(1) default NULL,
+  `col_151` tinyint(1) default NULL,
+  `col_152` tinyint(1) default NULL,
+  `col_153` tinyint(1) default NULL,
+  `col_154` tinyint(1) default NULL,
+  `col_155` tinyint(1) default NULL,
+  `col_156` tinyint(1) default NULL,
+  `col_157` tinyint(1) default NULL,
+  `col_158` tinyint(1) default NULL,
+  `col_159` tinyint(1) default NULL,
+  `col_160` tinyint(1) default NULL,
+  `col_161` tinyint(1) default NULL,
+  `col_162` tinyint(1) default NULL,
+  `col_163` tinyint(1) default NULL,
+  `col_164` tinyint(1) default NULL,
+  `col_165` tinyint(1) default NULL,
+  `col_166` tinyint(1) default NULL,
+  `col_167` tinyint(1) default NULL,
+  `col_168` tinyint(1) default NULL,
+  `col_169` tinyint(1) default NULL,
+  `col_170` tinyint(1) default NULL,
+  `col_171` tinyint(1) default NULL,
+  `col_172` tinyint(1) default NULL,
+  `col_173` tinyint(1) default NULL,
+  `col_174` tinyint(1) default NULL,
+  `col_175` tinyint(1) default NULL,
+  `col_176` tinyint(1) default NULL,
+  `col_177` tinyint(1) default NULL,
+  `col_178` tinyint(1) default NULL,
+  `col_179` tinyint(1) default NULL,
+  `col_180` tinyint(1) default NULL,
+  `col_181` tinyint(1) default NULL,
+  `col_182` tinyint(1) default NULL,
+  `col_183` tinyint(1) default NULL,
+  `col_184` tinyint(1) default NULL,
+  `col_185` tinyint(1) default NULL,
+  `col_186` tinyint(1) default NULL,
+  `col_187` tinyint(1) default NULL,
+  `col_188` tinyint(1) default NULL,
+  `col_189` tinyint(1) default NULL,
+  `col_190` tinyint(1) default NULL,
+  `col_191` tinyint(1) default NULL,
+  `col_192` tinyint(1) default NULL,
+  `col_193` tinyint(1) default NULL,
+  `col_194` tinyint(1) default NULL,
+  `col_195` tinyint(1) default NULL,
+  `col_196` tinyint(1) default NULL,
+  `col_197` tinyint(1) default NULL,
+  `col_198` tinyint(1) default NULL,
+  `col_199` tinyint(1) default NULL,
+  `col_200` tinyint(1) default NULL,
+  `col_201` tinyint(1) default NULL,
+  `col_202` tinyint(1) default NULL,
+  `col_203` tinyint(1) default NULL,
+  `col_204` tinyint(1) default NULL,
+  `col_205` tinyint(1) default NULL,
+  `col_206` tinyint(1) default NULL,
+  `col_207` tinyint(1) default NULL,
+  `col_208` tinyint(1) default NULL,
+  `col_209` tinyint(1) default NULL,
+  `col_210` tinyint(1) default NULL,
+  `col_211` tinyint(1) default NULL,
+  `col_212` tinyint(1) default NULL,
+  `col_213` tinyint(1) default NULL,
+  `col_214` tinyint(1) default NULL,
+  `col_215` tinyint(1) default NULL,
+  `col_216` tinyint(1) default NULL,
+  `col_217` tinyint(1) default NULL,
+  `col_218` tinyint(1) default NULL,
+  `col_219` tinyint(1) default NULL,
+  `col_220` tinyint(1) default NULL,
+  `col_221` tinyint(1) default NULL,
+  `col_222` tinyint(1) default NULL,
+  `col_223` tinyint(1) default NULL,
+  `col_224` tinyint(1) default NULL,
+  `col_225` tinyint(1) default NULL,
+  `col_226` tinyint(1) default NULL,
+  `col_227` tinyint(1) default NULL,
+  `col_228` tinyint(1) default NULL,
+  `col_229` tinyint(1) default NULL,
+  `col_230` tinyint(1) default NULL,
+  `col_231` tinyint(1) default NULL,
+  `col_232` tinyint(1) default NULL,
+  `col_233` tinyint(1) default NULL,
+  `col_234` tinyint(1) default NULL,
+  `col_235` tinyint(1) default NULL,
+  `col_236` tinyint(1) default NULL,
+  `col_237` tinyint(1) default NULL,
+  `col_238` tinyint(1) default NULL,
+  `col_239` tinyint(1) default NULL,
+  `col_240` tinyint(1) default NULL,
+  `col_241` tinyint(1) default NULL,
+  `col_242` tinyint(1) default NULL,
+  `col_243` tinyint(1) default NULL,
+  `col_244` tinyint(1) default NULL,
+  `col_245` tinyint(1) default NULL,
+  `col_246` tinyint(1) default NULL,
+  `col_247` tinyint(1) default NULL,
+  `col_248` tinyint(1) default NULL,
+  `col_249` tinyint(1) default NULL,
+  `col_250` tinyint(1) default NULL,
+  `col_251` tinyint(1) default NULL,
+  `col_252` tinyint(1) default NULL,
+  `col_253` tinyint(1) default NULL,
+  `col_254` tinyint(1) default NULL,
+  `col_255` tinyint(1) default NULL,
+  `col_256` tinyint(1) default NULL,
+  `col_257` tinyint(1) default NULL,
+  `col_258` tinyint(1) default NULL,
+  `col_259` tinyint(1) default NULL,
+  `col_260` tinyint(1) default NULL,
+  `col_261` tinyint(1) default NULL,
+  `col_262` tinyint(1) default NULL,
+  `col_263` tinyint(1) default NULL,
+  `col_264` tinyint(1) default NULL,
+  `col_265` tinyint(1) default NULL,
+  `col_266` tinyint(1) default NULL,
+  `col_267` tinyint(1) default NULL,
+  `col_268` tinyint(1) default NULL,
+  `col_269` tinyint(1) default NULL,
+  `col_270` tinyint(1) default NULL,
+  `col_271` tinyint(1) default NULL,
+  `col_272` tinyint(1) default NULL,
+  `col_273` tinyint(1) default NULL,
+  `col_274` tinyint(1) default NULL,
+  `col_275` tinyint(1) default NULL,
+  `col_276` tinyint(1) default NULL,
+  `col_277` tinyint(1) default NULL,
+  `col_278` tinyint(1) default NULL,
+  `col_279` tinyint(1) default NULL,
+  `col_280` tinyint(1) default NULL,
+  `col_281` tinyint(1) default NULL,
+  `col_282` tinyint(1) default NULL,
+  `col_283` tinyint(1) default NULL,
+  `col_284` tinyint(1) default NULL,
+  `col_285` tinyint(1) default NULL,
+  `col_286` tinyint(1) default NULL,
+  `col_287` tinyint(1) default NULL,
+  `col_288` tinyint(1) default NULL,
+  `col_289` tinyint(1) default NULL,
+  `col_290` tinyint(1) default NULL,
+  `col_291` tinyint(1) default NULL,
+  `col_292` tinyint(1) default NULL,
+  `col_293` tinyint(1) default NULL,
+  `col_294` tinyint(1) default NULL,
+  `col_295` tinyint(1) default NULL,
+  `col_296` tinyint(1) default NULL,
+  `col_297` tinyint(1) default NULL,
+  `col_298` tinyint(1) default NULL,
+  `col_299` tinyint(1) default NULL,
+  `col_300` tinyint(1) default NULL,
+  `col_301` tinyint(1) default NULL,
+  `col_302` tinyint(1) default NULL,
+  `col_303` tinyint(1) default NULL,
+  `col_304` tinyint(1) default NULL,
+  `col_305` tinyint(1) default NULL,
+  `col_306` tinyint(1) default NULL,
+  `col_307` tinyint(1) default NULL,
+  `col_308` tinyint(1) default NULL,
+  `col_309` tinyint(1) default NULL,
+  `col_310` tinyint(1) default NULL,
+  `col_311` tinyint(1) default NULL,
+  `col_312` tinyint(1) default NULL,
+  `col_313` tinyint(1) default NULL,
+  `col_314` tinyint(1) default NULL,
+  `col_315` tinyint(1) default NULL,
+  `col_316` tinyint(1) default NULL,
+  `col_317` tinyint(1) default NULL,
+  `col_318` tinyint(1) default NULL,
+  `col_319` tinyint(1) default NULL,
+  `col_320` tinyint(1) default NULL,
+  `col_321` tinyint(1) default NULL,
+  `col_322` tinyint(1) default NULL,
+  `col_323` tinyint(1) default NULL,
+  `col_324` tinyint(1) default NULL,
+  `col_325` tinyint(1) default NULL,
+  `col_326` tinyint(1) default NULL,
+  `col_327` tinyint(1) default NULL,
+  `col_328` tinyint(1) default NULL,
+  `col_329` tinyint(1) default NULL,
+  `col_330` tinyint(1) default NULL,
+  `col_331` tinyint(1) default NULL,
+  `col_332` tinyint(1) default NULL,
+  `col_333` tinyint(1) default NULL,
+  `col_334` tinyint(1) default NULL,
+  `col_335` tinyint(1) default NULL,
+  `col_336` tinyint(1) default NULL,
+  `col_337` tinyint(1) default NULL,
+  `col_338` tinyint(1) default NULL,
+  `col_339` tinyint(1) default NULL,
+  `col_340` tinyint(1) default NULL,
+  `col_341` tinyint(1) default NULL,
+  `col_342` tinyint(1) default NULL,
+  `col_343` tinyint(1) default NULL,
+  `col_344` tinyint(1) default NULL,
+  `col_345` tinyint(1) default NULL,
+  `col_346` tinyint(1) default NULL,
+  `col_347` tinyint(1) default NULL,
+  `col_348` tinyint(1) default NULL,
+  `col_349` tinyint(1) default NULL,
+  `col_350` tinyint(1) default NULL,
+  `col_351` tinyint(1) default NULL,
+  `col_352` tinyint(1) default NULL,
+  `col_353` tinyint(1) default NULL,
+  `col_354` tinyint(1) default NULL,
+  `col_355` tinyint(1) default NULL,
+  `col_356` tinyint(1) default NULL,
+  `col_357` tinyint(1) default NULL,
+  `col_358` tinyint(1) default NULL,
+  `col_359` tinyint(1) default NULL,
+  `col_360` tinyint(1) default NULL,
+  `col_361` tinyint(1) default NULL,
+  `col_362` tinyint(1) default NULL,
+  `col_363` tinyint(1) default NULL,
+  `col_364` tinyint(1) default NULL,
+  `col_365` tinyint(1) default NULL,
+  `col_366` tinyint(1) default NULL,
+  `col_367` tinyint(1) default NULL,
+  `col_368` tinyint(1) default NULL,
+  `col_369` tinyint(1) default NULL,
+  `col_370` tinyint(1) default NULL,
+  `col_371` tinyint(1) default NULL,
+  `col_372` tinyint(1) default NULL,
+  `col_373` tinyint(1) default NULL,
+  `col_374` tinyint(1) default NULL,
+  `col_375` tinyint(1) default NULL,
+  `col_376` tinyint(1) default NULL,
+  `col_377` tinyint(1) default NULL,
+  `col_378` tinyint(1) default NULL,
+  `col_379` tinyint(1) default NULL,
+  `col_380` tinyint(1) default NULL,
+  `col_381` tinyint(1) default NULL,
+  `col_382` tinyint(1) default NULL,
+  `col_383` tinyint(1) default NULL,
+  `col_384` tinyint(1) default NULL,
+  `col_385` tinyint(1) default NULL,
+  `col_386` tinyint(1) default NULL,
+  `col_387` tinyint(1) default NULL,
+  `col_388` tinyint(1) default NULL,
+  `col_389` tinyint(1) default NULL,
+  `col_390` tinyint(1) default NULL,
+  `col_391` tinyint(1) default NULL,
+  `col_392` tinyint(1) default NULL,
+  `col_393` tinyint(1) default NULL,
+  `col_394` tinyint(1) default NULL,
+  `col_395` tinyint(1) default NULL,
+  `col_396` tinyint(1) default NULL,
+  `col_397` tinyint(1) default NULL,
+  `col_398` tinyint(1) default NULL,
+  `col_399` tinyint(1) default NULL,
+  `col_400` tinyint(1) default NULL,
+  `col_401` tinyint(1) default NULL,
+  `col_402` tinyint(1) default NULL,
+  `col_403` tinyint(1) default NULL,
+  `col_404` tinyint(1) default NULL,
+  `col_405` tinyint(1) default NULL,
+  `col_406` tinyint(1) default NULL,
+  `col_407` tinyint(1) default NULL,
+  `col_408` tinyint(1) default NULL,
+  `col_409` tinyint(1) default NULL,
+  `col_410` tinyint(1) default NULL,
+  `col_411` tinyint(1) default NULL,
+  `col_412` tinyint(1) default NULL,
+  `col_413` tinyint(1) default NULL,
+  `col_414` tinyint(1) default NULL,
+  `col_415` tinyint(1) default NULL,
+  `col_416` tinyint(1) default NULL,
+  `col_417` tinyint(1) default NULL,
+  `col_418` tinyint(1) default NULL,
+  `col_419` tinyint(1) default NULL,
+  `col_420` tinyint(1) default NULL,
+  `col_421` tinyint(1) default NULL,
+  `col_422` tinyint(1) default NULL,
+  `col_423` tinyint(1) default NULL,
+  `col_424` tinyint(1) default NULL,
+  `col_425` tinyint(1) default NULL,
+  `col_426` tinyint(1) default NULL,
+  `col_427` tinyint(1) default NULL,
+  `col_428` tinyint(1) default NULL,
+  `col_429` tinyint(1) default NULL,
+  `col_430` tinyint(1) default NULL,
+  `col_431` tinyint(1) default NULL,
+  `col_432` tinyint(1) default NULL,
+  `col_433` tinyint(1) default NULL,
+  `col_434` tinyint(1) default NULL,
+  `col_435` tinyint(1) default NULL,
+  `col_436` tinyint(1) default NULL,
+  `col_437` tinyint(1) default NULL,
+  `col_438` tinyint(1) default NULL,
+  `col_439` tinyint(1) default NULL,
+  `col_440` tinyint(1) default NULL,
+  `col_441` tinyint(1) default NULL,
+  `col_442` tinyint(1) default NULL,
+  `col_443` tinyint(1) default NULL,
+  `col_444` tinyint(1) default NULL,
+  `col_445` tinyint(1) default NULL,
+  `col_446` tinyint(1) default NULL,
+  `col_447` tinyint(1) default NULL,
+  `col_448` tinyint(1) default NULL,
+  `col_449` tinyint(1) default NULL,
+  `col_450` tinyint(1) default NULL,
+  `col_451` tinyint(1) default NULL,
+  `col_452` tinyint(1) default NULL,
+  `col_453` tinyint(1) default NULL,
+  `col_454` tinyint(1) default NULL,
+  `col_455` tinyint(1) default NULL,
+  `col_456` tinyint(1) default NULL,
+  `col_457` tinyint(1) default NULL,
+  `col_458` tinyint(1) default NULL,
+  `col_459` tinyint(1) default NULL,
+  `col_460` tinyint(1) default NULL,
+  `col_461` tinyint(1) default NULL,
+  `col_462` tinyint(1) default NULL,
+  `col_463` tinyint(1) default NULL,
+  `col_464` tinyint(1) default NULL,
+  `col_465` tinyint(1) default NULL,
+  `col_466` tinyint(1) default NULL,
+  `col_467` tinyint(1) default NULL,
+  `col_468` tinyint(1) default NULL,
+  `col_469` tinyint(1) default NULL,
+  `col_470` tinyint(1) default NULL,
+  `col_471` tinyint(1) default NULL,
+  `col_472` tinyint(1) default NULL,
+  `col_473` tinyint(1) default NULL,
+  `col_474` tinyint(1) default NULL,
+  `col_475` tinyint(1) default NULL,
+  `col_476` tinyint(1) default NULL,
+  `col_477` tinyint(1) default NULL,
+  `col_478` tinyint(1) default NULL,
+  `col_479` tinyint(1) default NULL,
+  `col_480` tinyint(1) default NULL,
+  `col_481` tinyint(1) default NULL,
+  `col_482` tinyint(1) default NULL,
+  `col_483` tinyint(1) default NULL,
+  `col_484` tinyint(1) default NULL,
+  `col_485` tinyint(1) default NULL,
+  `col_486` tinyint(1) default NULL,
+  `col_487` tinyint(1) default NULL,
+  `col_488` tinyint(1) default NULL,
+  `col_489` tinyint(1) default NULL,
+  `col_490` tinyint(1) default NULL,
+  `col_491` tinyint(1) default NULL,
+  `col_492` tinyint(1) default NULL,
+  `col_493` tinyint(1) default NULL,
+  `col_494` tinyint(1) default NULL,
+  `col_495` tinyint(1) default NULL,
+  `col_496` tinyint(1) default NULL,
+  `col_497` tinyint(1) default NULL,
+  `col_498` tinyint(1) default NULL,
+  `col_499` tinyint(1) default NULL,
+  `col_500` tinyint(1) default NULL,
+  `col_501` tinyint(1) default NULL,
+  `col_502` tinyint(1) default NULL,
+  `col_503` tinyint(1) default NULL,
+  `col_504` tinyint(1) default NULL,
+  `col_505` tinyint(1) default NULL,
+  `col_506` tinyint(1) default NULL,
+  `col_507` tinyint(1) default NULL,
+  `col_508` tinyint(1) default NULL,
+  `col_509` tinyint(1) default NULL,
+  `col_510` tinyint(1) default NULL,
+  `col_511` tinyint(1) default NULL,
+  `col_512` tinyint(1) default NULL,
+  `col_513` tinyint(1) default NULL,
+  `col_514` tinyint(1) default NULL,
+  `col_515` tinyint(1) default NULL,
+  `col_516` tinyint(1) default NULL,
+  `col_517` tinyint(1) default NULL,
+  `col_518` tinyint(1) default NULL,
+  `col_519` tinyint(1) default NULL,
+  `col_520` tinyint(1) default NULL,
+  `col_521` tinyint(1) default NULL,
+  `col_522` tinyint(1) default NULL,
+  `col_523` tinyint(1) default NULL,
+  `col_524` tinyint(1) default NULL,
+  `col_525` tinyint(1) default NULL,
+  `col_526` tinyint(1) default NULL,
+  `col_527` tinyint(1) default NULL,
+  `col_528` tinyint(1) default NULL,
+  `col_529` tinyint(1) default NULL,
+  `col_530` tinyint(1) default NULL,
+  `col_531` tinyint(1) default NULL,
+  `col_532` tinyint(1) default NULL,
+  `col_533` tinyint(1) default NULL,
+  `col_534` tinyint(1) default NULL,
+  `col_535` tinyint(1) default NULL,
+  `col_536` tinyint(1) default NULL,
+  `col_537` tinyint(1) default NULL,
+  `col_538` tinyint(1) default NULL,
+  `col_539` tinyint(1) default NULL,
+  `col_540` tinyint(1) default NULL,
+  `col_541` tinyint(1) default NULL,
+  `col_542` tinyint(1) default NULL,
+  `col_543` tinyint(1) default NULL,
+  `col_544` tinyint(1) default NULL,
+  `col_545` tinyint(1) default NULL,
+  `col_546` tinyint(1) default NULL,
+  `col_547` tinyint(1) default NULL,
+  `col_548` tinyint(1) default NULL,
+  `col_549` tinyint(1) default NULL,
+  `col_550` tinyint(1) default NULL,
+  `col_551` tinyint(1) default NULL,
+  `col_552` tinyint(1) default NULL,
+  `col_553` tinyint(1) default NULL,
+  `col_554` tinyint(1) default NULL,
+  `col_555` tinyint(1) default NULL,
+  `col_556` tinyint(1) default NULL,
+  `col_557` tinyint(1) default NULL,
+  `col_558` tinyint(1) default NULL,
+  `col_559` tinyint(1) default NULL,
+  `col_560` tinyint(1) default NULL,
+  `col_561` tinyint(1) default NULL,
+  `col_562` tinyint(1) default NULL,
+  `col_563` tinyint(1) default NULL,
+  `col_564` tinyint(1) default NULL,
+  `col_565` tinyint(1) default NULL,
+  `col_566` tinyint(1) default NULL,
+  `col_567` tinyint(1) default NULL,
+  `col_568` tinyint(1) default NULL,
+  `col_569` tinyint(1) default NULL,
+  `col_570` tinyint(1) default NULL,
+  `col_571` tinyint(1) default NULL,
+  `col_572` tinyint(1) default NULL,
+  `col_573` tinyint(1) default NULL,
+  `col_574` tinyint(1) default NULL,
+  `col_575` tinyint(1) default NULL,
+  `col_576` tinyint(1) default NULL,
+  `col_577` tinyint(1) default NULL,
+  `col_578` tinyint(1) default NULL,
+  `col_579` tinyint(1) default NULL,
+  `col_580` tinyint(1) default NULL,
+  `col_581` tinyint(1) default NULL,
+  `col_582` tinyint(1) default NULL,
+  `col_583` tinyint(1) default NULL,
+  `col_584` tinyint(1) default NULL,
+  `col_585` tinyint(1) default NULL,
+  `col_586` tinyint(1) default NULL,
+  `col_587` tinyint(1) default NULL,
+  `col_588` tinyint(1) default NULL,
+  `col_589` tinyint(1) default NULL,
+  `col_590` tinyint(1) default NULL,
+  `col_591` tinyint(1) default NULL,
+  `col_592` tinyint(1) default NULL,
+  `col_593` tinyint(1) default NULL,
+  `col_594` tinyint(1) default NULL,
+  `col_595` tinyint(1) default NULL,
+  `col_596` tinyint(1) default NULL,
+  `col_597` tinyint(1) default NULL,
+  `col_598` tinyint(1) default NULL,
+  `col_599` tinyint(1) default NULL,
+  `col_600` tinyint(1) default NULL,
+  `col_601` tinyint(1) default NULL,
+  `col_602` tinyint(1) default NULL,
+  `col_603` tinyint(1) default NULL,
+  `col_604` tinyint(1) default NULL,
+  `col_605` tinyint(1) default NULL,
+  `col_606` tinyint(1) default NULL,
+  `col_607` tinyint(1) default NULL,
+  `col_608` tinyint(1) default NULL,
+  `col_609` tinyint(1) default NULL,
+  `col_610` tinyint(1) default NULL,
+  `col_611` tinyint(1) default NULL,
+  `col_612` tinyint(1) default NULL,
+  `col_613` tinyint(1) default NULL,
+  `col_614` tinyint(1) default NULL,
+  `col_615` tinyint(1) default NULL,
+  `col_616` tinyint(1) default NULL,
+  `col_617` tinyint(1) default NULL,
+  `col_618` tinyint(1) default NULL,
+  `col_619` tinyint(1) default NULL,
+  `col_620` tinyint(1) default NULL,
+  `col_621` tinyint(1) default NULL,
+  `col_622` tinyint(1) default NULL,
+  `col_623` tinyint(1) default NULL,
+  `col_624` tinyint(1) default NULL,
+  `col_625` tinyint(1) default NULL,
+  `col_626` tinyint(1) default NULL,
+  `col_627` tinyint(1) default NULL,
+  `col_628` tinyint(1) default NULL,
+  `col_629` tinyint(1) default NULL,
+  `col_630` tinyint(1) default NULL,
+  `col_631` tinyint(1) default NULL,
+  `col_632` tinyint(1) default NULL,
+  `col_633` tinyint(1) default NULL,
+  `col_634` tinyint(1) default NULL,
+  `col_635` tinyint(1) default NULL,
+  `col_636` tinyint(1) default NULL,
+  `col_637` tinyint(1) default NULL,
+  `col_638` tinyint(1) default NULL,
+  `col_639` tinyint(1) default NULL,
+  `col_640` tinyint(1) default NULL,
+  `col_641` tinyint(1) default NULL,
+  `col_642` tinyint(1) default NULL,
+  `col_643` tinyint(1) default NULL,
+  `col_644` tinyint(1) default NULL,
+  `col_645` tinyint(1) default NULL,
+  `col_646` tinyint(1) default NULL,
+  `col_647` tinyint(1) default NULL,
+  `col_648` tinyint(1) default NULL,
+  `col_649` tinyint(1) default NULL,
+  `col_650` tinyint(1) default NULL,
+  `col_651` tinyint(1) default NULL,
+  `col_652` tinyint(1) default NULL,
+  `col_653` tinyint(1) default NULL,
+  `col_654` tinyint(1) default NULL,
+  `col_655` tinyint(1) default NULL,
+  `col_656` tinyint(1) default NULL,
+  `col_657` tinyint(1) default NULL,
+  `col_658` tinyint(1) default NULL,
+  `col_659` tinyint(1) default NULL,
+  `col_660` tinyint(1) default NULL,
+  `col_661` tinyint(1) default NULL,
+  `col_662` tinyint(1) default NULL,
+  `col_663` tinyint(1) default NULL,
+  `col_664` tinyint(1) default NULL,
+  `col_665` tinyint(1) default NULL,
+  `col_666` tinyint(1) default NULL,
+  `col_667` tinyint(1) default NULL,
+  `col_668` tinyint(1) default NULL,
+  `col_669` tinyint(1) default NULL,
+  `col_670` tinyint(1) default NULL,
+  `col_671` tinyint(1) default NULL,
+  `col_672` tinyint(1) default NULL,
+  `col_673` tinyint(1) default NULL,
+  `col_674` tinyint(1) default NULL,
+  `col_675` tinyint(1) default NULL,
+  `col_676` tinyint(1) default NULL,
+  `col_677` tinyint(1) default NULL,
+  `col_678` tinyint(1) default NULL,
+  `col_679` tinyint(1) default NULL,
+  `col_680` tinyint(1) default NULL,
+  `col_681` tinyint(1) default NULL,
+  `col_682` tinyint(1) default NULL,
+  `col_683` tinyint(1) default NULL,
+  `col_684` tinyint(1) default NULL,
+  `col_685` tinyint(1) default NULL,
+  `col_686` tinyint(1) default NULL,
+  `col_687` tinyint(1) default NULL,
+  `col_688` tinyint(1) default NULL,
+  `col_689` tinyint(1) default NULL,
+  `col_690` tinyint(1) default NULL,
+  `col_691` tinyint(1) default NULL,
+  `col_692` tinyint(1) default NULL,
+  `col_693` tinyint(1) default NULL,
+  `col_694` tinyint(1) default NULL,
+  `col_695` tinyint(1) default NULL,
+  `col_696` tinyint(1) default NULL,
+  `col_697` tinyint(1) default NULL,
+  `col_698` tinyint(1) default NULL,
+  `col_699` tinyint(1) default NULL,
+  `col_700` tinyint(1) default NULL,
+  `col_701` tinyint(1) default NULL,
+  `col_702` tinyint(1) default NULL,
+  `col_703` tinyint(1) default NULL,
+  `col_704` tinyint(1) default NULL,
+  `col_705` tinyint(1) default NULL,
+  `col_706` tinyint(1) default NULL,
+  `col_707` tinyint(1) default NULL,
+  `col_708` tinyint(1) default NULL,
+  `col_709` tinyint(1) default NULL,
+  `col_710` tinyint(1) default NULL,
+  `col_711` tinyint(1) default NULL,
+  `col_712` tinyint(1) default NULL,
+  `col_713` tinyint(1) default NULL,
+  `col_714` tinyint(1) default NULL,
+  `col_715` tinyint(1) default NULL,
+  `col_716` tinyint(1) default NULL,
+  `col_717` tinyint(1) default NULL,
+  `col_718` tinyint(1) default NULL,
+  `col_719` tinyint(1) default NULL,
+  `col_720` tinyint(1) default NULL,
+  `col_721` tinyint(1) default NULL,
+  `col_722` tinyint(1) default NULL,
+  `col_723` tinyint(1) default NULL,
+  `col_724` tinyint(1) default NULL,
+  `col_725` tinyint(1) default NULL,
+  `col_726` tinyint(1) default NULL,
+  `col_727` tinyint(1) default NULL,
+  `col_728` tinyint(1) default NULL,
+  `col_729` tinyint(1) default NULL,
+  `col_730` tinyint(1) default NULL,
+  `col_731` tinyint(1) default NULL,
+  `col_732` tinyint(1) default NULL,
+  `col_733` tinyint(1) default NULL,
+  `col_734` tinyint(1) default NULL,
+  `col_735` tinyint(1) default NULL,
+  `col_736` tinyint(1) default NULL,
+  `col_737` tinyint(1) default NULL,
+  `col_738` tinyint(1) default NULL,
+  `col_739` tinyint(1) default NULL,
+  `col_740` tinyint(1) default NULL,
+  `col_741` tinyint(1) default NULL,
+  `col_742` tinyint(1) default NULL,
+  `col_743` tinyint(1) default NULL,
+  `col_744` tinyint(1) default NULL,
+  `col_745` tinyint(1) default NULL,
+  `col_746` tinyint(1) default NULL,
+  `col_747` tinyint(1) default NULL,
+  `col_748` tinyint(1) default NULL,
+  `col_749` tinyint(1) default NULL,
+  `col_750` tinyint(1) default NULL,
+  `col_751` tinyint(1) default NULL,
+  `col_752` tinyint(1) default NULL,
+  `col_753` tinyint(1) default NULL,
+  `col_754` tinyint(1) default NULL,
+  `col_755` tinyint(1) default NULL,
+  `col_756` tinyint(1) default NULL,
+  `col_757` tinyint(1) default NULL,
+  `col_758` tinyint(1) default NULL,
+  `col_759` tinyint(1) default NULL,
+  `col_760` tinyint(1) default NULL,
+  `col_761` tinyint(1) default NULL,
+  `col_762` tinyint(1) default NULL,
+  `col_763` tinyint(1) default NULL,
+  `col_764` tinyint(1) default NULL,
+  `col_765` tinyint(1) default NULL,
+  `col_766` tinyint(1) default NULL,
+  `col_767` tinyint(1) default NULL,
+  `col_768` tinyint(1) default NULL,
+  `col_769` tinyint(1) default NULL,
+  `col_770` tinyint(1) default NULL,
+  `col_771` tinyint(1) default NULL,
+  `col_772` tinyint(1) default NULL,
+  `col_773` tinyint(1) default NULL,
+  `col_774` tinyint(1) default NULL,
+  `col_775` tinyint(1) default NULL,
+  `col_776` tinyint(1) default NULL,
+  `col_777` tinyint(1) default NULL,
+  `col_778` tinyint(1) default NULL,
+  `col_779` tinyint(1) default NULL,
+  `col_780` tinyint(1) default NULL,
+  `col_781` tinyint(1) default NULL,
+  `col_782` tinyint(1) default NULL,
+  `col_783` tinyint(1) default NULL,
+  `col_784` tinyint(1) default NULL,
+  `col_785` tinyint(1) default NULL,
+  `col_786` tinyint(1) default NULL,
+  `col_787` tinyint(1) default NULL,
+  `col_788` tinyint(1) default NULL,
+  `col_789` tinyint(1) default NULL,
+  `col_790` tinyint(1) default NULL,
+  `col_791` tinyint(1) default NULL,
+  `col_792` tinyint(1) default NULL,
+  `col_793` tinyint(1) default NULL,
+  `col_794` tinyint(1) default NULL,
+  `col_795` tinyint(1) default NULL,
+  `col_796` tinyint(1) default NULL,
+  `col_797` tinyint(1) default NULL,
+  `col_798` tinyint(1) default NULL,
+  `col_799` tinyint(1) default NULL,
+  `col_800` tinyint(1) default NULL,
+  `col_801` tinyint(1) default NULL,
+  `col_802` tinyint(1) default NULL,
+  `col_803` tinyint(1) default NULL,
+  `col_804` tinyint(1) default NULL,
+  `col_805` tinyint(1) default NULL,
+  `col_806` tinyint(1) default NULL,
+  `col_807` tinyint(1) default NULL,
+  `col_808` tinyint(1) default NULL,
+  `col_809` tinyint(1) default NULL,
+  `col_810` tinyint(1) default NULL,
+  `col_811` tinyint(1) default NULL,
+  `col_812` tinyint(1) default NULL,
+  `col_813` tinyint(1) default NULL,
+  `col_814` tinyint(1) default NULL,
+  `col_815` tinyint(1) default NULL,
+  `col_816` tinyint(1) default NULL,
+  `col_817` tinyint(1) default NULL,
+  `col_818` tinyint(1) default NULL,
+  `col_819` tinyint(1) default NULL,
+  `col_820` tinyint(1) default NULL,
+  `col_821` tinyint(1) default NULL,
+  `col_822` tinyint(1) default NULL,
+  `col_823` tinyint(1) default NULL,
+  `col_824` tinyint(1) default NULL,
+  `col_825` tinyint(1) default NULL,
+  `col_826` tinyint(1) default NULL,
+  `col_827` tinyint(1) default NULL,
+  `col_828` tinyint(1) default NULL,
+  `col_829` tinyint(1) default NULL,
+  `col_830` tinyint(1) default NULL,
+  `col_831` tinyint(1) default NULL,
+  `col_832` tinyint(1) default NULL,
+  `col_833` tinyint(1) default NULL,
+  `col_834` tinyint(1) default NULL,
+  `col_835` tinyint(1) default NULL,
+  `col_836` tinyint(1) default NULL,
+  `col_837` tinyint(1) default NULL,
+  `col_838` tinyint(1) default NULL,
+  `col_839` tinyint(1) default NULL,
+  `col_840` tinyint(1) default NULL,
+  `col_841` tinyint(1) default NULL,
+  `col_842` tinyint(1) default NULL,
+  `col_843` tinyint(1) default NULL,
+  `col_844` tinyint(1) default NULL,
+  `col_845` tinyint(1) default NULL,
+  `col_846` tinyint(1) default NULL,
+  `col_847` tinyint(1) default NULL,
+  `col_848` tinyint(1) default NULL,
+  `col_849` tinyint(1) default NULL,
+  `col_850` tinyint(1) default NULL,
+  `col_851` tinyint(1) default NULL,
+  `col_852` tinyint(1) default NULL,
+  `col_853` tinyint(1) default NULL,
+  `col_854` tinyint(1) default NULL,
+  `col_855` tinyint(1) default NULL,
+  `col_856` tinyint(1) default NULL,
+  `col_857` tinyint(1) default NULL,
+  `col_858` tinyint(1) default NULL,
+  `col_859` tinyint(1) default NULL,
+  `col_860` tinyint(1) default NULL,
+  `col_861` tinyint(1) default NULL,
+  `col_862` tinyint(1) default NULL,
+  `col_863` tinyint(1) default NULL,
+  `col_864` tinyint(1) default NULL,
+  `col_865` tinyint(1) default NULL,
+  `col_866` tinyint(1) default NULL,
+  `col_867` tinyint(1) default NULL,
+  `col_868` tinyint(1) default NULL,
+  `col_869` tinyint(1) default NULL,
+  `col_870` tinyint(1) default NULL,
+  `col_871` tinyint(1) default NULL,
+  `col_872` tinyint(1) default NULL,
+  `col_873` tinyint(1) default NULL,
+  `col_874` tinyint(1) default NULL,
+  `col_875` tinyint(1) default NULL,
+  `col_876` tinyint(1) default NULL,
+  `col_877` tinyint(1) default NULL,
+  `col_878` tinyint(1) default NULL,
+  `col_879` tinyint(1) default NULL,
+  `col_880` tinyint(1) default NULL,
+  `col_881` tinyint(1) default NULL,
+  `col_882` tinyint(1) default NULL,
+  `col_883` tinyint(1) default NULL,
+  `col_884` tinyint(1) default NULL,
+  `col_885` tinyint(1) default NULL,
+  `col_886` tinyint(1) default NULL,
+  `col_887` tinyint(1) default NULL,
+  `col_888` tinyint(1) default NULL,
+  `col_889` tinyint(1) default NULL,
+  `col_890` tinyint(1) default NULL,
+  `col_891` tinyint(1) default NULL,
+  `col_892` tinyint(1) default NULL,
+  `col_893` tinyint(1) default NULL,
+  `col_894` tinyint(1) default NULL,
+  `col_895` tinyint(1) default NULL,
+  `col_896` tinyint(1) default NULL,
+  `col_897` tinyint(1) default NULL,
+  `col_898` tinyint(1) default NULL,
+  `col_899` tinyint(1) default NULL,
+  `col_900` tinyint(1) default NULL,
+  `col_901` tinyint(1) default NULL,
+  `col_902` tinyint(1) default NULL,
+  `col_903` tinyint(1) default NULL,
+  `col_904` tinyint(1) default NULL,
+  `col_905` tinyint(1) default NULL,
+  `col_906` tinyint(1) default NULL,
+  `col_907` tinyint(1) default NULL,
+  `col_908` tinyint(1) default NULL,
+  `col_909` tinyint(1) default NULL,
+  `col_910` tinyint(1) default NULL,
+  `col_911` tinyint(1) default NULL,
+  `col_912` tinyint(1) default NULL,
+  `col_913` tinyint(1) default NULL,
+  `col_914` tinyint(1) default NULL,
+  `col_915` tinyint(1) default NULL,
+  `col_916` tinyint(1) default NULL,
+  `col_917` tinyint(1) default NULL,
+  `col_918` tinyint(1) default NULL,
+  `col_919` tinyint(1) default NULL,
+  `col_920` tinyint(1) default NULL,
+  `col_921` tinyint(1) default NULL,
+  `col_922` tinyint(1) default NULL,
+  `col_923` tinyint(1) default NULL,
+  `col_924` tinyint(1) default NULL,
+  `col_925` tinyint(1) default NULL,
+  `col_926` tinyint(1) default NULL,
+  `col_927` tinyint(1) default NULL,
+  `col_928` tinyint(1) default NULL,
+  `col_929` tinyint(1) default NULL,
+  `col_930` tinyint(1) default NULL,
+  `col_931` tinyint(1) default NULL,
+  `col_932` tinyint(1) default NULL,
+  `col_933` tinyint(1) default NULL,
+  `col_934` tinyint(1) default NULL,
+  `col_935` tinyint(1) default NULL,
+  `col_936` tinyint(1) default NULL,
+  `col_937` tinyint(1) default NULL,
+  `col_938` tinyint(1) default NULL,
+  `col_939` tinyint(1) default NULL,
+  `col_940` tinyint(1) default NULL,
+  `col_941` tinyint(1) default NULL,
+  `col_942` tinyint(1) default NULL,
+  `col_943` tinyint(1) default NULL,
+  `col_944` tinyint(1) default NULL,
+  `col_945` tinyint(1) default NULL,
+  `col_946` tinyint(1) default NULL,
+  `col_947` tinyint(1) default NULL,
+  `col_948` tinyint(1) default NULL,
+  `col_949` tinyint(1) default NULL,
+  `col_950` tinyint(1) default NULL,
+  `col_951` tinyint(1) default NULL,
+  `col_952` tinyint(1) default NULL,
+  `col_953` tinyint(1) default NULL,
+  `col_954` tinyint(1) default NULL,
+  `col_955` tinyint(1) default NULL,
+  `col_956` tinyint(1) default NULL,
+  `col_957` tinyint(1) default NULL,
+  `col_958` tinyint(1) default NULL,
+  `col_959` tinyint(1) default NULL,
+  `col_960` tinyint(1) default NULL,
+  `col_961` tinyint(1) default NULL,
+  `col_962` tinyint(1) default NULL,
+  `col_963` tinyint(1) default NULL,
+  `col_964` tinyint(1) default NULL,
+  `col_965` tinyint(1) default NULL,
+  `col_966` tinyint(1) default NULL,
+  `col_967` tinyint(1) default NULL,
+  `col_968` tinyint(1) default NULL,
+  `col_969` tinyint(1) default NULL,
+  `col_970` tinyint(1) default NULL,
+  `col_971` tinyint(1) default NULL,
+  `col_972` tinyint(1) default NULL,
+  `col_973` tinyint(1) default NULL,
+  `col_974` tinyint(1) default NULL,
+  `col_975` tinyint(1) default NULL,
+  `col_976` tinyint(1) default NULL,
+  `col_977` tinyint(1) default NULL,
+  `col_978` tinyint(1) default NULL,
+  `col_979` tinyint(1) default NULL,
+  `col_980` tinyint(1) default NULL,
+  `col_981` tinyint(1) default NULL,
+  `col_982` tinyint(1) default NULL,
+  `col_983` tinyint(1) default NULL,
+  `col_984` tinyint(1) default NULL,
+  `col_985` tinyint(1) default NULL,
+  `col_986` tinyint(1) default NULL,
+  `col_987` tinyint(1) default NULL,
+  `col_988` tinyint(1) default NULL,
+  `col_989` tinyint(1) default NULL,
+  `col_990` tinyint(1) default NULL,
+  `col_991` tinyint(1) default NULL,
+  `col_992` tinyint(1) default NULL,
+  `col_993` tinyint(1) default NULL,
+  `col_994` tinyint(1) default NULL,
+  `col_995` tinyint(1) default NULL,
+  `col_996` tinyint(1) default NULL,
+  `col_997` tinyint(1) default NULL,
+  `col_998` tinyint(1) default NULL,
+  `col_999` tinyint(1) default NULL,
+  `col_1000` tinyint(1) default NULL,
+  `col_1001` tinyint(1) default NULL,
+  `col_1002` tinyint(1) default NULL,
+  `col_1003` tinyint(1) default NULL,
+  `col_1004` tinyint(1) default NULL,
+  `col_1005` tinyint(1) default NULL,
+  `col_1006` tinyint(1) default NULL,
+  `col_1007` tinyint(1) default NULL,
+  `col_1008` tinyint(1) default NULL,
+  `col_1009` tinyint(1) default NULL,
+  `col_1010` tinyint(1) default NULL,
+  `col_1011` tinyint(1) default NULL,
+  `col_1012` tinyint(1) default NULL,
+  `col_1013` tinyint(1) default NULL,
+  `col_1014` tinyint(1) default NULL,
+  `col_1015` tinyint(1) default NULL,
+  `col_1016` tinyint(1) default NULL,
+  `col_1017` tinyint(1) default NULL,
+  `col_1018` tinyint(1) default NULL,
+  `col_1019` tinyint(1) default NULL,
+  `col_1020` tinyint(1) default NULL,
+  `col_1021` tinyint(1) default NULL,
+  `col_1022` tinyint(1) default NULL,
+  `col_1023` tinyint(1) default NULL,
+  `col_1024` tinyint(1) default NULL,
+  `col_1025` tinyint(1) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+--enable_query_log
+CREATE VIEW v1 AS SELECT * FROM t1;
+
+INSERT INTO t1 VALUES();
+SELECT COUNT(*) FROM v1;
+
+--exec $MYSQL_DUMP --allow-keywords --single-transaction --quick --verbose test --result-file $MYSQL_TEST_DIR/var/tmp/bug31434.sql
+--exec $MYSQL test < $MYSQL_TEST_DIR/var/tmp/bug31434.sql
+--remove_file $MYSQL_TEST_DIR/var/tmp/bug31434.sql
+
+SELECT COUNT(*) FROM v1;
+
+DROP VIEW  v1;
+DROP TABLE t1;
+
+SET GLOBAL storage_engine=@old_engine;

=== modified file 'mysql-test/t/user_var.test'
--- a/mysql-test/t/user_var.test	2007-12-13 12:59:16 +0000
+++ b/mysql-test/t/user_var.test	2008-09-18 09:06:39 +0000
@@ -263,4 +263,26 @@ from t1 order by score desc;
 --enable_result_log
 drop table t1;
 
+#
+# Bug#26020: User-Defined Variables are not consistent with columns data types
+#
+
+create table t1(b bigint);
+insert into t1 (b) values (10), (30), (10);
+set @var := 0;
+select if(b=@var, 999, b) , @var := b from t1  order by b;
+drop table t1;
+
+create temporary table t1 (id int);
+insert into t1 values (2), (3), (3), (4);
+set @lastid=-1;
+select @lastid != id, @lastid, @lastid := id from t1;
+drop table t1;
+
+create temporary table t1 (id bigint);
+insert into t1 values (2), (3), (3), (4);
+set @lastid=-1;
+select @lastid != id, @lastid, @lastid := id from t1;
+drop table t1;
+
 --echo End of 5.1 tests

=== modified file 'sql/event_db_repository.cc'
--- a/sql/event_db_repository.cc	2008-07-17 19:55:18 +0000
+++ b/sql/event_db_repository.cc	2008-09-18 09:06:39 +0000
@@ -185,6 +185,8 @@ mysql_event_fill_row(THD *thd,
   DBUG_PRINT("info", ("dbname=[%s]", et->dbname.str));
   DBUG_PRINT("info", ("name  =[%s]", et->name.str));
 
+  DBUG_ASSERT(et->on_completion != Event_parse_data::ON_COMPLETION_DEFAULT);
+
   if (table->s->fields < ET_FIELD_COUNT)
   {
     /*
@@ -746,6 +748,18 @@ Event_db_repository::update_event(THD *t
 
   store_record(table,record[1]);
 
+  /*
+    We check whether ALTER EVENT was given dates that are in the past.
+    However to know how to react, we need the ON COMPLETION type. The
+    check is deferred to this point because by now we have the previous
+    setting (from the event-table) to fall back on if nothing was specified
+    in the ALTER EVENT-statement.
+  */
+
+  if (parse_data->check_dates(thd,
+                              table->field[ET_FIELD_ON_COMPLETION]->val_int()))
+    goto end;
+
   /* Don't update create on row update. */
   table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
 

=== modified file 'sql/event_parse_data.cc'
--- a/sql/event_parse_data.cc	2008-05-09 07:43:02 +0000
+++ b/sql/event_parse_data.cc	2008-08-18 11:05:51 +0000
@@ -45,7 +45,7 @@ Event_parse_data::new_instance(THD *thd)
 */
 
 Event_parse_data::Event_parse_data()
-  :on_completion(Event_parse_data::ON_COMPLETION_DROP),
+  :on_completion(Event_parse_data::ON_COMPLETION_DEFAULT),
   status(Event_parse_data::ENABLED),
   do_not_create(FALSE),
   body_changed(FALSE),
@@ -114,6 +114,12 @@ Event_parse_data::check_if_in_the_past(T
   if (ltime_utc >= (my_time_t) thd->query_start())
     return;
 
+  /*
+    We'll come back later when we have the real on_completion value
+  */
+  if (on_completion == Event_parse_data::ON_COMPLETION_DEFAULT)
+    return;
+
   if (on_completion == Event_parse_data::ON_COMPLETION_DROP)
   {
     switch (thd->lex->sql_command) {
@@ -142,6 +148,42 @@ Event_parse_data::check_if_in_the_past(T
 
 
 /*
+  Check time/dates in ALTER EVENT
+
+  We check whether ALTER EVENT was given dates that are in the past.
+  However to know how to react, we need the ON COMPLETION type. Hence,
+  the check is deferred until we have the previous ON COMPLETION type
+  from the event-db to fall back on if nothing was specified in the
+  ALTER EVENT-statement.
+
+  SYNOPSIS
+    Event_parse_data::check_dates()
+      thd            Thread
+      on_completion  ON COMPLETION value currently in event-db.
+                     Will be overridden by value in ALTER EVENT if given.
+
+  RETURN VALUE
+    TRUE            an error occurred, do not ALTER
+    FALSE           OK
+*/
+
+bool
+Event_parse_data::check_dates(THD *thd, int previous_on_completion)
+{
+  if (on_completion == Event_parse_data::ON_COMPLETION_DEFAULT)
+  {
+    on_completion= previous_on_completion;
+    if (!ends_null)
+      check_if_in_the_past(thd, ends);
+    if (!execute_at_null)
+      check_if_in_the_past(thd, execute_at);
+  }
+  return do_not_create;
+}
+
+
+
+/*
   Sets time for execution for one-time event.
 
   SYNOPSIS

=== modified file 'sql/event_parse_data.h'
--- a/sql/event_parse_data.h	2008-05-09 07:43:02 +0000
+++ b/sql/event_parse_data.h	2008-08-18 11:05:51 +0000
@@ -38,7 +38,12 @@ public:
 
   enum enum_on_completion
   {
-    ON_COMPLETION_DROP = 1,
+    /*
+      On CREATE EVENT, DROP is the DEFAULT as per the docs.
+      On ALTER  EVENT, "no change" is the DEFAULT.
+    */
+    ON_COMPLETION_DEFAULT = 0,
+    ON_COMPLETION_DROP,
     ON_COMPLETION_PRESERVE
   };
 
@@ -80,6 +85,9 @@ public:
   bool
   check_parse_data(THD *thd);
 
+  bool
+  check_dates(THD *thd, int previous_on_completion);
+
 private:
 
   void

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2008-08-07 03:05:33 +0000
+++ b/sql/item_func.cc	2008-09-18 09:06:39 +0000
@@ -3884,6 +3884,24 @@ static user_var_entry *get_variable(HASH
   return entry;
 }
 
+
+bool Item_func_set_user_var::set_entry(THD *thd, bool create_if_not_exists)
+{
+  if (thd == entry_thd && entry)
+    return FALSE;
+  entry_thd= thd;
+  if (!(entry= get_variable(&thd->user_vars, name, create_if_not_exists)))
+    return TRUE;
+  /* 
+     Remember the last query which updated it, this way a query can later know
+     if this variable is a constant item in the query (it is if update_query_id
+     is different from query_id).
+  */
+  entry->update_query_id= thd->query_id;
+  return FALSE;
+}
+
+
 /*
   When a user variable is updated (in a SET command or a query like
   SELECT @a:= ).
@@ -3893,15 +3911,8 @@ bool Item_func_set_user_var::fix_fields(
 {
   DBUG_ASSERT(fixed == 0);
   /* fix_fields will call Item_func_set_user_var::fix_length_and_dec */
-  if (Item_func::fix_fields(thd, ref) ||
-      !(entry= get_variable(&thd->user_vars, name, 1)))
+  if (Item_func::fix_fields(thd, ref) || set_entry(thd, TRUE))
     return TRUE;
-  /* 
-     Remember the last query which updated it, this way a query can later know
-     if this variable is a constant item in the query (it is if update_query_id
-     is different from query_id).
-  */
-  entry->update_query_id= thd->query_id;
   /*
     As it is wrong and confusing to associate any 
     character set with NULL, @a should be latin2

=== modified file 'sql/item_func.h'
--- a/sql/item_func.h	2008-05-29 15:44:11 +0000
+++ b/sql/item_func.h	2008-09-18 09:06:39 +0000
@@ -1293,6 +1293,17 @@ class Item_func_set_user_var :public Ite
 {
   enum Item_result cached_result_type;
   user_var_entry *entry;
+  /*
+    The entry_thd variable is used:
+    1) to skip unnecessary updates of the entry field (see above);
+    2) to reset the entry field that was initialized in the other thread
+       (for example, an item tree of a trigger that updates user variables
+       may be shared between several connections, and the entry_thd field
+       prevents updates of one connection user variables from a concurrent
+       connection calling the same trigger that initially updated some
+       user variable it the first connection context).
+  */
+  THD *entry_thd;
   char buffer[MAX_FIELD_WIDTH];
   String value;
   my_decimal decimal_buff;
@@ -1308,7 +1319,8 @@ class Item_func_set_user_var :public Ite
 public:
   LEX_STRING name; // keep it public
   Item_func_set_user_var(LEX_STRING a,Item *b)
-    :Item_func(b), cached_result_type(INT_RESULT), name(a)
+    :Item_func(b), cached_result_type(INT_RESULT),
+     entry(NULL), entry_thd(NULL), name(a)
   {}
   enum Functype functype() const { return SUSERVAR_FUNC; }
   double val_real();
@@ -1339,6 +1351,7 @@ public:
   }
   void save_org_in_field(Field *field) { (void)save_in_field(field, 1, 0); }
   bool register_field_in_read_map(uchar *arg);
+  bool set_entry(THD *thd, bool create_if_not_exists);
 };
 
 

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2008-09-08 08:52:36 +0000
+++ b/sql/sql_base.cc	2008-09-18 09:06:39 +0000
@@ -6491,6 +6491,22 @@ bool setup_fields(THD *thd, Item **ref_p
   if (ref_pointer_array)
     bzero(ref_pointer_array, sizeof(Item *) * fields.elements);
 
+  /*
+    We call set_entry() there (before fix_fields() of the whole list of field
+    items) because:
+    1) the list of field items has same order as in the query, and the
+       Item_func_get_user_var item may go before the Item_func_set_user_var:
+          SELECT @a, @a := 10 FROM t;
+    2) The entry->update_query_id value controls constantness of
+       Item_func_get_user_var items, so in presence of Item_func_set_user_var
+       items we have to refresh their entries before fixing of
+       Item_func_get_user_var items.
+  */
+  List_iterator<Item_func_set_user_var> li(thd->lex->set_var_list);
+  Item_func_set_user_var *var;
+  while ((var= li++))
+    var->set_entry(thd, FALSE);
+
   Item **ref= ref_pointer_array;
   thd->lex->current_select->cur_pos_in_select_list= 0;
   while ((item= it++))

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2008-07-15 16:29:51 +0000
+++ b/sql/sql_lex.cc	2008-09-18 09:06:39 +0000
@@ -303,6 +303,7 @@ void lex_start(THD *thd)
   lex->select_lex.init_query();
   lex->value_list.empty();
   lex->update_list.empty();
+  lex->set_var_list.empty();
   lex->param_list.empty();
   lex->view_list.empty();
   lex->prepared_stmt_params.empty();

=== modified file 'sql/sql_lex.h'
--- a/sql/sql_lex.h	2008-08-20 10:29:58 +0000
+++ b/sql/sql_lex.h	2008-09-18 09:06:39 +0000
@@ -1572,6 +1572,7 @@ typedef struct st_lex : public Query_tab
   List<Item>	      *insert_list,field_list,value_list,update_list;
   List<List_item>     many_values;
   List<set_var_base>  var_list;
+  List<Item_func_set_user_var> set_var_list; // in-query assignment list
   List<Item_param>    param_list;
   List<LEX_STRING>    view_list; // view list (list of field names in view)
   /*

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2008-09-10 08:38:07 +0000
+++ b/sql/sql_yacc.yy	2008-09-18 09:06:39 +0000
@@ -1972,6 +1972,8 @@ event_tail:
             if (!(lex->event_parse_data= Event_parse_data::new_instance(thd)))
               MYSQL_YYABORT;
             lex->event_parse_data->identifier= $3;
+            lex->event_parse_data->on_completion=
+                                  Event_parse_data::ON_COMPLETION_DROP;
 
             lex->sql_command= SQLCOM_CREATE_EVENT;
             /* We need that for disallowing subqueries */
@@ -8490,11 +8492,13 @@ variable:
 variable_aux:
           ident_or_text SET_VAR expr
           {
-            $$= new (YYTHD->mem_root) Item_func_set_user_var($1, $3);
+            Item_func_set_user_var *item;
+            $$= item= new (YYTHD->mem_root) Item_func_set_user_var($1, $3);
             if ($$ == NULL)
               MYSQL_YYABORT;
             LEX *lex= Lex;
             lex->uncacheable(UNCACHEABLE_RAND);
+            lex->set_var_list.push_back(item);
           }
         | ident_or_text
           {

Thread
bzr push into mysql-6.0 branch (gshchepa:2835 to 2836)Gleb Shchepa18 Sep