~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table_proto_write.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:
73
73
       filled out Field messages */
74
74
 
75
75
    if (use_existing_fields)
 
76
    {
76
77
      attribute= table_proto.mutable_field(field_number++);
 
78
    }
77
79
    else
78
80
    {
79
81
      /* Other code paths still have to fill out the proto */
81
83
 
82
84
      if (field_arg->flags & NOT_NULL_FLAG)
83
85
      {
84
 
        message::Table::Field::FieldConstraints *constraints;
 
86
        attribute->mutable_constraints()->set_is_nullable(false);
 
87
      }
 
88
      else
 
89
      {
 
90
        attribute->mutable_constraints()->set_is_nullable(true);
 
91
      }
85
92
 
86
 
        constraints= attribute->mutable_constraints();
87
 
        constraints->set_is_nullable(false);
 
93
      if (field_arg->flags & UNSIGNED_FLAG and 
 
94
          (field_arg->sql_type == DRIZZLE_TYPE_LONGLONG or field_arg->sql_type == DRIZZLE_TYPE_LONG))
 
95
      {
 
96
        field_arg->sql_type= DRIZZLE_TYPE_LONGLONG;
 
97
        attribute->mutable_constraints()->set_is_unsigned(true);
88
98
      }
89
99
 
90
100
      attribute->set_name(field_arg->field_name);
102
112
      return -1;
103
113
    }
104
114
 
 
115
    if (field_arg->flags & UNSIGNED_FLAG and 
 
116
       (field_arg->sql_type == DRIZZLE_TYPE_LONGLONG or field_arg->sql_type == DRIZZLE_TYPE_LONG))
 
117
    {
 
118
      message::Table::Field::FieldConstraints *constraints= attribute->mutable_constraints();
 
119
 
 
120
      field_arg->sql_type= DRIZZLE_TYPE_LONGLONG;
 
121
      constraints->set_is_unsigned(true);
 
122
 
 
123
      if (field_arg->flags & NOT_NULL_FLAG)
 
124
      {
 
125
        constraints->set_is_nullable(false);
 
126
      }
 
127
      else
 
128
      {
 
129
        constraints->set_is_nullable(true);
 
130
      }
 
131
    }
 
132
 
105
133
    attribute->set_type(message::internalFieldTypeToFieldProtoType(field_arg->sql_type));
106
134
 
107
135
    switch (attribute->type()) {