Skip to content

Commit a8b622b

Browse files
committed
WL#8016: Parser for optimizer hints
See WL page for details.
1 parent 36adbb1 commit a8b622b

32 files changed

+2780
-1119
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,8 @@ libmysqld/sql_view.cc
12311231
libmysqld/sql_yacc.cc
12321232
libmysqld/sql_yacc.cpp
12331233
libmysqld/sql_yacc.h
1234+
libmysqld/sql_hints.yy.cc
1235+
libmysqld/sql_hints.yy.h
12341236
libmysqld/stacktrace.c
12351237
libmysqld/strfunc.cc
12361238
libmysqld/table.cc
@@ -2111,6 +2113,8 @@ sql/sql_yacc.h
21112113
sql/sql_yacc.h.rule
21122114
sql/sql_yacc.output
21132115
sql/sql_yacc.yy.orig
2116+
sql/sql_hints.yy.cc
2117+
sql/sql_hints.yy.h
21142118
sql/test_time
21152119
sql/udf_example.so
21162120
sql_error.cc

client/mysql.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -2647,8 +2647,8 @@ static bool add_line(String &buffer, char *line, size_t line_length,
26472647

26482648
break;
26492649
}
2650-
else if (!*in_string && inchar == '/' && *(pos+1) == '*' &&
2651-
*(pos+2) != '!')
2650+
else if (!*in_string && inchar == '/' && pos[1] == '*' &&
2651+
pos[2] != '!' && pos[2] != '+')
26522652
{
26532653
if (preserve_comments)
26542654
{
@@ -2685,8 +2685,8 @@ static bool add_line(String &buffer, char *line, size_t line_length,
26852685
}
26862686
else
26872687
{ // Add found char to buffer
2688-
if (!*in_string && inchar == '/' && *(pos + 1) == '*' &&
2689-
*(pos + 2) == '!')
2688+
if (!*in_string && inchar == '/' && pos[1] == '*' &&
2689+
(pos[2] == '!' || pos[2] == '+'))
26902690
ss_comment= 1;
26912691
else if (!*in_string && ss_comment && inchar == '*' && *(pos + 1) == '/')
26922692
ss_comment= 0;

cmake/bison.cmake

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2009, 2015, 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
@@ -46,12 +46,14 @@ ENDMACRO()
4646

4747

4848
# Use bison to generate C++ and header file
49-
MACRO (RUN_BISON input_yy output_cc output_h)
49+
MACRO (RUN_BISON input_yy output_cc output_h name_prefix)
5050
IF(BISON_USABLE)
5151
ADD_CUSTOM_COMMAND(
5252
OUTPUT ${output_cc}
5353
${output_h}
54-
COMMAND ${BISON_EXECUTABLE} -y -p MYSQL
54+
COMMAND ${BISON_EXECUTABLE}
55+
--name-prefix=${name_prefix}
56+
--yacc
5557
--output=${output_cc}
5658
--defines=${output_h}
5759
${input_yy}

include/m_ctype.h

+3-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2015, 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
@@ -232,22 +232,6 @@ typedef struct
232232
uint mb_len;
233233
} my_match_t;
234234

235-
enum my_lex_states
236-
{
237-
MY_LEX_START, MY_LEX_CHAR, MY_LEX_IDENT,
238-
MY_LEX_IDENT_SEP, MY_LEX_IDENT_START,
239-
MY_LEX_REAL, MY_LEX_HEX_NUMBER, MY_LEX_BIN_NUMBER,
240-
MY_LEX_CMP_OP, MY_LEX_LONG_CMP_OP, MY_LEX_STRING, MY_LEX_COMMENT, MY_LEX_END,
241-
MY_LEX_OPERATOR_OR_IDENT, MY_LEX_NUMBER_IDENT, MY_LEX_INT_OR_REAL,
242-
MY_LEX_REAL_OR_POINT, MY_LEX_BOOL, MY_LEX_EOL, MY_LEX_ESCAPE,
243-
MY_LEX_LONG_COMMENT, MY_LEX_END_LONG_COMMENT, MY_LEX_SEMICOLON,
244-
MY_LEX_SET_VAR, MY_LEX_USER_END, MY_LEX_HOSTNAME, MY_LEX_SKIP,
245-
MY_LEX_USER_VARIABLE_DELIMITER, MY_LEX_SYSTEM_VAR,
246-
MY_LEX_IDENT_OR_KEYWORD,
247-
MY_LEX_IDENT_OR_HEX, MY_LEX_IDENT_OR_BIN, MY_LEX_IDENT_OR_NCHAR,
248-
MY_LEX_STRING_OR_DELIMITER
249-
};
250-
251235
struct charset_info_st;
252236

253237
typedef struct my_charset_loader_st
@@ -415,8 +399,8 @@ typedef struct charset_info_st
415399
const uint16 *tab_to_uni;
416400
const MY_UNI_IDX *tab_from_uni;
417401
const MY_UNICASE_INFO *caseinfo;
418-
const uchar *state_map;
419-
const uchar *ident_map;
402+
const struct lex_state_maps_st *state_maps; /* parser internal data */
403+
const uchar *ident_map; /* parser internal data */
420404
uint strxfrm_multiply;
421405
uchar caseup_multiply;
422406
uchar casedn_multiply;

libmysqld/CMakeLists.txt

+17
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ INCLUDE_DIRECTORIES(
3737
SET(GEN_YACC_SOURCES
3838
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
3939
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
40+
${CMAKE_CURRENT_BINARY_DIR}/sql_hints.yy.h
41+
${CMAKE_CURRENT_BINARY_DIR}/sql_hints.yy.cc
4042
)
4143

4244
SET(GEN_SOURCES
@@ -140,10 +142,25 @@ COPY_BISON_OUTPUT(
140142
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
141143
)
142144

145+
COPY_BISON_OUTPUT(
146+
${CMAKE_SOURCE_DIR}/sql/sql_hints.yy.cc
147+
${CMAKE_SOURCE_DIR}/sql/sql_hints.yy.h
148+
${CMAKE_CURRENT_BINARY_DIR}/sql_hints.yy.cc
149+
${CMAKE_CURRENT_BINARY_DIR}/sql_hints.yy.h
150+
)
151+
143152
RUN_BISON(
144153
${CMAKE_SOURCE_DIR}/sql/sql_yacc.yy
145154
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
146155
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
156+
MYSQL
157+
)
158+
159+
RUN_BISON(
160+
${CMAKE_SOURCE_DIR}/sql/sql_hints.yy
161+
${CMAKE_CURRENT_BINARY_DIR}/sql_hints.yy.cc
162+
${CMAKE_CURRENT_BINARY_DIR}/sql_hints.yy.h
163+
HINT_PARSER_
147164
)
148165

149166
ADD_CUSTOM_TARGET(GenYaccEmbeddedSource DEPENDS ${GEN_YACC_SOURCES})

0 commit comments

Comments
 (0)