MySQL 8.0.33
Source Code Documentation
sql_lexer_parser_state.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2022, 2023, 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 also distributed 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 included with MySQL.
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 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
25#ifndef ROUTING_SQL_LEXER_PARSER_STATE_INCLUDED
26#define ROUTING_SQL_LEXER_PARSER_STATE_INCLUDED
27
28#include <cstdlib>
29
33
34class THD;
35
36/**
37 Internal state of the parser.
38 The complete state consist of:
39 - input parameters that control the parser behavior
40 - state data used during lexical parsing,
41 - state data used during syntactic parsing.
42*/
44 protected:
45 /**
46 Constructor for special parsers of partial SQL clauses (DD)
47
48 @param grammar_selector_token See Lex_input_stream::grammar_selector_token
49 */
50 explicit Parser_state(int grammar_selector_token)
51 : m_input(), m_lip(grammar_selector_token), m_yacc(), m_comment(false) {}
52
53 public:
54 Parser_state() : m_input(), m_lip(~0U), m_yacc(), m_comment(false) {}
55
56 /**
57 Object initializer. Must be called before usage.
58
59 @retval false OK
60 @retval true Error
61 */
62 bool init(THD *thd, const char *buff, size_t length) {
63 return m_lip.init(thd, buff, length);
64 }
65
66 void reset(const char *found_semicolon, size_t length) {
67 m_lip.reset(found_semicolon, length);
68 m_yacc.reset();
69 }
70
71 /// Signal that the current query has a comment
72 void add_comment() { m_comment = true; }
73 /// Check whether the current query has a comment
74 bool has_comment() const { return m_comment; }
75
76 public:
80#if 0
81 /**
82 Current performance digest instrumentation.
83 */
85#endif
86 private:
87 bool m_comment; ///< True if current query contains comments
88};
89
90#endif
This class represents the character input stream consumed during lexical analysis.
Definition: sql_lexer_input_stream.h:69
bool init(THD *thd, const char *buff, size_t length)
Object initializer.
Definition: sql_lexer.cc:74
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:102
Internal state of the parser.
Definition: sql_lexer_parser_state.h:43
Lex_input_stream m_lip
Definition: sql_lexer_parser_state.h:78
void add_comment()
Signal that the current query has a comment.
Definition: sql_lexer_parser_state.h:72
void reset(const char *found_semicolon, size_t length)
Definition: sql_lexer_parser_state.h:66
Yacc_state m_yacc
Definition: sql_lexer_parser_state.h:79
Parser_state()
Definition: sql_lexer_parser_state.h:54
Parser_input m_input
Definition: sql_lexer_parser_state.h:77
Parser_state(int grammar_selector_token)
Constructor for special parsers of partial SQL clauses (DD)
Definition: sql_lexer_parser_state.h:50
bool has_comment() const
Check whether the current query has a comment.
Definition: sql_lexer_parser_state.h:74
bool m_comment
True if current query contains comments.
Definition: sql_lexer_parser_state.h:87
bool init(THD *thd, const char *buff, size_t length)
Object initializer.
Definition: sql_lexer_parser_state.h:62
PSI_digest_locker * m_digest_psi
Current performance digest instrumentation.
Definition: sql_lex.h:4589
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
The internal state of the syntax parser.
Definition: sql_lexer_yacc_state.h:245
void reset()
Definition: sql_lexer_yacc_state.h:251
struct PSI_digest_locker PSI_digest_locker
Definition: psi_statement_bits.h:111
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:75
Input parameters to the parser.
Definition: sql_lexer_parser_input.h:31
Definition: dtoa.cc:594