| 1 |
/***************************************************************************** |
| 2 |
|
| 3 |
Copyright (c) 2016, 2026, 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 designed to work with certain software (including |
| 10 |
but not limited to OpenSSL) that is licensed under separate terms, |
| 11 |
as designated in a particular file or component or in included license |
| 12 |
documentation. The authors of MySQL hereby grant you an additional |
| 13 |
permission to link the program and your derivative works with the |
| 14 |
separately licensed software that they have either included with |
| 15 |
the program or referenced in the documentation. |
| 16 |
|
| 17 |
This program is distributed in the hope that it will be useful, but WITHOUT |
| 18 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 19 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, |
| 20 |
for more details. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License along with |
| 23 |
this program; if not, write to the Free Software Foundation, Inc., |
| 24 |
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 25 |
|
| 26 |
*****************************************************************************/ |
| 27 |
Prototype to design the WL#8960 - Partial fetch and update of LOB. |
| 28 |
|
| 29 |
Uncompressed LOB: |
| 30 |
================ |
| 31 |
|
| 32 |
There are 3 types of pages - data pages, index pages and the first page. The |
| 33 |
data pages contain the LOB data. The index pages contain the index entries. |
| 34 |
The first page is divided into two - the first half contains the index entries |
| 35 |
and the second half contains the LOB data. |
| 36 |
|
| 37 |
Each index entry defines one data page. It contains the following information: |
| 38 |
|
| 39 |
. the previous index entry (6 bytes) |
| 40 |
. the next index entry (6 bytes) |
| 41 |
. list of older versions (16 bytes) |
| 42 |
. the trx id that created this index entry (6 bytes) |
| 43 |
. the page number (4 bytes) |
| 44 |
. data length. (2 bytes) |
| 45 |
|
| 46 |
Total size of 1 index entry is 40 bytes. |
| 47 |
|
| 48 |
For 16K page size, here are some useful information about the first page: |
| 49 |
|
| 50 |
. The first page can contain 203 index entries. |
| 51 |
. The first page can contain 8148 bytes of LOB data. |
| 52 |
. The first page is sufficient for an LOB of 3MB size (3317716 bytes). |
| 53 |
|
| 54 |
For 16K page size, here are some useful information about an index page: |
| 55 |
|
| 56 |
. The index page can contain 408 index entries. |
| 57 |
. The index page can represent 6684672 bytes (6MB) of LOB data. |
| 58 |
. For 1GB of data we need 160 index pages. |
| 59 |
. For 4GB of data we need 640 index pages. |
| 60 |
|
| 61 |
So for a small LOB of about 9MB, we will have 1 first page and 1 index page. |
| 62 |
|
| 63 |
Reading the LOB: |
| 64 |
--------------- |
| 65 |
|
| 66 |
The header of first page contains the base node of the list of index entries. |
| 67 |
Traversing this list will give the latest version of the LOB. If any index |
| 68 |
entry is not to be seen by the reading trx, then its list of older version |
| 69 |
is checked to see if it can see any of them. If no older version is to be |
| 70 |
seen, the index entry is skipped. |
| 71 |
|
| 72 |
Modification: |
| 73 |
------------ |
| 74 |
|
| 75 |
There are 3 operations - replace (size does not change), insert middle at the |
| 76 |
given offset (size increases), remove middle at give offset (size decreases). |
| 77 |
All the 3 modifications do page level copy-on-write. If an existing page is |
| 78 |
to be modified, then a copy is created and their index entries are adjusted |
| 79 |
so that the new version is the latest version and the existing page becomes |
| 80 |
an older version. |
| 81 |
|
| 82 |
Rollback and Purge: |
| 83 |
------------------- |
| 84 |
|
| 85 |
Given a trxid, the list of modified pages is available from the index |
| 86 |
entries. For rollback and purge operation, the index entries can be |
| 87 |
traversed and the relevant index entries can be removed. |
| 88 |
|
| 89 |
Rolling back to savepoint: |
| 90 |
-------------------------- |
| 91 |
|
| 92 |
Each page contains the FIL_PAGE_LSN. If this is greater than the save point |
| 93 |
lsn then remove this page, otherwise retain it. |
| 94 |
|