Commit ddeeb42e authored by Eugene Kosov's avatar Eugene Kosov

Merge 10.1 into 10.2

parents 75833ef9 cf403934
SpaceBeforeAssignmentOperators: false
SpaceAfterCStyleCast: true
BreakBeforeBraces: Custom
---
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
......@@ -13,6 +34,84 @@ BraceWrapping:
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakStringLiterals: true
ColumnLimit: 79
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
Language: Cpp
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseTab: Never
...
......@@ -36,6 +36,21 @@ use POSIX qw[ _exit ];
use IO::Handle qw[ flush ];
use mtr_results;
use Term::ANSIColor;
my %color_map = qw/pass green
retry-pass green
fail red
retry-fail red
disabled bright_black
skipped yellow
reset reset/;
sub xterm_color {
if (-t STDOUT and defined $ENV{TERM} and $ENV{TERM} =~ /xterm/) {
syswrite STDOUT, color($color_map{$_[0]});
}
}
my $tot_real_time= 0;
our $timestamp= 0;
......@@ -498,7 +513,16 @@ sub mtr_print (@) {
sub mtr_report (@) {
if (defined $verbose)
{
print _name(). join(" ", @_). "\n";
my @s = split /\[ (\S+) \]/, _name() . "@_\n";
if (@s > 1) {
print $s[0];
xterm_color($s[1]);
print "[ $s[1] ]";
xterm_color('reset');
print $s[2];
} else {
print $s[0];
}
}
}
......
......@@ -2510,6 +2510,40 @@ WHERE tb1.pk = 40
ORDER BY tb1.i1;
v2
DROP TABLE t1,t2;
#
# MDEV-19790 : IS NOT TRUE / IS NOT FALSE predicates over
# inner tables of outer joins
#
create table t1 (a int);
create table t2 (b int);
insert into t1 values (3), (7), (1);
insert into t2 values (7), (4), (3);
select * from t1 left join t2 on a=b;
a b
3 3
7 7
1 NULL
select * from t1 left join t2 on a=b where (b > 3) is not true;
a b
3 3
1 NULL
explain extended select * from t1 left join t2 on a=b where (b > 3) is not true;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`b` = `test`.`t1`.`a`) where `test`.`t2`.`b` > 3 is not true
select * from t1 left join t2 on a=b where (b > 3) is not false;
a b
7 7
1 NULL
explain extended select * from t1 left join t2 on a=b where (b > 3) is not false;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`b` = `test`.`t1`.`a`) where `test`.`t2`.`b` > 3 is not false
drop table t1,t2;
# end of 5.5 tests
#
# MDEV-19258: chained right joins all converted to inner joins
......
......@@ -2521,6 +2521,40 @@ WHERE tb1.pk = 40
ORDER BY tb1.i1;
v2
DROP TABLE t1,t2;
#
# MDEV-19790 : IS NOT TRUE / IS NOT FALSE predicates over
# inner tables of outer joins
#
create table t1 (a int);
create table t2 (b int);
insert into t1 values (3), (7), (1);
insert into t2 values (7), (4), (3);
select * from t1 left join t2 on a=b;
a b
7 7
3 3
1 NULL
select * from t1 left join t2 on a=b where (b > 3) is not true;
a b
3 3
1 NULL
explain extended select * from t1 left join t2 on a=b where (b > 3) is not true;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`b` = `test`.`t1`.`a`) where `test`.`t2`.`b` > 3 is not true
select * from t1 left join t2 on a=b where (b > 3) is not false;
a b
7 7
1 NULL
explain extended select * from t1 left join t2 on a=b where (b > 3) is not false;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`b` = `test`.`t1`.`a`) where `test`.`t2`.`b` > 3 is not false
drop table t1,t2;
# end of 5.5 tests
#
# MDEV-19258: chained right joins all converted to inner joins
......
......@@ -2040,6 +2040,29 @@ ORDER BY tb1.i1;
DROP TABLE t1,t2;
--echo #
--echo # MDEV-19790 : IS NOT TRUE / IS NOT FALSE predicates over
--echo # inner tables of outer joins
--echo #
create table t1 (a int);
create table t2 (b int);
insert into t1 values (3), (7), (1);
insert into t2 values (7), (4), (3);
select * from t1 left join t2 on a=b;
let $q=
select * from t1 left join t2 on a=b where (b > 3) is not true;
eval $q;
eval explain extended $q;
let $q=
select * from t1 left join t2 on a=b where (b > 3) is not false;
eval $q;
eval explain extended $q;
drop table t1,t2;
--echo # end of 5.5 tests
--echo #
......
......@@ -19,6 +19,7 @@
#include <mntent.h>
#include <sql_class.h>
#include <table.h>
#include <sql_acl.h> /* check_global_access() */
bool schema_table_store_record(THD *thd, TABLE *table);
......@@ -83,6 +84,9 @@ int disks_fill_table(THD* pThd, TABLE_LIST* pTables, Item* pCond)
int rv = 1;
TABLE* pTable = pTables->table;
if (check_global_access(pThd, FILE_ACL, true))
return 0;
FILE* pFile = setmntent("/etc/mtab", "r");
if (pFile)
......@@ -144,11 +148,11 @@ maria_declare_plugin(disks)
PLUGIN_LICENSE_GPL, /* license type */
disks_table_init, /* init function */
NULL, /* deinit function */
0x0100, /* version = 1.0 */
0x0101, /* version = 1.1 */
NULL, /* no status variables */
NULL, /* no system variables */
"1.0", /* String version representation */
MariaDB_PLUGIN_MATURITY_BETA /* Maturity (see include/mysql/plugin.h)*/
"1.1", /* String version representation */
MariaDB_PLUGIN_MATURITY_STABLE /* Maturity (see include/mysql/plugin.h)*/
}
mysql_declare_plugin_end;
......
#
# MDEV-18328: Make DISKS plugin check some privilege to access
# information_schema.DISKS table
#
CREATE USER user1@localhost;
GRANT SELECT ON *.* TO user1@localhost;
connect con1,localhost,user1,,;
connection con1;
select sum(Total) > sum(Available), sum(Total)>sum(Used) from information_schema.disks;
sum(Total) > sum(Available) sum(Total)>sum(Used)
NULL NULL
disconnect con1;
connection default;
GRANT FILE ON *.* TO user1@localhost;
connect con1,localhost,user1,,;
connection con1;
select sum(Total) > sum(Available), sum(Total)>sum(Used) from information_schema.disks;
sum(Total) > sum(Available) sum(Total)>sum(Used)
1 1
connection default;
DROP USER user1@localhost;
# End of 10.1 tests
source include/not_embedded.inc;
--echo #
--echo # MDEV-18328: Make DISKS plugin check some privilege to access
--echo # information_schema.DISKS table
--echo #
CREATE USER user1@localhost;
GRANT SELECT ON *.* TO user1@localhost;
connect (con1,localhost,user1,,);
connection con1;
select sum(Total) > sum(Available), sum(Total)>sum(Used) from information_schema.disks;
disconnect con1;
connection default;
GRANT FILE ON *.* TO user1@localhost;
connect (con1,localhost,user1,,);
connection con1;
select sum(Total) > sum(Available), sum(Total)>sum(Used) from information_schema.disks;
connection default;
DROP USER user1@localhost;
--echo # End of 10.1 tests
......@@ -15,7 +15,7 @@
#define PLUGIN_VERSION 0x104
#define PLUGIN_STR_VERSION "1.4.6"
#define PLUGIN_STR_VERSION "1.4.7"
#define _my_thread_var loc_thread_var
......@@ -292,7 +292,7 @@ static unsigned long long file_rotate_size;
static unsigned int rotations;
static my_bool rotate= TRUE;
static char logging;
static int internal_stop_logging= 0;
static volatile int internal_stop_logging= 0;
static char incl_user_buffer[1024];
static char excl_user_buffer[1024];
static char *big_buffer= NULL;
......@@ -534,16 +534,20 @@ static struct st_mysql_show_var audit_status[]=
#if defined(HAVE_PSI_INTERFACE) && !defined(FLOGGER_NO_PSI)
/* These belong to the service initialization */
static PSI_mutex_key key_LOCK_operations;
static PSI_mutex_key key_LOCK_atomic;
static PSI_mutex_key key_LOCK_bigbuffer;
static PSI_mutex_info mutex_key_list[]=
{
{ &key_LOCK_operations, "SERVER_AUDIT_plugin::lock_operations",
PSI_FLAG_GLOBAL},
{ &key_LOCK_atomic, "SERVER_AUDIT_plugin::lock_atomic",
PSI_FLAG_GLOBAL},
{ &key_LOCK_bigbuffer, "SERVER_AUDIT_plugin::lock_bigbuffer",
PSI_FLAG_GLOBAL}
};
#endif
static mysql_mutex_t lock_operations;
static mysql_mutex_t lock_atomic;
static mysql_mutex_t lock_bigbuffer;
/* The Percona server and partly MySQL don't support */
......@@ -554,6 +558,14 @@ static mysql_mutex_t lock_bigbuffer;
/* worths doing. */
#define CLIENT_ERROR if (!started_mysql) my_printf_error
#define ADD_ATOMIC(x, a) \
do { \
flogger_mutex_lock(&lock_atomic); \
x+= a; \
flogger_mutex_unlock(&lock_atomic); \
} while (0)
static uchar *getkey_user(const char *entry, size_t *length,
my_bool nu __attribute__((unused)) )
{
......@@ -732,20 +744,20 @@ static int user_coll_fill(struct user_coll *c, char *users,
if (cmp_user && take_over_cmp)
{
internal_stop_logging= 1;
ADD_ATOMIC(internal_stop_logging, 1);
CLIENT_ERROR(1, "User '%.*s' was removed from the"
" server_audit_excl_users.",
MYF(ME_JUST_WARNING), (int) cmp_length, users);
internal_stop_logging= 0;
ADD_ATOMIC(internal_stop_logging, -1);
blank_user(cmp_user);
refill_cmp_coll= 1;
}
else if (cmp_user)
{
internal_stop_logging= 1;
ADD_ATOMIC(internal_stop_logging, 1);
CLIENT_ERROR(1, "User '%.*s' is in the server_audit_incl_users, "
"so wasn't added.", MYF(ME_JUST_WARNING), (int) cmp_length, users);
internal_stop_logging= 0;
ADD_ATOMIC(internal_stop_logging, -1);
remove_user(users);
continue;
}
......@@ -1253,23 +1265,30 @@ static void change_connection(struct connection_info *cn,
event->ip, event->ip_length);
}
static int write_log(const char *message, size_t len)
static int write_log(const char *message, size_t len, int take_lock)
{
int result= 0;
if (take_lock)
flogger_mutex_lock(&lock_operations);
if (output_type == OUTPUT_FILE)
{
if (logfile &&
(is_active= (logger_write(logfile, message, len) == (int)len)))
return 0;
(is_active= (logger_write(logfile, message, len) == (int) len)))
goto exit;
++log_write_failures;
return 1;
result= 1;
}
else if (output_type == OUTPUT_SYSLOG)
{
syslog(syslog_facility_codes[syslog_facility] |
syslog_priority_codes[syslog_priority],
"%s %.*s", syslog_info, (int)len, message);
"%s %.*s", syslog_info, (int) len, message);
}
return 0;
exit:
if (take_lock)
flogger_mutex_unlock(&lock_operations);
return result;
}
......@@ -1328,7 +1347,7 @@ static int log_connection(const struct connection_info *cn,
csize+= my_snprintf(message+csize, sizeof(message) - 1 - csize,
",%.*s,,%d", cn->db_length, cn->db, event->status);
message[csize]= '\n';
return write_log(message, csize + 1);
return write_log(message, csize + 1, 1);
}
......@@ -1349,7 +1368,7 @@ static int log_connection_event(const struct mysql_event_connection *event,
csize+= my_snprintf(message+csize, sizeof(message) - 1 - csize,
",%.*s,,%d", event->database_length, event->database, event->status);
message[csize]= '\n';
return write_log(message, csize + 1);
return write_log(message, csize + 1, 1);
}
......@@ -1478,21 +1497,28 @@ static size_t escape_string_hide_passwords(const char *str, unsigned int len,
static int do_log_user(const char *name)
static int do_log_user(const char *name, int take_lock)
{
size_t len;
int result;
if (!name)
return 0;
len= strlen(name);
if (incl_user_coll.n_users)
return coll_search(&incl_user_coll, name, len) != 0;
if (take_lock)
flogger_mutex_lock(&lock_operations);
if (excl_user_coll.n_users)
return coll_search(&excl_user_coll, name, len) == 0;
if (incl_user_coll.n_users)
result= coll_search(&incl_user_coll, name, len) != 0;
else if (excl_user_coll.n_users)
result= coll_search(&excl_user_coll, name, len) == 0;
else
result= 1;
return 1;
if (take_lock)
flogger_mutex_unlock(&lock_operations);
return result;
}
......@@ -1589,7 +1615,7 @@ static int filter_query_type(const char *query, struct sa_keyword *kwd)
static int log_statement_ex(const struct connection_info *cn,
time_t ev_time, unsigned long thd_id,
const char *query, unsigned int query_len,
int error_code, const char *type)
int error_code, const char *type, int take_lock)
{
size_t csize;
char message_loc[1024];
......@@ -1737,7 +1763,7 @@ static int log_statement_ex(const struct connection_info *cn,
csize+= my_snprintf(message+csize, message_size - 1 - csize,
"\',%d", error_code);
message[csize]= '\n';
result= write_log(message, csize + 1);
result= write_log(message, csize + 1, take_lock);
if (message == big_buffer)
flogger_mutex_unlock(&lock_bigbuffer);
......@@ -1751,7 +1777,7 @@ static int log_statement(const struct connection_info *cn,
{
return log_statement_ex(cn, event->general_time, event->general_thread_id,
event->general_query, event->general_query_length,
event->general_error_code, type);
event->general_error_code, type, 1);
}
......@@ -1773,7 +1799,7 @@ static int log_table(const struct connection_info *cn,
",%.*s,%.*s,",event->database_length, event->database,
event->table_length, event->table);
message[csize]= '\n';
return write_log(message, csize + 1);
return write_log(message, csize + 1, 1);
}
......@@ -1797,7 +1823,7 @@ static int log_rename(const struct connection_info *cn,
event->new_database_length, event->new_database,
event->new_table_length, event->new_table);
message[csize]= '\n';
return write_log(message, csize + 1);
return write_log(message, csize + 1, 1);
}
......@@ -1989,8 +2015,6 @@ void auditing(MYSQL_THD thd, unsigned int event_class, const void *ev)
if (!thd || internal_stop_logging)
return;
flogger_mutex_lock(&lock_operations);
if (maria_55_started && debug_server_started &&
event_class == MYSQL_AUDIT_GENERAL_CLASS)
{
......@@ -2029,7 +2053,7 @@ void auditing(MYSQL_THD thd, unsigned int event_class, const void *ev)
}
if (event_class == MYSQL_AUDIT_GENERAL_CLASS && FILTER(EVENT_QUERY) &&
cn && (cn->log_always || do_log_user(cn->user)))
cn && (cn->log_always || do_log_user(cn->user, 1)))
{
const struct mysql_event_general *event =
(const struct mysql_event_general *) ev;
......@@ -2049,7 +2073,7 @@ void auditing(MYSQL_THD thd, unsigned int event_class, const void *ev)
{
const struct mysql_event_table *event =
(const struct mysql_event_table *) ev;
if (do_log_user(event->user))
if (do_log_user(event->user, 1))
{
switch (event->event_subclass)
{
......@@ -2113,7 +2137,6 @@ void auditing(MYSQL_THD thd, unsigned int event_class, const void *ev)
break;
}
}
flogger_mutex_unlock(&lock_operations);
}
......@@ -2381,6 +2404,7 @@ static int server_audit_init(void *p __attribute__((unused)))
PSI_server->register_mutex("server_audit", mutex_key_list, 1);
#endif
flogger_mutex_init(key_LOCK_operations, &lock_operations, MY_MUTEX_INIT_FAST);
flogger_mutex_init(key_LOCK_operations, &lock_atomic, MY_MUTEX_INIT_FAST);
flogger_mutex_init(key_LOCK_operations, &lock_bigbuffer, MY_MUTEX_INIT_FAST);
coll_init(&incl_user_coll);
......@@ -2468,6 +2492,7 @@ static int server_audit_deinit(void *p __attribute__((unused)))
(void) free(big_buffer);
flogger_mutex_destroy(&lock_operations);
flogger_mutex_destroy(&lock_atomic);
flogger_mutex_destroy(&lock_bigbuffer);
error_header();
......@@ -2560,7 +2585,7 @@ static void log_current_query(MYSQL_THD thd)
{
cn->log_always= 1;
log_statement_ex(cn, cn->query_time, thd_get_thread_id(thd),
cn->query, cn->query_length, 0, "QUERY");
cn->query, cn->query_length, 0, "QUERY", 0);
cn->log_always= 0;
}
}
......@@ -2572,12 +2597,13 @@ static void update_file_path(MYSQL_THD thd,
{
char *new_name= (*(char **) save) ? *(char **) save : empty_str;
if (!maria_55_started || !debug_server_started)
flogger_mutex_lock(&lock_operations);
internal_stop_logging= 1;
ADD_ATOMIC(internal_stop_logging, 1);
error_header();
fprintf(stderr, "Log file name was changed to '%s'.\n", new_name);
if (!maria_55_started || !debug_server_started)
flogger_mutex_lock(&lock_operations);
if (logging)
log_current_query(thd);
......@@ -2586,7 +2612,6 @@ static void update_file_path(MYSQL_THD thd,
char *sav_path= file_path;
file_path= new_name;
internal_stop_logging= 1;
stop_logging();
if (start_logging())
{
......@@ -2602,16 +2627,15 @@ static void update_file_path(MYSQL_THD thd,
}
goto exit_func;
}
internal_stop_logging= 0;
}
strncpy(path_buffer, new_name, sizeof(path_buffer)-1);
path_buffer[sizeof(path_buffer)-1]= 0;
file_path= path_buffer;
exit_func:
internal_stop_logging= 0;
if (!maria_55_started || !debug_server_started)
flogger_mutex_unlock(&lock_operations);
ADD_ATOMIC(internal_stop_logging, -1);
}
......@@ -2742,8 +2766,8 @@ static void update_output_type(MYSQL_THD thd,
if (output_type == new_output_type)
return;
ADD_ATOMIC(internal_stop_logging, 1);
flogger_mutex_lock(&lock_operations);
internal_stop_logging= 1;
if (logging)
{
log_current_query(thd);
......@@ -2757,8 +2781,8 @@ static void update_output_type(MYSQL_THD thd,
if (logging)
start_logging();
internal_stop_logging= 0;
flogger_mutex_unlock(&lock_operations);
ADD_ATOMIC(internal_stop_logging, -1);
}
......@@ -2806,9 +2830,9 @@ static void update_logging(MYSQL_THD thd,
if (new_logging == logging)
return;
ADD_ATOMIC(internal_stop_logging, 1);
if (!maria_55_started || !debug_server_started)
flogger_mutex_lock(&lock_operations);
internal_stop_logging= 1;
if ((logging= new_logging))
{
start_logging();
......@@ -2824,9 +2848,9 @@ static void update_logging(MYSQL_THD thd,
stop_logging();
}
internal_stop_logging= 0;
if (!maria_55_started || !debug_server_started)
flogger_mutex_unlock(&lock_operations);
ADD_ATOMIC(internal_stop_logging, -1);
}
......@@ -2838,16 +2862,16 @@ static void update_mode(MYSQL_THD thd __attribute__((unused)),
if (mode_readonly || new_mode == mode)
return;
ADD_ATOMIC(internal_stop_logging, 1);
if (!maria_55_started || !debug_server_started)
flogger_mutex_lock(&lock_operations);
internal_stop_logging= 1;
mark_always_logged(thd);
error_header();
fprintf(stderr, "Logging mode was changed from %d to %d.\n", mode, new_mode);
mode= new_mode;
internal_stop_logging= 0;
if (!maria_55_started || !debug_server_started)
flogger_mutex_unlock(&lock_operations);
ADD_ATOMIC(internal_stop_logging, -1);
}
......
......@@ -268,6 +268,8 @@ class Item_func_isnottrue : public Item_func_truth
virtual const char* func_name() const { return "isnottrue"; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_isnottrue>(thd, mem_root, this); }
bool eval_not_null_tables(void *opt_arg)
{ not_null_tables_cache= 0; return false; }
};
......@@ -299,6 +301,8 @@ class Item_func_isnotfalse : public Item_func_truth
virtual const char* func_name() const { return "isnotfalse"; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_isnotfalse>(thd, mem_root, this); }
bool eval_not_null_tables(void *opt_arg)
{ not_null_tables_cache= 0; return false; }
};
......
......@@ -118,11 +118,26 @@ void mysql_audit_acquire_plugins(THD *thd, ulong *event_class_mask)
{
plugin_foreach(thd, acquire_plugins, MYSQL_AUDIT_PLUGIN, event_class_mask);
add_audit_mask(thd->audit_class_mask, event_class_mask);
thd->audit_plugin_version= global_plugin_version;
}
DBUG_VOID_RETURN;
}
/**
Check if there were changes in the state of plugins
so we need to do the mysql_audit_release asap.
@param[in] thd
*/
my_bool mysql_audit_release_required(THD *thd)
{
return thd && (thd->audit_plugin_version != global_plugin_version);
}
/**
Release any resources associated with the current thd.
......@@ -158,6 +173,7 @@ void mysql_audit_release(THD *thd)
/* Reset the state of thread values */
reset_dynamic(&thd->audit_class_plugins);
bzero(thd->audit_class_mask, sizeof(thd->audit_class_mask));
thd->audit_plugin_version= -1;
}
......
......@@ -60,6 +60,7 @@ static inline void mysql_audit_notify(THD *thd, uint event_class,
#define mysql_audit_connection_enabled() 0
#define mysql_audit_table_enabled() 0
#endif
extern my_bool mysql_audit_release_required(THD *thd);
extern void mysql_audit_release(THD *thd);
static inline unsigned int strlen_uint(const char *s)
......
......@@ -628,6 +628,9 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
waiting_on_group_commit(FALSE), has_waiter(FALSE),
spcont(NULL),
m_parser_state(NULL),
#ifndef EMBEDDED_LIBRARY
audit_plugin_version(-1),
#endif
#if defined(ENABLED_DEBUG_SYNC)
debug_sync_control(0),
#endif /* defined(ENABLED_DEBUG_SYNC) */
......
......@@ -3163,6 +3163,7 @@ class THD :public Statement,
added to the list of audit plugins which are currently in use.
*/
unsigned long audit_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE];
int audit_plugin_version;
#endif
#if defined(ENABLED_DEBUG_SYNC)
......
......@@ -1331,6 +1331,7 @@ void do_handle_one_connection(CONNECT *connect)
while (thd_is_connection_alive(thd))
{
if (mysql_audit_release_required(thd))
mysql_audit_release(thd);
if (do_command(thd))
break;
......
......@@ -228,6 +228,7 @@ static DYNAMIC_ARRAY plugin_array;
static HASH plugin_hash[MYSQL_MAX_PLUGIN_TYPE_NUM];
static MEM_ROOT plugin_mem_root;
static bool reap_needed= false;
volatile int global_plugin_version= 1;
static bool initialized= 0;
ulong dlopen_count;
......@@ -2193,6 +2194,7 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name,
reap_plugins();
}
err:
global_plugin_version++;
mysql_mutex_unlock(&LOCK_plugin);
if (argv)
free_defaults(argv);
......@@ -2340,6 +2342,7 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name,
}
reap_plugins();
global_plugin_version++;
mysql_mutex_unlock(&LOCK_plugin);
DBUG_RETURN(error);
......
......@@ -37,6 +37,7 @@ enum enum_plugin_load_option { PLUGIN_OFF, PLUGIN_ON, PLUGIN_FORCE,
PLUGIN_FORCE_PLUS_PERMANENT };
extern const char *global_plugin_typelib_names[];
extern volatile int global_plugin_version;
extern ulong dlopen_count;
#include <my_sys.h>
......
......@@ -361,6 +361,7 @@ static int threadpool_process_request(THD *thd)
{
Vio *vio;
thd->net.reading_or_writing= 0;
if (mysql_audit_release_required(thd))
mysql_audit_release(thd);
if ((retval= do_command(thd)) != 0)
......
UseTab: Always
TabWidth: 8
IndentWidth: 8
BreakBeforeBinaryOperators: All
PointerAlignment: Left
AlwaysBreakAfterReturnType: TopLevel
BreakBeforeBraces: Custom
BraceWrapping:
AfterFunction: true
AccessModifierOffset: -8
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