538
540
if (field_item->field->can_be_compared_as_int64_t() &&
539
541
!(field_item->is_datetime() && args[1]->result_type() == STRING_RESULT))
541
if (convert_constant_item(&getSession(), field_item, &args[1]))
543
if (convert_constant_item(session, field_item, &args[1]))
543
545
cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
544
546
INT_RESULT); // Works for all types.
554
556
!(field_item->is_datetime() &&
555
557
args[0]->result_type() == STRING_RESULT))
557
if (convert_constant_item(&getSession(), field_item, &args[0]))
559
if (convert_constant_item(session, field_item, &args[0]))
559
561
cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
560
562
INT_RESULT); // Works for all types.
694
696
converted value. 0 on error and on zero-dates -- check 'failure'
698
get_date_from_str(Session *session, String *str, type::timestamp_t warn_type,
700
get_date_from_str(Session *session, String *str, enum enum_drizzle_timestamp_type warn_type,
699
701
char *warn_name, bool *error_arg)
702
type::cut_t error= type::VALID;
703
705
type::Time l_time;
704
type::timestamp_t ret;
706
ret= l_time.store(str->ptr(), str->length(),
707
(TIME_FUZZY_DATE | MODE_INVALID_DATES | (session->variables.sql_mode & MODE_NO_ZERO_DATE)),
710
if (ret == type::DRIZZLE_TIMESTAMP_DATETIME || ret == type::DRIZZLE_TIMESTAMP_DATE)
706
enum enum_drizzle_timestamp_type ret;
708
ret= str_to_datetime(str->ptr(), str->length(), &l_time,
709
(TIME_FUZZY_DATE | MODE_INVALID_DATES |
710
(session->variables.sql_mode & MODE_NO_ZERO_DATE)),
713
if (ret == DRIZZLE_TIMESTAMP_DATETIME || ret == DRIZZLE_TIMESTAMP_DATE)
713
716
Do not return yet, we may still want to throw a "trailing garbage"
716
719
*error_arg= false;
717
l_time.convert(value);
720
value= TIME_to_uint64_t_datetime(&l_time);
721
724
*error_arg= true;
722
error= type::CUT; /* force warning */
725
error= 1; /* force warning */
725
if (error != type::VALID)
727
730
make_truncated_value_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
728
731
str->ptr(), str->length(),
768
771
enum Arg_comparator::enum_date_cmp_type
769
772
Arg_comparator::can_compare_as_dates(Item *in_a, Item *in_b,
770
int64_t *const_value)
773
uint64_t *const_value)
772
775
enum enum_date_cmp_type cmp_type= CMP_DATE_DFLT;
773
776
Item *str_arg= 0, *date_arg= 0;
862
865
Item **a1, Item **a2,
863
866
Item_result type)
865
enum_date_cmp_type cmp_type;
866
int64_t const_value= -1;
868
enum enum_date_cmp_type cmp_type;
869
uint64_t const_value= (uint64_t)-1;
870
873
if ((cmp_type= can_compare_as_dates(*a, *b, &const_value)))
875
session= current_session;
872
876
owner= owner_arg;
873
877
a_type= (*a)->field_type();
874
878
b_type= (*b)->field_type();
878
if (const_value != -1)
882
if (const_value != (uint64_t)-1)
880
884
Item_cache_int *cache= new Item_cache_int();
881
885
/* Mark the cache as non-const to prevent re-caching. */
993
995
enum_field_types f_type= warn_item->field_type();
994
type::timestamp_t t_type= f_type == DRIZZLE_TYPE_DATE ? type::DRIZZLE_TIMESTAMP_DATE : type::DRIZZLE_TIMESTAMP_DATETIME;
996
enum enum_drizzle_timestamp_type t_type= f_type ==
997
DRIZZLE_TYPE_DATE ? DRIZZLE_TIMESTAMP_DATE : DRIZZLE_TIMESTAMP_DATETIME;
995
998
value= get_date_from_str(session, str, t_type, warn_item->name, &error);
997
1000
If str did not contain a valid date according to the current
1666
1668
change records at each execution.
1668
1670
if ((*args) != new_item)
1669
getSession().change_item_tree(args, new_item);
1671
current_session->change_item_tree(args, new_item);
1672
1674
Transform the right IN operand which should be an Item_in_subselect or a
2046
2049
The following can't be recoded with || as convert_constant_item
2047
2050
changes the argument
2049
if (convert_constant_item(&getSession(), field_item, &args[1]))
2052
if (convert_constant_item(session, field_item, &args[1]))
2050
2053
cmp_type=INT_RESULT; // Works for all types.
2051
if (convert_constant_item(&getSession(), field_item, &args[2]))
2054
if (convert_constant_item(session, field_item, &args[2]))
2052
2055
cmp_type=INT_RESULT; // Works for all types.
3181
in_int64_t::in_int64_t(uint32_t elements) :
3182
in_vector(elements, sizeof(packed_int64_t),(qsort2_cmp) cmp_int64_t, 0)
3184
in_int64_t::in_int64_t(uint32_t elements)
3185
:in_vector(elements,sizeof(packed_int64_t),(qsort2_cmp) cmp_int64_t, 0)
3185
3188
void in_int64_t::set(uint32_t pos,Item *item)
3696
3700
bool all_converted= true;
3697
3701
for (arg=args+1, arg_end=args+arg_count; arg != arg_end ; arg++)
3699
if (!convert_constant_item (&getSession(), field_item, &arg[0]))
3703
if (!convert_constant_item (session, field_item, &arg[0]))
3700
3704
all_converted= false;
3702
3706
if (all_converted)
4023
4027
change records at each execution.
4025
4029
if (new_item != item)
4026
getSession().change_item_tree(li.ref(), new_item);
4030
current_session->change_item_tree(li.ref(), new_item);
4028
4032
return Item_func::transform(transformer, arg);
4464
4468
pattern = first + 1;
4465
4469
pattern_len = (int) len - 2;
4466
int *suff = (int*) session->getMemRoot()->allocate((int) (sizeof(int)*
4467
((pattern_len + 1)*2+
4470
int *suff = (int*) session->alloc((int) (sizeof(int)*
4471
((pattern_len + 1)*2+
4469
4473
bmGs = suff + pattern_len + 1;
4470
4474
bmBc = bmGs + pattern_len + 1;
4471
4475
turboBM_compute_good_suffix_shifts(suff);
4482
4486
Item_bool_func2::cleanup();
4485
static unsigned char likeconv(const CHARSET_INFO *cs, unsigned char a)
4487
4489
#ifdef LIKE_CMP_TOUPPER
4488
return cs->toupper(a);
4490
#define likeconv(cs,A) (unsigned char) (cs)->toupper(A)
4490
return cs->sort_order[a];
4492
#define likeconv(cs,A) (unsigned char) (cs)->sort_order[(unsigned char) (A)]
4495
4497
Precomputation dependent only on pattern_len.
5111
5113
List_iterator_fast<Item_field> it(fields);
5112
5114
Item *item= const_item ? const_item : it++;
5115
if ((null_value= item->null_value))
5113
5117
eval_item->store_value(item);
5114
if ((null_value= item->null_value))
5116
5118
while ((item_field= it++))
5118
5120
/* Skip fields of non-const tables. They haven't been read yet */
5119
5121
if (item_field->field->getTable()->const_table)
5121
if (eval_item->cmp(item_field) || (null_value= item_field->null_value))
5123
if ((null_value= item_field->null_value) || eval_item->cmp(item_field))
5161
5163
change records at each execution.
5163
5165
if (new_item != item)
5164
getSession().change_item_tree((Item **) it.ref(), new_item);
5166
current_session->change_item_tree((Item **) it.ref(), new_item);
5166
5168
return Item_func::transform(transformer, arg);