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

+1-1
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

+1-2
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

+11-7
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

+8-2
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

+1
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

-1
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

+1-1
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

+1-2
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

+5-2
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

+5-2
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"

components/test/test_sys_var_service_int.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -22,13 +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+
#include <stdio.h>
26+
#ifndef _WIN32
27+
#include <unistd.h>
28+
#endif
29+
2530
#include <mysql/components/component_implementation.h>
2631
#include <mysql/components/service_implementation.h>
32+
#include <mysql/components/services/bits/system_variables_bits.h>
2733
#include <mysql/components/services/component_sys_var_service.h>
2834
#include <mysql/components/services/mysql_system_variable.h>
29-
#include <mysql/plugin.h>
3035

31-
#include "my_macros.h"
3236
#include "typelib.h"
3337

3438
#define VARIABLE_BUFFER_SIZE 1023

components/test/test_sys_var_service_same.cc

+5-2
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"

components/test/test_sys_var_service_str.cc

+8-3
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+
#include <stdio.h>
26+
#ifndef _WIN32
27+
#include <unistd.h>
28+
#endif
29+
2530
#include <mysql/components/component_implementation.h>
2631
#include <mysql/components/service_implementation.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 "typelib.h"
3336

3437
#define MAX_BUFFER_LENGTH 100
@@ -37,6 +40,8 @@ char log_text[MAX_BUFFER_LENGTH];
3740
FILE *outfile;
3841
const char *filename = "test_component_sys_var_service_str.log";
3942

43+
#define MAX_PATH_LEN 512
44+
4045
#define WRITE_LOG(format, lit_log_text) \
4146
log_text_len = sprintf(log_text, format, lit_log_text); \
4247
if (fwrite((uchar *)log_text, sizeof(char), log_text_len, outfile) != \
@@ -129,7 +134,7 @@ static mysql_service_status_t test_component_sys_var_service_str_init() {
129134
}
130135
}
131136
{
132-
char var[FN_REFLEN];
137+
char var[MAX_PATH_LEN];
133138
char *pvar;
134139
size_t len = sizeof(var) - 1;
135140

include/my_io.h

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232

3333
#include <mysql/components/services/bits/my_io_bits.h>
3434

35+
#ifdef MYSQL_COMPONENT
36+
#error This header shall not be included in components
37+
#endif
38+
3539
#ifdef _WIN32
3640

3741
/* Define missing access() modes. */

include/my_sys.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666

6767
#include "my_sharedlib.h"
6868
#include "mysql/components/services/bits/my_io_bits.h"
69+
#include "mysql/components/services/bits/my_syslog_bits.h"
6970
#include "mysql/components/services/bits/mysql_cond_bits.h"
7071
#include "mysql/components/services/bits/mysql_mutex_bits.h"
7172
#include "mysql/components/services/bits/psi_bits.h"
@@ -613,9 +614,6 @@ extern my_off_t my_ftell(FILE *stream);
613614
// Maximum size of message that will be logged.
614615
#define MAX_SYSLOG_MESSAGE_SIZE 1024
615616

616-
/* Platform-independent SysLog support */
617-
enum my_syslog_options { MY_SYSLOG_PIDS = 1 };
618-
619617
extern int my_openlog(const char *eventSourceName, int option, int facility);
620618
extern int my_closelog();
621619
extern int my_syslog(const CHARSET_INFO *cs, enum loglevel level,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* Copyright (c) 2024, Oracle and/or its affiliates.
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License, version 2.0,
5+
as published by the Free Software Foundation.
6+
7+
This program is designed to work with certain software (including
8+
but not limited to OpenSSL) that is licensed under separate terms,
9+
as designated in a particular file or component or in included license
10+
documentation. The authors of MySQL hereby grant you an additional
11+
permission to link the program and your derivative works with the
12+
separately licensed software that they have either included with
13+
the program or referenced in the documentation.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU General Public License, version 2.0, for more details.
19+
20+
You should have received a copy of the GNU General Public License
21+
along with this program; if not, write to the Free Software
22+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23+
24+
#ifndef MY_ERR_BITS_H
25+
#define MY_ERR_BITS_H
26+
27+
/** Max length of a error message. Should be kept in sync with ::ERRMSGSIZE. */
28+
#define MYSQL_ERRMSG_SIZE 512
29+
30+
#endif /* MY_ERR_BITS_H */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* Copyright (c) 2024, Oracle and/or its affiliates.
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License, version 2.0,
5+
as published by the Free Software Foundation.
6+
7+
This program is designed to work with certain software (including
8+
but not limited to OpenSSL) that is licensed under separate terms,
9+
as designated in a particular file or component or in included license
10+
documentation. The authors of MySQL hereby grant you an additional
11+
permission to link the program and your derivative works with the
12+
separately licensed software that they have either included with
13+
the program or referenced in the documentation.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU General Public License, version 2.0, for more details.
19+
20+
You should have received a copy of the GNU General Public License
21+
along with this program; if not, write to the Free Software
22+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23+
24+
#ifndef COMPONENTS_SERVICES_BITS_MY_SYSLOG_BITS_H
25+
#define COMPONENTS_SERVICES_BITS_MY_SYSLOG_BITS_H
26+
27+
/* Platform-independent SysLog support */
28+
enum my_syslog_options { MY_SYSLOG_PIDS = 1 };
29+
30+
#endif /* COMPONENTS_SERVICES_BITS_MY_SYSLOG_BITS_H */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* Copyright (c) 2024, Oracle and/or its affiliates.
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License, version 2.0,
5+
as published by the Free Software Foundation.
6+
7+
This program is designed to work with certain software (including
8+
but not limited to OpenSSL) that is licensed under separate terms,
9+
as designated in a particular file or component or in included license
10+
documentation. The authors of MySQL hereby grant you an additional
11+
permission to link the program and your derivative works with the
12+
separately licensed software that they have either included with
13+
the program or referenced in the documentation.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU General Public License, version 2.0, for more details.
19+
20+
You should have received a copy of the GNU General Public License
21+
along with this program; if not, write to the Free Software
22+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23+
24+
#ifndef MY_SQL_BITS_H
25+
#define MY_SQL_BITS_H
26+
27+
/** Length of SQL state string */
28+
#define SQLSTATE_LENGTH 5
29+
30+
#endif /* MY_SQL_BITS_H */

0 commit comments

Comments
 (0)