~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table_proto_write.cc

  • Committer: Stewart Smith
  • Author(s): stewart at flamingspork
  • Date: 2009-11-16 02:35:02 UTC
  • mto: (1220.1.11 staging)
  • mto: This revision was merged to the branch mainline in revision 1222.
  • Revision ID: stewart@flamingspork.com-20091116023502-jvwjd7hqy1p8ket8
[patch 02/17] field NULL | NOT NULL in proto in parser. Only for CREATE TABLE. Change default in proto to reflect default in SQL.

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
  {
61
61
    message::Table::Field *attribute;
62
62
 
 
63
    /* some (one) code path for CREATE TABLE fills the proto
 
64
       out more than the others, so we already have partially
 
65
       filled out Field messages */
 
66
 
63
67
    if (use_existing_fields)
64
68
      attribute= table_proto->mutable_field(field_number++);
65
69
    else
 
70
    {
 
71
      /* Other code paths still have to fill out the proto */
66
72
      attribute= table_proto->add_field();
67
73
 
 
74
      if(field_arg->flags & NOT_NULL_FLAG)
 
75
      {
 
76
        message::Table::Field::FieldConstraints *constraints;
 
77
 
 
78
        constraints= attribute->mutable_constraints();
 
79
        constraints->set_is_nullable(false);
 
80
      }
 
81
    }
 
82
 
 
83
    assert((!(field_arg->flags & NOT_NULL_FLAG)) == attribute->constraints().is_nullable());
 
84
 
68
85
    attribute->set_name(field_arg->field_name);
69
86
 
70
 
    if(! (field_arg->flags & NOT_NULL_FLAG))
71
 
    {
72
 
      message::Table::Field::FieldConstraints *constraints;
73
 
 
74
 
      constraints= attribute->mutable_constraints();
75
 
      constraints->set_is_nullable(true);
76
 
    }
77
 
 
78
87
    switch (field_arg->sql_type) {
79
88
    case DRIZZLE_TYPE_LONG:
80
89
      attribute->set_type(message::Table::Field::INTEGER);