21
21
This file defines all compare functions
25
#include "drizzled/sql_select.h"
26
#include "drizzled/error.h"
27
#include "drizzled/temporal.h"
28
#include "drizzled/item/cmpfunc.h"
29
#include "drizzled/cached_item.h"
30
#include "drizzled/item/cache_int.h"
31
#include "drizzled/item/int_with_ref.h"
32
#include "drizzled/check_stack_overrun.h"
33
#include "drizzled/time_functions.h"
34
#include "drizzled/internal/my_sys.h"
43
extern const double log_10[309];
45
static Eq_creator eq_creator;
46
static Ne_creator ne_creator;
47
static Gt_creator gt_creator;
48
static Lt_creator lt_creator;
49
static Ge_creator ge_creator;
50
static Le_creator le_creator;
52
static bool convert_constant_item(Session *, Item_field *, Item **);
24
#ifdef USE_PRAGMA_IMPLEMENTATION
25
#pragma implementation // gcc: Class implementation
28
#include "mysql_priv.h"
30
#include "sql_select.h"
32
static bool convert_constant_item(THD *, Item_field *, Item **);
54
34
static Item_result item_store_type(Item_result a, Item *item,
35
my_bool unsigned_flag)
57
37
Item_result b= item->result_type();
220
199
Bitmap of collected types - otherwise
223
static uint32_t collect_cmp_types(Item **items, uint32_t nitems, bool skip_nulls= false)
202
static uint collect_cmp_types(Item **items, uint nitems)
226
uint32_t found_types;
227
206
Item_result left_result= items[0]->result_type();
228
207
assert(nitems > 1);
230
209
for (i= 1; i < nitems ; i++)
232
if (skip_nulls && items[i]->type() == Item::NULL_ITEM)
233
continue; // Skip NULL constant items
234
if ((left_result == ROW_RESULT ||
211
if ((left_result == ROW_RESULT ||
235
212
items[i]->result_type() == ROW_RESULT) &&
236
213
cmp_row_type(items[0], items[i]))
238
found_types|= 1<< (uint32_t)item_cmp_type(left_result,
215
found_types|= 1<< (uint)item_cmp_type(left_result,
239
216
items[i]->result_type());
242
Even if all right-hand items are NULLs and we are skipping them all, we need
243
at least one type bit in the found_type bitmask.
245
if (skip_nulls && !found_types)
246
found_types= 1 << (uint)left_result;
247
218
return found_types;
221
static void my_coll_agg_error(DTCollation &c1, DTCollation &c2,
224
my_error(ER_CANT_AGGREGATE_2COLLATIONS, MYF(0),
225
c1.collation->name,c1.derivation_name(),
226
c2.collation->name,c2.derivation_name(),
251
231
Item_bool_func2* Eq_creator::create(Item *a, Item *b) const
257
const Eq_creator* Eq_creator::instance()
263
237
Item_bool_func2* Ne_creator::create(Item *a, Item *b) const
265
239
return new Item_func_ne(a, b);
269
const Ne_creator* Ne_creator::instance()
275
243
Item_bool_func2* Gt_creator::create(Item *a, Item *b) const
277
245
return new Item_func_gt(a, b);
281
const Gt_creator* Gt_creator::instance()
287
249
Item_bool_func2* Lt_creator::create(Item *a, Item *b) const
289
251
return new Item_func_lt(a, b);
293
const Lt_creator* Lt_creator::instance()
299
255
Item_bool_func2* Ge_creator::create(Item *a, Item *b) const
301
257
return new Item_func_ge(a, b);
305
const Ge_creator* Ge_creator::instance()
311
261
Item_bool_func2* Le_creator::create(Item *a, Item *b) const
313
263
return new Item_func_le(a, b);
316
const Le_creator* Le_creator::instance()
324
268
Most of these returns 0LL if false and 1LL if true and
325
269
NULL if some arg is NULL.
328
int64_t Item_func_not::val_int()
272
longlong Item_func_not::val_int()
330
274
assert(fixed == 1);
331
275
bool value= args[0]->val_bool();
439
383
1 Item was replaced with an integer version of the item
442
static bool convert_constant_item(Session *session, Item_field *field_item,
386
static bool convert_constant_item(THD *thd, Item_field *field_item,
445
389
Field *field= field_item->field;
448
field->setWriteSet();
450
392
if (!(*item)->with_subselect && (*item)->const_item())
452
ulong orig_sql_mode= session->variables.sql_mode;
453
enum_check_fields orig_count_cuted_fields= session->count_cuted_fields;
454
uint64_t orig_field_val= 0; /* original field value if valid */
394
TABLE *table= field->table;
395
ulong orig_sql_mode= thd->variables.sql_mode;
396
enum_check_fields orig_count_cuted_fields= thd->count_cuted_fields;
397
my_bitmap_map *old_write_map;
398
my_bitmap_map *old_read_map;
399
ulonglong orig_field_val= 0; /* original field value if valid */
403
old_write_map= dbug_tmp_use_all_columns(table, table->write_set);
404
old_read_map= dbug_tmp_use_all_columns(table, table->read_set);
456
406
/* For comparison purposes allow invalid dates like 2000-01-32 */
457
session->variables.sql_mode= (orig_sql_mode & ~MODE_NO_ZERO_DATE) |
407
thd->variables.sql_mode= (orig_sql_mode & ~MODE_NO_ZERO_DATE) |
458
408
MODE_INVALID_DATES;
459
session->count_cuted_fields= CHECK_FIELD_IGNORE;
409
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
462
412
Store the value of the field if it references an outer field because
498
453
if (!args[0] || !args[1])
502
457
We allow to convert to Unicode character sets in some cases.
503
458
The conditions when conversion is possible are:
504
459
- arguments A and B have different charsets
505
460
- A wins according to coercibility rules
506
461
- character set of A is superset for character set of B
508
463
If all of the above is true, then it's possible to convert
509
464
B into the character set of A, and then compare according
510
465
to the collation of A.
514
469
DTCollation coll;
515
470
if (args[0]->result_type() == STRING_RESULT &&
516
471
args[1]->result_type() == STRING_RESULT &&
517
472
agg_arg_charsets(coll, args, 2, MY_COLL_CMP_CONV, 1))
520
475
args[0]->cmp_context= args[1]->cmp_context=
521
476
item_cmp_type(args[0]->result_type(), args[1]->result_type());
522
477
// Make a special case of compare with fields to get nicer DATE comparisons
530
session= current_session;
531
Item_field *field_item= NULL;
533
if (args[0]->real_item()->type() == FIELD_ITEM)
486
if (!thd->is_context_analysis_only())
535
field_item= static_cast<Item_field*>(args[0]->real_item());
536
if (field_item->field->can_be_compared_as_int64_t() &&
537
!(field_item->is_datetime() && args[1]->result_type() == STRING_RESULT))
488
if (args[0]->real_item()->type() == FIELD_ITEM)
539
if (convert_constant_item(session, field_item, &args[1]))
490
Item_field *field_item= (Item_field*) (args[0]->real_item());
491
if (field_item->field->can_be_compared_as_longlong() &&
492
!(field_item->is_datetime() &&
493
args[1]->result_type() == STRING_RESULT))
541
cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
542
INT_RESULT); // Works for all types.
543
args[0]->cmp_context= args[1]->cmp_context= INT_RESULT;
495
if (convert_constant_item(thd, field_item, &args[1]))
497
cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
498
INT_RESULT); // Works for all types.
499
args[0]->cmp_context= args[1]->cmp_context= INT_RESULT;
548
504
if (args[1]->real_item()->type() == FIELD_ITEM)
550
field_item= static_cast<Item_field*>(args[1]->real_item());
551
if (field_item->field->can_be_compared_as_int64_t() &&
506
Item_field *field_item= (Item_field*) (args[1]->real_item());
507
if (field_item->field->can_be_compared_as_longlong() &&
552
508
!(field_item->is_datetime() &&
553
509
args[0]->result_type() == STRING_RESULT))
555
if (convert_constant_item(session, field_item, &args[0]))
511
if (convert_constant_item(thd, field_item, &args[0]))
557
513
cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
558
514
INT_RESULT); // Works for all types.
572
528
func= comparator_matrix[type]
573
[test(owner->functype() == Item_func::EQUAL_FUNC)];
529
[test(owner->functype() == Item_func::EQUAL_FUNC)];
578
uint32_t n= (*a)->cols();
579
if (n != (*b)->cols())
581
my_error(ER_OPERAND_COLUMNS, MYF(0), n);
585
if (!(comparators= new Arg_comparator[n]))
587
for (uint32_t i=0; i < n; i++)
589
if ((*a)->element_index(i)->cols() != (*b)->element_index(i)->cols())
591
my_error(ER_OPERAND_COLUMNS, MYF(0), (*a)->element_index(i)->cols());
594
comparators[i].set_cmp_func(owner, (*a)->addr(i), (*b)->addr(i));
533
uint n= (*a)->cols();
534
if (n != (*b)->cols())
536
my_error(ER_OPERAND_COLUMNS, MYF(0), n);
540
if (!(comparators= new Arg_comparator[n]))
542
for (uint i=0; i < n; i++)
544
if ((*a)->element_index(i)->cols() != (*b)->element_index(i)->cols())
546
my_error(ER_OPERAND_COLUMNS, MYF(0), (*a)->element_index(i)->cols());
549
comparators[i].set_cmp_func(owner, (*a)->addr(i), (*b)->addr(i));
599
553
case STRING_RESULT:
556
We must set cmp_charset here as we may be called from for an automatic
557
generated item, like in natural join
559
if (cmp_collation.set((*a)->collation, (*b)->collation) ||
560
cmp_collation.derivation == DERIVATION_NONE)
562
my_coll_agg_error((*a)->collation, (*b)->collation, owner->func_name());
565
if (cmp_collation.collation == &my_charset_bin)
602
We must set cmp_charset here as we may be called from for an automatic
603
generated item, like in natural join
568
We are using BLOB/BINARY/VARBINARY, change to compare byte by byte,
569
without removing end space
605
if (cmp_collation.set((*a)->collation, (*b)->collation) ||
606
cmp_collation.derivation == DERIVATION_NONE)
608
my_coll_agg_error((*a)->collation, (*b)->collation, owner->func_name());
611
if (cmp_collation.collation == &my_charset_bin)
614
We are using BLOB/BINARY/VARBINARY, change to compare byte by byte,
615
without removing end space
617
if (func == &Arg_comparator::compare_string)
618
func= &Arg_comparator::compare_binary_string;
619
else if (func == &Arg_comparator::compare_e_string)
620
func= &Arg_comparator::compare_e_binary_string;
571
if (func == &Arg_comparator::compare_string)
572
func= &Arg_comparator::compare_binary_string;
573
else if (func == &Arg_comparator::compare_e_string)
574
func= &Arg_comparator::compare_e_binary_string;
623
As this is binary compassion, mark all fields that they can't be
624
transformed. Otherwise we would get into trouble with comparisons
626
WHERE col= 'j' AND col LIKE BINARY 'j'
627
which would be transformed to:
577
As this is binary compassion, mark all fields that they can't be
578
transformed. Otherwise we would get into trouble with comparisons
580
WHERE col= 'j' AND col LIKE BINARY 'j'
581
which would be transformed to:
630
(*a)->walk(&Item::set_no_const_sub, false, (unsigned char*) 0);
631
(*b)->walk(&Item::set_no_const_sub, false, (unsigned char*) 0);
584
(*a)->walk(&Item::set_no_const_sub, false, (uchar*) 0);
585
(*b)->walk(&Item::set_no_const_sub, false, (uchar*) 0);
637
if (func == &Arg_comparator::compare_int_signed)
639
if ((*a)->unsigned_flag)
640
func= (((*b)->unsigned_flag)?
641
&Arg_comparator::compare_int_unsigned :
642
&Arg_comparator::compare_int_unsigned_signed);
643
else if ((*b)->unsigned_flag)
644
func= &Arg_comparator::compare_int_signed_unsigned;
646
else if (func== &Arg_comparator::compare_e_int)
648
if ((*a)->unsigned_flag ^ (*b)->unsigned_flag)
649
func= &Arg_comparator::compare_e_int_diff_signedness;
591
if (func == &Arg_comparator::compare_int_signed)
593
if ((*a)->unsigned_flag)
594
func= (((*b)->unsigned_flag)?
595
&Arg_comparator::compare_int_unsigned :
596
&Arg_comparator::compare_int_unsigned_signed);
597
else if ((*b)->unsigned_flag)
598
func= &Arg_comparator::compare_int_signed_unsigned;
600
else if (func== &Arg_comparator::compare_e_int)
602
if ((*a)->unsigned_flag ^ (*b)->unsigned_flag)
603
func= &Arg_comparator::compare_e_int_diff_signedness;
653
607
case DECIMAL_RESULT:
655
609
case REAL_RESULT:
611
if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
657
if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC)
659
precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
660
if (func == &Arg_comparator::compare_real)
661
func= &Arg_comparator::compare_real_fixed;
662
else if (func == &Arg_comparator::compare_e_real)
663
func= &Arg_comparator::compare_e_real_fixed;
613
precision= 5 / log_10[max((*a)->decimals, (*b)->decimals) + 1];
614
if (func == &Arg_comparator::compare_real)
615
func= &Arg_comparator::compare_real_fixed;
616
else if (func == &Arg_comparator::compare_e_real)
617
func= &Arg_comparator::compare_e_real_fixed;
692
647
converted value. 0 on error and on zero-dates -- check 'failure'
696
get_date_from_str(Session *session, String *str, enum enum_drizzle_timestamp_type warn_type,
651
get_date_from_str(THD *thd, String *str, timestamp_type warn_type,
697
652
char *warn_name, bool *error_arg)
702
enum enum_drizzle_timestamp_type ret;
657
enum_mysql_timestamp_type ret;
704
659
ret= str_to_datetime(str->ptr(), str->length(), &l_time,
705
660
(TIME_FUZZY_DATE | MODE_INVALID_DATES |
706
(session->variables.sql_mode & MODE_NO_ZERO_DATE)),
661
(thd->variables.sql_mode &
662
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE))),
709
if (ret == DRIZZLE_TIMESTAMP_DATETIME || ret == DRIZZLE_TIMESTAMP_DATE)
665
if (ret == MYSQL_TIMESTAMP_DATETIME || ret == MYSQL_TIMESTAMP_DATE)
712
668
Do not return yet, we may still want to throw a "trailing garbage"
715
671
*error_arg= false;
716
value= TIME_to_uint64_t_datetime(&l_time);
672
value= TIME_to_ulonglong_datetime(&l_time);
767
721
enum Arg_comparator::enum_date_cmp_type
768
Arg_comparator::can_compare_as_dates(Item *in_a, Item *in_b,
769
uint64_t *const_value)
722
Arg_comparator::can_compare_as_dates(Item *a, Item *b, ulonglong *const_value)
771
724
enum enum_date_cmp_type cmp_type= CMP_DATE_DFLT;
772
725
Item *str_arg= 0, *date_arg= 0;
774
if (in_a->type() == Item::ROW_ITEM || in_b->type() == Item::ROW_ITEM)
727
if (a->type() == Item::ROW_ITEM || b->type() == Item::ROW_ITEM)
775
728
return CMP_DATE_DFLT;
777
if (in_a->is_datetime())
730
if (a->is_datetime())
779
if (in_b->is_datetime())
732
if (b->is_datetime())
780
733
cmp_type= CMP_DATE_WITH_DATE;
781
else if (in_b->result_type() == STRING_RESULT)
734
else if (b->result_type() == STRING_RESULT)
783
736
cmp_type= CMP_DATE_WITH_STR;
788
else if (in_b->is_datetime() && in_a->result_type() == STRING_RESULT)
741
else if (b->is_datetime() && a->result_type() == STRING_RESULT)
790
743
cmp_type= CMP_STR_WITH_DATE;
795
748
if (cmp_type != CMP_DATE_DFLT)
802
755
(str_arg->type() != Item::FUNC_ITEM ||
803
756
((Item_func*)str_arg)->functype() != Item_func::GUSERVAR_FUNC))
806
* OK, we are here if we've got a date field (or something which can be
807
* compared as a date field) on one side of the equation, and a constant
808
* string on the other side. In this case, we must verify that the constant
809
* string expression can indeed be evaluated as a datetime. If it cannot,
810
* we throw an error here and stop processsing. Bad data should ALWAYS
811
* produce an error, and no implicit conversion or truncation should take place.
813
* If the conversion to a DateTime temporal is successful, then we convert
814
* the Temporal instance to a uint64_t for the comparison operator, which
815
* compares date(times) using int64_t semantics.
819
* Does a uint64_t conversion really have to happen here? Fields return int64_t
820
* from val_int(), not uint64_t...
825
/* DateTime used to pick up as many string conversion possibilities as possible. */
758
THD *thd= current_thd;
761
String tmp, *str_val= 0;
762
timestamp_type t_type= (date_arg->field_type() == MYSQL_TYPE_NEWDATE ?
763
MYSQL_TIMESTAMP_DATE : MYSQL_TIMESTAMP_DATETIME);
828
765
str_val= str_arg->val_str(&tmp);
832
* If we are here, it is most likely due to the comparison item
833
* being a NULL. Although this is incorrect (SQL demands that the term IS NULL
834
* be used, not = NULL since no item can be equal to NULL).
836
* So, return gracefully.
838
return CMP_DATE_DFLT;
840
if (! temporal.from_string(str_val->c_ptr(), str_val->length()))
842
/* Chuck an error. Bad datetime input. */
843
my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR), str_val->c_ptr());
844
return CMP_DATE_DFLT; /* :( What else can I return... */
847
/* String conversion was good. Convert to an integer for comparison purposes. */
849
temporal.to_int64_t(&int_value);
850
value= (uint64_t) int_value;
766
if (str_arg->null_value)
767
return CMP_DATE_DFLT;
768
value= get_date_from_str(thd, str_val, t_type, date_arg->name, &error);
770
return CMP_DATE_DFLT;
853
772
*const_value= value;
780
Retrieves correct TIME value from the given item.
785
item_arg [in/out] item to retrieve TIME value from
786
cache_arg [in/out] pointer to place to store the cache item to
787
warn_item [in] unused
788
is_null [out] true <=> the item_arg is null
791
Retrieves the correct TIME value from given item for comparison by the
792
compare_datetime() function.
793
If item's result can be compared as longlong then its int value is used
794
and a value returned by get_time function is used otherwise.
795
If an item is a constant one then its value is cached and it isn't
796
get parsed again. An Item_cache_int object is used for for cached values.
797
It seamlessly substitutes the original item. The cache item is marked as
798
non-constant to prevent re-caching it again.
805
get_time_value(THD *thd __attribute__((__unused__)),
806
Item ***item_arg, Item **cache_arg,
807
Item *warn_item __attribute__((__unused__)),
811
Item *item= **item_arg;
814
if (item->result_as_longlong())
816
value= item->val_int();
817
*is_null= item->null_value;
821
*is_null= item->get_time(<ime);
822
value= !*is_null ? TIME_to_ulonglong_datetime(<ime) : 0;
825
Do not cache GET_USER_VAR() function as its const_item() may return true
826
for the current thread but it still may change during the execution.
828
if (item->const_item() && cache_arg && (item->type() != Item::FUNC_ITEM ||
829
((Item_func*)item)->functype() != Item_func::GUSERVAR_FUNC))
831
Item_cache_int *cache= new Item_cache_int();
832
/* Mark the cache as non-const to prevent re-caching. */
833
cache->set_used_tables(1);
834
cache->store(item, value);
836
*item_arg= cache_arg;
860
842
int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg,
861
843
Item **a1, Item **a2,
862
844
Item_result type)
864
846
enum enum_date_cmp_type cmp_type;
865
uint64_t const_value= (uint64_t)-1;
847
ulonglong const_value= (ulonglong)-1;
869
851
if ((cmp_type= can_compare_as_dates(*a, *b, &const_value)))
871
session= current_session;
872
854
owner= owner_arg;
873
855
a_type= (*a)->field_type();
874
856
b_type= (*b)->field_type();
878
if (const_value != (uint64_t)-1)
860
if (const_value != (ulonglong)-1)
880
862
Item_cache_int *cache= new Item_cache_int();
881
863
/* Mark the cache as non-const to prevent re-caching. */
953
get_datetime_value(Session *session, Item ***item_arg, Item **cache_arg,
948
get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
954
949
Item *warn_item, bool *is_null)
957
952
String buf, *str= 0;
958
953
Item *item= **item_arg;
960
if (item->result_as_int64_t())
955
if (item->result_as_longlong())
962
957
value= item->val_int();
963
958
*is_null= item->null_value;
964
959
enum_field_types f_type= item->field_type();
966
Item_date_add_interval may return DRIZZLE_TYPE_STRING as the result
961
Item_date_add_interval may return MYSQL_TYPE_STRING as the result
967
962
field type. To detect that the DATE value has been returned we
968
963
compare it with 100000000L - any DATE value should be less than it.
969
964
Don't shift cached DATETIME values up for the second time.
971
if (f_type == DRIZZLE_TYPE_DATE ||
972
(f_type != DRIZZLE_TYPE_DATETIME && value < 100000000L))
966
if (f_type == MYSQL_TYPE_NEWDATE ||
967
(f_type != MYSQL_TYPE_DATETIME && value < 100000000L))
973
968
value*= 1000000L;
2036
2035
ge_cmp.set_datetime_cmp_func(args, args + 1);
2037
2036
le_cmp.set_datetime_cmp_func(args, args + 2);
2039
else if (args[0]->real_item()->type() == FIELD_ITEM)
2038
else if (time_items_found == 3)
2040
/* Compare TIME items as integers. */
2041
cmp_type= INT_RESULT;
2043
else if (args[0]->real_item()->type() == FIELD_ITEM &&
2044
thd->lex->sql_command != SQLCOM_SHOW_CREATE)
2041
2046
Item_field *field_item= (Item_field*) (args[0]->real_item());
2042
if (field_item->field->can_be_compared_as_int64_t())
2047
if (field_item->field->can_be_compared_as_longlong())
2045
2050
The following can't be recoded with || as convert_constant_item
2046
2051
changes the argument
2048
if (convert_constant_item(session, field_item, &args[1]))
2053
if (convert_constant_item(thd, field_item, &args[1]))
2049
2054
cmp_type=INT_RESULT; // Works for all types.
2050
if (convert_constant_item(session, field_item, &args[2]))
2055
if (convert_constant_item(thd, field_item, &args[2]))
2051
2056
cmp_type=INT_RESULT; // Works for all types.
2057
int64_t Item_func_between::val_int()
2062
longlong Item_func_between::val_int()
2058
2063
{ // ANSI BETWEEN
2059
2064
assert(fixed == 1);
2060
2065
if (compare_as_dates)
2196
2201
max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1);
2200
2204
max_length= max(args[0]->max_length, args[1]->max_length);
2203
switch (hybrid_type)
2206
switch (hybrid_type) {
2205
2207
case STRING_RESULT:
2206
2208
agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV, 1);
2209
2210
case DECIMAL_RESULT:
2210
2211
case REAL_RESULT:
2213
2213
case INT_RESULT:
2217
2216
case ROW_RESULT:
2221
2220
cached_field_type= agg_field_type(args, 2);
2225
uint32_t Item_func_ifnull::decimal_precision() const
2224
uint Item_func_ifnull::decimal_precision() const
2227
int max_int_part= max(args[0]->decimal_int_part(),args[1]->decimal_int_part());
2226
int max_int_part=max(args[0]->decimal_int_part(),args[1]->decimal_int_part());
2228
2227
return min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
2232
enum_field_types Item_func_ifnull::field_type() const
2231
enum_field_types Item_func_ifnull::field_type() const
2234
2233
return cached_field_type;
2237
Field *Item_func_ifnull::tmp_table_field(Table *table)
2236
Field *Item_func_ifnull::tmp_table_field(TABLE *table)
2239
2238
return tmp_table_field_from_field_type(table, 0);
2593
2592
/* Compare every WHEN argument with it and return the first match */
2594
for (uint32_t i=0 ; i < ncases ; i+=2)
2593
for (uint i=0 ; i < ncases ; i+=2)
2596
2595
cmp_type= item_cmp_type(left_result_type, args[i]->result_type());
2597
2596
assert(cmp_type != ROW_RESULT);
2598
assert(cmp_items[(uint32_t)cmp_type]);
2599
if (!(value_added_map & (1<<(uint32_t)cmp_type)))
2597
assert(cmp_items[(uint)cmp_type]);
2598
if (!(value_added_map & (1<<(uint)cmp_type)))
2601
cmp_items[(uint32_t)cmp_type]->store_value(args[first_expr_num]);
2600
cmp_items[(uint)cmp_type]->store_value(args[first_expr_num]);
2602
2601
if ((null_value=args[first_expr_num]->null_value))
2603
2602
return else_expr_num != -1 ? args[else_expr_num] : 0;
2604
value_added_map|= 1<<(uint32_t)cmp_type;
2603
value_added_map|= 1<<(uint)cmp_type;
2606
if (!cmp_items[(uint32_t)cmp_type]->cmp(args[i]) && !args[i]->null_value)
2605
if (!cmp_items[(uint)cmp_type]->cmp(args[i]) && !args[i]->null_value)
2607
2606
return args[i + 1];
2690
bool Item_func_case::fix_fields(Session *session, Item **ref)
2689
bool Item_func_case::fix_fields(THD *thd, Item **ref)
2693
2692
buff should match stack usage from
2694
2693
Item_func_case::val_int() -> Item_func_case::find_item()
2696
unsigned char buff[MAX_FIELD_WIDTH*2+sizeof(String)*2+sizeof(String*)*2
2697
+sizeof(double)*2+sizeof(int64_t)*2];
2698
bool res= Item_func::fix_fields(session, ref);
2695
uchar buff[MAX_FIELD_WIDTH*2+sizeof(String)*2+sizeof(String*)*2+sizeof(double)*2+sizeof(longlong)*2];
2696
bool res= Item_func::fix_fields(thd, ref);
2700
2698
Call check_stack_overrun after fix_fields to be sure that stack variable
2701
2699
is not optimized away
2703
if (check_stack_overrun(session, STACK_MIN_SIZE, buff))
2701
if (check_stack_overrun(thd, STACK_MIN_SIZE, buff))
2704
2702
return true; // Fatal error flag is set!
2717
2715
void Item_func_case::agg_num_lengths(Item *arg)
2719
uint32_t len= my_decimal_length_to_precision(arg->max_length, arg->decimals,
2717
uint len= my_decimal_length_to_precision(arg->max_length, arg->decimals,
2720
2718
arg->unsigned_flag) - arg->decimals;
2721
set_if_bigger(max_length, len);
2719
set_if_bigger(max_length, len);
2722
2720
set_if_bigger(decimals, arg->decimals);
2723
unsigned_flag= unsigned_flag && arg->unsigned_flag;
2721
unsigned_flag= unsigned_flag && arg->unsigned_flag;
2727
2725
void Item_func_case::fix_length_and_dec()
2731
uint32_t found_types= 0;
2732
if (!(agg= (Item**) memory::sql_alloc(sizeof(Item*)*(ncases+1))))
2729
uint found_types= 0;
2730
if (!(agg= (Item**) sql_alloc(sizeof(Item*)*(ncases+1))))
2736
2734
Aggregate all THEN and ELSE expression types
2737
2735
and collations when string result
2740
2738
for (nagg= 0 ; nagg < ncases/2 ; nagg++)
2741
2739
agg[nagg]= args[nagg*2+1];
2743
2741
if (else_expr_num != -1)
2744
2742
agg[nagg++]= args[else_expr_num];
2746
2744
agg_result_type(&cached_result_type, agg, nagg);
2747
2745
if ((cached_result_type == STRING_RESULT) &&
2748
2746
agg_arg_charsets(collation, agg, nagg, MY_COLL_ALLOW_CONV, 1))
2751
2749
cached_field_type= agg_field_type(agg, nagg);
2753
2751
Aggregate first expression and all THEN expression types
3026
3023
0 left argument is equal to the right argument.
3027
3024
1 left argument is greater than the right argument.
3029
int cmp_int64_t(void *, in_int64_t::packed_int64_t *a,
3030
in_int64_t::packed_int64_t *b)
3026
int cmp_longlong(void *cmp_arg __attribute__((__unused__)),
3027
in_longlong::packed_longlong *a,
3028
in_longlong::packed_longlong *b)
3032
3030
if (a->unsigned_flag != b->unsigned_flag)
3035
One of the args is unsigned and is too big to fit into the
3033
One of the args is unsigned and is too big to fit into the
3036
3034
positive signed range. Report no match.
3038
if ((a->unsigned_flag && ((uint64_t) a->val) > (uint64_t) INT64_MAX) ||
3039
(b->unsigned_flag && ((uint64_t) b->val) > (uint64_t) INT64_MAX))
3036
if ((a->unsigned_flag && ((ulonglong) a->val) > (ulonglong) LONGLONG_MAX) ||
3037
(b->unsigned_flag && ((ulonglong) b->val) > (ulonglong) LONGLONG_MAX))
3040
3038
return a->unsigned_flag ? 1 : -1;
3042
Although the signedness differs both args can fit into the signed
3040
Although the signedness differs both args can fit into the signed
3043
3041
positive range. Make them signed and compare as usual.
3045
3043
return cmp_longs (a->val, b->val);
3047
3045
if (a->unsigned_flag)
3048
return cmp_ulongs ((uint64_t) a->val, (uint64_t) b->val);
3046
return cmp_ulongs ((ulonglong) a->val, (ulonglong) b->val);
3050
3048
return cmp_longs (a->val, b->val);
3053
static int cmp_double(void *, double *a, double *b)
3051
static int cmp_double(void *cmp_arg __attribute__((__unused__)), double *a,double *b)
3055
3053
return *a < *b ? -1 : *a == *b ? 0 : 1;
3058
static int cmp_row(void *, cmp_item_row *a, cmp_item_row *b)
3056
static int cmp_row(void *cmp_arg __attribute__((__unused__)), cmp_item_row *a, cmp_item_row *b)
3060
3058
return a->compare(b);
3064
static int cmp_decimal(void *, my_decimal *a, my_decimal *b)
3062
static int cmp_decimal(void *cmp_arg __attribute__((__unused__)), my_decimal *a, my_decimal *b)
3067
3065
We need call of fixing buffer pointer, because fast sort just copy
3163
3155
delete [] (cmp_item_row*) base;
3166
unsigned char *in_row::get_value(Item *item)
3158
uchar *in_row::get_value(Item *item)
3168
3160
tmp.store_value(item);
3169
3161
if (item->is_null())
3171
return (unsigned char *)&tmp;
3163
return (uchar *)&tmp;
3174
void in_row::set(uint32_t pos, Item *item)
3166
void in_row::set(uint pos, Item *item)
3176
3168
((cmp_item_row*) base)[pos].store_value_by_template(&tmp, item);
3180
in_int64_t::in_int64_t(uint32_t elements)
3181
:in_vector(elements,sizeof(packed_int64_t),(qsort2_cmp) cmp_int64_t, 0)
3172
in_longlong::in_longlong(uint elements)
3173
:in_vector(elements,sizeof(packed_longlong),(qsort2_cmp) cmp_longlong, 0)
3184
void in_int64_t::set(uint32_t pos,Item *item)
3176
void in_longlong::set(uint pos,Item *item)
3186
struct packed_int64_t *buff= &((packed_int64_t*) base)[pos];
3178
struct packed_longlong *buff= &((packed_longlong*) base)[pos];
3188
3180
buff->val= item->val_int();
3189
3181
buff->unsigned_flag= item->unsigned_flag;
3192
unsigned char *in_int64_t::get_value(Item *item)
3184
uchar *in_longlong::get_value(Item *item)
3194
3186
tmp.val= item->val_int();
3195
3187
if (item->null_value)
3197
3189
tmp.unsigned_flag= item->unsigned_flag;
3198
return (unsigned char*) &tmp;
3190
return (uchar*) &tmp;
3201
void in_datetime::set(uint32_t pos,Item *item)
3193
void in_datetime::set(uint pos,Item *item)
3203
3195
Item **tmp_item= &item;
3205
struct packed_int64_t *buff= &((packed_int64_t*) base)[pos];
3197
struct packed_longlong *buff= &((packed_longlong*) base)[pos];
3207
buff->val= get_datetime_value(session, &tmp_item, 0, warn_item, &is_null);
3199
buff->val= get_datetime_value(thd, &tmp_item, 0, warn_item, &is_null);
3208
3200
buff->unsigned_flag= 1L;
3211
unsigned char *in_datetime::get_value(Item *item)
3203
uchar *in_datetime::get_value(Item *item)
3214
3206
Item **tmp_item= lval_cache ? &lval_cache : &item;
3215
tmp.val= get_datetime_value(session, &tmp_item, &lval_cache, warn_item, &is_null);
3207
tmp.val= get_datetime_value(thd, &tmp_item, &lval_cache, warn_item, &is_null);
3216
3208
if (item->null_value)
3218
3210
tmp.unsigned_flag= 1L;
3219
return (unsigned char*) &tmp;
3211
return (uchar*) &tmp;
3222
in_double::in_double(uint32_t elements)
3214
in_double::in_double(uint elements)
3223
3215
:in_vector(elements,sizeof(double),(qsort2_cmp) cmp_double, 0)
3226
void in_double::set(uint32_t pos,Item *item)
3218
void in_double::set(uint pos,Item *item)
3228
3220
((double*) base)[pos]= item->val_real();
3231
unsigned char *in_double::get_value(Item *item)
3223
uchar *in_double::get_value(Item *item)
3233
3225
tmp= item->val_real();
3234
3226
if (item->null_value)
3236
return (unsigned char*) &tmp;
3227
return 0; /* purecov: inspected */
3228
return (uchar*) &tmp;
3240
in_decimal::in_decimal(uint32_t elements)
3232
in_decimal::in_decimal(uint elements)
3241
3233
:in_vector(elements, sizeof(my_decimal),(qsort2_cmp) cmp_decimal, 0)
3245
void in_decimal::set(uint32_t pos, Item *item)
3237
void in_decimal::set(uint pos, Item *item)
3247
3239
/* as far as 'item' is constant, we can store reference on my_decimal */
3248
3240
my_decimal *dec= ((my_decimal *)base) + pos;
3249
3241
dec->len= DECIMAL_BUFF_LENGTH;
3250
3242
dec->fix_buffer_pointer();
3251
3243
my_decimal *res= item->val_decimal(dec);
3252
/* if item->val_decimal() is evaluated to NULL then res == 0 */
3244
/* if item->val_decimal() is evaluated to NULL then res == 0 */
3253
3245
if (!item->null_value && res != dec)
3254
3246
my_decimal2decimal(res, dec);
3258
unsigned char *in_decimal::get_value(Item *item)
3250
uchar *in_decimal::get_value(Item *item)
3260
3252
my_decimal *result= item->val_decimal(&val);
3261
3253
if (item->null_value)
3263
return (unsigned char *)result;
3255
return (uchar *)result;
3267
3259
cmp_item* cmp_item::get_comparator(Item_result type,
3268
const CHARSET_INFO * const cs)
3270
3262
switch (type) {
3271
3263
case STRING_RESULT:
3272
3264
return new cmp_item_sort_string(cs);
3274
3265
case INT_RESULT:
3275
3266
return new cmp_item_int;
3277
3267
case REAL_RESULT:
3278
3268
return new cmp_item_real;
3280
3269
case ROW_RESULT:
3281
3270
return new cmp_item_row;
3283
3271
case DECIMAL_RESULT:
3284
3272
return new cmp_item_decimal;
3287
3277
return 0; // to satisfy compiler :)
3675
3665
if (type_cnt == 1 && const_itm && !nulls_in_row())
3677
3667
if (compare_as_datetime)
3679
3668
array= new in_datetime(date_arg, arg_count - 1);
3684
3672
IN must compare INT columns and constants as int values (the same
3685
3673
way as equality does).
3686
So we must check here if the column on the left and all the constant
3687
values on the right can be compared as integers and adjust the
3674
So we must check here if the column on the left and all the constant
3675
values on the right can be compared as integers and adjust the
3688
3676
comparison type accordingly.
3690
3678
if (args[0]->real_item()->type() == FIELD_ITEM &&
3679
thd->lex->sql_command != SQLCOM_SHOW_CREATE &&
3691
3680
cmp_type != INT_RESULT)
3693
3682
Item_field *field_item= (Item_field*) (args[0]->real_item());
3694
if (field_item->field->can_be_compared_as_int64_t())
3683
if (field_item->field->can_be_compared_as_longlong())
3696
3685
bool all_converted= true;
3697
3686
for (arg=args+1, arg_end=args+arg_count; arg != arg_end ; arg++)
3699
if (!convert_constant_item (session, field_item, &arg[0]))
3688
if (!convert_constant_item (thd, field_item, &arg[0]))
3700
3689
all_converted= false;
3702
3691
if (all_converted)
3703
3692
cmp_type= INT_RESULT;
3707
3695
switch (cmp_type) {
3708
3696
case STRING_RESULT:
3709
array=new in_string(arg_count-1,(qsort2_cmp) srtcmp_in,
3697
array=new in_string(arg_count-1,(qsort2_cmp) srtcmp_in,
3710
3698
cmp_collation.collation);
3713
3700
case INT_RESULT:
3714
array= new in_int64_t(arg_count-1);
3701
array= new in_longlong(arg_count-1);
3717
3703
case REAL_RESULT:
3718
3704
array= new in_double(arg_count-1);
3721
3706
case ROW_RESULT:
3723
3708
The row comparator was created at the beginning but only DATETIME
3813
3797
Value of the function
3816
int64_t Item_func_in::val_int()
3800
longlong Item_func_in::val_int()
3818
3802
cmp_item *in_item;
3819
3803
assert(fixed == 1);
3820
uint32_t value_added_map= 0;
3804
uint value_added_map= 0;
3823
3807
int tmp=array->find(args[0]);
3824
3808
null_value=args[0]->null_value || (!tmp && have_null);
3825
return (int64_t) (!null_value && tmp != negated);
3809
return (longlong) (!null_value && tmp != negated);
3828
for (uint32_t i= 1 ; i < arg_count ; i++)
3812
for (uint i= 1 ; i < arg_count ; i++)
3830
3814
Item_result cmp_type= item_cmp_type(left_result_type, args[i]->result_type());
3831
in_item= cmp_items[(uint32_t)cmp_type];
3815
in_item= cmp_items[(uint)cmp_type];
3832
3816
assert(in_item);
3833
if (!(value_added_map & (1 << (uint32_t)cmp_type)))
3817
if (!(value_added_map & (1 << (uint)cmp_type)))
3835
3819
in_item->store_value(args[0]);
3836
3820
if ((null_value=args[0]->null_value))
3839
value_added_map|= 1 << (uint32_t)cmp_type;
3823
value_added_map|= 1 << (uint)cmp_type;
3841
3825
if (!in_item->cmp(args[i]) && !args[i]->null_value)
3842
return (int64_t) (!negated);
3826
return (longlong) (!negated);
3843
3827
have_null|= args[i]->null_value;
3846
3830
null_value= have_null;
3847
return (int64_t) (!null_value && negated);
3851
Item_cond::Item_cond(Session *session, Item_cond *item)
3852
:Item_bool_func(session, item),
3831
return (longlong) (!null_value && negated);
3835
longlong Item_func_bit_or::val_int()
3838
ulonglong arg1= (ulonglong) args[0]->val_int();
3839
if (args[0]->null_value)
3841
null_value=1; /* purecov: inspected */
3842
return 0; /* purecov: inspected */
3844
ulonglong arg2= (ulonglong) args[1]->val_int();
3845
if (args[1]->null_value)
3851
return (longlong) (arg1 | arg2);
3855
longlong Item_func_bit_and::val_int()
3858
ulonglong arg1= (ulonglong) args[0]->val_int();
3859
if (args[0]->null_value)
3861
null_value=1; /* purecov: inspected */
3862
return 0; /* purecov: inspected */
3864
ulonglong arg2= (ulonglong) args[1]->val_int();
3865
if (args[1]->null_value)
3867
null_value=1; /* purecov: inspected */
3868
return 0; /* purecov: inspected */
3871
return (longlong) (arg1 & arg2);
3874
Item_cond::Item_cond(THD *thd, Item_cond *item)
3875
:Item_bool_func(thd, item),
3853
3876
abort_on_null(item->abort_on_null),
3854
3877
and_tables_cache(item->and_tables_cache)
3862
void Item_cond::copy_andor_arguments(Session *session, Item_cond *item)
3885
void Item_cond::copy_andor_arguments(THD *thd, Item_cond *item)
3864
3887
List_iterator_fast<Item> li(item->list);
3865
3888
while (Item *it= li++)
3866
list.push_back(it->copy_andor_structure(session));
3889
list.push_back(it->copy_andor_structure(thd));
3871
Item_cond::fix_fields(Session *session, Item **)
3894
Item_cond::fix_fields(THD *thd, Item **ref __attribute__((__unused__)))
3873
3896
assert(fixed == 0);
3874
3897
List_iterator<Item> li(list);
3876
void *orig_session_marker= session->session_marker;
3877
unsigned char buff[sizeof(char*)]; // Max local vars in function
3899
void *orig_thd_marker= thd->thd_marker;
3900
uchar buff[sizeof(char*)]; // Max local vars in function
3878
3901
not_null_tables_cache= used_tables_cache= 0;
3879
3902
const_item_cache= 1;
3881
3904
if (functype() == COND_OR_FUNC)
3882
session->session_marker= 0;
3884
3907
and_table_cache is the value that Item_cond_or() returns for
3885
3908
not_null_tables()
3887
3910
and_tables_cache= ~(table_map) 0;
3889
if (check_stack_overrun(session, STACK_MIN_SIZE, buff))
3912
if (check_stack_overrun(thd, STACK_MIN_SIZE, buff))
3890
3913
return true; // Fatal error flag is set!
3892
3915
The following optimization reduces the depth of an AND-OR tree.
4050
4073
@param arg_t parameter to be passed to the transformer
4053
Item returned as the result of transformation of the root node
4076
Item returned as the result of transformation of the root node
4056
Item *Item_cond::compile(Item_analyzer analyzer, unsigned char **arg_p,
4057
Item_transformer transformer, unsigned char *arg_t)
4079
Item *Item_cond::compile(Item_analyzer analyzer, uchar **arg_p,
4080
Item_transformer transformer, uchar *arg_t)
4059
4082
if (!(this->*analyzer)(arg_p))
4062
4085
List_iterator<Item> li(list);
4064
4087
while ((item= li++))
4067
4090
The same parameter value of arg_p must be passed
4068
4091
to analyze any argument of the condition formula.
4070
unsigned char *arg_v= *arg_p;
4093
uchar *arg_v= *arg_p;
4071
4094
Item *new_item= item->compile(analyzer, &arg_v, transformer, arg_t);
4072
4095
if (new_item && new_item != item)
4073
4096
li.replace(new_item);
4411
4432
my_error(ER_WRONG_ARGUMENTS,MYF(0),"ESCAPE");
4415
4436
if (escape_item->const_item())
4418
4438
/* If we are on execution stage */
4419
4439
String *escape_str= escape_item->val_str(&tmp_value1);
4420
4440
if (escape_str)
4422
escape= (char *)memory::sql_alloc(escape_str->length());
4423
strcpy(escape, escape_str->ptr());
4442
if (escape_used_in_parsing && (
4443
(((thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) &&
4444
escape_str->numchars() != 1) ||
4445
escape_str->numchars() > 1)))
4447
my_error(ER_WRONG_ARGUMENTS,MYF(0),"ESCAPE");
4451
if (use_mb(cmp.cmp_collation.collation))
4453
CHARSET_INFO *cs= escape_str->charset();
4455
int rc= cs->cset->mb_wc(cs, &wc,
4456
(const uchar*) escape_str->ptr(),
4457
(const uchar*) escape_str->ptr() +
4458
escape_str->length());
4459
escape= (int) (rc > 0 ? wc : '\\');
4464
In the case of 8bit character set, we pass native
4465
code instead of Unicode code as "escape" argument.
4466
Convert to "cs" if charset of escape differs.
4468
CHARSET_INFO *cs= cmp.cmp_collation.collation;
4470
if (escape_str->needs_conversion(escape_str->length(),
4471
escape_str->charset(), cs, &unused))
4475
uint32 cnvlen= copy_and_convert(&ch, 1, cs, escape_str->ptr(),
4476
escape_str->length(),
4477
escape_str->charset(), &errors);
4478
escape= cnvlen ? ch : '\\';
4481
escape= *(escape_str->ptr());
4427
escape= (char *)memory::sql_alloc(1);
4428
strcpy(escape, "\\");
4432
4488
We could also do boyer-more for non-const items, but as we would have to
4433
4489
recompute the tables for each row it's not worth it.
4435
if (args[1]->const_item() && !use_strnxfrm(collation.collation))
4491
if (args[1]->const_item() && !use_strnxfrm(collation.collation) &&
4492
!(specialflag & SPECIAL_NO_NEW_FUNC))
4437
4494
String* res2 = args[1]->val_str(&tmp_value2);
4439
4496
return false; // Null argument
4441
4498
const size_t len = res2->length();
4442
4499
const char* first = res2->ptr();
4443
4500
const char* last = first + len - 1;
4501
4553
int *const splm1 = suff + plm1;
4502
const CHARSET_INFO * const cs= cmp.cmp_collation.collation;
4554
CHARSET_INFO *cs= cmp.cmp_collation.collation;
4504
4556
*splm1 = pattern_len;
4506
4558
if (!cs->sort_order)
4508
for (int i = pattern_len - 2; i >= 0; i--)
4561
for (i = pattern_len - 2; i >= 0; i--)
4510
4563
int tmp = *(splm1 + i - f);
4511
4564
if (g < i && tmp < i - g)
4518
while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
4569
g = i; // g = min(i, g)
4571
while (g >= 0 && pattern[g] == pattern[g + plm1 - f])
4526
for (int i = pattern_len - 2; 0 <= i; --i)
4580
for (i = pattern_len - 2; 0 <= i; --i)
4528
4582
int tmp = *(splm1 + i - f);
4529
4583
if (g < i && tmp < i - g)
4537
likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
4588
g = i; // g = min(i, g)
4591
likeconv(cs, pattern[g]) == likeconv(cs, pattern[g + plm1 - f]))
4673
4727
register int i = plm1;
4674
4728
while (i >= 0 && likeconv(cs,pattern[i]) == likeconv(cs,text[i + j]))
4677
if (i == plm1 - shift)
4731
if (i == plm1 - shift)
4684
register const int v= plm1 - i;
4686
bcShift= bmBc[(uint32_t) likeconv(cs, text[i + j])] - plm1 + i;
4687
shift= (turboShift > bcShift) ? turboShift : bcShift;
4688
shift= max(shift, bmGs[i]);
4737
register const int v = plm1 - i;
4739
bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
4740
shift = max(turboShift, bcShift);
4741
shift = max(shift, bmGs[i]);
4690
4742
if (shift == bmGs[i])
4691
u= (pattern_len - shift < v) ? pattern_len - shift : v;
4743
u = min(pattern_len - shift, v);
4694
if (turboShift < bcShift)
4695
shift= max(shift, u + 1);
4746
if (turboShift < bcShift)
4747
shift = max(shift, u + 1);
4791
4842
a IS NOT NULL -> a IS NULL.
4793
Item *Item_func_isnotnull::neg_transformer(Session *)
4844
Item *Item_func_isnotnull::neg_transformer(THD *thd __attribute__((__unused__)))
4795
4846
Item *item= new Item_func_isnull(args[0]);
4800
Item *Item_cond_and::neg_transformer(Session *session) /* NOT(a AND b AND ...) -> */
4851
Item *Item_cond_and::neg_transformer(THD *thd) /* NOT(a AND b AND ...) -> */
4801
4852
/* NOT a OR NOT b OR ... */
4803
neg_arguments(session);
4804
4855
Item *item= new Item_cond_or(list);
4809
Item *Item_cond_or::neg_transformer(Session *session) /* NOT(a OR b OR ...) -> */
4860
Item *Item_cond_or::neg_transformer(THD *thd) /* NOT(a OR b OR ...) -> */
4810
4861
/* NOT a AND NOT b AND ... */
4812
neg_arguments(session);
4813
4864
Item *item= new Item_cond_and(list);
4818
Item *Item_func_nop_all::neg_transformer(Session *)
4869
Item *Item_func_nop_all::neg_transformer(THD *thd __attribute__((__unused__)))
4820
4871
/* "NOT (e $cmp$ ANY (SELECT ...)) -> e $rev_cmp$" ALL (SELECT ...) */
4821
4872
Item_func_not_all *new_item= new Item_func_not_all(args[0]);