1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
4
* Copyright (C) 2008 Sun Microsystems, Inc.
6
6
* This program is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
21
21
#define DRIZZLED_ITEM_H
23
23
#include <drizzled/dtcollation.h>
24
#include <drizzled/drizzle_time.h>
25
#include <drizzled/decimal.h>
24
#include <drizzled/type/time.h>
25
#include <drizzled/type/decimal.h>
26
26
#include <drizzled/sql_list.h>
27
27
#include "drizzled/memory/sql_alloc.h"
28
28
#include <drizzled/table.h>
148
150
bool maybe_null; /**< True if item may be null */
149
151
bool null_value; /**< True if item is null */
150
152
bool unsigned_flag;
154
bool is_unsigned() const
156
return unsigned_flag;
159
virtual bool negative() const
151
164
bool with_sum_func;
152
165
bool is_autogenerated_name; /**< indicates whether name of this Item was autogenerated or set by user */
378
* Return pointer on my_decimal (it can be other then passed via argument)
393
* Return pointer on type::Decimal (it can be other then passed via argument)
379
394
* if value is not NULL (null_value flag will be reset to false).
380
395
* In case of NULL value it return 0 pointer and set null_value flag
383
virtual my_decimal *val_decimal(my_decimal *decimal_buffer)= 0;
398
virtual type::Decimal *val_decimal(type::Decimal *decimal_buffer)= 0;
385
401
* Return boolean value of item.
390
406
* true value is true (not equal to 0)
392
408
virtual bool val_bool();
393
410
/* Helper functions, see item_sum.cc */
394
411
String *val_string_from_real(String *str);
395
412
String *val_string_from_int(String *str);
396
413
String *val_string_from_decimal(String *str);
397
my_decimal *val_decimal_from_real(my_decimal *decimal_value);
398
my_decimal *val_decimal_from_int(my_decimal *decimal_value);
399
my_decimal *val_decimal_from_string(my_decimal *decimal_value);
400
my_decimal *val_decimal_from_date(my_decimal *decimal_value);
401
my_decimal *val_decimal_from_time(my_decimal *decimal_value);
414
type::Decimal *val_decimal_from_real(type::Decimal *decimal_value);
415
type::Decimal *val_decimal_from_int(type::Decimal *decimal_value);
416
type::Decimal *val_decimal_from_string(type::Decimal *decimal_value);
417
type::Decimal *val_decimal_from_date(type::Decimal *decimal_value);
418
type::Decimal *val_decimal_from_time(type::Decimal *decimal_value);
402
419
int64_t val_int_from_decimal();
403
420
double val_real_from_decimal();
527
544
For more information about view definition query, INFORMATION_SCHEMA
528
545
query and why they should be generated from the Item-tree, @see
529
mysql_register_view().
531
548
virtual void print(String *str, enum_query_type query_type);
560
577
bool skip_registered);
563
Get the value of the function as a DRIZZLE_TIME structure.
580
Get the value of the function as a type::Time structure.
564
581
As a extra convenience the time structure is reset on error!
566
virtual bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
583
virtual bool get_date(type::Time *ltime,uint32_t fuzzydate);
568
585
Get time of first argument.
570
587
As a extra convenience the time structure is reset on error!
572
virtual bool get_time(DRIZZLE_TIME *ltime);
573
virtual bool get_date_result(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
589
virtual bool get_time(type::Time *ltime);
590
virtual bool get_date_result(type::Time *ltime,uint32_t fuzzydate);
576
593
The method allows to determine nullness of a complex expression
761
778
* false otherwise
763
780
bool eq_by_collation(Item *item, bool binary_cmp, const CHARSET_INFO * const cs);
782
inline uint32_t char_to_byte_length_safe(uint32_t char_length_arg, uint32_t mbmaxlen_arg)
784
uint64_t tmp= ((uint64_t) char_length_arg) * mbmaxlen_arg;
785
return (tmp > UINT32_MAX) ? (uint32_t) UINT32_MAX : (uint32_t) tmp;
788
uint32_t max_char_length() const
790
return max_length / collation.collation->mbmaxlen;
793
void fix_length_and_charset(uint32_t max_char_length_arg, CHARSET_INFO *cs)
795
max_length= char_to_byte_length_safe(max_char_length_arg, cs->mbmaxlen);
796
collation.collation= cs;
799
void fix_char_length(uint32_t max_char_length_arg)
801
max_length= char_to_byte_length_safe(max_char_length_arg,
802
collation.collation->mbmaxlen);
805
void fix_char_length_uint64_t(uint64_t max_char_length_arg)
807
uint64_t max_result_length= max_char_length_arg *
808
collation.collation->mbmaxlen;
810
if (max_result_length >= MAX_BLOB_WIDTH)
812
max_length= MAX_BLOB_WIDTH;
817
max_length= max_result_length;
821
void fix_length_and_charset_datetime(uint32_t max_char_length_arg)
823
collation.set(&my_charset_bin);
824
fix_char_length(max_char_length_arg);
829
const std::string &type(Item::Type type);
830
} /* namespace display */
832
std::ostream& operator<<(std::ostream& output, const Item &item);
766
834
} /* namespace drizzled */
768
836
/** @TODO Why is this in the middle? */