Skip to content

Commit

Permalink
Moving the code from my_parse_error() to THD::parse_error().
Browse files Browse the repository at this point in the history
Reusing THD::parse_error() in sql_yacc.yy and sql_yacc_ora.yy
  • Loading branch information
Alexander Barkov committed Apr 5, 2017
1 parent 9f6aca1 commit c21fc00
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 168 deletions.
31 changes: 31 additions & 0 deletions sql/sql_class.h
Expand Up @@ -3882,6 +3882,37 @@ class THD :public Statement,
*/
void raise_note_printf(uint code, ...);

/**
@brief Push an error message into MySQL error stack with line
and position information.
This function provides semantic action implementers with a way
to push the famous "You have a syntax error near..." error
message into the error stack, which is normally produced only if
a parse error is discovered internally by the Bison generated
parser.
*/
void parse_error(const char *err_text, const char *yytext)
{
Lex_input_stream *lip= &m_parser_state->m_lip;
if (!yytext)
{
if (!(yytext= lip->get_tok_start()))
yytext= "";
}
/* Push an error into the error stack */
ErrConvString err(yytext, strlen(yytext), variables.character_set_client);
my_printf_error(ER_PARSE_ERROR, ER_THD(this, ER_PARSE_ERROR), MYF(0),
err_text, err.ptr(), lip->yylineno);
}
void parse_error(uint err_number, const char *yytext= 0)
{
return parse_error(ER_THD(this, err_number), yytext);
}
void parse_error()
{
return parse_error(ER_SYNTAX_ERROR);
}
private:
/*
Only the implementation of the SIGNAL and RESIGNAL statements
Expand Down
7 changes: 7 additions & 0 deletions sql/sql_lex.cc
Expand Up @@ -31,6 +31,13 @@
#include "sql_select.h"
#include "sql_cte.h"


void LEX::parse_error()
{
thd->parse_error();
}


static int lex_one_token(YYSTYPE *yylval, THD *thd);

/*
Expand Down

0 comments on commit c21fc00

Please sign in to comment.