mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Ensure that all clients reads the appropriate 'client', client-mariadb and 'mariadb' sections from my.cnf
The mysqld server and all clients now reads the new client-server section Fixed that mysqldumpslow supports new slow log formats and new mysqld --slow- options client/mysql.cc: Read also client-server and client-mariadb sections. client/mysql_upgrade.c: Read also client-server and client-mariadb sections. client/mysqladmin.cc: Read also client-server and client-mariadb sections. client/mysqlbinlog.cc: Read also client-server and client-mariadb sections. client/mysqlcheck.c: Read also client-server and client-mariadb sections. client/mysqldump.c: Read also client-server and client-mariadb sections. client/mysqlimport.c: Read also client-server and client-mariadb sections. client/mysqlshow.c: Read also client-server and client-mariadb sections. client/mysqltest.cc: Read also client-server and client-mariadb sections. extra/my_print_defaults.c: Updated help text scripts/mysql_fix_privilege_tables.sh: Read also sections client client-server client-mariadb scripts/mysql_install_db.pl.in: Also allow --data=* option Read also groups mariadb, server and client-server. scripts/mysql_install_db.sh: Also allow --data=* option Read also groups mariadb, server and client-server. Added --lose-skip-pbxt to bootstrap scripts/mysql_secure_installation.sh: Read also groups client-server and client-mariadb scripts/mysqld_multi.sh: Read also group mariadb scripts/mysqld_safe.sh: Read also groups mariadb server and client-server scripts/mysqldumpslow.sh: Fixed to support new slow log formats Added sorting on -ae (aggregated number of retreived rows) and e (retrieved rows) Read also group 'mariadb' If there is many instances of same option, use last one. Get slow log file from options log-slow-queries=filename or query-log-file=filename Added support for future --log-basename option sql-common/client.c: Read also groups 'client-server' and 'client-mariadb' tests/mysql_client_test.c: Read also groups 'client-server' and 'client-mariadb' tests/thread_test.c: Read also groups 'client-server' and 'client-mariadb'
This commit is contained in:
@ -1030,7 +1030,8 @@ static COMMANDS commands[] = {
|
|||||||
{ (char *)NULL, 0, 0, 0, ""}
|
{ (char *)NULL, 0, 0, 0, ""}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *load_default_groups[]= { "mysql","client",0 };
|
static const char *load_default_groups[]=
|
||||||
|
{ "mysql", "client", "client-server", "client-mariadb", 0 };
|
||||||
|
|
||||||
static int embedded_server_arg_count= 0;
|
static int embedded_server_arg_count= 0;
|
||||||
static char *embedded_server_args[MAX_SERVER_ARGS];
|
static char *embedded_server_args[MAX_SERVER_ARGS];
|
||||||
|
@ -816,8 +816,10 @@ static int run_sql_fix_privilege_tables(void)
|
|||||||
|
|
||||||
static const char *load_default_groups[]=
|
static const char *load_default_groups[]=
|
||||||
{
|
{
|
||||||
"client", /* Read settings how to connect to server */
|
"client", /* Read settings how to connect to server */
|
||||||
"mysql_upgrade", /* Read special settings for mysql_upgrade*/
|
"mysql_upgrade", /* Read special settings for mysql_upgrade */
|
||||||
|
"client-server", /* Reads settings common between client & server */
|
||||||
|
"client-mariadb", /* Read mariadb unique client settings */
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -223,7 +223,8 @@ static struct my_option my_long_options[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static const char *load_default_groups[]= { "mysqladmin","client",0 };
|
static const char *load_default_groups[]=
|
||||||
|
{ "mysqladmin", "client", "client-server", "client-mariadb", 0 };
|
||||||
|
|
||||||
my_bool
|
my_bool
|
||||||
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||||
|
@ -65,7 +65,8 @@ static FILE *result_file;
|
|||||||
#ifndef DBUG_OFF
|
#ifndef DBUG_OFF
|
||||||
static const char* default_dbug_option = "d:t:o,/tmp/mysqlbinlog.trace";
|
static const char* default_dbug_option = "d:t:o,/tmp/mysqlbinlog.trace";
|
||||||
#endif
|
#endif
|
||||||
static const char *load_default_groups[]= { "mysqlbinlog","client",0 };
|
static const char *load_default_groups[]=
|
||||||
|
{ "mysqlbinlog", "client", "client-server", "client-mariadb", 0 };
|
||||||
|
|
||||||
static void error(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
|
static void error(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
|
||||||
static void warning(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
|
static void warning(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
|
||||||
|
@ -187,7 +187,8 @@ static struct my_option my_long_options[] =
|
|||||||
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
|
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *load_default_groups[] = { "mysqlcheck", "client", 0 };
|
static const char *load_default_groups[]=
|
||||||
|
{ "mysqlcheck", "client", "client-server", "client-mariadb", 0 };
|
||||||
|
|
||||||
|
|
||||||
static void print_version(void);
|
static void print_version(void);
|
||||||
|
@ -480,7 +480,8 @@ static struct my_option my_long_options[] =
|
|||||||
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
|
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *load_default_groups[]= { "mysqldump","client",0 };
|
static const char *load_default_groups[]=
|
||||||
|
{ "mysqldump", "client", "client-server", "client-mariadb", 0 };
|
||||||
|
|
||||||
static void maybe_exit(int error);
|
static void maybe_exit(int error);
|
||||||
static void die(int error, const char* reason, ...);
|
static void die(int error, const char* reason, ...);
|
||||||
|
@ -183,7 +183,8 @@ static struct my_option my_long_options[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static const char *load_default_groups[]= { "mysqlimport","client",0 };
|
static const char *load_default_groups[]=
|
||||||
|
{ "mysqlimport","client", "client-server", "client-mariadb", 0 };
|
||||||
|
|
||||||
#include <help_start.h>
|
#include <help_start.h>
|
||||||
|
|
||||||
|
@ -53,7 +53,8 @@ static void print_res_header(MYSQL_RES *result);
|
|||||||
static void print_res_top(MYSQL_RES *result);
|
static void print_res_top(MYSQL_RES *result);
|
||||||
static void print_res_row(MYSQL_RES *result,MYSQL_ROW cur);
|
static void print_res_row(MYSQL_RES *result,MYSQL_ROW cur);
|
||||||
|
|
||||||
static const char *load_default_groups[]= { "mysqlshow","client",0 };
|
static const char *load_default_groups[]=
|
||||||
|
{ "mysqlshow","client", "client-server", "client-mariadb", 0 };
|
||||||
static char * opt_mysql_unix_port=0;
|
static char * opt_mysql_unix_port=0;
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
@ -178,7 +178,8 @@ static uint opt_protocol= 0;
|
|||||||
static int get_options(int *argc,char ***argv);
|
static int get_options(int *argc,char ***argv);
|
||||||
static uint opt_mysql_port= 0;
|
static uint opt_mysql_port= 0;
|
||||||
|
|
||||||
static const char *load_default_groups[]= { "mysqlslap","client",0 };
|
static const char *load_default_groups[]=
|
||||||
|
{ "mysqlslap", "client", "client-server", "client-mariadb", 0 };
|
||||||
|
|
||||||
typedef struct statement statement;
|
typedef struct statement statement;
|
||||||
|
|
||||||
|
@ -118,7 +118,8 @@ static my_bool abort_on_error= 1;
|
|||||||
static my_bool server_initialized= 0;
|
static my_bool server_initialized= 0;
|
||||||
static my_bool is_windows= 0;
|
static my_bool is_windows= 0;
|
||||||
static char **default_argv;
|
static char **default_argv;
|
||||||
static const char *load_default_groups[]= { "mysqltest", "client", 0 };
|
static const char *load_default_groups[]=
|
||||||
|
{ "mysqltest", "client", "client-server", "client-mariadb", 0 };
|
||||||
static char line_buffer[MAX_DELIMITER_LENGTH], *line_buffer_pos= line_buffer;
|
static char line_buffer[MAX_DELIMITER_LENGTH], *line_buffer_pos= line_buffer;
|
||||||
|
|
||||||
static uint start_lineno= 0; /* Start line of current command */
|
static uint start_lineno= 0; /* Start line of current command */
|
||||||
|
@ -104,7 +104,7 @@ static void usage(my_bool version)
|
|||||||
my_print_help(my_long_options);
|
my_print_help(my_long_options);
|
||||||
my_print_default_files(config_file);
|
my_print_default_files(config_file);
|
||||||
my_print_variables(my_long_options);
|
my_print_variables(my_long_options);
|
||||||
printf("\nExample usage:\n%s --defaults-file=example.cnf client mysql\n", my_progname);
|
printf("\nExample usage:\n%s --defaults-file=example.cnf client client-server mysql\n", my_progname);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <help_end.h>
|
#include <help_end.h>
|
||||||
|
@ -103,7 +103,7 @@ do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables`
|
parse_arguments `$print_defaults $defaults mysql_install_db client client-server client-mariadb mysql_fix_privilege_tables`
|
||||||
parse_arguments PICK-ARGS-FROM-ARGV "$@"
|
parse_arguments PICK-ARGS-FROM-ARGV "$@"
|
||||||
|
|
||||||
if test -z "$password"
|
if test -z "$password"
|
||||||
|
@ -116,7 +116,7 @@ sub parse_arguments
|
|||||||
"basedir=s",
|
"basedir=s",
|
||||||
"builddir=s", # FIXME not documented
|
"builddir=s", # FIXME not documented
|
||||||
"srcdir=s",
|
"srcdir=s",
|
||||||
"ldata|datadir=s",
|
"ldata|datadir|data=s",
|
||||||
|
|
||||||
# Note that the user will be passed to mysqld so that it runs
|
# Note that the user will be passed to mysqld so that it runs
|
||||||
# as 'user' (crucial e.g. if log-bin=/some_other_path/
|
# as 'user' (crucial e.g. if log-bin=/some_other_path/
|
||||||
@ -274,7 +274,7 @@ else
|
|||||||
|
|
||||||
my @default_options;
|
my @default_options;
|
||||||
my $cmd = quote_options($print_defaults,$opt->{'defaults-file'},
|
my $cmd = quote_options($print_defaults,$opt->{'defaults-file'},
|
||||||
"mysqld","mysql_install_db");
|
"mysqld","mariadb","mysql_install_db","server","client-server");
|
||||||
open(PIPE, "$cmd |") or error($opt,"can't run $cmd: $!");
|
open(PIPE, "$cmd |") or error($opt,"can't run $cmd: $!");
|
||||||
while ( <PIPE> )
|
while ( <PIPE> )
|
||||||
{
|
{
|
||||||
|
@ -103,7 +103,7 @@ parse_arguments()
|
|||||||
--basedir=*) basedir=`parse_arg "$arg"` ;;
|
--basedir=*) basedir=`parse_arg "$arg"` ;;
|
||||||
--builddir=*) builddir=`parse_arg "$arg"` ;;
|
--builddir=*) builddir=`parse_arg "$arg"` ;;
|
||||||
--srcdir=*) srcdir=`parse_arg "$arg"` ;;
|
--srcdir=*) srcdir=`parse_arg "$arg"` ;;
|
||||||
--ldata=*|--datadir=*) ldata=`parse_arg "$arg"` ;;
|
--ldata=*|--datadir=*|--data=*) ldata=`parse_arg "$arg"` ;;
|
||||||
--user=*)
|
--user=*)
|
||||||
# Note that the user will be passed to mysqld so that it runs
|
# Note that the user will be passed to mysqld so that it runs
|
||||||
# as 'user' (crucial e.g. if log-bin=/some_other_path/
|
# as 'user' (crucial e.g. if log-bin=/some_other_path/
|
||||||
@ -242,7 +242,7 @@ fi
|
|||||||
|
|
||||||
# Now we can get arguments from the groups [mysqld] and [mysql_install_db]
|
# Now we can get arguments from the groups [mysqld] and [mysql_install_db]
|
||||||
# in the my.cfg file, then re-run to merge with command line arguments.
|
# in the my.cfg file, then re-run to merge with command line arguments.
|
||||||
parse_arguments `$print_defaults $defaults mysqld mysql_install_db`
|
parse_arguments `$print_defaults $defaults mysqld mariadb mysql_install_db client-server`
|
||||||
parse_arguments PICK-ARGS-FROM-ARGV "$@"
|
parse_arguments PICK-ARGS-FROM-ARGV "$@"
|
||||||
|
|
||||||
# Configure paths to support files
|
# Configure paths to support files
|
||||||
@ -384,7 +384,7 @@ fi
|
|||||||
mysqld_bootstrap="${MYSQLD_BOOTSTRAP-$mysqld}"
|
mysqld_bootstrap="${MYSQLD_BOOTSTRAP-$mysqld}"
|
||||||
mysqld_install_cmd_line="$mysqld_bootstrap $defaults $mysqld_opt --bootstrap \
|
mysqld_install_cmd_line="$mysqld_bootstrap $defaults $mysqld_opt --bootstrap \
|
||||||
--basedir=$basedir --datadir=$ldata --log-warnings=0 --loose-skip-innodb \
|
--basedir=$basedir --datadir=$ldata --log-warnings=0 --loose-skip-innodb \
|
||||||
--loose-skip-ndbcluster $args --max_allowed_packet=8M \
|
--loose-skip-ndbcluster --loose-skip-pbxt $args --max_allowed_packet=8M \
|
||||||
--default-storage-engine=myisam \
|
--default-storage-engine=myisam \
|
||||||
--net_buffer_length=16K"
|
--net_buffer_length=16K"
|
||||||
|
|
||||||
|
@ -165,9 +165,9 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Now we can get arguments from the group [client]
|
# Now we can get arguments from the group [client] and [client-server]
|
||||||
# in the my.cfg file, then re-run to merge with command line arguments.
|
# in the my.cfg file, then re-run to merge with command line arguments.
|
||||||
parse_arguments `$print_defaults $defaults client`
|
parse_arguments `$print_defaults $defaults client client-server client-mariadb`
|
||||||
parse_arguments PICK-ARGS-FROM-ARGV "$@"
|
parse_arguments PICK-ARGS-FROM-ARGV "$@"
|
||||||
|
|
||||||
# Configure paths to support files
|
# Configure paths to support files
|
||||||
|
@ -200,7 +200,7 @@ sub defaults_for_group
|
|||||||
|
|
||||||
sub init_log
|
sub init_log
|
||||||
{
|
{
|
||||||
foreach my $opt (defaults_for_group('mysqld'))
|
foreach my $opt (defaults_for_group('mysqld mariadb'))
|
||||||
{
|
{
|
||||||
if ($opt =~ m/^--datadir=(.*)/ && -d "$1" && -w "$1")
|
if ($opt =~ m/^--datadir=(.*)/ && -d "$1" && -w "$1")
|
||||||
{
|
{
|
||||||
|
@ -313,7 +313,7 @@ append_arg_to_args () {
|
|||||||
args=
|
args=
|
||||||
|
|
||||||
SET_USER=2
|
SET_USER=2
|
||||||
parse_arguments `$print_defaults $defaults --loose-verbose mysqld server`
|
parse_arguments `$print_defaults $defaults --loose-verbose mysqld mariadb server client-server`
|
||||||
if test $SET_USER -eq 2
|
if test $SET_USER -eq 2
|
||||||
then
|
then
|
||||||
SET_USER=0
|
SET_USER=0
|
||||||
|
@ -20,13 +20,13 @@ GetOptions(\%opt,
|
|||||||
'v|verbose+',# verbose
|
'v|verbose+',# verbose
|
||||||
'help+', # write usage info
|
'help+', # write usage info
|
||||||
'd|debug+', # debug
|
'd|debug+', # debug
|
||||||
's=s', # what to sort by (al, at, ar, c, t, l, r)
|
's=s', # what to sort by (al, at, ar, ae, c, t, l, r, e)
|
||||||
'r!', # reverse the sort order (largest last instead of first)
|
'r!', # reverse the sort order (largest last instead of first)
|
||||||
't=i', # just show the top n queries
|
't=i', # just show the top n queries
|
||||||
'a!', # don't abstract all numbers to N and strings to 'S'
|
'a!', # don't abstract all numbers to N and strings to 'S'
|
||||||
'n=i', # abstract numbers with at least n digits within names
|
'n=i', # abstract numbers with at least n digits within names
|
||||||
'g=s', # grep: only consider stmts that include this string
|
'g=s', # grep: only consider stmts that include this string
|
||||||
'h=s', # hostname of db server for *-slow.log filename (can be wildcard)
|
'h=s', # hostname/basename of db server for *-slow.log filename (can be wildcard)
|
||||||
'i=s', # name of server instance (if using mysql.server startup script)
|
'i=s', # name of server instance (if using mysql.server startup script)
|
||||||
'l!', # don't subtract lock time from total time
|
'l!', # don't subtract lock time from total time
|
||||||
) or usage("bad option");
|
) or usage("bad option");
|
||||||
@ -34,34 +34,42 @@ GetOptions(\%opt,
|
|||||||
$opt{'help'} and usage();
|
$opt{'help'} and usage();
|
||||||
|
|
||||||
unless (@ARGV) {
|
unless (@ARGV) {
|
||||||
my $defaults = `my_print_defaults mysqld`;
|
my $defaults = `my_print_defaults mysqld mariadb`;
|
||||||
my $basedir = ($defaults =~ m/--basedir=(.*)/)[0]
|
|
||||||
or die "Can't determine basedir from 'my_print_defaults mysqld' output: $defaults";
|
|
||||||
warn "basedir=$basedir\n" if $opt{v};
|
|
||||||
|
|
||||||
my $datadir = ($defaults =~ m/--datadir=(.*)/)[0];
|
my $datadir = ($defaults =~ m/--datadir=(.*)/g)[-1];
|
||||||
my $slowlog = ($defaults =~ m/--log-slow-queries=(.*)/)[0];
|
|
||||||
if (!$datadir or $opt{i}) {
|
if (!$datadir or $opt{i}) {
|
||||||
# determine the datadir from the instances section of /etc/my.cnf, if any
|
# determine the datadir from the instances section of /etc/my.cnf, if any
|
||||||
my $instances = `my_print_defaults instances`;
|
my $instances = `my_print_defaults instances`;
|
||||||
die "Can't determine datadir from 'my_print_defaults mysqld' output: $defaults"
|
die "Can't determine datadir from 'my_print_defaults instances' output: $defaults"
|
||||||
unless $instances;
|
unless $instances;
|
||||||
my @instances = ($instances =~ m/^--(\w+)-/mg);
|
my @instances = ($instances =~ m/^--(\w+)-/mg);
|
||||||
die "No -i 'instance_name' specified to select among known instances: @instances.\n"
|
die "No -i 'instance_name' specified to select among known instances: @instances.\n"
|
||||||
unless $opt{i};
|
unless $opt{i};
|
||||||
die "Instance '$opt{i}' is unknown (known instances: @instances)\n"
|
die "Instance '$opt{i}' is unknown (known instances: @instances)\n"
|
||||||
unless grep { $_ eq $opt{i} } @instances;
|
unless grep { $_ eq $opt{i} } @instances;
|
||||||
$datadir = ($instances =~ m/--$opt{i}-datadir=(.*)/)[0]
|
$datadir = ($instances =~ m/--$opt{i}-datadir=(.*)/g)[-1]
|
||||||
or die "Can't determine --$opt{i}-datadir from 'my_print_defaults instances' output: $instances";
|
or die "Can't determine --$opt{i}-datadir from 'my_print_defaults instances' output: $instances";
|
||||||
warn "datadir=$datadir\n" if $opt{v};
|
warn "datadir=$datadir\n" if $opt{v};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( -f $slowlog ) {
|
my $slowlog = ($defaults =~ m/--log[-_]slow[-_]queries=(.*)/g)[-1];
|
||||||
|
if (!$slowlog)
|
||||||
|
{
|
||||||
|
$slowlog = ($defaults =~ m/--slow[-_]query[-_]log[-_]file=(.*)/g)[-1];
|
||||||
|
}
|
||||||
|
if ( $slowlog )
|
||||||
|
{
|
||||||
@ARGV = ($slowlog);
|
@ARGV = ($slowlog);
|
||||||
die "Can't find '$slowlog'\n" unless @ARGV;
|
die "Can't find '$slowlog'\n" unless @ARGV;
|
||||||
} else {
|
}
|
||||||
@ARGV = <$datadir/$opt{h}-slow.log>;
|
else
|
||||||
die "Can't find '$datadir/$opt{h}-slow.log'\n" unless @ARGV;
|
{
|
||||||
|
if (!$opt{h})
|
||||||
|
{
|
||||||
|
$opt{h}= ($defaults =~ m/--log[-_]basename=(.*)/g)[-1];
|
||||||
|
}
|
||||||
|
@ARGV = <$datadir/$opt{h}-slow.log>;
|
||||||
|
die "Can't find '$datadir/$opt{h}-slow.log'\n" unless @ARGV;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,8 +91,10 @@ while ( defined($_ = shift @pending) or defined($_ = <>) ) {
|
|||||||
s/^#? Time: \d{6}\s+\d+:\d+:\d+.*\n//;
|
s/^#? Time: \d{6}\s+\d+:\d+:\d+.*\n//;
|
||||||
my ($user,$host) = s/^#? User\@Host:\s+(\S+)\s+\@\s+(\S+).*\n// ? ($1,$2) : ('','');
|
my ($user,$host) = s/^#? User\@Host:\s+(\S+)\s+\@\s+(\S+).*\n// ? ($1,$2) : ('','');
|
||||||
|
|
||||||
s/^# Query_time: ([0-9.]+)\s+Lock_time: ([0-9.]+)\s+Rows_sent: ([0-9.]+).*\n//;
|
s/^# Thread_id: [0-9]+\s+Schema: [^\n]+\n//;
|
||||||
my ($t, $l, $r) = ($1, $2, $3);
|
s/^# Query_time: ([0-9.]+)\s+Lock_time: ([0-9.]+)\s+Rows_sent: ([0-9.]+)\s+Rows_examined: ([0-9.]+).*\n//;
|
||||||
|
my ($t, $l, $r, $e) = ($1, $2, $3, $4);
|
||||||
|
|
||||||
$t -= $l unless $opt{l};
|
$t -= $l unless $opt{l};
|
||||||
|
|
||||||
# remove fluff that mysqld writes to log when it (re)starts:
|
# remove fluff that mysqld writes to log when it (re)starts:
|
||||||
@ -92,6 +102,11 @@ while ( defined($_ = shift @pending) or defined($_ = <>) ) {
|
|||||||
s!^Tcp port: \d+ Unix socket: \S+\n!!mg;
|
s!^Tcp port: \d+ Unix socket: \S+\n!!mg;
|
||||||
s!^Time.*Id.*Command.*Argument.*\n!!mg;
|
s!^Time.*Id.*Command.*Argument.*\n!!mg;
|
||||||
|
|
||||||
|
# Remove optimizer info
|
||||||
|
s!^# QC_Hit: \S+\s+Full_scan: \S+\s+Full_join: \S+\s+Tmp_table: \S+\s+Tmp_table_on_disk: \S+[^\n]+\n!!mg;
|
||||||
|
s!^# Filesort: \S+\s+Filesort_on_disk: \S+[^\n]+\n!!mg;
|
||||||
|
s!^# Full_scan: \S+\s+Full_join: \S+[^\n]+\n!!mg;
|
||||||
|
|
||||||
s/^use \w+;\n//; # not consistently added
|
s/^use \w+;\n//; # not consistently added
|
||||||
s/^SET timestamp=\d+;\n//;
|
s/^SET timestamp=\d+;\n//;
|
||||||
|
|
||||||
@ -121,6 +136,7 @@ while ( defined($_ = shift @pending) or defined($_ = <>) ) {
|
|||||||
$s->{t} += $t;
|
$s->{t} += $t;
|
||||||
$s->{l} += $l;
|
$s->{l} += $l;
|
||||||
$s->{r} += $r;
|
$s->{r} += $r;
|
||||||
|
$s->{e} += $e;
|
||||||
$s->{users}->{$user}++ if $user;
|
$s->{users}->{$user}++ if $user;
|
||||||
$s->{hosts}->{$host}++ if $host;
|
$s->{hosts}->{$host}++ if $host;
|
||||||
|
|
||||||
@ -129,10 +145,11 @@ while ( defined($_ = shift @pending) or defined($_ = <>) ) {
|
|||||||
|
|
||||||
foreach (keys %stmt) {
|
foreach (keys %stmt) {
|
||||||
my $v = $stmt{$_} || die;
|
my $v = $stmt{$_} || die;
|
||||||
my ($c, $t, $l, $r) = @{ $v }{qw(c t l r)};
|
my ($c, $t, $l, $r, $e) = @{ $v }{qw(c t l r e)};
|
||||||
$v->{at} = $t / $c;
|
$v->{at} = $t / $c;
|
||||||
$v->{al} = $l / $c;
|
$v->{al} = $l / $c;
|
||||||
$v->{ar} = $r / $c;
|
$v->{ar} = $r / $c;
|
||||||
|
$v->{ae} = $e / $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
my @sorted = sort { $stmt{$b}->{$opt{s}} <=> $stmt{$a}->{$opt{s}} } keys %stmt;
|
my @sorted = sort { $stmt{$b}->{$opt{s}} <=> $stmt{$a}->{$opt{s}} } keys %stmt;
|
||||||
@ -141,13 +158,13 @@ my @sorted = sort { $stmt{$b}->{$opt{s}} <=> $stmt{$a}->{$opt{s}} } keys %stmt;
|
|||||||
|
|
||||||
foreach (@sorted) {
|
foreach (@sorted) {
|
||||||
my $v = $stmt{$_} || die;
|
my $v = $stmt{$_} || die;
|
||||||
my ($c, $t,$at, $l,$al, $r,$ar) = @{ $v }{qw(c t at l al r ar)};
|
my ($c, $t,$at, $l,$al, $r,$ar,$e, $ae) = @{ $v }{qw(c t at l al r ar e ae)};
|
||||||
my @users = keys %{$v->{users}};
|
my @users = keys %{$v->{users}};
|
||||||
my $user = (@users==1) ? $users[0] : sprintf "%dusers",scalar @users;
|
my $user = (@users==1) ? $users[0] : sprintf "%dusers",scalar @users;
|
||||||
my @hosts = keys %{$v->{hosts}};
|
my @hosts = keys %{$v->{hosts}};
|
||||||
my $host = (@hosts==1) ? $hosts[0] : sprintf "%dhosts",scalar @hosts;
|
my $host = (@hosts==1) ? $hosts[0] : sprintf "%dhosts",scalar @hosts;
|
||||||
printf "Count: %d Time=%.2fs (%ds) Lock=%.2fs (%ds) Rows=%.1f (%d), $user\@$host\n%s\n\n",
|
printf "Count: %d Time=%.2fs (%ds) Lock=%.2fs (%ds) Rows_sent=%.1f (%d), Rows_examined=%.1f (%d), $user\@$host\n%s\n\n",
|
||||||
$c, $at,$t, $al,$l, $ar,$r, $_;
|
$c, $at,$t, $al,$l, $ar,$r, $ae, $e, $_;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub usage {
|
sub usage {
|
||||||
@ -163,7 +180,7 @@ Parse and summarize the MySQL slow query log. Options are
|
|||||||
|
|
||||||
-v verbose
|
-v verbose
|
||||||
-d debug
|
-d debug
|
||||||
-s ORDER what to sort by (al, at, ar, c, l, r, t), 'at' is default
|
-s ORDER what to sort by (al, at, ar, ae, c, l, r, e, t), 'at' is default
|
||||||
al: average lock time
|
al: average lock time
|
||||||
ar: average rows sent
|
ar: average rows sent
|
||||||
at: average query time
|
at: average query time
|
||||||
|
@ -1064,12 +1064,16 @@ void mysql_read_default_options(struct st_mysql_options *options,
|
|||||||
{
|
{
|
||||||
int argc;
|
int argc;
|
||||||
char *argv_buff[1],**argv;
|
char *argv_buff[1],**argv;
|
||||||
const char *groups[3];
|
const char *groups[5];
|
||||||
DBUG_ENTER("mysql_read_default_options");
|
DBUG_ENTER("mysql_read_default_options");
|
||||||
DBUG_PRINT("enter",("file: %s group: %s",filename,group ? group :"NULL"));
|
DBUG_PRINT("enter",("file: %s group: %s",filename,group ? group :"NULL"));
|
||||||
|
|
||||||
argc=1; argv=argv_buff; argv_buff[0]= (char*) "client";
|
argc=1; argv=argv_buff; argv_buff[0]= (char*) "client";
|
||||||
groups[0]= (char*) "client"; groups[1]= (char*) group; groups[2]=0;
|
groups[0]= (char*) "client";
|
||||||
|
groups[1]= (char*) "client-server";
|
||||||
|
groups[2]= (char*) "client-mariadb";
|
||||||
|
groups[3]= (char*) group;
|
||||||
|
groups[4]=0;
|
||||||
|
|
||||||
my_load_defaults(filename, groups, &argc, &argv, NULL);
|
my_load_defaults(filename, groups, &argc, &argv, NULL);
|
||||||
if (argc != 1) /* If some default option */
|
if (argc != 1) /* If some default option */
|
||||||
|
@ -18446,7 +18446,8 @@ static void test_bug47485()
|
|||||||
Read and parse arguments and MySQL options from my.cnf
|
Read and parse arguments and MySQL options from my.cnf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const char *client_test_load_default_groups[]= { "client", 0 };
|
static const char *client_test_load_default_groups[]=
|
||||||
|
{ "client", "client-server", "client-mariadb", 0 };
|
||||||
static char **defaults_argv;
|
static char **defaults_argv;
|
||||||
|
|
||||||
static struct my_option client_test_long_options[] =
|
static struct my_option client_test_long_options[] =
|
||||||
|
@ -123,7 +123,8 @@ static struct my_option my_long_options[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static const char *load_default_groups[]= { "client",0 };
|
static const char *load_default_groups[]=
|
||||||
|
{ "client", "client-server", "client-mariadb", 0 };
|
||||||
|
|
||||||
static void usage()
|
static void usage()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user