~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to sql/set_var.cc

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
241
241
static sys_var_long_ptr sys_delayed_queue_size(&vars, "delayed_queue_size",
242
242
                                               &delayed_queue_size);
243
243
 
 
244
#ifdef HAVE_EVENT_SCHEDULER
244
245
static sys_var_event_scheduler sys_event_scheduler(&vars, "event_scheduler");
 
246
#endif
 
247
 
245
248
static sys_var_long_ptr sys_expire_logs_days(&vars, "expire_logs_days",
246
249
                                             &expire_logs_days);
247
250
static sys_var_bool_ptr sys_flush(&vars, "flush", &myisam_flush);
275
278
                                                              param_age_threshold));
276
279
static sys_var_bool_ptr sys_local_infile(&vars, "local_infile",
277
280
                                         &opt_local_infile);
278
 
static sys_var_bool_ptr       
 
281
static sys_var_bool_ptr
279
282
sys_trust_function_creators(&vars, "log_bin_trust_function_creators",
280
283
                            &trust_function_creators);
281
284
static sys_var_bool_ptr
426
429
static sys_var_thd_ulong        sys_trans_prealloc_size(&vars, "transaction_prealloc_size",
427
430
                                                &SV::trans_prealloc_size,
428
431
                                                0, fix_trans_mem_root);
429
 
sys_var_enum_const      sys_thread_handling(&vars, "thread_handling",
430
 
                                            &SV::thread_handling,
431
 
                                            &thread_handling_typelib,
432
 
                                            NULL);
 
432
sys_var_enum_const        sys_thread_handling(&vars, "thread_handling",
 
433
                                              &SV::thread_handling,
 
434
                                              &thread_handling_typelib,
 
435
                                              NULL);
433
436
 
434
437
#ifdef HAVE_QUERY_CACHE
435
438
static sys_var_long_ptr sys_query_cache_limit(&vars, "query_cache_limit",
504
507
                                             &table_cache_size);
505
508
static sys_var_long_ptr sys_table_lock_wait_timeout(&vars, "table_lock_wait_timeout",
506
509
                                                    &table_lock_wait_timeout);
 
510
 
 
511
#if defined(ENABLED_DEBUG_SYNC)
 
512
/* Debug Sync Facility. Implemented in debug_sync.cc. */
 
513
static sys_var_debug_sync sys_debug_sync(&vars, "debug_sync");
 
514
#endif /* defined(ENABLED_DEBUG_SYNC) */
 
515
 
507
516
static sys_var_long_ptr sys_thread_cache_size(&vars, "thread_cache_size",
508
517
                                              &thread_cache_size);
509
518
#if HAVE_POOL_OF_THREADS == 1
725
734
  return (uchar*) &thd->sys_var_tmp.long_value;
726
735
}
727
736
 
728
 
static sys_var_readonly    sys_repl_report_port(&vars, "report_port", OPT_GLOBAL, SHOW_INT, slave_get_report_port);
 
737
static sys_var_readonly    sys_repl_report_port(&vars, "report_port", OPT_GLOBAL, SHOW_LONG, slave_get_report_port);
729
738
 
730
739
#endif
731
740
 
822
831
#ifdef HAVE_THR_SETCONCURRENCY
823
832
  {"thread_concurrency",      (char*) &concurrency,                 SHOW_LONG},
824
833
#endif
825
 
  {"thread_stack",            (char*) &thread_stack,                SHOW_LONG},
 
834
  {"thread_stack",            (char*) &my_thread_stack_size,        SHOW_LONG},
826
835
};
827
836
 
828
837
 
1169
1178
  }
1170
1179
  if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 0)
1171
1180
    bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT);
 
1181
  DBUG_VOID_RETURN;
1172
1182
}
1173
1183
 
1174
1184
bool sys_var_thd_binlog_format::is_readonly() const
1200
1210
  if (thd->in_sub_stmt)
1201
1211
  {
1202
1212
    my_error(ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT, MYF(0));
1203
 
    return 1;    
 
1213
    return 1;
1204
1214
  }
1205
1215
  return sys_var_thd_enum::is_readonly();
1206
1216
}
1431
1441
  return (uchar*) enum_names->type_names[*value];
1432
1442
}
1433
1443
 
1434
 
 
1435
1444
uchar *sys_var_enum_const::value_ptr(THD *thd, enum_var_type type,
1436
1445
                                     LEX_STRING *base)
1437
1446
{
1511
1520
  if (var->type == OPT_GLOBAL)
1512
1521
  {
1513
1522
    /* Lock is needed to make things safe on 32 bit systems */
1514
 
    pthread_mutex_lock(&LOCK_global_system_variables);    
 
1523
    pthread_mutex_lock(&LOCK_global_system_variables);
1515
1524
    global_system_variables.*offset= (ha_rows) tmp;
1516
1525
    pthread_mutex_unlock(&LOCK_global_system_variables);
1517
1526
  }
1676
1685
      strmov(buff, "NULL");
1677
1686
      goto err;
1678
1687
    }
 
1688
 
 
1689
    if (!m_allow_empty_value &&
 
1690
        res->length() == 0)
 
1691
    {
 
1692
      buff[0]= 0;
 
1693
      goto err;
 
1694
    }
 
1695
 
1679
1696
    var->save_result.ulong_value= ((ulong)
1680
1697
                                   find_set(enum_names, res->c_ptr(),
1681
1698
                                            res->length(),
1691
1708
  else
1692
1709
  {
1693
1710
    ulonglong tmp= var->value->val_int();
1694
 
   /*
1695
 
     For when the enum is made to contain 64 elements, as 1ULL<<64 is
1696
 
     undefined, we guard with a "count<64" test.
1697
 
   */
 
1711
 
 
1712
    if (!m_allow_empty_value &&
 
1713
        tmp == 0)
 
1714
    {
 
1715
      buff[0]= '0';
 
1716
      buff[1]= 0;
 
1717
      goto err;
 
1718
    }
 
1719
 
 
1720
    /*
 
1721
      For when the enum is made to contain 64 elements, as 1ULL<<64 is
 
1722
      undefined, we guard with a "count<64" test.
 
1723
    */
1698
1724
    if (unlikely((tmp >= ((ULL(1)) << enum_names->count)) &&
1699
1725
                 (enum_names->count < 64)))
1700
1726
    {
2209
2235
  if (!cache_name || ! cache_name->length)
2210
2236
    cache_name= &default_key_cache_base;
2211
2237
  return ((KEY_CACHE*) find_named(&key_caches,
2212
 
                                      cache_name->str, cache_name->length, 0));
 
2238
                                  cache_name->str, cache_name->length, 0));
2213
2239
}
2214
2240
 
2215
 
 
2216
2241
uchar *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type,
2217
2242
                                         LEX_STRING *base)
2218
2243
{
2394
2419
  MY_STAT f_stat;
2395
2420
  String str(buff, sizeof(buff), system_charset_info), *res;
2396
2421
  const char *log_file_str;
2397
 
      
 
2422
  size_t path_length;
 
2423
 
2398
2424
  if (!(res= var->value->val_str(&str)))
2399
2425
    goto err;
2400
2426
 
2401
2427
  log_file_str= res->c_ptr();
2402
2428
  bzero(&f_stat, sizeof(MY_STAT));
2403
2429
 
2404
 
  (void) unpack_filename(path, log_file_str);
 
2430
  path_length= unpack_filename(path, log_file_str);
 
2431
 
 
2432
  if (!path_length)
 
2433
  {
 
2434
    /* File name is empty. */
 
2435
 
 
2436
    goto err;
 
2437
  }
 
2438
 
2405
2439
  if (my_stat(path, &f_stat, MYF(0)))
2406
2440
  {
2407
 
    /* Check if argument is a file and we have 'write' permission */
 
2441
    /*
 
2442
      A file system object exists. Check if argument is a file and we have
 
2443
      'write' permission.
 
2444
    */
 
2445
 
2408
2446
    if (!MY_S_ISREG(f_stat.st_mode) ||
2409
2447
        !(f_stat.st_mode & MY_S_IWRITE))
2410
2448
      goto err;
2411
 
  }
2412
 
  else
2413
 
  {
2414
 
    size_t path_length;
2415
 
    /*
2416
 
      Check if directory exists and 
2417
 
      we have permission to create file & write to file
2418
 
    */
2419
 
    (void) dirname_part(path, log_file_str, &path_length);
2420
 
    if (my_access(path, (F_OK|W_OK)))
2421
 
      goto err;
2422
 
  }
 
2449
 
 
2450
    return 0;
 
2451
  }
 
2452
 
 
2453
  /* Get dirname of the file path. */
 
2454
  (void) dirname_part(path, log_file_str, &path_length);
 
2455
 
 
2456
  /* Dirname is empty if file path is relative. */
 
2457
  if (!path_length)
 
2458
    return 0;
 
2459
 
 
2460
  /*
 
2461
    Check if directory exists and we have permission to create file and
 
2462
    write to file.
 
2463
  */
 
2464
  if (my_access(path, (F_OK|W_OK)))
 
2465
    goto err;
 
2466
 
2423
2467
  return 0;
2424
2468
 
2425
2469
err:
2933
2977
 
2934
2978
  ulonglong org_options= thd->options;
2935
2979
 
 
2980
  /*
 
2981
    If we are setting AUTOCOMMIT=1 and it was not already 1, then we
 
2982
    need to commit any outstanding transactions.
 
2983
   */
 
2984
  if (var->save_result.ulong_value != 0 &&
 
2985
      (thd->options & OPTION_NOT_AUTOCOMMIT) &&
 
2986
      ha_commit(thd))
 
2987
    return 1;
 
2988
 
2936
2989
  if (var->save_result.ulong_value != 0)
2937
2990
    thd->options&= ~((sys_var_thd_bit*) var->var)->bit_flag;
2938
2991
  else
2946
2999
      thd->options&= ~(ulonglong) (OPTION_BEGIN | OPTION_KEEP_LOG);
2947
3000
      thd->transaction.all.modified_non_trans_table= FALSE;
2948
3001
      thd->server_status|= SERVER_STATUS_AUTOCOMMIT;
2949
 
      if (ha_commit(thd))
2950
 
        return 1;
2951
3002
    }
2952
3003
    else
2953
3004
    {
3625
3676
  if (type == OPT_GLOBAL)
3626
3677
    plugin= my_plugin_lock(thd, &(global_system_variables.*offset));
3627
3678
  hton= plugin_data(plugin, handlerton*);
3628
 
  engine_name= &hton2plugin[hton->slot]->name;
 
3679
  engine_name= hton_name(hton);
3629
3680
  result= (uchar *) thd->strmake(engine_name->str, engine_name->length);
3630
3681
  if (type == OPT_GLOBAL)
3631
3682
    plugin_unlock(thd, plugin);
3968
4019
  DBUG_ENTER("sys_var_opt_readonly::update");
3969
4020
 
3970
4021
  /* Prevent self dead-lock */
3971
 
  if (thd->locked_tables || thd->active_transaction())
 
4022
  if (thd->locked_tables_mode || thd->active_transaction())
3972
4023
  {
3973
4024
    my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
3974
4025
    DBUG_RETURN(true);
4009
4060
    can cause to wait on a read lock, it's required for the client application
4010
4061
    to unlock everything, and acceptable for the server to wait on all locks.
4011
4062
  */
4012
 
  if (result= close_cached_tables(thd, NULL, FALSE, TRUE, TRUE))
 
4063
  if (result= close_cached_tables(thd, NULL, FALSE, TRUE))
4013
4064
    goto end_with_read_lock;
4014
4065
 
4015
4066
  if (result= make_global_read_lock_block_commit(thd))
4052
4103
  return (uchar*) thd->strdup(buf);
4053
4104
}
4054
4105
 
4055
 
 
 
4106
#ifdef HAVE_EVENT_SCHEDULER
4056
4107
bool sys_var_event_scheduler::check(THD *thd, set_var *var)
4057
4108
{
4058
4109
  return check_enum(thd, var, &Events::var_typelib);
4059
4110
}
4060
4111
 
4061
 
 
4062
4112
/*
4063
4113
   The update method of the global variable event_scheduler.
4064
4114
   If event_scheduler is switched from 0 to 1 then the scheduler main
4097
4147
{
4098
4148
  return (uchar *) Events::get_opt_event_scheduler_str();
4099
4149
}
4100
 
 
 
4150
#endif
4101
4151
 
4102
4152
/****************************************************************************
4103
4153
  Used templates