golden hour
/usr/include/mysql/server/private
⬆️ Go Up
Upload
File/Folder
Size
Actions
aria_backup.h
1.51 KB
Del
OK
assume_aligned.h
2.29 KB
Del
OK
atomic
-
Del
OK
authors.h
9.9 KB
Del
OK
backup.h
1.21 KB
Del
OK
bounded_queue.h
6.67 KB
Del
OK
client_settings.h
1.89 KB
Del
OK
compat56.h
2.23 KB
Del
OK
config.h
14.18 KB
Del
OK
contributors.h
4.76 KB
Del
OK
create_options.h
4.42 KB
Del
OK
custom_conf.h
1.06 KB
Del
OK
datadict.h
1.53 KB
Del
OK
debug_sync.h
2 KB
Del
OK
derived_handler.h
2.32 KB
Del
OK
derror.h
980 B
Del
OK
des_key_file.h
1.21 KB
Del
OK
discover.h
1.53 KB
Del
OK
dur_prop.h
1.06 KB
Del
OK
embedded_priv.h
1.62 KB
Del
OK
event_data_objects.h
4.09 KB
Del
OK
event_db_repository.h
3.56 KB
Del
OK
event_parse_data.h
2.83 KB
Del
OK
event_queue.h
3.36 KB
Del
OK
event_scheduler.h
3.21 KB
Del
OK
events.h
4.59 KB
Del
OK
field.h
211.96 KB
Del
OK
field_comp.h
1.15 KB
Del
OK
filesort.h
6.67 KB
Del
OK
filesort_utils.h
8 KB
Del
OK
ft_global.h
3.04 KB
Del
OK
gcalc_slicescan.h
16.87 KB
Del
OK
gcalc_tools.h
11.62 KB
Del
OK
grant.h
2.69 KB
Del
OK
group_by_handler.h
3.45 KB
Del
OK
gstream.h
2.38 KB
Del
OK
ha_partition.h
62.22 KB
Del
OK
ha_sequence.h
5.94 KB
Del
OK
handle_connections_win.h
884 B
Del
OK
handler.h
188.39 KB
Del
OK
hash.h
4.34 KB
Del
OK
hash_filo.h
5.55 KB
Del
OK
heap.h
9.2 KB
Del
OK
hostname.h
5.29 KB
Del
OK
ilist.h
6.85 KB
Del
OK
init.h
852 B
Del
OK
innodb_priv.h
1.29 KB
Del
OK
item.h
263.12 KB
Del
OK
item_cmpfunc.h
128.01 KB
Del
OK
item_create.h
11.22 KB
Del
OK
item_func.h
124.59 KB
Del
OK
item_geofunc.h
34.69 KB
Del
OK
item_jsonfunc.h
19.8 KB
Del
OK
item_row.h
5.43 KB
Del
OK
item_strfunc.h
64.55 KB
Del
OK
item_subselect.h
56.19 KB
Del
OK
item_sum.h
69.2 KB
Del
OK
item_timefunc.h
57.85 KB
Del
OK
item_vers.h
3.79 KB
Del
OK
item_windowfunc.h
32.61 KB
Del
OK
item_xmlfunc.h
4.36 KB
Del
OK
key.h
2 KB
Del
OK
keycaches.h
1.95 KB
Del
OK
lex.h
28.9 KB
Del
OK
lex_ident.h
2.07 KB
Del
OK
lex_string.h
3.97 KB
Del
OK
lex_symbol.h
1.29 KB
Del
OK
lf.h
6.31 KB
Del
OK
lock.h
2.15 KB
Del
OK
log.h
44.46 KB
Del
OK
log_event.h
178.94 KB
Del
OK
log_event_data_type.h
1.85 KB
Del
OK
log_event_old.h
19.32 KB
Del
OK
log_slow.h
1.98 KB
Del
OK
maria.h
5.73 KB
Del
OK
mariadb.h
1.25 KB
Del
OK
mdl.h
36.78 KB
Del
OK
mem_root_array.h
6.94 KB
Del
OK
message.h
1.17 KB
Del
OK
multi_range_read.h
22.58 KB
Del
OK
my_alarm.h
2.37 KB
Del
OK
my_apc.h
4.62 KB
Del
OK
my_atomic.h
7.11 KB
Del
OK
my_atomic_wrapper.h
2.92 KB
Del
OK
my_base.h
26.5 KB
Del
OK
my_bit.h
6.05 KB
Del
OK
my_bitmap.h
5.22 KB
Del
OK
my_check_opt.h
2.56 KB
Del
OK
my_compare.h
10.93 KB
Del
OK
my_context.h
6.59 KB
Del
OK
my_counter.h
1.68 KB
Del
OK
my_cpu.h
4.85 KB
Del
OK
my_crypt.h
904 B
Del
OK
my_decimal.h
13.43 KB
Del
OK
my_default.h
1.84 KB
Del
OK
my_handler_errors.h
4.74 KB
Del
OK
my_json_writer.h
17.9 KB
Del
OK
my_libwrap.h
1.16 KB
Del
OK
my_md5.h
1.45 KB
Del
OK
my_minidump.h
848 B
Del
OK
my_nosys.h
1.4 KB
Del
OK
my_rdtsc.h
8.15 KB
Del
OK
my_rnd.h
1.04 KB
Del
OK
my_service_manager.h
1.47 KB
Del
OK
my_stack_alloc.h
6.2 KB
Del
OK
my_stacktrace.h
3.14 KB
Del
OK
my_time.h
10.22 KB
Del
OK
my_tree.h
3.9 KB
Del
OK
my_uctype.h
67.9 KB
Del
OK
my_user.h
1.1 KB
Del
OK
myisam.h
17.11 KB
Del
OK
myisamchk.h
4.61 KB
Del
OK
myisammrg.h
4.78 KB
Del
OK
myisampack.h
14.58 KB
Del
OK
mysql_async.h
1.77 KB
Del
OK
mysqld.h
38.7 KB
Del
OK
mysqld_default_groups.h
204 B
Del
OK
mysqld_suffix.h
1.17 KB
Del
OK
mysys_err.h
2.95 KB
Del
OK
nt_servc.h
2.94 KB
Del
OK
opt_range.h
57.58 KB
Del
OK
opt_subselect.h
14.21 KB
Del
OK
opt_trace.h
8.11 KB
Del
OK
opt_trace_context.h
3.21 KB
Del
OK
parse_file.h
4.11 KB
Del
OK
partition_element.h
5.09 KB
Del
OK
partition_info.h
18.85 KB
Del
OK
password.h
1.14 KB
Del
OK
pfs_file_provider.h
3.08 KB
Del
OK
pfs_idle_provider.h
1.35 KB
Del
OK
pfs_memory_provider.h
1.59 KB
Del
OK
pfs_metadata_provider.h
1.85 KB
Del
OK
pfs_socket_provider.h
2.21 KB
Del
OK
pfs_stage_provider.h
1.52 KB
Del
OK
pfs_statement_provider.h
4.25 KB
Del
OK
pfs_table_provider.h
2.56 KB
Del
OK
pfs_thread_provider.h
5.43 KB
Del
OK
pfs_transaction_provider.h
2.78 KB
Del
OK
privilege.h
27.9 KB
Del
OK
probes_mysql.h
973 B
Del
OK
probes_mysql_dtrace.h
32.23 KB
Del
OK
probes_mysql_nodtrace.h
4.89 KB
Del
OK
procedure.h
6.57 KB
Del
OK
protocol.h
12.32 KB
Del
OK
proxy_protocol.h
548 B
Del
OK
queues.h
3.46 KB
Del
OK
records.h
3.03 KB
Del
OK
repl_failsafe.h
1.55 KB
Del
OK
replication.h
15.73 KB
Del
OK
rijndael.h
1.67 KB
Del
OK
rowid_filter.h
15.13 KB
Del
OK
rpl_constants.h
3.28 KB
Del
OK
rpl_filter.h
4.43 KB
Del
OK
rpl_gtid.h
13.31 KB
Del
OK
rpl_injector.h
9.43 KB
Del
OK
rpl_mi.h
13.65 KB
Del
OK
rpl_parallel.h
13.57 KB
Del
OK
rpl_record.h
1.55 KB
Del
OK
rpl_record_old.h
1.37 KB
Del
OK
rpl_reporting.h
2.96 KB
Del
OK
rpl_rli.h
31.8 KB
Del
OK
rpl_tblmap.h
3.1 KB
Del
OK
rpl_utility.h
9.4 KB
Del
OK
scheduler.h
2.99 KB
Del
OK
scope.h
1.76 KB
Del
OK
select_handler.h
2.18 KB
Del
OK
semisync.h
2.23 KB
Del
OK
semisync_master.h
22.7 KB
Del
OK
semisync_master_ack_receiver.h
5.73 KB
Del
OK
semisync_slave.h
3.47 KB
Del
OK
service_versions.h
2 KB
Del
OK
session_tracker.h
13.96 KB
Del
OK
set_var.h
16.1 KB
Del
OK
slave.h
11.99 KB
Del
OK
source_revision.h
67 B
Del
OK
sp.h
22.02 KB
Del
OK
sp_cache.h
2 KB
Del
OK
sp_head.h
63.05 KB
Del
OK
sp_pcontext.h
24.31 KB
Del
OK
sp_rcontext.h
14 KB
Del
OK
span.h
3.84 KB
Del
OK
spatial.h
21.82 KB
Del
OK
sql_acl.h
13.8 KB
Del
OK
sql_admin.h
2.78 KB
Del
OK
sql_alloc.h
1.83 KB
Del
OK
sql_alter.h
11.86 KB
Del
OK
sql_analyse.h
11.23 KB
Del
OK
sql_analyze_stmt.h
11.48 KB
Del
OK
sql_array.h
6.79 KB
Del
OK
sql_audit.h
13.62 KB
Del
OK
sql_base.h
24.83 KB
Del
OK
sql_basic_types.h
9.28 KB
Del
OK
sql_binlog.h
895 B
Del
OK
sql_bitmap.h
7.66 KB
Del
OK
sql_bootstrap.h
1.63 KB
Del
OK
sql_cache.h
21.15 KB
Del
OK
sql_callback.h
1.51 KB
Del
OK
sql_class.h
250.08 KB
Del
OK
sql_cmd.h
9.13 KB
Del
OK
sql_connect.h
3.99 KB
Del
OK
sql_const.h
10.94 KB
Del
OK
sql_crypt.h
1.4 KB
Del
OK
sql_cte.h
16.15 KB
Del
OK
sql_cursor.h
2.26 KB
Del
OK
sql_db.h
2.16 KB
Del
OK
sql_debug.h
4.65 KB
Del
OK
sql_delete.h
1.31 KB
Del
OK
sql_derived.h
1.26 KB
Del
OK
sql_digest.h
3.73 KB
Del
OK
sql_digest_stream.h
1.53 KB
Del
OK
sql_do.h
954 B
Del
OK
sql_error.h
38.12 KB
Del
OK
sql_explain.h
27.1 KB
Del
OK
sql_expression_cache.h
4.26 KB
Del
OK
sql_get_diagnostics.h
7.68 KB
Del
OK
sql_handler.h
2.84 KB
Del
OK
sql_help.h
920 B
Del
OK
sql_hset.h
3.56 KB
Del
OK
sql_i_s.h
7.97 KB
Del
OK
sql_insert.h
2.39 KB
Del
OK
sql_join_cache.h
47.44 KB
Del
OK
sql_lex.h
166.31 KB
Del
OK
sql_lifo_buffer.h
9.45 KB
Del
OK
sql_limit.h
2.38 KB
Del
OK
sql_list.h
21.56 KB
Del
OK
sql_load.h
1.25 KB
Del
OK
sql_locale.h
2.64 KB
Del
OK
sql_manager.h
960 B
Del
OK
sql_mode.h
6.58 KB
Del
OK
sql_parse.h
8.26 KB
Del
OK
sql_partition.h
11.75 KB
Del
OK
sql_partition_admin.h
5.8 KB
Del
OK
sql_plist.h
7.55 KB
Del
OK
sql_plugin.h
7.39 KB
Del
OK
sql_plugin_compat.h
2.18 KB
Del
OK
sql_prepare.h
11.14 KB
Del
OK
sql_priv.h
17.67 KB
Del
OK
sql_profile.h
7.63 KB
Del
OK
sql_reload.h
1.01 KB
Del
OK
sql_rename.h
982 B
Del
OK
sql_repl.h
2.96 KB
Del
OK
sql_schema.h
3.23 KB
Del
OK
sql_select.h
86.56 KB
Del
OK
sql_sequence.h
5.06 KB
Del
OK
sql_servers.h
1.74 KB
Del
OK
sql_show.h
9.39 KB
Del
OK
sql_signal.h
3.28 KB
Del
OK
sql_sort.h
21.39 KB
Del
OK
sql_statistics.h
11.96 KB
Del
OK
sql_string.h
36.43 KB
Del
OK
sql_table.h
11.07 KB
Del
OK
sql_tablespace.h
956 B
Del
OK
sql_test.h
1.55 KB
Del
OK
sql_time.h
8.18 KB
Del
OK
sql_trigger.h
10.76 KB
Del
OK
sql_truncate.h
2.03 KB
Del
OK
sql_tvc.h
2.36 KB
Del
OK
sql_type.h
286 KB
Del
OK
sql_type_geom.h
18.53 KB
Del
OK
sql_type_int.h
9.73 KB
Del
OK
sql_type_json.h
6 KB
Del
OK
sql_type_real.h
1.23 KB
Del
OK
sql_type_string.h
1.59 KB
Del
OK
sql_udf.h
4.74 KB
Del
OK
sql_union.h
1.04 KB
Del
OK
sql_update.h
1.88 KB
Del
OK
sql_view.h
2.33 KB
Del
OK
sql_window.h
6.65 KB
Del
OK
ssl_compat.h
3.07 KB
Del
OK
strfunc.h
2.22 KB
Del
OK
structs.h
25.13 KB
Del
OK
sys_vars_shared.h
2.67 KB
Del
OK
t_ctype.h
5.51 KB
Del
OK
table.h
112.29 KB
Del
OK
table_cache.h
4.13 KB
Del
OK
thr_alarm.h
2.87 KB
Del
OK
thr_lock.h
6.7 KB
Del
OK
thr_malloc.h
1.17 KB
Del
OK
thr_timer.h
1.53 KB
Del
OK
thread_cache.h
5.77 KB
Del
OK
thread_pool_priv.h
4 KB
Del
OK
threadpool.h
4.51 KB
Del
OK
threadpool_generic.h
3.83 KB
Del
OK
transaction.h
1.43 KB
Del
OK
tzfile.h
4.9 KB
Del
OK
tztime.h
3.32 KB
Del
OK
uniques.h
4.1 KB
Del
OK
unireg.h
7.43 KB
Del
OK
vers_string.h
2.47 KB
Del
OK
violite.h
9.71 KB
Del
OK
waiting_threads.h
4.43 KB
Del
OK
welcome_copyright_notice.h
1.19 KB
Del
OK
win_tzname_data.h
6.35 KB
Del
OK
winservice.h
1.17 KB
Del
OK
wqueue.h
1.53 KB
Del
OK
wsrep.h
3.23 KB
Del
OK
wsrep_applier.h
2.64 KB
Del
OK
wsrep_binlog.h
3.36 KB
Del
OK
wsrep_client_service.h
2.5 KB
Del
OK
wsrep_client_state.h
1.53 KB
Del
OK
wsrep_condition_variable.h
1.45 KB
Del
OK
wsrep_high_priority_service.h
4.8 KB
Del
OK
wsrep_mutex.h
1.19 KB
Del
OK
wsrep_mysqld.h
19.88 KB
Del
OK
wsrep_mysqld_c.h
1.2 KB
Del
OK
wsrep_on.h
1.68 KB
Del
OK
wsrep_priv.h
1.6 KB
Del
OK
wsrep_schema.h
4.54 KB
Del
OK
wsrep_server_service.h
3.55 KB
Del
OK
wsrep_server_state.h
2.23 KB
Del
OK
wsrep_sst.h
3.86 KB
Del
OK
wsrep_storage_service.h
1.77 KB
Del
OK
wsrep_thd.h
10.58 KB
Del
OK
wsrep_trans_observer.h
17.81 KB
Del
OK
wsrep_types.h
997 B
Del
OK
wsrep_utils.h
9.07 KB
Del
OK
wsrep_var.h
4.17 KB
Del
OK
wsrep_xid.h
1.42 KB
Del
OK
xa.h
1.69 KB
Del
OK
Edit: 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()); } 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()); } 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; const char *func_name() const override { return "period_add"; } 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; const char *func_name() const override { return "period_diff"; } 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; const char *func_name() const override { return "to_days"; } bool fix_length_and_dec() override { decimals=0; max_length=6*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; 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; const char *func_name() const override { return "to_seconds"; } bool fix_length_and_dec() override { decimals=0; fix_char_length(12); maybe_null= 1; 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; const char *func_name() const override { return "dayofmonth"; } bool fix_length_and_dec() override { decimals=0; max_length=2*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; 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; const char *func_name() const override { return "month"; } bool fix_length_and_dec() override { decimals= 0; fix_char_length(2); maybe_null=1; 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) {} const char *func_name() const override { return "monthname"; } 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; const char *func_name() const override { return "dayofyear"; } bool fix_length_and_dec() override { decimals= 0; fix_char_length(3); maybe_null=1; 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; const char *func_name() const override { return "hour"; } bool fix_length_and_dec() override { decimals=0; max_length=2*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; 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; const char *func_name() const override { return "minute"; } bool fix_length_and_dec() override { decimals=0; max_length=2*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; 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; const char *func_name() const override { return "quarter"; } bool fix_length_and_dec() override { decimals=0; max_length=1*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; 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; const char *func_name() const override { return "second"; } bool fix_length_and_dec() override { decimals=0; max_length=2*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; 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()) || (arg_count > 1 && args[1]->check_type_can_return_int(func_name())); } 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; const char *func_name() const override { return "week"; } bool fix_length_and_dec() override { decimals=0; max_length=2*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; 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()) || args[1]->check_type_can_return_int(func_name()); } public: Item_func_yearweek(THD *thd, Item *a, Item *b) :Item_long_func(thd, a, b) {} longlong val_int() override; const char *func_name() const override { return "yearweek"; } bool fix_length_and_dec() override { decimals=0; max_length=6*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; 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; const char *func_name() const override { return "year"; } 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; maybe_null=1; 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; const char *func_name() const override { 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); maybe_null=1; 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) {} const char *func_name() const override { return "dayname"; } 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); maybe_null= true; 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) {} const char *func_name() const override { return "unix_timestamp"; } 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) {} const char *func_name() const override { return "time_to_sec"; } 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 { 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(); 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 { 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 { 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) {} const char *func_name() const override { return "curtime"; } 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) {} const char *func_name() const override { return "utc_time"; } 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) {} const char *func_name() const override { return "curdate"; } 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) {} const char *func_name() const override { return "utc_date"; } 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) {} const char *func_name() const override { return "current_timestamp"; } 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) {} const char *func_name() const override { return "utc_timestamp"; } 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; } const char *func_name() const override { return "sysdate"; } 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()); } public: Item_func_from_days(THD *thd, Item *a): Item_datefunc(thd, a) {} const char *func_name() const override { return "from_days"; } 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()) || 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; const char *func_name() const override { return "date_format"; } 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; } const char *func_name() const override { return "time_format"; } 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); } }; class Item_func_from_unixtime :public Item_datetimefunc { bool check_arguments() const override { return args[0]->check_type_can_return_decimal(func_name()); } Time_zone *tz; public: Item_func_from_unixtime(THD *thd, Item *a): Item_datetimefunc(thd, a) {} const char *func_name() const override { return "from_unixtime"; } 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()) || 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) {} const char *func_name() const override { return "convert_tz"; } bool fix_length_and_dec() override { fix_attributes_datetime(args[0]->datetime_precision(current_thd)); maybe_null= true; 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()); } 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); maybe_null= true; return FALSE; } const char *func_name() const override { return "sec_to_time"; } 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) {} const char *func_name() const override { return "date_add_interval"; } 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; } const char *func_name() const override { return "extract"; } 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; const char *func_name() const override { return "cast_as_char"; } 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) {} const char *func_name() const override { return "cast_as_date"; } 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; } const char *func_name() const override { return "cast_as_time"; } 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; } const char *func_name() const override { return "cast_as_datetime"; } 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) {} const char *func_name() const override { return "makedate"; } 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()) || args[1]->check_type_can_return_time(func_name()); } public: Item_func_timestamp(THD *thd, Item *a, Item *b) :Item_datetimefunc(thd, a, b) { } const char *func_name() const override { return "timestamp"; } 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)); maybe_null= true; 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= true; 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; const char *func_name() const override { 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) {} const char *func_name() const override { return "timediff"; } 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); maybe_null= true; 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()); } 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); maybe_null= true; return FALSE; } const char *func_name() const override { return "maketime"; } 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; const char *func_name() const override { return "microsecond"; } bool fix_length_and_dec() override { decimals=0; maybe_null=1; 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) {} const char *func_name() const override { return "timestampdiff"; } longlong val_int() override; bool fix_length_and_dec() override { decimals=0; maybe_null=1; 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; const char *func_name() const override { return "get_format"; } bool fix_length_and_dec() override { maybe_null= 1; 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); const char *func_name() const override { return "str_to_date"; } 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()); } public: Item_func_last_day(THD *thd, Item *a): Item_datefunc(thd, a) {} const char *func_name() const override { return "last_day"; } 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->is_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->is_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->is_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 */
Save