MCPcopy Create free account
hub / github.com/MariaDB/server / period_get_condition

Function period_get_condition

sql/sql_select.cc:1027–1149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1025}
1026
1027static
1028Item* period_get_condition(THD *thd, TABLE_LIST *table, SELECT_LEX *select,
1029 vers_select_conds_t *conds, bool timestamp)
1030{
1031 DBUG_ASSERT(table);
1032 DBUG_ASSERT(table->table);
1033#define newx new (thd->mem_root)
1034 TABLE_SHARE *share= table->table->s;
1035 const TABLE_SHARE::period_info_t *period= conds->period;
1036
1037 const LEX_CSTRING &fstart= period->start_field(share)->field_name;
1038 const LEX_CSTRING &fend= period->end_field(share)->field_name;
1039
1040 conds->field_start= newx Item_field(thd, &select->context,
1041 table->db, table->alias,
1042 thd->strmake_lex_cstring(fstart));
1043 conds->field_end= newx Item_field(thd, &select->context,
1044 table->db, table->alias,
1045 thd->strmake_lex_cstring(fend));
1046
1047 Item *cond1= NULL, *cond2= NULL, *cond3= NULL, *curr= NULL;
1048 if (timestamp)
1049 {
1050 MYSQL_TIME max_time;
1051 switch (conds->type)
1052 {
1053 case SYSTEM_TIME_UNSPECIFIED:
1054 case SYSTEM_TIME_HISTORY:
1055 {
1056 thd->variables.time_zone->gmt_sec_to_TIME(&max_time, TIMESTAMP_MAX_VALUE);
1057 max_time.second_part= TIME_MAX_SECOND_PART;
1058 Datetime dt(&max_time);
1059 curr= newx Item_datetime_literal(thd, &dt, TIME_SECOND_PART_DIGITS);
1060 if (conds->type == SYSTEM_TIME_UNSPECIFIED)
1061 cond1= newx Item_func_eq(thd, conds->field_end, curr);
1062 else
1063 cond1= newx Item_func_lt(thd, conds->field_end, curr);
1064 break;
1065 }
1066 case SYSTEM_TIME_AS_OF:
1067 cond1= newx Item_func_le(thd, conds->field_start, conds->start.item);
1068 cond2= newx Item_func_gt(thd, conds->field_end, conds->start.item);
1069 break;
1070 case SYSTEM_TIME_FROM_TO:
1071 cond1= newx Item_func_lt(thd, conds->field_start, conds->end.item);
1072 cond2= newx Item_func_gt(thd, conds->field_end, conds->start.item);
1073 cond3= newx Item_func_lt(thd, conds->start.item, conds->end.item);
1074 break;
1075 case SYSTEM_TIME_BETWEEN:
1076 cond1= newx Item_func_le(thd, conds->field_start, conds->end.item);
1077 cond2= newx Item_func_gt(thd, conds->field_end, conds->start.item);
1078 cond3= newx Item_func_le(thd, conds->start.item, conds->end.item);
1079 break;
1080 case SYSTEM_TIME_BEFORE:
1081 cond1= newx Item_func_history(thd, conds->field_end);
1082 cond2= newx Item_func_lt(thd, conds->field_end, conds->start.item);
1083 break;
1084 default:

Callers 2

period_setup_condsMethod · 0.85
vers_setup_condsMethod · 0.85

Calls 15

Item_func_historyClass · 0.85
Item_func_trt_idClass · 0.85
Item_intClass · 0.85
and_itemsFunction · 0.85
start_fieldMethod · 0.80
end_fieldMethod · 0.80
strmake_lex_cstringMethod · 0.80
gmt_sec_to_TIMEMethod · 0.80
Item_fieldClass · 0.70

Tested by

no test coverage detected