summaryrefslogtreecommitdiff
path: root/storage/innobase/include/row0types.h
blob: 5f1e46c6a4d17a7fd3b970110d4649bbbf867052 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*****************************************************************************

Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2018, MariaDB Corporation.

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA

*****************************************************************************/

/**************************************************//**
@file include/row0types.h
Row operation global types

Created 12/27/1996 Heikki Tuuri
*******************************************************/

#ifndef row0types_h
#define row0types_h

struct plan_t;

struct upd_t;
struct upd_field_t;
struct upd_node_t;
struct del_node_t;
struct ins_node_t;
struct sel_node_t;
struct open_node_t;
struct fetch_node_t;

struct row_printf_node_t;
struct sel_buf_t;

struct undo_node_t;

struct purge_node_t;

struct row_ext_t;

/** Buffer for logging modifications during online index creation */
struct row_log_t;

/* MySQL data types */
struct TABLE;

/** Purge virtual column node information. */
struct purge_vcol_info_t
{
private:
	/** Is there a possible need to evaluate virtual columns? */
	bool	requested;
	/** Do we have to evaluate virtual columns (using mariadb_table)? */
	bool	used;

	/** True if it is used for the first time. */
	bool	first_use;

	/** MariaDB table opened for virtual column computation. */
	TABLE*	mariadb_table;

public:
	/** Default constructor */
	purge_vcol_info_t() :
		requested(false), used(false), first_use(false),
		mariadb_table(NULL)
	{}
	/** Reset the state. */
	void reset()
	{
		requested = false;
		used = false;
		first_use = false;
		mariadb_table = NULL;
	}

	/** Validate the virtual column information.
	@return true if the mariadb table opened successfully
	or doesn't try to calculate virtual column. */
	bool validate() const { return !used || mariadb_table; }

	/** @return the table handle for evaluating virtual columns */
	TABLE* table() const { return mariadb_table; }

	/** Set the table handle for evaluating virtual columns.
	@param[in]	table	table handle */
	void set_table(TABLE* table)
	{
		ut_ad(!table || is_first_fetch());
		mariadb_table = table;
	}

	/** Note that virtual column information may be needed. */
	void set_requested()
	{
		ut_ad(!used);
		ut_ad(!first_use);
		ut_ad(!mariadb_table);
		requested = true;
	}

	/** @return whether the virtual column information may be needed */
	bool is_requested() const { return requested; }

	/** Note that the virtual column information is needed. */
	void set_used()
	{
		ut_ad(requested);

		if (first_use) {
			first_use = false;
			ut_ad(used);
			return;
		}

		if (!used) {
			first_use = used = true;
		}
	}

	/** @return whether the virtual column information is needed */
	bool is_used() const
	{
		ut_ad(!first_use || used);
		ut_ad(!used || requested);
		ut_ad(used || !mariadb_table);
		return used;
	}

	/** Check whether it fetches mariadb table for the first time.
	@return true if first time tries to open mariadb table. */
	bool is_first_fetch() const
	{
		ut_ad(!first_use || used);
		ut_ad(!used || requested);
		ut_ad(used || !mariadb_table);
		return first_use;
	}
};

#endif