Commit 59408093 authored by Sergei Golubchik's avatar Sergei Golubchik

5.3 merge

parents a1fd37b1 51e14492
...@@ -84,6 +84,7 @@ typedef struct my_aio_result { ...@@ -84,6 +84,7 @@ typedef struct my_aio_result {
#define MY_THREADSAFE 2048 /* my_seek(): lock fd mutex */ #define MY_THREADSAFE 2048 /* my_seek(): lock fd mutex */
#define MY_SYNC 4096 /* my_copy(): sync dst file */ #define MY_SYNC 4096 /* my_copy(): sync dst file */
#define MY_SYNC_DIR 32768 /* my_create/delete/rename: sync directory */ #define MY_SYNC_DIR 32768 /* my_create/delete/rename: sync directory */
#define MY_SYNC_FILESIZE 65536 /* my_sync(): safe sync when file is extended */
#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */ #define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */
#define MY_GIVE_INFO 2 /* Give time info about process*/ #define MY_GIVE_INFO 2 /* Give time info about process*/
......
create table t1 (d date);
insert into t1 values ('2012-00-00');
select * from t1;
d
2012-00-00
update t1 set d = adddate(d, interval 1 day);
select * from t1;
d
NULL
drop table t1;
create table t1 (d datetime);
insert t1 values (addtime('9999-12-31 23:59:59', '00:00:01')),
(from_days(3652499));
select * from t1;
d
NULL
NULL
drop table t1;
...@@ -160,3 +160,11 @@ ERROR 42S22: Unknown column '' in 'VALUES() function' ...@@ -160,3 +160,11 @@ ERROR 42S22: Unknown column '' in 'VALUES() function'
INSERT INTO t2(a,b) VALUES (1,0) ON DUPLICATE KEY UPDATE INSERT INTO t2(a,b) VALUES (1,0) ON DUPLICATE KEY UPDATE
b=(SELECT VALUES(a)+2 FROM t1); b=(SELECT VALUES(a)+2 FROM t1);
DROP TABLE t1, t2; DROP TABLE t1, t2;
#
# MDEV-492: incorrect error check before sending OK in mysql_update
#
CREATE TABLE t1 (a CHAR(3), b BLOB);
UPDATE t1 SET a = 'new'
WHERE COLUMN_CREATE( 1, 'v', 1, 'w' ) IS NULL;
ERROR 22007: Illegal value used as argument of dynamic column function
drop table t1;
...@@ -1922,3 +1922,5 @@ cast(greatest(cast("0-0-0" as date), cast("10:20:05" as time)) as datetime(6)) ...@@ -1922,3 +1922,5 @@ cast(greatest(cast("0-0-0" as date), cast("10:20:05" as time)) as datetime(6))
select microsecond('12:00:00.123456'), microsecond('2009-12-31 23:59:59.000010'); select microsecond('12:00:00.123456'), microsecond('2009-12-31 23:59:59.000010');
microsecond('12:00:00.123456') microsecond('2009-12-31 23:59:59.000010') microsecond('12:00:00.123456') microsecond('2009-12-31 23:59:59.000010')
123456 10 123456 10
select now(258);
ERROR 42000: Too big precision 258 specified for 'now'. Maximum is 6.
#
# MDEV-454 Addition of a time interval reduces the resulting value
#
create table t1 (d date);
insert into t1 values ('2012-00-00');
select * from t1;
update t1 set d = adddate(d, interval 1 day);
select * from t1;
drop table t1;
#
# MDEV-456 An out-of-range datetime value (with a 5-digit year) can be created and cause troubles
#
create table t1 (d datetime);
insert t1 values (addtime('9999-12-31 23:59:59', '00:00:01')),
(from_days(3652499));
select * from t1;
drop table t1;
...@@ -189,3 +189,12 @@ INSERT INTO t2 VALUES (1,0) ON DUPLICATE KEY UPDATE ...@@ -189,3 +189,12 @@ INSERT INTO t2 VALUES (1,0) ON DUPLICATE KEY UPDATE
INSERT INTO t2(a,b) VALUES (1,0) ON DUPLICATE KEY UPDATE INSERT INTO t2(a,b) VALUES (1,0) ON DUPLICATE KEY UPDATE
b=(SELECT VALUES(a)+2 FROM t1); b=(SELECT VALUES(a)+2 FROM t1);
DROP TABLE t1, t2; DROP TABLE t1, t2;
--echo #
--echo # MDEV-492: incorrect error check before sending OK in mysql_update
--echo #
CREATE TABLE t1 (a CHAR(3), b BLOB);
--error ER_DYN_COL_DATA
UPDATE t1 SET a = 'new'
WHERE COLUMN_CREATE( 1, 'v', 1, 'w' ) IS NULL;
drop table t1;
...@@ -1172,3 +1172,5 @@ select cast(greatest(cast("0-0-0" as date), cast("10:20:05" as time)) as datetim ...@@ -1172,3 +1172,5 @@ select cast(greatest(cast("0-0-0" as date), cast("10:20:05" as time)) as datetim
select microsecond('12:00:00.123456'), microsecond('2009-12-31 23:59:59.000010'); select microsecond('12:00:00.123456'), microsecond('2009-12-31 23:59:59.000010');
--error ER_TOO_BIG_PRECISION
select now(258);
...@@ -49,6 +49,13 @@ void thr_set_sync_wait_callback(void (*before_wait)(void), ...@@ -49,6 +49,13 @@ void thr_set_sync_wait_callback(void (*before_wait)(void),
(which is correct behaviour, if we know that the other thread synced the (which is correct behaviour, if we know that the other thread synced the
file before closing) file before closing)
MY_SYNC_FILESIZE is useful when syncing a file after it has been extended.
On Linux, fdatasync() on ext3/ext4 file systems does not properly flush
to disk the inode data required to preserve the added data across a crash
(this looks to be a bug). But when a file is extended, inode data will most
likely need flushing in any case, so passing MY_SYNC_FILESIZE as flags
is not likely to be any slower, and will be crash safe on Linux ext3/ext4.
RETURN RETURN
0 ok 0 ok
-1 error -1 error
...@@ -84,8 +91,12 @@ int my_sync(File fd, myf my_flags) ...@@ -84,8 +91,12 @@ int my_sync(File fd, myf my_flags)
DBUG_PRINT("info",("fcntl(F_FULLFSYNC) failed, falling back")); DBUG_PRINT("info",("fcntl(F_FULLFSYNC) failed, falling back"));
#endif #endif
#if defined(HAVE_FDATASYNC) && HAVE_DECL_FDATASYNC #if defined(HAVE_FDATASYNC) && HAVE_DECL_FDATASYNC
if (!(my_flags & MY_SYNC_FILESIZE))
res= fdatasync(fd); res= fdatasync(fd);
#elif defined(HAVE_FSYNC) else
{
#endif
#if defined(HAVE_FSYNC)
res= fsync(fd); res= fsync(fd);
if (res == -1 && errno == ENOLCK) if (res == -1 && errno == ENOLCK)
res= 0; /* Result Bug in Old FreeBSD */ res= 0; /* Result Bug in Old FreeBSD */
...@@ -94,6 +105,9 @@ int my_sync(File fd, myf my_flags) ...@@ -94,6 +105,9 @@ int my_sync(File fd, myf my_flags)
#else #else
#error Cannot find a way to sync a file, durability in danger #error Cannot find a way to sync a file, durability in danger
res= 0; /* No sync (strange OS) */ res= 0; /* No sync (strange OS) */
#endif
#if defined(HAVE_FDATASYNC) && HAVE_DECL_FDATASYNC
}
#endif #endif
} while (res == -1 && errno == EINTR); } while (res == -1 && errno == EINTR);
......
...@@ -5677,7 +5677,7 @@ bool Field_newdate::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) ...@@ -5677,7 +5677,7 @@ bool Field_newdate::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
if (!tmp) if (!tmp)
return fuzzydate & TIME_NO_ZERO_DATE; return fuzzydate & TIME_NO_ZERO_DATE;
if (!ltime->month || !ltime->day) if (!ltime->month || !ltime->day)
return !(fuzzydate & TIME_FUZZY_DATE); return fuzzydate & TIME_NO_ZERO_IN_DATE;
return 0; return 0;
} }
......
...@@ -503,8 +503,8 @@ Item::Item(THD *thd, Item *item): ...@@ -503,8 +503,8 @@ Item::Item(THD *thd, Item *item):
orig_name(item->orig_name), orig_name(item->orig_name),
max_length(item->max_length), max_length(item->max_length),
name_length(item->name_length), name_length(item->name_length),
marker(item->marker),
decimals(item->decimals), decimals(item->decimals),
marker(item->marker),
maybe_null(item->maybe_null), maybe_null(item->maybe_null),
in_rollup(item->in_rollup), in_rollup(item->in_rollup),
null_value(item->null_value), null_value(item->null_value),
......
...@@ -618,8 +618,8 @@ public: ...@@ -618,8 +618,8 @@ public:
calls. calls.
*/ */
uint name_length; /* Length of name */ uint name_length; /* Length of name */
uint decimals;
int8 marker; int8 marker;
uint8 decimals;
bool maybe_null; /* If item may be null */ bool maybe_null; /* If item may be null */
bool in_rollup; /* If used in GROUP BY list bool in_rollup; /* If used in GROUP BY list
of a query with ROLLUP */ of a query with ROLLUP */
......
...@@ -361,9 +361,8 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, ...@@ -361,9 +361,8 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
{ {
uint days; uint days;
days= calc_daynr(l_time->year,1,1) + yearday - 1; days= calc_daynr(l_time->year,1,1) + yearday - 1;
if (days <= 0 || days > MAX_DAY_NUMBER) if (get_date_from_daynr(days,&l_time->year,&l_time->month,&l_time->day))
goto err; goto err;
get_date_from_daynr(days,&l_time->year,&l_time->month,&l_time->day);
} }
if (week_number >= 0 && weekday) if (week_number >= 0 && weekday)
...@@ -408,9 +407,8 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, ...@@ -408,9 +407,8 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
(weekday - 1); (weekday - 1);
} }
if (days <= 0 || days > MAX_DAY_NUMBER) if (get_date_from_daynr(days,&l_time->year,&l_time->month,&l_time->day))
goto err; goto err;
get_date_from_daynr(days,&l_time->year,&l_time->month,&l_time->day);
} }
if (l_time->month > 12 || l_time->day > 31 || l_time->hour > 23 || if (l_time->month > 12 || l_time->day > 31 || l_time->hour > 23 ||
...@@ -768,7 +766,7 @@ longlong Item_func_to_days::val_int() ...@@ -768,7 +766,7 @@ longlong Item_func_to_days::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime; MYSQL_TIME ltime;
if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE)) if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE))
return 0; return 0;
return (longlong) calc_daynr(ltime.year,ltime.month,ltime.day); return (longlong) calc_daynr(ltime.year,ltime.month,ltime.day);
} }
...@@ -808,7 +806,7 @@ longlong Item_func_to_seconds::val_int() ...@@ -808,7 +806,7 @@ longlong Item_func_to_seconds::val_int()
MYSQL_TIME ltime; MYSQL_TIME ltime;
longlong seconds; longlong seconds;
longlong days; longlong days;
if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE)) if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE))
return 0; return 0;
seconds= ltime.hour * 3600L + ltime.minute * 60 + ltime.second; seconds= ltime.hour * 3600L + ltime.minute * 60 + ltime.second;
seconds=ltime.neg ? -seconds : seconds; seconds=ltime.neg ? -seconds : seconds;
...@@ -1501,10 +1499,11 @@ bool Item_func_from_days::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) ...@@ -1501,10 +1499,11 @@ bool Item_func_from_days::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
if ((fuzzy_date & TIME_NO_ZERO_DATE) && value == 0) if ((fuzzy_date & TIME_NO_ZERO_DATE) && value == 0)
return (null_value= 1); return (null_value= 1);
bzero(ltime, sizeof(MYSQL_TIME)); bzero(ltime, sizeof(MYSQL_TIME));
get_date_from_daynr((long) value, &ltime->year, &ltime->month, &ltime->day); if (get_date_from_daynr((long) value, &ltime->year, &ltime->month,
&ltime->day))
return (null_value= 1);
if ((fuzzy_date & TIME_NO_ZERO_DATE) && if ((fuzzy_date & TIME_NO_ZERO_DATE) && ltime->year == 0)
(ltime->year == 0 || ltime->month == 0 || ltime->day == 0))
return (null_value= 1); return (null_value= 1);
ltime->time_type= MYSQL_TIMESTAMP_DATE; ltime->time_type= MYSQL_TIMESTAMP_DATE;
...@@ -2043,7 +2042,7 @@ bool Item_date_add_interval::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) ...@@ -2043,7 +2042,7 @@ bool Item_date_add_interval::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
{ {
INTERVAL interval; INTERVAL interval;
if (args[0]->get_date(ltime, TIME_NO_ZERO_DATE | TIME_FUZZY_DATE) || if (args[0]->get_date(ltime, TIME_NO_ZERO_DATE | TIME_FUZZY_DATE | TIME_NO_ZERO_IN_DATE) ||
get_interval_value(args[1], int_type, &interval)) get_interval_value(args[1], int_type, &interval))
return (null_value=1); return (null_value=1);
...@@ -2514,14 +2513,12 @@ bool Item_func_makedate::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) ...@@ -2514,14 +2513,12 @@ bool Item_func_makedate::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
year= year_2000_handling(year); year= year_2000_handling(year);
days= calc_daynr(year,1,1) + daynr - 1; days= calc_daynr(year,1,1) + daynr - 1;
/* Day number from year 0 to 9999-12-31 */ if (get_date_from_daynr(days, &ltime->year, &ltime->month, &ltime->day))
if (days >= 0 && days <= MAX_DAY_NUMBER) goto err;
{
bzero(ltime, sizeof(*ltime));
ltime->time_type= MYSQL_TIMESTAMP_DATE; ltime->time_type= MYSQL_TIMESTAMP_DATE;
get_date_from_daynr(days, &ltime->year, &ltime->month, &ltime->day); ltime->neg= 0;
ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
return (null_value= 0); return (null_value= 0);
}
err: err:
return (null_value= 1); return (null_value= 1);
...@@ -2615,8 +2612,8 @@ bool Item_func_add_time::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) ...@@ -2615,8 +2612,8 @@ bool Item_func_add_time::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
if (!is_time) if (!is_time)
{ {
get_date_from_daynr(days,&ltime->year,&ltime->month,&ltime->day); if (get_date_from_daynr(days,&ltime->year,&ltime->month,&ltime->day) ||
if (!ltime->day) !ltime->day)
return (null_value= 1); return (null_value= 1);
return (null_value= 0); return (null_value= 0);
} }
......
...@@ -3182,7 +3182,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name, ...@@ -3182,7 +3182,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name,
bytes_written+= description_event_for_queue->data_written; bytes_written+= description_event_for_queue->data_written;
} }
if (flush_io_cache(&log_file) || if (flush_io_cache(&log_file) ||
mysql_file_sync(log_file.file, MYF(MY_WME))) mysql_file_sync(log_file.file, MYF(MY_WME|MY_SYNC_FILESIZE)))
goto err; goto err;
mysql_mutex_lock(&LOCK_commit_ordered); mysql_mutex_lock(&LOCK_commit_ordered);
strmake(last_commit_pos_file, log_file_name, strmake(last_commit_pos_file, log_file_name,
...@@ -3212,7 +3212,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name, ...@@ -3212,7 +3212,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name,
strlen(log_file_name)) || strlen(log_file_name)) ||
my_b_write(&index_file, (uchar*) "\n", 1) || my_b_write(&index_file, (uchar*) "\n", 1) ||
flush_io_cache(&index_file) || flush_io_cache(&index_file) ||
mysql_file_sync(index_file.file, MYF(MY_WME))) mysql_file_sync(index_file.file, MYF(MY_WME|MY_SYNC_FILESIZE)))
goto err; goto err;
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
...@@ -3302,7 +3302,7 @@ static bool copy_up_file_and_fill(IO_CACHE *index_file, my_off_t offset) ...@@ -3302,7 +3302,7 @@ static bool copy_up_file_and_fill(IO_CACHE *index_file, my_off_t offset)
} }
/* The following will either truncate the file or fill the end with \n' */ /* The following will either truncate the file or fill the end with \n' */
if (mysql_file_chsize(file, offset - init_offset, '\n', MYF(MY_WME)) || if (mysql_file_chsize(file, offset - init_offset, '\n', MYF(MY_WME)) ||
mysql_file_sync(file, MYF(MY_WME))) mysql_file_sync(file, MYF(MY_WME|MY_SYNC_FILESIZE)))
goto err; goto err;
/* Reset data in old index cache */ /* Reset data in old index cache */
...@@ -3939,7 +3939,7 @@ int MYSQL_BIN_LOG::sync_purge_index_file() ...@@ -3939,7 +3939,7 @@ int MYSQL_BIN_LOG::sync_purge_index_file()
DBUG_ENTER("MYSQL_BIN_LOG::sync_purge_index_file"); DBUG_ENTER("MYSQL_BIN_LOG::sync_purge_index_file");
if ((error= flush_io_cache(&purge_index_file)) || if ((error= flush_io_cache(&purge_index_file)) ||
(error= my_sync(purge_index_file.file, MYF(MY_WME)))) (error= my_sync(purge_index_file.file, MYF(MY_WME|MY_SYNC_FILESIZE))))
DBUG_RETURN(error); DBUG_RETURN(error);
DBUG_RETURN(error); DBUG_RETURN(error);
...@@ -4556,7 +4556,7 @@ bool MYSQL_BIN_LOG::flush_and_sync(bool *synced) ...@@ -4556,7 +4556,7 @@ bool MYSQL_BIN_LOG::flush_and_sync(bool *synced)
if (sync_period && ++sync_counter >= sync_period) if (sync_period && ++sync_counter >= sync_period)
{ {
sync_counter= 0; sync_counter= 0;
err= mysql_file_sync(fd, MYF(MY_WME)); err= mysql_file_sync(fd, MYF(MY_WME|MY_SYNC_FILESIZE));
if (synced) if (synced)
*synced= 1; *synced= 1;
#ifndef DBUG_OFF #ifndef DBUG_OFF
......
...@@ -3876,8 +3876,9 @@ int JOIN_TAB_SCAN_MRR::next() ...@@ -3876,8 +3876,9 @@ int JOIN_TAB_SCAN_MRR::next()
If a record in in an incremental cache contains no fields then the If a record in in an incremental cache contains no fields then the
association for the last record in cache will be equal to cache->end_pos association for the last record in cache will be equal to cache->end_pos
*/ */
DBUG_ASSERT(cache->buff <= (uchar *) (*ptr) && DBUG_ASSERT((!(mrr_mode & HA_MRR_NO_ASSOCIATION))?
(uchar *) (*ptr) <= cache->end_pos); (cache->buff <= (uchar *) (*ptr) &&
(uchar *) (*ptr) <= cache->end_pos): TRUE);
if (join_tab->table->vfield) if (join_tab->table->vfield)
update_virtual_fields(join->thd, join_tab->table); update_virtual_fields(join->thd, join_tab->table);
} }
...@@ -4543,7 +4544,7 @@ bool JOIN_CACHE_BKAH::prepare_look_for_matches(bool skip_last) ...@@ -4543,7 +4544,7 @@ bool JOIN_CACHE_BKAH::prepare_look_for_matches(bool skip_last)
{ {
last_matching_rec_ref_ptr= next_matching_rec_ref_ptr= 0; last_matching_rec_ref_ptr= next_matching_rec_ref_ptr= 0;
if (no_association && if (no_association &&
(curr_matching_chain= get_matching_chain_by_join_key())) !(curr_matching_chain= get_matching_chain_by_join_key()))
return 1; return 1;
last_matching_rec_ref_ptr= get_next_rec_ref(curr_matching_chain); last_matching_rec_ref_ptr= get_next_rec_ref(curr_matching_chain);
return 0; return 0;
......
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
#include <m_ctype.h> #include <m_ctype.h>
/* Some functions to calculate dates */ #define MAX_DAY_NUMBER 3652424L
#ifndef TESTTIME /* Some functions to calculate dates */
/* /*
Name description of interval names used in statements. Name description of interval names used in statements.
...@@ -147,19 +147,16 @@ uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year) ...@@ -147,19 +147,16 @@ uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year)
/* Change a daynr to year, month and day */ /* Change a daynr to year, month and day */
/* Daynr 0 is returned as date 00.00.00 */ /* Daynr 0 is returned as date 00.00.00 */
void get_date_from_daynr(long daynr,uint *ret_year,uint *ret_month, bool get_date_from_daynr(long daynr,uint *ret_year,uint *ret_month,
uint *ret_day) uint *ret_day)
{ {
uint year,temp,leap_day,day_of_year,days_in_year; uint year,temp,leap_day,day_of_year,days_in_year;
uchar *month_pos; uchar *month_pos;
DBUG_ENTER("get_date_from_daynr"); DBUG_ENTER("get_date_from_daynr");
if (daynr <= 365L || daynr >= 3652500) if (daynr < 365 || daynr > MAX_DAY_NUMBER)
{ /* Fix if wrong daynr */ DBUG_RETURN(1);
*ret_year= *ret_month = *ret_day =0;
}
else
{
year= (uint) (daynr*100 / 36525L); year= (uint) (daynr*100 / 36525L);
temp=(((year-1)/100+1)*3)/4; temp=(((year-1)/100+1)*3)/4;
day_of_year=(uint) (daynr - (long) year * 365L) - (year-1)/4 +temp; day_of_year=(uint) (daynr - (long) year * 365L) - (year-1)/4 +temp;
...@@ -185,8 +182,7 @@ void get_date_from_daynr(long daynr,uint *ret_year,uint *ret_month, ...@@ -185,8 +182,7 @@ void get_date_from_daynr(long daynr,uint *ret_year,uint *ret_month,
; ;
*ret_year=year; *ret_year=year;
*ret_day=day_of_year+leap_day; *ret_day=day_of_year+leap_day;
} DBUG_RETURN(0);
DBUG_VOID_RETURN;
} }
/* Functions to handle periods */ /* Functions to handle periods */
...@@ -842,7 +838,6 @@ void make_truncated_value_warning(THD *thd, ...@@ -842,7 +838,6 @@ void make_truncated_value_warning(THD *thd,
/* Daynumber from year 0 to 9999-12-31 */ /* Daynumber from year 0 to 9999-12-31 */
#define MAX_DAY_NUMBER 3652424L
#define COMBINE(X) \ #define COMBINE(X) \
(((((X)->day * 24LL + (X)->hour) * 60LL + \ (((((X)->day * 24LL + (X)->hour) * 60LL + \
(X)->minute) * 60LL + (X)->second)*1000000LL + \ (X)->minute) * 60LL + (X)->second)*1000000LL + \
...@@ -909,19 +904,18 @@ bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, ...@@ -909,19 +904,18 @@ bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type,
daynr= usec; daynr= usec;
/* Day number from year 0 to 9999-12-31 */ /* Day number from year 0 to 9999-12-31 */
if ((ulonglong) daynr > MAX_DAY_NUMBER) if (get_date_from_daynr((long) daynr, &ltime->year, &ltime->month,
&ltime->day))
goto invalid_date; goto invalid_date;
get_date_from_daynr((long) daynr, &ltime->year, &ltime->month,
&ltime->day);
break; break;
} }
case INTERVAL_WEEK: case INTERVAL_WEEK:
period= (calc_daynr(ltime->year,ltime->month,ltime->day) + period= (calc_daynr(ltime->year,ltime->month,ltime->day) +
sign * (long) interval.day); sign * (long) interval.day);
/* Daynumber from year 0 to 9999-12-31 */ /* Daynumber from year 0 to 9999-12-31 */
if ((ulong) period > MAX_DAY_NUMBER) if (get_date_from_daynr((long) period,&ltime->year,&ltime->month,
&ltime->day))
goto invalid_date; goto invalid_date;
get_date_from_daynr((long) period,&ltime->year,&ltime->month,&ltime->day);
break; break;
case INTERVAL_YEAR: case INTERVAL_YEAR:
ltime->year+= sign * (long) interval.year; ltime->year+= sign * (long) interval.year;
...@@ -1071,4 +1065,3 @@ int my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b) ...@@ -1071,4 +1065,3 @@ int my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b)
return 0; return 0;
} }
#endif
...@@ -33,7 +33,7 @@ typedef struct st_known_date_time_format KNOWN_DATE_TIME_FORMAT; ...@@ -33,7 +33,7 @@ typedef struct st_known_date_time_format KNOWN_DATE_TIME_FORMAT;
ulong convert_period_to_month(ulong period); ulong convert_period_to_month(ulong period);
ulong convert_month_to_period(ulong month); ulong convert_month_to_period(ulong month);
void get_date_from_daynr(long daynr,uint *year, uint *month, uint *day); bool get_date_from_daynr(long daynr,uint *year, uint *month, uint *day);
my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, uint *error_code); my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, uint *error_code);
bool str_to_time_with_warn(CHARSET_INFO *cs, const char *str, uint length, bool str_to_time_with_warn(CHARSET_INFO *cs, const char *str, uint length,
MYSQL_TIME *l_time, ulonglong fuzzydate); MYSQL_TIME *l_time, ulonglong fuzzydate);
......
...@@ -406,7 +406,7 @@ int mysql_update(THD *thd, ...@@ -406,7 +406,7 @@ int mysql_update(THD *thd,
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK); table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
select= make_select(table, 0, 0, conds, 0, &error); select= make_select(table, 0, 0, conds, 0, &error);
if (error || !limit || if (error || !limit || thd->is_error() ||
(select && select->check_quick(thd, safe_update, limit))) (select && select->check_quick(thd, safe_update, limit)))
{ {
delete select; delete select;
......
...@@ -5872,9 +5872,9 @@ attribute: ...@@ -5872,9 +5872,9 @@ attribute:
NULL_SYM { Lex->type&= ~ NOT_NULL_FLAG; } NULL_SYM { Lex->type&= ~ NOT_NULL_FLAG; }
| not NULL_SYM { Lex->type|= NOT_NULL_FLAG; } | not NULL_SYM { Lex->type|= NOT_NULL_FLAG; }
| DEFAULT now_or_signed_literal { Lex->default_value=$2; } | DEFAULT now_or_signed_literal { Lex->default_value=$2; }
| ON UPDATE_SYM NOW_SYM opt_time_precision | ON UPDATE_SYM NOW_SYM optional_braces
{ {
Item *item= new (YYTHD->mem_root) Item_func_now_local($4); Item *item= new (YYTHD->mem_root) Item_func_now_local(6);
if (item == NULL) if (item == NULL)
MYSQL_YYABORT; MYSQL_YYABORT;
Lex->on_update_value= item; Lex->on_update_value= item;
...@@ -5966,9 +5966,9 @@ type_with_opt_collate: ...@@ -5966,9 +5966,9 @@ type_with_opt_collate:
now_or_signed_literal: now_or_signed_literal:
NOW_SYM opt_time_precision NOW_SYM optional_braces
{ {
$$= new (YYTHD->mem_root) Item_func_now_local($2); $$= new (YYTHD->mem_root) Item_func_now_local(6);
if ($$ == NULL) if ($$ == NULL)
MYSQL_YYABORT; MYSQL_YYABORT;
} }
......
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