From 22f6c58bb148fad71595d122635071ebbfb9f32c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 Mar 2005 23:36:25 +0400 Subject: [PATCH 1/3] Fix for bug #8894 "TIMESTAMP values scrambled/misaligned when using --new". Fixed Field_timestamp::val_int() so now it works correctly in --new mode (or for TIMESTAMP(19) columns). Also removed unused Field_timestamp::fill_and_store() method. mysql-test/r/type_timestamp.result: Added test for bug #8894 "TIMESTAMP values scrambled/misaligned when using --new". mysql-test/t/type_timestamp.test: Added test for bug #8894 "TIMESTAMP values scrambled/misaligned when using --new". sql/field.cc: Field_timestamp::fill_and_store() Removed unused method. Field_timestamp::val_int() Even in --new mode integer representation of TIMESTAMP value should not exceed 14 digits. sql/field.h: Removed unused Field_timestamp::fill_and_store() method. --- mysql-test/r/type_timestamp.result | 9 ++++++++ mysql-test/t/type_timestamp.test | 13 +++++++++++ sql/field.cc | 35 ++++-------------------------- sql/field.h | 1 - 4 files changed, 26 insertions(+), 32 deletions(-) diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result index 6253fa96ba8..d22fe9a94ae 100644 --- a/mysql-test/r/type_timestamp.result +++ b/mysql-test/r/type_timestamp.result @@ -221,3 +221,12 @@ ts1 20040101000000 20040101010000 drop table t1; +create table t1 (ts timestamp); +set TIMESTAMP=1000000000; +insert into t1 values (); +set new=1; +select ts+0 from t1; +ts+0 +20010909044640 +set new=0; +drop table t1; diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test index 464ee63c137..9d61e0eaef1 100644 --- a/mysql-test/t/type_timestamp.test +++ b/mysql-test/t/type_timestamp.test @@ -148,3 +148,16 @@ select * from t1; set new=0; select * from t1; drop table t1; + +# +# Test for bug #8894 "TIMESTAMP values scrambled/misaligned when using +# --new". TIMESTAMP columns should have correct values when they are used in +# integer context in --new mode. +# +create table t1 (ts timestamp); +set TIMESTAMP=1000000000; +insert into t1 values (); +set new=1; +select ts+0 from t1; +set new=0; +drop table t1; diff --git a/sql/field.cc b/sql/field.cc index 69ee6606be4..59a71a93d68 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2505,34 +2505,6 @@ void Field_timestamp::store(const char *from,uint len) longstore(ptr,tmp); } -void Field_timestamp::fill_and_store(char *from,uint len) -{ - uint res_length; - if (len <= field_length) - res_length=field_length; - else if (len <= 12) - res_length=12; /* purecov: inspected */ - else if (len <= 14) - res_length=14; /* purecov: inspected */ - else - res_length=(len+1)/2*2; // must be even - if (res_length != len) - { - bmove_upp(from+res_length,from+len,len); - bfill(from,res_length-len,'0'); - len=res_length; - } - long tmp=(long) str_to_timestamp(from,len); -#ifdef WORDS_BIGENDIAN - if (table->db_low_byte_first) - { - int4store(ptr,tmp); - } - else -#endif - longstore(ptr,tmp); -} - void Field_timestamp::store(double nr) { @@ -2644,7 +2616,7 @@ double Field_timestamp::val_real(void) longlong Field_timestamp::val_int(void) { - uint len,pos; + uint len, pos, max_int_rep_len; int part_time; uint32 temp; time_t time_arg; @@ -2665,7 +2637,8 @@ longlong Field_timestamp::val_int(void) localtime_r(&time_arg,&tm_tmp); l_time=&tm_tmp; res=(longlong) 0; - for (pos=len=0; len+1 < (uint) field_length ; len+=2,pos++) + max_int_rep_len= min(field_length, 14); + for (pos= len= 0; len+1 < max_int_rep_len ; len+= 2,pos++) { bool year_flag=0; switch (dayord.pos[pos]) { @@ -2677,7 +2650,7 @@ longlong Field_timestamp::val_int(void) case 5: part_time=l_time->tm_sec; break; default: part_time=0; break; /* purecov: deadcode */ } - if (year_flag && (field_length == 8 || field_length == 14)) + if (year_flag && (max_int_rep_len == 8 || max_int_rep_len == 14)) { res=res*(longlong) 10000+(part_time+ ((part_time < YY_PART_YEAR) ? 2000 : 1900)); diff --git a/sql/field.h b/sql/field.h index 87a9732b41e..3e258f81dcc 100644 --- a/sql/field.h +++ b/sql/field.h @@ -591,7 +591,6 @@ public: longget(tmp,ptr); return tmp; } - void fill_and_store(char *from,uint len); bool get_date(TIME *ltime,bool fuzzydate); bool get_time(TIME *ltime); From 7d865e0b12f98855d6b8687586a994f91764bc75 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 2 Apr 2005 20:13:19 +0200 Subject: [PATCH 2/3] bug#3891 - DROP TABLE many-unexistent-tables, was printing an error with %s instead of table names sql/sql_table.cc: print an error with a function that respects width modifiers (%.64s) mysql-test/r/drop.result: bug#3891 - DROP TABLE many-unexistent-tables, was printing an error with %s instead of table names mysql-test/t/drop.test: bug#3891 - DROP TABLE many-unexistent-tables, was printing an error with %s instead of table names sql/share/english/errmsg.txt: allow longer "table names" as DROP TABLE puts a list here sql/share/russian/errmsg.txt: allow longer "table names" as DROP TABLE puts a list here sql/share/ukrainian/errmsg.txt: allow longer "table names" as DROP TABLE puts a list here sql/sql_table.cc: print an error with a function that respects width modifiers (%.64s) --- mysql-test/r/drop.result | 14 ++++++++++++++ mysql-test/t/drop.test | 23 +++++++++++++++++++++++ sql/share/english/errmsg.txt | 2 +- sql/share/russian/errmsg.txt | 2 +- sql/share/ukrainian/errmsg.txt | 2 +- sql/sql_table.cc | 3 ++- 6 files changed, 42 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result index 5c732aebbcc..b2753e0ff84 100644 --- a/mysql-test/r/drop.result +++ b/mysql-test/r/drop.result @@ -22,6 +22,20 @@ n 4 drop database if exists mysqltest; create database mysqltest; +use mysqltest; +drop table table1, table2, table3, table4, table5, table6, +table7, table8, table9, table10, table11, table12, table13, +table14, table15, table16, table17, table18, table19, table20, +table21, table22, table23, table24, table25, table26, table27, +table28; +Unknown table 'table1,table2,table3,table4,table5,table6,table7,table8,table9,table10,table11,table12,table13,table14,table15,table16,table17,table18,table19,table20,table21,table22,table23,table' +drop table table1, table2, table3, table4, table5, table6, +table7, table8, table9, table10, table11, table12, table13, +table14, table15, table16, table17, table18, table19, table20, +table21, table22, table23, table24, table25, table26, table27, +table28, table29, table30; +Unknown table 'table1,table2,table3,table4,table5,table6,table7,table8,table9,table10,table11,table12,table13,table14,table15,table16,table17,table18,table19,table20,table21,table22,table23,table' +use test; drop database mysqltest; flush tables with read lock; create database mysqltest; diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test index 2f3fa99bac0..51807fe403d 100644 --- a/mysql-test/t/drop.test +++ b/mysql-test/t/drop.test @@ -22,6 +22,28 @@ insert into mysqltest.mysqltest values (4); select * from mysqltest.mysqltest; drop database if exists mysqltest; create database mysqltest; + +# +# drop many tables - bug#3891 +# we'll do it in mysqltest db, to be able to use longer table names +# (tableN instead on tN) +# +use mysqltest; +--error 1051 +drop table table1, table2, table3, table4, table5, table6, +table7, table8, table9, table10, table11, table12, table13, +table14, table15, table16, table17, table18, table19, table20, +table21, table22, table23, table24, table25, table26, table27, +table28; + +--error 1051 +drop table table1, table2, table3, table4, table5, table6, +table7, table8, table9, table10, table11, table12, table13, +table14, table15, table16, table17, table18, table19, table20, +table21, table22, table23, table24, table25, table26, table27, +table28, table29, table30; + +use test; drop database mysqltest; # test drop/create database and FLUSH TABLES WITH READ LOCK @@ -39,3 +61,4 @@ drop database mysqltest; show databases; --error 1008 drop database mysqltest; + diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index cfd878195ac..7c9d789c86e 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -65,7 +65,7 @@ "Column '%-.64s' cannot be null", "Unknown database '%-.64s'", "Table '%-.64s' already exists", -"Unknown table '%-.64s'", +"Unknown table '%-.180s'", "Column: '%-.64s' in %-.64s is ambiguous", "Server shutdown in progress", "Unknown column '%-.64s' in '%-.64s'", diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 172ee97c883..668b310a5dc 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -70,7 +70,7 @@ "Столбец '%-.64s' не может принимать величину NULL", "Неизвестная база данных '%-.64s'", "Таблица '%-.64s' уже существует", -"Неизвестная таблица '%-.64s'", +"Неизвестная таблица '%-.175s'", "Столбец '%-.64s' в %-.64s задан неоднозначно", "Сервер находится в процессе остановки", "Неизвестный столбец '%-.64s' в '%-.64s'", diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index 188523ecf45..131cf07a8e2 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -71,7 +71,7 @@ "Стовбець '%-.64s' не може бути нульовим", "Нев╕дома база данних '%-.64s'", "Таблиця '%-.64s' вже ╕сну╓", -"Нев╕дома таблиця '%-.64s'", +"Нев╕дома таблиця '%-.180s'", "Стовбець '%-.64s' у %-.64s визначений неоднозначно", "Завершу╓ться работа сервера", "Нев╕домий стовбець '%-.64s' у '%-.64s'", diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 33bdd992efb..cef480fadde 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -237,7 +237,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, if (wrong_tables.length()) { if (!foreign_key_error) - my_error(ER_BAD_TABLE_ERROR,MYF(0),wrong_tables.c_ptr()); + my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0), + wrong_tables.c_ptr()); else my_error(ER_ROW_IS_REFERENCED,MYF(0)); error= 1; From a77a2c8354911d7e3c64f7b56c697c3647d7db77 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 2 Apr 2005 21:36:50 +0200 Subject: [PATCH 3/3] results updated --- mysql-test/r/drop.result | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result index 6d67160bc28..40dda86b729 100644 --- a/mysql-test/r/drop.result +++ b/mysql-test/r/drop.result @@ -30,13 +30,13 @@ table7, table8, table9, table10, table11, table12, table13, table14, table15, table16, table17, table18, table19, table20, table21, table22, table23, table24, table25, table26, table27, table28; -Unknown table 'table1,table2,table3,table4,table5,table6,table7,table8,table9,table10,table11,table12,table13,table14,table15,table16,table17,table18,table19,table20,table21,table22,table23,table' +ERROR 42S02: Unknown table 'table1,table2,table3,table4,table5,table6,table7,table8,table9,table10,table11,table12,table13,table14,table15,table16,table17,table18,table19,table20,table21,table22,table23,table' drop table table1, table2, table3, table4, table5, table6, table7, table8, table9, table10, table11, table12, table13, table14, table15, table16, table17, table18, table19, table20, table21, table22, table23, table24, table25, table26, table27, table28, table29, table30; -Unknown table 'table1,table2,table3,table4,table5,table6,table7,table8,table9,table10,table11,table12,table13,table14,table15,table16,table17,table18,table19,table20,table21,table22,table23,table' +ERROR 42S02: Unknown table 'table1,table2,table3,table4,table5,table6,table7,table8,table9,table10,table11,table12,table13,table14,table15,table16,table17,table18,table19,table20,table21,table22,table23,table' use test; drop database mysqltest; flush tables with read lock;