MySQL  8.0.19
Source Code Documentation
sql_tmp_table.h
Go to the documentation of this file.
1 #ifndef SQL_TMP_TABLE_INCLUDED
2 #define SQL_TMP_TABLE_INCLUDED
3 
4 /* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License, version 2.0,
8  as published by the Free Software Foundation.
9 
10  This program is also distributed with certain software (including
11  but not limited to OpenSSL) that is licensed under separate terms,
12  as designated in a particular file or component or in included license
13  documentation. The authors of MySQL hereby grant you an additional
14  permission to link the program and your derivative works with the
15  separately licensed software that they have included with MySQL.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License, version 2.0, for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, write to the Free Software
24  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25 
26 /**
27  @file
28 
29  @brief
30  Temporary table handling functions.
31 */
32 
33 #include <stddef.h>
34 #include <sys/types.h>
35 
36 #include "my_base.h" // ha_rows
37 #include "my_inttypes.h"
38 #include "sql/item.h" // Item
39 #include "sql/temp_table_param.h"
40 
41 class Create_field;
42 class Field;
43 class SJ_TMP_TABLE;
44 class THD;
45 struct ORDER;
46 struct TABLE;
47 template <class T>
48 class List;
49 
53 };
54 
56  ORDER *group, bool distinct, bool save_sum_fields,
57  ulonglong select_options, ha_rows rows_limit,
58  const char *table_alias);
59 bool open_tmp_table(TABLE *table);
61  bool is_virtual = true,
62  ulonglong select_options = 0,
63  const char *alias = NULL);
64 bool create_ondisk_from_heap(THD *thd, TABLE *table, int error,
65  bool ignore_last_dup, bool *is_duplicate);
66 void free_tmp_table(THD *thd, TABLE *entry);
67 TABLE *create_duplicate_weedout_tmp_table(THD *thd, uint uniq_tuple_length_arg,
68  SJ_TMP_TABLE *sjtbl);
69 bool instantiate_tmp_table(THD *thd, TABLE *table);
70 Field *create_tmp_field(THD *thd, TABLE *table, Item *item, Item::Type type,
71  Func_ptr_array *copy_func, Field **from_field,
72  Field **default_field, bool group, bool modify_item,
73  bool table_cant_handle_bit_fields, bool make_copy_field,
74  bool copy_result_field = false);
75 Field *create_tmp_field_from_field(THD *thd, const Field *org_field,
76  const char *name, TABLE *table,
77  Item_field *item);
78 
79 /**
80  Get the minimum of max_key_length and max_key_part_length between
81  HEAP engine and internal_tmp_disk_storage_engine.
82 */
83 void get_max_key_and_part_length(uint *max_key_length,
84  uint *max_key_part_length,
85  uint *max_key_parts);
87 void encode_innodb_position(uchar *rowid_bytes, uint length, ha_rows row_num);
88 bool reposition_innodb_cursor(TABLE *table, ha_rows row_num);
89 #endif /* SQL_TMP_TABLE_INCLUDED */
Item
Definition: item.h:665
THD
Definition: sql_class.h:764
Mem_root_array
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:398
my_base.h
create_tmp_table_from_fields
TABLE * create_tmp_table_from_fields(THD *thd, List< Create_field > &field_list, bool is_virtual=true, ulonglong select_options=0, const char *alias=NULL)
Create an, optionally reduced, TABLE object with properly set up Field list from a list of field defi...
Definition: sql_tmp_table.cc:1834
is_duplicate
bool is_duplicate(Country_record *record, int skip_index)
Check for duplicate value of Primary/Unique Key column(s).
Definition: pfs_example_country.cc:50
temp_table_param.h
NULL
#define NULL
Definition: types.h:55
Temp_table_param
Object containing parameters used when creating and using temporary tables.
Definition: temp_table_param.h:74
TMP_TABLE_TEMPTABLE
@ TMP_TABLE_TEMPTABLE
Definition: sql_tmp_table.h:52
Create_field
Create_field is a description a field/column that may or may not exists in a table.
Definition: create_field.h:49
TABLE
Definition: table.h:1305
Item::Type
Type
Definition: item.h:701
create_ondisk_from_heap
bool create_ondisk_from_heap(THD *thd, TABLE *table, int error, bool ignore_last_dup, bool *is_duplicate)
If a MEMORY table gets full, create a disk-based table and copy all rows to this.
Definition: sql_tmp_table.cc:2411
get_max_key_and_part_length
void get_max_key_and_part_length(uint *max_key_length, uint *max_key_part_length, uint *max_key_parts)
Get the minimum of max_key_length and max_key_part_length between HEAP engine and internal_tmp_disk_s...
Definition: sql_tmp_table.cc:570
SJ_TMP_TABLE
Definition: sql_executor.h:129
Item_field
Definition: item.h:3329
open_tmp_table
bool open_tmp_table(TABLE *table)
Definition: sql_tmp_table.cc:2116
my_inttypes.h
encode_innodb_position
void encode_innodb_position(uchar *rowid_bytes, uint length, ha_rows row_num)
Encode an InnoDB PK in 6 bytes, high-byte first; like InnoDB's dict_sys_write_row_id() does.
Definition: sql_tmp_table.cc:2744
uint
unsigned int uint
Definition: uca-dump.cc:29
instantiate_tmp_table
bool instantiate_tmp_table(THD *thd, TABLE *table)
Instantiates temporary table.
Definition: sql_tmp_table.cc:2253
uchar
unsigned char uchar
Definition: my_inttypes.h:51
init_cache_tmp_engine_properties
void init_cache_tmp_engine_properties()
Initialize the storage engine properties for the alternative temporary table storage engines.
Definition: sql_tmp_table.cc:552
reposition_innodb_cursor
bool reposition_innodb_cursor(TABLE *table, ha_rows row_num)
Helper function for create_ondisk_from_heap().
Definition: sql_tmp_table.cc:2767
name
const string name("\"Name\"")
_entry
Definition: completion_hash.h:34
TMP_TABLE_MEMORY
@ TMP_TABLE_MEMORY
Definition: sql_tmp_table.h:51
error
Log error(cerr, "ERROR")
HttpMethod::type
int type
Definition: http_common.h:411
ORDER
Order clause list element.
Definition: table.h:276
create_tmp_table
TABLE * create_tmp_table(THD *thd, Temp_table_param *param, List< Item > &fields, ORDER *group, bool distinct, bool save_sum_fields, ulonglong select_options, ha_rows rows_limit, const char *table_alias)
Definition: sql_tmp_table.cc:828
gis::length
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
enum_internal_tmp_mem_storage_engine
enum_internal_tmp_mem_storage_engine
Definition: sql_tmp_table.h:50
ulonglong
unsigned long long int ulonglong
Definition: my_inttypes.h:55
List
Definition: aggregate_check.h:523
ha_rows
my_off_t ha_rows
Definition: my_base.h:1132
Field
Definition: field.h:695
create_tmp_field
Field * create_tmp_field(THD *thd, TABLE *table, Item *item, Item::Type type, Func_ptr_array *copy_func, Field **from_field, Field **default_field, bool group, bool modify_item, bool table_cant_handle_bit_fields, bool make_copy_field, bool copy_result_field=false)
Create field for temporary table.
Definition: sql_tmp_table.cc:306
create_tmp_field_from_field
Field * create_tmp_field_from_field(THD *thd, const Field *org_field, const char *name, TABLE *table, Item_field *item)
Create field for temporary table from given field.
Definition: sql_tmp_table.cc:118
free_tmp_table
void free_tmp_table(THD *thd, TABLE *entry)
Free TABLE object and release associated resources for internal temporary table.
Definition: sql_tmp_table.cc:2305
create_duplicate_weedout_tmp_table
TABLE * create_duplicate_weedout_tmp_table(THD *thd, uint uniq_tuple_length_arg, SJ_TMP_TABLE *sjtbl)
Create a temporary table to weed out duplicate rowid combinations.
Definition: sql_tmp_table.cc:1610
item.h