~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_load.cc

  • Committer: Brian Aker
  • Date: 2010-10-21 08:55:44 UTC
  • mto: (1866.1.1 merge)
  • mto: This revision was merged to the branch mainline in revision 1867.
  • Revision ID: brian@tangent.org-20101021085544-chpce06zm4tdaqdi
This creates a function for seeing which catalog you are in. It also
refactors some of the functions to be in the utility_function collect.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
  */
76
76
  void end_io_cache()
77
77
  {
78
 
    cache.end_io_cache();
 
78
    internal::end_io_cache(&cache);
79
79
    need_end_io_cache = 0;
80
80
  }
81
81
 
130
130
  String *field_term=ex->field_term,*escaped=ex->escaped;
131
131
  String *enclosed=ex->enclosed;
132
132
  bool is_fifo=0;
133
 
 
134
 
  assert(table_list->getSchemaName()); // This should never be null
135
 
 
 
133
  char *db= table_list->db;                     // This is never null
 
134
  assert(db);
136
135
  /*
137
136
    If path for cursor is not defined, we will use the current database.
138
137
    If this is not set, we will use the directory where the table to be
139
138
    loaded is located
140
139
  */
141
 
  util::string::const_shared_ptr schema(session->schema());
142
 
  const char *tdb= (schema and not schema->empty()) ? schema->c_str() : table_list->getSchemaName(); // Result should never be null
 
140
  const char *tdb= session->db.empty() ? db  : session->db.c_str();             // Result is never null
143
141
  assert(tdb);
144
142
  uint32_t skip_lines= ex->skip_lines;
145
143
  bool transactional_table;
146
 
  Session::killed_state_t killed_status= Session::NOT_KILLED;
 
144
  Session::killed_state killed_status= Session::NOT_KILLED;
147
145
 
148
146
  /* Escape and enclosed character may be a utf8 4-byte character */
149
147
  if (escaped->length() > 4 || enclosed->length() > 4)
171
169
  */
172
170
  if (unique_table(table_list, table_list->next_global))
173
171
  {
174
 
    my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->getTableName());
 
172
    my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name);
175
173
    return(true);
176
174
  }
177
175
 
206
204
    */
207
205
    if (table->timestamp_field)
208
206
    {
209
 
      if (table->isWriteSet(table->timestamp_field->position()))
210
 
      {
 
207
      if (table->isWriteSet(table->timestamp_field->field_index))
211
208
        table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
212
 
      }
213
209
      else
214
210
      {
215
 
        table->setWriteSet(table->timestamp_field->position());
 
211
        table->setWriteSet(table->timestamp_field->field_index);
216
212
      }
217
213
    }
218
214
    /* Fix the expressions in SET clause */
319
315
  info.handle_duplicates=handle_duplicates;
320
316
  info.escape_char=escaped->length() ? (*escaped)[0] : INT_MAX;
321
317
 
322
 
  SchemaIdentifier identifier(*schema);
 
318
  SchemaIdentifier identifier(session->db);
323
319
  READ_INFO read_info(file, tot_length,
324
320
                      ex->cs ? ex->cs : plugin::StorageEngine::getSchemaCollation(identifier),
325
321
                      *field_term, *ex->line_start, *ex->line_term, *enclosed,
393
389
     simulated killing in the middle of per-row loop
394
390
     must be effective for binlogging
395
391
  */
396
 
  killed_status= (error == 0)? Session::NOT_KILLED : session->getKilled();
 
392
  killed_status= (error == 0)? Session::NOT_KILLED : session->killed;
397
393
  if (error)
398
394
  {
399
395
    error= -1;                          // Error on read
439
435
 
440
436
  while (!read_info.read_fixed_length())
441
437
  {
442
 
    if (session->getKilled())
 
438
    if (session->killed)
443
439
    {
444
440
      session->send_kill_message();
445
441
      return(1);
457
453
    }
458
454
    it.rewind();
459
455
    unsigned char *pos=read_info.row_start;
460
 
#ifdef HAVE_VALGRIND
 
456
#ifdef HAVE_purify
461
457
    read_info.row_end[0]=0;
462
458
#endif
463
459
 
512
508
                          ER(ER_WARN_TOO_MANY_RECORDS), session->row_count);
513
509
    }
514
510
 
515
 
    if (session->getKilled() ||
 
511
    if (session->killed ||
516
512
        fill_record(session, set_fields, set_values,
517
513
                    ignore_check_option_errors))
518
514
      return(1);
561
557
 
562
558
  for (;;it.rewind())
563
559
  {
564
 
    if (session->getKilled())
 
560
    if (session->killed)
565
561
    {
566
562
      session->send_kill_message();
567
563
      return(1);
694
690
      }
695
691
    }
696
692
 
697
 
    if (session->getKilled() ||
 
693
    if (session->killed ||
698
694
        fill_record(session, set_fields, set_values,
699
695
                    ignore_check_option_errors))
700
696
      return(1);
715
711
      push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
716
712
                          ER_WARN_TOO_MANY_RECORDS, ER(ER_WARN_TOO_MANY_RECORDS),
717
713
                          session->row_count);
718
 
      if (session->getKilled())
 
714
      if (session->killed)
719
715
        return(1);
720
716
    }
721
717
    session->row_count++;
798
794
  else
799
795
  {
800
796
    end_of_buff=buffer+buff_length;
801
 
    if (cache.init_io_cache((false) ? -1 : cursor, 0,
802
 
                            (false) ? internal::READ_NET :
803
 
                            (is_fifo ? internal::READ_FIFO : internal::READ_CACHE),0L,1,
804
 
                            MYF(MY_WME)))
 
797
    if (init_io_cache(&cache,(false) ? -1 : cursor, 0,
 
798
                      (false) ? internal::READ_NET :
 
799
                      (is_fifo ? internal::READ_FIFO : internal::READ_CACHE),0L,1,
 
800
                      MYF(MY_WME)))
805
801
    {
806
802
      free((unsigned char*) buffer);
807
803
      error=1;
824
820
  if (!error)
825
821
  {
826
822
    if (need_end_io_cache)
827
 
      cache.end_io_cache();
 
823
      internal::end_io_cache(&cache);
828
824
    free(buffer);
829
825
    error=1;
830
826
  }