MySQL 8.3.0
Source Code Documentation
temptable::Row Class Reference

A row representation. More...

#include <row.h>

Public Member Functions

 Row (const unsigned char *mysql_row, Allocator< uint8_t > *allocator)
 
 Row (const Row &)=delete
 Copy constructing is disabled because it is too expensive. More...
 
Rowoperator= (const Row &)=delete
 Copy assignment is disabled because it is too expensive. More...
 
 Row (Row &&other)=delete
 Move constructor. More...
 
Rowoperator= (Row &&rhs)=delete
 Move assignment. More...
 
 ~Row ()
 Destructor. More...
 
Cell cell (const Column &column, size_t i) const
 Get a given cell. More...
 
Result copy_to_own_memory (const Columns &columns, size_t mysql_row_length) const
 Copy the user data to an own buffer (convert from write_row() format). More...
 
void copy_to_mysql_row (const Columns &columns, unsigned char *mysql_row, size_t mysql_row_length) const
 Copy the row in a MySQL buffer (convert to write_row() format). More...
 

Static Public Member Functions

static void swap (Row &r1, Row &r2)
 Swaps contents of two rows. More...
 
static int compare (const Row &lhs, const Row &rhs, const Columns &columns, Field **mysql_fields)
 Compare to another row. More...
 

Private Member Functions

Cellcells () const
 Get a pointer to the cells array. More...
 
Cell cell_in_row (size_t i) const
 Get a given cell. More...
 
Cell cell_in_mysql_memory (const Column &column) const
 Get a given cell. More...
 
size_t buf_length () const
 Derives the length of the buffer pointed to by m_ptr in bytes (when m_data_is_in_mysql_memory is false). More...
 

Private Attributes

Allocator< uint8_t > * m_allocator
 Allocator to use when copying from MySQL row to our own memory. More...
 
bool m_data_is_in_mysql_memory
 Indicate whether this object is lightweight, with just pointers to the MySQL row buffer or not. More...
 
unsigned char * m_ptr
 A pointer to either the mysql row, or our buffer. More...
 

Detailed Description

A row representation.

A row consists of multiple cells. A row is created from a handler row (in write_row() format) and initially it refers the data in the provided handler row - without copying any user data. Nevertheless such a lightweight row can be used in the same way as a row that has copied the user data and owns it.

Constructor & Destructor Documentation

◆ Row() [1/3]

temptable::Row::Row ( const unsigned char *  mysql_row,
Allocator< uint8_t > *  allocator 
)
inlineexplicit

◆ Row() [2/3]

temptable::Row::Row ( const Row )
delete

Copy constructing is disabled because it is too expensive.

◆ Row() [3/3]

temptable::Row::Row ( Row &&  other)
delete

Move constructor.

other is undefined after this call.

◆ ~Row()

temptable::Row::~Row ( )
inline

Destructor.

Member Function Documentation

◆ buf_length()

size_t temptable::Row::buf_length ( ) const
inlineprivate

Derives the length of the buffer pointed to by m_ptr in bytes (when m_data_is_in_mysql_memory is false).

Returns
buffer length

◆ cell()

Cell temptable::Row::cell ( const Column column,
size_t  i 
) const
inline

Get a given cell.

The cell contains pointers inside the row, so its lifetime should not be longer than the row.

Returns
a cell from the row.
Parameters
[in]columnColumn that corresponds to this cell.
[in]iThe index of the cell to fetch (must be < number_of_cells()).

◆ cell_in_mysql_memory()

Cell temptable::Row::cell_in_mysql_memory ( const Column column) const
inlineprivate

Get a given cell.

The cell contains pointers inside the row, so the returned cell's lifetime should not be longer than the row.

Returns
a cell from the row.
Parameters
[in]columnColumn that corresponds to this cell.

◆ cell_in_row()

Cell temptable::Row::cell_in_row ( size_t  i) const
inlineprivate

Get a given cell.

The cell contains pointers inside the row, so its lifetime should not be longer than the row.

Returns
a cell from the row.
Parameters
[in]iThe index of the cell to fetch (must be < number_of_cells()).

◆ cells()

Cell * temptable::Row::cells ( ) const
inlineprivate

Get a pointer to the cells array.

Only defined if m_data_is_in_mysql_memory is false.

Returns
cells array

◆ compare()

int temptable::Row::compare ( const Row lhs,
const Row rhs,
const Columns columns,
Field **  mysql_fields 
)
static

Compare to another row.

Used by Table::update() and Table::remove() to double check that the row which is passed as "old row" indeed equals to the row pointed to by the specified position.

Return values
<0if lhs < rhs
0if lhs == rhs
>0if lhs > rhs
Parameters
[in]lhsFirst row to compare.
[in]rhsSecond row to compare.
[in]columnsColumns that constitute `this` and in `rhs`.
[in]mysql_fieldsList of MySQL column definitions, used for querying metadata.

◆ copy_to_mysql_row()

void temptable::Row::copy_to_mysql_row ( const Columns columns,
unsigned char *  mysql_row,
size_t  mysql_row_length 
) const

Copy the row in a MySQL buffer (convert to write_row() format).

Parameters
[in]columnsMetadata for the columns that constitute this row.
[out]mysql_rowDestination buffer to copy the row to.
[in]mysql_row_lengthPresumed length of the mysql row in bytes.

◆ copy_to_own_memory()

Result temptable::Row::copy_to_own_memory ( const Columns columns,
size_t  mysql_row_length 
) const

Copy the user data to an own buffer (convert from write_row() format).

Returns
Result:OK or other Result::* error code
Parameters
[in]columnsMetadata for the columns that constitute this row.
[in]mysql_row_lengthLength of the mysql row in bytes (m_ptr).

◆ operator=() [1/2]

Row & temptable::Row::operator= ( const Row )
delete

Copy assignment is disabled because it is too expensive.

◆ operator=() [2/2]

Row & temptable::Row::operator= ( Row &&  rhs)
delete

Move assignment.

rhs is undefined after this call.

◆ swap()

void temptable::Row::swap ( Row r1,
Row r2 
)
inlinestatic

Swaps contents of two rows.

Parameters
[in,out]r1First row to swap.
[in,out]r2Seconds row to swap.

Member Data Documentation

◆ m_allocator

Allocator<uint8_t>* temptable::Row::m_allocator
private

Allocator to use when copying from MySQL row to our own memory.

◆ m_data_is_in_mysql_memory

bool temptable::Row::m_data_is_in_mysql_memory
mutableprivate

Indicate whether this object is lightweight, with just pointers to the MySQL row buffer or not.

◆ m_ptr

unsigned char* temptable::Row::m_ptr
mutableprivate

A pointer to either the mysql row, or our buffer.

If

  • m_data_is_in_mysql_memory is true, then this points to a buffer in mysql write_row() format, not owned by the current Row object;
  • m_data_is_in_mysql_memory is false, then this points a our own buffer that holds the cells and the user data. Its structure is: [0, A = sizeof(size_t)): buffer length [A, B = A + number_of_cells * sizeof(Cell)): cells array [B, B + sum(user data length for each cell)): user data of the cells

The documentation for this class was generated from the following files: