From: eugene Date: January 1 1970 12:00am Subject: bk commit into 5.1 tree (evgen:1.2617) BUG#30081 List-Archive: http://lists.mysql.com/commits/37644 X-Bug: 30081 Message-Id: <20071113132514.8E7ED53F61@moonbone.localdomain> Below is the list of changes that have just been committed into a local 5.1 repository of evgen. When evgen 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-11-13 13:24:48+00:00, evgen@stripped +17 -0 Bug#30081: "ON UPDATE CURRENT_TIMESTAMP" wasn't shown by the SHOW FIELDS command and reported to a client. The fact that a timestamp field will be set to NO on UPDATE wasn't shown by the SHOW COMMAND and reported to a client through connectors. This led to problems in the ODBC connector and might lead to a user confusion. A new filed flag called ON_UPDATE_NOW_FLAG is added. Constructors of the Field_timestamp set it when a field should be set to NOW on UPDATE. The get_schema_column_record function now reports whether a timestamp field will be set to NOW on UPDATE. client/mysql.cc@stripped, 2007-11-13 13:24:10+00:00, evgen@stripped +1 -0 Bug#30081: "ON UPDATE CURRENT_TIMESTAMP" wasn't shown by the SHOW FIELDS command and reported to a client. The fieldflag2str function is adjusted to print the ON_UPDATE_NOW_FLAG. include/mysql_com.h@stripped, 2007-11-13 13:24:09+00:00, evgen@stripped +1 -0 Bug#30081: "ON UPDATE CURRENT_TIMESTAMP" wasn't shown by the SHOW FIELDS command and reported to a client. A new filed flag called ON_UPDATE_NOW_FLAG is added. mysql-test/r/grant.result@stripped, 2007-11-13 13:23:34+00:00, evgen@stripped +1 -1 Adjusted a test case after fixing bug#30081. mysql-test/r/information_schema.result@stripped, 2007-11-13 13:22:58+00:00, evgen@stripped +4 -2 A test case adjusted after fixing the bug#30081. mysql-test/r/log_tables.result@stripped, 2007-11-13 13:22:57+00:00, evgen@stripped +2 -2 Adjusted a test case after fixing bug#30081. mysql-test/r/metadata.result@stripped, 2007-11-13 13:22:56+00:00, evgen@stripped +1 -1 Adjusted a test case after fixing bug#30081. mysql-test/r/ps_2myisam.result@stripped, 2007-11-13 13:22:41+00:00, evgen@stripped +1 -1 Adjusted a test case after fixing bug#30081. mysql-test/r/ps_3innodb.result@stripped, 2007-11-13 13:22:40+00:00, evgen@stripped +1 -1 Adjusted a test case after fixing bug#30081. mysql-test/r/ps_4heap.result@stripped, 2007-11-13 13:22:39+00:00, evgen@stripped +1 -1 Adjusted a test case after fixing bug#30081. mysql-test/r/ps_5merge.result@stripped, 2007-11-13 13:22:38+00:00, evgen@stripped +2 -2 Adjusted a test case after fixing bug#30081. mysql-test/r/show_check.result@stripped, 2007-11-13 13:22:37+00:00, evgen@stripped +2 -2 Adjusted a test case after fixing bug#30081. mysql-test/r/type_ranges.result@stripped, 2007-11-13 13:22:36+00:00, evgen@stripped +2 -2 Adjusted a test case after fixing bug#30081. mysql-test/r/type_timestamp.result@stripped, 2007-11-13 13:22:29+00:00, evgen@stripped +4 -4 Adjusted a test case after fixing bug#30081. mysql-test/t/information_schema.test@stripped, 2007-11-13 13:21:58+00:00, evgen@stripped +2 -1 A test case adjusted after fixing the bug#30081. sql/field.cc@stripped, 2007-11-13 13:24:07+00:00, evgen@stripped +4 -0 Bug#30081: "ON UPDATE CURRENT_TIMESTAMP" wasn't shown by the SHOW FIELDS command and reported to a client. Constructors of the Field_timestamp set the ON_UPDATE_NOW_FLAG on a field when it should be set to NOW on UPDATE. sql/sql_show.cc@stripped, 2007-11-13 13:24:02+00:00, evgen@stripped +6 -3 Bug#30081: "ON UPDATE CURRENT_TIMESTAMP" wasn't shown by the SHOW FIELDS command and reported to a client. The get_schema_column_record function now reports whether a timestamp field will be set to NOW on UPDATE. tests/mysql_client_test.c@stripped, 2007-11-13 13:23:36+00:00, evgen@stripped +1 -1 A test case adjusted after fixing the bug#30081. diff -Nrup a/client/mysql.cc b/client/mysql.cc --- a/client/mysql.cc 2007-09-24 09:41:22 +00:00 +++ b/client/mysql.cc 2007-11-13 13:24:10 +00:00 @@ -2366,6 +2366,7 @@ static char *fieldflags2str(uint f) { ff2s_check_flag(GROUP); ff2s_check_flag(UNIQUE); ff2s_check_flag(BINCMP); + ff2s_check_flag(ON_UPDATE_NOW); #undef ff2s_check_flag if (f) sprintf(s, " unknows=0x%04x", f); diff -Nrup a/include/mysql_com.h b/include/mysql_com.h --- a/include/mysql_com.h 2007-10-15 11:45:15 +00:00 +++ b/include/mysql_com.h 2007-11-13 13:24:09 +00:00 @@ -94,6 +94,7 @@ enum enum_server_command #define TIMESTAMP_FLAG 1024 /* Field is a timestamp */ #define SET_FLAG 2048 /* field is a set */ #define NO_DEFAULT_VALUE_FLAG 4096 /* Field doesn't have default value */ +#define ON_UPDATE_NOW_FLAG 8192 /* Field is set to NOW on UPDATE */ #define NUM_FLAG 32768 /* Field is num (for clients) */ #define PART_KEY_FLAG 16384 /* Intern; Part of some key */ #define GROUP_FLAG 32768 /* Intern: Group field */ diff -Nrup a/mysql-test/r/grant.result b/mysql-test/r/grant.result --- a/mysql-test/r/grant.result 2007-10-09 17:46:26 +00:00 +++ b/mysql-test/r/grant.result 2007-11-13 13:23:34 +00:00 @@ -529,7 +529,7 @@ Db char(64) NO PRI User char(16) NO PRI Table_name char(64) NO PRI Grantor char(77) NO MUL -Timestamp timestamp NO CURRENT_TIMESTAMP +Timestamp timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') NO Column_priv set('Select','Insert','Update','References') NO use test; diff -Nrup a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result --- a/mysql-test/r/information_schema.result 2007-10-29 10:47:53 +00:00 +++ b/mysql-test/r/information_schema.result 2007-11-13 13:22:58 +00:00 @@ -1141,11 +1141,13 @@ DROP FUNCTION func2; select column_type, group_concat(table_schema, '.', table_name), count(*) as num from information_schema.columns where table_schema='information_schema' and -(column_type = 'varchar(7)' or column_type = 'varchar(20)') +(column_type = 'varchar(7)' or column_type = 'varchar(20)' + or column_type = 'varchar(27)') group by column_type order by num; column_type group_concat(table_schema, '.', table_name) num +varchar(27) information_schema.COLUMNS 1 varchar(7) information_schema.ROUTINES,information_schema.VIEWS 2 -varchar(20) information_schema.COLUMNS,information_schema.FILES,information_schema.FILES,information_schema.PLUGINS,information_schema.PLUGINS,information_schema.PLUGINS 6 +varchar(20) information_schema.FILES,information_schema.FILES,information_schema.PLUGINS,information_schema.PLUGINS,information_schema.PLUGINS 5 create table t1(f1 char(1) not null, f2 char(9) not null) default character set utf8; select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from diff -Nrup a/mysql-test/r/log_tables.result b/mysql-test/r/log_tables.result --- a/mysql-test/r/log_tables.result 2007-10-19 20:03:16 +00:00 +++ b/mysql-test/r/log_tables.result 2007-11-13 13:22:57 +00:00 @@ -50,7 +50,7 @@ general_log CREATE TABLE `general_log` ( ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log' show fields from mysql.general_log; Field Type Null Key Default Extra -event_time timestamp NO CURRENT_TIMESTAMP +event_time timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP user_host mediumtext NO NULL thread_id int(11) NO NULL server_id int(11) NO NULL @@ -73,7 +73,7 @@ slow_log CREATE TABLE `slow_log` ( ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log' show fields from mysql.slow_log; Field Type Null Key Default Extra -start_time timestamp NO CURRENT_TIMESTAMP +start_time timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP user_host mediumtext NO NULL query_time time NO NULL lock_time time NO NULL diff -Nrup a/mysql-test/r/metadata.result b/mysql-test/r/metadata.result --- a/mysql-test/r/metadata.result 2007-06-20 09:20:41 +00:00 +++ b/mysql-test/r/metadata.result 2007-11-13 13:22:56 +00:00 @@ -21,7 +21,7 @@ def test t1 t1 g g 5 4 0 Y 32768 3 63 def test t1 t1 h h 246 7 0 Y 0 4 63 def test t1 t1 i i 13 4 0 Y 32864 0 63 def test t1 t1 j j 10 10 0 Y 128 0 63 -def test t1 t1 k k 7 19 0 N 1249 0 63 +def test t1 t1 k k 7 19 0 N 9441 0 63 def test t1 t1 l l 12 19 0 Y 128 0 63 def test t1 t1 m m 254 1 0 Y 256 0 8 def test t1 t1 n n 254 3 0 Y 2048 0 8 diff -Nrup a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result --- a/mysql-test/r/ps_2myisam.result 2007-10-18 12:55:03 +00:00 +++ b/mysql-test/r/ps_2myisam.result 2007-11-13 13:22:41 +00:00 @@ -63,7 +63,7 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63 def test t9 t9 c12 c12 246 10 6 Y 0 4 63 def test t9 t9 c13 c13 10 10 10 Y 128 0 63 def test t9 t9 c14 c14 12 19 19 Y 128 0 63 -def test t9 t9 c15 c15 7 19 19 N 1249 0 63 +def test t9 t9 c15 c15 7 19 19 N 9441 0 63 def test t9 t9 c16 c16 11 8 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 def test t9 t9 c18 c18 1 4 1 Y 32768 0 63 diff -Nrup a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result --- a/mysql-test/r/ps_3innodb.result 2007-10-18 12:55:03 +00:00 +++ b/mysql-test/r/ps_3innodb.result 2007-11-13 13:22:40 +00:00 @@ -63,7 +63,7 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63 def test t9 t9 c12 c12 246 10 6 Y 0 4 63 def test t9 t9 c13 c13 10 10 10 Y 128 0 63 def test t9 t9 c14 c14 12 19 19 Y 128 0 63 -def test t9 t9 c15 c15 7 19 19 N 1249 0 63 +def test t9 t9 c15 c15 7 19 19 N 9441 0 63 def test t9 t9 c16 c16 11 8 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 def test t9 t9 c18 c18 1 4 1 Y 32768 0 63 diff -Nrup a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result --- a/mysql-test/r/ps_4heap.result 2007-10-18 12:55:03 +00:00 +++ b/mysql-test/r/ps_4heap.result 2007-11-13 13:22:39 +00:00 @@ -64,7 +64,7 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63 def test t9 t9 c12 c12 246 10 6 Y 0 4 63 def test t9 t9 c13 c13 10 10 10 Y 128 0 63 def test t9 t9 c14 c14 12 19 19 Y 128 0 63 -def test t9 t9 c15 c15 7 19 19 N 1249 0 63 +def test t9 t9 c15 c15 7 19 19 N 9441 0 63 def test t9 t9 c16 c16 11 8 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 def test t9 t9 c18 c18 1 4 1 Y 32768 0 63 diff -Nrup a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result --- a/mysql-test/r/ps_5merge.result 2007-10-18 12:55:03 +00:00 +++ b/mysql-test/r/ps_5merge.result 2007-11-13 13:22:38 +00:00 @@ -106,7 +106,7 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63 def test t9 t9 c12 c12 246 10 6 Y 0 4 63 def test t9 t9 c13 c13 10 10 10 Y 128 0 63 def test t9 t9 c14 c14 12 19 19 Y 128 0 63 -def test t9 t9 c15 c15 7 19 19 N 1249 0 63 +def test t9 t9 c15 c15 7 19 19 N 9441 0 63 def test t9 t9 c16 c16 11 8 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 def test t9 t9 c18 c18 1 4 1 Y 32768 0 63 @@ -3128,7 +3128,7 @@ def test t9 t9 c11 c11 246 9 6 Y 0 4 63 def test t9 t9 c12 c12 246 10 6 Y 0 4 63 def test t9 t9 c13 c13 10 10 10 Y 128 0 63 def test t9 t9 c14 c14 12 19 19 Y 128 0 63 -def test t9 t9 c15 c15 7 19 19 N 1249 0 63 +def test t9 t9 c15 c15 7 19 19 N 9441 0 63 def test t9 t9 c16 c16 11 8 8 Y 128 0 63 def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 def test t9 t9 c18 c18 1 4 1 Y 32768 0 63 diff -Nrup a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result --- a/mysql-test/r/show_check.result 2007-09-20 11:27:56 +00:00 +++ b/mysql-test/r/show_check.result 2007-11-13 13:22:37 +00:00 @@ -979,7 +979,7 @@ def COLUMNS CHARACTER_SET_NAME CHARACT def COLUMNS COLLATION_NAME COLLATION_NAME 253 192 0 Y 0 0 33 def COLUMNS COLUMN_TYPE COLUMN_TYPE 252 589815 7 N 17 0 33 def COLUMNS COLUMN_KEY COLUMN_KEY 253 9 3 N 1 0 33 -def COLUMNS EXTRA EXTRA 253 60 0 N 1 0 33 +def COLUMNS EXTRA EXTRA 253 81 0 N 1 0 33 def COLUMNS PRIVILEGES PRIVILEGES 253 240 31 N 1 0 33 def COLUMNS COLUMN_COMMENT COLUMN_COMMENT 253 765 0 N 1 0 33 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT @@ -998,7 +998,7 @@ def COLUMNS COLUMN_TYPE Type 252 58981 def COLUMNS IS_NULLABLE Null 253 9 2 N 1 0 33 def COLUMNS COLUMN_KEY Key 253 9 3 N 1 0 33 def COLUMNS COLUMN_DEFAULT Default 252 589815 0 Y 16 0 33 -def COLUMNS EXTRA Extra 253 60 0 N 1 0 33 +def COLUMNS EXTRA Extra 253 81 0 N 1 0 33 Field Type Null Key Default Extra c int(11) NO PRI NULL ---------------------------------------------------------------- diff -Nrup a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result --- a/mysql-test/r/type_ranges.result 2007-09-20 08:56:25 +00:00 +++ b/mysql-test/r/type_ranges.result 2007-11-13 13:22:36 +00:00 @@ -57,7 +57,7 @@ ushort smallint(5) unsigned zerofill NUL umedium mediumint(8) unsigned NULL NO MUL 0 # ulong int(11) unsigned NULL NO MUL 0 # ulonglong bigint(13) unsigned NULL NO MUL 0 # -time_stamp timestamp NULL NO CURRENT_TIMESTAMP # +time_stamp timestamp NULL NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP # date_field date NULL YES NULL # time_field time NULL YES NULL # date_time datetime NULL YES NULL # @@ -225,7 +225,7 @@ ushort smallint(5) unsigned zerofill NUL umedium mediumint(8) unsigned NULL NO MUL 0 # ulong int(11) unsigned NULL NO MUL 0 # ulonglong bigint(13) unsigned NULL NO MUL 0 # -time_stamp timestamp NULL NO CURRENT_TIMESTAMP # +time_stamp timestamp NULL NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP # date_field char(10) latin1_swedish_ci YES NULL # time_field time NULL YES NULL # date_time datetime NULL YES NULL # diff -Nrup a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result --- a/mysql-test/r/type_timestamp.result 2007-06-26 11:15:02 +00:00 +++ b/mysql-test/r/type_timestamp.result 2007-11-13 13:22:29 +00:00 @@ -251,7 +251,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 show columns from t1; Field Type Null Key Default Extra -t1 timestamp NO 2003-01-01 00:00:00 +t1 timestamp NO 2003-01-01 00:00:00 on update CURRENT_TIMESTAMP t2 datetime YES NULL drop table t1; create table t1 (t1 timestamp default now() on update now(), t2 datetime); @@ -276,7 +276,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 show columns from t1; Field Type Null Key Default Extra -t1 timestamp NO CURRENT_TIMESTAMP +t1 timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP t2 datetime YES NULL drop table t1; create table t1 (t1 timestamp, t2 datetime, t3 timestamp); @@ -302,7 +302,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 show columns from t1; Field Type Null Key Default Extra -t1 timestamp NO CURRENT_TIMESTAMP +t1 timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP t2 datetime YES NULL t3 timestamp NO 0000-00-00 00:00:00 drop table t1; @@ -328,7 +328,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 show columns from t1; Field Type Null Key Default Extra -t1 timestamp NO CURRENT_TIMESTAMP +t1 timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP t2 datetime YES NULL truncate table t1; insert into t1 values ('2004-04-01 00:00:00', '2004-04-01 00:00:00'); diff -Nrup a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test --- a/mysql-test/t/information_schema.test 2007-10-29 10:48:06 +00:00 +++ b/mysql-test/t/information_schema.test 2007-11-13 13:21:58 +00:00 @@ -807,7 +807,8 @@ DROP FUNCTION func2; select column_type, group_concat(table_schema, '.', table_name), count(*) as num from information_schema.columns where table_schema='information_schema' and -(column_type = 'varchar(7)' or column_type = 'varchar(20)') +(column_type = 'varchar(7)' or column_type = 'varchar(20)' + or column_type = 'varchar(27)') group by column_type order by num; # diff -Nrup a/sql/field.cc b/sql/field.cc --- a/sql/field.cc 2007-10-23 15:10:26 +00:00 +++ b/sql/field.cc 2007-11-13 13:24:07 +00:00 @@ -4616,6 +4616,8 @@ Field_timestamp::Field_timestamp(uchar * /* This timestamp has auto-update */ share->timestamp_field= this; flags|= TIMESTAMP_FLAG; + if (unireg_check != TIMESTAMP_DN_FIELD) + flags|= ON_UPDATE_NOW_FLAG; } } @@ -4629,6 +4631,8 @@ Field_timestamp::Field_timestamp(bool ma { /* For 4.0 MYD and 4.0 InnoDB compatibility */ flags|= ZEROFILL_FLAG | UNSIGNED_FLAG; + if (unireg_check != TIMESTAMP_DN_FIELD) + flags|= ON_UPDATE_NOW_FLAG; } diff -Nrup a/sql/sql_show.cc b/sql/sql_show.cc --- a/sql/sql_show.cc 2007-10-23 08:20:49 +00:00 +++ b/sql/sql_show.cc 2007-11-13 13:24:02 +00:00 @@ -3777,8 +3777,11 @@ static int get_schema_column_record(THD end= tmp; if (field->unireg_check == Field::NEXT_NUMBER) - end=strmov(tmp,"auto_increment"); - table->field[16]->store(tmp, (uint) (end-tmp), cs); + table->field[16]->store(STRING_WITH_LEN("auto_increment"), cs); + if (show_table->timestamp_field == field && + field->unireg_check != Field::TIMESTAMP_DN_FIELD) + table->field[16]->store(STRING_WITH_LEN("on update CURRENT_TIMESTAMP"), + cs); table->field[18]->store(field->comment.str, field->comment.length, cs); if (schema_table_store_record(thd, table)) @@ -5981,7 +5984,7 @@ ST_FIELD_INFO columns_fields_info[]= {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 1, "Collation", OPEN_FRM_ONLY}, {"COLUMN_TYPE", 65535, MYSQL_TYPE_STRING, 0, 0, "Type", OPEN_FRM_ONLY}, {"COLUMN_KEY", 3, MYSQL_TYPE_STRING, 0, 0, "Key", OPEN_FRM_ONLY}, - {"EXTRA", 20, MYSQL_TYPE_STRING, 0, 0, "Extra", OPEN_FRM_ONLY}, + {"EXTRA", 27, MYSQL_TYPE_STRING, 0, 0, "Extra", OPEN_FRM_ONLY}, {"PRIVILEGES", 80, MYSQL_TYPE_STRING, 0, 0, "Privileges", OPEN_FRM_ONLY}, {"COLUMN_COMMENT", 255, MYSQL_TYPE_STRING, 0, 0, "Comment", OPEN_FRM_ONLY}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} diff -Nrup a/tests/mysql_client_test.c b/tests/mysql_client_test.c --- a/tests/mysql_client_test.c 2007-10-23 15:10:28 +00:00 +++ b/tests/mysql_client_test.c 2007-11-13 13:23:36 +00:00 @@ -7787,7 +7787,7 @@ static void test_explain_bug() verify_prepare_field(result, 5, "Extra", "EXTRA", mysql_get_server_version(mysql) <= 50000 ? MYSQL_TYPE_STRING : MYSQL_TYPE_VAR_STRING, - 0, 0, "", 20, 0); + 0, 0, "", 27, 0); mysql_free_result(result); mysql_stmt_close(stmt);