Skip to content

Commit fbd23dd

Browse files
author
Michal Jankowski
committed
Bug#34772777: mysql/plugin.h included in test_page_track_component
Problem: Headers mysql/plugin.h and my_io.h shall not be included by any component. Fix: 1) Added checks if the headers are compiled with component. 2) Remove unnecessary inclusions of the headers. 3) Copy missing declarations to components/bits/*.h and include them. Change-Id: I4e20e7e8725bed330cb4ac2856ae03098a261c79
1 parent a261e7c commit fbd23dd

35 files changed

+334
-166
lines changed

components/audit_api_message_emit/audit_api_message_emit.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
3838
#include <mysql/components/my_service.h>
3939
#include <mysql/components/service_implementation.h>
4040
#include <mysql/components/services/audit_api_message_service.h>
41+
#include <mysql/components/services/bits/my_err_bits.h>
4142
#include <mysql/components/services/udf_metadata.h>
4243
#include <mysql/components/services/udf_registration.h>
4344
#include <mysql/service_plugin_registry.h>
44-
#include <mysql_com.h>
4545

4646
#include <stdio.h>
4747
#include <stdlib.h>

components/logging/log_filter_dragnet.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
7373
"EXISTS source_line THEN unset source_line."
7474

7575
#include <mysqld_error.h>
76+
#include <cctype>
7677
#include "../sql/sql_error.h"
7778

7879
#include <mysql/components/component_implementation.h>
@@ -82,8 +83,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
8283
#include <mysql/components/services/component_sys_var_service.h>
8384
#include <mysql/components/services/mysql_system_variable.h>
8485

85-
#include "../sql/set_var.h"
86-
8786
REQUIRES_SERVICE_PLACEHOLDER(component_sys_variable_register);
8887
REQUIRES_SERVICE_PLACEHOLDER(component_sys_variable_unregister);
8988
REQUIRES_SERVICE_PLACEHOLDER(mysql_system_variable_reader);

components/logging/log_sink_syseventlog.cc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,20 @@ You should have received a copy of the GNU General Public License
2121
along with this program; if not, write to the Free Software
2222
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
2323

24-
#include <mysql/components/services/log_builtins.h>
25-
2624
#include "log_service_imp.h"
2725
#include "m_string.h" // native_strncasecmp()/native_strcasecmp()
2826
#include "my_compiler.h"
29-
#include "my_io.h"
30-
#include "my_sys.h"
3127
#include "mysqld_error.h" // so we can throw ER_LOG_SYSLOG_*
3228

3329
#include <mysql/components/component_implementation.h>
3430
#include <mysql/components/service_implementation.h>
31+
#include <mysql/components/services/log_builtins.h>
3532

33+
#include <mysql/components/services/bits/my_io_bits.h>
34+
#include <mysql/components/services/bits/my_syslog_bits.h>
3635
#include <mysql/components/services/component_sys_var_service.h>
3736
#include <mysql/components/services/mysql_system_variable.h>
3837

39-
#include "../sql/set_var.h"
40-
4138
#ifndef _WIN32
4239
#include <syslog.h> // LOG_DAEMON etc. -- facility names
4340

@@ -91,6 +88,12 @@ static SYSLOG_FACILITY syslog_facility[] = {
9188
#endif
9289
#define OPT_TAG "tag"
9390

91+
#ifdef _WIN32
92+
#define OS_PATH_SEPARATOR '\\'
93+
#else
94+
#define OS_PATH_SEPARATOR '/'
95+
#endif /* _WIN32 */
96+
9497
static bool inited = false; /**< component initialized */
9598

9699
// components we'll be using
@@ -295,7 +298,8 @@ static int var_update_tag(const char *tag) {
295298
bool ident_changed = false;
296299

297300
// tag must not contain directory separators
298-
if ((tag != nullptr) && (strchr(tag, FN_LIBCHAR) != nullptr)) return -1;
301+
if ((tag != nullptr) && (strchr(tag, OS_PATH_SEPARATOR) != nullptr))
302+
return -1;
299303

300304
/*
301305
make ident

components/mysqlbackup/backup_page_tracker.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,15 @@
3434
#include <sys/stat.h>
3535

3636
#include "backup_comp_constants.h"
37-
#include "mysql/plugin.h"
37+
#include "mysql/components/services/bits/my_err_bits.h"
3838
#include "mysqld_error.h"
3939

40+
#ifdef _WIN32
41+
#define OS_PATH_SEPARATOR '\\'
42+
#else
43+
#define OS_PATH_SEPARATOR '/'
44+
#endif /* _WIN32 */
45+
4046
// defined in mysqlbackup component definition
4147
extern char *mysqlbackup_backup_id;
4248

@@ -405,7 +411,7 @@ long long Backup_page_tracker::page_track_get_changed_pages(UDF_INIT *,
405411

406412
free(m_changed_pages_file);
407413
m_changed_pages_file =
408-
strdup((changed_pages_file_dir + FN_LIBCHAR + backupid +
414+
strdup((changed_pages_file_dir + OS_PATH_SEPARATOR + backupid +
409415
Backup_comp_constants::change_file_extension)
410416
.c_str());
411417

components/mysqlbackup/mysqlbackup.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
3030
#include "mysql/components/library_mysys/my_memory.h"
3131
#include "mysql/components/services/psi_memory.h"
3232
#include "mysql/service_security_context.h"
33+
#include "mysql_version.h"
3334
#include "mysqld_error.h"
3435
#include "string_with_len.h"
3536

components/test/statement_services/test_execute_regular_statement.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
3535
#include "mysql/components/services/defs/mysql_string_defs.h"
3636

3737
#include "field_types.h"
38-
#include "mysql_com.h"
3938
#include "scope_guard.h"
4039

4140
#include "utils.h"

components/test/test_mysql_command_services.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
2929
#include <mysql/components/services/udf_registration.h>
3030
#include <mysql/service_srv_session_info.h>
3131
#include <stdio.h>
32-
#include <string>
32+
#include <cstring>
3333

3434
REQUIRES_SERVICE_PLACEHOLDER_AS(mysql_thd_security_context, thd_security_ctx);
3535
REQUIRES_SERVICE_PLACEHOLDER_AS(mysql_account_database_security_context_lookup,

components/test/test_sensitive_system_variables.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
2323

2424
#include <mysql/components/component_implementation.h>
2525
#include <mysql/components/service_implementation.h>
26+
#include <mysql/components/services/bits/system_variables_bits.h>
2627
#include <mysql/components/services/component_sys_var_service.h>
27-
#include <mysql/plugin.h>
2828

29-
#include "my_macros.h"
3029
#include "scope_guard.h"
3130
#include "typelib.h"
3231

components/test/test_session_var_service.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ along with this program; if not, write to the Free Software
2222
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
2323

2424
#include <fcntl.h>
25+
#ifndef _WIN32
26+
#include <unistd.h>
27+
#endif
28+
2529
#include <mysql/components/component_implementation.h>
2630
#include <mysql/components/service_implementation.h>
31+
#include <mysql/components/services/bits/system_variables_bits.h>
2732
#include <mysql/components/services/component_sys_var_service.h>
2833
#include <mysql/components/services/mysql_current_thread_reader.h>
2934
#include <mysql/components/services/mysql_system_variable.h>
30-
#include <mysql/plugin.h>
3135

32-
#include "my_macros.h"
3336
#include "nulls.h"
3437
#include "template_utils.h"
3538
#include "typelib.h"

components/test/test_sys_var_service.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ along with this program; if not, write to the Free Software
2222
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
2323

2424
#include <fcntl.h>
25+
#ifndef _WIN32
26+
#include <unistd.h>
27+
#endif
28+
2529
#include <mysql/components/component_implementation.h>
2630
#include <mysql/components/service_implementation.h>
31+
#include <mysql/components/services/bits/system_variables_bits.h>
2732
#include <mysql/components/services/component_sys_var_service.h>
2833
#include <mysql/components/services/mysql_system_variable.h>
29-
#include <mysql/plugin.h>
3034

31-
#include "my_macros.h"
3235
#include "nulls.h"
3336
#include "template_utils.h"
3437
#include "typelib.h"

0 commit comments

Comments
 (0)