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"

0 commit comments

Comments
 (0)