MySQL 8.3.0
Source Code Documentation
sql_union.h
Go to the documentation of this file.
1/* Copyright (c) 2006, 2023, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef SQL_UNION_INCLUDED
24#define SQL_UNION_INCLUDED
25
26#include <sys/types.h>
27
28#include "my_inttypes.h"
29#include "sql/query_result.h" // Query_result_interceptor
30#include "sql/table.h"
31#include "sql/temp_table_param.h" // Temp_table_param
32
33class Item;
35class THD;
36template <class Element_type>
37class mem_root_deque;
38
40 protected:
42
43 public:
45
47 bool prepare(THD *thd, const mem_root_deque<Item *> &list,
48 Query_expression *u) override;
49 /**
50 Do prepare() if preparation has been postponed until column type
51 information is computed (used by Query_result_union_direct).
52
53 @param thd Thread handle
54 @param types Column types
55
56 @return false on success, true on failure
57 */
58 virtual bool postponed_prepare(THD *thd [[maybe_unused]],
59 const mem_root_deque<Item *> &types
60 [[maybe_unused]]) {
61 return false;
62 }
63 bool send_data(THD *thd, const mem_root_deque<Item *> &items) override;
64 bool send_eof(THD *thd) override;
65 virtual bool flush();
66 void cleanup() override { (void)reset(); }
67 bool reset() override;
68 bool create_result_table(THD *thd, const mem_root_deque<Item *> &column_types,
69 bool is_distinct, ulonglong options,
70 const char *alias, bool bit_fields_as_long,
71 bool create_table, Query_term_set_op *op = nullptr);
76 }
78
79 /// Set an effective LIMIT for the number of rows coming out of a materialized
80 /// temporary table used for implementing INTERSECT or EXCEPT: informs
81 /// TableScanIterator::TableScanIterator how many rows to read from the
82 /// materialized table. For UNION and simple tables the limitation is enforced
83 /// earlier, at materialize time, but this is not possible for INTERSECT and
84 /// EXCEPT due to the use of cardinality counters.
85 ///
86 /// @param limit_rows the effective limit, or HA_POS_ERROR if none.
87 void set_limit(ha_rows limit_rows) override;
88};
89
90#endif /* SQL_UNION_INCLUDED */
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:250
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:933
This class represents a query expression (one query block or several query blocks combined with UNION...
Definition: sql_lex.h:624
Definition: query_result.h:180
Definition: sql_union.h:39
Query_result_union()
Definition: sql_union.h:46
bool reset() override
Reset and empty the temporary table that stores the materialized query result.
Definition: sql_union.cc:244
bool skip_create_table() const
Definition: sql_union.h:77
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:58
Temp_table_param tmp_table_param
Definition: sql_union.h:41
virtual bool flush()
Definition: sql_union.cc:138
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:166
bool send_data(THD *thd, const mem_root_deque< Item * > &items) override
Definition: sql_union.cc:112
uint get_hidden_field_count() const
Definition: sql_union.h:74
TABLE * table
Definition: sql_union.h:44
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:248
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:106
void cleanup() override
Cleanup after this execution.
Definition: sql_union.h:66
bool send_eof(THD *thd) override
Definition: sql_union.cc:136
Common base class for n-ary set operations, including unary.
Definition: query_term.h:396
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:35
bool optimize_derived(THD *thd)
Optimize the query expression representing a derived table/view.
Definition: sql_derived.cc:1604
bool create_materialized_table(THD *thd)
Create result table for a materialized derived table/view.
Definition: sql_derived.cc:1652
Object containing parameters used when creating and using temporary tables.
Definition: temp_table_param.h:94
uint hidden_field_count
Definition: temp_table_param.h:132
bool skip_create_table
true <=> don't actually create table handler when creating the result table.
Definition: temp_table_param.h:175
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:110
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:1140
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
Definition: options.cc:56
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2877
Definition: table.h:1403