~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_delete.cc

  • Committer: Stewart Smith
  • Date: 2008-09-25 10:04:06 UTC
  • mto: This revision was merged to the branch mainline in revision 408.
  • Revision ID: stewart@flamingspork.com-20080925100406-hld92f4dr4nuar3a
Move compression functions (compress, uncompress and compressed_length) out into modules and fix test

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
 
  uint32_t usable_index= MAX_KEY;
 
46
  uint 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
 
    uint32_t         length= 0;
 
193
    uint         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 unsigned char*)a, (const unsigned char*)b);
 
422
  return file->cmp_ref((const uchar*)a, (const uchar*)b);
423
423
}
424
424
 
425
425
/*
492
492
}
493
493
 
494
494
 
495
 
multi_delete::multi_delete(TableList *dt, uint32_t num_of_tables_arg)
 
495
multi_delete::multi_delete(TableList *dt, uint 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 (uint32_t counter= 0; counter < num_of_tables; counter++)
 
593
  for (uint 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(uint32_t errcode,const char *err)
 
651
void multi_delete::send_error(uint 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
 
  uint32_t path_length;
 
850
  uint 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
 
    free((char*) table);
 
876
    my_free((char*) table,MYF(0));
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
 
    goto trunc_by_del;
 
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
  }
889
905
 
890
906
  // Remove the .frm extension AIX 5.2 64-bit compiler bug (BUG#16155): this
891
907
  // crashes, replacement works.  *(path + path_length - reg_ext_length)=
892
908
  // '\0';
893
909
  path[path_length - reg_ext_length] = 0;
894
 
  pthread_mutex_lock(&LOCK_open);
 
910
  VOID(pthread_mutex_lock(&LOCK_open));
895
911
  error= ha_create_table(thd, path, table_list->db, table_list->table_name,
896
912
                         &create_info, 1);
897
 
  pthread_mutex_unlock(&LOCK_open);
 
913
  VOID(pthread_mutex_unlock(&LOCK_open));
898
914
 
899
915
end:
900
916
  if (!dont_send_ok)
908
924
      write_bin_log(thd, true, thd->query, thd->query_length);
909
925
      my_ok(thd);               // This should return record count
910
926
    }
911
 
    pthread_mutex_lock(&LOCK_open);
 
927
    VOID(pthread_mutex_lock(&LOCK_open));
912
928
    unlock_table_name(thd, table_list);
913
 
    pthread_mutex_unlock(&LOCK_open);
 
929
    VOID(pthread_mutex_unlock(&LOCK_open));
914
930
  }
915
931
  else if (error)
916
932
  {
917
 
    pthread_mutex_lock(&LOCK_open);
 
933
    VOID(pthread_mutex_lock(&LOCK_open));
918
934
    unlock_table_name(thd, table_list);
919
 
    pthread_mutex_unlock(&LOCK_open);
 
935
    VOID(pthread_mutex_unlock(&LOCK_open));
920
936
  }
921
937
  return(error);
922
938
 
930
946
  bool save_binlog_row_based= thd->current_stmt_binlog_row_based;
931
947
  thd->clear_current_stmt_binlog_row_based();
932
948
  error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0,
933
 
                      HA_POS_ERROR, 0L, true);
 
949
                      HA_POS_ERROR, 0LL, true);
934
950
  ha_enable_transaction(thd, true);
935
951
  /*
936
952
    Safety, in case the engine ignored ha_enable_transaction(false)