diff options
author | Michael Widenius <monty@mariadb.org> | 2016-06-29 09:14:22 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2016-06-30 11:43:02 +0200 |
commit | db7edfed17efe6bc3684b0fbacc0b0249e4f0fa2 (patch) | |
tree | f1f484057487a73d32f379a5fdaacd53bfa27b5e /sql/item_timefunc.cc | |
parent | 23d03a1b1e486da353f20964a1b91068bec209c0 (diff) | |
download | mariadb-git-db7edfed17efe6bc3684b0fbacc0b0249e4f0fa2.tar.gz |
MDEV-7563 Support CHECK constraint as in (or close to) SQL Standard
MDEV-10134 Add full support for DEFAULT
- Added support for using tables with MySQL 5.7 virtual fields,
including MySQL 5.7 syntax
- Better error messages also for old cases
- CREATE ... SELECT now also updates timestamp columns
- Blob can now have default values
- Added new system variable "check_constraint_checks", to turn of
CHECK constraint checking if needed.
- Removed some engine independent tests in suite vcol to only test myisam
- Moved some tests from 'include' to 't'. Should some day be done for all tests.
- FRM version increased to 11 if one uses virtual fields or constraints
- Changed to use a bitmap to check if a field has got a value, instead of
setting HAS_EXPLICIT_VALUE bit in field flags
- Expressions can now be up to 65K in total
- Ensure we are not refering to uninitialized fields when handling virtual fields or defaults
- Changed check_vcol_func_processor() to return a bitmap of used types
- Had to change some functions that calculated cached value in fix_fields to do
this in val() or getdate() instead.
- store_now_in_TIME() now takes a THD argument
- fill_record() now updates default values
- Add a lookahead for NOT NULL, to be able to handle DEFAULT 1+1 NOT NULL
- Automatically generate a name for constraints that doesn't have a name
- Added support for ALTER TABLE DROP CONSTRAINT
- Ensure that partition functions register virtual fields used. This fixes
some bugs when using virtual fields in a partitioning function
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r-- | sql/item_timefunc.cc | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 16edb35c392..69eb3d63dd8 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1465,7 +1465,7 @@ void Item_temporal_func::fix_length_and_dec() We set maybe_null to 1 as default as any bad argument with date or time can get us to return NULL. */ - maybe_null= 1; + maybe_null= (arg_count > 0); if (decimals) { if (decimals == NOT_FIXED_DEC) @@ -1581,24 +1581,12 @@ bool Item_func_from_days::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) } -void Item_func_curdate::fix_length_and_dec() -{ - store_now_in_TIME(<ime); - - /* We don't need to set second_part and neg because they already 0 */ - ltime.hour= ltime.minute= ltime.second= 0; - ltime.time_type= MYSQL_TIMESTAMP_DATE; - Item_datefunc::fix_length_and_dec(); - maybe_null= false; -} - /** Converts current time in my_time_t to MYSQL_TIME represenatation for local time zone. Defines time zone (local) used for whole CURDATE function. */ -void Item_func_curdate_local::store_now_in_TIME(MYSQL_TIME *now_time) +void Item_func_curdate_local::store_now_in_TIME(THD *thd, MYSQL_TIME *now_time) { - THD *thd= current_thd; thd->variables.time_zone->gmt_sec_to_TIME(now_time, thd->query_start()); thd->time_zone_used= 1; } @@ -1608,9 +1596,8 @@ void Item_func_curdate_local::store_now_in_TIME(MYSQL_TIME *now_time) Converts current time in my_time_t to MYSQL_TIME represenatation for UTC time zone. Defines time zone (UTC) used for whole UTC_DATE function. */ -void Item_func_curdate_utc::store_now_in_TIME(MYSQL_TIME *now_time) +void Item_func_curdate_utc::store_now_in_TIME(THD *thd, MYSQL_TIME *now_time) { - THD *thd= current_thd; my_tz_UTC->gmt_sec_to_TIME(now_time, thd->query_start()); /* We are not flagging this query as using time zone, since it uses fixed @@ -1622,6 +1609,17 @@ void Item_func_curdate_utc::store_now_in_TIME(MYSQL_TIME *now_time) bool Item_func_curdate::get_date(MYSQL_TIME *res, ulonglong fuzzy_date __attribute__((unused))) { + THD *thd= current_thd; + query_id_t query_id= thd->query_id; + /* Cache value for this query */ + if (last_query_id != query_id) + { + last_query_id= query_id; + store_now_in_TIME(thd, <ime); + /* We don't need to set second_part and neg because they already 0 */ + ltime.hour= ltime.minute= ltime.second= 0; + ltime.time_type= MYSQL_TIMESTAMP_DATE; + } *res=ltime; return 0; } @@ -1641,6 +1639,14 @@ bool Item_func_curtime::fix_fields(THD *thd, Item **items) bool Item_func_curtime::get_date(MYSQL_TIME *res, ulonglong fuzzy_date __attribute__((unused))) { + THD *thd= current_thd; + query_id_t query_id= thd->query_id; + /* Cache value for this query */ + if (last_query_id != query_id) + { + last_query_id= query_id; + store_now_in_TIME(thd, <ime); + } *res= ltime; return 0; } @@ -1661,9 +1667,8 @@ static void set_sec_part(ulong sec_part, MYSQL_TIME *ltime, Item *item) Converts current time in my_time_t to MYSQL_TIME represenatation for local time zone. Defines time zone (local) used for whole CURTIME function. */ -void Item_func_curtime_local::store_now_in_TIME(MYSQL_TIME *now_time) +void Item_func_curtime_local::store_now_in_TIME(THD *thd, MYSQL_TIME *now_time) { - THD *thd= current_thd; thd->variables.time_zone->gmt_sec_to_TIME(now_time, thd->query_start()); now_time->year= now_time->month= now_time->day= 0; now_time->time_type= MYSQL_TIMESTAMP_TIME; @@ -1676,9 +1681,8 @@ void Item_func_curtime_local::store_now_in_TIME(MYSQL_TIME *now_time) Converts current time in my_time_t to MYSQL_TIME represenatation for UTC time zone. Defines time zone (UTC) used for whole UTC_TIME function. */ -void Item_func_curtime_utc::store_now_in_TIME(MYSQL_TIME *now_time) +void Item_func_curtime_utc::store_now_in_TIME(THD *thd, MYSQL_TIME *now_time) { - THD *thd= current_thd; my_tz_UTC->gmt_sec_to_TIME(now_time, thd->query_start()); now_time->year= now_time->month= now_time->day= 0; now_time->time_type= MYSQL_TIMESTAMP_TIME; @@ -1704,9 +1708,8 @@ bool Item_func_now::fix_fields(THD *thd, Item **items) Converts current time in my_time_t to MYSQL_TIME represenatation for local time zone. Defines time zone (local) used for whole NOW function. */ -void Item_func_now_local::store_now_in_TIME(MYSQL_TIME *now_time) +void Item_func_now_local::store_now_in_TIME(THD *thd, MYSQL_TIME *now_time) { - THD *thd= current_thd; thd->variables.time_zone->gmt_sec_to_TIME(now_time, thd->query_start()); set_sec_part(thd->query_start_sec_part(), now_time, this); thd->time_zone_used= 1; @@ -1717,9 +1720,8 @@ void Item_func_now_local::store_now_in_TIME(MYSQL_TIME *now_time) Converts current time in my_time_t to MYSQL_TIME represenatation for UTC time zone. Defines time zone (UTC) used for whole UTC_TIMESTAMP function. */ -void Item_func_now_utc::store_now_in_TIME(MYSQL_TIME *now_time) +void Item_func_now_utc::store_now_in_TIME(THD *thd, MYSQL_TIME *now_time) { - THD *thd= current_thd; my_tz_UTC->gmt_sec_to_TIME(now_time, thd->query_start()); set_sec_part(thd->query_start_sec_part(), now_time, this); /* @@ -1732,6 +1734,14 @@ void Item_func_now_utc::store_now_in_TIME(MYSQL_TIME *now_time) bool Item_func_now::get_date(MYSQL_TIME *res, ulonglong fuzzy_date __attribute__((unused))) { + THD *thd= current_thd; + query_id_t query_id= thd->query_id; + /* Cache value for this query */ + if (last_query_id != query_id) + { + last_query_id= query_id; + store_now_in_TIME(thd, <ime); + } *res= ltime; return 0; } @@ -1741,9 +1751,8 @@ bool Item_func_now::get_date(MYSQL_TIME *res, Converts current time in my_time_t to MYSQL_TIME represenatation for local time zone. Defines time zone (local) used for whole SYSDATE function. */ -void Item_func_sysdate_local::store_now_in_TIME(MYSQL_TIME *now_time) +void Item_func_sysdate_local::store_now_in_TIME(THD *thd, MYSQL_TIME *now_time) { - THD *thd= current_thd; my_hrtime_t now= my_hrtime(); thd->variables.time_zone->gmt_sec_to_TIME(now_time, hrtime_to_my_time(now)); set_sec_part(hrtime_sec_part(now), now_time, this); @@ -1754,7 +1763,7 @@ void Item_func_sysdate_local::store_now_in_TIME(MYSQL_TIME *now_time) bool Item_func_sysdate_local::get_date(MYSQL_TIME *res, ulonglong fuzzy_date __attribute__((unused))) { - store_now_in_TIME(res); + store_now_in_TIME(current_thd, res); return 0; } |