Skip to content

Commit 7131a0a

Browse files
author
Alexander Barkov
committed
Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext
2 parents 139441d + de7c2e5 commit 7131a0a

17 files changed

+118
-118
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
MYSQL_VERSION_MAJOR=10
22
MYSQL_VERSION_MINOR=2
3-
MYSQL_VERSION_PATCH=9
3+
MYSQL_VERSION_PATCH=10

client/mysqltest.cc

Lines changed: 57 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,47 @@ void revert_properties();
836836
static void handle_no_active_connection(struct st_command* command,
837837
struct st_connection *cn, DYNAMIC_STRING *ds);
838838

839+
840+
/* Wrapper for fgets.Strips \r off newlines on Windows.
841+
Should be used with together with my_popen().
842+
*/
843+
static char *my_fgets(char * s, int n, FILE * stream, int *len)
844+
{
845+
char *buf = fgets(s, n, stream);
846+
if (!buf)
847+
{
848+
*len= 0;
849+
return buf;
850+
}
851+
852+
*len = (int)strlen(buf);
853+
#ifdef _WIN32
854+
/* Strip '\r' off newlines. */
855+
if (*len > 1 && buf[*len - 2] == '\r' && buf[*len - 1] == '\n')
856+
{
857+
buf[*len - 2]= '\n';
858+
buf[*len - 1]= 0;
859+
(*len)--;
860+
}
861+
#endif
862+
return buf;
863+
}
864+
865+
/*
866+
Wrapper for popen().
867+
On Windows, uses binary mode to workaround
868+
C runtime bug mentioned in MDEV-9409
869+
*/
870+
static FILE* my_popen(const char *cmd, const char *mode)
871+
{
872+
FILE *f= popen(cmd, mode);
873+
#ifdef _WIN32
874+
if (f)
875+
_setmode(fileno(f), O_BINARY);
876+
#endif
877+
return f;
878+
}
879+
839880
#ifdef EMBEDDED_LIBRARY
840881

841882
#define EMB_SEND_QUERY 1
@@ -1785,19 +1826,20 @@ static int run_command(char* cmd,
17851826
DBUG_ENTER("run_command");
17861827
DBUG_PRINT("enter", ("cmd: %s", cmd));
17871828

1788-
if (!(res_file= popen(cmd, "r")))
1829+
if (!(res_file= my_popen(cmd, "r")))
17891830
{
17901831
report_or_die("popen(\"%s\", \"r\") failed", cmd);
17911832
DBUG_RETURN(-1);
17921833
}
17931834

1794-
while (fgets(buf, sizeof(buf), res_file))
1835+
int len;
1836+
while (my_fgets(buf, sizeof(buf), res_file, &len))
17951837
{
17961838
DBUG_PRINT("info", ("buf: %s", buf));
17971839
if(ds_res)
17981840
{
17991841
/* Save the output of this command in the supplied string */
1800-
dynstr_append(ds_res, buf);
1842+
dynstr_append_mem(ds_res, buf,len);
18011843
}
18021844
else
18031845
{
@@ -1886,14 +1928,15 @@ static int diff_check(const char *diff_name)
18861928

18871929
my_snprintf(buf, sizeof(buf), "%s -v", diff_name);
18881930

1889-
if (!(res_file= popen(buf, "r")))
1931+
if (!(res_file= my_popen(buf, "r")))
18901932
die("popen(\"%s\", \"r\") failed", buf);
18911933

18921934
/*
18931935
if diff is not present, nothing will be in stdout to increment
18941936
have_diff
18951937
*/
1896-
if (fgets(buf, sizeof(buf), res_file))
1938+
int len;
1939+
if (my_fgets(buf, sizeof(buf), res_file, &len))
18971940
have_diff= 1;
18981941

18991942
pclose(res_file);
@@ -3246,18 +3289,6 @@ void free_tmp_sh_file()
32463289
#endif
32473290

32483291

3249-
FILE* my_popen(DYNAMIC_STRING *ds_cmd, const char *mode)
3250-
{
3251-
#if defined _WIN32 && defined USE_CYGWIN
3252-
/* Dump the command into a sh script file and execute with popen */
3253-
str_to_file(tmp_sh_name, ds_cmd->str, ds_cmd->length);
3254-
return popen(tmp_sh_cmd, mode);
3255-
#else
3256-
return popen(ds_cmd->str, mode);
3257-
#endif
3258-
}
3259-
3260-
32613292
static void init_builtin_echo(void)
32623293
{
32633294
#ifdef _WIN32
@@ -3392,7 +3423,7 @@ void do_exec(struct st_command *command)
33923423
DBUG_PRINT("info", ("Executing '%s' as '%s'",
33933424
command->first_argument, ds_cmd.str));
33943425

3395-
if (!(res_file= my_popen(&ds_cmd, "r")))
3426+
if (!(res_file= my_popen(ds_cmd.str, "r")))
33963427
{
33973428
dynstr_free(&ds_cmd);
33983429
if (command->abort_on_error)
@@ -3406,24 +3437,9 @@ void do_exec(struct st_command *command)
34063437
init_dynamic_string(&ds_sorted, "", 1024, 1024);
34073438
ds_result= &ds_sorted;
34083439
}
3409-
3410-
#ifdef _WIN32
3411-
/* Workaround for CRT bug, MDEV-9409 */
3412-
_setmode(fileno(res_file), O_BINARY);
3413-
#endif
3414-
3415-
while (fgets(buf, sizeof(buf), res_file))
3440+
int len;
3441+
while (my_fgets(buf, sizeof(buf), res_file,&len))
34163442
{
3417-
int len = (int)strlen(buf);
3418-
#ifdef _WIN32
3419-
/* Strip '\r' off newlines. */
3420-
if (len > 1 && buf[len-2] == '\r' && buf[len-1] == '\n')
3421-
{
3422-
buf[len-2] = '\n';
3423-
buf[len-1] = 0;
3424-
len--;
3425-
}
3426-
#endif
34273443
replace_dynstr_append_mem(ds_result, buf, len);
34283444
}
34293445
error= pclose(res_file);
@@ -4685,24 +4701,25 @@ void do_perl(struct st_command *command)
46854701
/* Format the "perl <filename>" command */
46864702
my_snprintf(buf, sizeof(buf), "perl %s", temp_file_path);
46874703

4688-
if (!(res_file= popen(buf, "r")))
4704+
if (!(res_file= my_popen(buf, "r")))
46894705
{
46904706
if (command->abort_on_error)
46914707
die("popen(\"%s\", \"r\") failed", buf);
46924708
dynstr_free(&ds_delimiter);
46934709
DBUG_VOID_RETURN;
46944710
}
46954711

4696-
while (fgets(buf, sizeof(buf), res_file))
4712+
int len;
4713+
while (my_fgets(buf, sizeof(buf), res_file,&len))
46974714
{
46984715
if (disable_result_log)
46994716
{
4700-
buf[strlen(buf)-1]=0;
4701-
DBUG_PRINT("exec_result",("%s", buf));
4717+
buf[len - 1] = 0;
4718+
DBUG_PRINT("exec_result", ("%s", buf));
47024719
}
47034720
else
47044721
{
4705-
replace_dynstr_append(&ds_res, buf);
4722+
replace_dynstr_append_mem(&ds_res, buf, len);
47064723
}
47074724
}
47084725
error= pclose(res_file);

mysql-test/r/mysqld--help,win.rdiff

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
--net-buffer-length=#
1717
Buffer length for TCP/IP and socket communication
1818
--net-read-timeout=#
19-
@@ -956,6 +956,9 @@
19+
@@ -957,6 +957,9 @@
2020
characteristics (isolation level, read only/read
2121
write,snapshot - but not any work done / data modified
2222
within the transaction).
@@ -26,7 +26,7 @@
2626
--show-slave-auth-info
2727
Show user and password in SHOW SLAVE HOSTS on this
2828
master.
29-
@@ -1068,6 +1071,10 @@
29+
@@ -1069,6 +1072,10 @@
3030
Log slow queries to given log file. Defaults logging to
3131
'hostname'-slow.log. Must be enabled to activate other
3232
slow log options
@@ -37,7 +37,7 @@
3737
--socket=name Socket file to use for connection
3838
--sort-buffer-size=#
3939
Each thread that needs to do a sort allocates a buffer of
40-
@@ -1086,6 +1093,7 @@
40+
@@ -1087,6 +1094,7 @@
4141
NO_ENGINE_SUBSTITUTION, PAD_CHAR_TO_FULL_LENGTH
4242
--stack-trace Print a symbolic stack trace on failure
4343
(Defaults to on; use --skip-stack-trace to disable.)

mysql-test/r/mysqld--help.result

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,10 @@ The following options may be given as the first argument:
569569
--open-files-limit=#
570570
If this is not 0, then mysqld will use this value to
571571
reserve file descriptors to use with setrlimit(). If this
572-
value is 0 then mysqld will reserve max_connections*5 or
573-
max_connections + table_cache*2 (whichever is larger)
574-
number of file descriptors
572+
value is 0 or autoset then mysqld will reserve
573+
max_connections*5 or max_connections + table_cache*2
574+
(whichever is larger) number of file descriptors
575+
(Automatically configured unless set explicitly)
575576
--optimizer-prune-level=#
576577
Controls the heuristic(s) applied during query
577578
optimization to prune less-promising partial plans from
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
select @@global.host_cache_size;
2+
@@global.host_cache_size
3+
653

mysql-test/suite/sys_vars/r/sysvars_server_embedded,32bit.rdiff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@
12371237
VARIABLE_SCOPE GLOBAL
12381238
-VARIABLE_TYPE BIGINT UNSIGNED
12391239
+VARIABLE_TYPE INT UNSIGNED
1240-
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
1240+
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
12411241
NUMERIC_MIN_VALUE 0
12421242
NUMERIC_MAX_VALUE 4294967295
12431243
@@ -4346,7 +4346,7 @@

mysql-test/suite/sys_vars/r/sysvars_server_embedded.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4336,7 +4336,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL
43364336
VARIABLE_NAME OPEN_FILES_LIMIT
43374337
VARIABLE_SCOPE GLOBAL
43384338
VARIABLE_TYPE BIGINT UNSIGNED
4339-
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
4339+
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
43404340
NUMERIC_MIN_VALUE 0
43414341
NUMERIC_MAX_VALUE 4294967295
43424342
NUMERIC_BLOCK_SIZE 1

mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@
12911291
VARIABLE_SCOPE GLOBAL
12921292
-VARIABLE_TYPE BIGINT UNSIGNED
12931293
+VARIABLE_TYPE INT UNSIGNED
1294-
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
1294+
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
12951295
NUMERIC_MIN_VALUE 0
12961296
NUMERIC_MAX_VALUE 4294967295
12971297
@@ -5228,7 +5228,7 @@

mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5218,7 +5218,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL
52185218
VARIABLE_NAME OPEN_FILES_LIMIT
52195219
VARIABLE_SCOPE GLOBAL
52205220
VARIABLE_TYPE BIGINT UNSIGNED
5221-
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
5221+
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
52225222
NUMERIC_MIN_VALUE 0
52235223
NUMERIC_MAX_VALUE 4294967295
52245224
NUMERIC_BLOCK_SIZE 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--max_connections=1000 --open-files-limit=1000 --autoset-host-cache-size

0 commit comments

Comments
 (0)