~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/sql_load.cc

  • Committer: Brian Aker
  • Date: 2008-07-10 19:37:55 UTC
  • mfrom: (51.1.67 remove-dbug)
  • Revision ID: brian@tangent.org-20080710193755-f5g761uieqa3wxmt
Merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
135
135
      read_file_from_client - is this LOAD DATA LOCAL ?
136
136
 
137
137
  RETURN VALUES
138
 
    TRUE - error / FALSE - success
 
138
    true - error / false - success
139
139
*/
140
140
 
141
141
int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
167
167
  {
168
168
    my_message(ER_WRONG_FIELD_TERMINATORS,ER(ER_WRONG_FIELD_TERMINATORS),
169
169
               MYF(0));
170
 
    return(TRUE);
 
170
    return(true);
171
171
  }
172
172
  if (open_and_lock_tables(thd, table_list))
173
 
    return(TRUE);
 
173
    return(true);
174
174
  if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context,
175
175
                                    &thd->lex->select_lex.top_join_list,
176
176
                                    table_list,
188
188
  if (unique_table(thd, table_list, table_list->next_global, 0))
189
189
  {
190
190
    my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name);
191
 
    return(TRUE);
 
191
    return(true);
192
192
  }
193
193
 
194
194
  table= table_list->table;
207
207
    */
208
208
    if (setup_fields(thd, 0, set_fields, MARK_COLUMNS_WRITE, 0, 0) ||
209
209
        setup_fields(thd, 0, set_values, MARK_COLUMNS_READ, 0, 0))
210
 
      return(TRUE);
 
210
      return(true);
211
211
  }
212
212
  else
213
213
  {                                             // Part field list
215
215
    if (setup_fields(thd, 0, fields_vars, MARK_COLUMNS_WRITE, 0, 0) ||
216
216
        setup_fields(thd, 0, set_fields, MARK_COLUMNS_WRITE, 0, 0) ||
217
217
        check_that_all_fields_are_given_values(thd, table, table_list))
218
 
      return(TRUE);
 
218
      return(true);
219
219
    /*
220
220
      Check whenever TIMESTAMP field with auto-set feature specified
221
221
      explicitly.
233
233
    }
234
234
    /* Fix the expressions in SET clause */
235
235
    if (setup_fields(thd, 0, set_values, MARK_COLUMNS_READ, 0, 0))
236
 
      return(TRUE);
 
236
      return(true);
237
237
  }
238
238
 
239
239
  table->mark_columns_needed_for_insert();
265
265
  {
266
266
    my_message(ER_BLOBS_AND_NO_TERMINATED,ER(ER_BLOBS_AND_NO_TERMINATED),
267
267
               MYF(0));
268
 
    return(TRUE);
 
268
    return(true);
269
269
  }
270
270
  if (use_vars && !field_term->length() && !enclosed->length())
271
271
  {
272
272
    my_error(ER_LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR, MYF(0));
273
 
    return(TRUE);
 
273
    return(true);
274
274
  }
275
275
 
276
276
  /* We can't give an error in the middle when using LOCAL files */
303
303
      {
304
304
        /* Read only allowed from within dir specified by secure_file_priv */
305
305
        my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
306
 
        return(TRUE);
 
306
        return(true);
307
307
      }
308
308
 
309
309
      struct stat stat_info;
310
310
      if (stat(name,&stat_info))
311
 
        return(TRUE);
 
311
        return(true);
312
312
 
313
313
      // if we are not in slave thread, the file must be:
314
314
      if (!thd->slave_thread &&
318
318
             (stat_info.st_mode & S_IFIFO) == S_IFIFO)))
319
319
      {
320
320
        my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), name);
321
 
        return(TRUE);
 
321
        return(true);
322
322
      }
323
323
      if ((stat_info.st_mode & S_IFIFO) == S_IFIFO)
324
324
        is_fifo = 1;
325
325
    }
326
326
    if ((file=my_open(name,O_RDONLY,MYF(MY_WME))) < 0)
327
 
      return(TRUE);
 
327
      return(true);
328
328
  }
329
329
 
330
330
  COPY_INFO info;
341
341
  {
342
342
    if  (file >= 0)
343
343
      my_close(file,MYF(0));                    // no files in net reading
344
 
    return(TRUE);                               // Can't allocate buffers
 
344
    return(true);                               // Can't allocate buffers
345
345
  }
346
346
 
347
347
  if (mysql_bin_log.is_open())
414
414
     simulated killing in the middle of per-row loop
415
415
     must be effective for binlogging
416
416
  */
417
 
  DBUG_EXECUTE_IF("simulate_kill_bug27571",
418
 
                  {
419
 
                    error=1;
420
 
                    thd->killed= THD::KILL_QUERY;
421
 
                  };);
422
417
  killed_status= (error == 0)? THD::NOT_KILLED : thd->killed;
423
418
  if (error)
424
419
  {
475
470
          (ulong) (info.records - info.copied), (ulong) thd->cuted_fields);
476
471
 
477
472
  if (thd->transaction.stmt.modified_non_trans_table)
478
 
    thd->transaction.all.modified_non_trans_table= TRUE;
 
473
    thd->transaction.all.modified_non_trans_table= true;
479
474
 
480
475
  if (mysql_bin_log.is_open())
481
476
  {
508
503
  /* ok to client sent only after binlog write and engine commit */
509
504
  my_ok(thd, info.copied + info.deleted, 0L, name);
510
505
err:
511
 
  DBUG_ASSERT(transactional_table || !(info.copied || info.deleted) ||
 
506
  assert(transactional_table || !(info.copied || info.deleted) ||
512
507
              thd->transaction.stmt.modified_non_trans_table);
513
508
  table->file->ha_release_auto_increment();
514
 
  table->auto_increment_field_not_null= FALSE;
 
509
  table->auto_increment_field_not_null= false;
515
510
  thd->abort_on_warning= 0;
516
511
  return(error);
517
512
}
529
524
      (char*)thd->lex->fname_end - (char*)thd->query,
530
525
      (duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE :
531
526
      (ignore ? LOAD_DUP_IGNORE : LOAD_DUP_ERROR),
532
 
      transactional_table, FALSE, killed_err_arg);
 
527
      transactional_table, false, killed_err_arg);
533
528
  e.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F;
534
529
  return mysql_bin_log.write(&e);
535
530
}
586
581
    {
587
582
      Field *field= sql_field->field;                  
588
583
      if (field == table->next_number_field)
589
 
        table->auto_increment_field_not_null= TRUE;
 
584
        table->auto_increment_field_not_null= true;
590
585
      /*
591
586
        No fields specified in fields_vars list can be null in this format.
592
587
        Mark field as not null, we should do this for each row because of
631
626
      return(1);
632
627
 
633
628
    err= write_record(thd, table, &info);
634
 
    table->auto_increment_field_not_null= FALSE;
 
629
    table->auto_increment_field_not_null= false;
635
630
    if (err)
636
631
      return(1);
637
632
   
743
738
        field->set_notnull();
744
739
        read_info.row_end[0]=0;                 // Safe to change end marker
745
740
        if (field == table->next_number_field)
746
 
          table->auto_increment_field_not_null= TRUE;
 
741
          table->auto_increment_field_not_null= true;
747
742
        field->store((char*) pos, length, read_info.read_charset);
748
743
      }
749
744
      else if (item->type() == Item::STRING_ITEM)
813
808
      return(1);
814
809
 
815
810
    err= write_record(thd, table, &info);
816
 
    table->auto_increment_field_not_null= FALSE;
 
811
    table->auto_increment_field_not_null= false;
817
812
    if (err)
818
813
      return(1);
819
814
    /*
896
891
          field->reset();
897
892
          field->set_null();
898
893
          if (field == table->next_number_field)
899
 
            table->auto_increment_field_not_null= TRUE;
 
894
            table->auto_increment_field_not_null= true;
900
895
          if (!field->maybe_null())
901
896
          {
902
897
            if (field->type() == FIELD_TYPE_TIMESTAMP)
917
912
        Field *field= ((Item_field *)item)->field;
918
913
        field->set_notnull();
919
914
        if (field == table->next_number_field)
920
 
          table->auto_increment_field_not_null= TRUE;
 
915
          table->auto_increment_field_not_null= true;
921
916
        field->store((char *) tag->value.ptr(), tag->value.length(), cs);
922
917
      }
923
918
      else