~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/set_var.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-04-09 05:42:03 UTC
  • mfrom: (984 merge)
  • mto: (971.1.63 mordred)
  • mto: This revision was merged to the branch mainline in revision 990.
  • Revision ID: osullivan.padraig@gmail.com-20090409054203-c1n4db8u3aprsyox
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
  delay_key_write_type_names, NULL
93
93
};
94
94
 
95
 
static bool sys_update_init_connect(Session*, set_var*);
96
 
static void sys_default_init_connect(Session*, enum_var_type type);
97
95
static bool set_option_bit(Session *session, set_var *var);
98
96
static bool set_option_autocommit(Session *session, set_var *var);
99
97
static int  check_pseudo_thread_id(Session *session, set_var *var);
163
161
                                            fix_delay_key_write);
164
162
 
165
163
static sys_var_bool_ptr sys_flush(&vars, "flush", &myisam_flush);
166
 
sys_var_str             sys_init_connect(&vars, "init_connect", 0,
167
 
                                         sys_update_init_connect,
168
 
                                         sys_default_init_connect,0);
169
164
static sys_var_session_uint64_t sys_join_buffer_size(&vars, "join_buffer_size",
170
165
                                                     &SV::join_buff_size);
171
166
static sys_var_key_buffer_size  sys_key_buffer_size(&vars, "key_buffer_size");
415
410
#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(SHOW_VAR))
416
411
static SHOW_VAR fixed_vars[]= {
417
412
  {"back_log",                (char*) &back_log,                    SHOW_INT},
418
 
  {"init_file",               (char*) &opt_init_file,               SHOW_CHAR_PTR},
419
413
  {"language",                language,                             SHOW_CHAR},
420
414
#ifdef HAVE_MLOCKALL
421
415
  {"locked_in_memory",        (char*) &locked_in_memory,            SHOW_MY_BOOL},
451
445
*/
452
446
 
453
447
 
454
 
/*
455
 
  Update variables 'init_connect, init_slave'.
456
 
 
457
 
  In case of 'DEFAULT' value
458
 
  (for example: 'set GLOBAL init_connect=DEFAULT')
459
 
  'var' parameter is NULL pointer.
460
 
*/
461
 
 
462
 
bool update_sys_var_str(sys_var_str *var_str, pthread_rwlock_t *var_mutex,
463
 
                        set_var *var)
464
 
{
465
 
  char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
466
 
  uint32_t new_length= (var ? var->value->str_value.length() : 0);
467
 
  if (!old_value)
468
 
    old_value= (char*) "";
469
 
  res= (char *)malloc(new_length + 1);
470
 
  if (res == NULL)
471
 
    return 1;
472
 
  memcpy(res, old_value, new_length);
473
 
  res[new_length]= 0; 
474
 
 
475
 
  /*
476
 
    Replace the old value in such a way that the any thread using
477
 
    the value will work.
478
 
  */
479
 
  pthread_rwlock_wrlock(var_mutex);
480
 
  old_value= var_str->value;
481
 
  var_str->value= res;
482
 
  var_str->value_length= new_length;
483
 
  pthread_rwlock_unlock(var_mutex);
484
 
  free(old_value);
485
 
  return 0;
486
 
}
487
 
 
488
 
 
489
 
static bool sys_update_init_connect(Session *, set_var *var)
490
 
{
491
 
  return update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, var);
492
 
}
493
 
 
494
 
 
495
 
static void sys_default_init_connect(Session *, enum_var_type)
496
 
{
497
 
  update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, 0);
498
 
}
499
 
 
500
 
 
501
448
/**
502
449
  Set the OPTION_BIG_SELECTS flag if max_join_size == HA_POS_ERROR.
503
450
*/
561
508
static void fix_net_read_timeout(Session *session, enum_var_type type)
562
509
{
563
510
  if (type != OPT_GLOBAL)
564
 
    session->protocol->set_read_timeout(session->variables.net_read_timeout);
 
511
    session->protocol->setReadTimeout(session->variables.net_read_timeout);
565
512
}
566
513
 
567
514
 
568
515
static void fix_net_write_timeout(Session *session, enum_var_type type)
569
516
{
570
517
  if (type != OPT_GLOBAL)
571
 
    session->protocol->set_write_timeout(session->variables.net_write_timeout);
 
518
    session->protocol->setWriteTimeout(session->variables.net_write_timeout);
572
519
}
573
520
 
574
521
static void fix_net_retry_count(Session *session, enum_var_type type)
575
522
{
576
523
  if (type != OPT_GLOBAL)
577
 
    session->protocol->set_retry_count(session->variables.net_retry_count);
 
524
    session->protocol->setRetryCount(session->variables.net_retry_count);
578
525
}
579
526
 
580
527