MySQL 8.3.0
Source Code Documentation
storing_auto_thd.h
Go to the documentation of this file.
1/* Copyright (c) 2022, 2023, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is also distributed with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have included with MySQL.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License, version 2.0, for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef STORING_AUTO_THD_H
24#define STORING_AUTO_THD_H
25
26#include <sql/auto_thd.h>
27#include <sql/current_thd.h>
28#include <sql/sql_lex.h>
30#include "sql/auth/auth_acls.h"
31
34
35/**
36 A version of Auto_THD that:
37 - doesn't catch or print the error onto the error log but just passes it up
38 - stores and restores the current_thd correctly
39*/
43
44 public:
47 /* Allocate thread local memory if necessary. */
48 if (!m_previous_thd) {
50 }
52 }
53
55 if (m_previous_thd) {
57 Diagnostics_area *curr_da = thd->get_stmt_da();
58 /* We need to put any errors in the DA as well as the condition list. */
59 if (curr_da->is_error())
60 prev_da->set_error_status(curr_da->mysql_errno(),
61 curr_da->message_text(),
62 curr_da->returned_sqlstate());
63
65 }
67 if (!m_previous_thd) {
69 }
70 if (m_previous_thd) {
72 }
73 }
74 THD *get_THD() { return thd; }
75};
76
77#endif /* STORING_AUTO_THD_H */
std::unique_ptr< T, std::function< void(T *)> > Sctx_ptr
Definition: auth_common.h:955
Stores status of the currently executed statement.
Definition: sql_error.h:268
void set_error_status(THD *thd, uint mysql_errno)
Set ERROR status in the Diagnostics Area.
Definition: sql_error.cc:422
bool is_error() const
Definition: sql_error.h:365
const char * message_text() const
Definition: sql_error.h:375
uint mysql_errno() const
Definition: sql_error.h:385
void copy_sql_conditions_from_da(THD *thd, const Diagnostics_area *src_da)
Copy all SQL-conditions from src_da to this DA.
Definition: sql_error.cc:535
const char * returned_sqlstate() const
Definition: sql_error.h:390
A version of Auto_THD that:
Definition: storing_auto_thd.h:40
Storing_auto_THD()
Definition: storing_auto_thd.h:45
THD * get_THD()
Definition: storing_auto_thd.h:74
THD * m_previous_thd
Definition: storing_auto_thd.h:41
~Storing_auto_THD()
Definition: storing_auto_thd.h:54
THD * thd
Definition: storing_auto_thd.h:41
Sctx_ptr< Security_context > ctx
Definition: storing_auto_thd.h:42
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:35
void store_globals()
Definition: sql_class.cc:1704
Diagnostics_area * get_stmt_da()
Returns first Diagnostics Area for the current statement.
Definition: sql_class.h:3230
thread_local THD * current_thd
Definition: current_thd.cc:25
bool my_thread_init()
Allocate thread specific memory for the thread, used by mysys and dbug.
Definition: my_thr_init.cc:262
void my_thread_end()
Deallocate memory used by the thread for book-keeping.
Definition: my_thr_init.cc:297
THD * create_internal_thd_ctx(Sctx_ptr< Security_context > &ctx)
Wrapper of create_internal_thd() function, creating a temporary THD with the following differences co...
Definition: storing_auto_thd.cc:35
void destroy_internal_thd_ctx(THD *thd, Sctx_ptr< Security_context > &ctx)
Wrapper of destroy_internal_thd() function, safely destroying a temporary THD and its associated secu...
Definition: storing_auto_thd.cc:73