~drizzle-trunk/drizzle/development

390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008 Sun Microsystems
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
1 by brian
clean slate
19
20
/*
21
  Because of the function new_field() all field classes that have static
22
  variables must declare the size_of() member function.
23
*/
24
520.8.2 by Monty Taylor
Moved sql_parse.h and sql_error.h out of common_includes.
25
#ifndef DRIZZLED_FIELD_H
26
#define DRIZZLED_FIELD_H
27
28
#include <drizzled/sql_error.h>
520.8.3 by Monty Taylor
Moved hash back to mysys.
29
#include <drizzled/my_decimal.h>
1 by brian
clean slate
30
31
#define DATETIME_DEC                     6
173.1.9 by Toru Maesaka
ripped out DOUBLE and moved to field/
32
#define DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE FLOATING_POINT_BUFFER
33
205 by Brian Aker
uint32 -> uin32_t
34
const uint32_t max_field_size= (uint32_t) 4294967295U;
1 by brian
clean slate
35
36
class Send_field;
37
class Protocol;
38
class Create_field;
39
struct st_cache_field;
40
int field_conv(Field *to,Field *from);
41
438.1.13 by Brian Aker
uint cleanup.
42
inline uint32_t get_enum_pack_length(int elements)
1 by brian
clean slate
43
{
44
  return elements < 256 ? 1 : 2;
45
}
46
438.1.13 by Brian Aker
uint cleanup.
47
inline uint32_t get_set_pack_length(int elements)
1 by brian
clean slate
48
{
438.1.13 by Brian Aker
uint cleanup.
49
  uint32_t len= (elements + 7) / 8;
1 by brian
clean slate
50
  return len > 4 ? 8 : len;
51
}
52
383.7.1 by Andrey Zhakov
Initial submit of code and tests
53
class virtual_column_info: public Sql_alloc
54
{
55
public:
56
  Item *expr_item;
57
  LEX_STRING expr_str;
58
  Item *item_free_list;
59
  virtual_column_info() 
60
  : expr_item(0), item_free_list(0),
61
    field_type(DRIZZLE_TYPE_VIRTUAL),
62
    is_stored(false), data_inited(false)
63
  {
64
    expr_str.str= NULL;
65
    expr_str.length= 0;
66
  };
67
  ~virtual_column_info() {}
68
  enum_field_types get_real_type()
69
  {
70
    assert(data_inited);
71
    return data_inited ? field_type : DRIZZLE_TYPE_VIRTUAL;
72
  }
73
  void set_field_type(enum_field_types fld_type)
74
  {
75
    /* Calling this function can only be done once. */
76
    assert(not data_inited);
77
    data_inited= true;
78
    field_type= fld_type;
79
  }
80
  bool get_field_stored()
81
  {
82
    assert(data_inited);
83
    return data_inited ? is_stored : true;
84
  }
85
  void set_field_stored(bool stored)
86
  {
87
    is_stored= stored;
88
  }
89
private:
90
  /*
91
    The following data is only updated by the parser and read
92
    when a Create_field object is created/initialized.
93
  */
94
  enum_field_types field_type;   /* Real field type*/
95
  bool is_stored;             /* Indication that the field is 
96
                                    phisically stored in the database*/
97
  /*
98
    This flag is used to prevent other applications from
99
    reading and using incorrect data.
100
  */
101
  bool data_inited; 
102
};
103
1 by brian
clean slate
104
class Field
105
{
106
  Field(const Item &);				/* Prevent use of these */
107
  void operator=(Field &);
108
public:
109
  static void *operator new(size_t size) {return sql_alloc(size); }
212.1.3 by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)).
110
  static void operator delete(void *ptr_arg __attribute__((unused)),
111
                              size_t size __attribute__((unused)))
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
112
  { TRASH(ptr_arg, size); }
1 by brian
clean slate
113
481 by Brian Aker
Remove all of uchar.
114
  unsigned char		*ptr;			// Position to field in record
115
  unsigned char		*null_ptr;		// Byte where null_bit is
1 by brian
clean slate
116
  /*
520.1.22 by Brian Aker
Second pass of thd cleanup
117
    Note that you can use table->in_use as replacement for current_session member 
1 by brian
clean slate
118
    only inside of val_*() and store() members (e.g. you can't use it in cons)
119
  */
327.1.1 by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure).
120
  Table *table;		// Pointer for table
121
  Table *orig_table;		// Pointer to original table
1 by brian
clean slate
122
  const char	**table_name, *field_name;
123
  LEX_STRING	comment;
124
  /* Field is part of the following keys */
125
  key_map	key_start, part_of_key, part_of_key_not_clustered;
126
  key_map       part_of_sortkey;
127
  /* 
128
    We use three additional unireg types for TIMESTAMP to overcome limitation 
129
    of current binary format of .frm file. We'd like to be able to support 
130
    NOW() as default and on update value for such fields but unable to hold 
131
    this info anywhere except unireg_check field. This issue will be resolved
132
    in more clean way with transition to new text based .frm format.
133
    See also comment for Field_timestamp::Field_timestamp().
134
  */
135
  enum utype  { NONE,DATE,SHIELD,NOEMPTY,CASEUP,PNR,BGNR,PGNR,YES,NO,REL,
136
		CHECK,EMPTY,UNKNOWN_FIELD,CASEDN,NEXT_NUMBER,INTERVAL_FIELD,
137
                BIT_FIELD, TIMESTAMP_OLD_FIELD, CAPITALIZE, BLOB_FIELD,
138
                TIMESTAMP_DN_FIELD, TIMESTAMP_UN_FIELD, TIMESTAMP_DNUN_FIELD};
139
  enum imagetype { itRAW, itMBR};
140
141
  utype		unireg_check;
205 by Brian Aker
uint32 -> uin32_t
142
  uint32_t	field_length;		// Length of field
143
  uint32_t	flags;
206 by Brian Aker
Removed final uint dead types.
144
  uint16_t        field_index;            // field number in fields array
481 by Brian Aker
Remove all of uchar.
145
  unsigned char		null_bit;		// Bit used to test null bit
1 by brian
clean slate
146
  /**
147
     If true, this field was created in create_tmp_field_from_item from a NULL
148
     value. This means that the type of the field is just a guess, and the type
149
     may be freely coerced to another type.
150
151
     @see create_tmp_field_from_item
152
     @see Item_type_holder::get_real_type
153
154
   */
155
  bool is_created_from_null_item;
156
383.7.1 by Andrey Zhakov
Initial submit of code and tests
157
  /* Virtual column data */
158
  virtual_column_info *vcol_info;
159
  /*
160
    Indication that the field is phycically stored in tables 
161
    rather than just generated on SQL queries.
162
    As of now, false can only be set for generated-only virtual columns.
163
  */
164
  bool is_stored;
165
481 by Brian Aker
Remove all of uchar.
166
  Field(unsigned char *ptr_arg,uint32_t length_arg,unsigned char *null_ptr_arg,
167
        unsigned char null_bit_arg, utype unireg_check_arg,
1 by brian
clean slate
168
        const char *field_name_arg);
169
  virtual ~Field() {}
170
  /* Store functions returns 1 on overflow and -1 on fatal error */
438.1.13 by Brian Aker
uint cleanup.
171
  virtual int  store(const char *to, uint32_t length, const CHARSET_INFO * const cs)=0;
1 by brian
clean slate
172
  virtual int  store(double nr)=0;
152 by Brian Aker
longlong replacement
173
  virtual int  store(int64_t nr, bool unsigned_val)=0;
1 by brian
clean slate
174
  virtual int  store_decimal(const my_decimal *d)=0;
398.1.1 by Monty Taylor
Remove typedef enum enum_drizzle_timestamp_type timestamp_type;
175
  virtual int store_time(DRIZZLE_TIME *ltime, enum enum_drizzle_timestamp_type t_type);
438.1.13 by Brian Aker
uint cleanup.
176
  int store(const char *to, uint32_t length, const CHARSET_INFO * const cs,
1 by brian
clean slate
177
            enum_check_fields check_level);
178
  virtual double val_real(void)=0;
152 by Brian Aker
longlong replacement
179
  virtual int64_t val_int(void)=0;
1 by brian
clean slate
180
  virtual my_decimal *val_decimal(my_decimal *);
181
  inline String *val_str(String *str) { return val_str(str, str); }
182
  /*
183
     val_str(buf1, buf2) gets two buffers and should use them as follows:
184
     if it needs a temp buffer to convert result to string - use buf1
185
       example Field_tiny::val_str()
186
     if the value exists as a string already - use buf2
241 by Brian Aker
First pass of CHAR removal.
187
       example Field_varstring::val_str() (???)
1 by brian
clean slate
188
     consequently, buf2 may be created as 'String buf;' - no memory
189
     will be allocated for it. buf1 will be allocated to hold a
190
     value if it's too small. Using allocated buffer for buf2 may result in
191
     an unnecessary free (and later, may be an alloc).
192
     This trickery is used to decrease a number of malloc calls.
193
  */
194
  virtual String *val_str(String*,String *)=0;
275 by Brian Aker
Full removal of my_bool from central server.
195
  String *val_int_as_str(String *val_buffer, bool unsigned_flag);
1 by brian
clean slate
196
  /*
51.1.58 by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another
197
   str_needs_quotes() returns true if the value returned by val_str() needs
1 by brian
clean slate
198
   to be quoted when used in constructing an SQL query.
199
  */
51.1.58 by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another
200
  virtual bool str_needs_quotes() { return false; }
1 by brian
clean slate
201
  virtual Item_result result_type () const=0;
202
  virtual Item_result cmp_type () const { return result_type(); }
203
  virtual Item_result cast_to_int_type () const { return result_type(); }
204
  static bool type_can_have_key_part(enum_field_types);
205
  static enum_field_types field_type_merge(enum_field_types, enum_field_types);
206
  static Item_result result_merge_type(enum_field_types);
207
  virtual bool eq(Field *field)
208
  {
209
    return (ptr == field->ptr && null_ptr == field->null_ptr &&
210
            null_bit == field->null_bit);
211
  }
212
  virtual bool eq_def(Field *field);
213
  
214
  /*
215
    pack_length() returns size (in bytes) used to store field data in memory
216
    (i.e. it returns the maximum size of the field in a row of the table,
217
    which is located in RAM).
218
  */
205 by Brian Aker
uint32 -> uin32_t
219
  virtual uint32_t pack_length() const { return (uint32_t) field_length; }
1 by brian
clean slate
220
221
  /*
222
    pack_length_in_rec() returns size (in bytes) used to store field data on
223
    storage (i.e. it returns the maximal size of the field in a row of the
224
    table, which is located on disk).
225
  */
205 by Brian Aker
uint32 -> uin32_t
226
  virtual uint32_t pack_length_in_rec() const { return pack_length(); }
438.1.13 by Brian Aker
uint cleanup.
227
  virtual int compatible_field_size(uint32_t field_metadata);
228
  virtual uint32_t pack_length_from_metadata(uint32_t field_metadata)
1 by brian
clean slate
229
  { return field_metadata; }
230
  /*
231
    This method is used to return the size of the data in a row-based
232
    replication row record. The default implementation of returning 0 is
51.1.58 by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another
233
    designed to allow fields that do not use metadata to return true (1)
1 by brian
clean slate
234
    from compatible_field_size() which uses this function in the comparison.
235
    The default value for field metadata for fields that do not have 
236
    metadata is 0. Thus, 0 == 0 means the fields are compatible in size.
237
238
    Note: While most classes that override this method return pack_length(),
241 by Brian Aker
First pass of CHAR removal.
239
    the classes Field_varstring, and Field_blob return 
1 by brian
clean slate
240
    field_length + 1, field_length, and pack_length_no_ptr() respectfully.
241
  */
438.1.13 by Brian Aker
uint cleanup.
242
  virtual uint32_t row_pack_length() { return 0; }
481 by Brian Aker
Remove all of uchar.
243
  virtual int save_field_metadata(unsigned char *first_byte)
1 by brian
clean slate
244
  { return do_save_field_metadata(first_byte); }
245
246
  /*
247
    data_length() return the "real size" of the data in memory.
248
    For varstrings, this does _not_ include the length bytes.
249
  */
205 by Brian Aker
uint32 -> uin32_t
250
  virtual uint32_t data_length() { return pack_length(); }
1 by brian
clean slate
251
  /*
252
    used_length() returns the number of bytes actually used to store the data
253
    of the field. So for a varstring it includes both lenght byte(s) and
254
    string data, and anything after data_length() bytes are unused.
255
  */
205 by Brian Aker
uint32 -> uin32_t
256
  virtual uint32_t used_length() { return pack_length(); }
257
  virtual uint32_t sort_length() const { return pack_length(); }
1 by brian
clean slate
258
259
  /**
260
     Get the maximum size of the data in packed format.
261
262
     @return Maximum data length of the field when packed using the
263
     Field::pack() function.
264
   */
205 by Brian Aker
uint32 -> uin32_t
265
  virtual uint32_t max_data_length() const {
1 by brian
clean slate
266
    return pack_length();
267
  };
268
212.6.1 by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file.
269
  virtual int reset(void) { memset(ptr, 0, pack_length()); return 0; }
1 by brian
clean slate
270
  virtual void reset_fields() {}
271
  virtual void set_default()
272
  {
327.1.1 by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure).
273
    my_ptrdiff_t l_offset= (my_ptrdiff_t) (table->getDefaultValues() - table->record[0]);
1 by brian
clean slate
274
    memcpy(ptr, ptr + l_offset, pack_length());
275
    if (null_ptr)
481 by Brian Aker
Remove all of uchar.
276
      *null_ptr= ((*null_ptr & (unsigned char) ~null_bit) | (null_ptr[l_offset] & null_bit));
1 by brian
clean slate
277
  }
278
  virtual bool binary() const { return 1; }
279
  virtual bool zero_pack() const { return 1; }
280
  virtual enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
205 by Brian Aker
uint32 -> uin32_t
281
  virtual uint32_t key_length() const { return pack_length(); }
1 by brian
clean slate
282
  virtual enum_field_types type() const =0;
283
  virtual enum_field_types real_type() const { return type(); }
481 by Brian Aker
Remove all of uchar.
284
  inline  int cmp(const unsigned char *str) { return cmp(ptr,str); }
285
  virtual int cmp_max(const unsigned char *a, const unsigned char *b,
438.1.13 by Brian Aker
uint cleanup.
286
                      uint32_t max_len __attribute__((unused)))
1 by brian
clean slate
287
    { return cmp(a, b); }
481 by Brian Aker
Remove all of uchar.
288
  virtual int cmp(const unsigned char *,const unsigned char *)=0;
289
  virtual int cmp_binary(const unsigned char *a,const unsigned char *b,
365.2.5 by Monty Taylor
More ~0 removal.
290
                         uint32_t  __attribute__((unused)) max_length=UINT32_MAX)
1 by brian
clean slate
291
  { return memcmp(a,b,pack_length()); }
438.1.13 by Brian Aker
uint cleanup.
292
  virtual int cmp_offset(uint32_t row_offset)
1 by brian
clean slate
293
  { return cmp(ptr,ptr+row_offset); }
438.1.13 by Brian Aker
uint cleanup.
294
  virtual int cmp_binary_offset(uint32_t row_offset)
1 by brian
clean slate
295
  { return cmp_binary(ptr, ptr+row_offset); };
481 by Brian Aker
Remove all of uchar.
296
  virtual int key_cmp(const unsigned char *a,const unsigned char *b)
1 by brian
clean slate
297
  { return cmp(a, b); }
481 by Brian Aker
Remove all of uchar.
298
  virtual int key_cmp(const unsigned char *str, uint32_t length __attribute__((unused)))
1 by brian
clean slate
299
  { return cmp(ptr,str); }
438.1.13 by Brian Aker
uint cleanup.
300
  virtual uint32_t decimals() const { return 0; }
1 by brian
clean slate
301
  /*
302
    Caller beware: sql_type can change str.Ptr, so check
303
    ptr() to see if it changed if you are using your own buffer
304
    in str and restore it with set() if needed
305
  */
306
  virtual void sql_type(String &str) const =0;
438.1.13 by Brian Aker
uint cleanup.
307
  virtual uint32_t size_of() const =0;		// For new field
1 by brian
clean slate
308
  inline bool is_null(my_ptrdiff_t row_offset= 0)
309
  { return null_ptr ? (null_ptr[row_offset] & null_bit ? 1 : 0) : table->null_row; }
310
  inline bool is_real_null(my_ptrdiff_t row_offset= 0)
311
    { return null_ptr ? (null_ptr[row_offset] & null_bit ? 1 : 0) : 0; }
481 by Brian Aker
Remove all of uchar.
312
  inline bool is_null_in_record(const unsigned char *record)
1 by brian
clean slate
313
  {
314
    if (!null_ptr)
315
      return 0;
438.1.13 by Brian Aker
uint cleanup.
316
    return test(record[(uint32_t) (null_ptr -table->record[0])] &
1 by brian
clean slate
317
		null_bit);
318
  }
319
  inline bool is_null_in_record_with_offset(my_ptrdiff_t offset)
320
  {
321
    if (!null_ptr)
322
      return 0;
323
    return test(null_ptr[offset] & null_bit);
324
  }
325
  inline void set_null(my_ptrdiff_t row_offset= 0)
326
    { if (null_ptr) null_ptr[row_offset]|= null_bit; }
327
  inline void set_notnull(my_ptrdiff_t row_offset= 0)
481 by Brian Aker
Remove all of uchar.
328
    { if (null_ptr) null_ptr[row_offset]&= (unsigned char) ~null_bit; }
1 by brian
clean slate
329
  inline bool maybe_null(void) { return null_ptr != 0 || table->maybe_null; }
330
  inline bool real_maybe_null(void) { return null_ptr != 0; }
331
332
  enum {
333
    LAST_NULL_BYTE_UNDEF= 0
334
  };
335
336
  /*
337
    Find the position of the last null byte for the field.
338
339
    SYNOPSIS
340
      last_null_byte()
341
342
    DESCRIPTION
343
      Return a pointer to the last byte of the null bytes where the
344
      field conceptually is placed.
345
346
    RETURN VALUE
347
      The position of the last null byte relative to the beginning of
348
      the record. If the field does not use any bits of the null
349
      bytes, the value 0 (LAST_NULL_BYTE_UNDEF) is returned.
350
   */
351
  size_t last_null_byte() const {
352
    size_t bytes= do_last_null_byte();
327.1.1 by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure).
353
    assert(bytes <= table->getNullBytes());
1 by brian
clean slate
354
    return bytes;
355
  }
356
357
  virtual void make_field(Send_field *);
481 by Brian Aker
Remove all of uchar.
358
  virtual void sort_string(unsigned char *buff,uint32_t length)=0;
438.1.13 by Brian Aker
uint cleanup.
359
  virtual bool optimize_range(uint32_t idx, uint32_t part);
1 by brian
clean slate
360
  /*
361
    This should be true for fields which, when compared with constant
152 by Brian Aker
longlong replacement
362
    items, can be casted to int64_t. In this case we will at 'fix_fields'
363
    stage cast the constant items to int64_ts and at the execution stage
1 by brian
clean slate
364
    use field->val_int() for comparison.  Used to optimize clauses like
365
    'a_column BETWEEN date_const, date_const'.
366
  */
152 by Brian Aker
longlong replacement
367
  virtual bool can_be_compared_as_int64_t() const { return false; }
1 by brian
clean slate
368
  virtual void free() {}
327.1.1 by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure).
369
  virtual Field *new_field(MEM_ROOT *root, Table *new_table,
1 by brian
clean slate
370
                           bool keep_type);
327.1.1 by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure).
371
  virtual Field *new_key_field(MEM_ROOT *root, Table *new_table,
481 by Brian Aker
Remove all of uchar.
372
                               unsigned char *new_ptr, unsigned char *new_null_ptr,
438.1.13 by Brian Aker
uint cleanup.
373
                               uint32_t new_null_bit);
327.1.1 by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure).
374
  Field *clone(MEM_ROOT *mem_root, Table *new_table);
481 by Brian Aker
Remove all of uchar.
375
  inline void move_field(unsigned char *ptr_arg,unsigned char *null_ptr_arg,unsigned char null_bit_arg)
1 by brian
clean slate
376
  {
377
    ptr=ptr_arg; null_ptr=null_ptr_arg; null_bit=null_bit_arg;
378
  }
481 by Brian Aker
Remove all of uchar.
379
  inline void move_field(unsigned char *ptr_arg) { ptr=ptr_arg; }
1 by brian
clean slate
380
  virtual void move_field_offset(my_ptrdiff_t ptr_diff)
381
  {
481 by Brian Aker
Remove all of uchar.
382
    ptr=ADD_TO_PTR(ptr,ptr_diff, unsigned char*);
1 by brian
clean slate
383
    if (null_ptr)
481 by Brian Aker
Remove all of uchar.
384
      null_ptr=ADD_TO_PTR(null_ptr,ptr_diff,unsigned char*);
1 by brian
clean slate
385
  }
481 by Brian Aker
Remove all of uchar.
386
  virtual void get_image(unsigned char *buff, uint32_t length,
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
387
                         const CHARSET_INFO * const cs __attribute__((unused)))
1 by brian
clean slate
388
    { memcpy(buff,ptr,length); }
481 by Brian Aker
Remove all of uchar.
389
  virtual void set_image(const unsigned char *buff,uint32_t length,
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
390
                         const CHARSET_INFO * const cs __attribute__((unused)))
1 by brian
clean slate
391
    { memcpy(ptr,buff,length); }
392
393
394
  /*
395
    Copy a field part into an output buffer.
396
397
    SYNOPSIS
398
      Field::get_key_image()
399
      buff   [out] output buffer
400
      length       output buffer size
401
      type         itMBR for geometry blobs, otherwise itRAW
402
403
    DESCRIPTION
404
      This function makes a copy of field part of size equal to or
405
      less than "length" parameter value.
406
      For fields of string types (CHAR, VARCHAR, TEXT) the rest of buffer
407
      is padded by zero byte.
408
409
    NOTES
410
      For variable length character fields (i.e. UTF-8) the "length"
411
      parameter means a number of output buffer bytes as if all field
412
      characters have maximal possible size (mbmaxlen). In the other words,
413
      "length" parameter is a number of characters multiplied by
414
      field_charset->mbmaxlen.
415
416
    RETURN
417
      Number of copied bytes (excluding padded zero bytes -- see above).
418
  */
419
481 by Brian Aker
Remove all of uchar.
420
  virtual uint32_t get_key_image(unsigned char *buff, uint32_t length,
212.1.3 by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)).
421
                             imagetype type __attribute__((unused)))
1 by brian
clean slate
422
  {
423
    get_image(buff, length, &my_charset_bin);
424
    return length;
425
  }
481 by Brian Aker
Remove all of uchar.
426
  virtual void set_key_image(const unsigned char *buff,uint32_t length)
1 by brian
clean slate
427
    { set_image(buff,length, &my_charset_bin); }
438.1.13 by Brian Aker
uint cleanup.
428
  inline int64_t val_int_offset(uint32_t row_offset)
1 by brian
clean slate
429
    {
430
      ptr+=row_offset;
152 by Brian Aker
longlong replacement
431
      int64_t tmp=val_int();
1 by brian
clean slate
432
      ptr-=row_offset;
433
      return tmp;
434
    }
481 by Brian Aker
Remove all of uchar.
435
  inline int64_t val_int(const unsigned char *new_ptr)
1 by brian
clean slate
436
  {
481 by Brian Aker
Remove all of uchar.
437
    unsigned char *old_ptr= ptr;
152 by Brian Aker
longlong replacement
438
    int64_t return_value;
481 by Brian Aker
Remove all of uchar.
439
    ptr= (unsigned char*) new_ptr;
1 by brian
clean slate
440
    return_value= val_int();
441
    ptr= old_ptr;
442
    return return_value;
443
  }
481 by Brian Aker
Remove all of uchar.
444
  inline String *val_str(String *str, const unsigned char *new_ptr)
1 by brian
clean slate
445
  {
481 by Brian Aker
Remove all of uchar.
446
    unsigned char *old_ptr= ptr;
447
    ptr= (unsigned char*) new_ptr;
1 by brian
clean slate
448
    val_str(str);
449
    ptr= old_ptr;
450
    return str;
451
  }
452
  virtual bool send_binary(Protocol *protocol);
453
481 by Brian Aker
Remove all of uchar.
454
  virtual unsigned char *pack(unsigned char *to, const unsigned char *from,
438.1.13 by Brian Aker
uint cleanup.
455
                      uint32_t max_length, bool low_byte_first);
1 by brian
clean slate
456
  /**
481 by Brian Aker
Remove all of uchar.
457
     @overload Field::pack(unsigned char*, const unsigned char*, uint32_t, bool)
1 by brian
clean slate
458
  */
481 by Brian Aker
Remove all of uchar.
459
  unsigned char *pack(unsigned char *to, const unsigned char *from)
1 by brian
clean slate
460
  {
481 by Brian Aker
Remove all of uchar.
461
    unsigned char *result= this->pack(to, from, UINT_MAX, table->s->db_low_byte_first);
51.1.58 by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another
462
    return(result);
1 by brian
clean slate
463
  }
464
481 by Brian Aker
Remove all of uchar.
465
  virtual const unsigned char *unpack(unsigned char* to, const unsigned char *from,
438.1.13 by Brian Aker
uint cleanup.
466
                              uint32_t param_data, bool low_byte_first);
1 by brian
clean slate
467
  /**
481 by Brian Aker
Remove all of uchar.
468
     @overload Field::unpack(unsigned char*, const unsigned char*, uint32_t, bool)
1 by brian
clean slate
469
  */
481 by Brian Aker
Remove all of uchar.
470
  const unsigned char *unpack(unsigned char* to, const unsigned char *from)
1 by brian
clean slate
471
  {
481 by Brian Aker
Remove all of uchar.
472
    const unsigned char *result= unpack(to, from, 0U, table->s->db_low_byte_first);
51.1.58 by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another
473
    return(result);
1 by brian
clean slate
474
  }
475
481 by Brian Aker
Remove all of uchar.
476
  virtual unsigned char *pack_key(unsigned char* to, const unsigned char *from,
438.1.13 by Brian Aker
uint cleanup.
477
                          uint32_t max_length, bool low_byte_first)
1 by brian
clean slate
478
  {
479
    return pack(to, from, max_length, low_byte_first);
480
  }
481 by Brian Aker
Remove all of uchar.
481
  virtual unsigned char *pack_key_from_key_image(unsigned char* to, const unsigned char *from,
438.1.13 by Brian Aker
uint cleanup.
482
					uint32_t max_length, bool low_byte_first)
1 by brian
clean slate
483
  {
484
    return pack(to, from, max_length, low_byte_first);
485
  }
481 by Brian Aker
Remove all of uchar.
486
  virtual const unsigned char *unpack_key(unsigned char* to, const unsigned char *from,
438.1.13 by Brian Aker
uint cleanup.
487
                                  uint32_t max_length, bool low_byte_first)
1 by brian
clean slate
488
  {
489
    return unpack(to, from, max_length, low_byte_first);
490
  }
481 by Brian Aker
Remove all of uchar.
491
  virtual uint32_t packed_col_length(const unsigned char *to __attribute__((unused)),
438.1.13 by Brian Aker
uint cleanup.
492
                                 uint32_t length)
1 by brian
clean slate
493
  { return length;}
438.1.13 by Brian Aker
uint cleanup.
494
  virtual uint32_t max_packed_col_length(uint32_t max_length)
1 by brian
clean slate
495
  { return max_length;}
496
481 by Brian Aker
Remove all of uchar.
497
  virtual int pack_cmp(const unsigned char *a,const unsigned char *b,
438.1.13 by Brian Aker
uint cleanup.
498
                       uint32_t key_length_arg __attribute__((unused)),
275 by Brian Aker
Full removal of my_bool from central server.
499
                       bool insert_or_update __attribute__((unused)))
1 by brian
clean slate
500
  { return cmp(a,b); }
481 by Brian Aker
Remove all of uchar.
501
  virtual int pack_cmp(const unsigned char *b,
438.1.13 by Brian Aker
uint cleanup.
502
                       uint32_t key_length_arg __attribute__((unused)),
275 by Brian Aker
Full removal of my_bool from central server.
503
                       bool insert_or_update __attribute__((unused)))
1 by brian
clean slate
504
  { return cmp(ptr,b); }
481 by Brian Aker
Remove all of uchar.
505
  uint32_t offset(unsigned char *record)
1 by brian
clean slate
506
  {
438.1.13 by Brian Aker
uint cleanup.
507
    return (uint32_t) (ptr - record);
1 by brian
clean slate
508
  }
509
  void copy_from_tmp(int offset);
438.1.13 by Brian Aker
uint cleanup.
510
  uint32_t fill_cache_field(struct st_cache_field *copy);
511
  virtual bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
512
  virtual bool get_time(DRIZZLE_TIME *ltime);
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
513
  virtual const CHARSET_INFO *charset(void) const { return &my_charset_bin; }
514
  virtual const CHARSET_INFO *sort_charset(void) const { return charset(); }
51.1.58 by Jay Pipes
Replace/remove DBUG and standardize TRUE/FALSE. Remove ASSERT_COLUMN_XXX macros, that work will be done on another
515
  virtual bool has_charset(void) const { return false; }
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
516
  virtual void set_charset(const CHARSET_INFO * const charset_arg __attribute__((unused)))
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
517
  { }
1 by brian
clean slate
518
  virtual enum Derivation derivation(void) const
519
  { return DERIVATION_IMPLICIT; }
212.1.3 by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)).
520
  virtual void set_derivation(enum Derivation derivation_arg __attribute__((unused)))
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
521
  { }
261.4.1 by Felipe
- Renamed MYSQL_ERROR to DRIZZLE_ERROR.
522
  bool set_warning(DRIZZLE_ERROR::enum_warning_level, unsigned int code,
1 by brian
clean slate
523
                   int cuted_increment);
438.1.13 by Brian Aker
uint cleanup.
524
  void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level, uint32_t code, 
525
                            const char *str, uint32_t str_len,
398.1.1 by Monty Taylor
Remove typedef enum enum_drizzle_timestamp_type timestamp_type;
526
                            enum enum_drizzle_timestamp_type ts_type, int cuted_increment);
438.1.13 by Brian Aker
uint cleanup.
527
  void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level, uint32_t code, 
398.1.1 by Monty Taylor
Remove typedef enum enum_drizzle_timestamp_type timestamp_type;
528
                            int64_t nr, enum enum_drizzle_timestamp_type ts_type,
1 by brian
clean slate
529
                            int cuted_increment);
438.1.13 by Brian Aker
uint cleanup.
530
  void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level, const uint32_t code, 
398.1.1 by Monty Taylor
Remove typedef enum enum_drizzle_timestamp_type timestamp_type;
531
                            double nr, enum enum_drizzle_timestamp_type ts_type);
1 by brian
clean slate
532
  inline bool check_overflow(int op_result)
533
  {
534
    return (op_result == E_DEC_OVERFLOW);
535
  }
536
  int warn_if_overflow(int op_result);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
537
  void init(Table *table_arg)
1 by brian
clean slate
538
  {
539
    orig_table= table= table_arg;
540
    table_name= &table_arg->alias;
541
  }
542
543
  /* maximum possible display length */
205 by Brian Aker
uint32 -> uin32_t
544
  virtual uint32_t max_display_length()= 0;
1 by brian
clean slate
545
438.1.13 by Brian Aker
uint cleanup.
546
  virtual uint32_t is_equal(Create_field *new_field);
152 by Brian Aker
longlong replacement
547
  /* convert decimal to int64_t with overflow check */
548
  int64_t convert_decimal2int64_t(const my_decimal *val, bool unsigned_flag,
1 by brian
clean slate
549
                                    int *err);
550
  /* The max. number of characters */
205 by Brian Aker
uint32 -> uin32_t
551
  inline uint32_t char_length() const
1 by brian
clean slate
552
  {
553
    return field_length / charset()->mbmaxlen;
554
  }
555
556
  inline enum column_format_type column_format() const
557
  {
558
    return (enum column_format_type)
559
      ((flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK);
560
  }
561
562
  /* Hash value */
290 by Brian Aker
Update for ulong change over.
563
  virtual void hash(uint32_t *nr, uint32_t *nr2);
520.1.21 by Brian Aker
THD -> Session rename
564
  friend bool reopen_table(Session *,Table *,bool);
438.1.13 by Brian Aker
uint cleanup.
565
  friend int cre_myisam(char * name, register Table *form, uint32_t options,
1 by brian
clean slate
566
			uint64_t auto_increment_value);
567
  friend class Copy_field;
568
  friend class Item_avg_field;
569
  friend class Item_std_field;
570
  friend class Item_sum_num;
571
  friend class Item_sum_sum;
572
  friend class Item_sum_str;
573
  friend class Item_sum_count;
574
  friend class Item_sum_avg;
575
  friend class Item_sum_std;
576
  friend class Item_sum_min;
577
  friend class Item_sum_max;
578
  friend class Item_func_group_concat;
579
580
private:
581
  /*
582
    Primitive for implementing last_null_byte().
583
584
    SYNOPSIS
585
      do_last_null_byte()
586
587
    DESCRIPTION
588
      Primitive for the implementation of the last_null_byte()
589
      function. This represents the inheritance interface and can be
590
      overridden by subclasses.
591
   */
592
  virtual size_t do_last_null_byte() const;
593
594
/**
595
   Retrieve the field metadata for fields.
596
597
   This default implementation returns 0 and saves 0 in the metadata_ptr
598
   value.
599
600
   @param   metadata_ptr   First byte of field metadata
601
602
   @returns 0 no bytes written.
603
*/
481 by Brian Aker
Remove all of uchar.
604
  virtual int do_save_field_metadata(unsigned char *metadata_ptr __attribute__((unused)))
1 by brian
clean slate
605
  { return 0; }
606
};
607
608
/*
609
  Create field class for CREATE TABLE
610
*/
611
612
class Create_field :public Sql_alloc
613
{
614
public:
615
  const char *field_name;
616
  const char *change;			// If done with alter table
617
  const char *after;			// Put column after this one
618
  LEX_STRING comment;			// Comment for field
619
  Item	*def;				// Default value
620
  enum	enum_field_types sql_type;
621
  /*
622
    At various stages in execution this can be length of field in bytes or
623
    max number of characters. 
624
  */
290 by Brian Aker
Update for ulong change over.
625
  uint32_t length;
1 by brian
clean slate
626
  /*
627
    The value of `length' as set by parser: is the number of characters
628
    for most of the types, or of bytes for BLOBs or numeric types.
629
  */
205 by Brian Aker
uint32 -> uin32_t
630
  uint32_t char_length;
438.1.13 by Brian Aker
uint cleanup.
631
  uint32_t  decimals, flags, pack_length, key_length;
1 by brian
clean slate
632
  Field::utype unireg_check;
633
  TYPELIB *interval;			// Which interval to use
634
  TYPELIB *save_interval;               // Temporary copy for the above
635
                                        // Used only for UCS2 intervals
636
  List<String> interval_list;
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
637
  const CHARSET_INFO *charset;
1 by brian
clean slate
638
  Field *field;				// For alter table
639
206 by Brian Aker
Removed final uint dead types.
640
  uint8_t row,col,sc_length,interval_id;	// For rea_create_table
438.1.13 by Brian Aker
uint cleanup.
641
  uint32_t	offset,pack_flag;
383.7.1 by Andrey Zhakov
Initial submit of code and tests
642
643
  /* Virtual column expression statement */
644
  virtual_column_info *vcol_info;
645
  /*
646
    Indication that the field is phycically stored in tables 
647
    rather than just generated on SQL queries.
648
    As of now, FALSE can only be set for generated-only virtual columns.
649
  */
650
  bool is_stored;
651
1 by brian
clean slate
652
  Create_field() :after(0) {}
653
  Create_field(Field *field, Field *orig_field);
654
  /* Used to make a clone of this object for ALTER/CREATE TABLE */
655
  Create_field *clone(MEM_ROOT *mem_root) const
656
    { return new (mem_root) Create_field(*this); }
657
  void create_length_to_internal_length(void);
658
659
  inline enum column_format_type column_format() const
660
  {
661
    return (enum column_format_type)
662
      ((flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK);
663
  }
664
665
  /* Init for a tmp table field. To be extended if need be. */
666
  void init_for_tmp_table(enum_field_types sql_type_arg,
205 by Brian Aker
uint32 -> uin32_t
667
                          uint32_t max_length, uint32_t decimals,
1 by brian
clean slate
668
                          bool maybe_null, bool is_unsigned);
669
520.1.22 by Brian Aker
Second pass of thd cleanup
670
  bool init(Session *session, char *field_name, enum_field_types type, char *length,
438.1.13 by Brian Aker
uint cleanup.
671
            char *decimals, uint32_t type_modifier, Item *default_value,
1 by brian
clean slate
672
            Item *on_update_value, LEX_STRING *comment, char *change,
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
673
            List<String> *interval_list, const CHARSET_INFO * const cs,
438.1.13 by Brian Aker
uint cleanup.
674
            uint32_t uint_geom_type,
383.7.1 by Andrey Zhakov
Initial submit of code and tests
675
            enum column_format_type column_format,
676
            virtual_column_info *vcol_info);
1 by brian
clean slate
677
};
678
679
680
/*
681
  A class for sending info to the client
682
*/
683
684
class Send_field {
685
 public:
686
  const char *db_name;
687
  const char *table_name,*org_table_name;
688
  const char *col_name,*org_col_name;
290 by Brian Aker
Update for ulong change over.
689
  uint32_t length;
438.1.13 by Brian Aker
uint cleanup.
690
  uint32_t charsetnr, flags, decimals;
1 by brian
clean slate
691
  enum_field_types type;
692
  Send_field() {}
693
};
694
695
696
/*
697
  A class for quick copying data to fields
698
*/
699
700
class Copy_field :public Sql_alloc {
701
  /**
702
    Convenience definition of a copy function returned by
703
    get_copy_func.
704
  */
705
  typedef void Copy_func(Copy_field*);
706
  Copy_func *get_copy_func(Field *to, Field *from);
707
public:
481 by Brian Aker
Remove all of uchar.
708
  unsigned char *from_ptr,*to_ptr;
709
  unsigned char *from_null_ptr,*to_null_ptr;
274 by Brian Aker
my_bool conversion in Table
710
  bool *null_row;
438.1.13 by Brian Aker
uint cleanup.
711
  uint32_t	from_bit,to_bit;
712
  uint32_t from_length,to_length;
1 by brian
clean slate
713
  Field *from_field,*to_field;
714
  String tmp;					// For items
715
716
  Copy_field() {}
717
  ~Copy_field() {}
718
  void set(Field *to,Field *from,bool save);	// Field to field 
481 by Brian Aker
Remove all of uchar.
719
  void set(unsigned char *to,Field *from);		// Field to string
1 by brian
clean slate
720
  void (*do_copy)(Copy_field *);
721
  void (*do_copy2)(Copy_field *);		// Used to handle null values
722
};
723
724
481 by Brian Aker
Remove all of uchar.
725
Field *make_field(TABLE_SHARE *share, unsigned char *ptr, uint32_t field_length,
575.4.7 by Monty Taylor
More header cleanup.
726
                  unsigned char *null_pos, unsigned char null_bit,
727
                  uint32_t pack_flag, enum_field_types field_type,
728
                  const CHARSET_INFO * cs,
729
                  Field::utype unireg_check,
730
                  TYPELIB *interval, const char *field_name);
731
438.1.13 by Brian Aker
uint cleanup.
732
uint32_t pack_length_to_packflag(uint32_t type);
290 by Brian Aker
Update for ulong change over.
733
enum_field_types get_blob_type_from_length(uint32_t length);
205 by Brian Aker
uint32 -> uin32_t
734
uint32_t calc_pack_length(enum_field_types type,uint32_t length);
1 by brian
clean slate
735
int set_field_to_null(Field *field);
736
int set_field_to_null_with_conversions(Field *field, bool no_conversions);
737
173.1.3 by Toru Maesaka
ripped out datetime and moved to field/
738
483.1.4 by Lee
break out Field_longstr
739
bool
740
test_if_important_data(const CHARSET_INFO * const cs, 
741
		       const char *str,
742
                       const char *strend);
743
173.1.3 by Toru Maesaka
ripped out datetime and moved to field/
744
/*
745
  Field subclasses
746
 */
483.1.5 by Lee
clean up code for Field_str
747
#include <drizzled/field/str.h>
483.1.4 by Lee
break out Field_longstr
748
#include <drizzled/field/longstr.h>
483.1.6 by Lee
code clean up for Field_num
749
#include <drizzled/field/num.h>
214 by Brian Aker
Rename of fields (fix issue with string and decimal .h clashing).
750
#include <drizzled/field/blob.h>
438.4.1 by Lee
breaking out enum field classes
751
#include <drizzled/field/enum.h>
214 by Brian Aker
Rename of fields (fix issue with string and decimal .h clashing).
752
#include <drizzled/field/null.h>
753
#include <drizzled/field/date.h>
754
#include <drizzled/field/fdecimal.h>
483.1.1 by Lee
latest code cleanup for Field_real
755
#include <drizzled/field/real.h>
214 by Brian Aker
Rename of fields (fix issue with string and decimal .h clashing).
756
#include <drizzled/field/double.h>
757
#include <drizzled/field/long.h>
758
#include <drizzled/field/int64_t.h>
483.1.6 by Lee
code clean up for Field_num
759
#include <drizzled/field/num.h>
214 by Brian Aker
Rename of fields (fix issue with string and decimal .h clashing).
760
#include <drizzled/field/timetype.h>
761
#include <drizzled/field/timestamp.h>
762
#include <drizzled/field/datetime.h>
763
#include <drizzled/field/fstring.h>
764
#include <drizzled/field/varstring.h>
173.1.3 by Toru Maesaka
ripped out datetime and moved to field/
765
1 by brian
clean slate
766
/*
767
  The following are for the interface with the .frm file
768
*/
769
770
#define FIELDFLAG_DECIMAL		1
771
#define FIELDFLAG_BINARY		1	// Shares same flag
772
#define FIELDFLAG_NUMBER		2
216 by Brian Aker
Remove completely ZEROFILL
773
#define FIELDFLAG_DECIMAL_POSITION      4
1 by brian
clean slate
774
#define FIELDFLAG_PACK			120	// Bits used for packing
775
#define FIELDFLAG_INTERVAL		256     // mangled with decimals!
776
#define FIELDFLAG_BLOB			1024	// mangled with decimals!
520 by Brian Aker
Remove dead field defines (and dropped a dead function for SP).
777
1 by brian
clean slate
778
#define FIELDFLAG_NO_DEFAULT		16384   /* sql */
438.1.13 by Brian Aker
uint cleanup.
779
#define FIELDFLAG_SUM			((uint32_t) 32768)// predit: +#fieldflag
780
#define FIELDFLAG_MAYBE_NULL		((uint32_t) 32768)// sql
781
#define FIELDFLAG_HEX_ESCAPE		((uint32_t) 0x10000)
1 by brian
clean slate
782
#define FIELDFLAG_PACK_SHIFT		3
783
#define FIELDFLAG_DEC_SHIFT		8
784
#define FIELDFLAG_MAX_DEC		31
785
786
#define MTYP_TYPENR(type) (type & 127)	/* Remove bits from type */
787
788
#define f_is_dec(x)		((x) & FIELDFLAG_DECIMAL)
789
#define f_is_num(x)		((x) & FIELDFLAG_NUMBER)
216 by Brian Aker
Remove completely ZEROFILL
790
#define f_is_decimal_precision(x)	((x) & FIELDFLAG_DECIMAL_POSITION)
1 by brian
clean slate
791
#define f_is_packed(x)		((x) & FIELDFLAG_PACK)
792
#define f_packtype(x)		(((x) >> FIELDFLAG_PACK_SHIFT) & 15)
206 by Brian Aker
Removed final uint dead types.
793
#define f_decimals(x)		((uint8_t) (((x) >> FIELDFLAG_DEC_SHIFT) & FIELDFLAG_MAX_DEC))
1 by brian
clean slate
794
#define f_is_alpha(x)		(!f_is_num(x))
795
#define f_is_binary(x)          ((x) & FIELDFLAG_BINARY) // 4.0- compatibility
796
#define f_is_enum(x)            (((x) & (FIELDFLAG_INTERVAL | FIELDFLAG_NUMBER)) == FIELDFLAG_INTERVAL)
797
#define f_is_blob(x)		(((x) & (FIELDFLAG_BLOB | FIELDFLAG_NUMBER)) == FIELDFLAG_BLOB)
798
#define f_is_equ(x)		((x) & (1+2+FIELDFLAG_PACK+31*256))
520 by Brian Aker
Remove dead field defines (and dropped a dead function for SP).
799
#define f_settype(x)   (((int) x) << FIELDFLAG_PACK_SHIFT)
1 by brian
clean slate
800
#define f_maybe_null(x)		(x & FIELDFLAG_MAYBE_NULL)
801
#define f_no_default(x)		(x & FIELDFLAG_NO_DEFAULT)
802
#define f_is_hex_escape(x)      ((x) & FIELDFLAG_HEX_ESCAPE)
173.1.3 by Toru Maesaka
ripped out datetime and moved to field/
803
483.1.5 by Lee
clean up code for Field_str
804
bool
805
check_string_copy_error(Field_str *field,
806
                        const char *well_formed_error_pos,
807
                        const char *cannot_convert_error_pos,
808
                        const char *end,
809
                        const CHARSET_INFO * const cs);
520.8.2 by Monty Taylor
Moved sql_parse.h and sql_error.h out of common_includes.
810
811
#endif /* DRIZZLED_FIELD_H */