MySQL 9.1.0
Source Code Documentation
interesting_orders_defs.h
Go to the documentation of this file.
1/* Copyright (c) 2021, 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_JOIN_OPTIMIZER_INTERESTING_ORDERS_DEFS_H
25#define SQL_JOIN_OPTIMIZER_INTERESTING_ORDERS_DEFS_H
26
27// Definitions related to interesting_orders.h that can be pulled in
28// without additional dependencies on MySQL headers.
29
30#include <bitset>
31
32enum enum_order : int;
33class Item;
34class THD;
35
36// All Item * are normalized to opaque handles, where handle(x) == handle(y)
37// iff x->eq(y, /*binary_cmp=*/true). This makes them faster to compare,
38// and as an added bonus, they also take up slightly less memory.
39using ItemHandle = int;
40
41// Like ORDER, but smaller and easier to handle for our purposes (in particular,
42// no double-pointer for item). Designed for planning, not execution, so you
43// will need to make a Filesort element out of it eventually.
46
47 // ORDER_NOT_RELEVANT for a group specification. Groupings are by convention
48 // sorted by item.
50};
51
52inline bool operator==(const OrderElement &a, const OrderElement &b) {
53 return a.item == b.item && a.direction == b.direction;
54}
55
56// We represent sets of functional dependencies by bitsets, and for simplicity,
57// we only allow a fixed number of them; if you have more of them, they will not
58// get their own bitmask and will be silently ignored (imposisble to follow in
59// the state machine). Note that this does not include “always-on” FDs and FDs
60// that will be pruned away, as these are either removed or silently removed to
61// the highest indexes.
62static constexpr int kMaxSupportedFDs = 64;
63using FunctionalDependencySet = std::bitset<kMaxSupportedFDs>;
64
65static constexpr int kMaxSupportedOrderings = 64;
66using OrderingSet = std::bitset<kMaxSupportedOrderings>;
67
68#endif // SQL_JOIN_OPTIMIZER_INTERESTING_ORDERS_H
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:930
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
std::bitset< kMaxSupportedFDs > FunctionalDependencySet
Definition: interesting_orders_defs.h:63
static constexpr int kMaxSupportedFDs
Definition: interesting_orders_defs.h:62
std::bitset< kMaxSupportedOrderings > OrderingSet
Definition: interesting_orders_defs.h:66
bool operator==(const OrderElement &a, const OrderElement &b)
Definition: interesting_orders_defs.h:52
static constexpr int kMaxSupportedOrderings
Definition: interesting_orders_defs.h:65
int ItemHandle
Definition: interesting_orders_defs.h:39
enum_order
Definition: key_spec.h:65
Definition: interesting_orders_defs.h:44
enum_order direction
Definition: interesting_orders_defs.h:49
ItemHandle item
Definition: interesting_orders_defs.h:45