SILENT KILLERPanel

Current Path: > > > usr > include > mysql > server > private


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: ///usr/include/mysql/server/private

NameTypeSizeLast ModifiedActions
atomic Directory - -
aligned.h File 1136 bytes May 28 2025 17:32:51.
aria_backup.h File 1547 bytes May 28 2025 17:32:51.
assume_aligned.h File 2350 bytes May 28 2025 17:32:51.
authors.h File 10141 bytes May 28 2025 17:32:51.
backup.h File 1703 bytes May 28 2025 17:32:51.
bounded_queue.h File 6093 bytes May 28 2025 17:32:51.
client_settings.h File 1935 bytes May 28 2025 17:32:51.
compat56.h File 2280 bytes May 28 2025 17:32:51.
config.h File 14574 bytes May 28 2025 17:32:51.
contributors.h File 4878 bytes May 28 2025 17:32:51.
create_options.h File 4524 bytes May 28 2025 17:32:51.
create_tmp_table.h File 2808 bytes May 28 2025 17:32:51.
cset_narrowing.h File 3968 bytes May 28 2025 17:32:51.
custom_conf.h File 1082 bytes May 28 2025 17:32:51.
datadict.h File 1700 bytes May 28 2025 17:32:51.
ddl_log.h File 12685 bytes May 28 2025 17:32:51.
debug.h File 1234 bytes May 28 2025 17:32:51.
debug_sync.h File 2046 bytes May 28 2025 17:32:51.
derived_handler.h File 2379 bytes May 28 2025 17:32:51.
derror.h File 980 bytes May 28 2025 17:32:51.
des_key_file.h File 1236 bytes May 28 2025 17:32:51.
discover.h File 1570 bytes May 28 2025 17:32:51.
dur_prop.h File 1082 bytes May 28 2025 17:32:51.
embedded_priv.h File 1733 bytes May 28 2025 17:32:51.
event_data_objects.h File 4187 bytes May 28 2025 17:32:51.
event_db_repository.h File 3648 bytes May 28 2025 17:32:51.
event_parse_data.h File 2899 bytes May 28 2025 17:32:51.
event_queue.h File 3438 bytes May 28 2025 17:32:51.
event_scheduler.h File 3290 bytes May 28 2025 17:32:51.
events.h File 4704 bytes May 28 2025 17:32:51.
field.h File 220415 bytes May 28 2025 17:32:51.
field_comp.h File 1174 bytes May 28 2025 17:32:51.
filesort.h File 7283 bytes May 28 2025 17:32:51.
filesort_utils.h File 8195 bytes May 28 2025 17:32:51.
ft_global.h File 3113 bytes May 28 2025 17:32:51.
gcalc_slicescan.h File 17272 bytes May 28 2025 17:32:51.
gcalc_tools.h File 11900 bytes May 28 2025 17:32:51.
grant.h File 2758 bytes May 28 2025 17:32:51.
group_by_handler.h File 3534 bytes May 28 2025 17:32:51.
gstream.h File 2437 bytes May 28 2025 17:32:51.
ha_handler_stats.h File 2335 bytes May 28 2025 17:32:51.
ha_partition.h File 64413 bytes May 28 2025 17:32:51.
ha_sequence.h File 6245 bytes May 28 2025 17:32:51.
handle_connections_win.h File 884 bytes May 28 2025 17:32:51.
handler.h File 201171 bytes May 28 2025 17:32:51.
hash.h File 4449 bytes May 28 2025 17:32:51.
hash_filo.h File 5688 bytes May 28 2025 17:32:51.
heap.h File 9480 bytes May 28 2025 17:32:51.
hostname.h File 5419 bytes May 28 2025 17:32:51.
ilist.h File 7048 bytes May 28 2025 17:32:51.
init.h File 852 bytes May 28 2025 17:32:51.
innodb_priv.h File 1319 bytes May 28 2025 17:32:51.
item.h File 279188 bytes May 28 2025 17:32:51.
item_cmpfunc.h File 135027 bytes May 28 2025 17:32:51.
item_create.h File 11501 bytes May 28 2025 17:32:51.
item_func.h File 136655 bytes May 28 2025 17:32:51.
item_geofunc.h File 38904 bytes May 28 2025 17:32:51.
item_jsonfunc.h File 22516 bytes May 28 2025 17:32:51.
item_row.h File 5221 bytes May 28 2025 17:32:51.
item_strfunc.h File 72241 bytes May 28 2025 17:32:51.
item_subselect.h File 59153 bytes May 28 2025 17:32:51.
item_sum.h File 72287 bytes May 28 2025 17:32:51.
item_timefunc.h File 64615 bytes May 28 2025 17:32:51.
item_vers.h File 4334 bytes May 28 2025 17:32:51.
item_windowfunc.h File 34315 bytes May 28 2025 17:32:51.
item_xmlfunc.h File 4607 bytes May 28 2025 17:32:51.
json_table.h File 9506 bytes May 28 2025 17:32:51.
key.h File 2132 bytes May 28 2025 17:32:51.
keycaches.h File 1995 bytes May 28 2025 17:32:51.
lex.h File 29827 bytes May 28 2025 17:32:51.
lex_string.h File 4068 bytes May 28 2025 17:32:51.
lex_symbol.h File 1323 bytes May 28 2025 17:32:51.
lf.h File 6462 bytes May 28 2025 17:32:51.
lock.h File 2203 bytes May 28 2025 17:32:51.
log.h File 46083 bytes May 28 2025 17:32:51.
log_event.h File 186410 bytes May 28 2025 17:32:51.
log_event_data_type.h File 1890 bytes May 28 2025 17:32:51.
log_event_old.h File 19830 bytes May 28 2025 17:32:51.
log_slow.h File 2442 bytes May 28 2025 17:32:51.
maria.h File 5872 bytes May 28 2025 17:32:51.
mariadb.h File 1277 bytes May 28 2025 17:32:51.
mdl.h File 38468 bytes May 28 2025 17:32:51.
mem_root_array.h File 7106 bytes May 28 2025 17:32:51.
message.h File 1195 bytes May 28 2025 17:32:51.
multi_range_read.h File 23179 bytes May 28 2025 17:32:51.
my_alarm.h File 2429 bytes May 28 2025 17:32:51.
my_apc.h File 4747 bytes May 28 2025 17:32:51.
my_atomic.h File 7281 bytes May 28 2025 17:32:51.
my_atomic_wrapper.h File 3051 bytes May 28 2025 17:32:51.
my_base.h File 27210 bytes May 28 2025 17:32:51.
my_bit.h File 6196 bytes May 28 2025 17:32:51.
my_bitmap.h File 5882 bytes May 28 2025 17:32:51.
my_check_opt.h File 2618 bytes May 28 2025 17:32:51.
my_compare.h File 11194 bytes May 28 2025 17:32:51.
my_counter.h File 1721 bytes May 28 2025 17:32:51.
my_cpu.h File 4855 bytes May 28 2025 17:32:51.
my_crypt.h File 904 bytes May 28 2025 17:32:51.
my_decimal.h File 14489 bytes May 28 2025 17:32:51.
my_default.h File 1880 bytes May 28 2025 17:32:51.
my_handler_errors.h File 4882 bytes May 28 2025 17:32:51.
my_json_writer.h File 18382 bytes May 28 2025 17:32:51.
my_libwrap.h File 1183 bytes May 28 2025 17:32:51.
my_md5.h File 1486 bytes May 28 2025 17:32:51.
my_minidump.h File 848 bytes May 28 2025 17:32:51.
my_nosys.h File 1438 bytes May 28 2025 17:32:51.
my_rdtsc.h File 8425 bytes May 28 2025 17:32:51.
my_rnd.h File 1064 bytes May 28 2025 17:32:51.
my_service_manager.h File 2050 bytes May 28 2025 17:32:51.
my_stack_alloc.h File 6493 bytes May 28 2025 17:32:51.
my_stacktrace.h File 3215 bytes May 28 2025 17:32:51.
my_time.h File 10466 bytes May 28 2025 17:32:51.
my_tree.h File 3991 bytes May 28 2025 17:32:51.
my_uctype.h File 69528 bytes May 28 2025 17:32:51.
my_user.h File 1126 bytes May 28 2025 17:32:51.
myisam.h File 17506 bytes May 28 2025 17:32:51.
myisamchk.h File 4716 bytes May 28 2025 17:32:51.
myisammrg.h File 4897 bytes May 28 2025 17:32:51.
myisampack.h File 14929 bytes May 28 2025 17:32:51.
mysqld.h File 40502 bytes May 28 2025 17:32:51.
mysqld_default_groups.h File 204 bytes May 28 2025 17:32:51.
mysqld_suffix.h File 1201 bytes May 28 2025 17:32:51.
mysys_err.h File 3022 bytes May 28 2025 17:32:51.
opt_range.h File 59591 bytes May 28 2025 17:32:51.
opt_subselect.h File 14551 bytes May 28 2025 17:32:51.
opt_trace.h File 8494 bytes May 28 2025 17:32:51.
opt_trace_context.h File 3291 bytes May 28 2025 17:32:51.
parse_file.h File 4387 bytes May 28 2025 17:32:51.
partition_element.h File 5209 bytes May 28 2025 17:32:51.
partition_info.h File 19300 bytes May 28 2025 17:32:51.
password.h File 1170 bytes May 28 2025 17:32:51.
pfs_file_provider.h File 3153 bytes May 28 2025 17:32:51.
pfs_idle_provider.h File 1385 bytes May 28 2025 17:32:51.
pfs_memory_provider.h File 1626 bytes May 28 2025 17:32:51.
pfs_metadata_provider.h File 1898 bytes May 28 2025 17:32:51.
pfs_socket_provider.h File 2258 bytes May 28 2025 17:32:51.
pfs_stage_provider.h File 1556 bytes May 28 2025 17:32:51.
pfs_statement_provider.h File 4347 bytes May 28 2025 17:32:51.
pfs_table_provider.h File 2625 bytes May 28 2025 17:32:51.
pfs_thread_provider.h File 5560 bytes May 28 2025 17:32:51.
pfs_transaction_provider.h File 2846 bytes May 28 2025 17:32:51.
privilege.h File 28642 bytes May 28 2025 17:32:51.
probes_mysql.h File 973 bytes May 28 2025 17:32:51.
probes_mysql_dtrace.h File 33005 bytes May 28 2025 17:32:51.
probes_mysql_nodtrace.h File 5005 bytes May 28 2025 17:32:51.
procedure.h File 6784 bytes May 28 2025 17:32:51.
protocol.h File 12490 bytes May 28 2025 17:32:51.
proxy_protocol.h File 548 bytes May 28 2025 17:32:51.
queues.h File 3477 bytes May 28 2025 17:32:51.
records.h File 3147 bytes May 28 2025 17:32:51.
repl_failsafe.h File 1585 bytes May 28 2025 17:32:51.
replication.h File 16106 bytes May 28 2025 17:32:51.
rijndael.h File 1711 bytes May 28 2025 17:32:51.
rowid_filter.h File 15477 bytes May 28 2025 17:32:51.
rpl_constants.h File 3357 bytes May 28 2025 17:32:51.
rpl_filter.h File 4535 bytes May 28 2025 17:32:51.
rpl_gtid.h File 13683 bytes May 28 2025 17:32:51.
rpl_injector.h File 9621 bytes May 28 2025 17:32:51.
rpl_mi.h File 14991 bytes May 28 2025 17:32:51.
rpl_parallel.h File 17461 bytes May 28 2025 17:32:51.
rpl_record.h File 1585 bytes May 28 2025 17:32:51.
rpl_record_old.h File 1407 bytes May 28 2025 17:32:51.
rpl_reporting.h File 3713 bytes May 28 2025 17:32:51.
rpl_rli.h File 32746 bytes May 28 2025 17:32:51.
rpl_tblmap.h File 3177 bytes May 28 2025 17:32:51.
rpl_utility.h File 9630 bytes May 28 2025 17:32:51.
scheduler.h File 3199 bytes May 28 2025 17:32:51.
scope.h File 4393 bytes May 28 2025 17:32:51.
select_handler.h File 2228 bytes May 28 2025 17:32:51.
semisync.h File 2287 bytes May 28 2025 17:32:51.
semisync_master.h File 25562 bytes May 28 2025 17:32:51.
semisync_master_ack_receiver.h File 8709 bytes May 28 2025 17:32:51.
semisync_slave.h File 3733 bytes May 28 2025 17:32:51.
service_versions.h File 2049 bytes May 28 2025 17:32:51.
session_tracker.h File 14275 bytes May 28 2025 17:32:51.
set_var.h File 16551 bytes May 28 2025 17:32:51.
slave.h File 12275 bytes May 28 2025 17:32:51.
socketpair.h File 842 bytes May 28 2025 17:32:51.
source_revision.h File 67 bytes May 28 2025 17:32:51.
sp.h File 22588 bytes May 28 2025 17:32:51.
sp_cache.h File 2045 bytes May 28 2025 17:32:51.
sp_head.h File 64509 bytes May 28 2025 17:32:51.
sp_pcontext.h File 24897 bytes May 28 2025 17:32:51.
sp_rcontext.h File 14334 bytes May 28 2025 17:32:51.
span.h File 3931 bytes May 28 2025 17:32:51.
spatial.h File 22305 bytes May 28 2025 17:32:51.
sql_acl.h File 14132 bytes May 28 2025 17:32:51.
sql_admin.h File 2915 bytes May 28 2025 17:32:51.
sql_alloc.h File 1732 bytes May 28 2025 17:32:51.
sql_alter.h File 15277 bytes May 28 2025 17:32:51.
sql_analyse.h File 11125 bytes May 28 2025 17:32:51.
sql_analyze_stmt.h File 12681 bytes May 28 2025 17:32:51.
sql_array.h File 6875 bytes May 28 2025 17:32:51.
sql_audit.h File 13943 bytes May 28 2025 17:32:51.
sql_base.h File 25880 bytes May 28 2025 17:32:51.
sql_basic_types.h File 9528 bytes May 28 2025 17:32:51.
sql_binlog.h File 895 bytes May 28 2025 17:32:51.
sql_bitmap.h File 7845 bytes May 28 2025 17:32:51.
sql_bootstrap.h File 1812 bytes May 28 2025 17:32:51.
sql_cache.h File 21676 bytes May 28 2025 17:32:51.
sql_callback.h File 1542 bytes May 28 2025 17:32:51.
sql_class.h File 267375 bytes May 28 2025 17:32:51.
sql_cmd.h File 9421 bytes May 28 2025 17:32:51.
sql_connect.h File 4087 bytes May 28 2025 17:32:51.
sql_const.h File 11228 bytes May 28 2025 17:32:51.
sql_crypt.h File 1437 bytes May 28 2025 17:32:51.
sql_cte.h File 16533 bytes May 28 2025 17:32:51.
sql_cursor.h File 2316 bytes May 28 2025 17:32:51.
sql_db.h File 2440 bytes May 28 2025 17:32:51.
sql_debug.h File 5646 bytes May 28 2025 17:32:51.
sql_delete.h File 1343 bytes May 28 2025 17:32:51.
sql_derived.h File 1289 bytes May 28 2025 17:32:51.
sql_digest.h File 3819 bytes May 28 2025 17:32:51.
sql_digest_stream.h File 1567 bytes May 28 2025 17:32:51.
sql_do.h File 954 bytes May 28 2025 17:32:51.
sql_error.h File 39588 bytes May 28 2025 17:32:51.
sql_explain.h File 29020 bytes May 28 2025 17:32:51.
sql_expression_cache.h File 4359 bytes May 28 2025 17:32:51.
sql_get_diagnostics.h File 7867 bytes May 28 2025 17:32:51.
sql_handler.h File 2910 bytes May 28 2025 17:32:51.
sql_help.h File 995 bytes May 28 2025 17:32:51.
sql_hset.h File 3401 bytes May 28 2025 17:32:51.
sql_i_s.h File 8232 bytes May 28 2025 17:32:51.
sql_insert.h File 2651 bytes May 28 2025 17:32:51.
sql_join_cache.h File 48669 bytes May 28 2025 17:32:51.
sql_lex.h File 172548 bytes May 28 2025 17:32:51.
sql_lifo_buffer.h File 9676 bytes May 28 2025 17:32:51.
sql_limit.h File 3187 bytes May 28 2025 17:32:51.
sql_list.h File 22458 bytes May 28 2025 17:32:51.
sql_load.h File 1276 bytes May 28 2025 17:32:51.
sql_locale.h File 2701 bytes May 28 2025 17:32:51.
sql_manager.h File 960 bytes May 28 2025 17:32:51.
sql_mode.h File 6735 bytes May 28 2025 17:32:51.
sql_parse.h File 8636 bytes May 28 2025 17:32:51.
sql_partition.h File 12072 bytes May 28 2025 17:32:51.
sql_partition_admin.h File 5940 bytes May 28 2025 17:32:51.
sql_plist.h File 7732 bytes May 28 2025 17:32:51.
sql_plugin.h File 7549 bytes May 28 2025 17:32:51.
sql_plugin_compat.h File 2237 bytes May 28 2025 17:32:51.
sql_prepare.h File 11409 bytes May 28 2025 17:32:51.
sql_priv.h File 18593 bytes May 28 2025 17:32:51.
sql_profile.h File 7816 bytes May 28 2025 17:32:51.
sql_reload.h File 1036 bytes May 28 2025 17:32:51.
sql_rename.h File 982 bytes May 28 2025 17:32:51.
sql_repl.h File 3045 bytes May 28 2025 17:32:51.
sql_schema.h File 3303 bytes May 28 2025 17:32:51.
sql_select.h File 88898 bytes May 28 2025 17:32:51.
sql_sequence.h File 5180 bytes May 28 2025 17:32:51.
sql_servers.h File 1777 bytes May 28 2025 17:32:51.
sql_show.h File 9616 bytes May 28 2025 17:32:51.
sql_signal.h File 3362 bytes May 28 2025 17:32:51.
sql_sort.h File 21967 bytes May 28 2025 17:32:51.
sql_statistics.h File 12454 bytes May 28 2025 17:32:51.
sql_string.h File 39773 bytes May 28 2025 17:32:51.
sql_table.h File 9612 bytes May 28 2025 17:32:51.
sql_tablespace.h File 956 bytes May 28 2025 17:32:51.
sql_test.h File 1589 bytes May 28 2025 17:32:51.
sql_time.h File 8374 bytes May 28 2025 17:32:51.
sql_trigger.h File 12332 bytes May 28 2025 17:32:51.
sql_truncate.h File 2079 bytes May 28 2025 17:32:51.
sql_tvc.h File 2418 bytes May 28 2025 17:32:51.
sql_type.h File 295437 bytes May 28 2025 17:32:51.
sql_type_fixedbin.h File 64320 bytes May 28 2025 17:32:51.
sql_type_fixedbin_storage.h File 5467 bytes May 28 2025 17:32:51.
sql_type_geom.h File 19086 bytes May 28 2025 17:32:51.
sql_type_int.h File 10001 bytes May 28 2025 17:32:51.
sql_type_json.h File 6155 bytes May 28 2025 17:32:51.
sql_type_real.h File 1257 bytes May 28 2025 17:32:51.
sql_type_string.h File 1629 bytes May 28 2025 17:32:51.
sql_udf.h File 4850 bytes May 28 2025 17:32:51.
sql_union.h File 1064 bytes May 28 2025 17:32:51.
sql_update.h File 1923 bytes May 28 2025 17:32:51.
sql_view.h File 2470 bytes May 28 2025 17:32:51.
sql_window.h File 6814 bytes May 28 2025 17:32:51.
ssl_compat.h File 3147 bytes May 28 2025 17:32:51.
strfunc.h File 2275 bytes May 28 2025 17:32:51.
structs.h File 26379 bytes May 28 2025 17:32:51.
sys_vars_shared.h File 2729 bytes May 28 2025 17:32:51.
t_ctype.h File 5639 bytes May 28 2025 17:32:51.
table.h File 115741 bytes May 28 2025 17:32:51.
table_cache.h File 4232 bytes May 28 2025 17:32:51.
thr_alarm.h File 2932 bytes May 28 2025 17:32:51.
thr_lock.h File 7350 bytes May 28 2025 17:32:51.
thr_malloc.h File 1202 bytes May 28 2025 17:32:51.
thr_timer.h File 1563 bytes May 28 2025 17:32:51.
thread_cache.h File 5905 bytes May 28 2025 17:32:51.
threadpool.h File 4810 bytes May 28 2025 17:32:51.
threadpool_generic.h File 3969 bytes May 28 2025 17:32:51.
threadpool_winsockets.h File 2290 bytes May 28 2025 17:32:51.
transaction.h File 1466 bytes May 28 2025 17:32:51.
tzfile.h File 5014 bytes May 28 2025 17:32:51.
tztime.h File 3397 bytes May 28 2025 17:32:51.
uniques.h File 4217 bytes May 28 2025 17:32:51.
unireg.h File 7716 bytes May 28 2025 17:32:51.
vers_string.h File 2534 bytes May 28 2025 17:32:51.
violite.h File 10086 bytes May 28 2025 17:32:51.
waiting_threads.h File 4532 bytes May 28 2025 17:32:51.
welcome_copyright_notice.h File 1218 bytes May 28 2025 17:32:51.
win_tzname_data.h File 6506 bytes May 28 2025 17:32:51.
winservice.h File 1194 bytes May 28 2025 17:32:51.
wqueue.h File 1565 bytes May 28 2025 17:32:51.
wsrep.h File 3308 bytes May 28 2025 17:32:51.
wsrep_applier.h File 2703 bytes May 28 2025 17:32:51.
wsrep_binlog.h File 3441 bytes May 28 2025 17:32:51.
wsrep_client_service.h File 2560 bytes May 28 2025 17:32:51.
wsrep_client_state.h File 1566 bytes May 28 2025 17:32:51.
wsrep_condition_variable.h File 1484 bytes May 28 2025 17:32:51.
wsrep_high_priority_service.h File 4912 bytes May 28 2025 17:32:51.
wsrep_mutex.h File 1216 bytes May 28 2025 17:32:51.
wsrep_mysqld.h File 21138 bytes May 28 2025 17:32:51.
wsrep_mysqld_c.h File 1227 bytes May 28 2025 17:32:51.
wsrep_on.h File 1718 bytes May 28 2025 17:32:51.
wsrep_priv.h File 1634 bytes May 28 2025 17:32:51.
wsrep_schema.h File 4943 bytes May 28 2025 17:32:51.
wsrep_server_service.h File 3631 bytes May 28 2025 17:32:51.
wsrep_server_state.h File 2285 bytes May 28 2025 17:32:51.
wsrep_sst.h File 3951 bytes May 28 2025 17:32:51.
wsrep_storage_service.h File 1809 bytes May 28 2025 17:32:51.
wsrep_thd.h File 11160 bytes May 28 2025 17:32:51.
wsrep_trans_observer.h File 18119 bytes May 28 2025 17:32:51.
wsrep_types.h File 997 bytes May 28 2025 17:32:51.
wsrep_utils.h File 9290 bytes May 28 2025 17:32:51.
wsrep_var.h File 4607 bytes May 28 2025 17:32:51.
wsrep_xid.h File 1549 bytes May 28 2025 17:32:51.
xa.h File 1845 bytes May 28 2025 17:32:51.

Reading File: ///usr/include/mysql/server/private/item_timefunc.h

#ifndef ITEM_TIMEFUNC_INCLUDED
#define ITEM_TIMEFUNC_INCLUDED
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
   Copyright (c) 2009-2011, Monty Program Ab

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1335  USA */


/* Function items used by mysql */

#ifdef USE_PRAGMA_INTERFACE
#pragma interface			/* gcc class implementation */
#endif

class MY_LOCALE;


bool get_interval_value(THD *thd, Item *args,
                        interval_type int_type, INTERVAL *interval);


class Item_long_func_date_field: public Item_long_ge0_func
{
  bool check_arguments() const override
  { return args[0]->check_type_can_return_date(func_name_cstring()); }
public:
  Item_long_func_date_field(THD *thd, Item *a)
   :Item_long_ge0_func(thd, a) { }
};


class Item_long_func_time_field: public Item_long_ge0_func
{
  bool check_arguments() const override
  { return args[0]->check_type_can_return_time(func_name_cstring()); }
public:
  Item_long_func_time_field(THD *thd, Item *a)
   :Item_long_ge0_func(thd, a) { }
};


class Item_func_period_add :public Item_long_func
{
  bool check_arguments() const override
  { return check_argument_types_can_return_int(0, 2); }
public:
  Item_func_period_add(THD *thd, Item *a, Item *b): Item_long_func(thd, a, b) {}
  longlong val_int() override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("period_add") };
    return name;
  }
  bool fix_length_and_dec() override
  {
    max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
    return FALSE;
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_period_add>(thd, this); }
};


class Item_func_period_diff :public Item_long_func
{
  bool check_arguments() const override
  { return check_argument_types_can_return_int(0, 2); }
public:
  Item_func_period_diff(THD *thd, Item *a, Item *b): Item_long_func(thd, a, b) {}
  longlong val_int() override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("period_diff") };
    return name;
  }
  bool fix_length_and_dec() override
  {
    decimals=0;
    max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
    return FALSE;
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_period_diff>(thd, this); }
};


class Item_func_to_days :public Item_long_func_date_field
{
public:
  Item_func_to_days(THD *thd, Item *a): Item_long_func_date_field(thd, a) {}
  longlong val_int() override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("to_days") };
    return name;
  }
  bool fix_length_and_dec() override
  {
    decimals=0; 
    max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
    set_maybe_null();
    return FALSE;
  }
  enum_monotonicity_info get_monotonicity_info() const override;
  longlong val_int_endpoint(bool left_endp, bool *incl_endp) override;
  bool check_partition_func_processor(void *int_arg) override {return FALSE;}
  bool check_vcol_func_processor(void *arg) override { return FALSE;}
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_date_args();
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_to_days>(thd, this); }
};


class Item_func_to_seconds :public Item_longlong_func
{
  bool check_arguments() const override
  { return check_argument_types_can_return_date(0, arg_count); }
public:
  Item_func_to_seconds(THD *thd, Item *a): Item_longlong_func(thd, a) {}
  longlong val_int() override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("to_seconds") };
    return name;
  }
  bool fix_length_and_dec() override
  {
    decimals=0; 
    fix_char_length(12);
    set_maybe_null();
    return FALSE;
  }
  enum_monotonicity_info get_monotonicity_info() const override;
  longlong val_int_endpoint(bool left_endp, bool *incl_endp) override;
  bool check_partition_func_processor(void *bool_arg) override { return FALSE;}

  /* Only meaningful with date part and optional time part */
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_date_args();
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_to_seconds>(thd, this); }
};


class Item_func_dayofmonth :public Item_long_func_date_field
{
public:
  Item_func_dayofmonth(THD *thd, Item *a): Item_long_func_date_field(thd, a) {}
  longlong val_int() override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("dayofmonth") };
    return name;
  }
  bool fix_length_and_dec() override
  {
    decimals=0; 
    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
    set_maybe_null();
    return FALSE;
  }
  bool check_partition_func_processor(void *int_arg) override {return FALSE;}
  bool check_vcol_func_processor(void *arg) override { return FALSE;}
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_date_args();
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_dayofmonth>(thd, this); }
};


class Item_func_month :public Item_long_ge0_func
{
public:
  Item_func_month(THD *thd, Item *a): Item_long_ge0_func(thd, a)
  { }
  longlong val_int() override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("month") };
    return name;
  }
  bool fix_length_and_dec() override
  {
    decimals= 0;
    fix_char_length(2);
    set_maybe_null();
    return FALSE;
  }
  bool check_partition_func_processor(void *int_arg) override {return FALSE;}
  bool check_vcol_func_processor(void *arg) override { return FALSE;}
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_date_args();
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_month>(thd, this); }
};


class Item_func_monthname :public Item_str_func
{
  MY_LOCALE *locale;
public:
  Item_func_monthname(THD *thd, Item *a): Item_str_func(thd, a) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("monthname") };
    return name;
  }
  String *val_str(String *str) override;
  bool fix_length_and_dec() override;
  bool check_partition_func_processor(void *int_arg) override {return TRUE;}
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_date_args();
  }
  bool check_vcol_func_processor(void *arg) override
  {
    return mark_unsupported_function(func_name(), "()", arg, VCOL_SESSION_FUNC);
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_monthname>(thd, this); }
};


class Item_func_dayofyear :public Item_long_func_date_field
{
public:
  Item_func_dayofyear(THD *thd, Item *a): Item_long_func_date_field(thd, a) {}
  longlong val_int() override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("dayofyear") };
    return name;
  }
  bool fix_length_and_dec() override
  {
    decimals= 0;
    fix_char_length(3);
    set_maybe_null();
    return FALSE;
  }
  bool check_partition_func_processor(void *int_arg) override {return FALSE;}
  bool check_vcol_func_processor(void *arg) override { return FALSE;}
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_date_args();
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_dayofyear>(thd, this); }
};


class Item_func_hour :public Item_long_func_time_field
{
public:
  Item_func_hour(THD *thd, Item *a): Item_long_func_time_field(thd, a) {}
  longlong val_int() override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("hour") };
    return name;
  }
  bool fix_length_and_dec() override
  {
    decimals=0;
    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
    set_maybe_null();
    return FALSE;
  }
  bool check_partition_func_processor(void *int_arg) override {return FALSE;}
  bool check_vcol_func_processor(void *arg) override { return FALSE;}
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_time_args();
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_hour>(thd, this); }
};


class Item_func_minute :public Item_long_func_time_field
{
public:
  Item_func_minute(THD *thd, Item *a): Item_long_func_time_field(thd, a) {}
  longlong val_int() override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("minute") };
    return name;
  }
  bool fix_length_and_dec() override
  {
    decimals=0;
    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
    set_maybe_null();
    return FALSE;
  }
  bool check_partition_func_processor(void *int_arg) override {return FALSE;}
  bool check_vcol_func_processor(void *arg) override { return FALSE;}
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_time_args();
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_minute>(thd, this); }
};


class Item_func_quarter :public Item_long_func_date_field
{
public:
  Item_func_quarter(THD *thd, Item *a): Item_long_func_date_field(thd, a) {}
  longlong val_int() override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("quarter") };
    return name;
  }
  bool fix_length_and_dec() override
  {
     decimals=0;
     max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
     set_maybe_null();
     return FALSE;
  }
  bool check_partition_func_processor(void *int_arg) override {return FALSE;}
  bool check_vcol_func_processor(void *arg) override { return FALSE;}
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_date_args();
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_quarter>(thd, this); }
};


class Item_func_second :public Item_long_func_time_field
{
public:
  Item_func_second(THD *thd, Item *a): Item_long_func_time_field(thd, a) {}
  longlong val_int() override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("second") };
    return name;
  }
  bool fix_length_and_dec() override
  {
    decimals=0;
    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
    set_maybe_null();
    return FALSE;
  }
  bool check_partition_func_processor(void *int_arg) override {return FALSE;}
  bool check_vcol_func_processor(void *arg) override { return FALSE;}
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_time_args();
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_second>(thd, this); }
};


class Item_func_week :public Item_long_ge0_func
{
  bool check_arguments() const override
  {
    return args[0]->check_type_can_return_date(func_name_cstring()) ||
           (arg_count > 1 && args[1]->check_type_can_return_int(func_name_cstring()));
  }
public:
  Item_func_week(THD *thd, Item *a): Item_long_ge0_func(thd, a) {}
  Item_func_week(THD *thd, Item *a, Item *b): Item_long_ge0_func(thd, a, b) {}
  longlong val_int() override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("week") };
    return name;
  }
  bool fix_length_and_dec() override
  {
    decimals=0;
    max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
    set_maybe_null();
    return FALSE;
  }
  bool check_vcol_func_processor(void *arg) override
  {
    if (arg_count == 2)
      return FALSE;
    return mark_unsupported_function(func_name(), "()", arg, VCOL_SESSION_FUNC);
  }
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return arg_count == 2;
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_week>(thd, this); }
};

class Item_func_yearweek :public Item_long_func
{
  bool check_arguments() const override
  {
    return args[0]->check_type_can_return_date(func_name_cstring()) ||
           args[1]->check_type_can_return_int(func_name_cstring());
  }
public:
  Item_func_yearweek(THD *thd, Item *a, Item *b)
   :Item_long_func(thd, a, b) {}
  longlong val_int() override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("yearweek") };
    return name;
  }
  bool fix_length_and_dec() override
  {
    decimals=0;
    max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
    set_maybe_null();
    return FALSE;
  }
  bool check_partition_func_processor(void *int_arg) override {return FALSE;}
  bool check_vcol_func_processor(void *arg) override { return FALSE;}
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_date_args();
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_yearweek>(thd, this); }
};


class Item_func_year :public Item_long_func_date_field
{
public:
  Item_func_year(THD *thd, Item *a): Item_long_func_date_field(thd, a) {}
  longlong val_int() override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("year") };
    return name;
  }
  enum_monotonicity_info get_monotonicity_info() const override;
  longlong val_int_endpoint(bool left_endp, bool *incl_endp) override;
  bool fix_length_and_dec() override
  {
    decimals=0;
    max_length=4*MY_CHARSET_BIN_MB_MAXLEN;
    set_maybe_null();
    return FALSE;
  }
  bool check_partition_func_processor(void *int_arg) override {return FALSE;}
  bool check_vcol_func_processor(void *arg) override { return FALSE;}
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_date_args();
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_year>(thd, this); }
};


class Item_func_weekday :public Item_long_func
{
  bool odbc_type;
public:
  Item_func_weekday(THD *thd, Item *a, bool type_arg):
    Item_long_func(thd, a), odbc_type(type_arg) { }
  longlong val_int() override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING dayofweek= {STRING_WITH_LEN("dayofweek") };
    static LEX_CSTRING weekday= {STRING_WITH_LEN("weekday") };
    return (odbc_type ? dayofweek : weekday);
  }
  bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override
  {
    return type_handler()->Item_get_date_with_warn(thd, this, ltime, fuzzydate);
  }
  bool fix_length_and_dec() override
  {
    decimals= 0;
    fix_char_length(1);
    set_maybe_null();
    return FALSE;
  }
  bool check_partition_func_processor(void *int_arg) override {return FALSE;}
  bool check_vcol_func_processor(void *arg) override { return FALSE;}
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_date_args();
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_weekday>(thd, this); }
};

class Item_func_dayname :public Item_str_func
{
  MY_LOCALE *locale;
 public:
  Item_func_dayname(THD *thd, Item *a): Item_str_func(thd, a) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("dayname") };
    return name;
  }
  String *val_str(String *str) override;
  const Type_handler *type_handler() const override
  { return &type_handler_varchar; }
  bool fix_length_and_dec() override;
  bool check_partition_func_processor(void *int_arg) override {return TRUE;}
  bool check_vcol_func_processor(void *arg) override
  {
    return mark_unsupported_function(func_name(), "()", arg, VCOL_SESSION_FUNC);
  }
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_date_args();
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_dayname>(thd, this); }
};


class Item_func_seconds_hybrid: public Item_func_numhybrid
{
public:
  Item_func_seconds_hybrid(THD *thd): Item_func_numhybrid(thd) {}
  Item_func_seconds_hybrid(THD *thd, Item *a): Item_func_numhybrid(thd, a) {}
  void fix_length_and_dec_generic(uint dec)
  {
    DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS);
    decimals= dec;
    max_length=17 + (decimals ? decimals + 1 : 0);
    set_maybe_null();
    if (decimals)
      set_handler(&type_handler_newdecimal);
    else
      set_handler(type_handler_long_or_longlong());
  }
  double real_op() override { DBUG_ASSERT(0); return 0; }
  String *str_op(String *str) override { DBUG_ASSERT(0); return 0; }
  bool date_op(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override
  {
    DBUG_ASSERT(0);
    return true;
  }
};


class Item_func_unix_timestamp :public Item_func_seconds_hybrid
{
  bool get_timestamp_value(my_time_t *seconds, ulong *second_part);
public:
  Item_func_unix_timestamp(THD *thd): Item_func_seconds_hybrid(thd) {}
  Item_func_unix_timestamp(THD *thd, Item *a):
    Item_func_seconds_hybrid(thd, a) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("unix_timestamp") };
    return name;
  }
  enum_monotonicity_info get_monotonicity_info() const override;
  longlong val_int_endpoint(bool left_endp, bool *incl_endp) override;
  bool check_partition_func_processor(void *int_arg) override {return FALSE;}
  /*
    UNIX_TIMESTAMP() depends on the current timezone
    (and thus may not be used as a partitioning function)
    when its argument is NOT of the TIMESTAMP type.
  */
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_timestamp_args();
  }
  bool check_vcol_func_processor(void *arg) override
  {
    if (arg_count)
      return FALSE;
    return mark_unsupported_function(func_name(), "()", arg, VCOL_TIME_FUNC);
  }
  bool fix_length_and_dec() override
  {
    fix_length_and_dec_generic(arg_count ?
                               args[0]->datetime_precision(current_thd) : 0);
    return FALSE;
  }
  longlong int_op() override;
  my_decimal *decimal_op(my_decimal* buf) override;
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_unix_timestamp>(thd, this); }
};


class Item_func_time_to_sec :public Item_func_seconds_hybrid
{
public:
  Item_func_time_to_sec(THD *thd, Item *item):
    Item_func_seconds_hybrid(thd, item) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("time_to_sec") };
    return name;
  }
  bool check_partition_func_processor(void *int_arg) override {return FALSE;}
  bool check_vcol_func_processor(void *arg) override { return FALSE;}
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_time_args();
  }
  bool fix_length_and_dec() override
  {
    fix_length_and_dec_generic(args[0]->time_precision(current_thd));
    return FALSE;
  }
  longlong int_op() override;
  my_decimal *decimal_op(my_decimal* buf) override;
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_time_to_sec>(thd, this); }
};


class Item_datefunc :public Item_func
{
public:
  Item_datefunc(THD *thd): Item_func(thd) { }
  Item_datefunc(THD *thd, Item *a): Item_func(thd, a) { }
  Item_datefunc(THD *thd, Item *a, Item *b): Item_func(thd, a, b) { }
  const Type_handler *type_handler() const override
  { return &type_handler_newdate; }
  longlong val_int() override
  {
    DBUG_ASSERT(!is_cond());
    return Date(this).to_longlong();
  }
  double val_real() override
  { return Date(this).to_double(); }
  String *val_str(String *to) override
  { return Date(this).to_string(to); }
  my_decimal *val_decimal(my_decimal *to) override
  { return Date(this).to_decimal(to); }
  bool fix_length_and_dec() override
  {
    fix_attributes_date();
    set_maybe_null(arg_count > 0);
    return FALSE;
  }
};


class Item_timefunc :public Item_func
{
public:
  Item_timefunc(THD *thd): Item_func(thd) {}
  Item_timefunc(THD *thd, Item *a): Item_func(thd, a) {}
  Item_timefunc(THD *thd, Item *a, Item *b): Item_func(thd, a, b) {}
  Item_timefunc(THD *thd, Item *a, Item *b, Item *c): Item_func(thd, a, b ,c) {}
  const Type_handler *type_handler() const override
  { return &type_handler_time2; }
  longlong val_int() override
  {
    DBUG_ASSERT(!is_cond());
    return Time(this).to_longlong();
  }
  double val_real() override
  { return Time(this).to_double(); }
  String *val_str(String *to) override
  { return Time(this).to_string(to, decimals); }
  my_decimal *val_decimal(my_decimal *to) override
  { return Time(this).to_decimal(to); }
  bool val_native(THD *thd, Native *to) override
  { return Time(thd, this).to_native(to, decimals); }
};


class Item_datetimefunc :public Item_func
{
public:
  Item_datetimefunc(THD *thd): Item_func(thd) {}
  Item_datetimefunc(THD *thd, Item *a): Item_func(thd, a) {}
  Item_datetimefunc(THD *thd, Item *a, Item *b): Item_func(thd, a, b) {}
  Item_datetimefunc(THD *thd, Item *a, Item *b, Item *c):
    Item_func(thd, a, b ,c) {}
  const Type_handler *type_handler() const override
  { return &type_handler_datetime2; }
  longlong val_int() override
  {
    DBUG_ASSERT(!is_cond());
    return Datetime(this).to_longlong();
  }
  double val_real() override { return Datetime(this).to_double(); }
  String *val_str(String *to) override
  { return Datetime(this).to_string(to, decimals); }
  my_decimal *val_decimal(my_decimal *to) override
  { return Datetime(this).to_decimal(to); }
};


/* Abstract CURTIME function. Children should define what time zone is used */

class Item_func_curtime :public Item_timefunc
{
  MYSQL_TIME ltime;
  query_id_t last_query_id;
public:
  Item_func_curtime(THD *thd, uint dec): Item_timefunc(thd), last_query_id(0)
  { decimals= dec; }
  bool fix_fields(THD *, Item **) override;
  bool fix_length_and_dec() override
  { fix_attributes_time(decimals); return FALSE; }
  bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate) override;
  /* 
    Abstract method that defines which time zone is used for conversion.
    Converts time current time in my_time_t representation to broken-down
    MYSQL_TIME representation using UTC-SYSTEM or per-thread time zone.
  */
  virtual void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time)=0;
  bool check_vcol_func_processor(void *arg) override
  {
    return mark_unsupported_function(func_name(), "()", arg, VCOL_TIME_FUNC);
  }
  void print(String *str, enum_query_type query_type) override;
};


class Item_func_curtime_local :public Item_func_curtime
{
public:
  Item_func_curtime_local(THD *thd, uint dec): Item_func_curtime(thd, dec) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("curtime") };
    return name;
  }
  void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time) override;
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_curtime_local>(thd, this); }
};


class Item_func_curtime_utc :public Item_func_curtime
{
public:
  Item_func_curtime_utc(THD *thd, uint dec): Item_func_curtime(thd, dec) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("utc_time") };
    return name;
  }
  void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time) override;
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_curtime_utc>(thd, this); }
};


/* Abstract CURDATE function. See also Item_func_curtime. */

class Item_func_curdate :public Item_datefunc
{
  query_id_t last_query_id;
  MYSQL_TIME ltime;
public:
  Item_func_curdate(THD *thd): Item_datefunc(thd), last_query_id(0) {}
  bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate) override;
  virtual void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time)=0;
  bool check_vcol_func_processor(void *arg) override
  {
    return mark_unsupported_function(func_name(), "()", arg, VCOL_TIME_FUNC);
  }
};


class Item_func_curdate_local :public Item_func_curdate
{
public:
  Item_func_curdate_local(THD *thd): Item_func_curdate(thd) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("curdate") };
    return name;
  }
  void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time) override;
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_curdate_local>(thd, this); }
};


class Item_func_curdate_utc :public Item_func_curdate
{
public:
  Item_func_curdate_utc(THD *thd): Item_func_curdate(thd) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("utc_date") };
    return name;
  }
  void store_now_in_TIME(THD* thd, MYSQL_TIME *now_time) override;
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_curdate_utc>(thd, this); }
};


/* Abstract CURRENT_TIMESTAMP function. See also Item_func_curtime */

class Item_func_now :public Item_datetimefunc
{
  MYSQL_TIME ltime;
  query_id_t last_query_id;
public:
  Item_func_now(THD *thd, uint dec): Item_datetimefunc(thd), last_query_id(0)
  { decimals= dec; }
  bool fix_fields(THD *, Item **) override;
  bool fix_length_and_dec() override
  { fix_attributes_datetime(decimals); return FALSE;}
  bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate) override;
  virtual void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time)=0;
  bool check_vcol_func_processor(void *arg) override
  {
    /*
      NOW is safe for replication as slaves will run with same time as
      master
    */
    return mark_unsupported_function(func_name(), "()", arg, VCOL_TIME_FUNC);
  }
  void print(String *str, enum_query_type query_type) override;
};


class Item_func_now_local :public Item_func_now
{
public:
  Item_func_now_local(THD *thd, uint dec): Item_func_now(thd, dec) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("current_timestamp") };
    return name;
  }
  int save_in_field(Field *field, bool no_conversions) override;
  void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time) override;
  enum Functype functype() const override { return NOW_FUNC; }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_now_local>(thd, this); }
};


class Item_func_now_utc :public Item_func_now
{
public:
  Item_func_now_utc(THD *thd, uint dec): Item_func_now(thd, dec) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("utc_timestamp") };
    return name;
  }
  void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time) override;
  enum Functype functype() const override { return NOW_UTC_FUNC; }
  bool check_vcol_func_processor(void *arg) override
  {
    return mark_unsupported_function(func_name(), "()", arg,
                                     VCOL_TIME_FUNC | VCOL_NON_DETERMINISTIC);
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_now_utc>(thd, this); }
};


/*
  This is like NOW(), but always uses the real current time, not the
  query_start(). This matches the Oracle behavior.
*/
class Item_func_sysdate_local :public Item_func_now
{
public:
  Item_func_sysdate_local(THD *thd, uint dec): Item_func_now(thd, dec) {}
  bool const_item() const override { return 0; }
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("sysdate") };
    return name;
  }
  void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time) override;
  bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate) override;
  table_map used_tables() const override { return RAND_TABLE_BIT; }
  bool check_vcol_func_processor(void *arg) override
  {
    return mark_unsupported_function(func_name(), "()", arg,
                                     VCOL_TIME_FUNC | VCOL_NON_DETERMINISTIC);
  }
  enum Functype functype() const override { return SYSDATE_FUNC; }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_sysdate_local>(thd, this); }
};


class Item_func_from_days :public Item_datefunc
{
  bool check_arguments() const override
  { return args[0]->check_type_can_return_int(func_name_cstring()); }
public:
  Item_func_from_days(THD *thd, Item *a): Item_datefunc(thd, a) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("from_days") };
    return name;
  }
  bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate) override;
  bool check_partition_func_processor(void *int_arg) override {return FALSE;}
  bool check_vcol_func_processor(void *arg) override { return FALSE;}
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return has_date_args() || has_time_args();
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_from_days>(thd, this); }
};


class Item_func_date_format :public Item_str_func
{
  bool check_arguments() const override
  {
    return args[0]->check_type_can_return_date(func_name_cstring()) ||
           check_argument_types_can_return_text(1, arg_count);
  }
  const MY_LOCALE *locale;
  int fixed_length;
  String value;
protected:
  bool is_time_format;
public:
  Item_func_date_format(THD *thd, Item *a, Item *b):
    Item_str_func(thd, a, b), locale(0), is_time_format(false) {}
  Item_func_date_format(THD *thd, Item *a, Item *b, Item *c):
    Item_str_func(thd, a, b, c), locale(0), is_time_format(false) {}
  String *val_str(String *str) override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("date_format") };
    return name;
  }
  bool fix_length_and_dec() override;
  uint format_length(const String *format);
  bool eq(const Item *item, bool binary_cmp) const override;
  bool check_vcol_func_processor(void *arg) override
  {
    if (arg_count > 2)
      return false;
    return mark_unsupported_function(func_name(), "()", arg, VCOL_SESSION_FUNC);
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_date_format>(thd, this); }
};

class Item_func_time_format: public Item_func_date_format
{
public:
  Item_func_time_format(THD *thd, Item *a, Item *b):
    Item_func_date_format(thd, a, b) { is_time_format= true; }
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("time_format") };
    return name;
  }
  bool check_vcol_func_processor(void *arg) override { return false; }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_time_format>(thd, this); }
};


/* the max length of datetime format models string in Oracle is 144 */
#define MAX_DATETIME_FORMAT_MODEL_LEN 144

class Item_func_tochar :public Item_str_func
{
  const MY_LOCALE *locale;
  THD *thd;
  String warning_message;
  bool fixed_length;

  /*
    When datetime format models is parsed, use uint16 integers to
    represent the format models and store in fmt_array.
  */
  uint16 fmt_array[MAX_DATETIME_FORMAT_MODEL_LEN+1];

  bool check_arguments() const override
  {
    return
      (args[0]->check_type_can_return_date(func_name_cstring()) &&
       args[0]->check_type_can_return_time(func_name_cstring())) ||
      check_argument_types_can_return_text(1, arg_count);
  }

public:
  Item_func_tochar(THD *thd, Item *a, Item *b):
    Item_str_func(thd, a, b), locale(0)
  {
    /* NOTE: max length of warning message is 64 */
    warning_message.alloc(64);
    warning_message.length(0);
  }
  ~Item_func_tochar() { warning_message.free(); }
  String *val_str(String *str) override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("to_char") };
    return name;
  }
  bool fix_length_and_dec() override;
  bool parse_format_string(const String *format, uint *fmt_len);

  bool check_vcol_func_processor(void *arg) override
  {
    if (arg_count > 2)
      return false;
    return mark_unsupported_function(func_name(), "()", arg, VCOL_SESSION_FUNC);
  }

  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_tochar>(thd, this); }
};


class Item_func_from_unixtime :public Item_datetimefunc
{
  bool check_arguments() const override
  { return args[0]->check_type_can_return_decimal(func_name_cstring()); }
  Time_zone *tz;
 public:
  Item_func_from_unixtime(THD *thd, Item *a): Item_datetimefunc(thd, a) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("from_unixtime") };
    return name;
  }
  bool fix_length_and_dec() override;
  bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate) override;
  bool check_vcol_func_processor(void *arg) override
  {
    return mark_unsupported_function(func_name(), "()", arg, VCOL_SESSION_FUNC);
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_from_unixtime>(thd, this); }
};


/* 
  We need Time_zone class declaration for storing pointers in
  Item_func_convert_tz.
*/
class Time_zone;

/*
  This class represents CONVERT_TZ() function.
  The important fact about this function that it is handled in special way.
  When such function is met in expression time_zone system tables are added
  to global list of tables to open, so later those already opened and locked
  tables can be used during this function calculation for loading time zone
  descriptions.
*/
class Item_func_convert_tz :public Item_datetimefunc
{
  bool check_arguments() const override
  {
    return args[0]->check_type_can_return_date(func_name_cstring()) ||
           check_argument_types_can_return_text(1, arg_count);
  }
  /*
    If time zone parameters are constants we are caching objects that
    represent them (we use separate from_tz_cached/to_tz_cached members
    to indicate this fact, since NULL is legal value for from_tz/to_tz
    members.
  */
  bool from_tz_cached, to_tz_cached;
  Time_zone *from_tz, *to_tz;
 public:
  Item_func_convert_tz(THD *thd, Item *a, Item *b, Item *c):
    Item_datetimefunc(thd, a, b, c), from_tz_cached(0), to_tz_cached(0) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("convert_tz") };
    return name;
  }
  bool fix_length_and_dec() override
  {
    fix_attributes_datetime(args[0]->datetime_precision(current_thd));
    set_maybe_null();
    return FALSE;
  }
  bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate) override;
  void cleanup() override;
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_convert_tz>(thd, this); }
};


class Item_func_sec_to_time :public Item_timefunc
{
  bool check_arguments() const override
  { return args[0]->check_type_can_return_decimal(func_name_cstring()); }
public:
  Item_func_sec_to_time(THD *thd, Item *item): Item_timefunc(thd, item) {}
  bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate) override;
  bool fix_length_and_dec() override
  {
    fix_attributes_time(args[0]->decimals);
    set_maybe_null();
    return FALSE;
  }
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("sec_to_time") };
    return name;
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_sec_to_time>(thd, this); }
};


class Item_date_add_interval :public Item_handled_func
{
public:
  const interval_type int_type; // keep it public
  const bool date_sub_interval; // keep it public
  Item_date_add_interval(THD *thd, Item *a, Item *b, interval_type type_arg,
                         bool neg_arg):
    Item_handled_func(thd, a, b), int_type(type_arg),
    date_sub_interval(neg_arg) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("date_add_interval") };
    return name;
  }
  bool fix_length_and_dec() override;
  bool eq(const Item *item, bool binary_cmp) const override;
  void print(String *str, enum_query_type query_type) override;
  enum precedence precedence() const override { return INTERVAL_PRECEDENCE; }
  bool need_parentheses_in_default() override { return true; }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_date_add_interval>(thd, this); }
};


class Item_extract :public Item_int_func,
                    public Type_handler_hybrid_field_type
{
  date_mode_t m_date_mode;
  const Type_handler_int_result *handler_by_length(uint32 length,
                                                   uint32 threashold)
  {
    if (length >= threashold)
      return &type_handler_slonglong;
    return &type_handler_slong;
  }
  void set_date_length(uint32 length)
  {
    /*
      DATE components (e.g. YEAR, YEAR_MONTH, QUARTER, MONTH, WEEK)
      return non-negative values but historically EXTRACT for date
      components always returned the signed int data type.
      So do equivalent functions YEAR(), QUARTER(), MONTH(), WEEK().
      Let's set the data type to "signed int, but not negative",
      so "this" produces better data types in VARCHAR and DECIMAL context
      by using the fact that all of the max_length characters are spent
      for digits (non of them are spent for the sign).
    */
    set_handler(&type_handler_slong_ge0);
    fix_char_length(length);
    m_date_mode= date_mode_t(0);
  }
  void set_day_length(uint32 length)
  {
    /*
      Units starting with DAY can be negative:
        EXTRACT(DAY FROM '-24:00:00') -> -1
    */
    set_handler(handler_by_length(max_length= length + 1/*sign*/, 11));
    m_date_mode= Temporal::Options(TIME_INTERVAL_DAY, current_thd);
  }
  void set_time_length(uint32 length)
  {
    set_handler(handler_by_length(max_length= length + 1/*sign*/, 11));
    m_date_mode= Temporal::Options(TIME_INTERVAL_hhmmssff, current_thd);
  }
 public:
  const interval_type int_type; // keep it public
  Item_extract(THD *thd, interval_type type_arg, Item *a):
    Item_int_func(thd, a),
    Type_handler_hybrid_field_type(&type_handler_slonglong),
    m_date_mode(date_mode_t(0)),
    int_type(type_arg)
  { }
  const Type_handler *type_handler() const override
  {
    return Type_handler_hybrid_field_type::type_handler();
  }
  longlong val_int() override;
  enum Functype functype() const override { return EXTRACT_FUNC; }
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("extract") };
    return name;
  }
  bool check_arguments() const override;
  bool fix_length_and_dec() override;
  bool eq(const Item *item, bool binary_cmp) const override;
  void print(String *str, enum_query_type query_type) override;
  bool check_partition_func_processor(void *int_arg) override {return FALSE;}
  bool check_vcol_func_processor(void *arg) override
  {
    if (int_type != INTERVAL_WEEK)
      return FALSE;
    return mark_unsupported_function(func_name(), "()", arg, VCOL_SESSION_FUNC);
  }
  bool check_valid_arguments_processor(void *int_arg) override
  {
    switch (int_type) {
    case INTERVAL_YEAR:
    case INTERVAL_YEAR_MONTH:
    case INTERVAL_QUARTER:
    case INTERVAL_MONTH:
    /* case INTERVAL_WEEK: Not allowed as partitioning function, bug#57071 */
    case INTERVAL_DAY:
      return !has_date_args();
    case INTERVAL_DAY_HOUR:
    case INTERVAL_DAY_MINUTE:
    case INTERVAL_DAY_SECOND:
    case INTERVAL_DAY_MICROSECOND:
      return !has_datetime_args();
    case INTERVAL_HOUR:
    case INTERVAL_HOUR_MINUTE:
    case INTERVAL_HOUR_SECOND:
    case INTERVAL_MINUTE:
    case INTERVAL_MINUTE_SECOND:
    case INTERVAL_SECOND:
    case INTERVAL_MICROSECOND:
    case INTERVAL_HOUR_MICROSECOND:
    case INTERVAL_MINUTE_MICROSECOND:
    case INTERVAL_SECOND_MICROSECOND:
      return !has_time_args();
    default:
      /*
        INTERVAL_LAST is only an end marker,
        INTERVAL_WEEK depends on default_week_format which is a session
        variable and cannot be used for partitioning. See bug#57071.
      */
      break;
    }
    return true;
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_extract>(thd, this); }
};


class Item_char_typecast :public Item_handled_func
{
  uint cast_length;
  CHARSET_INFO *cast_cs, *from_cs;
  bool charset_conversion;
  String tmp_value;
  bool m_suppress_warning_to_error_escalation;
public:
  bool has_explicit_length() const { return cast_length != ~0U; }
private:
  String *reuse(String *src, size_t length);
  String *copy(String *src, CHARSET_INFO *cs);
  uint adjusted_length_with_warn(uint length);
  void check_truncation_with_warn(String *src, size_t dstlen);
  void fix_length_and_dec_internal(CHARSET_INFO *fromcs);
public:
  // Methods used by ColumnStore
  uint get_cast_length() const { return cast_length; }
public:
  Item_char_typecast(THD *thd, Item *a, uint length_arg, CHARSET_INFO *cs_arg):
    Item_handled_func(thd, a), cast_length(length_arg), cast_cs(cs_arg),
    m_suppress_warning_to_error_escalation(false) {}
  enum Functype functype() const override { return CHAR_TYPECAST_FUNC; }
  bool eq(const Item *item, bool binary_cmp) const override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("cast_as_char") };
    return name;
  }
  CHARSET_INFO *cast_charset() const { return cast_cs; }
  String *val_str_generic(String *a);
  String *val_str_binary_from_native(String *a);
  void fix_length_and_dec_generic();
  void fix_length_and_dec_numeric();
  void fix_length_and_dec_str();
  void fix_length_and_dec_native_to_binary(uint32 octet_length);
  bool fix_length_and_dec() override
  {
    return args[0]->type_handler()->Item_char_typecast_fix_length_and_dec(this);
  }
  void print(String *str, enum_query_type query_type) override;
  bool need_parentheses_in_default() override { return true; }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_char_typecast>(thd, this); }
};


class Item_interval_DDhhmmssff_typecast :public Item_char_typecast
{
  uint m_fsp;
public:
  Item_interval_DDhhmmssff_typecast(THD *thd, Item *a, uint fsp)
   :Item_char_typecast(thd, a,Interval_DDhhmmssff::max_char_length(fsp),
                       &my_charset_latin1),
    m_fsp(fsp)
  { }
  String *val_str(String *to) override
  {
    Interval_DDhhmmssff it(current_thd, args[0], m_fsp);
    null_value= !it.is_valid_interval_DDhhmmssff();
    return it.to_string(to, m_fsp);
  }
};


class Item_date_typecast :public Item_datefunc
{
public:
  Item_date_typecast(THD *thd, Item *a): Item_datefunc(thd, a) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("cast_as_date") };
    return name;
  }
  void print(String *str, enum_query_type query_type) override
  {
    print_cast_temporal(str, query_type);
  }
  bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override;
  bool fix_length_and_dec() override
  {
    return args[0]->type_handler()->Item_date_typecast_fix_length_and_dec(this);
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_date_typecast>(thd, this); }
};


class Item_time_typecast :public Item_timefunc
{
public:
  Item_time_typecast(THD *thd, Item *a, uint dec_arg):
    Item_timefunc(thd, a) { decimals= dec_arg; }
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("cast_as_time") };
    return name;
  }
  void print(String *str, enum_query_type query_type) override
  {
    print_cast_temporal(str, query_type);
  }
  bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override;
  bool fix_length_and_dec() override
  {
    return args[0]->type_handler()->
           Item_time_typecast_fix_length_and_dec(this);
  }
  Sql_mode_dependency value_depends_on_sql_mode() const override;
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_time_typecast>(thd, this); }
};


class Item_datetime_typecast :public Item_datetimefunc
{
public:
  Item_datetime_typecast(THD *thd, Item *a, uint dec_arg):
    Item_datetimefunc(thd, a) { decimals= dec_arg; }
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("cast_as_datetime") };
    return name;
  }
  void print(String *str, enum_query_type query_type) override
  {
    print_cast_temporal(str, query_type);
  }
  bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override;
  bool fix_length_and_dec() override
  {
    return args[0]->type_handler()->
           Item_datetime_typecast_fix_length_and_dec(this);
  }
  Sql_mode_dependency value_depends_on_sql_mode() const override;
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_datetime_typecast>(thd, this); }
};


class Item_func_makedate :public Item_datefunc
{
  bool check_arguments() const override
  { return check_argument_types_can_return_int(0, arg_count); }
public:
  Item_func_makedate(THD *thd, Item *a, Item *b):
    Item_datefunc(thd, a, b) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("makedate") };
    return name;
  }
  bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override;
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_makedate>(thd, this); }
};


class Item_func_timestamp :public Item_datetimefunc
{
  bool check_arguments() const override
  {
    return args[0]->check_type_can_return_date(func_name_cstring()) ||
           args[1]->check_type_can_return_time(func_name_cstring());
  }
public:
  Item_func_timestamp(THD *thd, Item *a, Item *b)
   :Item_datetimefunc(thd, a, b)
  { }
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("timestamp") };
    return name;
  }
  bool fix_length_and_dec() override
  {
    THD *thd= current_thd;
    uint dec0= args[0]->datetime_precision(thd);
    uint dec1= Interval_DDhhmmssff::fsp(thd, args[1]);
    fix_attributes_datetime(MY_MAX(dec0, dec1));
    set_maybe_null();
    return false;
  }
  bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override
  {
    Datetime dt(thd, args[0], Datetime::Options(TIME_CONV_NONE, thd));
    if (!dt.is_valid_datetime())
      return (null_value= 1);

    Interval_DDhhmmssff it(thd, args[1]);
    if (!it.is_valid_interval_DDhhmmssff())
      return (null_value= true);
    return (null_value= Sec6_add(dt.get_mysql_time(), it.get_mysql_time(), 1).
                           to_datetime(ltime));
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_timestamp>(thd, this); }
};


/**
  ADDTIME(t,a) and SUBTIME(t,a) are time functions that calculate a
  time/datetime value

  t: time_or_datetime_expression
  a: time_expression

  Result: Time value or datetime value
*/

class Item_func_add_time :public Item_handled_func
{
  int sign;
public:
  // Methods used by ColumnStore
  int get_sign() const { return sign; }
public:
  Item_func_add_time(THD *thd, Item *a, Item *b, bool neg_arg)
   :Item_handled_func(thd, a, b), sign(neg_arg ? -1 : 1)
  { }
  bool fix_length_and_dec() override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING addtime= { STRING_WITH_LEN("addtime") };
    static LEX_CSTRING subtime= { STRING_WITH_LEN("subtime") };
    return sign > 0 ? addtime : subtime;
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_add_time>(thd, this); }
};


class Item_func_timediff :public Item_timefunc
{
  bool check_arguments() const override
  { return check_argument_types_can_return_time(0, arg_count); }
public:
  Item_func_timediff(THD *thd, Item *a, Item *b): Item_timefunc(thd, a, b) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("timediff") };
    return name;
  }
  bool fix_length_and_dec() override
  {
    THD *thd= current_thd;
    uint dec= MY_MAX(args[0]->time_precision(thd),
                     args[1]->time_precision(thd));
    fix_attributes_time(dec);
    set_maybe_null();
    return FALSE;
  }
  bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override;
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_timediff>(thd, this); }
};

class Item_func_maketime :public Item_timefunc
{
  bool check_arguments() const override
  {
    return check_argument_types_can_return_int(0, 2) ||
           args[2]->check_type_can_return_decimal(func_name_cstring());
  }
public:
  Item_func_maketime(THD *thd, Item *a, Item *b, Item *c):
    Item_timefunc(thd, a, b, c)
  {}
  bool fix_length_and_dec() override
  {
    fix_attributes_time(args[2]->decimals);
    set_maybe_null();
    return FALSE;
  }
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("maketime") };
    return name;
  }
  bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override;
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_maketime>(thd, this); }
};


class Item_func_microsecond :public Item_long_func_time_field
{
public:
  Item_func_microsecond(THD *thd, Item *a): Item_long_func_time_field(thd, a) {}
  longlong val_int() override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("microsecond") };
    return name;
  }
  bool fix_length_and_dec() override
  {
    decimals=0;
    set_maybe_null();
    fix_char_length(6);
    return FALSE;
  }
  bool check_partition_func_processor(void *int_arg) override {return FALSE;}
  bool check_vcol_func_processor(void *arg) override { return FALSE;}
  bool check_valid_arguments_processor(void *int_arg) override
  {
    return !has_time_args();
  }
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_microsecond>(thd, this); }
};


class Item_func_timestamp_diff :public Item_longlong_func
{
  bool check_arguments() const override
  { return check_argument_types_can_return_date(0, arg_count); }
  const interval_type int_type;
public:
  // Methods used by ColumnStore
  interval_type get_int_type() const { return int_type; };
public:
  Item_func_timestamp_diff(THD *thd, Item *a, Item *b, interval_type type_arg):
    Item_longlong_func(thd, a, b), int_type(type_arg) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("timestampdiff") };
    return name;
  }
  longlong val_int() override;
  bool fix_length_and_dec() override
  {
    decimals=0;
    set_maybe_null();
    return FALSE;
  }
  void print(String *str, enum_query_type query_type) override;
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_timestamp_diff>(thd, this); }
};


enum date_time_format
{
  USA_FORMAT, JIS_FORMAT, ISO_FORMAT, EUR_FORMAT, INTERNAL_FORMAT
};

class Item_func_get_format :public Item_str_ascii_func
{
public:
  const timestamp_type type; // keep it public
  Item_func_get_format(THD *thd, timestamp_type type_arg, Item *a):
    Item_str_ascii_func(thd, a), type(type_arg)
  {}
  String *val_str_ascii(String *str) override;
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("get_format") };
    return name;
  }
  bool fix_length_and_dec() override
  {
    set_maybe_null();
    decimals=0;
    fix_length_and_charset(17, default_charset());
    return FALSE;
  }
  void print(String *str, enum_query_type query_type) override;
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_get_format>(thd, this); }
};


class Item_func_str_to_date :public Item_handled_func
{
  bool const_item;
  String subject_converter;
  String format_converter;
  CHARSET_INFO *internal_charset;
public:
  Item_func_str_to_date(THD *thd, Item *a, Item *b):
    Item_handled_func(thd, a, b), const_item(false),
    internal_charset(NULL)
  {}
  bool get_date_common(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate,
                       timestamp_type);
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("str_to_date") };
    return name;
  }
  bool fix_length_and_dec() override;
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_str_to_date>(thd, this); }
};


class Item_func_last_day :public Item_datefunc
{
  bool check_arguments() const override
  { return args[0]->check_type_can_return_date(func_name_cstring()); }
public:
  Item_func_last_day(THD *thd, Item *a): Item_datefunc(thd, a) {}
  LEX_CSTRING func_name_cstring() const override
  {
    static LEX_CSTRING name= {STRING_WITH_LEN("last_day") };
    return name;
  }
  bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate) override;
  Item *do_get_copy(THD *thd) const override
  { return get_item_copy<Item_func_last_day>(thd, this); }
};


/*****************************************************************************/

class Func_handler_date_add_interval
{
protected:
  static uint interval_dec(const Item *item, interval_type int_type)
  {
    if (int_type == INTERVAL_MICROSECOND ||
        (int_type >= INTERVAL_DAY_MICROSECOND &&
         int_type <= INTERVAL_SECOND_MICROSECOND))
      return TIME_SECOND_PART_DIGITS;
    if (int_type == INTERVAL_SECOND && item->decimals > 0)
      return MY_MIN(item->decimals, TIME_SECOND_PART_DIGITS);
    return 0;
  }
  interval_type int_type(const Item_handled_func *item) const
  {
    return static_cast<const Item_date_add_interval*>(item)->int_type;
  }
  bool sub(const Item_handled_func *item) const
  {
    return static_cast<const Item_date_add_interval*>(item)->date_sub_interval;
  }
  bool add(THD *thd, Item *item, interval_type type, bool sub, MYSQL_TIME *to) const
  {
    INTERVAL interval;
    if (get_interval_value(thd, item, type, &interval))
      return true;
    if (sub)
      interval.neg = !interval.neg;
    return date_add_interval(thd, to, type, interval);
  }
};


class Func_handler_date_add_interval_datetime:
        public Item_handled_func::Handler_datetime,
        public Func_handler_date_add_interval
{
public:
  bool fix_length_and_dec(Item_handled_func *item) const override
  {
    uint dec= MY_MAX(item->arguments()[0]->datetime_precision(current_thd),
                     interval_dec(item->arguments()[1], int_type(item)));
    item->fix_attributes_datetime(dec);
    return false;
  }
  bool get_date(THD *thd, Item_handled_func *item,
                MYSQL_TIME *to, date_mode_t fuzzy) const override
  {
    Datetime::Options opt(TIME_CONV_NONE, thd);
    Datetime dt(thd, item->arguments()[0], opt);
    if (!dt.is_valid_datetime() ||
         dt.check_date_with_warn(thd, TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE))
      return (item->null_value= true);
    dt.copy_to_mysql_time(to);
    return (item->null_value= add(thd, item->arguments()[1],
                                  int_type(item), sub(item), to));
  }
};


class Func_handler_date_add_interval_datetime_arg0_time:
        public Func_handler_date_add_interval_datetime
{
public:
  bool get_date(THD *thd, Item_handled_func *item,
                MYSQL_TIME *to, date_mode_t fuzzy) const override;
};


class Func_handler_date_add_interval_date:
        public Item_handled_func::Handler_date,
        public Func_handler_date_add_interval
{
public:
  bool get_date(THD *thd, Item_handled_func *item,
                MYSQL_TIME *to, date_mode_t fuzzy) const override
  {
    /*
      The first argument is known to be of the DATE data type (not DATETIME).
      We don't need rounding here.
    */
    Date d(thd, item->arguments()[0], TIME_CONV_NONE);
    if (!d.is_valid_date() ||
         d.check_date_with_warn(thd, TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE))
      return (item->null_value= true);
    d.copy_to_mysql_time(to);
    return (item->null_value= add(thd, item->arguments()[1],
                                  int_type(item), sub(item), to));
  }
};


class Func_handler_date_add_interval_time:
        public Item_handled_func::Handler_time,
        public Func_handler_date_add_interval
{
public:
  bool fix_length_and_dec(Item_handled_func *item) const override
  {
    uint dec= MY_MAX(item->arguments()[0]->time_precision(current_thd),
                     interval_dec(item->arguments()[1], int_type(item)));
    item->fix_attributes_time(dec);
    return false;
  }
  bool get_date(THD *thd, Item_handled_func *item,
                MYSQL_TIME *to, date_mode_t fuzzy) const override
  {
    Time t(thd, item->arguments()[0]);
    if (!t.is_valid_time())
      return (item->null_value= true);
    t.copy_to_mysql_time(to);
    return (item->null_value= add(thd, item->arguments()[1],
                                  int_type(item), sub(item), to));
  }
};


class Func_handler_date_add_interval_string:
        public Item_handled_func::Handler_temporal_string,
        public Func_handler_date_add_interval
{
public:
  bool fix_length_and_dec(Item_handled_func *item) const override
  {
    uint dec= MY_MAX(item->arguments()[0]->datetime_precision(current_thd),
                     interval_dec(item->arguments()[1], int_type(item)));
    item->Type_std_attributes::set(
      Type_temporal_attributes_not_fixed_dec(MAX_DATETIME_WIDTH, dec, false),
      DTCollation(item->default_charset(),
                  DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII));
    item->fix_char_length(item->max_length);
    return false;
  }
  bool get_date(THD *thd, Item_handled_func *item,
                MYSQL_TIME *to, date_mode_t fuzzy) const override
  {
    if (item->arguments()[0]->
          get_date(thd, to, Datetime::Options(TIME_CONV_NONE, thd)) ||
        (to->time_type != MYSQL_TIMESTAMP_TIME &&
         check_date_with_warn(thd, to, TIME_NO_ZEROS, MYSQL_TIMESTAMP_ERROR)))
      return (item->null_value= true);
    return (item->null_value= add(thd, item->arguments()[1],
                                  int_type(item), sub(item), to));
  }
};


class Func_handler_sign
{
protected:
  int m_sign;
  Func_handler_sign(int sign) :m_sign(sign) { }
};


class Func_handler_add_time_datetime:
        public Item_handled_func::Handler_datetime,
        public Func_handler_sign
{
public:
  Func_handler_add_time_datetime(int sign)
   :Func_handler_sign(sign)
  { }
  bool fix_length_and_dec(Item_handled_func *item) const override
  {
    THD *thd= current_thd;
    uint dec0= item->arguments()[0]->datetime_precision(thd);
    uint dec1= Interval_DDhhmmssff::fsp(thd, item->arguments()[1]);
    item->fix_attributes_datetime(MY_MAX(dec0, dec1));
    return false;
  }
  bool get_date(THD *thd, Item_handled_func *item,
                MYSQL_TIME *to, date_mode_t fuzzy) const override
  {
    DBUG_ASSERT(item->fixed());
    Datetime::Options opt(TIME_CONV_NONE, thd);
    Datetime dt(thd, item->arguments()[0], opt);
    if (!dt.is_valid_datetime())
      return (item->null_value= true);
    Interval_DDhhmmssff it(thd, item->arguments()[1]);
    if (!it.is_valid_interval_DDhhmmssff())
      return (item->null_value= true);
    return (item->null_value= (Sec6_add(dt.get_mysql_time(),
                                        it.get_mysql_time(), m_sign).
                               to_datetime(to)));
  }
};


class Func_handler_add_time_time:
        public Item_handled_func::Handler_time,
        public Func_handler_sign
{
public:
  Func_handler_add_time_time(int sign)
   :Func_handler_sign(sign)
  { }
  bool fix_length_and_dec(Item_handled_func *item) const override
  {
    THD *thd= current_thd;
    uint dec0= item->arguments()[0]->time_precision(thd);
    uint dec1= Interval_DDhhmmssff::fsp(thd, item->arguments()[1]);
    item->fix_attributes_time(MY_MAX(dec0, dec1));
    return false;
  }
  bool get_date(THD *thd, Item_handled_func *item,
                MYSQL_TIME *to, date_mode_t fuzzy) const override
  {
    DBUG_ASSERT(item->fixed());
    Time t(thd, item->arguments()[0]);
    if (!t.is_valid_time())
      return (item->null_value= true);
    Interval_DDhhmmssff i(thd, item->arguments()[1]);
    if (!i.is_valid_interval_DDhhmmssff())
      return (item->null_value= true);
    return (item->null_value= (Sec6_add(t.get_mysql_time(),
                                        i.get_mysql_time(), m_sign).
                                 to_time(thd, to, item->decimals)));
  }
};


class Func_handler_add_time_string:
        public Item_handled_func::Handler_temporal_string,
        public Func_handler_sign
{
public:
  Func_handler_add_time_string(int sign)
   :Func_handler_sign(sign)
  { }
  bool fix_length_and_dec(Item_handled_func *item) const override
  {
    uint dec0= item->arguments()[0]->decimals;
    uint dec1= Interval_DDhhmmssff::fsp(current_thd, item->arguments()[1]);
    uint dec= MY_MAX(dec0, dec1);
    item->Type_std_attributes::set(
      Type_temporal_attributes_not_fixed_dec(MAX_DATETIME_WIDTH, dec, false),
      DTCollation(item->default_charset(),
                  DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII));
    item->fix_char_length(item->max_length);
    return false;
  }
  bool get_date(THD *thd, Item_handled_func *item,
                MYSQL_TIME *to, date_mode_t fuzzy) const override
  {
    DBUG_ASSERT(item->fixed());
    // Detect a proper timestamp type based on the argument values
    Temporal_hybrid l_time1(thd, item->arguments()[0],
                            Temporal::Options(TIME_TIME_ONLY, thd));
    if (!l_time1.is_valid_temporal())
      return (item->null_value= true);
    Interval_DDhhmmssff l_time2(thd, item->arguments()[1]);
    if (!l_time2.is_valid_interval_DDhhmmssff())
      return (item->null_value= true);
    Sec6_add add(l_time1.get_mysql_time(), l_time2.get_mysql_time(), m_sign);
    return (item->null_value= (l_time1.get_mysql_time()->time_type ==
                                 MYSQL_TIMESTAMP_TIME ?
                               add.to_time(thd, to, item->decimals) :
                               add.to_datetime(to)));
  }
};


class Func_handler_str_to_date_datetime_sec:
        public Item_handled_func::Handler_datetime
{
public:
  bool fix_length_and_dec(Item_handled_func *item) const override
  {
    item->fix_attributes_datetime(0);
    return false;
  }
  bool get_date(THD *thd, Item_handled_func *item,
                MYSQL_TIME *to, date_mode_t fuzzy) const override
  {
    return static_cast<Item_func_str_to_date*>(item)->
             get_date_common(thd, to, fuzzy, MYSQL_TIMESTAMP_DATETIME);
  }
};


class Func_handler_str_to_date_datetime_usec:
        public Item_handled_func::Handler_datetime
{
public:
  bool fix_length_and_dec(Item_handled_func *item) const override
  {
    item->fix_attributes_datetime(TIME_SECOND_PART_DIGITS);
    return false;
  }
  bool get_date(THD *thd, Item_handled_func *item,
                MYSQL_TIME *to, date_mode_t fuzzy) const override
  {
    return static_cast<Item_func_str_to_date*>(item)->
             get_date_common(thd, to, fuzzy, MYSQL_TIMESTAMP_DATETIME);
  }
};


class Func_handler_str_to_date_date: public Item_handled_func::Handler_date
{
public:
  bool get_date(THD *thd, Item_handled_func *item,
                MYSQL_TIME *to, date_mode_t fuzzy) const override
  {
    return static_cast<Item_func_str_to_date*>(item)->
             get_date_common(thd, to, fuzzy, MYSQL_TIMESTAMP_DATE);
  }
};


class Func_handler_str_to_date_time: public Item_handled_func::Handler_time
{
public:
  bool get_date(THD *thd, Item_handled_func *item,
                MYSQL_TIME *to, date_mode_t fuzzy) const override
  {
    if (static_cast<Item_func_str_to_date*>(item)->
         get_date_common(thd, to, fuzzy, MYSQL_TIMESTAMP_TIME))
      return true;
    if (to->day)
    {
      /*
        Day part for time type can be nonzero value and so
        we should add hours from day part to hour part to
        keep valid time value.
      */
      to->hour+= to->day * 24;
      to->day= 0;
    }
    return false;
  }
};


class Func_handler_str_to_date_time_sec: public Func_handler_str_to_date_time
{
public:
  bool fix_length_and_dec(Item_handled_func *item) const override
  {
    item->fix_attributes_time(0);
    return false;
  }
};


class Func_handler_str_to_date_time_usec: public Func_handler_str_to_date_time
{
public:
  bool fix_length_and_dec(Item_handled_func *item) const override
  {
    item->fix_attributes_time(TIME_SECOND_PART_DIGITS);
    return false;
  }
};


#endif /* ITEM_TIMEFUNC_INCLUDED */

SILENT KILLER Tool