Commit 95af195d authored by serg@serg.mysql.com's avatar serg@serg.mysql.com

disable partial timestamps in --new mode

parent 6897b002
...@@ -101,6 +101,6 @@ t2 t4 t6 t8 t10 t12 t14 ...@@ -101,6 +101,6 @@ t2 t4 t6 t8 t10 t12 t14
set new=1; set new=1;
select * from t1; select * from t1;
t2 t4 t6 t8 t10 t12 t14 t2 t4 t6 t8 t10 t12 t14
00 00-00 00-00-00 0000-00-00 00-00-00 00:00 00-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00
97 97-12 97-12-31 1997-12-31 97-12-31 23:47 97-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59
drop table t1; drop table t1;
...@@ -2616,17 +2616,14 @@ String *Field_timestamp::val_str(String *val_buffer, ...@@ -2616,17 +2616,14 @@ String *Field_timestamp::val_str(String *val_buffer,
String *val_ptr __attribute__((unused))) String *val_ptr __attribute__((unused)))
{ {
uint pos; uint pos;
int extra;
int part_time; int part_time;
uint32 temp; uint32 temp;
time_t time_arg; time_t time_arg;
struct tm *l_time; struct tm *l_time;
struct tm tm_tmp; struct tm tm_tmp;
my_bool new_format= (current_thd->variables.new_mode), my_bool new_format= (current_thd->variables.new_mode),
full_year=(field_length == 8 || field_length == 14); full_year=(field_length == 8 || field_length == 14 || new_format);
static const uint extras[]={0,1,2,2,4,5,5}; int real_field_length= new_format ? 19 : field_length;
extra= new_format ? extras[field_length/2-1] : 0;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first) if (table->db_low_byte_first)
...@@ -2638,18 +2635,17 @@ String *Field_timestamp::val_str(String *val_buffer, ...@@ -2638,18 +2635,17 @@ String *Field_timestamp::val_str(String *val_buffer,
if (temp == 0L) if (temp == 0L)
{ /* Zero time is "000000" */ { /* Zero time is "000000" */
if (new_format) if (new_format)
val_buffer->copy("0000-00-00 00:00:00"+2*(1-full_year), val_buffer->copy("0000-00-00 00:00:00", real_field_length);
field_length+extra);
else else
val_buffer->copy("00000000000000", field_length); val_buffer->copy("00000000000000", real_field_length);
return val_buffer; return val_buffer;
} }
time_arg=(time_t) temp; time_arg=(time_t) temp;
localtime_r(&time_arg,&tm_tmp); localtime_r(&time_arg,&tm_tmp);
l_time=&tm_tmp; l_time=&tm_tmp;
val_buffer->alloc(field_length+extra+1); val_buffer->alloc(real_field_length+1);
char *to=(char*) val_buffer->ptr(),*end=to+field_length+extra; char *to=(char*) val_buffer->ptr(),*end=to+real_field_length;
for (pos=0; to < end ; pos++) for (pos=0; to < end ; pos++)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment