Skip to content

Commit d47167e

Browse files
author
Steinar H. Gunderson
committed
Bug#24488219: INCLUDE WHAT YOU USE
Make only one canonical place to get LEX_STRING from. We had this typedef repeated a number of times throughout the code base, which would cause IWYU to pick a random one and include e.g. sql_class.h into client code. Change-Id: I5fb63ff4d02c3ae3c1913957bf70df287f9f2289
1 parent 442cb30 commit d47167e

File tree

205 files changed

+287
-118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+287
-118
lines changed

client/mysql.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include <violite.h>
4747

4848
#include "client_priv.h"
49+
#include "lex_string.h"
4950
#include "my_compiler.h"
5051
#include "my_dbug.h"
5152
#include "my_default.h"

include/lex_string.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
3+
4+
This program is free software; you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation; version 2 of the License.
7+
8+
This program is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
GNU General Public License for more details.
12+
13+
You should have received a copy of the GNU General Public License
14+
along with this program; if not, write to the Free Software
15+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16+
17+
#ifndef LEX_STRING_INCLUDED
18+
#define LEX_STRING_INCLUDED
19+
20+
#include "mysql/mysql_lex_string.h"
21+
22+
/*
23+
LEX_STRING -- a pair of a C-string and its length.
24+
(it's part of the plugin API as a MYSQL_LEX_STRING)
25+
Ditto LEX_CSTRING/MYSQL_LEX_CSTRING.
26+
*/
27+
28+
typedef struct st_mysql_lex_string LEX_STRING;
29+
typedef struct st_mysql_const_lex_string LEX_CSTRING;
30+
31+
#endif

include/m_string.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <stdlib.h>
2727
#include <string.h>
2828

29+
#include "lex_string.h"
2930
#include "my_byteorder.h" /* uint8korr */
3031
#include "my_config.h"
3132
#include "my_dbug.h"
@@ -336,20 +337,10 @@ static inline char *ullstr(longlong value, char *buff)
336337
}
337338
#endif
338339

339-
/*
340-
LEX_STRING -- a pair of a C-string and its length.
341-
(it's part of the plugin API as a MYSQL_LEX_STRING)
342-
Ditto LEX_CSTRING/MYSQL_LEX_CSTRING.
343-
*/
344-
345-
typedef struct st_mysql_lex_string LEX_STRING;
346-
typedef struct st_mysql_const_lex_string LEX_CSTRING;
347-
348340
#define STRING_WITH_LEN(X) (X), ((sizeof(X) - 1))
349341
#define USTRING_WITH_LEN(X) ((uchar*) X), ((sizeof(X) - 1))
350342
#define C_STRING_WITH_LEN(X) ((char *) (X)), ((sizeof(X) - 1))
351343

352-
353344
/**
354345
Skip trailing space.
355346

include/sql_string.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <sys/types.h>
2727
#include <new>
2828

29+
#include "lex_string.h"
2930
#include "m_ctype.h" // my_convert
3031
#include "m_string.h" // LEX_CSTRING
3132
#include "mem_root_fwd.h"
@@ -39,9 +40,6 @@
3940
#include "mysql/psi/psi_memory.h"
4041
#include "mysql/service_mysql_alloc.h" // my_free
4142

42-
typedef struct st_mysql_lex_string LEX_STRING;
43-
44-
4543
#ifdef MYSQL_SERVER
4644
extern "C" {
4745
extern PSI_memory_key key_memory_String_value;

plugin/audit_null/audit_null.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <stdio.h>
2323
#include <sys/types.h>
2424

25+
#include "lex_string.h"
2526
#include "my_compiler.h"
2627
#include "my_inttypes.h"
2728
#include "my_macros.h"

plugin/version_token/version_token.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <sys/types.h>
2828
#include <sstream>
2929

30+
#include "lex_string.h"
3031
#include "my_compiler.h"
3132
#include "my_dbug.h"
3233
#include "my_inttypes.h"

rapid/plugin/group_replication/src/sql_service/sql_service_interface.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <stddef.h>
1919

20+
#include "lex_string.h"
2021
#include "my_dbug.h"
2122
#include "plugin_log.h"
2223

sql-common/client.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
#include "errmsg.h"
4949
#include "hash.h"
50+
#include "lex_string.h"
5051
#include "my_compiler.h"
5152
#include "my_dbug.h"
5253
#include "my_default.h"

sql/auth/auth_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <vector>
2626

2727
#include "auth_acls.h" /* ACL information */
28+
#include "lex_string.h"
2829
#include "m_string.h"
2930
#include "my_command.h"
3031
#include "my_dbug.h"

sql/auth/role_tables.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "field.h"
2323
#include "handler.h"
2424
#include "key.h"
25+
#include "lex_string.h"
2526
#include "m_string.h"
2627
#include "mdl.h"
2728
#include "my_base.h"

sql/auth/sql_auth_cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "handler.h"
2626
#include "hash.h" // HASH
2727
#include "key.h"
28+
#include "lex_string.h"
2829
#include "lf.h"
2930
#include "mf_wcomp.h" // wild_many, wild_one, wild_prefix
3031
#include "my_atomic.h"

sql/auth/sql_authentication.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -16,10 +16,12 @@
1616
#ifndef SQL_AUTHENTICATION_INCLUDED
1717
#define SQL_AUTHENTICATION_INCLUDED
1818

19+
#include "my_config.h"
20+
1921
#include <sys/types.h>
2022

23+
#include "lex_string.h"
2124
#include "m_ctype.h"
22-
#include "my_config.h"
2325
#include "my_thread_local.h" // my_thread_id
2426
#include "mysql/plugin.h"
2527
#include "mysql/plugin_auth.h" // MYSQL_SERVER_AUTH_INFO

sql/auth/sql_authorization.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "item.h"
4545
#include "key.h"
4646
#include "key_spec.h" /* Key_spec */
47+
#include "lex_string.h"
4748
#include "log.h" /* sql_print_warning */
4849
#include "m_ctype.h"
4950
#include "m_string.h"

sql/auth/sql_security_ctx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <algorithm>
2222

2323
#include "auth/auth_common.h"
24+
#include "lex_string.h"
2425
#include "m_string.h"
2526
#include "my_dbug.h"
2627
#include "my_sharedlib.h"

sql/auth/sql_user.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "handler.h"
2222
#include "hash.h"
2323
#include "item.h"
24+
#include "lex_string.h"
2425
#include "log_event.h" /* append_query_string */
2526
#include "m_ctype.h"
2627
#include "m_string.h"

sql/auth/sql_user_table.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "hash.h"
3737
#include "item_func.h" /* mqh_used */
3838
#include "key.h" /* key_copy, key_cmp_if_same */
39+
#include "lex_string.h"
3940
/* key_restore */
4041
#include "log.h" /* sql_print_warning */
4142
#include "m_ctype.h"

sql/binlog.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <stdlib.h>
2727
#include <sys/stat.h>
2828

29+
#include "lex_string.h"
2930
#include "my_macros.h"
3031
#include "my_systime.h"
3132
#ifdef HAVE_UNISTD_H

sql/bootstrap.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include "bootstrap_impl.h"
2727
#include "error_handler.h" // Internal_error_handler
28+
#include "lex_string.h"
2829
#include "log.h" // sql_print_warning
2930
#include "m_string.h"
3031
#include "my_dbug.h"

sql/conn_handler/init_net_server_extension.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <stddef.h>
2121

22+
#include "lex_string.h"
2223
#include "my_dbug.h"
2324
#include "my_inttypes.h"
2425
#include "mysql/psi/mysql_idle.h" // MYSQL_SOCKET_SET_STATE,

sql/dd/dd_event.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "dd/types/schema.h"
2222
#include "event_parse_data.h" // Event_parse_data
2323
#include "key.h"
24+
#include "lex_string.h"
2425
#include "log.h" // sql_print_error
2526
#include "my_dbug.h"
2627
#include "my_sys.h"

sql/dd/dd_routine.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "dd/types/view.h"
3535
#include "field.h"
3636
#include "key.h"
37+
#include "lex_string.h"
3738
#include "my_dbug.h"
3839
#include "my_decimal.h"
3940
#include "my_inttypes.h"

sql/dd/dd_table.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "item.h"
4949
#include "key.h"
5050
#include "key_spec.h"
51+
#include "lex_string.h"
5152
#include "log.h" // sql_print_error
5253
#include "m_ctype.h"
5354
#include "m_string.h"

sql/dd/dd_tablespace.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "dd/types/tablespace.h" // dd::Tablespace
3333
#include "dd/types/tablespace_file.h" // dd::Tablespace_file
3434
#include "handler.h"
35+
#include "lex_string.h"
3536
#include "my_dbug.h"
3637
#include "my_inttypes.h"
3738
#include "my_io.h"

sql/dd/dd_trigger.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -16,11 +16,11 @@
1616
#ifndef DD_TRIGGER_INCLUDED
1717
#define DD_TRIGGER_INCLUDED
1818

19+
#include "dd/string_type.h" // dd::String_type
20+
#include "lex_string.h"
1921
#include "m_string.h" // LEX_CSTRING
2022
#include "trigger_def.h" // enum_trigger_order_type
2123

22-
#include "dd/string_type.h" // dd::String_type
23-
2424
class THD;
2525
class Trigger;
2626
typedef struct st_mem_root MEM_ROOT;

sql/dd/dd_upgrade.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "event_db_repository.h" // Events
4141
#include "event_parse_data.h" // Event_parse_data
4242
#include "handler.h" // legacy_db_type
43+
#include "lex_string.h"
4344
#include "lock.h" // Tablespace_hash_set
4445
#include "log.h" // sql_print_warning
4546
#include "my_dbug.h"

sql/dd/dd_view.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "item.h"
4040
#include "item_func.h" // Item_func
4141
#include "key.h"
42+
#include "lex_string.h"
4243
#include "log.h" // sql_print_error, sql_print_..
4344
#include "mdl.h"
4445
#include "my_dbug.h"

sql/dd/impl/bootstrapper.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include "dd/types/view.h" // dd::View
5353
#include "error_handler.h" // No_such_table_error_handler
5454
#include "handler.h" // dict_init_mode_t
55+
#include "lex_string.h"
5556
#include "log.h" // sql_print_warning()
5657
#include "m_ctype.h"
5758
#include "m_string.h" // STRING_WITH_LEN

sql/dd/impl/cache/dictionary_client.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#include "dd/types/view_table.h" // View_table
6666
#include "debug_sync.h" // DEBUG_SYNC()
6767
#include "handler.h"
68+
#include "lex_string.h"
6869
#include "log.h" // sql_print_warning()
6970
#include "m_ctype.h"
7071
#include "m_string.h"

sql/dd/impl/dictionary_impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "dd/dictionary.h" // dd::Dictionary
2626
#include "dd/object_id.h" // dd::Object_id
2727
#include "dd/string_type.h" // dd::String_type
28+
#include "lex_string.h"
2829
#include "m_string.h"
2930
#include "table.h" // MYSQL_SCHEMA_NAME
3031

sql/dd/impl/properties_impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "dd/properties.h" // dd::Properties
2525
#include "dd/string_type.h" // dd::String_type
26+
#include "lex_string.h"
2627
#include "m_string.h"
2728
#include "my_dbug.h"
2829
#include "my_inttypes.h"

sql/dd/impl/sdi_file.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "dd/types/schema.h" // dd::Schema
3232
#include "dd/types/table.h" // dd::Table
3333
#include "handler.h"
34+
#include "lex_string.h"
3435
#include "m_ctype.h"
3536
#include "my_dbug.h"
3637
#include "my_inttypes.h"

sql/dd/impl/system_registry.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2014, 2017 Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -44,6 +44,7 @@
4444
#include "dd/impl/tables/version.h" // Version
4545
#include "dd/impl/tables/view_routine_usage.h" // View_routine_usage
4646
#include "dd/impl/tables/view_table_usage.h" // View_table_usage
47+
#include "lex_string.h"
4748
#include "m_string.h"
4849
#include "table.h" // MYSQL_SYSTEM_SCHEMA
4950

sql/dd/impl/types/event_impl.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@
2323
#include "dd/impl/transaction_impl.h" // Open_dictionary_tables_ctx
2424
#include "dd/string_type.h" // dd::String_type
2525
#include "dd/types/weak_object.h"
26-
#include "mysql_com.h"
27-
#include "mysqld_error.h" // ER_*
28-
#include "mysqld.h"
26+
#include "lex_string.h"
2927
#include "my_sys.h"
3028
#include "my_user.h" // parse_user
29+
#include "mysql_com.h"
30+
#include "mysqld.h"
31+
#include "mysqld_error.h" // ER_*
3132

3233
using dd::tables::Events;
3334

sql/dd/impl/types/routine_impl.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -27,11 +27,12 @@
2727
#include "dd/string_type.h" // dd::String_type
2828
#include "dd/types/parameter.h"
2929
#include "dd/types/weak_object.h"
30-
#include "mysql_com.h"
31-
#include "mysqld_error.h"
32-
#include "mysqld.h"
30+
#include "lex_string.h"
3331
#include "my_sys.h"
3432
#include "my_user.h" // parse_user
33+
#include "mysql_com.h"
34+
#include "mysqld.h"
35+
#include "mysqld_error.h"
3536

3637
using dd::tables::Routines;
3738
using dd::tables::Parameters;

sql/dd/impl/types/trigger_impl.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -24,10 +24,11 @@
2424
#include "dd/string_type.h" // dd::String_type
2525
#include "dd/types/object_table.h"
2626
#include "dd/types/weak_object.h"
27-
#include "mysql_com.h"
28-
#include "mysqld_error.h" // ER_*
27+
#include "lex_string.h"
2928
#include "my_sys.h"
3029
#include "my_user.h" // parse_user
30+
#include "mysql_com.h"
31+
#include "mysqld_error.h" // ER_*
3132
#include "sql_class.h"
3233

3334
using dd::tables::Triggers;

0 commit comments

Comments
 (0)