~kentokushiba/spiderformysql/spider-2.0-src

« back to all changes in this revision

Viewing changes to spd_copy_tables.cc

  • Committer: Kentoku SHIBA
  • Date: 2011-05-12 15:25:47 UTC
  • Revision ID: kentokushiba@gmail.com-20110512152547-6hb2cvwnbg7v6ax3
2.25

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include "sql_class.h"
28
28
#include "sql_base.h"
29
29
#include "sql_partition.h"
 
30
#include "transaction.h"
30
31
#endif
31
32
#include "spd_err.h"
32
33
#include "spd_param.h"
399
400
      my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
400
401
        &table_conn, sizeof(SPIDER_COPY_TABLE_CONN),
401
402
        &tmp_share, sizeof(SPIDER_SHARE),
402
 
        &tmp_connect_info, sizeof(char *) * 15,
403
 
        &tmp_connect_info_length, sizeof(uint) * 15,
404
 
        &tmp_long, sizeof(long) * 5,
405
 
        &tmp_longlong, sizeof(longlong) * 3,
 
403
        &tmp_connect_info, sizeof(char *) * SPIDER_TMP_SHARE_CHAR_PTR_COUNT,
 
404
        &tmp_connect_info_length, sizeof(uint) * SPIDER_TMP_SHARE_UINT_COUNT,
 
405
        &tmp_long, sizeof(long) * SPIDER_TMP_SHARE_LONG_COUNT,
 
406
        &tmp_longlong, sizeof(longlong) * SPIDER_TMP_SHARE_LONGLONG_COUNT,
406
407
        NullS))
407
408
    ) {
408
409
      spider_sys_index_end(table_tables);
790
791
  int error_num, roop_count, all_link_cnt, use_table_charset;
791
792
  SPIDER_COPY_TABLES *copy_tables = NULL;
792
793
  THD *thd = current_thd;
793
 
  TABLE_LIST *table_list;
 
794
  TABLE_LIST *table_list = NULL;
794
795
  TABLE *table;
795
796
  TABLE_SHARE *table_share;
796
797
  KEY *key_info;
899
900
#if MYSQL_VERSION_ID < 50500
900
901
  if (open_and_lock_tables(thd, table_list))
901
902
#else
 
903
  table_list->mdl_request.init(
 
904
    MDL_key::TABLE,
 
905
    table_list->db,
 
906
    table_list->table_name,
 
907
    MDL_SHARED_READ,
 
908
    MDL_TRANSACTION
 
909
  );
902
910
  if (open_and_lock_tables(thd, table_list, FALSE, 0))
903
911
#endif
904
912
  {
1046
1054
  for (table_conn = copy_tables->table_conn[1];
1047
1055
    table_conn; table_conn = table_conn->next)
1048
1056
    spider_db_free_set_names(table_conn->share);
 
1057
  if (table_list->table)
 
1058
  {
 
1059
#if MYSQL_VERSION_ID < 50500
 
1060
    ha_autocommit_or_rollback(thd, 0);
 
1061
#else
 
1062
    (thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd));
 
1063
#endif
 
1064
    close_thread_tables(thd);
 
1065
  }
1049
1066
  if (spider)
1050
1067
    my_free(spider, MYF(0));
1051
1068
  spider_udf_free_copy_tables_alloc(copy_tables);
1053
1070
  DBUG_RETURN(1);
1054
1071
 
1055
1072
error_db_udf_copy_tables:
1056
 
error_free_set_names:
1057
1073
error_append_set_names:
1058
1074
  for (table_conn = copy_tables->table_conn[0];
1059
1075
    table_conn; table_conn = table_conn->next)
1062
1078
    table_conn; table_conn = table_conn->next)
1063
1079
    spider_db_free_set_names(table_conn->share);
1064
1080
error:
 
1081
  if (table_list && table_list->table)
 
1082
  {
 
1083
#if MYSQL_VERSION_ID < 50500
 
1084
    ha_autocommit_or_rollback(thd, 0);
 
1085
#else
 
1086
    (thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd));
 
1087
#endif
 
1088
    close_thread_tables(thd);
 
1089
  }
1065
1090
  if (spider)
1066
1091
  {
1067
1092
    for (roop_count = 0; roop_count < all_link_cnt; roop_count++)