~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/set_var.cc

  • Committer: Monty Taylor
  • Date: 2008-12-01 00:41:43 UTC
  • mto: (632.1.3 devel)
  • mto: This revision was merged to the branch mainline in revision 634.
  • Revision ID: mordred@solanthus.local-20081201004143-4fqrydrxdymk6rdm
First step in support size_t sys_var stuff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
251
251
                                                           &SV::min_examined_row_limit);
252
252
static sys_var_session_uint64_t sys_myisam_max_sort_file_size(&vars, "myisam_max_sort_file_size", &SV::myisam_max_sort_file_size, fix_myisam_max_sort_file_size, 1);
253
253
static sys_var_session_uint32_t       sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads);
254
 
static sys_var_session_uint64_t sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
 
254
static sys_var_session_size_t   sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
255
255
 
256
256
static sys_var_session_enum         sys_myisam_stats_method(&vars, "myisam_stats_method",
257
257
                                                            &SV::myisam_stats_method,
300
300
static sys_var_session_uint32_t sys_div_precincrement(&vars, "div_precision_increment",
301
301
                                                      &SV::div_precincrement);
302
302
 
303
 
static sys_var_session_uint32_t sys_range_alloc_block_size(&vars, "range_alloc_block_size",
 
303
static sys_var_session_size_t   sys_range_alloc_block_size(&vars, "range_alloc_block_size",
304
304
                                                           &SV::range_alloc_block_size);
305
305
static sys_var_session_uint32_t sys_query_alloc_block_size(&vars, "query_alloc_block_size",
306
306
                                                           &SV::query_alloc_block_size,
327
327
                                                         &slave_allow_batching);
328
328
static sys_var_long_ptr sys_slow_launch_time(&vars, "slow_launch_time",
329
329
                                             &slow_launch_time);
330
 
static sys_var_session_uint64_t sys_sort_buffer(&vars, "sort_buffer_size",
 
330
static sys_var_session_size_t   sys_sort_buffer(&vars, "sort_buffer_size",
331
331
                                                &SV::sortbuff_size);
332
332
/*
333
333
  sql_mode should *not* have binlog_mode=SESSION_VARIABLE_IN_BINLOG:
806
806
  return out;
807
807
}
808
808
 
 
809
 
 
810
static size_t fix_size_t(Session *session, size_t num,
 
811
                           const struct my_option *option_limits)
 
812
{
 
813
  bool fixed= false;
 
814
  size_t out= (size_t)getopt_ull_limit_value(num, option_limits, &fixed);
 
815
 
 
816
  throw_bounds_warning(session, fixed, true, option_limits->name, (int64_t) num);
 
817
  return out;
 
818
}
 
819
 
809
820
static bool get_unsigned(Session *, set_var *var)
810
821
{
811
822
  if (var->value->unsigned_flag)
818
829
  return 0;
819
830
}
820
831
 
 
832
static bool get_size_t(Session *, set_var *var)
 
833
{
 
834
  if (var->value->unsigned_flag)
 
835
    var->save_result.uint64_t_value= (size_t) var->value->val_int();
 
836
  else
 
837
  {
 
838
    ssize_t v= var->value->val_int();
 
839
    var->save_result.uint64_t_value= (size_t) ((v < 0) ? 0 : v);
 
840
  }
 
841
  return 0;
 
842
}
 
843
 
821
844
 
822
845
sys_var_long_ptr::
823
846
sys_var_long_ptr(sys_var_chain *chain, const char *name_arg, uint64_t *value_ptr_arg,
909
932
}
910
933
 
911
934
 
 
935
bool sys_var_size_t_ptr::update(Session *session, set_var *var)
 
936
{
 
937
  size_t tmp= var->save_result.size_t_value;
 
938
  pthread_mutex_lock(&LOCK_global_system_variables);
 
939
  if (option_limits)
 
940
    *value= fix_size_t(session, tmp, option_limits);
 
941
  else
 
942
    *value= tmp;
 
943
  pthread_mutex_unlock(&LOCK_global_system_variables);
 
944
  return 0;
 
945
}
 
946
 
 
947
 
 
948
void sys_var_size_t_ptr::set_default(Session *, enum_var_type)
 
949
{
 
950
  bool not_used;
 
951
  pthread_mutex_lock(&LOCK_global_system_variables);
 
952
  *value= (size_t)getopt_ull_limit_value((size_t) option_limits->def_value,
 
953
                                         option_limits, &not_used);
 
954
  pthread_mutex_unlock(&LOCK_global_system_variables);
 
955
}
 
956
 
912
957
bool sys_var_bool_ptr::update(Session *, set_var *var)
913
958
{
914
959
  *value= (bool) var->save_result.uint32_t_value;
1105
1150
  return (unsigned char*) &(session->variables.*offset);
1106
1151
}
1107
1152
 
 
1153
bool sys_var_session_size_t::check(Session *session, set_var *var)
 
1154
{
 
1155
  return (get_size_t(session, var) ||
 
1156
          (check_func && (*check_func)(session, var)));
 
1157
}
 
1158
 
 
1159
bool sys_var_session_size_t::update(Session *session,  set_var *var)
 
1160
{
 
1161
  size_t tmp= var->save_result.size_t_value;
 
1162
 
 
1163
  if (tmp > max_system_variables.*offset)
 
1164
    tmp= max_system_variables.*offset;
 
1165
 
 
1166
  if (option_limits)
 
1167
    tmp= fix_size_t(session, tmp, option_limits);
 
1168
  if (var->type == OPT_GLOBAL)
 
1169
  {
 
1170
    /* Lock is needed to make things safe on 32 bit systems */
 
1171
    pthread_mutex_lock(&LOCK_global_system_variables);
 
1172
    global_system_variables.*offset= tmp;
 
1173
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
1174
  }
 
1175
  else
 
1176
    session->variables.*offset= tmp;
 
1177
  return 0;
 
1178
}
 
1179
 
 
1180
 
 
1181
void sys_var_session_size_t::set_default(Session *session, enum_var_type type)
 
1182
{
 
1183
  if (type == OPT_GLOBAL)
 
1184
  {
 
1185
    bool not_used;
 
1186
    pthread_mutex_lock(&LOCK_global_system_variables);
 
1187
    global_system_variables.*offset=
 
1188
      getopt_ull_limit_value((size_t) option_limits->def_value,
 
1189
                             option_limits, &not_used);
 
1190
    pthread_mutex_unlock(&LOCK_global_system_variables);
 
1191
  }
 
1192
  else
 
1193
    session->variables.*offset= global_system_variables.*offset;
 
1194
}
 
1195
 
 
1196
 
 
1197
unsigned char *sys_var_session_size_t::value_ptr(Session *session,
 
1198
                                                 enum_var_type type,
 
1199
                                                 LEX_STRING *)
 
1200
{
 
1201
  if (type == OPT_GLOBAL)
 
1202
    return (unsigned char*) &(global_system_variables.*offset);
 
1203
  return (unsigned char*) &(session->variables.*offset);
 
1204
}
 
1205
 
1108
1206
 
1109
1207
bool sys_var_session_bool::update(Session *session,  set_var *var)
1110
1208
{