MySQL 8.0.39
Source Code Documentation
sql_lexer_parser_state.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2022, 2024, Oracle and/or its affiliates.
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, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef ROUTING_SQL_LEXER_PARSER_STATE_INCLUDED
27#define ROUTING_SQL_LEXER_PARSER_STATE_INCLUDED
28
29#include <cstdlib>
30
34
35class THD;
36
37/**
38 Internal state of the parser.
39 The complete state consist of:
40 - input parameters that control the parser behavior
41 - state data used during lexical parsing,
42 - state data used during syntactic parsing.
43*/
45 protected:
46 /**
47 Constructor for special parsers of partial SQL clauses (DD)
48
49 @param grammar_selector_token See Lex_input_stream::grammar_selector_token
50 */
51 explicit Parser_state(int grammar_selector_token)
52 : m_input(), m_lip(grammar_selector_token), m_yacc(), m_comment(false) {}
53
54 public:
55 Parser_state() : m_input(), m_lip(~0U), m_yacc(), m_comment(false) {}
56
57 /**
58 Object initializer. Must be called before usage.
59
60 @retval false OK
61 @retval true Error
62 */
63 bool init(THD *thd, const char *buff, size_t length) {
64 return m_lip.init(thd, buff, length);
65 }
66
67 void reset(const char *found_semicolon, size_t length) {
68 m_lip.reset(found_semicolon, length);
69 m_yacc.reset();
70 }
71
72 /// Signal that the current query has a comment
73 void add_comment() { m_comment = true; }
74 /// Check whether the current query has a comment
75 bool has_comment() const { return m_comment; }
76
77 public:
81#if 0
82 /**
83 Current performance digest instrumentation.
84 */
86#endif
87 private:
88 bool m_comment; ///< True if current query contains comments
89};
90
91#endif
This class represents the character input stream consumed during lexical analysis.
Definition: sql_lexer_input_stream.h:70
bool init(THD *thd, const char *buff, size_t length)
Object initializer.
Definition: sql_lexer.cc:75
void reset(const char *buff, size_t length)
Prepare Lex_input_stream instance state for use for handling next SQL statement.
Definition: sql_lexer.cc:103
Internal state of the parser.
Definition: sql_lexer_parser_state.h:44
Lex_input_stream m_lip
Definition: sql_lexer_parser_state.h:79
void add_comment()
Signal that the current query has a comment.
Definition: sql_lexer_parser_state.h:73
void reset(const char *found_semicolon, size_t length)
Definition: sql_lexer_parser_state.h:67
Yacc_state m_yacc
Definition: sql_lexer_parser_state.h:80
Parser_state()
Definition: sql_lexer_parser_state.h:55
Parser_input m_input
Definition: sql_lexer_parser_state.h:78
Parser_state(int grammar_selector_token)
Constructor for special parsers of partial SQL clauses (DD)
Definition: sql_lexer_parser_state.h:51
bool has_comment() const
Check whether the current query has a comment.
Definition: sql_lexer_parser_state.h:75
bool m_comment
True if current query contains comments.
Definition: sql_lexer_parser_state.h:88
bool init(THD *thd, const char *buff, size_t length)
Object initializer.
Definition: sql_lexer_parser_state.h:63
PSI_digest_locker * m_digest_psi
Current performance digest instrumentation.
Definition: sql_lex.h:4629
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
The internal state of the syntax parser.
Definition: sql_lexer_yacc_state.h:246
void reset()
Definition: sql_lexer_yacc_state.h:252
struct PSI_digest_locker PSI_digest_locker
Definition: psi_statement_bits.h:112
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
Input parameters to the parser.
Definition: sql_lexer_parser_input.h:32
Definition: dtoa.cc:594