~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_parse.cc

  • Committer: Mark Atwood
  • Date: 2011-10-05 15:24:11 UTC
  • mfrom: (2420.2.4 rf)
  • Revision ID: me@mark.atwood.name-20111005152411-xksdn4vulhmtz2x4
mergeĀ lp:~olafvdspek/drizzle/refactor1a

Show diffs side-by-side

added added

removed removed

Lines of Context:
696
696
    if (not unit->fake_select_lex && unit->add_fake_select_lex(lex->session))
697
697
      return true;
698
698
 
699
 
    select_lex->context.outer_context=
700
 
                unit->first_select()->context.outer_context;
 
699
    select_lex->context.outer_context= unit->first_select()->context.outer_context;
701
700
  }
702
701
 
703
702
  select_lex->master_unit()->global_parameters= select_lex;
730
729
  lex_string_t tmp;
731
730
  tmp.str= (char*) var_name;
732
731
  tmp.length=strlen(var_name);
733
 
  lex_string_t null_lex_string;
734
 
  memset(&null_lex_string.str, 0, sizeof(null_lex_string));
735
732
  /*
736
733
    We set the name of Item to @@session.var_name because that then is used
737
734
    as the column name in the output.
738
735
  */
739
 
  if (Item* var= get_system_var(session, OPT_SESSION, tmp, null_lex_string))
 
736
  if (Item* var= get_system_var(session, OPT_SESSION, tmp, null_lex_string()))
740
737
  {
741
738
    char buff[MAX_SYS_VAR_LENGTH*2+4+8];
742
739
    char *end= buff;
764
761
   * by setting the query_safe_cache param to TRUE
765
762
   */
766
763
  if (plugin::QueryCache::isCached(&session) && not plugin::QueryCache::sendCachedResultset(&session))
767
 
      return;
 
764
    return;
768
765
  Lex_input_stream lip(&session, inBuf, length);
769
766
  if (parse_sql(&session, &lip))
770
767
    assert(session.is_error());
771
768
  else if (not session.is_error())
772
769
  {
773
 
    DRIZZLE_QUERY_EXEC_START(session.getQueryString()->c_str(), session.thread_id,
774
 
                             const_cast<const char *>(session.schema()->c_str()));
 
770
    DRIZZLE_QUERY_EXEC_START(session.getQueryString()->c_str(), session.thread_id, session.schema()->c_str());
775
771
    // Implement Views here --Brian
776
772
    /* Actually execute the query */
777
773
    try
803
799
 
804
800
bool add_field_to_list(Session *session, lex_string_t *field_name, enum_field_types type,
805
801
                       const char *length, const char *decimals,
806
 
                       uint32_t type_modifier,
807
 
                       enum column_format_type column_format,
808
 
                       Item *default_value, Item *on_update_value,
809
 
                       lex_string_t *comment,
810
 
                       const char *change,
811
 
                       List<String> *interval_list, const charset_info_st * const cs)
 
802
                       uint32_t type_modifier, column_format_type column_format,
 
803
                       Item *default_value, Item *on_update_value, lex_string_t *comment,
 
804
                       const char *change, List<String> *interval_list, const charset_info_st* cs)
812
805
{
813
 
  register CreateField *new_field;
814
806
  LEX  *lex= &session->lex();
815
807
  statement::AlterTable *statement= (statement::AlterTable *)lex->statement;
816
808
 
819
811
 
820
812
  if (type_modifier & PRI_KEY_FLAG)
821
813
  {
822
 
    Key *key;
823
814
    lex->col_list.push_back(new Key_part_spec(*field_name, 0));
824
 
    key= new Key(Key::PRIMARY, null_lex_string(),
825
 
                      &default_key_create_info,
826
 
                      0, lex->col_list);
827
 
    statement->alter_info.key_list.push_back(key);
 
815
    statement->alter_info.key_list.push_back(new Key(Key::PRIMARY, null_lex_string(), &default_key_create_info, 0, lex->col_list));
828
816
    lex->col_list.clear();
829
817
  }
830
818
  if (type_modifier & (UNIQUE_FLAG | UNIQUE_KEY_FLAG))
831
819
  {
832
 
    Key *key;
833
820
    lex->col_list.push_back(new Key_part_spec(*field_name, 0));
834
 
    key= new Key(Key::UNIQUE, null_lex_string(),
835
 
                 &default_key_create_info, 0,
836
 
                 lex->col_list);
837
 
    statement->alter_info.key_list.push_back(key);
 
821
    statement->alter_info.key_list.push_back(new Key(Key::UNIQUE, null_lex_string(), &default_key_create_info, 0, lex->col_list));
838
822
    lex->col_list.clear();
839
823
  }
840
824
 
859
843
      default_value= 0;
860
844
      if ((type_modifier & (NOT_NULL_FLAG | AUTO_INCREMENT_FLAG)) == NOT_NULL_FLAG)
861
845
      {
862
 
        my_error(ER_INVALID_DEFAULT, MYF(0), field_name->str);
863
 
        return true;
 
846
        my_error(ER_INVALID_DEFAULT, MYF(0), field_name->str);
 
847
        return true;
864
848
      }
865
849
    }
866
850
    else if (type_modifier & AUTO_INCREMENT_FLAG)
876
860
    return true;
877
861
  }
878
862
 
879
 
  new_field= new CreateField;
880
 
  if (new_field->init(session, field_name->str, type, length, decimals,
881
 
                         type_modifier, comment, change, interval_list, cs, 0, column_format)
 
863
  CreateField* new_field= new CreateField;
 
864
  if (new_field->init(session, field_name->str, type, length, decimals, type_modifier, *comment, change, interval_list, cs, 0, column_format)
882
865
      || new_field->setDefaultValue(default_value, on_update_value))
883
866
    return true;
884
867
 
932
915
  if (not table->is_derived_table() && table->db.str)
933
916
  {
934
917
    my_casedn_str(files_charset_info, table->db.str);
935
 
 
936
 
    identifier::Schema schema_identifier(string(table->db.str));
937
 
    if (not schema::check(*session, schema_identifier))
 
918
    if (not schema::check(*session, identifier::Schema(table->db.str)))
938
919
    {
939
920
      my_error(ER_WRONG_DB_NAME, MYF(0), table->db.str);
940
921
      return NULL;
948
929
      my_message(ER_DERIVED_MUST_HAVE_ALIAS, ER(ER_DERIVED_MUST_HAVE_ALIAS), MYF(0));
949
930
      return NULL;
950
931
    }
951
 
    alias_str= (char*) session->mem.memdup(alias_str,table->table.length+1);
 
932
    alias_str= (char*) session->mem.memdup(alias_str, table->table.length+1);
952
933
  }
953
934
  TableList *ptr = (TableList *) session->mem.calloc(sizeof(TableList));
954
935