List:Commits« Previous MessageNext Message »
From:Sergei Golubchik Date:October 5 2007 4:59pm
Subject:Re: bk commit into 5.0 tree (evgen:1.2505) BUG#30081
View as plain text  
Hi!

On Sep 12, eugene@stripped wrote:
> 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.

 
> 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 */

1. This cannot go in 5.0
2. You forgot to update mysql.cc, function fieldflags2str().
3. rename to ON_UPDATE_NOW_FLAG, as the sql syntax is ON UPDATE NOW.

>  #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/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

no, fix the test case to have

  ... or column_type = 'varchar(27)')

>  varchar(7)	information_schema.ROUTINES,information_schema.VIEWS	2
>
> 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();
> +    }

1. The field cannot be null anyway (obvious from the code above that
sets auto_increment), remove set_notnull().

2. This is confusingly inconsistent. Replace the code for
"auto_increment" with the same table->field[16]->store(STRING_WITH_LEN(...))
 
>      table->field[18]->store(field->comment.str, field->comment.length,
> cs);
>      if (schema_table_store_record(thd, table))

Regards / Mit vielen Grüssen,
Sergei

-- 
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /   Sergei Golubchik <serg@stripped>
 / /|_/ / // /\ \/ /_/ / /__  Principal Software Developer
/_/  /_/\_, /___/\___\_\___/  MySQL GmbH, Dachauer Str. 37, D-80335 München
       <___/                  Geschäftsführer: Kaj Arnö - HRB
München 162140
Thread
bk commit into 5.0 tree (evgen:1.2505) BUG#30081eugene12 Sep
  • Re: bk commit into 5.0 tree (evgen:1.2505) BUG#30081Sergei Golubchik5 Oct