~thomir-deactivatedaccount/drizzle/drizzle-fix-bug653747

« back to all changes in this revision

Viewing changes to server/item.h

Merged in Jay's tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
300
300
  void *error_processor_data;
301
301
 
302
302
  /*
303
 
    When TRUE items are resolved in this context both against the
304
 
    SELECT list and this->table_list. If FALSE, items are resolved
 
303
    When true items are resolved in this context both against the
 
304
    SELECT list and this->table_list. If false, items are resolved
305
305
    only against this->table_list.
306
306
  */
307
307
  bool resolve_in_select_list;
320
320
 
321
321
  void init()
322
322
  {
323
 
    resolve_in_select_list= FALSE;
 
323
    resolve_in_select_list= false;
324
324
    error_processor= &dummy_error_processor;
325
325
    first_name_resolution_table= NULL;
326
326
    last_name_resolution_table= NULL;
329
329
  void resolve_in_table_list_only(TABLE_LIST *tables)
330
330
  {
331
331
    table_list= first_name_resolution_table= tables;
332
 
    resolve_in_select_list= FALSE;
 
332
    resolve_in_select_list= false;
333
333
  }
334
334
 
335
335
  void process_error(THD *thd)
420
420
                    OUT: Parameter to be passed to the transformer
421
421
 
422
422
    RETURN 
423
 
      TRUE   Invoke the transformer
424
 
      FALSE  Don't do it
 
423
      true   Invoke the transformer
 
424
      false  Don't do it
425
425
 
426
426
*/
427
427
typedef bool (Item::*Item_analyzer) (uchar **argp);
556
556
 
557
557
    SYNOPSIS
558
558
      val_int_endpoint()
559
 
        left_endp  FALSE  <=> The interval is "x < const" or "x <= const"
560
 
                   TRUE   <=> The interval is "x > const" or "x >= const"
 
559
        left_endp  false  <=> The interval is "x < const" or "x <= const"
 
560
                   true   <=> The interval is "x > const" or "x >= const"
561
561
 
562
 
        incl_endp  IN   TRUE <=> the comparison is '<' or '>'
563
 
                        FALSE <=> the comparison is '<=' or '>='
 
562
        incl_endp  IN   true <=> the comparison is '<' or '>'
 
563
                        false <=> the comparison is '<=' or '>='
564
564
                   OUT  The same but for the "F(x) $CMP$ F(const)" comparison
565
565
 
566
566
    DESCRIPTION
582
582
    RETURN
583
583
      The output range bound, which equal to the value of val_int()
584
584
        - If the value of the function is NULL then the bound is the
585
 
          smallest possible value of LONGLONG_MIN
 
585
          smallest possible value of INT64_MIN
586
586
  */
587
587
  virtual int64_t val_int_endpoint(bool left_endp __attribute__((__unused__)),
588
588
                                    bool *incl_endp __attribute__((__unused__)))
597
597
      val_real()
598
598
 
599
599
    RETURN
600
 
      In case of NULL value return 0.0 and set null_value flag to TRUE.
601
 
      If value is not null null_value flag will be reset to FALSE.
 
600
      In case of NULL value return 0.0 and set null_value flag to true.
 
601
      If value is not null null_value flag will be reset to false.
602
602
  */
603
603
  virtual double val_real()=0;
604
604
  /*
608
608
      val_int()
609
609
 
610
610
    RETURN
611
 
      In case of NULL value return 0 and set null_value flag to TRUE.
612
 
      If value is not null null_value flag will be reset to FALSE.
 
611
      In case of NULL value return 0 and set null_value flag to true.
 
612
      If value is not null null_value flag will be reset to false.
613
613
  */
614
614
  virtual int64_t val_int()=0;
615
615
  /*
648
648
 
649
649
    RETURN
650
650
      In case of NULL value return 0 (NULL pointer) and set null_value flag
651
 
      to TRUE.
652
 
      If value is not null null_value flag will be reset to FALSE.
 
651
      to true.
 
652
      If value is not null null_value flag will be reset to false.
653
653
  */
654
654
  virtual String *val_str(String *str)=0;
655
655
  /*
666
666
 
667
667
    RETURN
668
668
      Return pointer on my_decimal (it can be other then passed via argument)
669
 
        if value is not NULL (null_value flag will be reset to FALSE).
 
669
        if value is not NULL (null_value flag will be reset to false).
670
670
      In case of NULL value it return 0 pointer and set null_value flag
671
 
        to TRUE.
 
671
        to true.
672
672
  */
673
673
  virtual my_decimal *val_decimal(my_decimal *decimal_buffer)= 0;
674
674
  /*
675
675
    Return boolean value of item.
676
676
 
677
677
    RETURN
678
 
      FALSE value is false or NULL
679
 
      TRUE value is true (not equal to 0)
 
678
      false value is false or NULL
 
679
      true value is true (not equal to 0)
680
680
  */
681
681
  virtual bool val_bool();
682
682
  virtual String *val_nodeset(String*) { return 0; }
799
799
 
800
800
  /*
801
801
    Inform the item that there will be no distinction between its result
802
 
    being FALSE or NULL.
 
802
    being false or NULL.
803
803
 
804
804
    NOTE
805
805
      This function will be called for eg. Items that are top-level AND-parts
936
936
  }
937
937
 
938
938
  /*
939
 
    result_as_int64_t() must return TRUE for Items representing DATE/TIME
 
939
    result_as_int64_t() must return true for Items representing DATE/TIME
940
940
    functions and DATE/TIME table fields.
941
941
    Those Items have result_type()==STRING_RESULT (and not INT_RESULT), but
942
942
    their values should be compared as integers (because the integer
943
943
    representation is more precise than the string one).
944
944
  */
945
 
  virtual bool result_as_int64_t() { return FALSE; }
 
945
  virtual bool result_as_int64_t() { return false; }
946
946
  bool is_datetime();
947
947
 
948
948
  /*
1043
1043
  bool remove_dependence_processor(uchar * arg);
1044
1044
  virtual void print(String *str, enum_query_type query_type);
1045
1045
  virtual bool change_context_processor(uchar *cntx)
1046
 
    { context= (Name_resolution_context *)cntx; return FALSE; }
 
1046
    { context= (Name_resolution_context *)cntx; return false; }
1047
1047
  friend bool insert_fields(THD *thd, Name_resolution_context *context,
1048
1048
                            const char *db_name,
1049
1049
                            const char *table_name, List_iterator<Item> *it,
1084
1084
  Item_equal *item_equal;
1085
1085
  bool no_const_subst;
1086
1086
  /*
1087
 
    if any_privileges set to TRUE then here real effective privileges will
 
1087
    if any_privileges set to true then here real effective privileges will
1088
1088
    be stored
1089
1089
  */
1090
1090
  uint have_privileges;
1183
1183
public:
1184
1184
  Item_null(char *name_par=0)
1185
1185
  {
1186
 
    maybe_null= null_value= TRUE;
 
1186
    maybe_null= null_value= true;
1187
1187
    max_length= 0;
1188
1188
    name= name_par ? name_par : (char*) "NULL";
1189
1189
    fixed= 1;
1351
1351
    words, avoid pointing at one item from two different nodes of the tree.
1352
1352
    Return a new basic constant item if parameter value is a basic
1353
1353
    constant, assert otherwise. This method is called only if
1354
 
    basic_const_item returned TRUE.
 
1354
    basic_const_item returned true.
1355
1355
  */
1356
1356
  Item *safe_charset_converter(CHARSET_INFO *tocs);
1357
1357
  Item *clone_item();
1358
1358
  /*
1359
1359
    Implement by-value equality evaluation if parameter value
1360
1360
    is set and is a basic constant (integer, real or string).
1361
 
    Otherwise return FALSE.
 
1361
    Otherwise return false.
1362
1362
  */
1363
1363
  bool eq(const Item *item, bool binary_cmp) const;
1364
1364
  /** Item is a argument to a limit clause. */
1485
1485
  int64_t val_int()
1486
1486
  {
1487
1487
    assert(fixed == 1);
1488
 
    if (value <= (double) LONGLONG_MIN)
 
1488
    if (value <= (double) INT64_MIN)
1489
1489
    {
1490
 
       return LONGLONG_MIN;
 
1490
       return INT64_MIN;
1491
1491
    }
1492
 
    else if (value >= (double) (uint64_t) LONGLONG_MAX)
 
1492
    else if (value >= (double) (uint64_t) INT64_MAX)
1493
1493
    {
1494
 
      return LONGLONG_MAX;
 
1494
      return INT64_MAX;
1495
1495
    }
1496
1496
    return (int64_t) rint(value);
1497
1497
  }
1531
1531
  Item_string(const char *str,uint length,
1532
1532
              CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE,
1533
1533
              uint repertoire= MY_REPERTOIRE_UNICODE30)
1534
 
    : m_cs_specified(FALSE)
 
1534
    : m_cs_specified(false)
1535
1535
  {
1536
1536
    str_value.set_or_copy_aligned(str, length, cs);
1537
1537
    collation.set(cs, dv, repertoire);
1550
1550
  }
1551
1551
  /* Just create an item and do not fill string representation */
1552
1552
  Item_string(CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE)
1553
 
    : m_cs_specified(FALSE)
 
1553
    : m_cs_specified(false)
1554
1554
  {
1555
1555
    collation.set(cs, dv);
1556
1556
    max_length= 0;
1561
1561
  Item_string(const char *name_par, const char *str, uint length,
1562
1562
              CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE,
1563
1563
              uint repertoire= MY_REPERTOIRE_UNICODE30)
1564
 
    : m_cs_specified(FALSE)
 
1564
    : m_cs_specified(false)
1565
1565
  {
1566
1566
    str_value.set_or_copy_aligned(str, length, cs);
1567
1567
    collation.set(cs, dv, repertoire);
1614
1614
  virtual void print(String *str, enum_query_type query_type);
1615
1615
 
1616
1616
  /**
1617
 
    Return TRUE if character-set-introducer was explicitly specified in the
 
1617
    Return true if character-set-introducer was explicitly specified in the
1618
1618
    original query for this item (text literal).
1619
1619
 
1620
1620
    This operation is to be called from Item_string::print(). The idea is
1628
1628
    one day when we start using original query as a view definition.
1629
1629
 
1630
1630
    @return This operation returns the value of m_cs_specified attribute.
1631
 
      @retval TRUE if character set introducer was explicitly specified in
 
1631
      @retval true if character set introducer was explicitly specified in
1632
1632
      the original query.
1633
 
      @retval FALSE otherwise.
 
1633
      @retval false otherwise.
1634
1634
  */
1635
1635
  inline bool is_cs_specified() const
1636
1636
  {
1815
1815
  */
1816
1816
  Item_ref(Name_resolution_context *context_arg, Item **item,
1817
1817
           const char *table_name_arg, const char *field_name_arg,
1818
 
           bool alias_name_used_arg= FALSE);
 
1818
           bool alias_name_used_arg= false);
1819
1819
 
1820
1820
  /* Constructor need to process subselect with temporary tables (see Item) */
1821
1821
  Item_ref(THD *thd, Item_ref *item)
1922
1922
  Item_direct_ref(Name_resolution_context *context_arg, Item **item,
1923
1923
                  const char *table_name_arg,
1924
1924
                  const char *field_name_arg,
1925
 
                  bool alias_name_used_arg= FALSE)
 
1925
                  bool alias_name_used_arg= false)
1926
1926
    :Item_ref(context_arg, item, table_name_arg,
1927
1927
              field_name_arg, alias_name_used_arg)
1928
1928
  {}
1984
1984
  /* The aggregate function under which this outer ref is used, if any. */
1985
1985
  Item_sum *in_sum_func;
1986
1986
  /*
1987
 
    TRUE <=> that the outer_ref is already present in the select list
 
1987
    true <=> that the outer_ref is already present in the select list
1988
1988
    of the outer select.
1989
1989
  */
1990
1990
  bool found_in_select_list;
2026
2026
/*
2027
2027
  An object of this class:
2028
2028
   - Converts val_XXX() calls to ref->val_XXX_result() calls, like Item_ref.
2029
 
   - Sets owner->was_null=TRUE if it has returned a NULL value from any
 
2029
   - Sets owner->was_null=true if it has returned a NULL value from any
2030
2030
     val_XXX() function. This allows to inject an Item_ref_null_helper
2031
2031
     object into subquery and then check if the subquery has produced a row
2032
2032
     with NULL value.
2324
2324
  virtual void print(String *str, enum_query_type query_type);
2325
2325
  bool eq_def(Field *field) 
2326
2326
  { 
2327
 
    return cached_field ? cached_field->eq_def (field) : FALSE;
 
2327
    return cached_field ? cached_field->eq_def (field) : false;
2328
2328
  }
2329
2329
  bool eq(const Item *item,
2330
2330
          bool binary_cmp __attribute__((__unused__))) const
2350
2350
  String* val_str(String *str);
2351
2351
  my_decimal *val_decimal(my_decimal *);
2352
2352
  enum Item_result result_type() const { return INT_RESULT; }
2353
 
  bool result_as_int64_t() { return TRUE; }
 
2353
  bool result_as_int64_t() { return true; }
2354
2354
};
2355
2355
 
2356
2356