~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/slave.cc

Removed ushort references.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "rpl_rli.h"
31
31
#include "sql_repl.h"
32
32
#include "rpl_filter.h"
 
33
#include "repl_failsafe.h"
33
34
#include <mysys/thr_alarm.h>
34
35
#include <libdrizzle/sql_common.h>
35
36
#include <libdrizzle/errmsg.h>
36
37
#include <mysys/mysys_err.h>
37
38
#include <drizzled/drizzled_error_messages.h>
38
39
 
39
 
#if TIME_WITH_SYS_TIME
40
 
# include <sys/time.h>
41
 
# include <time.h>
42
 
#else
43
 
# if HAVE_SYS_TIME_H
44
 
#  include <sys/time.h>
45
 
# else
46
 
#  include <time.h>
47
 
# endif
48
 
#endif
49
 
 
50
 
 
51
40
#include "rpl_tblmap.h"
52
41
 
53
42
#define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
1195
1184
  field_list.push_back(new Item_empty_string("Until_Log_File", FN_REFLEN));
1196
1185
  field_list.push_back(new Item_return_int("Until_Log_Pos", 10,
1197
1186
                                           DRIZZLE_TYPE_LONGLONG));
 
1187
  field_list.push_back(new Item_empty_string("Master_SSL_Allowed", 7));
 
1188
  field_list.push_back(new Item_empty_string("Master_SSL_CA_File",
 
1189
                                             sizeof(mi->ssl_ca)));
 
1190
  field_list.push_back(new Item_empty_string("Master_SSL_CA_Path",
 
1191
                                             sizeof(mi->ssl_capath)));
 
1192
  field_list.push_back(new Item_empty_string("Master_SSL_Cert",
 
1193
                                             sizeof(mi->ssl_cert)));
 
1194
  field_list.push_back(new Item_empty_string("Master_SSL_Cipher",
 
1195
                                             sizeof(mi->ssl_cipher)));
 
1196
  field_list.push_back(new Item_empty_string("Master_SSL_Key",
 
1197
                                             sizeof(mi->ssl_key)));
1198
1198
  field_list.push_back(new Item_return_int("Seconds_Behind_Master", 10,
1199
1199
                                           DRIZZLE_TYPE_LONGLONG));
 
1200
  field_list.push_back(new Item_empty_string("Master_SSL_Verify_Server_Cert",
 
1201
                                             3));
1200
1202
  field_list.push_back(new Item_return_int("Last_IO_Errno", 4, DRIZZLE_TYPE_LONG));
1201
1203
  field_list.push_back(new Item_empty_string("Last_IO_Error", 20));
1202
1204
  field_list.push_back(new Item_return_int("Last_SQL_Errno", 4, DRIZZLE_TYPE_LONG));
1262
1264
    protocol->store(mi->rli.until_log_name, &my_charset_bin);
1263
1265
    protocol->store((uint64_t) mi->rli.until_log_pos);
1264
1266
 
 
1267
    protocol->store(mi->ssl? "Ignored":"No", &my_charset_bin);
 
1268
    protocol->store(mi->ssl_ca, &my_charset_bin);
 
1269
    protocol->store(mi->ssl_capath, &my_charset_bin);
 
1270
    protocol->store(mi->ssl_cert, &my_charset_bin);
 
1271
    protocol->store(mi->ssl_cipher, &my_charset_bin);
 
1272
    protocol->store(mi->ssl_key, &my_charset_bin);
 
1273
 
1265
1274
    /*
1266
1275
      Seconds_Behind_Master: if SQL thread is running and I/O thread is
1267
1276
      connected, we can compute it otherwise show NULL (i.e. unknown).
1298
1307
    {
1299
1308
      protocol->store_null();
1300
1309
    }
 
1310
    protocol->store(mi->ssl_verify_server_cert? "Yes":"No", &my_charset_bin);
1301
1311
 
1302
1312
    // Last_IO_Errno
1303
1313
    protocol->store(mi->last_error().number);
1340
1350
  return;
1341
1351
}
1342
1352
 
 
1353
void set_slave_thread_default_charset(THD* thd, Relay_log_info const *rli)
 
1354
{
 
1355
  thd->variables.character_set_client=
 
1356
    global_system_variables.character_set_client;
 
1357
  thd->variables.collation_connection=
 
1358
    global_system_variables.collation_connection;
 
1359
  thd->variables.collation_server=
 
1360
    global_system_variables.collation_server;
 
1361
  thd->update_charset();
 
1362
 
 
1363
  /*
 
1364
    We use a const cast here since the conceptual (and externally
 
1365
    visible) behavior of the function is to set the default charset of
 
1366
    the thread.  That the cache has to be invalidated is a secondary
 
1367
    effect.
 
1368
   */
 
1369
  const_cast<Relay_log_info*>(rli)->cached_charset_invalidate();
 
1370
  return;
 
1371
}
 
1372
 
1343
1373
/*
1344
1374
  init_slave_thread()
1345
1375
*/
2170
2200
  /* Forget the relay log's format */
2171
2201
  delete mi->rli.relay_log.description_event_for_queue;
2172
2202
  mi->rli.relay_log.description_event_for_queue= 0;
 
2203
  // TODO: make rpl_status part of Master_info
 
2204
  change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE);
2173
2205
  assert(thd->net.buff != 0);
2174
2206
  net_end(&thd->net); // destructor will not free it, because net.vio is 0
2175
2207
  close_thread_tables(thd);
2436
2468
  pthread_mutex_unlock(&rli->data_lock);
2437
2469
  pthread_cond_broadcast(&rli->data_cond);
2438
2470
  rli->ignore_log_space_limit= 0; /* don't need any lock */
 
2471
  /* we die so won't remember charset - re-update them on next thread start */
 
2472
  rli->cached_charset_invalidate();
2439
2473
  rli->save_temporary_tables = thd->temporary_tables;
2440
2474
 
2441
2475
  /*
3146
3180
    if (++err_count == master_retry_count)
3147
3181
    {
3148
3182
      slave_was_killed=1;
 
3183
      if (reconnect)
 
3184
        change_rpl_status(RPL_ACTIVE_SLAVE,RPL_LOST_SOLDIER);
3149
3185
      break;
3150
3186
    }
3151
3187
    safe_sleep(thd,mi->connect_retry,(CHECK_KILLED_FUNC)io_slave_killed,
3164
3200
                                IO_RPL_LOG_NAME,
3165
3201
                                llstr(mi->master_log_pos,llbuff));
3166
3202
    }
 
3203
    else
 
3204
    {
 
3205
      change_rpl_status(RPL_IDLE_SLAVE,RPL_ACTIVE_SLAVE);
 
3206
    }
3167
3207
  }
3168
3208
  drizzle->reconnect= 1;
3169
3209
  return(slave_was_killed);