~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/create_field.h

  • Committer: Mats Kindahl
  • Date: 2008-08-26 07:32:59 UTC
  • mto: (489.1.2 codestyle)
  • mto: This revision was merged to the branch mainline in revision 491.
  • Revision ID: mats@mysql.com-20080826073259-9k4evtajgldgolli
Replaced use of thd_proc_info() macro with calls to
set_proc_info() and get_proc_info() internally.  Introduced
functions set_thd_proc_info() and get_thd_proc_info() for
external users, i.e., plug-ins.

The set_thd_proc_info() accepted callers info that can be used to
print debug output, but the information was not used. The return
value was changed to void and the old value is not fetched any
more. To be able to get the value of proc_info for external
users, the function get_thd_proc_info() was introduced.

The thd_proc_info() macro called set_thd_proc_info() but almost
never used the return value of set_thd_proc_info() so the macro
was replaced with a call of THD::set_proc_info().

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008-2009 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
 
 */
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;
30
 
 
31
 
/**
32
 
 * Class representing a field in a CREATE TABLE statement.
33
 
 *
34
 
 * Basically, all information for a new or altered field
35
 
 * definition is contained in the Create_field class.
36
 
 */
37
 
class CreateField :public memory::SqlAlloc
38
 
{
39
 
public:
40
 
  const char *field_name; /**< Name of the field to be created */
41
 
  const char *change; /**< If done with alter table */
42
 
  const char *after; /**< Put this new Field after this Field */
43
 
  LEX_STRING comment; /**< A comment for this field */
44
 
  Item *def; /**< Default value for the new field */
45
 
  enum enum_field_types sql_type; /**< The data type of the new field */
46
 
  /**
47
 
   * At various stages in execution this can be length of field in bytes or
48
 
   * max number of characters.
49
 
   */
50
 
  uint32_t length;
51
 
  /**
52
 
   * The value of `length' as set by parser: is the number of characters
53
 
   * for most of the types, or of bytes for BLOBs or numeric types.
54
 
   */
55
 
  uint32_t char_length;
56
 
  uint32_t decimals;
57
 
  uint32_t flags;
58
 
  uint32_t pack_length;
59
 
  uint32_t key_length;
60
 
  Field::utype unireg_check; /**< See Field::unireg_check */
61
 
  TYPELIB *interval; /**< Which interval to use (ENUM types..) */
62
 
  List<String> interval_list;
63
 
  const CHARSET_INFO *charset; /**< Character set for the column -- @TODO should be deleted */
64
 
  Field *field; // For alter table
65
 
 
66
 
  uint8_t interval_id;  // For rea_create_table
67
 
  uint32_t offset;
68
 
 
69
 
  CreateField() :after(0) {}
70
 
  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
 
  void create_length_to_internal_length(void);
75
 
 
76
 
  inline enum column_format_type column_format() const
77
 
  {
78
 
    return (enum column_format_type)
79
 
      ((flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK);
80
 
  }
81
 
 
82
 
  /**
83
 
   * Init for a tmp table field. To be extended if need be. 
84
 
   *
85
 
   * @note This is currently ONLY used in Item_sum_distinct::setup()
86
 
   */
87
 
  void init_for_tmp_table(enum_field_types sql_type_arg,
88
 
                          uint32_t max_length,
89
 
                          uint32_t decimals,
90
 
                          bool maybe_null);
91
 
 
92
 
  /**
93
 
    Initialize field definition for create.
94
 
 
95
 
    @param session                   Thread handle
96
 
    @param fld_name              Field name
97
 
    @param fld_type              Field type
98
 
    @param fld_length            Field length
99
 
    @param fld_decimals          Decimal (if any)
100
 
    @param fld_type_modifier     Additional type information
101
 
    @param fld_default_value     Field default value (if any)
102
 
    @param fld_on_update_value   The value of ON UPDATE clause
103
 
    @param fld_comment           Field comment
104
 
    @param fld_change            Field change
105
 
    @param fld_interval_list     Interval list (if any)
106
 
    @param fld_charset           Field charset
107
 
 
108
 
    @retval
109
 
      false on success
110
 
    @retval
111
 
      true  on error
112
 
  */
113
 
  bool init(Session *session,
114
 
            char *field_name,
115
 
            enum_field_types type,
116
 
            char *length,
117
 
            char *decimals,
118
 
            uint32_t type_modifier,
119
 
            Item *default_value,
120
 
            Item *on_update_value,
121
 
            LEX_STRING *comment,
122
 
            char *change,
123
 
            List<String> *interval_list,
124
 
            const CHARSET_INFO * const cs,
125
 
            uint32_t uint_geom_type,
126
 
            enum column_format_type column_format);
127
 
};
128
 
 
129
 
} /* namespace drizzled */
130
 
 
131
 
#endif /* DRIZZLED_CREATE_FIELD_H */