~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/create_field.h

mergeĀ lp:~hingo/drizzle/drizzle-auth_ldap-fix-and-docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008-2009 Sun Microsystems
 
4
 *  Copyright (C) 2008-2009 Sun Microsystems, Inc.
5
5
 *
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
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef DRIZZLED_CREATE_FIELD_H
21
 
#define DRIZZLED_CREATE_FIELD_H
22
 
 
23
 
#include "drizzled/field.h"
24
 
 
25
 
namespace drizzled
26
 
{
27
 
 
28
 
class Item;
29
 
typedef struct st_typelib TYPELIB;
 
20
#pragma once
 
21
 
 
22
#include <drizzled/field.h>
 
23
 
 
24
namespace drizzled {
30
25
 
31
26
/**
32
27
 * Class representing a field in a CREATE TABLE statement.
34
29
 * Basically, all information for a new or altered field
35
30
 * definition is contained in the Create_field class.
36
31
 */
37
 
class CreateField :public memory::SqlAlloc
 
32
class CreateField : public memory::SqlAlloc
38
33
{
39
34
public:
40
35
  const char *field_name; /**< Name of the field to be created */
41
36
  const char *change; /**< If done with alter table */
42
37
  const char *after; /**< Put this new Field after this Field */
43
 
  LEX_STRING comment; /**< A comment for this field */
 
38
  str_ref comment; /**< A comment for this field */
44
39
  Item *def; /**< Default value for the new field */
45
 
  enum enum_field_types sql_type; /**< The data type of the new field */
 
40
  enum_field_types sql_type; /**< The data type of the new field */
 
41
 
 
42
  enum_field_types type() const
 
43
  {
 
44
    return sql_type;
 
45
  }
 
46
 
46
47
  /**
47
48
   * At various stages in execution this can be length of field in bytes or
48
49
   * max number of characters.
60
61
  Field::utype unireg_check; /**< See Field::unireg_check */
61
62
  TYPELIB *interval; /**< Which interval to use (ENUM types..) */
62
63
  List<String> interval_list;
63
 
  const CHARSET_INFO *charset; /**< Character set for the column -- @TODO should be deleted */
 
64
  const charset_info_st *charset; /**< Character set for the column -- @TODO should be deleted */
64
65
  Field *field; // For alter table
65
66
 
66
67
  uint8_t interval_id;  // For rea_create_table
68
69
 
69
70
  CreateField() :after(0) {}
70
71
  CreateField(Field *field, Field *orig_field);
71
 
  /* Used to make a clone of this object for ALTER/CREATE TABLE */
72
 
  CreateField *clone(memory::Root *mem_root) const
73
 
    { return new (mem_root) CreateField(*this); }
74
72
  void create_length_to_internal_length(void);
75
73
 
76
74
  inline enum column_format_type column_format() const
110
108
    @retval
111
109
      true  on error
112
110
  */
113
 
  bool init(Session *session,
114
 
            char *field_name,
 
111
  bool init(Session*,
 
112
            const char *field_name,
115
113
            enum_field_types type,
116
 
            char *length,
117
 
            char *decimals,
 
114
            const char *length,
 
115
            const char *decimals,
118
116
            uint32_t type_modifier,
119
 
            Item *default_value,
120
 
            Item *on_update_value,
121
 
            LEX_STRING *comment,
122
 
            char *change,
 
117
            str_ref comment,
 
118
            const char *change,
123
119
            List<String> *interval_list,
124
 
            const CHARSET_INFO * const cs,
 
120
            const charset_info_st*,
125
121
            uint32_t uint_geom_type,
126
 
            enum column_format_type column_format);
 
122
            column_format_type column_format);
 
123
 
 
124
  bool setDefaultValue(Item *default_value, Item *on_update_item);
127
125
};
128
126
 
 
127
std::ostream& operator<<(std::ostream&, const CreateField&);
 
128
 
129
129
} /* namespace drizzled */
130
130
 
131
 
#endif /* DRIZZLED_CREATE_FIELD_H */