~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definition/table.cc

  • Committer: Brian Aker
  • Date: 2010-12-20 19:24:24 UTC
  • mfrom: (2008.2.5 integer-refactor)
  • Revision ID: brian@tangent.org-20101220192424-iyccxsagvuw43kaz
A rather large and tasty cleanup of issues around ints, and one additional
fix for alter table.

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
#include "drizzled/field/double.h"
73
73
#include "drizzled/field/int32.h"
74
74
#include "drizzled/field/int64.h"
 
75
#include "drizzled/field/size.h"
75
76
#include "drizzled/field/num.h"
76
77
#include "drizzled/field/timestamp.h"
77
78
#include "drizzled/field/datetime.h"
1324
1325
 
1325
1326
    assert(enum_field_types_size == 12);
1326
1327
 
1327
 
    Field* f= make_field(record + field_offsets[fieldnr] + data_offset,
 
1328
    Field* f= make_field(pfield,
 
1329
                         record + field_offsets[fieldnr] + data_offset,
1328
1330
                         field_length,
1329
1331
                         pfield.constraints().is_nullable(),
1330
1332
                         null_pos,
2010
2012
  return;
2011
2013
} /* open_table_error */
2012
2014
 
 
2015
Field *TableShare::make_field(message::Table::Field &pfield,
 
2016
                              unsigned char *ptr,
 
2017
                              uint32_t field_length,
 
2018
                              bool is_nullable,
 
2019
                              unsigned char *null_pos,
 
2020
                              unsigned char null_bit,
 
2021
                              uint8_t decimals,
 
2022
                              enum_field_types field_type,
 
2023
                              const CHARSET_INFO * field_charset,
 
2024
                              Field::utype unireg_check,
 
2025
                              TYPELIB *interval,
 
2026
                              const char *field_name)
 
2027
{
 
2028
  return make_field(ptr,
 
2029
                    field_length,
 
2030
                    is_nullable,
 
2031
                    null_pos,
 
2032
                    null_bit,
 
2033
                    decimals,
 
2034
                    field_type,
 
2035
                    field_charset,
 
2036
                    unireg_check,
 
2037
                    interval,
 
2038
                    field_name,
 
2039
                    pfield.constraints().is_unsigned());
 
2040
}
 
2041
 
2013
2042
Field *TableShare::make_field(unsigned char *ptr,
2014
2043
                              uint32_t field_length,
2015
2044
                              bool is_nullable,
2020
2049
                              const CHARSET_INFO * field_charset,
2021
2050
                              Field::utype unireg_check,
2022
2051
                              TYPELIB *interval,
2023
 
                              const char *field_name)
 
2052
                              const char *field_name, 
 
2053
                              bool is_unsigned)
2024
2054
{
2025
2055
  if (! is_nullable)
2026
2056
  {
2100
2130
                                        unireg_check,
2101
2131
                                        field_name);
2102
2132
  case DRIZZLE_TYPE_LONGLONG:
2103
 
    return new (&mem_root) field::Int64(ptr,
2104
 
                                        field_length,
2105
 
                                        null_pos,
2106
 
                                        null_bit,
2107
 
                                        unireg_check,
2108
 
                                        field_name);
 
2133
    {
 
2134
      if (is_unsigned)
 
2135
      {
 
2136
        return new (&mem_root) field::Size(ptr,
 
2137
                                           field_length,
 
2138
                                           null_pos,
 
2139
                                           null_bit,
 
2140
                                           unireg_check,
 
2141
                                           field_name);
 
2142
      }
 
2143
 
 
2144
      return new (&mem_root) field::Int64(ptr,
 
2145
                                          field_length,
 
2146
                                          null_pos,
 
2147
                                          null_bit,
 
2148
                                          unireg_check,
 
2149
                                          field_name);
 
2150
    }
2109
2151
  case DRIZZLE_TYPE_TIMESTAMP:
2110
2152
    return new (&mem_root) Field_timestamp(ptr,
2111
2153
                                      field_length,