MySQL 9.1.0
Source Code Documentation
sql_union.h
Go to the documentation of this file.
1/* Copyright (c) 2006, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
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, version 2.0, 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#ifndef SQL_UNION_INCLUDED
25#define SQL_UNION_INCLUDED
26
27#include <sys/types.h>
28
29#include "my_inttypes.h"
30#include "sql/query_result.h" // Query_result_interceptor
31#include "sql/table.h"
32#include "sql/temp_table_param.h" // Temp_table_param
33
34class Item;
36class THD;
37template <class Element_type>
38class mem_root_deque;
39
41 protected:
43
44 public:
46
48 bool prepare(THD *thd, const mem_root_deque<Item *> &list,
49 Query_expression *u) override;
50 /**
51 Do prepare() if preparation has been postponed until column type
52 information is computed (used by Query_result_union_direct).
53
54 @param thd Thread handle
55 @param types Column types
56
57 @return false on success, true on failure
58 */
59 virtual bool postponed_prepare(THD *thd [[maybe_unused]],
60 const mem_root_deque<Item *> &types
61 [[maybe_unused]]) {
62 return false;
63 }
64 bool send_data(THD *thd, const mem_root_deque<Item *> &items) override;
65 bool send_eof(THD *thd) override;
66 virtual bool flush();
67 void cleanup() override { (void)reset(); }
68 bool reset() override;
69 bool create_result_table(THD *thd, const mem_root_deque<Item *> &column_types,
70 bool is_distinct, ulonglong options,
71 const char *alias, bool bit_fields_as_long,
72 bool create_table, Query_term_set_op *op = nullptr);
77 }
79
80 /// Set an effective LIMIT for the number of rows coming out of a materialized
81 /// temporary table used for implementing INTERSECT or EXCEPT: informs
82 /// TableScanIterator::TableScanIterator how many rows to read from the
83 /// materialized table. For UNION and simple tables the limitation is enforced
84 /// earlier, at materialize time, but this is not possible for INTERSECT and
85 /// EXCEPT due to the use of cardinality counters.
86 ///
87 /// @param limit_rows the effective limit, or HA_POS_ERROR if none.
88 void set_limit(ha_rows limit_rows) override;
89
90 // For assignment of tmp_table_param for CTE clones
91 friend class Common_table_expr;
92};
93
94#endif /* SQL_UNION_INCLUDED */
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
After parsing, a Common Table Expression is accessed through a Table_ref.
Definition: table.h:4484
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:930
This class represents a query expression (one query block or several query blocks combined with UNION...
Definition: sql_lex.h:627
Definition: query_result.h:181
Definition: sql_union.h:40
Query_result_union()
Definition: sql_union.h:47
bool reset() override
Reset and empty the temporary table that stores the materialized query result.
Definition: sql_union.cc:247
bool skip_create_table() const
Definition: sql_union.h:78
virtual bool postponed_prepare(THD *thd, const mem_root_deque< Item * > &types)
Do prepare() if preparation has been postponed until column type information is computed (used by Que...
Definition: sql_union.h:59
Temp_table_param tmp_table_param
Definition: sql_union.h:42
virtual bool flush()
Definition: sql_union.cc:141
bool create_result_table(THD *thd, const mem_root_deque< Item * > &column_types, bool is_distinct, ulonglong options, const char *alias, bool bit_fields_as_long, bool create_table, Query_term_set_op *op=nullptr)
Create a temporary table to store the result of a query expression (used, among others,...
Definition: sql_union.cc:169
bool send_data(THD *thd, const mem_root_deque< Item * > &items) override
Definition: sql_union.cc:115
uint get_hidden_field_count() const
Definition: sql_union.h:75
TABLE * table
Definition: sql_union.h:45
void set_limit(ha_rows limit_rows) override
Set an effective LIMIT for the number of rows coming out of a materialized temporary table used for i...
Definition: sql_union.cc:251
bool prepare(THD *thd, const mem_root_deque< Item * > &list, Query_expression *u) override
Perform preparation specific to the query expression or DML statement.
Definition: sql_union.cc:109
void cleanup() override
Cleanup after this execution.
Definition: sql_union.h:67
bool send_eof(THD *thd) override
Definition: sql_union.cc:139
Common base class for n-ary set operations, including unary.
Definition: query_term.h:555
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
bool optimize_derived(THD *thd)
Optimize the query expression representing a derived table/view.
Definition: sql_derived.cc:1641
bool create_materialized_table(THD *thd)
Create result table for a materialized derived table/view.
Definition: sql_derived.cc:1689
Object containing parameters used when creating and using temporary tables.
Definition: temp_table_param.h:97
uint hidden_field_count
Definition: temp_table_param.h:135
bool skip_create_table
true <=> don't actually create table handler when creating the result table.
Definition: temp_table_param.h:178
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:111
PFS_table * create_table(PFS_table_share *share, PFS_thread *opening_thread, const void *identity)
Create instrumentation for a table instance.
Definition: pfs_instr.cc:1307
my_off_t ha_rows
Definition: my_base.h:1141
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
Definition: options.cc:57
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2880
Definition: table.h:1421