Commit f1a5c49c authored by Sergei Golubchik's avatar Sergei Golubchik

various fixes for buildbot failures

parent 10fedf67
......@@ -99,6 +99,17 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
ulong flags, int *was_cut);
longlong number_to_datetime(longlong nr, ulong sec_part, MYSQL_TIME *time_res,
uint flags, int *was_cut);
static inline
longlong double_to_datetime(double nr, MYSQL_TIME *ltime, uint flags, int *cut)
{
if (nr < 0 || nr > LONGLONG_MAX)
nr= (double)LONGLONG_MAX;
return number_to_datetime((longlong) floor(nr),
(ulong)((nr-floor(nr))*TIME_SECOND_PART_FACTOR),
ltime, flags, cut);
}
int number_to_time(my_bool neg, longlong nr, ulong sec_part,
MYSQL_TIME *ltime, int *was_cut);
ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *);
......
......@@ -196,7 +196,7 @@ f8 date YES NULL
f9 time(6) YES NULL
select * from t1;
f1 f2 f3 f4 f5 f6 f7 f8 f9
1997-01-01 1998-01-02 01:01:00.000003 49:01:01.000001 46:58:57.999999 -24:00:00.000001 10:11:12 2001-12-01 01:01:01.000000 1997-12-31 23:59:59.000001
1997-01-01 1998-01-02 01:01:00.000002 49:01:00.000002 46:58:57.999999 -24:00:00.000001 10:11:12 2001-12-01 01:01:01.000000 1997-12-31 23:59:59.000001
create table test(t1 datetime, t2 time, t3 time, t4 datetime);
insert into test values
('2001-01-01 01:01:01', '01:01:01', null, '2001-02-01 01:01:01'),
......@@ -241,6 +241,8 @@ a
select microsecond(19971231235959.01) as a;
a
10000
Warnings:
Warning 1292 Truncated incorrect time value: '19971231235959.01'
select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a;
a
1997-12-31 00:00:10.090000
......
......@@ -7,7 +7,7 @@ SELECT CONCAT(Jahr,'-',Monat,'-',Tag,' ',Zeit) AS Date,
UNIX_TIMESTAMP(CONCAT(Jahr,'-',Monat,'-',Tag,' ',Zeit)) AS Unix
FROM t1;
Date Unix
1998-9-16 09:26:00 905927160
1998-9-16 09:26:00 905927160
1998-9-16 09:26:00 905927160.000000
1998-9-16 09:26:00 905927160.000000
drop table t1;
set time_zone= @@global.time_zone;
......@@ -923,13 +923,10 @@ INSERT INTO t1 VALUES
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref PRIMARY PRIMARY 20 const 2 Using index condition
Warnings:
Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
item started price
Warnings:
Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 0
Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00'
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
item started price
A1 2005-11-01 08:00:00 1000.000
......@@ -941,7 +938,7 @@ id select_type table type possible_keys key key_len ref rows Extra
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
item started price
Warnings:
Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 0
Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00'
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
item started price
A1 2005-11-01 08:00:00 1000.000
......
......@@ -2121,8 +2121,8 @@ INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
Warnings:
Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 0
Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 0
Warning 1292 Incorrect datetime value: 'wrong-date-value'
Warning 1292 Incorrect datetime value: 'wrong-date-value'
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
DROP TABLE t1,t2;
......@@ -3265,7 +3265,7 @@ f1 f2
4 2005-10-01
5 2005-12-30
Warnings:
Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 0
Warning 1292 Truncated incorrect date value: '2005-09-3a'
select * from t1 where f2 <= '2005-09-31';
f1 f2
1 2005-01-01
......@@ -3276,7 +3276,7 @@ f1 f2
1 2005-01-01
2 2005-09-01
Warnings:
Warning 1292 Incorrect date value: '2005-09-3a' for column 'f2' at row 0
Warning 1292 Truncated incorrect date value: '2005-09-3a'
drop table t1;
create table t1 (f1 int, f2 int);
insert into t1 values (1, 30), (2, 20), (3, 10);
......
......@@ -191,4 +191,4 @@ CAST(CAST('2006-08-10 10:11:12' AS DATETIME) + INTERVAL 14 MICROSECOND AS DECIMA
20060810101112.000014
SELECT CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6));
CAST(CAST('10:11:12.098700' AS TIME) AS DECIMAL(20,6))
101112.098700
101112.000000
......@@ -29,8 +29,8 @@ insert into t1 values("10.22.22"),(1234567),(123456789),(123456789.10),("10 22:2
Warnings:
Warning 1265 Data truncated for column 't' at row 1
Warning 1265 Data truncated for column 't' at row 2
Warning 1264 Out of range value for column 't' at row 3
Warning 1264 Out of range value for column 't' at row 4
Warning 1265 Data truncated for column 't' at row 3
Warning 1265 Data truncated for column 't' at row 4
Warning 1265 Data truncated for column 't' at row 6
select * from t1;
t
......@@ -55,8 +55,8 @@ t
36:30:31
00:00:10
00:00:00
838:59:59
838:59:59
00:00:00
00:00:00
262:22:00
00:00:12
drop table t1;
......
......@@ -225,10 +225,10 @@ c int(11) YES NULL VIRTUAL
d varchar(5) YES NULL PERSISTENT
show full columns from t1;
Field Type Collation Null Key Default Extra Privileges Comment
a int(11) NULL NO NULL select,insert,update,references
b varchar(32) latin1_swedish_ci YES NULL select,insert,update,references
c int(11) NULL YES NULL VIRTUAL select,insert,update,references
d varchar(5) latin1_swedish_ci YES NULL PERSISTENT select,insert,update,references
a int(11) NULL NO NULL #
b varchar(32) latin1_swedish_ci YES NULL #
c int(11) NULL YES NULL VIRTUAL #
d varchar(5) latin1_swedish_ci YES NULL PERSISTENT #
INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,NULL);
UPDATE `test`.`t1` SET `d`='b' WHERE `a`='1' AND `b`='a' AND `c`='1' AND `d`='a';
Warnings:
......
......@@ -195,6 +195,7 @@ CREATE TABLE `t1` (
) ENGINE=MyISAM;
show create table t1;
show columns from t1;
--replace_column 8 #
show full columns from t1;
INSERT INTO `test`.`t1`(`a`,`b`,`c`,`d`) VALUES ( '1','a',NULL,NULL);
UPDATE `test`.`t1` SET `d`='b' WHERE `a`='1' AND `b`='a' AND `c`='1' AND `d`='a';
......
......@@ -1280,7 +1280,7 @@ int number_to_time(my_bool neg, longlong nr, ulong sec_part,
sec_part= TIME_MAX_SECOND_PART;
*was_cut= MYSQL_TIME_WARN_OUT_OF_RANGE;
}
ltime->hour = nr/100/100;
ltime->hour = (uint)(nr/100/100);
ltime->minute= nr/100%100;
ltime->second= nr%100;
ltime->second_part= sec_part;
......
......@@ -4624,12 +4624,7 @@ int Field_timestamp::store(double nr)
Lazy_string_double str(nr);
THD *thd= table->in_use;
/* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */
if (nr < 0 || nr > LONGLONG_MAX)
nr= static_cast<double>(LONGLONG_MAX);
longlong tmp= number_to_datetime((longlong) floor(nr),
(nr-floor(nr))*TIME_SECOND_PART_FACTOR,
&l_time, (thd->variables.sql_mode &
longlong tmp= double_to_datetime(nr, &l_time, (thd->variables.sql_mode &
MODE_NO_ZERO_DATE) |
MODE_NO_ZERO_IN_DATE, &error);
return store_TIME_with_warning(thd, &l_time, &str, error, tmp != -1);
......@@ -5119,11 +5114,7 @@ int Field_temporal::store(double nr)
THD *thd= table->in_use;
Lazy_string_double str(nr);
if (nr < 0 || nr > LONGLONG_MAX)
nr= static_cast<double>(LONGLONG_MAX);
longlong tmp= number_to_datetime((longlong) floor(nr),
((nr-floor(nr))*TIME_SECOND_PART_FACTOR),
&ltime,
longlong tmp= double_to_datetime(nr, &ltime,
(TIME_FUZZY_DATE |
(thd->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE |
......@@ -5231,8 +5222,8 @@ int Field_time::store(double nr)
bool neg= nr < 0;
if (neg)
nr= -nr;
int have_smth_to_conv= !number_to_time(neg, nr,
(nr - trunc(nr)) * TIME_SECOND_PART_FACTOR,
int have_smth_to_conv= !number_to_time(neg, (longlong)nr,
(ulong)((nr - floor(nr)) * TIME_SECOND_PART_FACTOR),
&ltime, &was_cut);
return store_TIME_with_warning(&ltime, &str, was_cut, have_smth_to_conv);
......
......@@ -1433,7 +1433,7 @@ public:
DBUG_ASSERT(dec);
DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS);
zero_point= sec_part_shift(
((TIME_MAX_VALUE_SECONDS+1)*TIME_SECOND_PART_FACTOR), dec);
((TIME_MAX_VALUE_SECONDS+1LL)*TIME_SECOND_PART_FACTOR), dec);
}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
uint decimals() const { return dec; }
......
......@@ -669,11 +669,9 @@ Copy_field::get_copy_func(Field *to,Field *from)
{
/* If types are not 100 % identical then convert trough get_date() */
if (!to->eq_def(from) ||
(((to->table->in_use->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
MODE_INVALID_DATES))) &&
(to->type() == MYSQL_TYPE_DATE ||
to->type() == MYSQL_TYPE_DATETIME)))
((to->table->in_use->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE)) &&
mysql_type_to_time_type(to->type()) != MYSQL_TIMESTAMP_TIME))
return do_field_temporal;
/* Do binary copy */
}
......
......@@ -4186,7 +4186,7 @@ bool Item_dyncol_get::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
return 0;
}
/* let double_to_datetime_with_warn() issue the warning message */
val.double_value= ULONGLONG_MAX;
val.double_value= static_cast<double>(ULONGLONG_MAX);
/* fall_trough */
case DYN_COL_DOUBLE:
if (double_to_datetime_with_warn(val.double_value, ltime, fuzzy_date,
......
......@@ -482,7 +482,7 @@ bool Item_sum::walk (Item_processor processor, bool walk_subquery,
Field *Item_sum::create_tmp_field(bool group, TABLE *table,
uint convert_blob_length)
{
Field *field;
Field *UNINIT_VAR(field);
switch (result_type()) {
case REAL_RESULT:
field= new Field_double(max_length, maybe_null, name, decimals, TRUE);
......
......@@ -290,16 +290,16 @@ bool double_to_datetime_with_warn(double value, MYSQL_TIME *ltime,
ulong fuzzydate, const char *field_name)
{
const Lazy_string_double str(value);
ulonglong nr;
ulong sec_part;
bool neg= value < 0;
if (neg)
value= -value;
nr = value > LONGLONG_MAX ? LONGLONG_MAX
: static_cast<ulonglong>(trunc(value));
sec_part= (ulong)((value - nr)*TIME_SECOND_PART_FACTOR);
if (value > LONGLONG_MAX)
value= static_cast<double>(LONGLONG_MAX);
longlong nr= static_cast<ulonglong>(floor(value));
uint sec_part= static_cast<ulong>((value - floor(value))*TIME_SECOND_PART_FACTOR);
return number_to_time_with_warn(neg, nr, sec_part, ltime, fuzzydate, &str,
field_name);
}
......@@ -857,7 +857,7 @@ bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type,
{
if (usec > TIME_MAX_HOUR)
goto invalid_date;
ltime->hour= usec;
ltime->hour= static_cast<uint>(usec);
ltime->day= 0;
return 0;
}
......
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