27
#ifndef DRIZZLED_FIELD_H
28
#define DRIZZLED_FIELD_H
30
#include "drizzled/sql_error.h"
31
#include "drizzled/type/decimal.h"
32
#include "drizzled/key_map.h"
33
#include "drizzled/sql_list.h"
34
#include "drizzled/structs.h"
35
#include "drizzled/charset_info.h"
36
#include "drizzled/item_result.h"
37
#include "drizzled/charset_info.h"
29
#include <drizzled/common_fwd.h>
30
#include <drizzled/sql_error.h>
31
#include <drizzled/type/decimal.h>
32
#include <drizzled/key_map.h>
33
#include <drizzled/sql_list.h>
34
#include <drizzled/structs.h>
35
#include <drizzled/charset.h>
36
#include <drizzled/item_result.h>
37
#include <drizzled/charset.h>
42
#include "drizzled/visibility.h"
42
#include <drizzled/visibility.h>
47
46
#define DATETIME_DEC 6
48
47
#define DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE FLOATING_POINT_BUFFER
51
#define ASSERT_COLUMN_MARKED_FOR_READ assert(!getTable() || (getTable()->read_set == NULL || isReadSet()))
52
#define ASSERT_COLUMN_MARKED_FOR_WRITE assert(!getTable() || (getTable()->write_set == NULL || isWriteSet()))
54
#define ASSERT_COLUMN_MARKED_FOR_READ assert(getTable())
55
#define ASSERT_COLUMN_MARKED_FOR_WRITE assert(getTable())
58
typedef struct st_typelib TYPELIB;
49
#define ASSERT_COLUMN_MARKED_FOR_READ assert(getTable() && (not getTable()->read_set || isReadSet()))
50
#define ASSERT_COLUMN_MARKED_FOR_WRITE assert(getTable() && (not getTable()->write_set || isWriteSet()))
60
52
const uint32_t max_field_size= (uint32_t) 4294967295U;
68
54
int field_conv(Field *to,Field *from);
202
188
/* Store functions returns 1 on overflow and -1 on fatal error */
203
189
virtual int store(const char *to,
205
const CHARSET_INFO * const cs)=0;
191
const charset_info_st * const cs)=0;
206
192
virtual int store(double nr)=0;
207
193
virtual int store(int64_t nr, bool unsigned_val)=0;
208
194
virtual int store_decimal(const type::Decimal *d)=0;
209
195
int store_and_check(enum_check_fields check_level,
212
const CHARSET_INFO * const cs);
198
const charset_info_st * const cs);
214
200
This is called when storing a date in a string.
217
203
Needs to be changed if/when we want to support different time formats.
219
205
virtual int store_time(type::Time <ime, type::timestamp_t t_type);
220
virtual double val_real()=0;
221
virtual int64_t val_int()=0;
222
virtual type::Decimal *val_decimal(type::Decimal *);
223
String *val_str_internal(String *str)
206
virtual double val_real() const=0;
207
virtual int64_t val_int() const =0;
208
virtual type::Decimal *val_decimal(type::Decimal *) const;
209
String *val_str_internal(String *str) const
225
211
return val_str(str, str);
237
223
an unnecessary free (and later, may be an alloc).
238
224
This trickery is used to decrease a number of malloc calls.
240
virtual String *val_str(String*, String *)=0;
226
virtual String *val_str(String*, String *) const =0;
243
229
str_needs_quotes() returns true if the value returned by val_str() needs
364
350
virtual uint32_t size_of() const =0;
366
bool is_null(ptrdiff_t row_offset= 0);
367
bool is_real_null(ptrdiff_t row_offset= 0);
368
bool is_null_in_record(const unsigned char *record);
369
bool is_null_in_record_with_offset(ptrdiff_t offset);
352
bool is_null(ptrdiff_t row_offset= 0) const;
353
bool is_real_null(ptrdiff_t row_offset= 0) const;
354
bool is_null_in_record(const unsigned char *record) const;
355
bool is_null_in_record_with_offset(ptrdiff_t offset) const;
370
356
void set_null(ptrdiff_t row_offset= 0);
371
357
void set_notnull(ptrdiff_t row_offset= 0);
372
bool maybe_null(void);
373
bool real_maybe_null(void);
358
bool maybe_null(void) const;
359
bool real_maybe_null(void) const;
375
361
virtual void make_field(SendField *);
376
362
virtual void sort_string(unsigned char *buff,uint32_t length)=0;
410
396
null_ptr= ADD_TO_PTR(null_ptr,ptr_diff,unsigned char*);
412
virtual void get_image(unsigned char *buff, uint32_t length, const CHARSET_INFO * const)
398
virtual void get_image(unsigned char *buff, uint32_t length, const charset_info_st * const)
414
400
memcpy(buff,ptr,length);
416
virtual void get_image(std::basic_string<unsigned char> &buff, uint32_t length, const CHARSET_INFO * const)
402
virtual void get_image(std::basic_string<unsigned char> &buff, uint32_t length, const charset_info_st * const)
418
404
buff.append(ptr,length);
420
virtual void set_image(const unsigned char *buff,uint32_t length, const CHARSET_INFO * const)
406
virtual void set_image(const unsigned char *buff,uint32_t length, const charset_info_st * const)
422
408
memcpy(ptr,buff,length);
598
583
void copy_from_tmp(int offset);
599
584
uint32_t fill_cache_field(CacheField *copy);
600
virtual bool get_date(type::Time <ime,uint32_t fuzzydate);
601
virtual bool get_time(type::Time <ime);
602
virtual const CHARSET_INFO *charset(void) const { return &my_charset_bin; }
603
virtual const CHARSET_INFO *sort_charset(void) const { return charset(); }
585
virtual bool get_date(type::Time <ime,uint32_t fuzzydate) const;
586
virtual bool get_time(type::Time <ime) const;
587
virtual const charset_info_st *charset(void) const { return &my_charset_bin; }
588
virtual const charset_info_st *sort_charset(void) const { return charset(); }
604
589
virtual bool has_charset(void) const { return false; }
605
virtual void set_charset(const CHARSET_INFO * const)
590
virtual void set_charset(const charset_info_st * const)
607
592
virtual enum Derivation derivation(void) const
742
virtual void hash(uint32_t *nr, uint32_t *nr2);
727
virtual void hash(uint32_t *nr, uint32_t *nr2) const;
743
728
friend bool reopen_table(Session *,Table *,bool);
745
730
friend class CopyField;
768
753
uint32_t unpack_num(uint32_t &destination, const unsigned char *arg= NULL) const;
758
inline bool isDateTime(const enum_field_types &arg)
762
case DRIZZLE_TYPE_DATE:
763
case DRIZZLE_TYPE_DATETIME:
764
case DRIZZLE_TYPE_MICROTIME:
765
case DRIZZLE_TYPE_TIME:
766
case DRIZZLE_TYPE_TIMESTAMP:
769
case DRIZZLE_TYPE_BLOB:
770
case DRIZZLE_TYPE_BOOLEAN:
771
case DRIZZLE_TYPE_DECIMAL:
772
case DRIZZLE_TYPE_DOUBLE:
773
case DRIZZLE_TYPE_ENUM:
774
case DRIZZLE_TYPE_LONG:
775
case DRIZZLE_TYPE_LONGLONG:
776
case DRIZZLE_TYPE_NULL:
777
case DRIZZLE_TYPE_UUID:
778
case DRIZZLE_TYPE_VARCHAR:
771
788
std::ostream& operator<<(std::ostream& output, const Field &field);
773
790
} /* namespace drizzled */
775
792
/** @TODO Why is this in the middle of the file???*/
776
#include "drizzled/create_field.h"
793
#include <drizzled/create_field.h>
778
795
namespace drizzled
821
838
* true - If string has some important data
823
bool test_if_important_data(const CHARSET_INFO * const cs,
840
bool test_if_important_data(const charset_info_st * const cs,
825
842
const char *strend);
827
844
} /* namespace drizzled */
829
#endif /* DRIZZLED_FIELD_H */