MySQL  8.0.19
Source Code Documentation
row0sel.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1997, 2019, Oracle and/or its affiliates. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8 
9 This program is also distributed with certain software (including but not
10 limited to OpenSSL) that is licensed under separate terms, as designated in a
11 particular file or component or in included license documentation. The authors
12 of MySQL hereby grant you an additional permission to link the program and
13 your derivative works with the separately licensed software that they have
14 included with MySQL.
15 
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19 for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 
25 *****************************************************************************/
26 
27 /** @file include/row0sel.h
28  Select
29 
30  Created 12/19/1997 Heikki Tuuri
31  *******************************************************/
32 
33 #ifndef row0sel_h
34 #define row0sel_h
35 
36 #include "univ.i"
37 
38 #include "btr0pcur.h"
39 #include "data0data.h"
40 #include "dict0stats.h"
41 #include "dict0types.h"
42 #include "pars0sym.h"
43 #include "que0types.h"
44 #include "read0types.h"
45 #include "row0mysql.h"
46 #include "row0types.h"
47 #include "trx0types.h"
48 
49 /** Creates a select node struct.
50  @return own: select node struct */
52  mem_heap_t *heap); /*!< in: memory heap where created */
53 /** Frees the memory private to a select node when a query graph is freed,
54  does not free the heap where the node was originally created. */
55 void sel_node_free_private(sel_node_t *node); /*!< in: select node struct */
56 /** Frees a prefetch buffer for a column, including the dynamically allocated
57  memory for data stored there. */
59  sel_buf_t *prefetch_buf); /*!< in, own: prefetch buffer */
60 
61 /** Gets the plan node for the nth table in a join.
62 @param[in] node select node
63 @param[in] i get ith plan node
64 @return plan node */
65 UNIV_INLINE
66 plan_t *sel_node_get_nth_plan(sel_node_t *node, ulint i);
67 
68 /** Performs a select step. This is a high-level function used in SQL execution
69  graphs.
70  @return query thread to run next or NULL */
71 que_thr_t *row_sel_step(que_thr_t *thr); /*!< in: query thread */
72 /** Performs an execution step of an open or close cursor statement node.
73  @return query thread to run next or NULL */
74 UNIV_INLINE
75 que_thr_t *open_step(que_thr_t *thr); /*!< in: query thread */
76 /** Performs a fetch for a cursor.
77  @return query thread to run next or NULL */
78 que_thr_t *fetch_step(que_thr_t *thr); /*!< in: query thread */
79 
80 /** Copy used fields from cached row.
81 Copy cache record field by field, don't touch fields that
82 are not covered by current key.
83 @param[out] buf Where to copy the MySQL row.
84 @param[in] cached_rec What to copy (in MySQL row format).
85 @param[in] prebuilt prebuilt struct. */
86 void row_sel_copy_cached_fields_for_mysql(byte *buf, const byte *cached_rec,
87  row_prebuilt_t *prebuilt);
88 
89 // clang-format off
90 /** Convert a row in the Innobase format to a row in the MySQL format.
91 Note that the template in prebuilt may advise us to copy only a few
92 columns to mysql_rec, other columns are left blank. All columns may not
93 be needed in the query.
94 @param[out] mysql_rec row in the MySQL format
95 @param[in,out] prebuilt prebuilt structure
96 @param[in] rec Innobase record in the index
97  which was described in prebuilt's
98  template, or in the clustered index;
99  must be protected by a page latch
100 @param[in] vrow virtual columns
101 @param[in] rec_clust true if rec is in the clustered index instead
102  of prebuilt->index
103 @param[in] index index of rec
104 @param[in] offsets array returned by rec_get_offsets(rec)
105 @param[in] clust_templ_for_sec true if rec belongs to secondary index
106  but the prebuilt->template is in
107  clustered index format and it
108  is used only for end range comparison
109 @param[in] lob_undo the LOB undo information.
110 @param[in,out] blob_heap If not null then use this heap for BLOBs.
111 @return true on success, false if not all columns could be retrieved */
112 // clang-format on
113 bool row_sel_store_mysql_rec(byte *mysql_rec, row_prebuilt_t *prebuilt,
114  const rec_t *rec, const dtuple_t *vrow,
115  bool rec_clust, const dict_index_t *index,
116  const ulint *offsets, bool clust_templ_for_sec,
117  lob::undo_vers_t *lob_undo, mem_heap_t *blob_heap);
118 
119 /** Converts a key value stored in MySQL format to an Innobase dtuple. The last
120  field of the key value may be just a prefix of a fixed length field: hence
121  the parameter key_len. But currently we do not allow search keys where the
122  last field is only a prefix of the full key field len and print a warning if
123  such appears. */
125  dtuple_t *tuple, /*!< in/out: tuple where to build;
126  NOTE: we assume that the type info
127  in the tuple is already according
128  to index! */
129  byte *buf, /*!< in: buffer to use in field
130  conversions; NOTE that dtuple->data
131  may end up pointing inside buf so
132  do not discard that buffer while
133  the tuple is being used. See
134  row_mysql_store_col_in_innobase_format()
135  in the case of DATA_INT */
136  ulint buf_len, /*!< in: buffer length */
137  dict_index_t *index, /*!< in: index of the key value */
138  const byte *key_ptr, /*!< in: MySQL key value */
139  ulint key_len, /*!< in: MySQL key value length */
140  trx_t *trx); /*!< in: transaction */
141 
142 /** Searches for rows in the database. This is used in the interface to
143 MySQL. This function opens a cursor, and also implements fetch next
144 and fetch prev. NOTE that if we do a search with a full key value
145 from a unique index (ROW_SEL_EXACT), then we will not store the cursor
146 position and fetch next or fetch prev must not be tried to the cursor!
147 
148 @param[out] buf buffer for the fetched row in MySQL format
149 @param[in] mode search mode PAGE_CUR_L
150 @param[in,out] prebuilt prebuilt struct for the table handler;
151  this contains the info to search_tuple,
152  index; if search tuple contains 0 field then
153  we position the cursor at start or the end of
154  index, depending on 'mode'
155 @param[in] match_mode 0 or ROW_SEL_EXACT or ROW_SEL_EXACT_PREFIX
156 @param[in] direction 0 or ROW_SEL_NEXT or ROW_SEL_PREV;
157  Note: if this is != 0, then prebuilt must has a
158  pcur with stored position! In opening of a
159  cursor 'direction' should be 0.
160 @return DB_SUCCESS, DB_RECORD_NOT_FOUND, DB_END_OF_INDEX, DB_DEADLOCK,
161 DB_LOCK_TABLE_FULL, DB_CORRUPTION, or DB_TOO_BIG_RECORD */
162 UNIV_INLINE
164  row_prebuilt_t *prebuilt, ulint match_mode,
165  ulint direction)
166  MY_ATTRIBUTE((warn_unused_result));
167 
168 /** Searches for rows in the database using cursor.
169 function is meant for temporary table that are not shared accross connection
170 and so lot of complexity is reduced especially locking and transaction related.
171 The cursor is an iterator over the table/index.
172 
173 @param[out] buf buffer for the fetched row in MySQL format
174 @param[in] mode search mode PAGE_CUR_L
175 @param[in,out] prebuilt prebuilt struct for the table handler;
176  this contains the info to search_tuple,
177  index; if search tuple contains 0 field then
178  we position the cursor at start or the end of
179  index, depending on 'mode'
180 @param[in] match_mode 0 or ROW_SEL_EXACT or ROW_SEL_EXACT_PREFIX
181 @param[in] direction 0 or ROW_SEL_NEXT or ROW_SEL_PREV;
182  Note: if this is != 0, then prebuilt must has a
183  pcur with stored position! In opening of a
184  cursor 'direction' should be 0.
185 @return DB_SUCCESS or error code */
187  row_prebuilt_t *prebuilt, ulint match_mode,
188  ulint direction) MY_ATTRIBUTE((warn_unused_result));
189 
190 /** Searches for rows in the database using cursor.
191 Function is mainly used for tables that are shared accorss connection and
192 so it employs technique that can help re-construct the rows that
193 transaction is suppose to see.
194 It also has optimization such as pre-caching the rows, using AHI, etc.
195 
196 @param[out] buf buffer for the fetched row in MySQL format
197 @param[in] mode search mode PAGE_CUR_L
198 @param[in,out] prebuilt prebuilt struct for the table handler;
199  this contains the info to search_tuple,
200  index; if search tuple contains 0 field then
201  we position the cursor at start or the end of
202  index, depending on 'mode'
203 @param[in] match_mode 0 or ROW_SEL_EXACT or ROW_SEL_EXACT_PREFIX
204 @param[in] direction 0 or ROW_SEL_NEXT or ROW_SEL_PREV;
205  Note: if this is != 0, then prebuilt must has a
206  pcur with stored position! In opening of a
207  cursor 'direction' should be 0.
208 @return DB_SUCCESS or error code */
209 dberr_t row_search_mvcc(byte *buf, page_cur_mode_t mode,
210  row_prebuilt_t *prebuilt, ulint match_mode,
211  const ulint direction)
212  MY_ATTRIBUTE((warn_unused_result));
213 
214 /** Count rows in a R-Tree leaf level.
215  @return DB_SUCCESS if successful */
217  row_prebuilt_t *prebuilt, /*!< in: prebuilt struct for the
218  table handle; this contains the info
219  of search_tuple, index; if search
220  tuple contains 0 fields then we
221  position the cursor at the start or
222  the end of the index, depending on
223  'mode' */
224  ulint *n_rows, /*!< out: number of entries
225  seen in the consistent read */
226  ulint *n_dups); /*!< out: number of dup entries
227  seen in the consistent read */
228 
229 /** Read the max AUTOINC value from an index.
230  @return DB_SUCCESS if all OK else error code */
232  dict_index_t *index, /*!< in: index to search */
233  const char *col_name, /*!< in: autoinc column name */
234  ib_uint64_t *value) /*!< out: AUTOINC value read */
235  MY_ATTRIBUTE((warn_unused_result));
236 
237 /** A structure for caching column values for prefetched rows */
238 struct sel_buf_t {
239  byte *data; /*!< data, or NULL; if not NULL, this field
240  has allocated memory which must be explicitly
241  freed; can be != NULL even when len is
242  UNIV_SQL_NULL */
243  ulint len; /*!< data length or UNIV_SQL_NULL */
245  /*!< size of memory buffer allocated for data:
246  this can be more than len; this is defined
247  when data != NULL */
248 };
249 
250 /** Query plan */
251 struct plan_t {
252  dict_table_t *table; /*!< table struct in the dictionary
253  cache */
254  dict_index_t *index; /*!< table index used in the search */
255  btr_pcur_t pcur; /*!< persistent cursor used to search
256  the index */
257  ibool asc; /*!< TRUE if cursor traveling upwards */
258  ibool pcur_is_open; /*!< TRUE if pcur has been positioned
259  and we can try to fetch new rows */
260  ibool cursor_at_end; /*!< TRUE if the cursor is open but
261  we know that there are no more
262  qualifying rows left to retrieve from
263  the index tree; NOTE though, that
264  there may still be unprocessed rows in
265  the prefetch stack; always FALSE when
266  pcur_is_open is FALSE */
268  /*!< TRUE if the pcur position has been
269  stored and the record it is positioned
270  on has already been processed */
271  que_node_t **tuple_exps; /*!< array of expressions
272  which are used to calculate
273  the field values in the search
274  tuple: there is one expression
275  for each field in the search
276  tuple */
277  dtuple_t *tuple; /*!< search tuple */
278  page_cur_mode_t mode; /*!< search mode: PAGE_CUR_G, ... */
279  ulint n_exact_match; /*!< number of first fields in
280  the search tuple which must be
281  exactly matched */
282  ibool unique_search; /*!< TRUE if we are searching an
283  index record with a unique key */
284  ulint n_rows_fetched; /*!< number of rows fetched using pcur
285  after it was opened */
286  ulint n_rows_prefetched; /*!< number of prefetched rows cached
287  for fetch: fetching several rows in
288  the same mtr saves CPU time */
289  ulint first_prefetched; /*!< index of the first cached row in
290  select buffer arrays for each column */
291  ibool no_prefetch; /*!< no prefetch for this table */
292  sym_node_list_t columns; /*!< symbol table nodes for the columns
293  to retrieve from the table */
295  end_conds; /*!< conditions which determine the
296  fetch limit of the index segment we
297  have to look at: when one of these
298  fails, the result set has been
299  exhausted for the cursor in this
300  index; these conditions are normalized
301  so that in a comparison the column
302  for this table is the first argument */
304  other_conds; /*!< the rest of search conditions we can
305  test at this table in a join */
306  ibool must_get_clust; /*!< TRUE if index is a non-clustered
307  index and we must also fetch the
308  clustered index record; this is the
309  case if the non-clustered record does
310  not contain all the needed columns, or
311  if this is a single-table explicit
312  cursor, or a searched update or
313  delete */
314  ulint *clust_map; /*!< map telling how clust_ref is built
315  from the fields of a non-clustered
316  record */
317  dtuple_t *clust_ref; /*!< the reference to the clustered
318  index entry is built here if index is
319  a non-clustered index */
320  btr_pcur_t clust_pcur; /*!< if index is non-clustered, we use
321  this pcur to search the clustered
322  index */
323  mem_heap_t *old_vers_heap; /*!< memory heap used in building an old
324  version of a row, or NULL */
325 };
326 
327 /** Select node states */
329  SEL_NODE_CLOSED, /*!< it is a declared cursor which is not
330  currently open */
331  SEL_NODE_OPEN, /*!< intention locks not yet set on tables */
332  SEL_NODE_FETCH, /*!< intention locks have been set */
333  SEL_NODE_NO_MORE_ROWS /*!< cursor has reached the result set end */
334 };
335 
336 /** Select statement node */
337 struct sel_node_t {
338  que_common_t common; /*!< node type: QUE_NODE_SELECT */
339  enum sel_node_state state; /*!< node state */
340  que_node_t *select_list; /*!< select list */
341  sym_node_t *into_list; /*!< variables list or NULL */
342  sym_node_t *table_list; /*!< table list */
343  ibool asc; /*!< TRUE if the rows should be fetched
344  in an ascending order */
345  ibool set_x_locks; /*!< TRUE if the cursor is for update or
346  delete, which means that a row x-lock
347  should be placed on the cursor row */
348  ulint row_lock_mode; /*!< LOCK_X or LOCK_S */
349  ulint n_tables; /*!< number of tables */
350  ulint fetch_table; /*!< number of the next table to access
351  in the join */
352  plan_t *plans; /*!< array of n_tables many plan nodes
353  containing the search plan and the
354  search data structures */
355  que_node_t *search_cond; /*!< search condition */
356  ReadView *read_view; /*!< if the query is a non-locking
357  consistent read, its read view is
358  placed here, otherwise NULL */
359  ibool consistent_read; /*!< TRUE if the select is a consistent,
360  non-locking read */
361  order_node_t *order_by; /*!< order by column definition, or
362  NULL */
363  ibool is_aggregate; /*!< TRUE if the select list consists of
364  aggregate functions */
366  /*!< TRUE if the aggregate row has
367  already been fetched for the current
368  cursor */
369  ibool can_get_updated; /*!< this is TRUE if the select
370  is in a single-table explicit
371  cursor which can get updated
372  within the stored procedure,
373  or in a searched update or
374  delete; NOTE that to determine
375  of an explicit cursor if it
376  can get updated, the parser
377  checks from a stored procedure
378  if it contains positioned
379  update or delete statements */
380  sym_node_t *explicit_cursor; /*!< not NULL if an explicit cursor */
382  copy_variables; /*!< variables whose values we have to
383  copy when an explicit cursor is opened,
384  so that they do not change between
385  fetches */
386 };
387 
388 /** Fetch statement node */
389 struct fetch_node_t {
390  que_common_t common; /*!< type: QUE_NODE_FETCH */
391  sel_node_t *cursor_def; /*!< cursor definition */
392  sym_node_t *into_list; /*!< variables to set */
393 
394  pars_user_func_t *func; /*!< User callback function or NULL.
395  The first argument to the function
396  is a sel_node_t*, containing the
397  results of the SELECT operation for
398  one row. If the function returns
399  NULL, it is not interested in
400  further rows and the cursor is
401  modified so (cursor % NOTFOUND) is
402  true. If it returns not-NULL,
403  continue normally. */
404 };
405 
406 /** Open or close cursor operation type */
408  ROW_SEL_OPEN_CURSOR, /*!< open cursor */
409  ROW_SEL_CLOSE_CURSOR /*!< close cursor */
410 };
411 
412 /** Open or close cursor statement node */
413 struct open_node_t {
414  que_common_t common; /*!< type: QUE_NODE_OPEN */
415  enum open_node_op op_type; /*!< operation type: open or
416  close cursor */
417  sel_node_t *cursor_def; /*!< cursor definition */
418 };
419 
420 /** Search direction for the MySQL interface */
422  ROW_SEL_NEXT = 1, /*!< ascending direction */
423  ROW_SEL_PREV = 2 /*!< descending direction */
424 };
425 
426 /** Match mode for the MySQL interface */
428  ROW_SEL_EXACT = 1, /*!< search using a complete key value */
429  ROW_SEL_EXACT_PREFIX /*!< search using a key prefix which
430  must match rows: the prefix may
431  contain an incomplete field (the last
432  field in prefix may be just a prefix
433  of a fixed length column) */
434 };
435 
436 #ifdef UNIV_DEBUG
437 /** Convert a non-SQL-NULL field from Innobase format to MySQL format. */
438 #define row_sel_field_store_in_mysql_format(dest, templ, idx, field, src, len, \
439  sec) \
440  row_sel_field_store_in_mysql_format_func(dest, templ, idx, field, src, len, \
441  sec)
442 #else /* UNIV_DEBUG */
443 /** Convert a non-SQL-NULL field from Innobase format to MySQL format. */
444 #define row_sel_field_store_in_mysql_format(dest, templ, idx, field, src, len, \
445  sec) \
446  row_sel_field_store_in_mysql_format_func(dest, templ, idx, src, len)
447 #endif /* UNIV_DEBUG */
448 
449 /** Stores a non-SQL-NULL field in the MySQL format. The counterpart of this
450 function is row_mysql_store_col_in_innobase_format() in row0mysql.cc.
451 @param[in,out] dest buffer where to store; NOTE
452  that BLOBs are not in themselves stored
453  here: the caller must allocate and copy
454  the BLOB into buffer before, and pass
455  the pointer to the BLOB in 'data'
456 @param[in] templ MySQL column template. Its following fields
457  are referenced: type, is_unsigned,
458 mysql_col_len, mbminlen, mbmaxlen
459 @param[in] index InnoDB index
460 @param[in] field_no templ->rec_field_no or templ->clust_rec_field_no
461  or templ->icp_rec_field_no
462 @param[in] data data to store
463 @param[in] len length of the data
464 @param[in] sec_field secondary index field no if the secondary index
465  record but the prebuilt template is in
466  clustered index format and used only for end
467  range comparison. */
469  const mysql_row_templ_t *templ,
470  const dict_index_t *index,
471 #ifdef UNIV_DEBUG
472  ulint field_no,
473 #endif /* UNIV_DEBUG */
474  const byte *data, ulint len
475 #ifdef UNIV_DEBUG
476  ,
477  ulint sec_field
478 #endif /* UNIV_DEBUG */
479 );
480 
481 /** Search the record present in innodb_table_stats table using
482 db_name, table_name and fill it in table stats structure.
483 @param[in] db_name database name
484 @param[in] tbl_name table name
485 @param[out] table_stats stats table structure.
486 @return true if successful else false. */
487 bool row_search_table_stats(const char *db_name, const char *tbl_name,
489 
490 /** Search the record present in innodb_index_stats using
491 db_name, table name and index_name and fill the
492 cardinality for the each column.
493 @param[in] db_name database name
494 @param[in] tbl_name table name
495 @param[in] index_name index name
496 @param[in] col_offset offset of the column in the index
497 @param[out] cardinality cardinality of the column.
498 @return true if successful else false. */
499 bool row_search_index_stats(const char *db_name, const char *tbl_name,
500  const char *index_name, ulint col_offset,
501  ulonglong *cardinality);
502 
503 #include "row0sel.ic"
504 
505 #endif
fetch_node_t::common
que_common_t common
type: QUE_NODE_FETCH
Definition: row0sel.h:390
row_sel_direction
row_sel_direction
Search direction for the MySQL interface.
Definition: row0sel.h:421
row_search_for_mysql
UNIV_INLINE dberr_t row_search_for_mysql(byte *buf, page_cur_mode_t mode, row_prebuilt_t *prebuilt, ulint match_mode, ulint direction)
Searches for rows in the database.
dtuple_t
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:716
btr_pcur_t
Definition: btr0pcur.h:177
dict0types.h
sel_node_t::asc
ibool asc
TRUE if the rows should be fetched in an ascending order.
Definition: row0sel.h:343
plan_t::pcur_is_open
ibool pcur_is_open
TRUE if pcur has been positioned and we can try to fetch new rows.
Definition: row0sel.h:258
SEL_NODE_NO_MORE_ROWS
@ SEL_NODE_NO_MORE_ROWS
cursor has reached the result set end
Definition: row0sel.h:333
TableStatsRecord
Represent the record of innodb_table_stats table.
Definition: dict0stats.h:166
read0types.h
row_sel_copy_cached_fields_for_mysql
void row_sel_copy_cached_fields_for_mysql(byte *buf, const byte *cached_rec, row_prebuilt_t *prebuilt)
Copy used fields from cached row.
Definition: row0sel.cc:3567
UT_LIST_BASE_NODE_T
#define UT_LIST_BASE_NODE_T(TYPE)
Definition: innodb_utility.h:46
lob::undo_vers_t
The list of modifications to be applied on LOBs to get older versions.
Definition: lob0undo.h:144
sel_node_t::fetch_table
ulint fetch_table
number of the next table to access in the join
Definition: row0sel.h:350
pars_user_func_t
User-supplied function and argument.
Definition: pars0pars.h:457
page_cur_mode_t
page_cur_mode_t
Definition: page0types.h:158
dict_index_t
Data structure for an index.
Definition: dict0mem.h:869
dd::upgrade_57::table_stats
const String_type table_stats
Definition: global.h:47
fetch_node_t::into_list
sym_node_t * into_list
variables to set
Definition: row0sel.h:392
sel_node_t::explicit_cursor
sym_node_t * explicit_cursor
not NULL if an explicit cursor
Definition: row0sel.h:380
ROW_SEL_EXACT
@ ROW_SEL_EXACT
search using a complete key value
Definition: row0sel.h:428
sel_buf_t::val_buf_size
ulint val_buf_size
size of memory buffer allocated for data: this can be more than len; this is defined when data !...
Definition: row0sel.h:244
plan_t::tuple
dtuple_t * tuple
search tuple
Definition: row0sel.h:277
plan_t::cursor_at_end
ibool cursor_at_end
TRUE if the cursor is open but we know that there are no more qualifying rows left to retrieve from t...
Definition: row0sel.h:260
sym_node_t
Symbol table node.
Definition: pars0sym.h:112
plan_t::clust_map
ulint * clust_map
map telling how clust_ref is built from the fields of a non-clustered record
Definition: row0sel.h:314
dberr_t
dberr_t
Definition: db0err.h:38
sel_buf_t
A structure for caching column values for prefetched rows.
Definition: row0sel.h:238
value
const string value("\"Value\"")
plan_t::end_conds
end_conds
conditions which determine the fetch limit of the index segment we have to look at: when one of these...
Definition: row0sel.h:295
plan_t::n_exact_match
ulint n_exact_match
number of first fields in the search tuple which must be exactly matched
Definition: row0sel.h:279
dict_table_t
Data structure for a database table.
Definition: dict0mem.h:1510
plan_t::unique_search
ibool unique_search
TRUE if we are searching an index record with a unique key.
Definition: row0sel.h:282
sel_node_t::into_list
sym_node_t * into_list
variables list or NULL
Definition: row0sel.h:341
fetch_node_t::func
pars_user_func_t * func
User callback function or NULL.
Definition: row0sel.h:394
row_sel_match_mode
row_sel_match_mode
Match mode for the MySQL interface.
Definition: row0sel.h:427
mysql_row_templ_t
Definition: row0mysql.h:479
sel_node_get_nth_plan
UNIV_INLINE plan_t * sel_node_get_nth_plan(sel_node_t *node, ulint i)
Gets the plan node for the nth table in a join.
sel_node_t::read_view
ReadView * read_view
if the query is a non-locking consistent read, its read view is placed here, otherwise NULL
Definition: row0sel.h:356
row_sel_field_store_in_mysql_format_func
void row_sel_field_store_in_mysql_format_func(byte *dest, const mysql_row_templ_t *templ, const dict_index_t *index, ulint field_no, const byte *data, ulint len, ulint sec_field)
Stores a non-SQL-NULL field in the MySQL format.
Definition: row0sel.cc:2565
plan_t::mode
page_cur_mode_t mode
search mode: PAGE_CUR_G, ...
Definition: row0sel.h:278
dict0stats.h
rec_t
byte rec_t
Definition: rem0types.h:39
ROW_SEL_NEXT
@ ROW_SEL_NEXT
ascending direction
Definition: row0sel.h:422
open_node_t
Open or close cursor statement node.
Definition: row0sel.h:413
que0types.h
mem_block_info_t
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:337
sel_node_t::n_tables
ulint n_tables
number of tables
Definition: row0sel.h:349
plan_t
Query plan.
Definition: row0sel.h:251
ROW_SEL_PREV
@ ROW_SEL_PREV
descending direction
Definition: row0sel.h:423
plan_t::old_vers_heap
mem_heap_t * old_vers_heap
memory heap used in building an old version of a row, or NULL
Definition: row0sel.h:323
plan_t::n_rows_prefetched
ulint n_rows_prefetched
number of prefetched rows cached for fetch: fetching several rows in the same mtr saves CPU time
Definition: row0sel.h:286
sel_node_t::set_x_locks
ibool set_x_locks
TRUE if the cursor is for update or delete, which means that a row x-lock should be placed on the cur...
Definition: row0sel.h:345
sel_node_t::select_list
que_node_t * select_list
select list
Definition: row0sel.h:340
row_search_mvcc
dberr_t row_search_mvcc(byte *buf, page_cur_mode_t mode, row_prebuilt_t *prebuilt, ulint match_mode, const ulint direction)
Searches for rows in the database using cursor.
Definition: row0sel.cc:4416
sel_node_free_private
void sel_node_free_private(sel_node_t *node)
Frees the memory private to a select node when a query graph is freed, does not free the heap where t...
Definition: row0sel.cc:366
open_node_t::common
que_common_t common
type: QUE_NODE_OPEN
Definition: row0sel.h:414
row_search_table_stats
bool row_search_table_stats(const char *db_name, const char *tbl_name, TableStatsRecord &table_stats)
Search the record present in innodb_table_stats table using db_name, table_name and fill it in table ...
Definition: row0sel.cc:6265
sel_node_t::aggregate_already_fetched
ibool aggregate_already_fetched
TRUE if the aggregate row has already been fetched for the current cursor.
Definition: row0sel.h:365
ROW_SEL_CLOSE_CURSOR
@ ROW_SEL_CLOSE_CURSOR
close cursor
Definition: row0sel.h:409
sel_node_t::is_aggregate
ibool is_aggregate
TRUE if the select list consists of aggregate functions.
Definition: row0sel.h:363
fetch_node_t::cursor_def
sel_node_t * cursor_def
cursor definition
Definition: row0sel.h:391
plan_t::must_get_clust
ibool must_get_clust
TRUE if index is a non-clustered index and we must also fetch the clustered index record; this is the...
Definition: row0sel.h:306
ROW_SEL_EXACT_PREFIX
@ ROW_SEL_EXACT_PREFIX
search using a key prefix which must match rows: the prefix may contain an incomplete field (the last...
Definition: row0sel.h:429
row0types.h
sel_node_t::search_cond
que_node_t * search_cond
search condition
Definition: row0sel.h:355
SEL_NODE_CLOSED
@ SEL_NODE_CLOSED
it is a declared cursor which is not currently open
Definition: row0sel.h:329
pars0sym.h
row_search_max_autoinc
dberr_t row_search_max_autoinc(dict_index_t *index, const char *col_name, ib_uint64_t *value)
Read the max AUTOINC value from an index.
Definition: row0sel.cc:6202
plan_t::asc
ibool asc
TRUE if cursor traveling upwards.
Definition: row0sel.h:257
que_node_t
void que_node_t
Definition: que0types.h:40
trx0types.h
btr0pcur.h
plan_t::clust_ref
dtuple_t * clust_ref
the reference to the clustered index entry is built here if index is a non-clustered index
Definition: row0sel.h:317
open_step
UNIV_INLINE que_thr_t * open_step(que_thr_t *thr)
Performs an execution step of an open or close cursor statement node.
row_sel_convert_mysql_key_to_innobase
void row_sel_convert_mysql_key_to_innobase(dtuple_t *tuple, byte *buf, ulint buf_len, dict_index_t *index, const byte *key_ptr, ulint key_len, trx_t *trx)
Converts a key value stored in MySQL format to an Innobase dtuple.
Definition: row0sel.cc:2295
que_common_t
Definition: que0types.h:50
plan_t::pcur
btr_pcur_t pcur
persistent cursor used to search the index
Definition: row0sel.h:255
sel_node_t::can_get_updated
ibool can_get_updated
this is TRUE if the select is in a single-table explicit cursor which can get updated within the stor...
Definition: row0sel.h:369
row0mysql.h
func_node_t
A predefined function or operator node in a parsing tree; this construct is also used for some non-fu...
Definition: pars0pars.h:487
row_search_index_stats
bool row_search_index_stats(const char *db_name, const char *tbl_name, const char *index_name, ulint col_offset, ulonglong *cardinality)
Search the record present in innodb_index_stats using db_name, table name and index_name and fill the...
Definition: row0sel.cc:6326
sel_node_t::table_list
sym_node_t * table_list
table list
Definition: row0sel.h:342
ReadView
Read view lists the trx ids of those transactions for which a consistent read should not see the modi...
Definition: read0types.h:47
fetch_step
que_thr_t * fetch_step(que_thr_t *thr)
Performs a fetch for a cursor.
Definition: row0sel.cc:2239
fetch_node_t
Fetch statement node.
Definition: row0sel.h:389
sel_node_state
sel_node_state
Select node states.
Definition: row0sel.h:328
plan_t::index
dict_index_t * index
table index used in the search
Definition: row0sel.h:254
SEL_NODE_FETCH
@ SEL_NODE_FETCH
intention locks have been set
Definition: row0sel.h:332
sel_node_t::plans
plan_t * plans
array of n_tables many plan nodes containing the search plan and the search data structures
Definition: row0sel.h:352
row_sel_store_mysql_rec
bool row_sel_store_mysql_rec(byte *mysql_rec, row_prebuilt_t *prebuilt, const rec_t *rec, const dtuple_t *vrow, bool rec_clust, const dict_index_t *index, const ulint *offsets, bool clust_templ_for_sec, lob::undo_vers_t *lob_undo, mem_heap_t *blob_heap)
Convert a row in the Innobase format to a row in the MySQL format.
Definition: row0sel.cc:2957
sel_node_t::common
que_common_t common
node type: QUE_NODE_SELECT
Definition: row0sel.h:338
sel_node_t
Select statement node.
Definition: row0sel.h:337
sel_node_t::consistent_read
ibool consistent_read
TRUE if the select is a consistent, non-locking read.
Definition: row0sel.h:359
rules_table_service::db_name
const char * db_name
Definition: rules_table_service.cc:54
plan_t::columns
sym_node_list_t columns
symbol table nodes for the columns to retrieve from the table
Definition: row0sel.h:292
plan_t::tuple_exps
que_node_t ** tuple_exps
array of expressions which are used to calculate the field values in the search tuple: there is one e...
Definition: row0sel.h:271
row_sel_step
que_thr_t * row_sel_step(que_thr_t *thr)
Performs a select step.
Definition: row0sel.cc:2140
sel_col_prefetch_buf_free
void sel_col_prefetch_buf_free(sel_buf_t *prefetch_buf)
Frees a prefetch buffer for a column, including the dynamically allocated memory for data stored ther...
Definition: row0sel.cc:560
sel_node_t::order_by
order_node_t * order_by
order by column definition, or NULL
Definition: row0sel.h:361
row_search_no_mvcc
dberr_t row_search_no_mvcc(byte *buf, page_cur_mode_t mode, row_prebuilt_t *prebuilt, ulint match_mode, ulint direction)
Searches for rows in the database using cursor.
Definition: row0sel.cc:3990
ROW_SEL_OPEN_CURSOR
@ ROW_SEL_OPEN_CURSOR
open cursor
Definition: row0sel.h:408
data0data.h
plan_t::table
dict_table_t * table
table struct in the dictionary cache
Definition: row0sel.h:252
ulonglong
unsigned long long int ulonglong
Definition: my_inttypes.h:55
sel_buf_t::len
ulint len
data length or UNIV_SQL_NULL
Definition: row0sel.h:243
plan_t::other_conds
other_conds
the rest of search conditions we can test at this table in a join
Definition: row0sel.h:304
open_node_t::cursor_def
sel_node_t * cursor_def
cursor definition
Definition: row0sel.h:417
plan_t::clust_pcur
btr_pcur_t clust_pcur
if index is non-clustered, we use this pcur to search the clustered index
Definition: row0sel.h:320
open_node_op
open_node_op
Open or close cursor operation type.
Definition: row0sel.h:407
SEL_NODE_OPEN
@ SEL_NODE_OPEN
intention locks not yet set on tables
Definition: row0sel.h:331
sel_node_t::row_lock_mode
ulint row_lock_mode
LOCK_X or LOCK_S.
Definition: row0sel.h:348
que_thr_t
Definition: que0que.h:246
row_prebuilt_t
A struct for (sometimes lazily) prebuilt structures in an Innobase table handle used within MySQL; th...
Definition: row0mysql.h:539
sel_buf_t::data
byte * data
data, or NULL; if not NULL, this field has allocated memory which must be explicitly freed; can be !...
Definition: row0sel.h:239
sel_node_create
sel_node_t * sel_node_create(mem_heap_t *heap)
Creates a select node struct.
Definition: row0sel.cc:349
row_count_rtree_recs
dberr_t row_count_rtree_recs(row_prebuilt_t *prebuilt, ulint *n_rows, ulint *n_dups)
Count rows in a R-Tree leaf level.
Definition: row0sel.cc:6007
plan_t::stored_cursor_rec_processed
ibool stored_cursor_rec_processed
TRUE if the pcur position has been stored and the record it is positioned on has already been process...
Definition: row0sel.h:267
index
char * index(const char *, int c)
Definition: mysql.cc:2875
plan_t::first_prefetched
ulint first_prefetched
index of the first cached row in select buffer arrays for each column
Definition: row0sel.h:289
trx_t
Definition: trx0trx.h:780
plan_t::no_prefetch
ibool no_prefetch
no prefetch for this table
Definition: row0sel.h:291
plan_t::n_rows_fetched
ulint n_rows_fetched
number of rows fetched using pcur after it was opened
Definition: row0sel.h:284
order_node_t
An order-by node in a select.
Definition: pars0pars.h:502