~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table_proto_write.cc

  • Committer: Brian Aker
  • Date: 2009-11-12 16:13:04 UTC
  • mfrom: (1211.1.7 staging)
  • Revision ID: brian@gaz-20091112161304-opamiauv36fg0n6u
Rollup of Brian, Padraig, and Stewart patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
        if (field_arg->decimals != NOT_FIXED_DEC)
85
85
        {
86
86
          drizzled::message::Table::Field::NumericFieldOptions *numeric_field_options;
87
 
          
 
87
 
88
88
          numeric_field_options= attribute->mutable_numeric_options();
89
 
          /* 
90
 
           * Precision and scale are specified like so:
91
 
           *
92
 
           * DOUBLE(P,S)
93
 
           *
94
 
           * From the CreateField, we get the "length", which is the *total* length
95
 
           * of the double storage space, including the decimal point if there is a
96
 
           * scale argument and a 1 byte length header.  We also get the "decimals", 
97
 
           * which is actually the scale (the number of numbers stored after the decimal point)
98
 
           *
99
 
           * Therefore, PRECISION= LENGTH - 1 - (SCALE ? SCALE + 1 : 0)
100
 
           */
101
 
          if (field_arg->decimals)
102
 
            numeric_field_options->set_precision(field_arg->length - 2); /* One for the decimal, one for the header */
103
 
          else
104
 
            numeric_field_options->set_precision(field_arg->length - 1); /* for the header */
 
89
 
 
90
          numeric_field_options->set_precision(field_arg->length);
105
91
          numeric_field_options->set_scale(field_arg->decimals);
106
92
        }
107
93
      }
133
119
 
134
120
        break;
135
121
      }
136
 
    case DRIZZLE_TYPE_NEWDECIMAL:
 
122
    case DRIZZLE_TYPE_DECIMAL:
137
123
      {
138
124
        message::Table::Field::NumericFieldOptions *numeric_field_options;
139
125
 
287
273
      }
288
274
    }
289
275
 
 
276
    if (field_arg->sql_type != DRIZZLE_TYPE_DECIMAL
 
277
        && field_arg->sql_type != DRIZZLE_TYPE_DOUBLE)
290
278
    {
291
279
      message::Table::Field::FieldOptions *field_options;
292
280
      field_options= attribute->mutable_options();