~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/set_var.cc

  • Committer: Brian Aker
  • Date: 2008-07-10 19:37:55 UTC
  • mfrom: (51.1.67 remove-dbug)
  • Revision ID: brian@tangent.org-20080710193755-f5g761uieqa3wxmt
Merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
201
201
static sys_var_long_ptr sys_connect_timeout(&vars, "connect_timeout",
202
202
                                            &connect_timeout);
203
203
static sys_var_const_str       sys_datadir(&vars, "datadir", mysql_real_data_home);
204
 
#ifndef DBUG_OFF
205
 
static sys_var_thd_dbug        sys_dbug(&vars, "debug");
206
 
#endif
207
204
static sys_var_enum             sys_delay_key_write(&vars, "delay_key_write",
208
205
                                            &delay_key_write_options,
209
206
                                            &delay_key_write_typelib,
930
927
 
931
928
void fix_slave_exec_mode(enum_var_type type __attribute__((__unused__)))
932
929
{
933
 
  DBUG_ENTER("fix_slave_exec_mode");
934
930
  compile_time_assert(sizeof(slave_exec_mode_options) * CHAR_BIT
935
931
                      > SLAVE_EXEC_MODE_LAST_BIT - 1);
936
932
  if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT) == 1 &&
989
985
static void fix_max_binlog_size(THD *thd __attribute__((__unused__)),
990
986
                                enum_var_type type __attribute__((__unused__)))
991
987
{
992
 
  DBUG_ENTER("fix_max_binlog_size");
993
 
  DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
994
 
                     max_binlog_size, max_relay_log_size));
995
988
  mysql_bin_log.set_max_size(max_binlog_size);
996
989
#ifdef HAVE_REPLICATION
997
990
  if (!max_relay_log_size)
998
991
    active_mi->rli.relay_log.set_max_size(max_binlog_size);
999
992
#endif
1000
 
  DBUG_VOID_RETURN;
 
993
  return;
1001
994
}
1002
995
 
1003
996
static void fix_max_relay_log_size(THD *thd __attribute__((__unused__)),
1004
997
                                   enum_var_type type __attribute__((__unused__)))
1005
998
{
1006
 
  DBUG_ENTER("fix_max_relay_log_size");
1007
 
  DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
1008
 
                     max_binlog_size, max_relay_log_size));
1009
999
#ifdef HAVE_REPLICATION
1010
1000
  active_mi->rli.relay_log.set_max_size(max_relay_log_size ?
1011
1001
                                        max_relay_log_size: max_binlog_size);
1012
1002
#endif
1013
 
  DBUG_VOID_RETURN;
 
1003
  return;
1014
1004
}
1015
1005
 
1016
1006
static void fix_max_connections(THD *thd __attribute__((__unused__)),
1062
1052
                        ER_TRUNCATED_WRONG_VALUE,
1063
1053
                        ER(ER_TRUNCATED_WRONG_VALUE), name, buf);
1064
1054
  }
1065
 
  return FALSE;
 
1055
  return false;
1066
1056
}
1067
1057
 
1068
1058
static ulonglong fix_unsigned(THD *thd, ulonglong num,
1069
1059
                              const struct my_option *option_limits)
1070
1060
{
1071
 
  my_bool fixed= FALSE;
 
1061
  my_bool fixed= false;
1072
1062
  ulonglong out= getopt_ull_limit_value(num, option_limits, &fixed);
1073
1063
 
1074
 
  throw_bounds_warning(thd, fixed, TRUE, option_limits->name, (longlong) num);
 
1064
  throw_bounds_warning(thd, fixed, true, option_limits->name, (longlong) num);
1075
1065
  return out;
1076
1066
}
1077
1067
 
1114
1104
    if (tmp > ULONG_MAX)
1115
1105
    {
1116
1106
      tmp= ULONG_MAX;
1117
 
      throw_bounds_warning(thd, TRUE, TRUE, name,
 
1107
      throw_bounds_warning(thd, true, true, name,
1118
1108
                           (longlong) var->save_result.ulonglong_value);
1119
1109
    }
1120
1110
#endif
1208
1198
  /* Don't use bigger value than given with --maximum-variable-name=.. */
1209
1199
  if ((ulong) tmp > max_system_variables.*offset)
1210
1200
  {
1211
 
    throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) tmp);
 
1201
    throw_bounds_warning(thd, true, true, name, (longlong) tmp);
1212
1202
    tmp= max_system_variables.*offset;
1213
1203
  }
1214
1204
  
1218
1208
  else if (tmp > ULONG_MAX)
1219
1209
  {
1220
1210
    tmp= ULONG_MAX;
1221
 
    throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) var->save_result.ulonglong_value);
 
1211
    throw_bounds_warning(thd, true, true, name, (longlong) var->save_result.ulonglong_value);
1222
1212
  }
1223
1213
#endif
1224
1214
  
1661
1651
                                           DATE_TIME_FORMAT *new_value)
1662
1652
{
1663
1653
  DATE_TIME_FORMAT *old;
1664
 
  DBUG_ENTER("sys_var_date_time_format::update2");
1665
 
  DBUG_DUMP("positions", (uchar*) new_value->positions,
1666
 
            sizeof(new_value->positions));
1667
1654
 
1668
1655
  if (type == OPT_GLOBAL)
1669
1656
  {
1678
1665
    (thd->variables.*offset)= new_value;
1679
1666
  }
1680
1667
  my_free((char*) old, MYF(MY_ALLOW_ZERO_PTR));
1681
 
  DBUG_VOID_RETURN;
 
1668
  return;
1682
1669
}
1683
1670
 
1684
1671
 
2280
2267
      file_log->open_query_log(sys_var_general_log_path.value);
2281
2268
      break;
2282
2269
    default:
2283
 
      DBUG_ASSERT(0);
 
2270
      assert(0);
2284
2271
    }
2285
2272
  }
2286
2273
 
2569
2556
      May be we should have a separate error message for this?
2570
2557
    */
2571
2558
    my_error(ER_GLOBAL_VARIABLE, MYF(0), name);
2572
 
    return TRUE;
 
2559
    return true;
2573
2560
  }
2574
2561
}
2575
2562
 
2576
2563
bool sys_var_max_user_conn::update(THD *thd __attribute__((__unused__)),
2577
2564
                                   set_var *var)
2578
2565
{
2579
 
  DBUG_ASSERT(var->type == OPT_GLOBAL);
 
2566
  assert(var->type == OPT_GLOBAL);
2580
2567
  pthread_mutex_lock(&LOCK_global_system_variables);
2581
2568
  max_user_connections= (uint)var->save_result.ulonglong_value;
2582
2569
  pthread_mutex_unlock(&LOCK_global_system_variables);
2587
2574
void sys_var_max_user_conn::set_default(THD *thd __attribute__((__unused__)),
2588
2575
                                        enum_var_type type __attribute__((__unused__)))
2589
2576
{
2590
 
  DBUG_ASSERT(type == OPT_GLOBAL);
 
2577
  assert(type == OPT_GLOBAL);
2591
2578
  pthread_mutex_lock(&LOCK_global_system_variables);
2592
2579
  max_user_connections= (ulong) option_limits->def_value;
2593
2580
  pthread_mutex_unlock(&LOCK_global_system_variables);
2756
2743
    {
2757
2744
      /* We changed to auto_commit mode */
2758
2745
      thd->options&= ~(ulonglong) (OPTION_BEGIN | OPTION_KEEP_LOG);
2759
 
      thd->transaction.all.modified_non_trans_table= FALSE;
 
2746
      thd->transaction.all.modified_non_trans_table= false;
2760
2747
      thd->server_status|= SERVER_STATUS_AUTOCOMMIT;
2761
2748
      if (ha_commit(thd))
2762
2749
        return 1;
2763
2750
    }
2764
2751
    else
2765
2752
    {
2766
 
      thd->transaction.all.modified_non_trans_table= FALSE;
 
2753
      thd->transaction.all.modified_non_trans_table= false;
2767
2754
      thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
2768
2755
    }
2769
2756
  }
3025
3012
int set_var_init()
3026
3013
{
3027
3014
  uint count= 0;
3028
 
  DBUG_ENTER("set_var_init");
3029
3015
  
3030
3016
  for (sys_var *var=vars.first; var; var= var->next, count++) {};
3031
3017
 
3052
3038
  */
3053
3039
  sys_sql_max_join_size.option_limits= sys_max_join_size.option_limits;
3054
3040
 
3055
 
  DBUG_RETURN(0);
 
3041
  return(0);
3056
3042
 
3057
3043
error:
3058
3044
  fprintf(stderr, "failed to initialize system variables");
3059
 
  DBUG_RETURN(1);
 
3045
  return(1);
3060
3046
}
3061
3047
 
3062
3048
 
3143
3129
{
3144
3130
  int error;
3145
3131
  List_iterator_fast<set_var_base> it(*var_list);
3146
 
  DBUG_ENTER("sql_set_variables");
3147
3132
 
3148
3133
  set_var_base *var;
3149
3134
  while ((var=it++))
3160
3145
 
3161
3146
err:
3162
3147
  free_underlaid_joins(thd, &thd->lex->select_lex);
3163
 
  DBUG_RETURN(error);
 
3148
  return(error);
3164
3149
}
3165
3150
 
3166
3151
 
3350
3335
    value= &(thd->variables.*offset);
3351
3336
    new_value= my_plugin_lock(NULL, &(global_system_variables.*offset));
3352
3337
  }
3353
 
  DBUG_ASSERT(new_value);
 
3338
  assert(new_value);
3354
3339
  old_value= *value;
3355
3340
  *value= new_value;
3356
3341
  plugin_unlock(NULL, old_value);
3447
3432
                     void (*free_element)(const char *name, uchar*))
3448
3433
{
3449
3434
  NAMED_LIST *element;
3450
 
  DBUG_ENTER("delete_elements");
3451
3435
  while ((element= list->get()))
3452
3436
  {
3453
3437
    (*free_element)(element->name, element->data);
3454
3438
    delete element;
3455
3439
  }
3456
 
  DBUG_VOID_RETURN;
 
3440
  return;
3457
3441
}
3458
3442
 
3459
3443
 
3462
3446
static KEY_CACHE *create_key_cache(const char *name, uint length)
3463
3447
{
3464
3448
  KEY_CACHE *key_cache;
3465
 
  DBUG_ENTER("create_key_cache");
3466
 
  DBUG_PRINT("enter",("name: %.*s", length, name));
3467
3449
  
3468
3450
  if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE),
3469
3451
                                             MYF(MY_ZEROFILL | MY_WME))))
3486
3468
      key_cache->param_age_threshold=  dflt_key_cache_var.param_age_threshold;
3487
3469
    }
3488
3470
  }
3489
 
  DBUG_RETURN(key_cache);
 
3471
  return(key_cache);
3490
3472
}
3491
3473
 
3492
3474
 
3531
3513
{
3532
3514
  bool result;
3533
3515
 
3534
 
  DBUG_ENTER("sys_var_opt_readonly::update");
3535
 
 
3536
3516
  /* Prevent self dead-lock */
3537
3517
  if (thd->locked_tables || thd->active_transaction())
3538
3518
  {
3539
3519
    my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
3540
 
    DBUG_RETURN(true);
 
3520
    return(true);
3541
3521
  }
3542
3522
 
3543
3523
  if (thd->global_read_lock)
3549
3529
      - SET GLOBAL READ_ONLY = 1
3550
3530
    */
3551
3531
    result= sys_var_bool_ptr::update(thd, var);
3552
 
    DBUG_RETURN(result);
 
3532
    return(result);
3553
3533
  }
3554
3534
 
3555
3535
  /*
3564
3544
  */
3565
3545
 
3566
3546
  if (lock_global_read_lock(thd))
3567
 
    DBUG_RETURN(true);
 
3547
    return(true);
3568
3548
 
3569
3549
  /*
3570
3550
    This call will be blocked by any connection holding a READ or WRITE lock.
3575
3555
    can cause to wait on a read lock, it's required for the client application
3576
3556
    to unlock everything, and acceptable for the server to wait on all locks.
3577
3557
  */
3578
 
  if ((result= close_cached_tables(thd, NULL, FALSE, TRUE, TRUE)) == true)
 
3558
  if ((result= close_cached_tables(thd, NULL, false, true, true)) == true)
3579
3559
    goto end_with_read_lock;
3580
3560
 
3581
3561
  if ((result= make_global_read_lock_block_commit(thd)) == true)
3587
3567
end_with_read_lock:
3588
3568
  /* Release the lock */
3589
3569
  unlock_global_read_lock(thd);
3590
 
  DBUG_RETURN(result);
3591
 
}
3592
 
 
3593
 
bool sys_var_thd_dbug::update(THD *thd __attribute__((__unused__)),
3594
 
                              set_var *var)
3595
 
{
3596
 
  if (var->type == OPT_GLOBAL)
3597
 
  {
3598
 
    DBUG_SET_INITIAL(var ? var->value->str_value.c_ptr() : "");
3599
 
  }
3600
 
  else
3601
 
  {
3602
 
    DBUG_SET(var ? var->value->str_value.c_ptr() : "");
3603
 
  }
3604
 
 
3605
 
  return 0;
3606
 
}
3607
 
 
3608
 
 
3609
 
uchar *sys_var_thd_dbug::value_ptr(THD *thd, enum_var_type type,
3610
 
                                   LEX_STRING *b __attribute__((__unused__)))
3611
 
{
3612
 
  char buf[256];
3613
 
  if (type == OPT_GLOBAL)
3614
 
  {
3615
 
    DBUG_EXPLAIN_INITIAL(buf, sizeof(buf));
3616
 
  }
3617
 
  else
3618
 
  {
3619
 
    DBUG_EXPLAIN(buf, sizeof(buf));
3620
 
  }
3621
 
  return (uchar*) thd->strdup(buf);
 
3570
  return(result);
3622
3571
}
3623
3572
 
3624
3573
/****************************************************************************