---
 drizzled/sql_yacc.yy          |  135 +++++++++++++++++++++++++++++++++++++++---
 drizzled/table_proto_write.cc |    5 +
 2 files changed, 132 insertions(+), 8 deletions(-)

Index: pandora-build/drizzled/sql_yacc.yy
===================================================================
--- pandora-build.orig/drizzled/sql_yacc.yy     2009-11-04 15:40:20.351683729 
+1100
+++ pandora-build/drizzled/sql_yacc.yy  2009-11-04 17:10:53.091674803 +1100
@@ -1576,56 +1576,173 @@ type:
         { 
           $$=$1; 
           Lex->length=(char*) 0; /* use default length */
+
+          statement::CreateTable *statement=
+            (statement::CreateTable *)Lex->statement;
+
+          if (statement->current_proto_field)
+          {
+            if ($1 == DRIZZLE_TYPE_LONG)
+              
statement->current_proto_field->set_type(message::Table::Field::INTEGER);
+            else if ($1 == DRIZZLE_TYPE_LONGLONG)
+              
statement->current_proto_field->set_type(message::Table::Field::BIGINT);
+            else
+              abort();
+          }
         }
-        | real_type opt_precision { $$=$1; }
+        | real_type opt_precision
+          {
+            $$=$1;
+
+            statement::CreateTable *statement=
+              (statement::CreateTable *)Lex->statement;
+
+            if (statement->current_proto_field)
+            {
+              assert ($1 == DRIZZLE_TYPE_DOUBLE);
+              
statement->current_proto_field->set_type(message::Table::Field::DOUBLE);
+            }
+          }
         | char '(' NUM ')' opt_binary
           {
             Lex->length=$3.str;
             $$=DRIZZLE_TYPE_VARCHAR;
+
+            statement::CreateTable *statement=
+              (statement::CreateTable *)Lex->statement;
+
+            if (statement->current_proto_field)
+              
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
           }
         | char opt_binary
           {
             Lex->length=(char*) "1";
             $$=DRIZZLE_TYPE_VARCHAR;
+
+            statement::CreateTable *statement=
+              (statement::CreateTable *)Lex->statement;
+
+            if (statement->current_proto_field)
+              
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
           }
         | varchar '(' NUM ')' opt_binary
           {
             Lex->length=$3.str;
             $$= DRIZZLE_TYPE_VARCHAR;
+
+            statement::CreateTable *statement=
+              (statement::CreateTable *)Lex->statement;
+
+            if (statement->current_proto_field)
+              
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
           }
         | VARBINARY '(' NUM ')'
           {
             Lex->length=$3.str;
             Lex->charset=&my_charset_bin;
             $$= DRIZZLE_TYPE_VARCHAR;
+
+            statement::CreateTable *statement=
+              (statement::CreateTable *)Lex->statement;
+
+            if (statement->current_proto_field)
+              
statement->current_proto_field->set_type(message::Table::Field::VARCHAR);
           }
         | DATE_SYM
-          { $$=DRIZZLE_TYPE_DATE; }
+          {
+            $$=DRIZZLE_TYPE_DATE;
+
+            statement::CreateTable *statement=
+              (statement::CreateTable *)Lex->statement;
+
+            if (statement->current_proto_field)
+              
statement->current_proto_field->set_type(message::Table::Field::DATE);
+          }
         | TIMESTAMP_SYM
-          { $$=DRIZZLE_TYPE_TIMESTAMP; }
+          {
+            $$=DRIZZLE_TYPE_TIMESTAMP;
+
+            statement::CreateTable *statement=
+              (statement::CreateTable *)Lex->statement;
+
+            if (statement->current_proto_field)
+              
statement->current_proto_field->set_type(message::Table::Field::TIMESTAMP);
+          }
         | DATETIME_SYM
-          { $$=DRIZZLE_TYPE_DATETIME; }
+          {
+            $$=DRIZZLE_TYPE_DATETIME;
+
+            statement::CreateTable *statement=
+              (statement::CreateTable *)Lex->statement;
+
+            if (statement->current_proto_field)
+              
statement->current_proto_field->set_type(message::Table::Field::DATETIME);
+          }
         | BLOB_SYM
           {
             Lex->charset=&my_charset_bin;
             $$=DRIZZLE_TYPE_BLOB;
             Lex->length=(char*) 0; /* use default length */
+
+            statement::CreateTable *statement=
+              (statement::CreateTable *)Lex->statement;
+
+            if (statement->current_proto_field)
+              
statement->current_proto_field->set_type(message::Table::Field::BLOB);
           }
         | TEXT_SYM opt_binary
           { 
             $$=DRIZZLE_TYPE_BLOB; 
             Lex->length=(char*) 0; /* use default length */
+
+            statement::CreateTable *statement=
+              (statement::CreateTable *)Lex->statement;
+
+            if (statement->current_proto_field)
+              
statement->current_proto_field->set_type(message::Table::Field::BLOB);
           }
         | DECIMAL_SYM float_options
-          { $$=DRIZZLE_TYPE_NEWDECIMAL;}
+          {
+            $$=DRIZZLE_TYPE_NEWDECIMAL;
+
+            statement::CreateTable *statement=
+              (statement::CreateTable *)Lex->statement;
+
+            if (statement->current_proto_field)
+              
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
+          }
         | NUMERIC_SYM float_options
-          { $$=DRIZZLE_TYPE_NEWDECIMAL;}
+          {
+            $$=DRIZZLE_TYPE_NEWDECIMAL;
+
+            statement::CreateTable *statement=
+              (statement::CreateTable *)Lex->statement;
+
+            if (statement->current_proto_field)
+              
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
+          }
         | FIXED_SYM float_options
-          { $$=DRIZZLE_TYPE_NEWDECIMAL;}
+          {
+            $$=DRIZZLE_TYPE_NEWDECIMAL;
+
+            statement::CreateTable *statement=
+              (statement::CreateTable *)Lex->statement;
+
+            if (statement->current_proto_field)
+              
statement->current_proto_field->set_type(message::Table::Field::DECIMAL);
+          }
         | ENUM_SYM
           {Lex->interval_list.empty();}
           '(' string_list ')' opt_binary
-          { $$=DRIZZLE_TYPE_ENUM; }
+          {
+            $$=DRIZZLE_TYPE_ENUM;
+
+            statement::CreateTable *statement=
+              (statement::CreateTable *)Lex->statement;
+
+            if (statement->current_proto_field)
+              
statement->current_proto_field->set_type(message::Table::Field::ENUM);
+          }
         | SERIAL_SYM
           {
             $$=DRIZZLE_TYPE_LONGLONG;
@@ -1637,6 +1754,8 @@ type:
               message::Table::Field::FieldConstraints *constraints;
               constraints= 
statement->current_proto_field->mutable_constraints();
               constraints->set_is_nullable(false);
+
+              
statement->current_proto_field->set_type(message::Table::Field::BIGINT);
             }
           }
         ;
Index: pandora-build/drizzled/table_proto_write.cc
===================================================================
--- pandora-build.orig/drizzled/table_proto_write.cc    2009-11-04 
15:42:47.741656560 +1100
+++ pandora-build/drizzled/table_proto_write.cc 2009-11-04 17:09:45.824188445 
+1100
@@ -85,6 +85,9 @@ int fill_table_proto(message::Table *tab
     assert((!(field_arg->flags & NOT_NULL_FLAG)) == 
attribute->constraints().is_nullable());
     assert(strcmp(attribute->name().c_str(), field_arg->field_name)==0);
 
+
+    message::Table::Field::FieldType parser_type= attribute->type();
+
     switch (field_arg->sql_type) {
     case DRIZZLE_TYPE_LONG:
       attribute->set_type(message::Table::Field::INTEGER);
@@ -196,6 +199,8 @@ int fill_table_proto(message::Table *tab
       assert(0); /* Tell us, since this shouldn't happend */
     }
 
+    assert (!use_existing_fields || parser_type == attribute->type());
+
 #ifdef NOTDONE
     field_constraints= attribute->mutable_constraints();
     constraints->set_is_nullable(field_arg->def->null_value);

-- 
Stewart Smith

_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help   : https://help.launchpad.net/ListHelp

Reply via email to