MySQL 8.0.31
Source Code Documentation
row0mysql.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2000, 2022, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is also distributed with certain software (including but not
10limited to OpenSSL) that is licensed under separate terms, as designated in a
11particular file or component or in included license documentation. The authors
12of MySQL hereby grant you an additional permission to link the program and
13your derivative works with the separately licensed software that they have
14included with MySQL.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19for more details.
20
21You should have received a copy of the GNU General Public License along with
22this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
25*****************************************************************************/
26
27/** @file include/row0mysql.h
28 Interface between Innobase row operations and MySQL.
29 Contains also create table and other data dictionary operations.
30
31 Created 9/17/2000 Heikki Tuuri
32 *******************************************************/
33
34#ifndef row0mysql_h
35#define row0mysql_h
36
37#ifndef UNIV_HOTBACKUP
38#include "ha_prototypes.h"
39#endif /* !UNIV_HOTBACKUP */
40
41#include <stddef.h>
42#include <sys/types.h>
43#include <algorithm>
44
45#include "btr0pcur.h"
46#include "data0data.h"
47#include "data0type.h"
48#include "db0err.h"
49#include "dict0types.h"
50#include "fts0fts.h"
51#include "gis0type.h"
52#include "lob0undo.h"
53#include "lock0types.h"
54#include "mem0mem.h"
55#include "my_compiler.h"
56#include "my_inttypes.h"
57#include "que0types.h"
58#include "rem0types.h"
59#include "row0types.h"
60#include "sess0sess.h"
61#include "sql_cmd.h"
62#include "trx0types.h"
63#include "univ.i"
64#include "ut0bool_scope_guard.h"
65
66// Forward declarations
67class THD;
68class ha_innobase;
70namespace dd {
71class Table;
72}
73struct TABLE;
74struct btr_pcur_t;
75struct dfield_t;
76struct dict_field_t;
77struct dict_foreign_t;
78struct dict_index_t;
79struct dict_table_t;
80struct dict_v_col_t;
81struct dtuple_t;
82struct ins_node_t;
83struct mtr_t;
84struct que_fork_t;
85struct que_thr_t;
86struct trx_t;
87struct upd_node_t;
88struct upd_t;
89
90#ifndef UNIV_HOTBACKUP
91extern bool row_rollback_on_timeout;
92
93struct row_prebuilt_t;
94
95/** Frees the blob heap in prebuilt when no longer needed. */
97 row_prebuilt_t *prebuilt); /*!< in: prebuilt struct of a
98 ha_innobase:: table handle */
99/** Stores a >= 5.0.3 format true VARCHAR length to dest, in the MySQL row
100 format.
101 @return pointer to the data, we skip the 1 or 2 bytes at the start
102 that are used to store the len */
104 byte *dest, /*!< in: where to store */
105 ulint len, /*!< in: length, must fit in two bytes */
106 ulint lenlen); /*!< in: storage length of len: either 1 or 2 bytes */
107/** Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and
108 returns a pointer to the data.
109 @return pointer to the data, we skip the 1 or 2 bytes at the start
110 that are used to store the len */
112 ulint *len, /*!< out: variable-length field length */
113 const byte *field, /*!< in: field in the MySQL format */
114 ulint lenlen); /*!< in: storage length of len: either 1
115 or 2 bytes */
116
117/** Stores a reference to a BLOB in the MySQL format.
118@param[in] dest Where to store
119@param[in,out] col_len Dest buffer size: determines into how many bytes the blob
120length is stored, the space for the length may vary from 1 to 4 bytes
121@param[in] data Blob data; if the value to store is sql null this should be null
122pointer
123@param[in] len Blob length; if the value to store is sql null this should be 0;
124remember also to set the null bit in the mysql record header! */
125void row_mysql_store_blob_ref(byte *dest, ulint col_len, const void *data,
126 ulint len);
127
128/** Reads a reference to a BLOB in the MySQL format.
129@param[out] len BLOB length.
130@param[in] ref BLOB reference in the MySQL format.
131@param[in] col_len BLOB reference length (not BLOB length).
132@return pointer to BLOB data */
133const byte *row_mysql_read_blob_ref(ulint *len, const byte *ref, ulint col_len);
134
135/** Converts InnoDB geometry data format to MySQL data format. */
137 byte *dest, /*!< in/out: where to store */
138 ulint dest_len, /*!< in: dest buffer size: determines into
139 how many bytes the geometry length is stored,
140 the space for the length may vary from 1
141 to 4 bytes */
142 const byte *src, /*!< in: geometry data; if the value to store
143 is SQL NULL this should be NULL pointer */
144 ulint src_len); /*!< in: geometry length; if the value to store
145 is SQL NULL this should be 0; remember
146 also to set the NULL bit in the MySQL record
147 header! */
148
149/** Pad a column with spaces.
150@param[in] mbminlen Minimum size of a character, in bytes
151@param[out] pad Padded buffer
152@param[in] len Number of bytes to pad */
153void row_mysql_pad_col(ulint mbminlen, byte *pad, ulint len);
154
155/** Stores a non-SQL-NULL field given in the MySQL format in the InnoDB format.
156 The counterpart of this function is row_sel_field_store_in_mysql_format() in
157 row0sel.cc.
158 @return up to which byte we used buf in the conversion */
160 dfield_t *dfield, /*!< in/out: dfield where dtype
161 information must be already set when
162 this function is called! */
163 byte *buf, /*!< in/out: buffer for a converted
164 integer value; this must be at least
165 col_len long then! NOTE that dfield
166 may also get a pointer to 'buf',
167 therefore do not discard this as long
168 as dfield is used! */
169 bool row_format_col, /*!< true if the mysql_data is from
170 a MySQL row, false if from a MySQL
171 key value;
172 in MySQL, a true VARCHAR storage
173 format differs in a row and in a
174 key value: in a key value the length
175 is always stored in 2 bytes! */
176 const byte *mysql_data, /*!< in: MySQL column value, not
177 SQL NULL; NOTE that dfield may also
178 get a pointer to mysql_data,
179 therefore do not discard this as long
180 as dfield is used! */
181 ulint col_len, /*!< in: MySQL column length; NOTE that
182 this is the storage length of the
183 column in the MySQL format row, not
184 necessarily the length of the actual
185 payload data; if the column is a true
186 VARCHAR then this is irrelevant */
187 ulint comp); /*!< in: nonzero=compact format */
188/** Handles user errors and lock waits detected by the database engine.
189 @return true if it was a lock wait and we should continue running the
190 query thread */
192 dberr_t *new_err, /*!< out: possible new error encountered in
193 rollback, or the old error which was
194 during the function entry */
195 trx_t *trx, /*!< in: transaction */
196 que_thr_t *thr, /*!< in: query thread, or NULL */
197 trx_savept_t *savept); /*!< in: savepoint, or NULL */
198/** Create a prebuilt struct for a MySQL table handle.
199 @return own: a prebuilt struct */
201 dict_table_t *table, /*!< in: Innobase table handle */
202 ulint mysql_row_len); /*!< in: length in bytes of a row in
203 the MySQL format */
204
205/** Free a prebuilt struct for a MySQL table handle.
206@param[in,out] prebuilt Prebuilt struct
207@param[in] dict_locked True=data dictionary locked */
208void row_prebuilt_free(row_prebuilt_t *prebuilt, bool dict_locked);
209
210/** Updates the transaction pointers in query graphs stored in the prebuilt
211struct.
212@param[in,out] prebuilt Prebuilt struct in MySQL handle.
213@param[in,out] trx Transaction handle. */
215
216/** Sets an AUTO_INC type lock on the table mentioned in prebuilt. The
217 AUTO_INC lock gives exclusive access to the auto-inc counter of the
218 table. The lock is reserved only for the duration of an SQL statement.
219 It is not compatible with another AUTO_INC or exclusive lock on the
220 table.
221 @return error code or DB_SUCCESS */
223 row_prebuilt_t *prebuilt); /*!< in: prebuilt struct in the MySQL
224 table handle */
225
226/** Sets a table lock on the table mentioned in prebuilt.
227@param[in,out] prebuilt table handle
228@return error code or DB_SUCCESS */
230
231/** Does an insert for MySQL.
232@param[in] mysql_rec row in the MySQL format
233@param[in,out] prebuilt prebuilt struct in MySQL handle
234@return error code or DB_SUCCESS*/
235[[nodiscard]] dberr_t row_insert_for_mysql(const byte *mysql_rec,
236 row_prebuilt_t *prebuilt);
237
238/** Builds a dummy query graph used in selects. */
239void row_prebuild_sel_graph(row_prebuilt_t *prebuilt); /*!< in: prebuilt struct
240 in MySQL handle */
241/** Gets pointer to a prebuilt update vector used in updates. If the update
242 graph has not yet been built in the prebuilt struct, then this function
243 first builds it.
244 @return prebuilt update vector */
246 row_prebuilt_t *prebuilt); /*!< in: prebuilt struct in MySQL
247 handle */
248/** Checks if a table is such that we automatically created a clustered
249 index on it (on row id).
250 @return true if the clustered index was generated automatically */
252 const dict_table_t *table); /*!< in: table */
253
254/** Does an update or delete of a row for MySQL.
255@param[in] mysql_rec row in the MySQL format
256@param[in,out] prebuilt prebuilt struct in MySQL handle
257@return error code or DB_SUCCESS */
258[[nodiscard]] dberr_t row_update_for_mysql(const byte *mysql_rec,
259 row_prebuilt_t *prebuilt);
260
261/** Delete all rows for the given table by freeing/truncating indexes.
262@param[in,out] table table handler */
264
265#endif /* !UNIV_HOTBACKUP */
266
267/** Checks if a table name contains the string "/#sql" which denotes temporary
268 tables in MySQL.
269 @return true if temporary table */
270[[nodiscard]] bool row_is_mysql_tmp_table_name(const char *name);
271/*!< in: table name in the form
272'database/tablename' */
273
274#ifndef UNIV_HOTBACKUP
275/** Creates an query graph node of 'update' type to be used in the MySQL
276 interface.
277 @return own: update node */
279 dict_table_t *table, /*!< in: table to update */
280 mem_heap_t *heap); /*!< in: mem heap from which allocated */
281/** Does a cascaded delete or set null in a foreign key operation.
282 @return error code or DB_SUCCESS */
284 que_thr_t *thr, /*!< in: query thread */
285 upd_node_t *node, /*!< in: update node used in the cascade
286 or set null operation */
287 dict_table_t *table) /*!< in: table where we do the operation */
288 MY_ATTRIBUTE((nonnull));
289
290/** Locks the data dictionary exclusively for performing a table create or other
291 data dictionary modification operation.
292@param[in,out] trx Transaction
293@param[in] location Location */
295
296/** Unlocks the data dictionary exclusive lock. */
297void row_mysql_unlock_data_dictionary(trx_t *trx); /*!< in/out: transaction */
298
299/** Locks the data dictionary in shared mode from modifications, for performing
300 foreign key check, rollback, or other operation invisible to MySQL.
301@param[in,out] trx Transaction
302@param[in] location Location */
304
305/** Unlocks the data dictionary shared lock. */
306void row_mysql_unfreeze_data_dictionary(trx_t *trx); /*!< in/out: transaction */
307
308/** Creates a table for MySQL. On success the in-memory table could be
309kept in non-LRU list while on failure the 'table' object will be freed.
310@param[in,out] table table definition(will be freed, or on
311 DB_SUCCESS added to the data dictionary cache)
312@param[in] compression compression algorithm to use, can be nullptr
313@param[in] create_info HA_CREATE_INFO object
314@param[in,out] trx transaction
315@param[in] heap temp memory heap or nullptr
316@return error code or DB_SUCCESS */
318 dict_table_t *&table, const char *compression,
319 const HA_CREATE_INFO *create_info, trx_t *trx, mem_heap_t *heap);
320
321/** Does an index creation operation for MySQL. TODO: currently failure
322 to create an index results in dropping the whole table! This is no problem
323 currently as all indexes must be created at the same time as the table.
324 @return error number or DB_SUCCESS */
326 dict_index_t *index, /*!< in, own: index definition
327 (will be freed) */
328 trx_t *trx, /*!< in: transaction handle */
329 const ulint *field_lengths, /*!< in: if not NULL, must contain
330 dict_index_get_n_fields(index)
331 actual field lengths for the
332 index columns, which are
333 then checked for not being too
334 large. */
335 dict_table_t *handler); /* ! in/out: table handler. */
336
337/** Loads foreign key constraints for the table being created. This
338 function should be called after the indexes for a table have been
339 created. Each foreign key constraint must be accompanied with indexes
340 in both participating tables. The indexes are allowed to contain more
341 fields than mentioned in the constraint.
342
343 @param[in] trx transaction
344 @param[in] name table full name in normalized form
345 @param[in] dd_table MySQL dd::Table for the table
346 @return error code or DB_SUCCESS */
348 trx_t *trx, const char *name, const dd::Table *dd_table);
349
350/** The master thread in srv0srv.cc calls this regularly to drop tables which
351 we must drop in background after queries to them have ended. Such lazy
352 dropping of tables is needed in ALTER TABLE on Unix.
353 @return how many tables dropped + remaining tables in list */
355
356/** Sets an exclusive lock on a table.
357 @return error code or DB_SUCCESS */
358[[nodiscard]] dberr_t row_mysql_lock_table(
359 trx_t *trx, /*!< in/out: transaction */
360 dict_table_t *table, /*!< in: table to lock */
361 enum lock_mode mode, /*!< in: LOCK_X or LOCK_S */
362 const char *op_info); /*!< in: string for trx->op_info */
363
364/** Drop a tablespace as part of dropping or renaming a table.
365This deletes the fil_space_t if found and the file on disk.
366@param[in] space_id Tablespace ID
367@param[in] filepath File path of tablespace to delete
368@return error code or DB_SUCCESS */
369dberr_t row_drop_tablespace(space_id_t space_id, const char *filepath);
370
371/** Drop a table for MySQL. If the data dictionary was not already locked
372by the transaction, the transaction will be committed. Otherwise, the
373data dictionary will remain locked.
374@param[in] name Table name
375@param[in] trx Transaction handle
376@param[in] nonatomic Whether it is permitted to release
377and reacquire dict_operation_lock
378@param[in,out] handler Table handler or NULL
379@return error code or DB_SUCCESS */
380dberr_t row_drop_table_for_mysql(const char *name, trx_t *trx, bool nonatomic,
381 dict_table_t *handler = nullptr);
382/** Drop a table for MySQL. If the data dictionary was not already locked
383by the transaction, the transaction will be committed. Otherwise, the
384data dictionary will remain locked.
385@param[in] name table name
386@param[in,out] trx data dictionary transaction
387@return error code or DB_SUCCESS */
389 return (row_drop_table_for_mysql(name, trx, true, nullptr));
390}
391
392/** Discards the tablespace of a table which stored in an .ibd file. Discarding
393 means that this function deletes the .ibd file and assigns a new table id for
394 the table. Also the flag table->ibd_file_missing is set true.
395 @return error code or DB_SUCCESS */
397 const char *name, /*!< in: table name */
398 trx_t *trx); /*!< in: transaction handle */
399
400/** Drop a database for MySQL.
401@param[in] name database name which ends at '/'
402@param[in] trx transaction handle
403@param[out] found number of dropped tables
404@return error code or DB_SUCCESS */
406
407/** Renames a table for MySQL.
408@param[in] old_name old table name
409@param[in] new_name new table name
410@param[in] dd_table dd::Table for new table
411@param[in,out] trx transaction
412@param[in] replay whether in replay stage
413@return error code or DB_SUCCESS */
414[[nodiscard]] dberr_t row_rename_table_for_mysql(const char *old_name,
415 const char *new_name,
416 const dd::Table *dd_table,
417 trx_t *trx, bool replay);
418
419/** Read the total number of records in a consistent view.
420@param[in,out] trx Covering transaction.
421@param[in] indexes Indexes to scan.
422@param[in] max_threads Maximum number of threads to use.
423@param[out] n_rows Number of rows seen.
424@return DB_SUCCESS or error code. */
426 trx_t *trx, std::vector<dict_index_t *> &indexes, size_t max_threads,
427 ulint *n_rows);
428
429/** Scans an index for either COUNT(*) or CHECK TABLE.
430If CHECK TABLE; Checks that the index contains entries in an ascending order,
431unique constraint is not broken, and calculates the number of index entries
432in the read view of the current transaction.
433@param[in,out] prebuilt Prebuilt struct in MySQL handle.
434@param[in,out] index Index to scan.
435@param[in] n_threads Number of threads to use for the scan
436@param[in] check_keys True if called form check table.
437@param[out] n_rows Number of entries seen in the consistent read.
438@return DB_SUCCESS or other error */
439[[nodiscard]] dberr_t row_scan_index_for_mysql(row_prebuilt_t *prebuilt,
441 size_t n_threads,
442 bool check_keys, ulint *n_rows);
443/** Initialize this module */
444void row_mysql_init(void);
445
446/** Close this module */
447void row_mysql_close(void);
448
449/* A struct describing a place for an individual column in the MySQL
450row format which is presented to the table handler in ha_innobase.
451This template struct is used to speed up row transformations between
452Innobase and MySQL. */
453
455 ulint col_no; /*!< column number of the column */
456 ulint rec_field_no; /*!< field number of the column in an
457 Innobase record in the current index;
458 not defined if template_type is
459 ROW_MYSQL_WHOLE_ROW */
460 ulint clust_rec_field_no; /*!< field number of the column in an
461 Innobase record in the clustered index;
462 not defined if template_type is
463 ROW_MYSQL_WHOLE_ROW */
464 ulint icp_rec_field_no; /*!< field number of the column in an
465 Innobase record in the current index;
466 only defined for columns that could be
467 used to evaluate a pushed down index
468 condition and/or end-range condition */
469 ulint mysql_col_offset; /*!< offset of the column in the MySQL
470 row format */
471 ulint mysql_col_len; /*!< length of the column in the MySQL
472 row format */
473 ulint mysql_mvidx_len; /*!< index length on multi-value array */
474 ulint mysql_null_byte_offset; /*!< MySQL NULL bit byte offset in a
475 MySQL record */
476 ulint mysql_null_bit_mask; /*!< bit mask to get the NULL bit,
477 zero if column cannot be NULL */
478 ulint type; /*!< column type in Innobase mtype
479 numbers DATA_CHAR... */
480 ulint mysql_type; /*!< MySQL type code; this is always
481 < 256 */
482 ulint mysql_length_bytes; /*!< if mysql_type
483 == DATA_MYSQL_TRUE_VARCHAR, this tells
484 whether we should use 1 or 2 bytes to
485 store the MySQL true VARCHAR data
486 length at the start of row in the MySQL
487 format (NOTE that the MySQL key value
488 format always uses 2 bytes for the data
489 len) */
490 ulint charset; /*!< MySQL charset-collation code
491 of the column, or zero */
492 ulint mbminlen; /*!< minimum length of a char, in bytes,
493 or zero if not a char type */
494 ulint mbmaxlen; /*!< maximum length of a char, in bytes,
495 or zero if not a char type */
496 ulint is_unsigned; /*!< if a column type is an integer
497 type and this field is != 0, then
498 it is an unsigned integer type */
499 ulint is_virtual; /*!< if a column is a virtual column */
500 ulint is_multi_val; /*!< if a column is a Multi-Value Array virtual
501 column */
502};
503
504constexpr uint32_t MYSQL_FETCH_CACHE_SIZE = 8;
505/* After fetching this many rows, we start caching them in fetch_cache */
506constexpr uint32_t MYSQL_FETCH_CACHE_THRESHOLD = 4;
507
508constexpr uint32_t ROW_PREBUILT_ALLOCATED = 78540783;
509constexpr uint32_t ROW_PREBUILT_FREED = 26423527;
510
511/** A struct for (sometimes lazily) prebuilt structures in an Innobase table
512handle used within MySQL; these are used to save CPU time. */
513
515 ulint magic_n; /*!< this magic number is set to
516 ROW_PREBUILT_ALLOCATED when created,
517 or ROW_PREBUILT_FREED when the
518 struct has been freed */
519 dict_table_t *table; /*!< Innobase table handle */
520 dict_index_t *index; /*!< current index for a search, if
521 any */
522 trx_t *trx; /*!< current transaction handle */
523 unsigned sql_stat_start : 1; /*!< true when we start processing of
524 an SQL statement: we may have to set
525 an intention lock on the table,
526 create a consistent read view etc. */
528 /*!< if the user did not define a
529 primary key in MySQL, then Innobase
530 automatically generated a clustered
531 index where the ordering column is
532 the row id: in this case this flag
533 is set to true */
534 unsigned index_usable : 1; /*!< caches the value of
535 index->is_usable(trx) */
536 unsigned read_just_key : 1; /*!< set to 1 when MySQL calls
537 ha_innobase::extra with the
538 argument HA_EXTRA_KEYREAD; it is enough
539 to read just columns defined in
540 the index (i.e., no read of the
541 clustered index record necessary) */
542 unsigned used_in_HANDLER : 1; /*!< true if we have been using this
543 handle in a MySQL HANDLER low level
544 index cursor command: then we must
545 store the pcur position even in a
546 unique search from a clustered index,
547 because HANDLER allows NEXT and PREV
548 in such a situation */
549 unsigned template_type : 2; /*!< ROW_MYSQL_WHOLE_ROW,
550 ROW_MYSQL_REC_FIELDS,
551 ROW_MYSQL_DUMMY_TEMPLATE, or
552 ROW_MYSQL_NO_TEMPLATE */
553 unsigned n_template : 10; /*!< number of elements in the
554 template */
555 unsigned null_bitmap_len : 10; /*!< number of bytes in the SQL NULL
556 bitmap at the start of a row in the
557 MySQL format */
558 unsigned need_to_access_clustered : 1; /*!< if we are fetching
559 columns through a secondary index
560 and at least one column is not in
561 the secondary index, then this is
562 set to true */
563 unsigned templ_contains_blob : 1; /*!< true if the template contains
564 a column with DATA_LARGE_MTYPE(
565 get_innobase_type_from_mysql_type())
566 is true;
567 not to be confused with InnoDB
568 externally stored columns
569 (VARCHAR can be off-page too) */
570 unsigned templ_contains_fixed_point : 1; /*!< true if the
571 template contains a column with
572 DATA_POINT. Since InnoDB regards
573 DATA_POINT as non-BLOB type, the
574 templ_contains_blob can't tell us
575 if there is DATA_POINT */
576
577 /** 1 if extra(HA_EXTRA_INSERT_WITH_UPDATE) was requested, which happens
578 when ON DUPLICATE KEY UPDATE clause is present, 0 otherwise */
580
581 /** 1 if extra(HA_EXTRA_WRITE_CAN_REPLACE) was requested, which happen when
582 REPLACE is done instead of regular INSERT, 0 otherwise */
583 unsigned replace : 1;
584
585 /** template used to transform rows fast between MySQL and Innobase formats;
586 memory for this template is not allocated from 'heap' */
588
589 /** memory heap from which these auxiliary structures are allocated when
590 needed */
592
593 /** memory heap from which innodb_api_buf is allocated per session */
595
596 /** Innobase SQL insert node used to perform inserts to the table */
598
599 /** buffer for storing data converted to the Innobase format from the MySQL
600 format */
602
603 /* buffer for converting data format for multi-value virtual columns */
605 const byte *default_rec; /*!< the default values of all columns
606 (a "default row") in MySQL format */
608 /*!< normally this is set to 0; if this
609 is set to ROW_RETRIEVE_PRIMARY_KEY,
610 then we should at least retrieve all
611 columns in the primary key; if this
612 is set to ROW_RETRIEVE_ALL_COLS, then
613 we must retrieve all columns in the
614 key (if read_just_key == 1), or all
615 columns in the table */
616 upd_node_t *upd_node; /*!< Innobase SQL update node used
617 to perform updates and deletes */
618 trx_id_t trx_id; /*!< The table->def_trx_id when
619 ins_graph was built */
620 que_fork_t *ins_graph; /*!< Innobase SQL query graph used
621 in inserts. Will be rebuilt on
622 trx_id or n_indexes mismatch. */
623 que_fork_t *upd_graph; /*!< Innobase SQL query graph used
624 in updates or deletes */
625 btr_pcur_t *pcur; /*!< persistent cursor used in selects
626 and updates */
627 btr_pcur_t *clust_pcur; /*!< persistent cursor used in
628 some selects and updates */
629 que_fork_t *sel_graph; /*!< dummy query graph used in
630 selects */
631 dtuple_t *search_tuple; /*!< prebuilt dtuple used in selects */
632
633 /** prebuilt dtuple used in selects where the end of range is known */
635
636 /** Set to true in row_search_mvcc when a row matching exactly the length and
637 value of stop_tuple was found, so that the next iteration of row_search_mvcc
638 knows it can simply return DB_RECORD_NOT_FOUND. If true, then for sure, at
639 least one such matching row was seen. If false, it might be false negative, as
640 not all control paths lead to setting this field to true in case a matching
641 row is visited. */
643
644 private:
645 /** Set to true iff we are inside read_range_first() or read_range_next() */
647
648 public:
649 bool is_reading_range() const { return m_is_reading_range; }
650
652 public:
655 };
656
658 /* We implement row_is_reading_range_guard_t as a simple bool_scope_guard_t
659 because we trust that scopes are never nested and thus we don't need to
660 count their "openings" and "closings", so we assert that.*/
662 return row_is_reading_range_guard_t(*this);
663 }
664
666 /*!< if the clustered index was
667 generated, the row id of the
668 last row fetched is stored
669 here */
670 doc_id_t fts_doc_id; /* if the table has an FTS index on
671 it then we fetch the doc_id.
672 FTS-FIXME: Currently we fetch it always
673 but in the future we must only fetch
674 it when FTS columns are being
675 updated */
676 dtuple_t *clust_ref; /*!< prebuilt dtuple used in
677 sel/upd/del */
678 ulint select_lock_type; /*!< LOCK_NONE, LOCK_S, or LOCK_X */
679 enum select_mode select_mode; /*!< SELECT_ORDINARY,
680 SELECT_SKIP_LOKCED, or SELECT_NO_WAIT */
681 ulint row_read_type; /*!< ROW_READ_WITH_LOCKS if row locks
682 should be the obtained for records
683 under an UPDATE or DELETE cursor.
684 If trx_t::allow_semi_consistent()
685 returns true, this can be set to
686 ROW_READ_TRY_SEMI_CONSISTENT, so that
687 if the row under an UPDATE or DELETE
688 cursor was locked by another
689 transaction, InnoDB will resort
690 to reading the last committed value
691 ('semi-consistent read'). Then,
692 this field will be set to
693 ROW_READ_DID_SEMI_CONSISTENT to
694 indicate that. If the row does not
695 match the WHERE condition, MySQL will
696 invoke handler::unlock_row() to
697 clear the flag back to
698 ROW_READ_TRY_SEMI_CONSISTENT and
699 to simply skip the row. If
700 the row matches, the next call to
701 row_search_for_mysql() will lock
702 the row.
703 This eliminates lock waits in some
704 cases; note that this breaks
705 serializability. */
706
707 /** byte offset of the end of the last requested column*/
709
710 /** length in bytes of a row in the MySQL format */
712
713 /** number of rows fetched after positioning the current cursor */
715
716 /** ROW_SEL_NEXT or ROW_SEL_PREV */
718
720 /*!< a cache for fetched rows if we
721 fetch many rows from the same cursor:
722 it saves CPU time to fetch them in a
723 batch; we reserve mysql_row_len
724 bytes for each such row; these
725 pointers point 4 bytes past the
726 allocated mem buf start, because
727 there is a 4 byte magic number at the
728 start and at the end */
729 ulint fetch_cache_first; /*!< position of the first not yet
730 fetched row in fetch_cache */
731 ulint n_fetch_cached; /*!< number of not yet fetched rows
732 in fetch_cache */
733 mem_heap_t *blob_heap; /*!< in SELECTS BLOB fields are copied
734 to this heap */
735 mem_heap_t *old_vers_heap; /*!< memory heap where a previous
736 version is built in consistent read */
737 enum {
741 };
742 /** normally false;
743 if session is using READ COMMITTED or READ UNCOMMITTED isolation level, set in
744 row_search_for_mysql() if we set a new record lock on the secondary or
745 clustered index;
746 this is used in row_try_unlock() when releasing the lock under the cursor if
747 we determine after retrieving the row that it does not need to be locked
748 ('mini-rollback')
749
750 [LOCK_PCUR] corresponds to pcur, the first index we looked up
751 (can be secondary or clustered!)
752
753 [LOCK_CLUST_PCUR] corresponds to clust_pcur, which if used at all, is always
754 the clustered index.
755
756 The meaning of these booleans is:
757 true = we've created a rec lock, which we might release as we "own" it
758 false = we should not release any lock for this index as we either reused
759 some existing lock, or there is some other reason, we should keep it
760 */
761 std::bitset<LOCK_COUNT> new_rec_lock;
762 bool keep_other_fields_on_keyread; /*!< when using fetch
763 cache with HA_EXTRA_KEYREAD, don't
764 overwrite other fields in mysql row
765 row buffer.*/
766 bool in_fts_query; /*!< Whether we are in a FTS query */
767 bool fts_doc_id_in_read_set; /*!< true if table has externally
768 defined FTS_DOC_ID coulmn. */
769 /*----------------------*/
771 /*!< last value of AUTO-INC interval */
772 ulonglong autoinc_increment; /*!< The increment step of the auto
773 increment column. Value must be
774 greater than or equal to 1. Required to
775 calculate the next value */
776 ulonglong autoinc_offset; /*!< The offset passed to
777 get_auto_increment() by MySQL. Required
778 to calculate the next value */
779 dberr_t autoinc_error; /*!< The actual error code encountered
780 while trying to init or read the
781 autoinc value from the table. We
782 store it here so that we can return
783 it to MySQL */
784 /*----------------------*/
785 bool idx_cond; /*!< True if index condition pushdown
786 is used, false otherwise. */
787 ulint idx_cond_n_cols; /*!< Number of fields in idx_cond_cols.
788 0 if and only if idx_cond == false. */
789 /*----------------------*/
790 unsigned innodb_api : 1; /*!< whether this is a InnoDB API
791 query */
792 const rec_t *innodb_api_rec; /*!< InnoDB API search result */
793 void *innodb_api_buf; /*!< Buffer holding copy of the physical
794 Innodb API search record */
795 ulint innodb_api_rec_size; /*!< Size of the Innodb API record */
796 /*----------------------*/
797
798 /*----------------------*/
799 rtr_info_t *rtr_info; /*!< R-tree Search Info */
800 /*----------------------*/
801
802 ulint magic_n2; /*!< this should be the same as
803 magic_n */
804
805 bool ins_sel_stmt; /*!< if true then ins_sel_statement. */
806
807 innodb_session_t *session; /*!< InnoDB session handler. */
808 byte *srch_key_val1; /*!< buffer used in converting
809 search key values from MySQL format
810 to InnoDB format.*/
811 byte *srch_key_val2; /*!< buffer used in converting
812 search key values from MySQL format
813 to InnoDB format.*/
814 uint srch_key_val_len; /*!< Size of search key */
815 /** Disable prefetch. */
817
818 /** true, if server has called ha_extra(HA_EXTRA_NO_READ_LOCKING) */
820
821 /** true, if we were asked to skip AUTOINC locking for the table. */
823
824 /** Return materialized key for secondary index scan */
826
827 /** Whether this is a temporary(intrinsic) table read to keep the position
828 for this MySQL TABLE object */
830
831 /** Whether tree modifying operation happened on a temporary (intrinsic)
832 table index tree. In this case, it could be split, but no shrink. */
834
835 /** The MySQL table object */
837
838 /** The MySQL handler object. */
840
841 /** limit value to avoid fts result overflow */
843
844 /** True if exceeded the end_range while filling the prefetch cache. */
846
847 /** Undo information for LOB mvcc */
849
851
853
854 /** Can a record buffer or a prefetch cache be utilized for prefetching
855 records in this scan?
856 @retval true if records can be prefetched
857 @retval false if records cannot be prefetched */
858 bool can_prefetch_records() const;
859
860 /** Determines if the query is REPLACE or ON DUPLICATE KEY UPDATE in which
861 case duplicate values should be allowed (and further processed) instead of
862 causing an error.
863 @return true iff duplicated values should be allowed */
865
866 /** This is an no-op unless trx is using a READ COMMITTED or READ UNCOMMITTED
867 isolation level.
868 Before calling this function row_search_for_mysql() must have stored to
869 new_rec_locks[] the information which new record locks really were set.
870 This function removes a newly set index record locks under pcur or clust_pcur.
871 Thus, this implements a 'mini-rollback' that releases the latest index record
872 locks we've just set.
873
874 @param[in] has_latches_on_recs true if called so that we have the
875 latches on the records under pcur
876 and clust_pcur, and we do not need
877 to reposition the cursors. */
878 void try_unlock(bool has_latches_on_recs);
879
880 private:
881 /** A helper function for init_search_tuples_types() which prepares the shape
882 of the tuple to match the index
883 @param[in] tuple this->search_tuple or this->m_stop_tuple */
887 }
888
889 public:
890 /** Counts how many elements of @see new_rec_lock[] array are set to true. */
891 size_t new_rec_locks_count() const { return new_rec_lock.count(); }
892
893 /** Initializes search_tuple and m_stop_tuple shape so they match the index */
897 }
898
899 /** Resets both search_tuple and m_stop_tuple */
903 }
904
905 /** Inside this function perform activity that needs to be done at the
906 end of statement. */
907 void end_stmt();
908
909 /** @return true iff the operation can skip concurrency ticket. */
910 bool skip_concurrency_ticket() const;
911
912 /** It is unsafe to copy this struct, and moving it would be non-trivial,
913 because we want to keep in sync with row_is_reading_range_guard_t. Therefore
914 it is much safer/easier to just forbid such operations. */
919};
920
921/** Callback for row_mysql_sys_index_iterate() */
923 virtual ~SysIndexCallback() = default;
924
925 /** Callback method
926 @param mtr current mini-transaction
927 @param pcur persistent cursor. */
928 virtual void operator()(mtr_t *mtr, btr_pcur_t *pcur) noexcept = 0;
929};
930
931/** Get the updated parent field value from the update vector for the
932given col_no.
933@param[in] foreign foreign key information
934@param[in] update updated parent vector.
935@param[in] col_no base column position of the child table to check
936@return updated field from the parent update vector, else NULL */
938 upd_t *update, uint32_t col_no);
939
940/** Get the computed value by supplying the base column values.
941@param[in,out] row the data row
942@param[in] col virtual column
943@param[in] index index on the virtual column
944@param[in,out] local_heap heap memory for processing large data etc.
945@param[in,out] heap memory heap that copies the actual index row
946@param[in] ifield index field
947@param[in] thd MySQL thread handle
948@param[in,out] mysql_table mysql table object
949@param[in] old_table during ALTER TABLE, this is the old table
950 or NULL.
951@param[in] parent_update update vector for the parent row
952@param[in] foreign foreign key information
953@return the field filled with computed value, or NULL if just want
954to store the value in passed in "my_rec" */
956 const dtuple_t *row, const dict_v_col_t *col, const dict_index_t *index,
957 mem_heap_t **local_heap, mem_heap_t *heap, const dict_field_t *ifield,
958 THD *thd, TABLE *mysql_table, const dict_table_t *old_table,
959 upd_t *parent_update, dict_foreign_t *foreign);
960
961/** Parse out multi-values from a MySQL record
962@param[in] mysql_table MySQL table structure
963@param[in] f_idx field index of the multi-value column
964@param[in,out] dfield field structure to store parsed multi-value
965@param[in,out] value nullptr or the multi-value structure
966 to store the parsed values
967@param[in] old_val old value if exists
968@param[in] comp true if InnoDB table uses compact row format
969@param[in,out] heap memory heap */
970void innobase_get_multi_value(const TABLE *mysql_table, ulint f_idx,
971 dfield_t *dfield, multi_value_data *value,
972 uint old_val, ulint comp, mem_heap_t *heap);
973
974/** Get the computed value by supplying the base column values.
975@param[in,out] table the table whose virtual column template to be built */
977
978/** Change dbname and table name in table->vc_templ.
979@param[in,out] table the table whose virtual column template
980dbname and tbname to be renamed. */
982
983constexpr uint32_t ROW_PREBUILT_FETCH_MAGIC_N = 465765687;
984
985constexpr uint32_t ROW_MYSQL_WHOLE_ROW = 0;
986constexpr uint32_t ROW_MYSQL_REC_FIELDS = 1;
987constexpr uint32_t ROW_MYSQL_NO_TEMPLATE = 2;
988/** dummy template used in row_scan_and_check_index */
989constexpr uint32_t ROW_MYSQL_DUMMY_TEMPLATE = 3;
990
991/* Values for hint_need_to_fetch_extra_cols */
992constexpr uint32_t ROW_RETRIEVE_PRIMARY_KEY = 1;
993constexpr uint32_t ROW_RETRIEVE_ALL_COLS = 2;
994
995/* Values for row_read_type */
996constexpr uint32_t ROW_READ_WITH_LOCKS = 0;
997constexpr uint32_t ROW_READ_TRY_SEMI_CONSISTENT = 1;
998constexpr uint32_t ROW_READ_DID_SEMI_CONSISTENT = 2;
999
1000#ifdef UNIV_DEBUG
1001/** Wait for the background drop list to become empty. */
1003#endif /* UNIV_DEBUG */
1004#endif /* !UNIV_HOTBACKUP */
1005
1006#endif /* row0mysql.h */
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:50
The index tree persistent cursor.
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:922
Definition: table.h:46
The class defining a handle to an InnoDB table.
Definition: ha_innodb.h:86
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4354
Definition: sess0sess.h:70
row_is_reading_range_guard_t(row_prebuilt_t &prebuilt)
Definition: row0mysql.h:653
A RAII-style class, which sets a given boolean to true in constructor, and to false in destructor,...
Definition: ut0bool_scope_guard.h:38
bool_scope_guard_t(bool &active)
Creates the RAII guard which sets active to true for the duration of its lifetime.
Definition: ut0bool_scope_guard.h:47
void dtuple_set_n_fields(dtuple_t *tuple, ulint n_fields)
Sets number of fields used in a tuple.
Definition: data0data.cc:95
SQL data field and tuple.
Data types.
constexpr uint32_t DATA_ROW_ID_LEN
stored length for row id
Definition: data0type.h:178
Global error codes for the database.
dberr_t
Definition: db0err.h:38
void dict_index_copy_types(dtuple_t *tuple, const dict_index_t *index, ulint n_fields)
Copies types of fields contained in index to tuple.
Definition: dict0dict.cc:2907
Data dictionary global types.
Full text search header file.
uint64_t doc_id_t
Document id type.
Definition: fts0fts.h:76
R-tree header file.
Prototypes for global functions in ha_innodb.cc that are called by InnoDB C code.
Undo logging small changes to BLOBs.
The transaction lock system global types.
select_mode
Definition: lock0types.h:44
lock_mode
Definition: lock0types.h:51
The memory management.
Header for compiler-dependent features.
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
static uint update
Definition: myisamlog.cc:90
static const char * filepath
Definition: myisamlog.cc:93
Definition: buf0block_hint.cc:29
PT & ref(PT *tp)
Definition: tablespace_impl.cc:358
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:42
mode
Definition: file_handle.h:59
This file contains a set of libraries providing overloads for regular dynamic allocation routines whi...
Definition: aligned_alloc.h:47
Query graph global types.
Record manager global types.
byte rec_t
Definition: rem0types.h:40
constexpr uint32_t ROW_MYSQL_NO_TEMPLATE
Definition: row0mysql.h:987
dberr_t row_drop_table_for_mysql(const char *name, trx_t *trx, bool nonatomic, dict_table_t *handler=nullptr)
Drop a table for MySQL.
Definition: row0mysql.cc:3739
void innobase_rename_vc_templ(dict_table_t *table)
Change dbname and table name in table->vc_templ.
Definition: ha_innodb.cc:23493
constexpr uint32_t ROW_PREBUILT_ALLOCATED
Definition: row0mysql.h:508
constexpr uint32_t ROW_READ_WITH_LOCKS
Definition: row0mysql.h:996
dberr_t row_mysql_lock_table(trx_t *trx, dict_table_t *table, enum lock_mode mode, const char *op_info)
Sets an exclusive lock on a table.
Definition: row0mysql.cc:3575
constexpr uint32_t ROW_PREBUILT_FETCH_MAGIC_N
Definition: row0mysql.h:983
void row_mysql_store_blob_ref(byte *dest, ulint col_len, const void *data, ulint len)
Stores a reference to a BLOB in the MySQL format.
Definition: row0mysql.cc:212
byte * row_mysql_store_col_in_innobase_format(dfield_t *dfield, byte *buf, bool row_format_col, const byte *mysql_data, ulint col_len, ulint comp)
Stores a non-SQL-NULL field given in the MySQL format in the InnoDB format.
Definition: row0mysql.cc:375
constexpr uint32_t ROW_RETRIEVE_PRIMARY_KEY
Definition: row0mysql.h:992
dberr_t row_create_index_for_mysql(dict_index_t *index, trx_t *trx, const ulint *field_lengths, dict_table_t *handler)
Does an index creation operation for MySQL.
Definition: row0mysql.cc:2874
void row_mysql_store_geometry(byte *dest, ulint dest_len, const byte *src, ulint src_len)
Converts InnoDB geometry data format to MySQL data format.
Definition: row0mysql.cc:245
dfield_t * innobase_get_computed_value(const dtuple_t *row, const dict_v_col_t *col, const dict_index_t *index, mem_heap_t **local_heap, mem_heap_t *heap, const dict_field_t *ifield, THD *thd, TABLE *mysql_table, const dict_table_t *old_table, upd_t *parent_update, dict_foreign_t *foreign)
Get the computed value by supplying the base column values.
Definition: ha_innodb.cc:23546
const byte * row_mysql_read_true_varchar(ulint *len, const byte *field, ulint lenlen)
Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and returns a pointer to the da...
Definition: row0mysql.cc:185
dberr_t row_mysql_parallel_select_count_star(trx_t *trx, std::vector< dict_index_t * > &indexes, size_t max_threads, ulint *n_rows)
Read the total number of records in a consistent view.
Definition: row0mysql.cc:4345
constexpr uint32_t ROW_MYSQL_DUMMY_TEMPLATE
dummy template used in row_scan_and_check_index
Definition: row0mysql.h:989
void innobase_get_multi_value(const TABLE *mysql_table, ulint f_idx, dfield_t *dfield, multi_value_data *value, uint old_val, ulint comp, mem_heap_t *heap)
Parse out multi-values from a MySQL record.
Definition: ha_innodb.cc:8947
dberr_t row_scan_index_for_mysql(row_prebuilt_t *prebuilt, dict_index_t *index, size_t n_threads, bool check_keys, ulint *n_rows)
Scans an index for either COUNT(*) or CHECK TABLE.
Definition: row0mysql.cc:4543
const byte * row_mysql_read_blob_ref(ulint *len, const byte *ref, ulint col_len)
Reads a reference to a BLOB in the MySQL format.
Definition: row0mysql.cc:233
dberr_t row_create_table_for_mysql(dict_table_t *&table, const char *compression, const HA_CREATE_INFO *create_info, trx_t *trx, mem_heap_t *heap)
Creates a table for MySQL.
Definition: row0mysql.cc:2724
dberr_t row_update_cascade_for_mysql(que_thr_t *thr, upd_node_t *node, dict_table_t *table)
Does a cascaded delete or set null in a foreign key operation.
Definition: row0mysql.cc:2569
void row_mysql_unlock_data_dictionary(trx_t *trx)
Unlocks the data dictionary exclusive lock.
Definition: row0mysql.cc:2711
constexpr uint32_t ROW_PREBUILT_FREED
Definition: row0mysql.h:509
void row_wait_for_background_drop_list_empty()
Wait for the background drop list to become empty.
Definition: row0mysql.cc:127
void row_mysql_unfreeze_data_dictionary(trx_t *trx)
Unlocks the data dictionary shared lock.
Definition: row0mysql.cc:2684
constexpr uint32_t MYSQL_FETCH_CACHE_SIZE
Definition: row0mysql.h:504
dberr_t row_discard_tablespace_for_mysql(const char *name, trx_t *trx)
Discards the tablespace of a table which stored in an .ibd file.
Definition: row0mysql.cc:3520
dberr_t row_table_load_foreign_constraints(trx_t *trx, const char *name, const dd::Table *dd_table)
Loads foreign key constraints for the table being created.
Definition: row0mysql.cc:3034
dberr_t row_update_for_mysql(const byte *mysql_rec, row_prebuilt_t *prebuilt)
Does an update or delete of a row for MySQL.
Definition: row0mysql.cc:2445
void row_mysql_prebuilt_free_blob_heap(row_prebuilt_t *prebuilt)
Frees the blob heap in prebuilt when no longer needed.
Definition: row0mysql.cc:146
row_prebuilt_t * row_create_prebuilt(dict_table_t *table, ulint mysql_row_len)
Create a prebuilt struct for a MySQL table handle.
Definition: row0mysql.cc:780
dberr_t row_drop_database_for_mysql(const char *name, trx_t *trx, ulint *found)
Drop a database for MySQL.
dberr_t row_lock_table_autoinc_for_mysql(row_prebuilt_t *prebuilt)
Sets an AUTO_INC type lock on the table mentioned in prebuilt.
Definition: row0mysql.cc:1143
constexpr uint32_t ROW_MYSQL_WHOLE_ROW
Definition: row0mysql.h:985
ulint row_drop_tables_for_mysql_in_background(void)
The master thread in srv0srv.cc calls this regularly to drop tables which we must drop in background ...
Definition: row0mysql.cc:3139
constexpr uint32_t ROW_READ_DID_SEMI_CONSISTENT
Definition: row0mysql.h:998
byte * row_mysql_store_true_var_len(byte *dest, ulint len, ulint lenlen)
Stores a >= 5.0.3 format true VARCHAR length to dest, in the MySQL row format.
Definition: row0mysql.cc:160
upd_t * row_get_prebuilt_update_vector(row_prebuilt_t *prebuilt)
Gets pointer to a prebuilt update vector used in updates.
Definition: row0mysql.cc:1781
dfield_t * innobase_get_field_from_update_vector(dict_foreign_t *foreign, upd_t *update, uint32_t col_no)
Get the updated parent field value from the update vector for the given col_no.
Definition: ha_innodb.cc:23504
constexpr uint32_t ROW_RETRIEVE_ALL_COLS
Definition: row0mysql.h:993
void row_mysql_freeze_data_dictionary(trx_t *trx, ut::Location location)
Locks the data dictionary in shared mode from modifications, for performing foreign key check,...
Definition: row0mysql.cc:2675
void row_mysql_pad_col(ulint mbminlen, byte *pad, ulint len)
Pad a column with spaces.
Definition: row0mysql.cc:338
bool row_is_mysql_tmp_table_name(const char *name)
Checks if a table name contains the string "/#sql" which denotes temporary tables in MySQL.
Definition: row0mysql.cc:4127
void row_mysql_close(void)
Close this module.
Definition: row0mysql.cc:4748
void row_update_prebuilt_trx(row_prebuilt_t *prebuilt, trx_t *trx)
Updates the transaction pointers in query graphs stored in the prebuilt struct.
Definition: row0mysql.cc:1003
dberr_t row_rename_table_for_mysql(const char *old_name, const char *new_name, const dd::Table *dd_table, trx_t *trx, bool replay)
Renames a table for MySQL.
Definition: row0mysql.cc:4139
bool row_mysql_handle_errors(dberr_t *new_err, trx_t *trx, que_thr_t *thr, trx_savept_t *savept)
Handles user errors and lock waits detected by the database engine.
Definition: row0mysql.cc:652
void row_prebuilt_free(row_prebuilt_t *prebuilt, bool dict_locked)
Free a prebuilt struct for a MySQL table handle.
Definition: row0mysql.cc:930
constexpr uint32_t ROW_MYSQL_REC_FIELDS
Definition: row0mysql.h:986
void row_mysql_lock_data_dictionary(trx_t *trx, ut::Location location)
Locks the data dictionary exclusively for performing a table create or other data dictionary modifica...
Definition: row0mysql.cc:2697
constexpr uint32_t ROW_READ_TRY_SEMI_CONSISTENT
Definition: row0mysql.h:997
bool row_rollback_on_timeout
Provide optional 4.x backwards compatibility for 5.0 and above.
Definition: row0mysql.cc:93
void innobase_init_vc_templ(dict_table_t *table)
Get the computed value by supplying the base column values.
Definition: ha_innodb.cc:23459
upd_node_t * row_create_update_node_for_mysql(dict_table_t *table, mem_heap_t *heap)
Creates an query graph node of 'update' type to be used in the MySQL interface.
Definition: row0mysql.cc:1736
void row_mysql_init(void)
Initialize this module.
Definition: row0mysql.cc:4741
bool row_table_got_default_clust_index(const dict_table_t *table)
Checks if a table is such that we automatically created a clustered index on it (on row id).
Definition: row0mysql.cc:2661
dberr_t row_lock_table(row_prebuilt_t *prebuilt)
Sets a table lock on the table mentioned in prebuilt.
Definition: row0mysql.cc:1212
void row_delete_all_rows(dict_table_t *table)
Delete all rows for the given table by freeing/truncating indexes.
Definition: row0mysql.cc:2456
dberr_t row_drop_tablespace(space_id_t space_id, const char *filepath)
Drop a tablespace as part of dropping or renaming a table.
Definition: row0mysql.cc:3702
void row_prebuild_sel_graph(row_prebuilt_t *prebuilt)
Builds a dummy query graph used in selects.
Definition: row0mysql.cc:1717
constexpr uint32_t MYSQL_FETCH_CACHE_THRESHOLD
Definition: row0mysql.h:506
dberr_t row_insert_for_mysql(const byte *mysql_rec, row_prebuilt_t *prebuilt)
Does an insert for MySQL.
Definition: row0mysql.cc:1706
Row operation global types.
InnoDB session state tracker.
Representation of an SQL command.
case opt name
Definition: sslopt-case.h:32
Definition: handler.h:2987
Callback for row_mysql_sys_index_iterate()
Definition: row0mysql.h:922
virtual ~SysIndexCallback()=default
virtual void operator()(mtr_t *mtr, btr_pcur_t *pcur) noexcept=0
Callback method.
Definition: table.h:1396
Definition: btr0pcur.h:98
Structure for an SQL data field.
Definition: data0data.h:604
Data structure for a field in an index.
Definition: dict0mem.h:870
Data structure for a foreign key constraint; an example: FOREIGN KEY (A, B) REFERENCES TABLE2 (C,...
Definition: dict0mem.h:1641
Data structure for an index.
Definition: dict0mem.h:1021
unsigned n_fields
number of fields in the index
Definition: dict0mem.h:1081
Data structure for a database table.
Definition: dict0mem.h:1884
Data structure for a virtual column in a table.
Definition: dict0mem.h:790
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:681
Definition: row0ins.h:161
The list of modifications to be applied on LOBs to get older versions.
Definition: lob0undo.h:145
void reset()
Empty the collected LOB undo information from cache.
Definition: lob0undo.h:189
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:299
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:181
Structure to hold number of multiple values.
Definition: data0data.h:383
Definition: row0mysql.h:454
ulint mysql_null_byte_offset
MySQL NULL bit byte offset in a MySQL record.
Definition: row0mysql.h:474
ulint mysql_col_offset
offset of the column in the MySQL row format
Definition: row0mysql.h:469
ulint rec_field_no
field number of the column in an Innobase record in the current index; not defined if template_type i...
Definition: row0mysql.h:456
ulint is_unsigned
if a column type is an integer type and this field is != 0, then it is an unsigned integer type
Definition: row0mysql.h:496
ulint mysql_type
MySQL type code; this is always < 256.
Definition: row0mysql.h:480
ulint mbminlen
minimum length of a char, in bytes, or zero if not a char type
Definition: row0mysql.h:492
ulint mbmaxlen
maximum length of a char, in bytes, or zero if not a char type
Definition: row0mysql.h:494
ulint mysql_length_bytes
if mysql_type == DATA_MYSQL_TRUE_VARCHAR, this tells whether we should use 1 or 2 bytes to store the ...
Definition: row0mysql.h:482
ulint mysql_null_bit_mask
bit mask to get the NULL bit, zero if column cannot be NULL
Definition: row0mysql.h:476
ulint is_virtual
if a column is a virtual column
Definition: row0mysql.h:499
ulint col_no
column number of the column
Definition: row0mysql.h:455
ulint is_multi_val
if a column is a Multi-Value Array virtual column
Definition: row0mysql.h:500
ulint type
column type in Innobase mtype numbers DATA_CHAR...
Definition: row0mysql.h:478
ulint mysql_col_len
length of the column in the MySQL row format
Definition: row0mysql.h:471
ulint clust_rec_field_no
field number of the column in an Innobase record in the clustered index; not defined if template_type...
Definition: row0mysql.h:460
ulint mysql_mvidx_len
index length on multi-value array
Definition: row0mysql.h:473
ulint icp_rec_field_no
field number of the column in an Innobase record in the current index; only defined for columns that ...
Definition: row0mysql.h:464
ulint charset
MySQL charset-collation code of the column, or zero.
Definition: row0mysql.h:490
Definition: que0que.h:300
Definition: que0que.h:241
A struct for (sometimes lazily) prebuilt structures in an Innobase table handle used within MySQL; th...
Definition: row0mysql.h:514
bool m_read_virtual_key
Return materialized key for secondary index scan.
Definition: row0mysql.h:825
trx_id_t trx_id
The table->def_trx_id when ins_graph was built.
Definition: row0mysql.h:618
unsigned used_in_HANDLER
true if we have been using this handle in a MySQL HANDLER low level index cursor command: then we mus...
Definition: row0mysql.h:542
byte * srch_key_val2
buffer used in converting search key values from MySQL format to InnoDB format.
Definition: row0mysql.h:811
upd_node_t * upd_node
Innobase SQL update node used to perform updates and deletes.
Definition: row0mysql.h:616
unsigned sql_stat_start
true when we start processing of an SQL statement: we may have to set an intention lock on the table,...
Definition: row0mysql.h:523
row_prebuilt_t(row_prebuilt_t &&)=delete
innodb_session_t * session
InnoDB session handler.
Definition: row0mysql.h:807
multi_value_data * mv_data
Definition: row0mysql.h:604
dict_table_t * table
Innobase table handle.
Definition: row0mysql.h:519
const byte * default_rec
the default values of all columns (a "default row") in MySQL format
Definition: row0mysql.h:605
ulonglong m_fts_limit
limit value to avoid fts result overflow
Definition: row0mysql.h:842
void lob_undo_reset()
Definition: row0mysql.h:852
unsigned replace
1 if extra(HA_EXTRA_WRITE_CAN_REPLACE) was requested, which happen when REPLACE is done instead of re...
Definition: row0mysql.h:583
size_t new_rec_locks_count() const
Counts how many elements of.
Definition: row0mysql.h:891
dtuple_t * search_tuple
prebuilt dtuple used in selects
Definition: row0mysql.h:631
ulint hint_need_to_fetch_extra_cols
normally this is set to 0; if this is set to ROW_RETRIEVE_PRIMARY_KEY, then we should at least retrie...
Definition: row0mysql.h:607
mysql_row_templ_t * mysql_template
template used to transform rows fast between MySQL and Innobase formats; memory for this template is ...
Definition: row0mysql.h:587
ulint mysql_prefix_len
byte offset of the end of the last requested column
Definition: row0mysql.h:708
doc_id_t fts_doc_id
Definition: row0mysql.h:670
bool keep_other_fields_on_keyread
when using fetch cache with HA_EXTRA_KEYREAD, don't overwrite other fields in mysql row row buffer.
Definition: row0mysql.h:762
ulint select_lock_type
LOCK_NONE, LOCK_S, or LOCK_X.
Definition: row0mysql.h:678
bool no_autoinc_locking
true, if we were asked to skip AUTOINC locking for the table.
Definition: row0mysql.h:822
row_prebuilt_t(row_prebuilt_t const &)=delete
It is unsafe to copy this struct, and moving it would be non-trivial, because we want to keep in sync...
row_prebuilt_t & operator=(row_prebuilt_t const &)=delete
ulonglong autoinc_offset
The offset passed to get_auto_increment() by MySQL.
Definition: row0mysql.h:776
void end_stmt()
Inside this function perform activity that needs to be done at the end of statement.
Definition: row0mysql.cc:4810
ulint innodb_api_rec_size
Size of the Innodb API record.
Definition: row0mysql.h:795
unsigned innodb_api
whether this is a InnoDB API query
Definition: row0mysql.h:790
btr_pcur_t * clust_pcur
persistent cursor used in some selects and updates
Definition: row0mysql.h:627
unsigned templ_contains_fixed_point
true if the template contains a column with DATA_POINT.
Definition: row0mysql.h:570
unsigned null_bitmap_len
number of bytes in the SQL NULL bitmap at the start of a row in the MySQL format
Definition: row0mysql.h:555
bool ins_sel_stmt
if true then ins_sel_statement.
Definition: row0mysql.h:805
mem_heap_t * blob_heap
in SELECTS BLOB fields are copied to this heap
Definition: row0mysql.h:733
bool m_is_reading_range
Set to true iff we are inside read_range_first() or read_range_next()
Definition: row0mysql.h:646
ins_node_t * ins_node
Innobase SQL insert node used to perform inserts to the table.
Definition: row0mysql.h:597
bool m_no_prefetch
Disable prefetch.
Definition: row0mysql.h:816
unsigned n_template
number of elements in the template
Definition: row0mysql.h:553
bool m_temp_tree_modified
Whether tree modifying operation happened on a temporary (intrinsic) table index tree.
Definition: row0mysql.h:833
unsigned on_duplicate_key_update
1 if extra(HA_EXTRA_INSERT_WITH_UPDATE) was requested, which happens when ON DUPLICATE KEY UPDATE cla...
Definition: row0mysql.h:579
@ LOCK_PCUR
Definition: row0mysql.h:738
@ LOCK_COUNT
Definition: row0mysql.h:740
@ LOCK_CLUST_PCUR
Definition: row0mysql.h:739
btr_pcur_t * pcur
persistent cursor used in selects and updates
Definition: row0mysql.h:625
ulint n_fetch_cached
number of not yet fetched rows in fetch_cache
Definition: row0mysql.h:731
std::bitset< LOCK_COUNT > new_rec_lock
normally false; if session is using READ COMMITTED or READ UNCOMMITTED isolation level,...
Definition: row0mysql.h:761
lob::undo_vers_t * get_lob_undo()
Definition: row0mysql.h:850
mem_heap_t * cursor_heap
memory heap from which innodb_api_buf is allocated per session
Definition: row0mysql.h:594
ulonglong autoinc_increment
The increment step of the auto increment column.
Definition: row0mysql.h:772
unsigned templ_contains_blob
true if the template contains a column with DATA_LARGE_MTYPE( get_innobase_type_from_mysql_type()) is...
Definition: row0mysql.h:563
ulint idx_cond_n_cols
Number of fields in idx_cond_cols.
Definition: row0mysql.h:787
ulint row_read_type
ROW_READ_WITH_LOCKS if row locks should be the obtained for records under an UPDATE or DELETE cursor.
Definition: row0mysql.h:681
lob::undo_vers_t m_lob_undo
Undo information for LOB mvcc.
Definition: row0mysql.h:848
ha_innobase * m_mysql_handler
The MySQL handler object.
Definition: row0mysql.h:839
bool in_fts_query
Whether we are in a FTS query.
Definition: row0mysql.h:766
bool no_read_locking
true, if server has called ha_extra(HA_EXTRA_NO_READ_LOCKING)
Definition: row0mysql.h:819
mem_heap_t * old_vers_heap
memory heap where a previous version is built in consistent read
Definition: row0mysql.h:735
bool is_reading_range() const
Definition: row0mysql.h:649
bool skip_concurrency_ticket() const
Definition: row0mysql.cc:4775
void try_unlock(bool has_latches_on_recs)
This is an no-op unless trx is using a READ COMMITTED or READ UNCOMMITTED isolation level.
Definition: row0mysql.cc:2489
ulint fetch_direction
ROW_SEL_NEXT or ROW_SEL_PREV.
Definition: row0mysql.h:717
ulint n_rows_fetched
number of rows fetched after positioning the current cursor
Definition: row0mysql.h:714
bool allow_duplicates()
Determines if the query is REPLACE or ON DUPLICATE KEY UPDATE in which case duplicate values should b...
Definition: row0mysql.h:864
ulint mysql_row_len
length in bytes of a row in the MySQL format
Definition: row0mysql.h:711
byte * srch_key_val1
buffer used in converting search key values from MySQL format to InnoDB format.
Definition: row0mysql.h:808
unsigned need_to_access_clustered
if we are fetching columns through a secondary index and at least one column is not in the secondary ...
Definition: row0mysql.h:558
que_fork_t * upd_graph
Innobase SQL query graph used in updates or deletes.
Definition: row0mysql.h:623
dtuple_t * m_stop_tuple
prebuilt dtuple used in selects where the end of range is known
Definition: row0mysql.h:634
bool m_stop_tuple_found
Set to true in row_search_mvcc when a row matching exactly the length and value of stop_tuple was fou...
Definition: row0mysql.h:642
byte * fetch_cache[MYSQL_FETCH_CACHE_SIZE]
a cache for fetched rows if we fetch many rows from the same cursor: it saves CPU time to fetch them ...
Definition: row0mysql.h:719
dberr_t autoinc_error
The actual error code encountered while trying to init or read the autoinc value from the table.
Definition: row0mysql.h:779
bool idx_cond
True if index condition pushdown is used, false otherwise.
Definition: row0mysql.h:785
byte * ins_upd_rec_buff
buffer for storing data converted to the Innobase format from the MySQL format
Definition: row0mysql.h:601
trx_t * trx
current transaction handle
Definition: row0mysql.h:522
unsigned read_just_key
set to 1 when MySQL calls ha_innobase::extra with the argument HA_EXTRA_KEYREAD; it is enough to read...
Definition: row0mysql.h:536
row_prebuilt_t & operator=(row_prebuilt_t &&)=delete
bool m_temp_read_shared
Whether this is a temporary(intrinsic) table read to keep the position for this MySQL TABLE object.
Definition: row0mysql.h:829
byte row_id[DATA_ROW_ID_LEN]
if the clustered index was generated, the row id of the last row fetched is stored here
Definition: row0mysql.h:665
TABLE * m_mysql_table
The MySQL table object.
Definition: row0mysql.h:836
const rec_t * innodb_api_rec
InnoDB API search result.
Definition: row0mysql.h:792
void init_search_tuples_types()
Initializes search_tuple and m_stop_tuple shape so they match the index.
Definition: row0mysql.h:894
unsigned clust_index_was_generated
if the user did not define a primary key in MySQL, then Innobase automatically generated a clustered ...
Definition: row0mysql.h:527
unsigned index_usable
caches the value of index->is_usable(trx)
Definition: row0mysql.h:534
void * innodb_api_buf
Buffer holding copy of the physical Innodb API search record.
Definition: row0mysql.h:793
row_is_reading_range_guard_t get_is_reading_range_guard()
Definition: row0mysql.h:657
void init_tuple_types(dtuple_t *tuple)
A helper function for init_search_tuples_types() which prepares the shape of the tuple to match the i...
Definition: row0mysql.h:884
bool can_prefetch_records() const
Can a record buffer or a prefetch cache be utilized for prefetching records in this scan?
Definition: row0mysql.cc:4760
rtr_info_t * rtr_info
R-tree Search Info.
Definition: row0mysql.h:799
ulint fetch_cache_first
position of the first not yet fetched row in fetch_cache
Definition: row0mysql.h:729
bool m_end_range
True if exceeded the end_range while filling the prefetch cache.
Definition: row0mysql.h:845
enum select_mode select_mode
SELECT_ORDINARY, SELECT_SKIP_LOKCED, or SELECT_NO_WAIT.
Definition: row0mysql.h:679
dtuple_t * clust_ref
prebuilt dtuple used in sel/upd/del
Definition: row0mysql.h:676
void clear_search_tuples()
Resets both search_tuple and m_stop_tuple.
Definition: row0mysql.h:900
ulint magic_n
this magic number is set to ROW_PREBUILT_ALLOCATED when created, or ROW_PREBUILT_FREED when the struc...
Definition: row0mysql.h:515
que_fork_t * ins_graph
Innobase SQL query graph used in inserts.
Definition: row0mysql.h:620
ulonglong autoinc_last_value
last value of AUTO-INC interval
Definition: row0mysql.h:770
uint srch_key_val_len
Size of search key.
Definition: row0mysql.h:814
bool fts_doc_id_in_read_set
true if table has externally defined FTS_DOC_ID coulmn.
Definition: row0mysql.h:767
mem_heap_t * heap
memory heap from which these auxiliary structures are allocated when needed
Definition: row0mysql.h:591
unsigned template_type
ROW_MYSQL_WHOLE_ROW, ROW_MYSQL_REC_FIELDS, ROW_MYSQL_DUMMY_TEMPLATE, or ROW_MYSQL_NO_TEMPLATE.
Definition: row0mysql.h:549
dict_index_t * index
current index for a search, if any
Definition: row0mysql.h:520
que_fork_t * sel_graph
dummy query graph used in selects
Definition: row0mysql.h:629
ulint magic_n2
this should be the same as magic_n
Definition: row0mysql.h:802
Vectors holding the matching internal pages/nodes and leaf records.
Definition: gis0type.h:108
Transaction savepoint.
Definition: trx0types.h:147
Definition: trx0trx.h:680
Definition: row0upd.h:700
Definition: row0upd.h:564
Definition: ut0core.h:32
Transaction system global type definitions.
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:137
unsigned int uint
Definition: uca-dump.cc:29
Version control for database, common definitions, and include files.
unsigned long int ulint
Definition: univ.i:407
The ut_bool_scope_guard class which sets boolean to true for the duration of scope.
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:68