~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_delete.cc

Merged in changes from Andrey.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
  bool          transactional_table, safe_update, const_cond;
44
44
  bool          const_cond_result;
45
45
  ha_rows       deleted= 0;
46
 
  uint usable_index= MAX_KEY;
 
46
  uint32_t usable_index= MAX_KEY;
47
47
  SELECT_LEX   *select_lex= &thd->lex->select_lex;
48
48
  THD::killed_state killed_status= THD::NOT_KILLED;
49
49
  
190
190
 
191
191
  if (order && order->elements)
192
192
  {
193
 
    uint         length= 0;
 
193
    uint32_t         length= 0;
194
194
    SORT_FIELD  *sortorder;
195
195
    ha_rows examined_rows;
196
196
    
419
419
extern "C" int refpos_order_cmp(void* arg, const void *a,const void *b)
420
420
{
421
421
  handler *file= (handler*)arg;
422
 
  return file->cmp_ref((const uchar*)a, (const uchar*)b);
 
422
  return file->cmp_ref((const unsigned char*)a, (const unsigned char*)b);
423
423
}
424
424
 
425
425
/*
492
492
}
493
493
 
494
494
 
495
 
multi_delete::multi_delete(TableList *dt, uint num_of_tables_arg)
 
495
multi_delete::multi_delete(TableList *dt, uint32_t num_of_tables_arg)
496
496
  : delete_tables(dt), deleted(0), found(0),
497
497
    num_of_tables(num_of_tables_arg), error(0),
498
498
    do_delete(0), transactional_tables(0), normal_tables(0), error_handled(0)
590
590
    table->no_keyread=0;
591
591
  }
592
592
 
593
 
  for (uint counter= 0; counter < num_of_tables; counter++)
 
593
  for (uint32_t counter= 0; counter < num_of_tables; counter++)
594
594
  {
595
595
    if (tempfiles[counter])
596
596
      delete tempfiles[counter];
648
648
}
649
649
 
650
650
 
651
 
void multi_delete::send_error(uint errcode,const char *err)
 
651
void multi_delete::send_error(uint32_t errcode,const char *err)
652
652
{
653
653
  
654
654
 
847
847
  char path[FN_REFLEN];
848
848
  Table *table;
849
849
  bool error;
850
 
  uint path_length;
 
850
  uint32_t path_length;
851
851
  
852
852
 
853
853
  memset(&create_info, 0, sizeof(create_info));
873
873
                                             OTM_OPEN))))
874
874
      (void) rm_temporary_table(table_type, path, frm_only);
875
875
    free_table_share(share);
876
 
    my_free((char*) table,MYF(0));
 
876
    free((char*) table);
877
877
    /*
878
878
      If we return here we will not have logged the truncation to the bin log
879
879
      and we will not my_ok() to the client.
885
885
                                    table_list->table_name, reg_ext, 0);
886
886
 
887
887
  if (!dont_send_ok)
888
 
  {
889
 
    enum legacy_db_type table_type;
890
 
    mysql_frm_type(thd, path, &table_type);
891
 
    if (table_type == DB_TYPE_UNKNOWN)
892
 
    {
893
 
      my_error(ER_NO_SUCH_TABLE, MYF(0),
894
 
               table_list->db, table_list->table_name);
895
 
      return(true);
896
 
    }
897
 
 
898
 
    if (!ha_check_storage_engine_flag(ha_resolve_by_legacy_type(thd, table_type),
899
 
                                      HTON_CAN_RECREATE))
900
 
      goto trunc_by_del;
901
 
 
902
 
    if (lock_and_wait_for_table_name(thd, table_list))
903
 
      return(true);
904
 
  }
 
888
    goto trunc_by_del;
905
889
 
906
890
  // Remove the .frm extension AIX 5.2 64-bit compiler bug (BUG#16155): this
907
891
  // crashes, replacement works.  *(path + path_length - reg_ext_length)=
908
892
  // '\0';
909
893
  path[path_length - reg_ext_length] = 0;
910
 
  VOID(pthread_mutex_lock(&LOCK_open));
 
894
  pthread_mutex_lock(&LOCK_open);
911
895
  error= ha_create_table(thd, path, table_list->db, table_list->table_name,
912
896
                         &create_info, 1);
913
 
  VOID(pthread_mutex_unlock(&LOCK_open));
 
897
  pthread_mutex_unlock(&LOCK_open);
914
898
 
915
899
end:
916
900
  if (!dont_send_ok)
924
908
      write_bin_log(thd, true, thd->query, thd->query_length);
925
909
      my_ok(thd);               // This should return record count
926
910
    }
927
 
    VOID(pthread_mutex_lock(&LOCK_open));
 
911
    pthread_mutex_lock(&LOCK_open);
928
912
    unlock_table_name(thd, table_list);
929
 
    VOID(pthread_mutex_unlock(&LOCK_open));
 
913
    pthread_mutex_unlock(&LOCK_open);
930
914
  }
931
915
  else if (error)
932
916
  {
933
 
    VOID(pthread_mutex_lock(&LOCK_open));
 
917
    pthread_mutex_lock(&LOCK_open);
934
918
    unlock_table_name(thd, table_list);
935
 
    VOID(pthread_mutex_unlock(&LOCK_open));
 
919
    pthread_mutex_unlock(&LOCK_open);
936
920
  }
937
921
  return(error);
938
922
 
946
930
  bool save_binlog_row_based= thd->current_stmt_binlog_row_based;
947
931
  thd->clear_current_stmt_binlog_row_based();
948
932
  error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0,
949
 
                      HA_POS_ERROR, 0LL, true);
 
933
                      HA_POS_ERROR, 0L, true);
950
934
  ha_enable_transaction(thd, true);
951
935
  /*
952
936
    Safety, in case the engine ignored ha_enable_transaction(false)