MySQL 9.2.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
pack_rows Namespace Reference

Classes

struct  Column
 A class that represents a field, which also holds a cached value of the field's data type. More...
 
struct  Table
 This struct is primarily used for holding the extracted columns in a hash join or BKA join, or the input columns in a streaming aggregation operation. More...
 
class  TableCollection
 A structure that contains a list of input tables for a hash join operation, BKA join operation or a streaming aggregation operation, and some pre-computed properties for the tables. More...
 

Functions

static size_t CalculateColumnStorageSize (const Column &column)
 Calculate how many bytes the data in the column uses. More...
 
size_t ComputeRowSizeUpperBound (const TableCollection &tables)
 Similar to ComputeRowSizeUpperBoundSansBlobs, but will calculate blob size as well. More...
 
size_t ComputeRowSizeUpperBoundSansBlobs (const TableCollection &tables)
 Count up how many bytes a single row from the given tables will occupy, in "packed" format. More...
 
bool StoreFromTableBuffers (const TableCollection &tables, String *buffer)
 Take the data marked for reading in "tables" and store it in the provided buffer. More...
 
const ucharLoadIntoTableBuffers (const TableCollection &tables, const uchar *ptr)
 Take the data in "ptr" and put it back to the tables' record buffers. More...
 
bool ShouldCopyRowId (const TABLE *table)
 
ALWAYS_INLINE ucharStoreFromTableBuffersRaw (const TableCollection &tables, uchar *dptr)
 

Function Documentation

◆ CalculateColumnStorageSize()

static size_t pack_rows::CalculateColumnStorageSize ( const Column column)
static

Calculate how many bytes the data in the column uses.

We don't bother calculating the exact size for all types, since we consider reserving some extra bytes in buffers harmless. In particular, as long as the column is not of type BLOB, TEXT, JSON or GEOMETRY, we return an upper bound of the storage size. In the case of said types, we return the actual storage size; we do not want to return 4 gigabytes for a BLOB column if it only contains 10 bytes of data.

Parameters
columnthe column to calculate size for

◆ ComputeRowSizeUpperBound()

size_t pack_rows::ComputeRowSizeUpperBound ( const TableCollection tables)

Similar to ComputeRowSizeUpperBoundSansBlobs, but will calculate blob size as well.

To do this, we need to look at the data stored in the record buffers.

Note
{This means that the function cannot be called without making sure there is valid data in the table buffers.}

◆ ComputeRowSizeUpperBoundSansBlobs()

size_t pack_rows::ComputeRowSizeUpperBoundSansBlobs ( const TableCollection tables)

Count up how many bytes a single row from the given tables will occupy, in "packed" format.

Note that this is an upper bound, so the length after calling Field::pack may very well be shorter than the size returned by this function.

The value returned from this function will sum up 1) The row-id if that is to be kept. 2) Size of the NULL flags. This includes:

  • Space for a NULL flag per nullable column.
  • Space for a NULL flag per nullable table (tables on the inner side of an outer join). 3) Size of the buffer returned by pack() on all columns marked in the read_set_internal. We do not necessarily have valid data in the table buffers, so we do not try to calculate size for blobs.

◆ LoadIntoTableBuffers()

const uchar * pack_rows::LoadIntoTableBuffers ( const TableCollection tables,
const uchar ptr 
)

Take the data in "ptr" and put it back to the tables' record buffers.

The tables must be exactly the same as when the row was created. That is, it must contain the same tables in the same order, and the read set of each table must be identical when storing and restoring the row. If that's not the case, you will end up with undefined and unpredictable behavior.

Returns a pointer to where we ended reading.

◆ ShouldCopyRowId()

bool pack_rows::ShouldCopyRowId ( const TABLE table)
inline

◆ StoreFromTableBuffers()

bool pack_rows::StoreFromTableBuffers ( const TableCollection tables,
String buffer 
)

Take the data marked for reading in "tables" and store it in the provided buffer.

What data to store is determined by the read set of each table. Note that any existing data in "buffer" will be overwritten.

The output buffer will contain the following data for each table in "tables":

1) NULL-row flag if the table is nullable. 2) NULL flags for each nullable column. 3) The actual data from the columns. 4) The row ID for each row. This is only stored if the optimizer requested row IDs when creating the TableCollection.

Return values
trueif error, false otherwise

◆ StoreFromTableBuffersRaw()

ALWAYS_INLINE uchar * pack_rows::StoreFromTableBuffersRaw ( const TableCollection tables,
uchar dptr 
)