~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_load.cc

  • Committer: Patrick Crews
  • Date: 2010-12-07 20:02:50 UTC
  • Revision ID: gleebix@gmail.com-20101207200250-6a27jgqalgw5bsb5
Added disabled.def file to disable drizzleslap due to Bug#684269.  Need to skip for tarball release this round

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
/* Copy data from a textfile to table */
18
18
 
19
19
#include "config.h"
20
 
 
21
20
#include <drizzled/sql_load.h>
22
21
#include <drizzled/error.h>
23
22
#include <drizzled/data_home.h>
24
23
#include <drizzled/session.h>
25
24
#include <drizzled/sql_base.h>
26
 
#include <drizzled/field/epoch.h>
 
25
#include <drizzled/field/timestamp.h>
27
26
#include "drizzled/internal/my_sys.h"
28
27
#include "drizzled/internal/iocache.h"
29
28
#include <drizzled/db.h>
30
 
#include "drizzled/plugin/storage_engine.h"
31
29
 
32
30
#include <sys/stat.h>
33
31
#include <fcntl.h>
83
81
 
84
82
  /*
85
83
    Either this method, or we need to make cache public
86
 
    Arg must be set from load() since constructor does not see
 
84
    Arg must be set from mysql_load() since constructor does not see
87
85
    either the table or Session value
88
86
  */
89
87
  void set_io_cache_arg(void* arg) { cache.arg = arg; }
105
103
  Execute LOAD DATA query
106
104
 
107
105
  SYNOPSYS
108
 
    load()
 
106
    mysql_load()
109
107
      session - current thread
110
108
      ex  - file_exchange object representing source cursor and its parsing rules
111
109
      table_list  - list of tables to which we are loading data
121
119
    true - error / false - success
122
120
*/
123
121
 
124
 
int load(Session *session,file_exchange *ex,TableList *table_list,
 
122
int mysql_load(Session *session,file_exchange *ex,TableList *table_list,
125
123
                List<Item> &fields_vars, List<Item> &set_fields,
126
124
                List<Item> &set_values,
127
125
                enum enum_duplicates handle_duplicates, bool ignore)
140
138
    If this is not set, we will use the directory where the table to be
141
139
    loaded is located
142
140
  */
143
 
  util::string::const_shared_ptr schema(session->schema());
144
 
  const char *tdb= (schema and not schema->empty()) ? schema->c_str() : table_list->getSchemaName(); // Result should never be null
 
141
  const char *tdb= session->db.empty() ? table_list->getSchemaName()  : session->db.c_str();            // Result is never null
145
142
  assert(tdb);
146
143
  uint32_t skip_lines= ex->skip_lines;
147
144
  bool transactional_table;
208
205
    */
209
206
    if (table->timestamp_field)
210
207
    {
211
 
      if (table->isWriteSet(table->timestamp_field->position()))
212
 
      {
 
208
      if (table->isWriteSet(table->timestamp_field->field_index))
213
209
        table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
214
 
      }
215
210
      else
216
211
      {
217
 
        table->setWriteSet(table->timestamp_field->position());
 
212
        table->setWriteSet(table->timestamp_field->field_index);
218
213
      }
219
214
    }
220
215
    /* Fix the expressions in SET clause */
321
316
  info.handle_duplicates=handle_duplicates;
322
317
  info.escape_char=escaped->length() ? (*escaped)[0] : INT_MAX;
323
318
 
324
 
  identifier::Schema identifier(*schema);
 
319
  SchemaIdentifier identifier(session->db);
325
320
  READ_INFO read_info(file, tot_length,
326
321
                      ex->cs ? ex->cs : plugin::StorageEngine::getSchemaCollation(identifier),
327
322
                      *field_term, *ex->line_start, *ex->line_term, *enclosed,
367
362
    table->cursor->ha_start_bulk_insert((ha_rows) 0);
368
363
    table->copy_blobs=1;
369
364
 
370
 
    session->setAbortOnWarning(true);
 
365
    session->abort_on_warning= true;
371
366
 
372
367
    if (!field_term->length() && !enclosed->length())
373
368
      error= read_fixed_length(session, info, table_list, fields_vars,
416
411
              session->transaction.stmt.hasModifiedNonTransData());
417
412
  table->cursor->ha_release_auto_increment();
418
413
  table->auto_increment_field_not_null= false;
419
 
  session->setAbortOnWarning(false);
420
 
 
 
414
  session->abort_on_warning= 0;
421
415
  return(error);
422
416
}
423
417
 
487
481
        push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
488
482
                            ER_WARN_TOO_FEW_RECORDS,
489
483
                            ER(ER_WARN_TOO_FEW_RECORDS), session->row_count);
490
 
 
491
 
        if (not field->maybe_null() and field->is_timestamp())
492
 
            ((field::Epoch::pointer) field)->set_time();
 
484
        if (!field->maybe_null() && field->type() == DRIZZLE_TYPE_TIMESTAMP)
 
485
            ((Field_timestamp*) field)->set_time();
493
486
      }
494
487
      else
495
488
      {
605
598
            return(1);
606
599
          }
607
600
          field->set_null();
608
 
          if (not field->maybe_null())
 
601
          if (!field->maybe_null())
609
602
          {
610
 
            if (field->is_timestamp())
611
 
            {
612
 
              ((field::Epoch::pointer) field)->set_time();
613
 
            }
 
603
            if (field->type() == DRIZZLE_TYPE_TIMESTAMP)
 
604
              ((Field_timestamp*) field)->set_time();
614
605
            else if (field != table->next_number_field)
615
 
            {
616
 
              field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_NULL_TO_NOTNULL, 1);
617
 
            }
 
606
              field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
607
                                 ER_WARN_NULL_TO_NOTNULL, 1);
618
608
          }
619
609
        }
620
610
        else if (item->type() == Item::STRING_ITEM)
675
665
                     session->row_count);
676
666
            return(1);
677
667
          }
678
 
          if (not field->maybe_null() and field->is_timestamp())
679
 
              ((field::Epoch::pointer) field)->set_time();
 
668
          if (!field->maybe_null() && field->type() == DRIZZLE_TYPE_TIMESTAMP)
 
669
              ((Field_timestamp*) field)->set_time();
680
670
          /*
681
671
            QQ: We probably should not throw warning for each field.
682
672
            But how about intention to always have the same number