MySQL  8.0.23
Source Code Documentation
zlob0first.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 2016, 2020, Oracle and/or its affiliates.
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 #ifndef zlob0first_h
27 #define zlob0first_h
28 
29 #include "fil0types.h"
30 #include "fut0lst.h"
31 #include "lob0impl.h"
32 #include "univ.i"
33 
34 namespace lob {
35 
36 /** The first page of an zlob. */
37 struct z_first_page_t {
38  /** Version information. One byte. */
39  static const ulint OFFSET_VERSION = FIL_PAGE_DATA;
40 
41  /** One byte of flag bits. Currently only one bit (the least
42  significant bit) is used, other 7 bits are available for future use.*/
43  static const ulint OFFSET_FLAGS = FIL_PAGE_DATA + 1;
44 
45  /** LOB version. 4 bytes.*/
46  static const uint32_t OFFSET_LOB_VERSION = OFFSET_FLAGS + 1;
47 
48  /** The last transaction that modified this LOB. */
49  static const ulint OFFSET_LAST_TRX_ID = OFFSET_LOB_VERSION + 4;
50 
51  /** The last transaction that modified this LOB. */
52  static const ulint OFFSET_LAST_UNDO_NO = OFFSET_LAST_TRX_ID + 6;
53 
54  /** The length of compressed data stored in this page. */
55  static const ulint OFFSET_DATA_LEN = OFFSET_LAST_UNDO_NO + 4;
56 
57  /** The transaction that created data in the data portion. */
58  static const ulint OFFSET_TRX_ID = OFFSET_DATA_LEN + 4;
59 
60  /** The next index page. */
61  static const ulint OFFSET_INDEX_PAGE_NO = OFFSET_TRX_ID + 6;
62 
63  /** The next frag nodes page. */
64  static const ulint OFFSET_FRAG_NODES_PAGE_NO = OFFSET_INDEX_PAGE_NO + 4;
65 
66  /** List of free index entries. */
67  static const ulint OFFSET_FREE_LIST = OFFSET_FRAG_NODES_PAGE_NO + 4;
68 
69  /** List of index entries. */
71 
72  /** List of free frag entries. */
73  static const ulint OFFSET_FREE_FRAG_LIST =
75 
76  /** List of frag entries. */
77  static const ulint OFFSET_FRAG_LIST =
79 
80  /** Begin of index entries. */
81  static const ulint OFFSET_INDEX_BEGIN =
83 
84  /** Given the page size, what is the number of index entries the
85  first page can contain. */
86  ulint get_n_index_entries() const;
87 
88  /** Given the page size, what is the number of frag entries the
89  first page can contain. */
90  ulint get_n_frag_entries() const;
91 
92  ulint size_of_index_entries() const;
93 
94  ulint size_of_frag_entries() const {
96  }
97 
98  ulint begin_frag_entries() const {
100  }
101 
102  ulint begin_data() const {
104  }
105 
106  bool is_empty() const {
107  flst_base_node_t *flst = index_list();
108  return (flst_get_len(flst) == 0);
109  }
110 
111  /** Get the length of the index list.
112  @return length of the index list. */
113  ulint get_index_list_length() const {
114  flst_base_node_t *flst = index_list();
115  return (flst_get_len(flst));
116  }
117 
118  void set_version_0() {
120  }
121 
122  byte *begin_data_ptr() const { return (frame() + begin_data()); }
123 
124  /** Amount of zlob data that can be stored in first page (in bytes). */
125  ulint payload() {
127  ut_ad(begin_data() + FIL_PAGE_DATA_END < page_size.physical());
128  return (page_size.physical() - begin_data() - FIL_PAGE_DATA_END);
129  }
130 
132 
133  z_first_page_t(mtr_t *mtr, dict_index_t *index)
134  : m_block(nullptr), m_mtr(mtr), m_index(index) {}
135 
136  z_first_page_t(buf_block_t *block) : m_block(block) {}
137 
138  z_first_page_t(buf_block_t *block, mtr_t *mtr, dict_index_t *index)
139  : m_block(block), m_mtr(mtr), m_index(index) {}
140 
141  buf_block_t *alloc(bool bulk);
142 
143  void import(trx_id_t trx_id);
144 
145  page_type_t get_page_type() const {
147  }
148 
149  /** Load the given page number as the first page in x-latch mode.
150  @param[in] page_no the first page number.
151  @return the buffer block of the given page number. */
152  buf_block_t *load_x(page_no_t page_no) {
153  page_id_t page_id(dict_index_get_space(m_index), page_no);
155  m_block = buf_page_get(page_id, page_size, RW_X_LATCH, m_mtr);
156  return (m_block);
157  }
158 
159  /** Load the first page using given mini-transaction. The first page must
160  already be x-latched by the m_mtr.
161  @param[in] mtr the mini-transaction in which first page is to be loaded.
162  @return the buffer block of first page. */
163  buf_block_t *load_x(mtr_t *mtr) const {
166  RW_X_LATCH, mtr);
167  ut_ad(tmp == m_block);
168  return (tmp);
169  }
170 
171  /** Load the first page of the compressed LOB with x-latch.
172  @param[in] page_id the page identifier of first page
173  @param[in] page_size the page size information of table.
174  @return buffer block of the first page. */
175  buf_block_t *load_x(const page_id_t &page_id, const page_size_t &page_size);
176 
177  /** Load the given page number as the first page in s-latch mode.
178  @param[in] page_no the first page number.
179  @return the buffer block of the given page number. */
180  buf_block_t *load_s(page_no_t page_no) {
181  ut_ad(m_block == nullptr);
182 
183  page_id_t page_id(dict_index_get_space(m_index), page_no);
185  m_block = buf_page_get(page_id, page_size, RW_S_LATCH, m_mtr);
186  return (m_block);
187  }
188 
189  /** Deallocate the first page of a compressed LOB. */
190  void dealloc();
191 
192  /** Set the FIL_PAGE_NEXT to FIL_NULL. */
194 
195  /** Set the FIL_PAGE_PREV to FIL_NULL. */
197 
198  /** Set the FIL_PAGE_NEXT to the given value.
199  @param[in] page_no the page number to set in FIL_PAGE_NEXT.
200  @param[in] mtr mini trx to be used for this modification. */
201  void set_next_page_no(page_no_t page_no, mtr_t *mtr) {
202  ut_ad(mtr != nullptr);
203  mlog_write_ulint(frame() + FIL_PAGE_NEXT, page_no, MLOG_4BYTES, mtr);
204  }
205 
206  /** Set the FIL_PAGE_PREV to the given value.
207  @param[in] page_no the page number to set in FIL_PAGE_PREV.
208  @param[in] mtr mini trx to be used for this modification. */
209  void set_prev_page_no(page_no_t page_no, mtr_t *mtr) {
210  ut_ad(mtr != nullptr);
212  }
213 
214  /** Write the space identifier to the page header, without generating
215  redo log records.
216  @param[in] space_id the space identifier. */
217  void set_space_id_no_redo(space_id_t space_id) {
219  nullptr);
220  }
221 
222  void init() {
223  ut_ad(m_mtr != nullptr);
224 
225  set_page_type();
226  set_version_0();
227  set_data_len(0);
230  set_trx_id(0);
231  flst_base_node_t *flst = free_list();
232  flst_init(flst, m_mtr);
233  flst_base_node_t *ilst = index_list();
234  flst_init(ilst, m_mtr);
235  flst_base_node_t *free_frag_lst = free_frag_list();
236  flst_init(free_frag_lst, m_mtr);
237  flst_base_node_t *frag_lst = frag_list();
238  flst_init(frag_lst, m_mtr);
243  }
244 
245  /** Get the amount of zlob data stored in this page. */
246  ulint get_data_len() const {
247  return (mach_read_from_4(frame() + OFFSET_DATA_LEN));
248  }
249 
250  /** Get the page number. */
251  page_no_t get_page_no() const { return (m_block->page.id.page_no()); }
252 
253  /** Get the page id of the first page of compressed LOB.
254  @return page id of the first page of compressed LOB. */
255  page_id_t get_page_id() const {
256  ut_ad(m_block != nullptr);
257 
258  return (m_block->page.id);
259  }
260 
261  fil_addr_t get_self_addr() const {
262  page_no_t page_no = get_page_no();
263  uint32_t offset = static_cast<uint32_t>(begin_data());
264  return (fil_addr_t(page_no, offset));
265  }
266 
267  /** All the index pages are singled linked with each other, and
268  the first page contains the link to one index page.
269  @param[in] page_no the page number of an index page. */
270  void set_index_page_no(page_no_t page_no) {
271  ut_ad(m_mtr != nullptr);
273  m_mtr);
274  }
275 
276  /** All the index pages are singled linked with each other, and
277  the first page contains the link to one index page. Get that index
278  page number.
279  @return the index page number. */
280  page_no_t get_index_page_no() const {
282  }
283 
284  /** All the fragment pages are doubly linked with each other, and
285  the first page contains the link to one fragment page in FIL_PAGE_PREV. Get
286  that frag page number.
287  @return the frag page number. */
288  page_no_t get_frag_page_no() const { return (m_block->get_prev_page_no()); }
289 
290  /** All the fragment pages are doubly linked with each other, and
291  the first page contains the link to one fragment page in FIL_PAGE_PREV. Get
292  that frag page number.
293  @param[in] mtr Mini-transaction to use for this read operation.
294  @return the frag page number. */
295  page_no_t get_frag_page_no(mtr_t *mtr) const {
296  return (mtr_read_ulint(frame() + FIL_PAGE_PREV, MLOG_4BYTES, mtr));
297  }
298 
299 #ifdef UNIV_DEBUG
300  /** Verify that the page number pointed to by FIL_PAGE_PREV of the first page
301  of LOB is indeed a fragment page. It uses its own mtr internally.
302  @return true if it is a fragment page, false otherwise. */
304 #endif /* UNIV_DEBUG */
305 
306  /** All the fragment pages are doubly linked with each other, and
307  the first page contains the link to one fragment page in FIL_PAGE_PREV.
308  @param[in] mtr Mini-transaction for this modification.
309  @param[in] page_no The page number of a fragment page. */
310  void set_frag_page_no(mtr_t *mtr, page_no_t page_no) {
312  set_prev_page_no(page_no, mtr);
313  }
314 
315  /** All the fragment pages are doubly linked with each other, and
316  the first page contains the link to one fragment page in FIL_PAGE_PREV.
317  @param[in] page_no the page number of a fragment page. */
318  void set_frag_page_no(page_no_t page_no) {
320  set_prev_page_no(page_no, m_mtr);
321  }
322 
323  /** All the frag node pages are singled linked with each other, and
324  the first page contains the link to one frag node page.
325  @param[in] page_no the page number of an frag node page. */
326  void set_frag_node_page_no(page_no_t page_no) {
327  ut_ad(m_mtr != nullptr);
329  m_mtr);
330  }
331 
332  /** Free all the z_frag_page_t pages. All the z_frag_page_t pages are
333  singly linked to each other. The head of the list is maintained in the
334  first page.
335  @return the number of pages freed. */
337 
338  /** Free all the index pages.
339  @return the number of pages freed. */
340  size_t free_all_index_pages();
341 
342  /** Free all the fragment pages.
343  @return the number of pages freed. */
344  size_t free_all_frag_pages();
345 
346  private:
347  /** Free all the fragment pages when the next page of the first LOB page IS
348  * NOT USED to link the fragment pages.
349  @return the number of pages freed. */
350  size_t free_all_frag_pages_old();
351 
352  /** Free all the fragment pages when the next page of the first LOB page IS
353  * USED to link the fragment pages.
354  @return the number of pages freed. */
355  size_t free_all_frag_pages_new();
356 
357  public:
358  /** Free all the data pages.
359  @return the number of pages freed. */
360  size_t free_all_data_pages();
361 
362  /** All the frag node pages are singled linked with each other, and the
363  first page contains the link to one frag node page. Get that frag node
364  page number.
365  @return the index page number. */
368  }
369 
370  /** Set the page type to FIL_PAGE_TYPE_UNKNOWN. This is done while
371  deallocating this page. */
372  void set_page_type_unknown() {
373  ut_ad(m_mtr != nullptr);
375  MLOG_2BYTES, m_mtr);
376  }
377 
378  void set_page_type() {
379  ut_ad(m_mtr != nullptr);
381  MLOG_2BYTES, m_mtr);
382  }
383 
384  void set_data_len(ulint len) {
385  ut_ad(m_mtr != nullptr);
387  }
388 
389  /** Update the trx id in the header.
390  @param[in] tid the given transaction identifier. */
391  void set_trx_id(trx_id_t tid) {
392  byte *ptr = frame() + OFFSET_TRX_ID;
393  mach_write_to_6(ptr, tid);
394  mlog_log_string(ptr, 6, m_mtr);
395  }
396 
397  /** Update the trx id in the header, without generating redo
398  log records.
399  @param[in] tid the given transaction identifier. */
400  void set_trx_id_no_redo(trx_id_t tid) {
401  byte *ptr = frame() + OFFSET_TRX_ID;
402  mach_write_to_6(ptr, tid);
403  }
404 
405  /** Initialize the LOB version to 1. */
406  void init_lob_version() {
407  ut_ad(m_mtr != nullptr);
408 
410  }
411 
412  /** Get the LOB version
413  @return the LOB version. */
414  uint32_t get_lob_version() {
416  }
417 
418  /** Increment LOB version by 1. */
419  uint32_t incr_lob_version();
420 
421  /** Get one byte of flags
422  @return one byte of flags. */
423  uint8_t get_flags() { return (mach_read_from_1(frame() + OFFSET_FLAGS)); }
424 
425  /** When the bit is set, the LOB is not partially updatable anymore.
426  @return true, if partially updatable.
427  @return false, if partially NOT updatable. */
428  bool can_be_partially_updated() {
429  uint8_t flags = get_flags();
430  return (!(flags & 0x01));
431  }
432 
433  /** When the bit is set, the LOB is not partially updatable anymore.
434  Enable the bit.
435  @param[in] trx the current transaction.*/
437 
438  void set_last_trx_id(trx_id_t tid) {
439  byte *ptr = frame() + OFFSET_LAST_TRX_ID;
440  mach_write_to_6(ptr, tid);
441  mlog_log_string(ptr, 6, m_mtr);
442  }
443 
444  /** Update the last transaction identifier in the header, without
445  generating redo logs.
446  @param[in] tid given transaction identifier.*/
448  byte *ptr = frame() + OFFSET_LAST_TRX_ID;
449  mach_write_to_6(ptr, tid);
450  }
451 
452  void set_last_trx_undo_no(undo_no_t undo_no) {
453  ut_ad(m_mtr != nullptr);
454 
455  byte *ptr = frame() + OFFSET_LAST_UNDO_NO;
456  mlog_write_ulint(ptr, undo_no, MLOG_4BYTES, m_mtr);
457  }
458 
459  trx_id_t get_last_trx_id() const {
460  byte *ptr = frame() + OFFSET_LAST_TRX_ID;
461  return (mach_read_from_6(ptr));
462  }
463 
465  byte *ptr = frame() + OFFSET_LAST_UNDO_NO;
466  return (mach_read_from_4(ptr));
467  }
468 
469  flst_base_node_t *free_list() const { return (frame() + OFFSET_FREE_LIST); }
470 
472 
474  return (frame() + OFFSET_FREE_FRAG_LIST);
475  }
476 
477  flst_base_node_t *frag_list() const { return (frame() + OFFSET_FRAG_LIST); }
478 
479  void init_frag_entries() {
480  flst_base_node_t *free_frag_lst = free_frag_list();
481  ulint n = get_n_frag_entries();
482  for (ulint i = 0; i < n; ++i) {
483  flst_node_t *ptr = frame() + begin_frag_entries();
484  ptr += (i * z_frag_entry_t::SIZE);
485  z_frag_entry_t frag_entry(ptr, m_mtr);
486  frag_entry.init();
487  frag_entry.push_back(free_frag_lst);
488  }
489  }
490 
491  void init_index_entries();
492 
493  /** Allocate a fragment of the given size. This involves finding a
494  fragment page, that has space to store len bytes of data. If necessary,
495  allocate a new fragment page.
496  @param[in] bulk true if it is bulk operation
497  (OPCODE_INSERT_BULK), false otherwise.
498  @param[in] len length of data to be stored in
499  fragment page.
500  @param[out] frag_page the fragment page with the needed
501  free space.
502  @param[out] entry fragment page entry representing frag_page.
503  @return fragment identifier within the fragment page.
504  @return FRAG_ID_NULL if fragment could not be allocated. */
505  frag_id_t alloc_fragment(bool bulk, ulint len, z_frag_page_t &frag_page,
507 
508  /** Allocate one index entry. If there is no free index entry,
509  allocate an index page (a page full of z_index_entry_t objects)
510  and service the request.
511  @return the allocated index entry. */
513 
514  /** Allocate one frag page entry. If there is no free frag
515  entry, allocate an frag node page (a page full of z_frag_entry_t
516  objects) and service the request.
517  @return the allocated frag entry. */
518  z_frag_entry_t alloc_frag_entry(bool bulk);
519 
520  /** Print the index entries. */
521  std::ostream &print_index_entries(std::ostream &out) const;
522 
523  /** Print the index entries. */
524  std::ostream &print_frag_entries(std::ostream &out) const;
525 
526  /** Print the page. */
527  std::ostream &print(std::ostream &out) const;
528 
529  byte *frame() const { return (buf_block_get_frame(m_block)); }
530 
531  /** Load the page, in x-latch mode, containing the given file address.
532  @param[in] addr given file address
533  @return the file list node pointer. */
534  flst_node_t *addr2ptr_x(fil_addr_t &addr) const {
535  return (addr2ptr_x(addr, m_mtr));
536  }
537 
538  /** Load the page, in x-latch mode, containing the given file address.
539  @param[in] addr given file address
540  @param[in] mtr the mini-transaction context to be used.
541  @return the file list node pointer. */
542  flst_node_t *addr2ptr_x(fil_addr_t &addr, mtr_t *mtr) const {
544  const page_size_t page_size = dict_table_page_size(m_index->table);
545  return (fut_get_ptr(space, page_size, addr, RW_X_LATCH, mtr));
546  }
547 
548  /** Load the page, in s-latch mode, containing the given file address.
549  @param[in] addr given file address
550  @return the file list node pointer. */
553  const page_size_t page_size = dict_table_page_size(m_index->table);
554  return (fut_get_ptr(space, page_size, addr, RW_S_LATCH, m_mtr));
555  }
556 
557  /** Load the entry available in the given file address.
558  @param[in] addr file address
559  @param[out] entry the entry to be loaded.*/
560  void load_entry_s(fil_addr_t &addr, z_index_entry_t &entry);
561 
562  /** Load the entry available in the given file address.
563  @param[in] addr file address
564  @param[out] entry the entry to be loaded.*/
565  void load_entry_x(fil_addr_t &addr, z_index_entry_t &entry);
566 
567  /** Free all the pages of the zlob.
568  @return the total number of pages freed. */
569  size_t destroy();
570 
571 #ifdef UNIV_DEBUG
572  private:
573  /** Validate the LOB. This is a costly function. We need to avoid using
574  this directly, instead call z_first_page_t::validate().
575  @return true if valid, false otherwise. */
576  bool validate_low();
577 
578  public:
579  /** Validate the LOB.
580  @return true if valid, false otherwise. */
581  bool validate() {
582  static const uint32_t FREQ = 50;
583  static std::atomic<uint32_t> n{0};
584 
585  bool valid = true;
586  if (++n % FREQ == 0) {
587  valid = validate_low();
588  }
589  return (valid);
590  }
591 #endif /* UNIV_DEBUG */
592 
593  /** Get the buffer block of the first page of LOB.
594  @return the buffer block of the first page of LOB. */
595  buf_block_t *get_block() const { return (m_block); }
596 
597  public:
598  void set_mtr(mtr_t *mtr) { m_mtr = mtr; }
599 
600  /** Restart the given mtr. The first page must already be x-latched by the
601  m_mtr.
602  @param[in] mtr the mini-transaction context which is to be restarted. */
603  void restart_mtr(mtr_t *mtr) {
604  ut_ad(mtr != m_mtr);
605 
606  mtr_commit(mtr);
607  mtr_start(mtr);
609  load_x(mtr);
610  }
611 
612  private:
613  /** The buffer block of the first page. */
615 
616  /** The mini-transaction context. */
617  mtr_t *m_mtr;
618 
619  /** The index dictionary object. */
621 
622 }; // struct z_first_page_t
623 
624 /** Overloading the global output parameter to print object of type
625 z_first_page_t into the given output stream.
626 @param[in,out] out output stream.
627 @param[in] obj object to be printed.
628 @return the output stream. */
629 inline std::ostream &operator<<(std::ostream &out, const z_first_page_t &obj) {
630  return (obj.print(out));
631 }
632 
633 } /* namespace lob */
634 
635 #endif /* zlob0first_h */
page_no_t
uint32 page_no_t
Page number.
Definition: api0api.h:57
FIL_PAGE_DATA
constexpr ulint FIL_PAGE_DATA
start of the data on the page
Definition: fil0types.h:110
lob::z_first_page_t::set_trx_id
void set_trx_id(trx_id_t tid)
Update the trx id in the header.
Definition: zlob0first.h:439
lob::z_first_page_t::init_index_entries
void init_index_entries()
Definition: zlob0first.cc:417
lob::z_first_page_t::set_prev_page_no
void set_prev_page_no(page_no_t page_no, mtr_t *mtr)
Set the FIL_PAGE_PREV to the given value.
Definition: zlob0first.h:257
lob::z_first_page_t::get_block
buf_block_t * get_block() const
Get the buffer block of the first page of LOB.
Definition: zlob0first.h:643
lob::z_first_page_t::get_n_frag_entries
ulint get_n_frag_entries() const
Given the page size, what is the number of frag entries the first page can contain.
Definition: zlob0first.cc:88
FIL_PAGE_PREV
#define FIL_PAGE_PREV
if there is a 'natural' predecessor of the page, its offset.
Definition: fil0types.h:50
undo_no_t
ib_id_t undo_no_t
Undo number.
Definition: trx0types.h:148
lob::z_first_page_t::frame
byte * frame() const
Definition: zlob0first.h:577
lob::z_first_page_t::free_frag_list
flst_base_node_t * free_frag_list() const
Definition: zlob0first.h:521
lob::frag_id_t
ulint frag_id_t
Definition: lob0impl.h:512
lob::z_first_page_t::addr2ptr_x
flst_node_t * addr2ptr_x(fil_addr_t &addr) const
Load the page, in x-latch mode, containing the given file address.
Definition: zlob0first.h:582
mtr_read_ulint
#define mtr_read_ulint(p, t, m)
Read 1 - 4 bytes from a file page buffered in the buffer pool.
Definition: mtr0mtr.h:87
lob::z_first_page_t::set_next_page_no
void set_next_page_no(page_no_t page_no, mtr_t *mtr)
Set the FIL_PAGE_NEXT to the given value.
Definition: zlob0first.h:249
lob::z_first_page_t::begin_data
ulint begin_data() const
Definition: zlob0first.h:150
trx_id_t
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:144
lob::z_frag_entry_t::SIZE
static const ulint SIZE
Total size of one frag entry.
Definition: lob0impl.h:601
lob::z_first_page_t::free_all_frag_pages_old
size_t free_all_frag_pages_old()
Free all the fragment pages when the next page of the first LOB page IS NOT USED to link the fragment...
Definition: zlob0first.cc:597
lob::z_first_page_t::init_frag_entries
void init_frag_entries()
Definition: zlob0first.h:527
lob::z_first_page_t::OFFSET_LAST_TRX_ID
static const ulint OFFSET_LAST_TRX_ID
The last transaction that modified this LOB.
Definition: zlob0first.h:97
flst_init
UNIV_INLINE void flst_init(flst_base_node_t *base, mtr_t *mtr)
Initializes a list base node.
lob::z_first_page_t::set_next_page_null
void set_next_page_null()
Set the FIL_PAGE_NEXT to FIL_NULL.
Definition: zlob0first.h:241
lob::z_first_page_t::is_empty
bool is_empty() const
Definition: zlob0first.h:154
ut_ad
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:66
lob::z_first_page_t::OFFSET_LOB_VERSION
static const uint32_t OFFSET_LOB_VERSION
LOB version.
Definition: zlob0first.h:94
nullptr
Dialog Client Authentication nullptr
Definition: dialog.cc:353
dict_index_get_space
UNIV_INLINE space_id_t dict_index_get_space(const dict_index_t *index)
Gets the space id of the root of the index tree.
dict_index_t
Data structure for an index.
Definition: dict0mem.h:879
lob::z_first_page_t::restart_mtr
void restart_mtr(mtr_t *mtr)
Restart the given mtr.
Definition: zlob0first.h:651
mtr_t
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:169
lob::z_first_page_t::load_x
buf_block_t * load_x(page_no_t page_no)
Load the given page number as the first page in x-latch mode.
Definition: zlob0first.h:200
lob::z_first_page_t::free_all_frag_pages_new
size_t free_all_frag_pages_new()
Free all the fragment pages when the next page of the first LOB page IS USED to link the fragment pag...
Definition: zlob0first.cc:658
lob::z_first_page_t::frag_list
flst_base_node_t * frag_list() const
Definition: zlob0first.h:525
lob::z_first_page_t::destroy
size_t destroy()
Free all the pages of the zlob.
Definition: zlob0first.cc:682
flst_base_node_t
byte flst_base_node_t
Definition: fut0lst.h:45
lob::z_first_page_t::m_mtr
mtr_t * m_mtr
The mini-transaction context.
Definition: zlob0first.h:665
flst_node_t
byte flst_node_t
Definition: fut0lst.h:46
mach_read_from_1
UNIV_INLINE uint8_t mach_read_from_1(const byte *b)
The following function is used to fetch data from one byte.
lob::z_first_page_t::set_last_trx_undo_no
void set_last_trx_undo_no(undo_no_t undo_no)
Definition: zlob0first.h:500
lob::z_first_page_t::get_data_len
ulint get_data_len() const
Get the amount of zlob data stored in this page.
Definition: zlob0first.h:294
lob::z_first_page_t::get_flags
uint8_t get_flags()
Get one byte of flags.
Definition: zlob0first.h:471
lob::z_first_page_t::OFFSET_LAST_UNDO_NO
static const ulint OFFSET_LAST_UNDO_NO
The last transaction that modified this LOB.
Definition: zlob0first.h:100
FLST_BASE_NODE_SIZE
constexpr ulint FLST_BASE_NODE_SIZE
Definition: fut0lst.h:49
lob::z_first_page_t::set_frag_node_page_no
void set_frag_node_page_no(page_no_t page_no)
All the frag node pages are singled linked with each other, and the first page contains the link to o...
Definition: zlob0first.h:374
MLOG_1BYTE
@ MLOG_1BYTE
one byte is written
Definition: mtr0types.h:69
lob::z_first_page_t::OFFSET_INDEX_LIST
static const ulint OFFSET_INDEX_LIST
List of index entries.
Definition: zlob0first.h:118
lob::z_first_page_t::set_prev_page_null
void set_prev_page_null()
Set the FIL_PAGE_PREV to FIL_NULL.
Definition: zlob0first.h:244
lob::z_first_page_t::get_index_page_no
page_no_t get_index_page_no() const
All the index pages are singled linked with each other, and the first page contains the link to one i...
Definition: zlob0first.h:328
page_size_t::physical
size_t physical() const
Retrieve the physical page size (on-disk).
Definition: page0size.h:120
MLOG_4BYTES
@ MLOG_4BYTES
4 bytes ...
Definition: mtr0types.h:75
lob::z_frag_entry_t
An entry representing one fragment page.
Definition: lob0impl.h:577
buf_block_t
The buffer control block structure.
Definition: buf0buf.h:1544
mach_read_from_2
UNIV_INLINE uint16_t mach_read_from_2(const byte *b)
The following function is used to fetch data from 2 consecutive bytes.
lob::z_first_page_t::get_self_addr
fil_addr_t get_self_addr() const
Definition: zlob0first.h:309
lob::z_first_page_t::set_index_page_no
void set_index_page_no(page_no_t page_no)
All the index pages are singled linked with each other, and the first page contains the link to one i...
Definition: zlob0first.h:318
buf_page_get
#define buf_page_get(ID, SIZE, LA, MTR)
NOTE! The following macros should be used instead of buf_page_get_gen, to improve debugging.
Definition: buf0buf.h:363
FIL_PAGE_DATA_END
constexpr ulint FIL_PAGE_DATA_END
size of the page trailer
Definition: fil0types.h:118
FIL_PAGE_TYPE_ZLOB_FIRST
constexpr page_type_t FIL_PAGE_TYPE_ZLOB_FIRST
The first page of a compressed LOB.
Definition: fil0fil.h:1286
lob::z_first_page_t::set_data_len
void set_data_len(ulint len)
Definition: zlob0first.h:432
lob::z_first_page_t::z_first_page_t
z_first_page_t()
Definition: zlob0first.h:179
lob::z_first_page_t::alloc_frag_entry
z_frag_entry_t alloc_frag_entry(bool bulk)
Allocate one frag page entry.
Definition: zlob0first.cc:216
lob::z_first_page_t::free_all_frag_node_pages
size_t free_all_frag_node_pages()
Free all the z_frag_page_t pages.
Definition: zlob0first.cc:360
n
int n
Definition: xcom_base.cc:445
lob::z_first_page_t::get_n_index_entries
ulint get_n_index_entries() const
Given the page size, what is the number of index entries the first page can contain.
Definition: zlob0first.cc:60
mlog_log_string
void mlog_log_string(byte *ptr, ulint len, mtr_t *mtr)
Logs a write of a string to a file page buffered in the buffer pool.
Definition: mtr0log.cc:333
lob::z_first_page_t::OFFSET_FRAG_NODES_PAGE_NO
static const ulint OFFSET_FRAG_NODES_PAGE_NO
The next frag nodes page.
Definition: zlob0first.h:112
FIL_PAGE_SPACE_ID
#define FIL_PAGE_SPACE_ID
alias for space id
Definition: fil0types.h:107
lob::operator<<
std::ostream & operator<<(std::ostream &out, const plist_node_t &obj)
Definition: lob0impl.h:262
lob::z_first_page_t::free_all_index_pages
size_t free_all_index_pages()
Free all the index pages.
Definition: zlob0first.cc:389
lob::z_first_page_t::m_index
dict_index_t * m_index
The index dictionary object.
Definition: zlob0first.h:668
buf_block_t::get_prev_page_no
page_no_t get_prev_page_no() const
Get the prev page number of the current buffer block.
Definition: buf0buf.h:1720
MLOG_2BYTES
@ MLOG_2BYTES
2 bytes ...
Definition: mtr0types.h:72
lob::z_first_page_t::OFFSET_FLAGS
static const ulint OFFSET_FLAGS
One byte of flag bits.
Definition: zlob0first.h:91
lob::z_first_page_t::set_trx_id_no_redo
void set_trx_id_no_redo(trx_id_t tid)
Update the trx id in the header, without generating redo log records.
Definition: zlob0first.h:448
lob::z_first_page_t::OFFSET_FREE_LIST
static const ulint OFFSET_FREE_LIST
List of free index entries.
Definition: zlob0first.h:115
lob::z_first_page_t::set_page_type_unknown
void set_page_type_unknown()
Set the page type to FIL_PAGE_TYPE_UNKNOWN.
Definition: zlob0first.h:420
mtr_start
#define mtr_start(m)
Start a mini-transaction.
Definition: mtr0mtr.h:50
RW_S_LATCH
@ RW_S_LATCH
Definition: sync0rw.h:136
mach_write_to_6
UNIV_INLINE void mach_write_to_6(byte *b, ib_uint64_t id)
The following function is used to store data in 6 consecutive bytes.
lob::z_first_page_t::get_page_type
page_type_t get_page_type() const
Definition: zlob0first.h:193
mlog_write_ulint
void mlog_write_ulint(byte *ptr, ulint val, mlog_id_t type, mtr_t *mtr)
Writes 1, 2 or 4 bytes to a file page.
Definition: mtr0log.cc:247
lob::z_frag_page_t
The fragment page.
Definition: lob0impl.h:1372
page_size_t
Page size descriptor.
Definition: page0size.h:49
buf_block_t::page
buf_page_t page
page information; this must be the first field, so that buf_pool->page_hash can point to buf_page_t o...
Definition: buf0buf.h:1550
lob::z_first_page_t::dealloc
void dealloc()
Deallocate the first page of a compressed LOB.
Definition: zlob0first.cc:438
lob::z_first_page_t::alloc_fragment
frag_id_t alloc_fragment(bool bulk, ulint len, z_frag_page_t &frag_page, z_frag_entry_t &entry)
Allocate a fragment of the given size.
Definition: zlob0first.cc:239
mtr_t::set_log_mode
mtr_log_t set_log_mode(mtr_log_t mode)
Change the logging mode.
Definition: mtr0mtr.cc:422
mach_read_from_4
UNIV_INLINE uint32_t mach_read_from_4(const byte *b)
The following function is used to fetch data from 4 consecutive bytes.
lob::z_first_page_t::init_lob_version
void init_lob_version()
Initialize the LOB version to 1.
Definition: zlob0first.h:454
dict_index_t::get_page_size
page_size_t get_page_size() const
Get the page size of the tablespace to which this index belongs.
Definition: dict0mem.cc:833
lob::z_first_page_t::size_of_frag_entries
ulint size_of_frag_entries() const
Definition: zlob0first.h:142
lob::z_first_page_t::OFFSET_INDEX_PAGE_NO
static const ulint OFFSET_INDEX_PAGE_NO
The next index page.
Definition: zlob0first.h:109
RW_X_LATCH
@ RW_X_LATCH
Definition: sync0rw.h:137
lob::z_first_page_t::verify_frag_page_no
bool verify_frag_page_no()
Verify that the page number pointed to by FIL_PAGE_PREV of the first page of LOB is indeed a fragment...
Definition: zlob0first.cc:694
lob::z_first_page_t::get_last_trx_undo_no
undo_no_t get_last_trx_undo_no() const
Definition: zlob0first.h:512
lob::z_first_page_t::print_frag_entries
std::ostream & print_frag_entries(std::ostream &out) const
Print the index entries.
Definition: zlob0first.cc:168
lob::z_first_page_t::OFFSET_VERSION
static const ulint OFFSET_VERSION
Version information.
Definition: zlob0first.h:87
mach_read_from_6
UNIV_INLINE ib_uint64_t mach_read_from_6(const byte *b)
The following function is used to fetch data from 6 consecutive bytes.
lob::z_first_page_t::begin_frag_entries
ulint begin_frag_entries() const
Definition: zlob0first.h:146
lob::z_first_page_t::validate
bool validate()
Validate the LOB.
Definition: zlob0first.h:629
lob::z_first_page_t::OFFSET_DATA_LEN
static const ulint OFFSET_DATA_LEN
The length of compressed data stored in this page.
Definition: zlob0first.h:103
mtr_commit
#define mtr_commit(m)
Commit a mini-transaction.
Definition: mtr0mtr.h:59
lob::z_first_page_t::get_frag_node_page_no
page_no_t get_frag_node_page_no()
All the frag node pages are singled linked with each other, and the first page contains the link to o...
Definition: zlob0first.h:414
lob::z_first_page_t::get_index_list_length
ulint get_index_list_length() const
Get the length of the index list.
Definition: zlob0first.h:161
lob::z_first_page_t::get_page_id
page_id_t get_page_id() const
Get the page id of the first page of compressed LOB.
Definition: zlob0first.h:303
dict_table_page_size
UNIV_INLINE const page_size_t dict_table_page_size(const dict_table_t *table)
Get the table page size.
FIL_PAGE_TYPE_UNKNOWN
constexpr page_type_t FIL_PAGE_TYPE_UNKNOWN
In old tablespaces, garbage in FIL_PAGE_TYPE is replaced with this value when flushing pages.
Definition: fil0fil.h:1250
FIL_PAGE_TYPE
#define FIL_PAGE_TYPE
file page type: FIL_PAGE_INDEX,..., 2 bytes.
Definition: fil0types.h:75
lob::z_first_page_t::incr_lob_version
uint32_t incr_lob_version()
Increment LOB version by 1.
Definition: zlob0first.cc:468
lob::z_first_page_t::index_list
flst_base_node_t * index_list() const
Definition: zlob0first.h:519
mtr_memo_contains
#define mtr_memo_contains(m, o, t)
Check if memo contains the given item.
Definition: mtr0mtr.h:107
lob::z_first_page_t::set_version_0
void set_version_0()
Definition: zlob0first.h:166
lob::z_first_page_t::get_page_no
page_no_t get_page_no() const
Get the page number.
Definition: zlob0first.h:299
fut_get_ptr
UNIV_INLINE byte * fut_get_ptr(space_id_t space, const page_size_t &page_size, fil_addr_t addr, rw_lock_type_t rw_latch, mtr_t *mtr, buf_block_t **ptr_block=nullptr)
Gets a pointer to a file address and latches the page.
lob::z_first_page_t::get_frag_page_no
page_no_t get_frag_page_no() const
All the fragment pages are doubly linked with each other, and the first page contains the link to one...
Definition: zlob0first.h:336
lob::z_first_page_t::alloc
buf_block_t * alloc(bool bulk)
Definition: zlob0first.cc:113
lob::z_first_page_t::begin_data_ptr
byte * begin_data_ptr() const
Definition: zlob0first.h:170
lob::z_first_page_t::m_block
buf_block_t * m_block
The buffer block of the first page.
Definition: zlob0first.h:662
FIL_PAGE_NEXT
#define FIL_PAGE_NEXT
if there is a 'natural' successor of the page, its offset.
Definition: fil0types.h:60
page_id_t
Page identifier.
Definition: buf0types.h:168
_entry
Definition: completion_hash.h:34
page_type_t
uint16_t page_type_t
Definition: fil0fil.h:1199
lob::z_first_page_t::set_mtr
void set_mtr(mtr_t *mtr)
Definition: zlob0first.h:646
lob0impl.h
dict_index_t::table
dict_table_t * table
back pointer to table
Definition: dict0mem.h:884
lob::z_first_page_t::OFFSET_INDEX_BEGIN
static const ulint OFFSET_INDEX_BEGIN
Begin of index entries.
Definition: zlob0first.h:129
lob::z_first_page_t::init
void init()
Definition: zlob0first.h:270
lob::z_first_page_t::set_frag_page_no
void set_frag_page_no(mtr_t *mtr, page_no_t page_no)
All the fragment pages are doubly linked with each other, and the first page contains the link to one...
Definition: zlob0first.h:358
lob::z_first_page_t::load_s
buf_block_t * load_s(page_no_t page_no)
Load the given page number as the first page in s-latch mode.
Definition: zlob0first.h:228
flst_get_len
UNIV_INLINE ulint flst_get_len(const flst_base_node_t *base)
Get the length of a list.
lob::z_first_page_t::size_of_index_entries
ulint size_of_index_entries() const
Definition: zlob0first.cc:413
lob::z_first_page_t::free_all_data_pages
size_t free_all_data_pages()
Free all the data pages.
Definition: zlob0first.cc:499
lob::z_first_page_t::get_lob_version
uint32_t get_lob_version()
Get the LOB version.
Definition: zlob0first.h:462
lob::z_first_page_t::validate_low
bool validate_low()
Validate the LOB.
Definition: zlob0first.cc:540
buf_block_get_frame
UNIV_INLINE buf_frame_t * buf_block_get_frame(const buf_block_t *block)
Gets a pointer to the memory frame of a block.
lob::z_first_page_t::set_last_trx_id
void set_last_trx_id(trx_id_t tid)
Definition: zlob0first.h:486
FIL_NULL
constexpr page_no_t FIL_NULL
'null' (undefined) page offset in the context of file spaces
Definition: fil0fil.h:1137
lob::z_first_page_t::OFFSET_FRAG_LIST
static const ulint OFFSET_FRAG_LIST
List of frag entries.
Definition: zlob0first.h:125
fut0lst.h
lob::z_first_page_t::free_list
flst_base_node_t * free_list() const
Definition: zlob0first.h:517
lob::z_first_page_t::free_all_frag_pages
size_t free_all_frag_pages()
Free all the fragment pages.
Definition: zlob0first.cc:648
lob::z_first_page_t::load_entry_s
void load_entry_s(fil_addr_t &addr, z_index_entry_t &entry)
Load the entry available in the given file address.
Definition: zlob0first.cc:429
space_id_t
uint32 space_id_t
Tablespace identifier.
Definition: api0api.h:59
lob::z_first_page_t::print_index_entries
std::ostream & print_index_entries(std::ostream &out) const
Print the index entries.
Definition: zlob0first.cc:130
lob::z_first_page_t::set_last_trx_id_no_redo
void set_last_trx_id_no_redo(trx_id_t tid)
Update the last transaction identifier in the header, without generating redo logs.
Definition: zlob0first.h:495
lob::z_first_page_t::set_page_type
void set_page_type()
Definition: zlob0first.h:426
lob::z_first_page_t::alloc_index_entry
z_index_entry_t alloc_index_entry(bool bulk)
Allocate one index entry.
Definition: zlob0first.cc:191
fil0types.h
lob::z_first_page_t::payload
ulint payload()
Amount of zlob data that can be stored in first page (in bytes).
Definition: zlob0first.h:173
lob::z_first_page_t::mark_cannot_be_partially_updated
void mark_cannot_be_partially_updated(trx_t *trx)
When the bit is set, the LOB is not partially updatable anymore.
Definition: zlob0first.cc:481
lob::z_first_page_t::set_space_id_no_redo
void set_space_id_no_redo(space_id_t space_id)
Write the space identifier to the page header, without generating redo log records.
Definition: zlob0first.h:265
lob::z_first_page_t::OFFSET_TRX_ID
static const ulint OFFSET_TRX_ID
The transaction that created data in the data portion.
Definition: zlob0first.h:106
lob::z_first_page_t::print
std::ostream & print(std::ostream &out) const
Print the page.
Definition: zlob0first.cc:351
lob::z_first_page_t::get_last_trx_id
trx_id_t get_last_trx_id() const
Definition: zlob0first.h:507
lob::z_first_page_t::can_be_partially_updated
bool can_be_partially_updated()
When the bit is set, the LOB is not partially updatable anymore.
Definition: zlob0first.h:476
fil_addr_t
File space address.
Definition: fil0fil.h:1154
mtr_t::get_log_mode
mtr_log_t get_log_mode() const
Get the logging mode.
lob::z_first_page_t::load_entry_x
void load_entry_x(fil_addr_t &addr, z_index_entry_t &entry)
Load the entry available in the given file address.
Definition: zlob0first.cc:433
page_id_t::page_no
page_no_t page_no() const
Retrieve the page number.
Definition: buf0types.h:204
lob
Provides the large objects (LOB) module.
Definition: lob0del.h:31
MTR_MEMO_PAGE_X_FIX
@ MTR_MEMO_PAGE_X_FIX
Definition: mtr0types.h:261
lob::z_index_entry_t
An index entry pointing to one zlib stream.
Definition: zlob0index.h:110
lob::z_first_page_t::addr2ptr_s
flst_node_t * addr2ptr_s(fil_addr_t &addr)
Load the page, in s-latch mode, containing the given file address.
Definition: zlob0first.h:599
lob::z_first_page_t
The first page of an zlob.
Definition: zlob0first.h:61
lob::z_first_page_t::OFFSET_FREE_FRAG_LIST
static const ulint OFFSET_FREE_FRAG_LIST
List of free frag entries.
Definition: zlob0first.h:121
trx_t
Definition: trx0trx.h:836
buf_page_t::id
page_id_t id
Page id.
Definition: buf0buf.h:1401
flags
static int flags[50]
Definition: hp_test1.cc:39