MySQL  8.0.27
Source Code Documentation
sql_union.h
Go to the documentation of this file.
1 /* Copyright (c) 2006, 2021, 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 "my_base.h"
27 #include "my_compiler.h"
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 
33 class Item;
34 class Query_expression;
35 class THD;
36 template <class T>
37 class List;
38 
40  protected:
42  /// Count of rows successfully stored in tmp table
44 
45  public:
47 
50  bool prepare(THD *thd, const mem_root_deque<Item *> &list,
51  Query_expression *u) override;
52  /**
53  Do prepare() if preparation has been postponed until column type
54  information is computed (used by Query_result_union_direct).
55 
56  @param thd Thread handle
57  @param types Column types
58 
59  @return false on success, true on failure
60  */
61  virtual bool postponed_prepare(THD *thd [[maybe_unused]],
62  const mem_root_deque<Item *> &types
63  [[maybe_unused]]) {
64  return false;
65  }
66  bool send_data(THD *thd, const mem_root_deque<Item *> &items) override;
67  bool send_eof(THD *thd) override;
68  virtual bool flush();
69  void cleanup(THD *) override { (void)reset(); }
70  bool reset() override;
71  bool create_result_table(THD *thd, const mem_root_deque<Item *> &column_types,
72  bool is_distinct, ulonglong options,
73  const char *alias, bool bit_fields_as_long,
74  bool create_table);
76  friend bool TABLE_LIST::optimize_derived(THD *thd);
77  const ha_rows *row_count() const override { return &m_rows_in_table; }
78 };
79 
80 #endif /* SQL_UNION_INCLUDED */
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:802
Definition: sql_list.h:431
This class represents a query expression (one query block or several query blocks combined with UNION...
Definition: sql_lex.h:629
Definition: query_result.h:200
Definition: sql_union.h:39
Query_result_union()
Definition: sql_union.h:48
bool reset() override
Reset and empty the temporary table that stores the materialized query result.
Definition: sql_union.cc:218
const ha_rows * row_count() const override
Definition: sql_union.h:77
Temp_table_param tmp_table_param
Definition: sql_union.h:41
virtual bool flush()
Definition: sql_union.cc:139
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)
Create a temporary table to store the result of a query expression (used, among others,...
Definition: sql_union.cc:163
bool send_data(THD *thd, const mem_root_deque< Item * > &items) override
Definition: sql_union.cc:111
TABLE * table
Definition: sql_union.h:46
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:105
ha_rows m_rows_in_table
Count of rows successfully stored in tmp table.
Definition: sql_union.h:43
virtual bool postponed_prepare(THD *thd[[maybe_unused]], const mem_root_deque< Item * > &types[[maybe_unused]])
Do prepare() if preparation has been postponed until column type information is computed (used by Que...
Definition: sql_union.h:61
void cleanup(THD *) override
Cleanup after this execution.
Definition: sql_union.h:69
bool send_eof(THD *thd) override
Definition: sql_union.cc:137
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:821
Object containing parameters used when creating and using temporary tables.
Definition: temp_table_param.h:98
Dialog Client Authentication nullptr
Definition: dialog.cc:352
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:1247
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1138
Header for compiler-dependent features.
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
Definition: options.cc:45
bool optimize_derived(THD *thd)
Optimize the query expression representing a derived table/view.
Definition: sql_derived.cc:1339
bool create_materialized_table(THD *thd)
Create result table for a materialized derived table/view.
Definition: sql_derived.cc:1387
Definition: table.h:1394