Below is the list of changes that have just been committed into a local
5.0 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-09-12 16:18:15+00:00, evgen@stripped +15 -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 NOW_ON_UPDATE_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.
include/mysql_com.h@stripped, 2007-09-12 16:17:20+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 NOW_ON_UPDATE_FLAG is added.
mysql-test/r/grant.result@stripped, 2007-09-12 16:17:24+00:00, evgen@stripped +1 -1
Adjusted a test case after fixing bug#30081.
mysql-test/r/information_schema.result@stripped, 2007-09-12 16:17:24+00:00,
evgen@stripped +6 -1
Added a test case for the bug#30081: "ON UPDATE CURRENT_TIMESTAMP" wasn't shown by the
SHOW FIELDS
command and reported to a client.
mysql-test/r/metadata.result@stripped, 2007-09-12 16:17:25+00:00, evgen@stripped +1 -1
Adjusted a test case after fixing bug#30081.
mysql-test/r/ps_2myisam.result@stripped, 2007-09-12 16:17:25+00:00, evgen@stripped +1
-1
Adjusted a test case after fixing bug#30081.
mysql-test/r/ps_3innodb.result@stripped, 2007-09-12 16:17:26+00:00, evgen@stripped +1
-1
Adjusted a test case after fixing bug#30081.
mysql-test/r/ps_4heap.result@stripped, 2007-09-12 16:17:27+00:00, evgen@stripped +1 -1
Adjusted a test case after fixing bug#30081.
mysql-test/r/ps_5merge.result@stripped, 2007-09-12 16:17:27+00:00, evgen@stripped +2
-2
Adjusted a test case after fixing bug#30081.
mysql-test/r/show_check.result@stripped, 2007-09-12 16:17:28+00:00, evgen@stripped +2
-2
Adjusted a test case after fixing bug#30081.
mysql-test/r/type_ranges.result@stripped, 2007-09-12 16:17:28+00:00, evgen@stripped +2
-2
Adjusted a test case after fixing bug#30081.
mysql-test/r/type_timestamp.result@stripped, 2007-09-12 16:17:29+00:00, evgen@stripped
+4 -4
Adjusted a test case after fixing bug#30081.
mysql-test/t/information_schema.test@stripped, 2007-09-12 16:17:30+00:00,
evgen@stripped +8 -0
Added a test case for the bug#30081: "ON UPDATE CURRENT_TIMESTAMP" wasn't shown by the
SHOW FIELDS
command and reported to a client.
sql/field.cc@stripped, 2007-09-12 16:17:22+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 NOW_ON_UPDATE_FLAG on a field when
it should be set to NOW on UPDATE.
sql/sql_show.cc@stripped, 2007-09-12 16:17:23+00:00, evgen@stripped +8 -1
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-09-12 16:17:23+00:00, evgen@stripped +36 -1
Added a test case for the bug#30081: "ON UPDATE CURRENT_TIMESTAMP" wasn't shown by the
SHOW FIELDS
command and reported to a client.
diff -Nrup a/include/mysql_com.h b/include/mysql_com.h
--- a/include/mysql_com.h 2007-05-25 09:38:19 +00:00
+++ b/include/mysql_com.h 2007-09-12 16:17:20 +00:00
@@ -90,6 +90,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 NOW_ON_UPDATE_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-05-11 20:45:44 +00:00
+++ b/mysql-test/r/grant.result 2007-09-12 16:17:24 +00:00
@@ -526,7 +526,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') 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-08-20 06:23:06 +00:00
+++ b/mysql-test/r/information_schema.result 2007-09-12 16:17:24 +00:00
@@ -1093,7 +1093,6 @@ table_schema='information_schema' and
(column_type = 'varchar(7)' or column_type = 'varchar(20)')
group by column_type order by num;
column_type group_concat(table_schema, '.', table_name) num
-varchar(20) information_schema.COLUMNS 1
varchar(7) information_schema.ROUTINES,information_schema.VIEWS 2
create table t1(f1 char(1) not null, f2 char(9) not null)
default character set utf8;
@@ -1354,4 +1353,10 @@ where event_object_table='t1';
trigger_name
drop user mysqltest_1@localhost;
drop database mysqltest;
+CREATE TABLE t1 (a TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, b TIMESTAMP);
+SHOW FIELDS FROM t1;
+Field Type Null Key Default Extra
+a timestamp NO 0000-00-00 00:00:00 on update CURRENT_TIMESTAMP
+b timestamp NO 0000-00-00 00:00:00
+DROP TABLE t1;
End of 5.0 tests.
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-09-12 16:17:25 +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-06-29 13:37:15 +00:00
+++ b/mysql-test/r/ps_2myisam.result 2007-09-12 16:17:25 +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-06-29 13:37:15 +00:00
+++ b/mysql-test/r/ps_3innodb.result 2007-09-12 16:17:26 +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-06-29 13:37:15 +00:00
+++ b/mysql-test/r/ps_4heap.result 2007-09-12 16:17:27 +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-06-29 13:37:15 +00:00
+++ b/mysql-test/r/ps_5merge.result 2007-09-12 16:17:27 +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
@@ -3127,7 +3127,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-08-02 13:23:14 +00:00
+++ b/mysql-test/r/show_check.result 2007-09-12 16:17:28 +00:00
@@ -880,7 +880,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
@@ -899,7 +899,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
----------------------------------------------------------------
diff -Nrup a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result
--- a/mysql-test/r/type_ranges.result 2007-07-11 19:02:53 +00:00
+++ b/mysql-test/r/type_ranges.result 2007-09-12 16:17:28 +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 2006-12-13 09:17:38 +00:00
+++ b/mysql-test/r/type_timestamp.result 2007-09-12 16:17: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
delete from 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-08-20 06:23:06 +00:00
+++ b/mysql-test/t/information_schema.test 2007-09-12 16:17:30 +00:00
@@ -1071,4 +1071,12 @@ connection default;
drop user mysqltest_1@localhost;
drop database mysqltest;
+#
+# Bug#30081: "ON UPDATE CURRENT_TIMESTAMP" wasn't showed by the SHOW FIELDS
+# command and reported to a client.
+#
+CREATE TABLE t1 (a TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, b TIMESTAMP);
+SHOW FIELDS FROM t1;
+DROP TABLE t1;
+
--echo End of 5.0 tests.
diff -Nrup a/sql/field.cc b/sql/field.cc
--- a/sql/field.cc 2007-08-06 11:57:26 +00:00
+++ b/sql/field.cc 2007-09-12 16:17:22 +00:00
@@ -4267,6 +4267,8 @@ Field_timestamp::Field_timestamp(char *p
/* This timestamp has auto-update */
table->timestamp_field= this;
flags|=TIMESTAMP_FLAG;
+ if (unireg_check != TIMESTAMP_DN_FIELD)
+ flags|= NOW_ON_UPDATE_FLAG;
}
}
@@ -4286,6 +4288,8 @@ Field_timestamp::Field_timestamp(bool ma
/* This timestamp has auto-update */
table->timestamp_field= this;
flags|=TIMESTAMP_FLAG;
+ if (unireg_check != TIMESTAMP_DN_FIELD)
+ flags|= NOW_ON_UPDATE_FLAG;
}
}
diff -Nrup a/sql/sql_show.cc b/sql/sql_show.cc
--- a/sql/sql_show.cc 2007-08-21 13:59:41 +00:00
+++ b/sql/sql_show.cc 2007-09-12 16:17:23 +00:00
@@ -2823,6 +2823,13 @@ static int get_schema_column_record(THD
if (field->unireg_check == Field::NEXT_NUMBER)
end=strmov(tmp,"auto_increment");
table->field[16]->store(tmp, (uint) (end-tmp), 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[16]->set_notnull();
+ }
table->field[18]->store(field->comment.str, field->comment.length, cs);
if (schema_table_store_record(thd, table))
@@ -4145,7 +4152,7 @@ ST_FIELD_INFO columns_fields_info[]=
{"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 1, "Collation"},
{"COLUMN_TYPE", 65535, MYSQL_TYPE_STRING, 0, 0, "Type"},
{"COLUMN_KEY", 3, MYSQL_TYPE_STRING, 0, 0, "Key"},
- {"EXTRA", 20, MYSQL_TYPE_STRING, 0, 0, "Extra"},
+ {"EXTRA", 27, MYSQL_TYPE_STRING, 0, 0, "Extra"},
{"PRIVILEGES", 80, MYSQL_TYPE_STRING, 0, 0, "Privileges"},
{"COLUMN_COMMENT", 255, MYSQL_TYPE_STRING, 0, 0, "Comment"},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
diff -Nrup a/tests/mysql_client_test.c b/tests/mysql_client_test.c
--- a/tests/mysql_client_test.c 2007-08-15 14:21:36 +00:00
+++ b/tests/mysql_client_test.c 2007-09-12 16:17:23 +00:00
@@ -7516,7 +7516,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);
@@ -15857,6 +15857,40 @@ static void test_bug29306()
DBUG_VOID_RETURN;
}
+
+static void test_bug30081()
+{
+ MYSQL_FIELD *field;
+ int rc;
+ MYSQL_RES *res;
+
+ DBUG_ENTER("test_bug30081");
+ myheader("test_bug30081");
+
+ rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
+ myquery(rc);
+ rc= mysql_query(mysql, "CREATE TABLE t1 (f1 timestamp on update "
+ "current_timestamp)");
+ myquery(rc);
+
+ res= mysql_list_fields(mysql, "t1", NULL);
+ field= mysql_fetch_field(res);
+ DBUG_ASSERT(field);
+ if (! opt_silent)
+ {
+ printf("field name %s\n", field->name);
+ if (field->flags & NOW_ON_UPDATE_FLAG)
+ printf("set to NOW on UPDATE flag is found\n");
+ }
+ DIE_UNLESS(field->flags & NOW_ON_UPDATE_FLAG);
+ mysql_free_result(res);
+
+ rc= mysql_query(mysql, "DROP TABLE t1");
+ myquery(rc);
+
+ DBUG_VOID_RETURN;
+}
+
/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -16143,6 +16177,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug27592", test_bug27592 },
{ "test_bug29948", test_bug29948 },
{ "test_bug29306", test_bug29306 },
+ { "test_bug30081", test_bug30081 },
{ 0, 0 }
};