diff options
author | Alexander Barkov <bar@mariadb.com> | 2018-11-09 09:45:37 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2018-11-09 09:56:02 +0400 |
commit | 3074beaad6bf259c6427d77783ea821d0b16b424 (patch) | |
tree | bae290aa1e69f095bf21667297de268b442931ba /sql/sql_class.h | |
parent | d5e1f6a632ac8cb5ccf7eecf0717290232c0c240 (diff) | |
download | mariadb-git-3074beaad6bf259c6427d77783ea821d0b16b424.tar.gz |
MDEV-17387 MariaDB Server giving wrong error while executing select query from procedure
Changing the way how a cursor is opened to fetch its structure only,
e.g. for a cursor FOR loop record variable.
The old methods with setting thd->lex->limit_rows_examined to an Item_uint(0)
was not reliable and could push these messages into diagnostics area:
The query examined at least 1 rows, which exceeds LIMIT ROWS EXAMINED (0)
The new method should be more reliable, as it completely prevents the call
of do_select() in JOIN::exec_inner() during the cursor structure discovery,
so the execution of the cursor SELECT query returns immediately after the
preparation step (when the result row structure becomes known),
without even entering the code that fetches the result rows.
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r-- | sql/sql_class.h | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index acd48b07900..1a7eb943193 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5037,6 +5037,14 @@ public: Currently all intercepting classes derive from select_result_interceptor. */ virtual bool is_result_interceptor()=0; + + /* + This method is used to distinguish an normal SELECT from the cursor + structure discovery for cursor%ROWTYPE routine variables. + If this method returns "true", then a SELECT execution performs only + all preparation stages, but does not fetch any rows. + */ + virtual bool view_structure_only() const { return false; } }; @@ -5156,9 +5164,13 @@ private: { List<sp_variable> *spvar_list; uint field_count; + bool m_view_structure_only; bool send_data_to_variable_list(List<sp_variable> &vars, List<Item> &items); public: - Select_fetch_into_spvars(THD *thd_arg): select_result_interceptor(thd_arg) {} + Select_fetch_into_spvars(THD *thd_arg, bool view_structure_only) + :select_result_interceptor(thd_arg), + m_view_structure_only(view_structure_only) + {} void reset(THD *thd_arg) { select_result_interceptor::reset(thd_arg); @@ -5171,16 +5183,17 @@ private: virtual bool send_eof() { return FALSE; } virtual int send_data(List<Item> &items); virtual int prepare(List<Item> &list, SELECT_LEX_UNIT *u); + virtual bool view_structure_only() const { return m_view_structure_only; } }; public: sp_cursor() - :result(NULL), + :result(NULL, false), m_lex_keeper(NULL), server_side_cursor(NULL) { } - sp_cursor(THD *thd_arg, sp_lex_keeper *lex_keeper) - :result(thd_arg), + sp_cursor(THD *thd_arg, sp_lex_keeper *lex_keeper, bool view_structure_only) + :result(thd_arg, view_structure_only), m_lex_keeper(lex_keeper), server_side_cursor(NULL) {} @@ -5192,8 +5205,6 @@ public: int open(THD *thd); - int open_view_structure_only(THD *thd); - int close(THD *thd); my_bool is_open() |