Commit 7131a0a8 authored by Alexander Barkov's avatar Alexander Barkov

Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext

parents 139441d0 de7c2e5e
MYSQL_VERSION_MAJOR=10
MYSQL_VERSION_MINOR=2
MYSQL_VERSION_PATCH=9
MYSQL_VERSION_PATCH=10
......@@ -836,6 +836,47 @@ void revert_properties();
static void handle_no_active_connection(struct st_command* command,
struct st_connection *cn, DYNAMIC_STRING *ds);
/* Wrapper for fgets.Strips \r off newlines on Windows.
Should be used with together with my_popen().
*/
static char *my_fgets(char * s, int n, FILE * stream, int *len)
{
char *buf = fgets(s, n, stream);
if (!buf)
{
*len= 0;
return buf;
}
*len = (int)strlen(buf);
#ifdef _WIN32
/* Strip '\r' off newlines. */
if (*len > 1 && buf[*len - 2] == '\r' && buf[*len - 1] == '\n')
{
buf[*len - 2]= '\n';
buf[*len - 1]= 0;
(*len)--;
}
#endif
return buf;
}
/*
Wrapper for popen().
On Windows, uses binary mode to workaround
C runtime bug mentioned in MDEV-9409
*/
static FILE* my_popen(const char *cmd, const char *mode)
{
FILE *f= popen(cmd, mode);
#ifdef _WIN32
if (f)
_setmode(fileno(f), O_BINARY);
#endif
return f;
}
#ifdef EMBEDDED_LIBRARY
#define EMB_SEND_QUERY 1
......@@ -1785,19 +1826,20 @@ static int run_command(char* cmd,
DBUG_ENTER("run_command");
DBUG_PRINT("enter", ("cmd: %s", cmd));
if (!(res_file= popen(cmd, "r")))
if (!(res_file= my_popen(cmd, "r")))
{
report_or_die("popen(\"%s\", \"r\") failed", cmd);
DBUG_RETURN(-1);
}
while (fgets(buf, sizeof(buf), res_file))
int len;
while (my_fgets(buf, sizeof(buf), res_file, &len))
{
DBUG_PRINT("info", ("buf: %s", buf));
if(ds_res)
{
/* Save the output of this command in the supplied string */
dynstr_append(ds_res, buf);
dynstr_append_mem(ds_res, buf,len);
}
else
{
......@@ -1886,14 +1928,15 @@ static int diff_check(const char *diff_name)
my_snprintf(buf, sizeof(buf), "%s -v", diff_name);
if (!(res_file= popen(buf, "r")))
if (!(res_file= my_popen(buf, "r")))
die("popen(\"%s\", \"r\") failed", buf);
/*
if diff is not present, nothing will be in stdout to increment
have_diff
*/
if (fgets(buf, sizeof(buf), res_file))
int len;
if (my_fgets(buf, sizeof(buf), res_file, &len))
have_diff= 1;
pclose(res_file);
......@@ -3246,18 +3289,6 @@ void free_tmp_sh_file()
#endif
FILE* my_popen(DYNAMIC_STRING *ds_cmd, const char *mode)
{
#if defined _WIN32 && defined USE_CYGWIN
/* Dump the command into a sh script file and execute with popen */
str_to_file(tmp_sh_name, ds_cmd->str, ds_cmd->length);
return popen(tmp_sh_cmd, mode);
#else
return popen(ds_cmd->str, mode);
#endif
}
static void init_builtin_echo(void)
{
#ifdef _WIN32
......@@ -3392,7 +3423,7 @@ void do_exec(struct st_command *command)
DBUG_PRINT("info", ("Executing '%s' as '%s'",
command->first_argument, ds_cmd.str));
if (!(res_file= my_popen(&ds_cmd, "r")))
if (!(res_file= my_popen(ds_cmd.str, "r")))
{
dynstr_free(&ds_cmd);
if (command->abort_on_error)
......@@ -3406,24 +3437,9 @@ void do_exec(struct st_command *command)
init_dynamic_string(&ds_sorted, "", 1024, 1024);
ds_result= &ds_sorted;
}
#ifdef _WIN32
/* Workaround for CRT bug, MDEV-9409 */
_setmode(fileno(res_file), O_BINARY);
#endif
while (fgets(buf, sizeof(buf), res_file))
int len;
while (my_fgets(buf, sizeof(buf), res_file,&len))
{
int len = (int)strlen(buf);
#ifdef _WIN32
/* Strip '\r' off newlines. */
if (len > 1 && buf[len-2] == '\r' && buf[len-1] == '\n')
{
buf[len-2] = '\n';
buf[len-1] = 0;
len--;
}
#endif
replace_dynstr_append_mem(ds_result, buf, len);
}
error= pclose(res_file);
......@@ -4685,7 +4701,7 @@ void do_perl(struct st_command *command)
/* Format the "perl <filename>" command */
my_snprintf(buf, sizeof(buf), "perl %s", temp_file_path);
if (!(res_file= popen(buf, "r")))
if (!(res_file= my_popen(buf, "r")))
{
if (command->abort_on_error)
die("popen(\"%s\", \"r\") failed", buf);
......@@ -4693,16 +4709,17 @@ void do_perl(struct st_command *command)
DBUG_VOID_RETURN;
}
while (fgets(buf, sizeof(buf), res_file))
int len;
while (my_fgets(buf, sizeof(buf), res_file,&len))
{
if (disable_result_log)
{
buf[strlen(buf)-1]=0;
DBUG_PRINT("exec_result",("%s", buf));
buf[len - 1] = 0;
DBUG_PRINT("exec_result", ("%s", buf));
}
else
{
replace_dynstr_append(&ds_res, buf);
replace_dynstr_append_mem(&ds_res, buf, len);
}
}
error= pclose(res_file);
......
......@@ -16,7 +16,7 @@
--net-buffer-length=#
Buffer length for TCP/IP and socket communication
--net-read-timeout=#
@@ -956,6 +956,9 @@
@@ -957,6 +957,9 @@
characteristics (isolation level, read only/read
write,snapshot - but not any work done / data modified
within the transaction).
......@@ -26,7 +26,7 @@
--show-slave-auth-info
Show user and password in SHOW SLAVE HOSTS on this
master.
@@ -1068,6 +1071,10 @@
@@ -1069,6 +1072,10 @@
Log slow queries to given log file. Defaults logging to
'hostname'-slow.log. Must be enabled to activate other
slow log options
......@@ -37,7 +37,7 @@
--socket=name Socket file to use for connection
--sort-buffer-size=#
Each thread that needs to do a sort allocates a buffer of
@@ -1086,6 +1093,7 @@
@@ -1087,6 +1094,7 @@
NO_ENGINE_SUBSTITUTION, PAD_CHAR_TO_FULL_LENGTH
--stack-trace Print a symbolic stack trace on failure
(Defaults to on; use --skip-stack-trace to disable.)
......
......@@ -569,9 +569,10 @@ The following options may be given as the first argument:
--open-files-limit=#
If this is not 0, then mysqld will use this value to
reserve file descriptors to use with setrlimit(). If this
value is 0 then mysqld will reserve max_connections*5 or
max_connections + table_cache*2 (whichever is larger)
number of file descriptors
value is 0 or autoset then mysqld will reserve
max_connections*5 or max_connections + table_cache*2
(whichever is larger) number of file descriptors
(Automatically configured unless set explicitly)
--optimizer-prune-level=#
Controls the heuristic(s) applied during query
optimization to prune less-promising partial plans from
......
select @@global.host_cache_size;
@@global.host_cache_size
653
......@@ -1237,7 +1237,7 @@
VARIABLE_SCOPE GLOBAL
-VARIABLE_TYPE BIGINT UNSIGNED
+VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors
VARIABLE_COMMENT If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 or autoset then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 4294967295
@@ -4346,7 +4346,7 @@
......
......@@ -4336,7 +4336,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME OPEN_FILES_LIMIT
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors
VARIABLE_COMMENT If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 or autoset then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 4294967295
NUMERIC_BLOCK_SIZE 1
......
......@@ -1291,7 +1291,7 @@
VARIABLE_SCOPE GLOBAL
-VARIABLE_TYPE BIGINT UNSIGNED
+VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors
VARIABLE_COMMENT If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 or autoset then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 4294967295
@@ -5228,7 +5228,7 @@
......
......@@ -5218,7 +5218,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME OPEN_FILES_LIMIT
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors
VARIABLE_COMMENT If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 or autoset then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 4294967295
NUMERIC_BLOCK_SIZE 1
......
--max_connections=1000 --open-files-limit=1000 --autoset-host-cache-size
......@@ -4407,21 +4407,6 @@ static int init_common_variables()
SYSVAR_AUTOSIZE(threadpool_size, my_getncpus());
#endif
/* Fix host_cache_size. */
if (IS_SYSVAR_AUTOSIZE(&host_cache_size))
{
if (max_connections <= 628 - 128)
SYSVAR_AUTOSIZE(host_cache_size, 128 + max_connections);
else if (max_connections <= ((ulong)(2000 - 628)) * 20 + 500)
SYSVAR_AUTOSIZE(host_cache_size, 628 + ((max_connections - 500) / 20));
else
SYSVAR_AUTOSIZE(host_cache_size, 2000);
}
/* Fix back_log (back_log == 0 added for MySQL compatibility) */
if (back_log == 0 || IS_SYSVAR_AUTOSIZE(&back_log))
SYSVAR_AUTOSIZE(back_log, MY_MIN(900, (50 + max_connections / 5)));
/* connections and databases needs lots of files */
{
uint files, wanted_files, max_open_files;
......@@ -4446,7 +4431,7 @@ static int init_common_variables()
if (files < wanted_files)
{
if (!open_files_limit)
if (!open_files_limit || IS_SYSVAR_AUTOSIZE(&open_files_limit))
{
/*
If we have requested too much file handles than we bring
......@@ -4475,6 +4460,36 @@ static int init_common_variables()
}
SYSVAR_AUTOSIZE(open_files_limit, files);
}
/*
Max_connections is now set.
Now we can fix other variables depending on this variable.
*/
/* Fix host_cache_size */
if (IS_SYSVAR_AUTOSIZE(&host_cache_size))
{
/*
The default value is 128.
The autoset value is 128, plus 1 for a value of max_connections
up to 500, plus 1 for every increment of 20 over 500 in the
max_connections value, capped at 2000.
*/
uint size= (HOST_CACHE_SIZE + MY_MIN(max_connections, 500) +
MY_MAX(((long) max_connections)-500,0)/20);
SYSVAR_AUTOSIZE(host_cache_size, size);
}
/* Fix back_log (back_log == 0 added for MySQL compatibility) */
if (back_log == 0 || IS_SYSVAR_AUTOSIZE(&back_log))
{
/*
The default value is 150.
The autoset value is 50 + max_connections / 5 capped at 900
*/
SYSVAR_AUTOSIZE(back_log, MY_MIN(900, (50 + max_connections / 5)));
}
unireg_init(opt_specialflag); /* Set up extern variabels */
if (!(my_default_lc_messages=
my_locale_by_name(lc_messages)))
......
......@@ -2311,10 +2311,10 @@ export sys_var *Sys_old_passwords_ptr= &Sys_old_passwords; // for sql_acl.cc
static Sys_var_ulong Sys_open_files_limit(
"open_files_limit",
"If this is not 0, then mysqld will use this value to reserve file "
"descriptors to use with setrlimit(). If this value is 0 then mysqld "
"will reserve max_connections*5 or max_connections + table_cache*2 "
"(whichever is larger) number of file descriptors",
READ_ONLY GLOBAL_VAR(open_files_limit), CMD_LINE(REQUIRED_ARG),
"descriptors to use with setrlimit(). If this value is 0 or autoset "
"then mysqld will reserve max_connections*5 or max_connections + "
"table_cache*2 (whichever is larger) number of file descriptors",
AUTO_SET READ_ONLY GLOBAL_VAR(open_files_limit), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, OS_FILE_LIMIT), DEFAULT(0), BLOCK_SIZE(1));
/// @todo change to enum
......
......@@ -1569,7 +1569,7 @@ page_dir_balance_slot(
/* The last directory slot cannot be balanced with the upper
neighbor, as there is none. */
if (UNIV_UNLIKELY(slot_no == page_dir_get_n_slots(page) - 1)) {
if (UNIV_UNLIKELY(slot_no + 1 == page_dir_get_n_slots(page))) {
return;
}
......
......@@ -49,14 +49,7 @@ my_bool srv_sync_debug;
/** The global mutex which protects debug info lists of all rw-locks.
To modify the debug info list of an rw-lock, this mutex has to be
acquired in addition to the mutex protecting the lock. */
static ib_mutex_t rw_lock_debug_mutex;
/** If deadlock detection does not get immediately the mutex,
it may wait for this event */
static os_event_t rw_lock_debug_event;
/** This is set to true, if there may be waiters for the event */
static bool rw_lock_debug_waiters;
static SysMutex rw_lock_debug_mutex;
/** The latch held by a thread */
struct Latched {
......@@ -1242,13 +1235,7 @@ void
LatchDebug::init()
UNIV_NOTHROW
{
ut_a(rw_lock_debug_event == NULL);
mutex_create(LATCH_ID_RW_LOCK_DEBUG, &rw_lock_debug_mutex);
rw_lock_debug_event = os_event_create("rw_lock_debug_event");
rw_lock_debug_waiters = FALSE;
}
/** Shutdown the latch debug checking
......@@ -1259,12 +1246,6 @@ void
LatchDebug::shutdown()
UNIV_NOTHROW
{
ut_a(rw_lock_debug_event != NULL);
os_event_destroy(rw_lock_debug_event);
rw_lock_debug_event = NULL;
mutex_free(&rw_lock_debug_mutex);
ut_a(s_initialized);
......@@ -1284,22 +1265,7 @@ mutex. */
void
rw_lock_debug_mutex_enter()
{
for (;;) {
if (0 == mutex_enter_nowait(&rw_lock_debug_mutex)) {
return;
}
os_event_reset(rw_lock_debug_event);
rw_lock_debug_waiters = TRUE;
if (0 == mutex_enter_nowait(&rw_lock_debug_mutex)) {
return;
}
os_event_wait(rw_lock_debug_event);
}
mutex_enter(&rw_lock_debug_mutex);
}
/** Releases the debug mutex. */
......@@ -1307,11 +1273,6 @@ void
rw_lock_debug_mutex_exit()
{
mutex_exit(&rw_lock_debug_mutex);
if (rw_lock_debug_waiters) {
rw_lock_debug_waiters = FALSE;
os_event_set(rw_lock_debug_event);
}
}
#endif /* UNIV_DEBUG */
......
......@@ -57,7 +57,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
char kfilename[FN_REFLEN], klinkname[FN_REFLEN], *klinkname_ptr;
char dfilename[FN_REFLEN], dlinkname[FN_REFLEN], *dlinkname_ptr= 0;
ulong pack_reclength;
ulonglong tot_length,max_rows, tmp;
ulonglong tot_length,max_rows, tmp, tot_length_part;
enum en_fieldtype type;
enum data_file_type org_datafile_type= datafile_type;
MARIA_SHARE share;
......@@ -664,10 +664,10 @@ int maria_create(const char *name, enum data_file_type datafile_type,
if (tot_length == ULLONG_MAX)
continue;
ulonglong tot_length_part= (max_rows/(ulong) (((uint) maria_block_size -
MAX_KEYPAGE_HEADER_SIZE -
KEYPAGE_CHECKSUM_SIZE)/
(length*2)));
tot_length_part= (max_rows/(ulong) (((uint) maria_block_size -
MAX_KEYPAGE_HEADER_SIZE -
KEYPAGE_CHECKSUM_SIZE)/
(length*2)));
if (tot_length_part >= (ULLONG_MAX / maria_block_size +
ULLONG_MAX % maria_block_size))
tot_length= ULLONG_MAX;
......
......@@ -918,6 +918,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
if (internal_table)
set_if_smaller(share->base.max_data_file_length,
max_data_file_length);
if (share->now_transactional)
{
/* Setup initial state that is visible for all */
MARIA_STATE_HISTORY_CLOSED *history;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment