~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_insert.cc

  • Committer: Olaf van der Spek
  • Date: 2011-03-10 12:49:38 UTC
  • mto: This revision was merged to the branch mainline in revision 2233.
  • Revision ID: olafvdspek@gmail.com-20110310124938-gwhzx3pq8ueg682n
Session::lex()

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
  }
89
89
  else
90
90
  {                                             // Part field list
91
 
    Select_Lex *select_lex= &session->getLex()->select_lex;
 
91
    Select_Lex *select_lex= &session->lex().select_lex;
92
92
    Name_resolution_context *context= &select_lex->context;
93
93
    Name_resolution_context_state ctx_state;
94
94
    int res;
283
283
    if (table != NULL)
284
284
      table->cursor->ha_release_auto_increment();
285
285
    if (!joins_freed)
286
 
      free_underlaid_joins(session, &session->getLex()->select_lex);
 
286
      free_underlaid_joins(session, &session->lex().select_lex);
287
287
    session->setAbortOnWarning(false);
288
288
    DRIZZLE_INSERT_DONE(1, 0);
289
289
    return true;
292
292
  /* mysql_prepare_insert set table_list->table if it was not set */
293
293
  table= table_list->table;
294
294
 
295
 
  context= &session->getLex()->select_lex.context;
 
295
  context= &session->lex().select_lex.context;
296
296
  /*
297
297
    These three asserts test the hypothesis that the resetting of the name
298
298
    resolution context below is not necessary at all since the list of local
322
322
      if (table != NULL)
323
323
        table->cursor->ha_release_auto_increment();
324
324
      if (!joins_freed)
325
 
        free_underlaid_joins(session, &session->getLex()->select_lex);
 
325
        free_underlaid_joins(session, &session->lex().select_lex);
326
326
      session->setAbortOnWarning(false);
327
327
      DRIZZLE_INSERT_DONE(1, 0);
328
328
 
333
333
      if (table != NULL)
334
334
        table->cursor->ha_release_auto_increment();
335
335
      if (!joins_freed)
336
 
        free_underlaid_joins(session, &session->getLex()->select_lex);
 
336
        free_underlaid_joins(session, &session->lex().select_lex);
337
337
      session->setAbortOnWarning(false);
338
338
      DRIZZLE_INSERT_DONE(1, 0);
339
339
      return true;
425
425
    session->row_count++;
426
426
  }
427
427
 
428
 
  free_underlaid_joins(session, &session->getLex()->select_lex);
 
428
  free_underlaid_joins(session, &session->lex().select_lex);
429
429
  joins_freed= true;
430
430
 
431
431
  /*
485
485
    if (table != NULL)
486
486
      table->cursor->ha_release_auto_increment();
487
487
    if (!joins_freed)
488
 
      free_underlaid_joins(session, &session->getLex()->select_lex);
 
488
      free_underlaid_joins(session, &session->lex().select_lex);
489
489
    session->setAbortOnWarning(false);
490
490
    DRIZZLE_INSERT_DONE(1, 0);
491
491
    return true;
548
548
     than INSERT.
549
549
  */
550
550
 
551
 
  if (setup_tables_and_check_access(session, &session->getLex()->select_lex.context,
552
 
                                    &session->getLex()->select_lex.top_join_list,
 
551
  if (setup_tables_and_check_access(session, &session->lex().select_lex.context,
 
552
                                    &session->lex().select_lex.top_join_list,
553
553
                                    table_list,
554
 
                                    &session->getLex()->select_lex.leaf_tables,
 
554
                                    &session->lex().select_lex.leaf_tables,
555
555
                                    select_insert))
556
556
    return(true);
557
557
 
598
598
                          bool select_insert,
599
599
                          bool check_fields, bool abort_on_warning)
600
600
{
601
 
  Select_Lex *select_lex= &session->getLex()->select_lex;
 
601
  Select_Lex *select_lex= &session->lex().select_lex;
602
602
  Name_resolution_context *context= &select_lex->context;
603
603
  Name_resolution_context_state ctx_state;
604
604
  bool insert_into_view= (0 != 0);
965
965
err:
966
966
  info->last_errno= error;
967
967
  /* current_select is NULL if this is a delayed insert */
968
 
  if (session->getLex()->current_select)
969
 
    session->getLex()->current_select->no_error= 0;        // Give error
 
968
  if (session->lex().current_select)
 
969
    session->lex().current_select->no_error= 0;        // Give error
970
970
  table->print_error(error,MYF(0));
971
971
 
972
972
before_err:
1090
1090
{
1091
1091
  int res;
1092
1092
  table_map map= 0;
1093
 
  Select_Lex *lex_current_select_save= session->getLex()->current_select;
 
1093
  Select_Lex *lex_current_select_save= session->lex().current_select;
1094
1094
 
1095
1095
 
1096
1096
  unit= u;
1100
1100
    select, LEX::current_select should point to the first select while
1101
1101
    we are fixing fields from insert list.
1102
1102
  */
1103
 
  session->getLex()->current_select= &session->getLex()->select_lex;
 
1103
  session->lex().current_select= &session->lex().select_lex;
1104
1104
  res= check_insert_fields(session, table_list, *fields, values,
1105
1105
                           !insert_into_view, &map) ||
1106
1106
       setup_fields(session, 0, values, MARK_COLUMNS_READ, 0, 0);
1116
1116
 
1117
1117
  if (info.handle_duplicates == DUP_UPDATE && !res)
1118
1118
  {
1119
 
    Name_resolution_context *context= &session->getLex()->select_lex.context;
 
1119
    Name_resolution_context *context= &session->lex().select_lex.context;
1120
1120
    Name_resolution_context_state ctx_state;
1121
1121
 
1122
1122
    /* Save the state of the current name resolution context. */
1134
1134
      We use next_name_resolution_table descructively, so check it first (views?)
1135
1135
    */
1136
1136
    assert (!table_list->next_name_resolution_table);
1137
 
    if (session->getLex()->select_lex.group_list.elements == 0 and
1138
 
        not session->getLex()->select_lex.with_sum_func)
 
1137
    if (session->lex().select_lex.group_list.elements == 0 and
 
1138
        not session->lex().select_lex.with_sum_func)
1139
1139
      /*
1140
1140
        We must make a single context out of the two separate name resolution contexts :
1141
1141
        the INSERT table and the tables in the SELECT part of INSERT ... SELECT.
1160
1160
      while ((item= li++))
1161
1161
      {
1162
1162
        item->transform(&Item::update_value_transformer,
1163
 
                        (unsigned char*)session->getLex()->current_select);
 
1163
                        (unsigned char*)session->lex().current_select);
1164
1164
      }
1165
1165
    }
1166
1166
 
1168
1168
    ctx_state.restore_state(context, table_list);
1169
1169
  }
1170
1170
 
1171
 
  session->getLex()->current_select= lex_current_select_save;
 
1171
  session->lex().current_select= lex_current_select_save;
1172
1172
  if (res)
1173
1173
    return(1);
1174
1174
  /*
1184
1184
  if (unique_table(table_list, table_list->next_global))
1185
1185
  {
1186
1186
    /* Using same table for INSERT and SELECT */
1187
 
    session->getLex()->current_select->options|= OPTION_BUFFER_RESULT;
1188
 
    session->getLex()->current_select->join->select_options|= OPTION_BUFFER_RESULT;
 
1187
    session->lex().current_select->options|= OPTION_BUFFER_RESULT;
 
1188
    session->lex().current_select->join->select_options|= OPTION_BUFFER_RESULT;
1189
1189
  }
1190
 
  else if (not (session->getLex()->current_select->options & OPTION_BUFFER_RESULT))
 
1190
  else if (not (session->lex().current_select->options & OPTION_BUFFER_RESULT))
1191
1191
  {
1192
1192
    /*
1193
1193
      We must not yet prepare the result table if it is the same as one of the
1240
1240
 
1241
1241
int select_insert::prepare2(void)
1242
1242
{
1243
 
  if (session->getLex()->current_select->options & OPTION_BUFFER_RESULT)
 
1243
  if (session->lex().current_select->options & OPTION_BUFFER_RESULT)
1244
1244
    table->cursor->ha_start_bulk_insert((ha_rows) 0);
1245
1245
 
1246
1246
  return(0);