mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-36390: Minor refactoring of the method get_expr_query at the classes sp_instr_cpush/sp_instr_cursor_copy_struct
Duplicated code from methods sp_instr_cpush::get_expr_query sp_instr_cursor_copy_struct::get_expr_query were extracted to the standalone function get_cursor_query Additionally, added correct parsing of a cursor definition with a new line or TAB instead of the space immediately after FOR/IS.
This commit is contained in:
committed by
Alexander Barkov
parent
7b3e02e1aa
commit
c76d17a917
@@ -1227,6 +1227,32 @@ public:
|
||||
}; // class sp_instr_hreturn : public sp_instr_jump
|
||||
|
||||
|
||||
/**
|
||||
Get a query text associated with the cursor.
|
||||
*/
|
||||
|
||||
static inline LEX_CSTRING get_cursor_query(const LEX_CSTRING &cursor_stmt)
|
||||
{
|
||||
/*
|
||||
Lexer on processing the clause CURSOR FOR / CURSOR IS doesn't
|
||||
move a pointer on cpp_buf after the token FOR/IS so skip it explicitly
|
||||
in order to get correct value of cursor's query string.
|
||||
*/
|
||||
|
||||
if (strncasecmp(cursor_stmt.str, "FOR", 3) == 0 &&
|
||||
my_isspace(current_thd->variables.character_set_client,
|
||||
cursor_stmt.str[3]))
|
||||
return LEX_CSTRING{cursor_stmt.str + 4, cursor_stmt.length - 4};
|
||||
|
||||
if (strncasecmp(cursor_stmt.str, "IS", 2) == 0 &&
|
||||
my_isspace(current_thd->variables.character_set_client,
|
||||
cursor_stmt.str[2]))
|
||||
return LEX_CSTRING{cursor_stmt.str + 3, cursor_stmt.length - 3};
|
||||
|
||||
return cursor_stmt;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This is DECLARE CURSOR
|
||||
*/
|
||||
@@ -1287,16 +1313,7 @@ public:
|
||||
protected:
|
||||
LEX_CSTRING get_expr_query() const override
|
||||
{
|
||||
/*
|
||||
Lexer on processing the clause CURSOR FOR / CURSOR IS doesn't
|
||||
move a pointer on cpp_buf after the token FOR/IS so skip it explicitly
|
||||
in order to get correct value of cursor's query string.
|
||||
*/
|
||||
if (strncasecmp(m_cursor_stmt.str, "FOR ", 4) == 0)
|
||||
return LEX_CSTRING{m_cursor_stmt.str + 4, m_cursor_stmt.length - 4};
|
||||
if (strncasecmp(m_cursor_stmt.str, "IS ", 3) == 0)
|
||||
return LEX_CSTRING{m_cursor_stmt.str + 3, m_cursor_stmt.length - 3};
|
||||
return m_cursor_stmt;
|
||||
return get_cursor_query(m_cursor_stmt);
|
||||
}
|
||||
|
||||
bool on_after_expr_parsing(THD *) override
|
||||
@@ -1428,16 +1445,7 @@ public:
|
||||
protected:
|
||||
LEX_CSTRING get_expr_query() const override
|
||||
{
|
||||
/*
|
||||
Lexer on processing the clause CURSOR FOR / CURSOR IS doesn't
|
||||
move a pointer on cpp_buf after the token FOR/IS so skip it explicitly
|
||||
in order to get correct value of cursor's query string.
|
||||
*/
|
||||
if (strncasecmp(m_cursor_stmt.str, "FOR ", 4) == 0)
|
||||
return LEX_CSTRING{m_cursor_stmt.str + 4, m_cursor_stmt.length - 4};
|
||||
if (strncasecmp(m_cursor_stmt.str, "IS ", 3) == 0)
|
||||
return LEX_CSTRING{m_cursor_stmt.str + 3, m_cursor_stmt.length - 3};
|
||||
return m_cursor_stmt;
|
||||
return get_cursor_query(m_cursor_stmt);
|
||||
}
|
||||
|
||||
bool on_after_expr_parsing(THD *) override
|
||||
|
Reference in New Issue
Block a user