MySQL 9.1.0
Source Code Documentation
|
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... | |
Row & | operator= (const Row &)=delete |
Copy assignment is disabled because it is too expensive. More... | |
Row (Row &&other)=delete | |
Move constructor. More... | |
Row & | operator= (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 | |
Cell * | cells () 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... | |
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.
|
delete |
Copy constructing is disabled because it is too expensive.
|
delete |
Move constructor.
other
is undefined after this call.
|
inlineprivate |
Derives the length of the buffer pointed to by m_ptr
in bytes (when m_data_is_in_mysql_memory
is false).
Get a given cell.
The cell contains pointers inside the row, so its lifetime should not be longer than the row.
[in] | column | Column that corresponds to this cell. |
[in] | i | The index of the cell to fetch (must be < number_of_cells()). |
Get a given cell.
The cell contains pointers inside the row, so the returned cell's lifetime should not be longer than the row.
[in] | column | Column that corresponds to this cell. |
Get a given cell.
The cell contains pointers inside the row, so its lifetime should not be longer than the row.
[in] | i | The index of the cell to fetch (must be < number_of_cells()). |
Get a pointer to the cells array.
Only defined if m_data_is_in_mysql_memory
is false.
|
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.
<0 | if lhs < rhs |
0 | if lhs == rhs |
>0 | if lhs > rhs |
[in] | lhs | First row to compare. |
[in] | rhs | Second row to compare. |
[in] | columns | Columns that constitute `this` and in `rhs`. |
[in] | mysql_fields | List of MySQL column definitions, used for querying metadata. |
void Row< T >::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).
[in] | columns | Metadata for the columns that constitute this row. |
[out] | mysql_row | Destination buffer to copy the row to. |
[in] | mysql_row_length | Presumed length of the mysql row in bytes. |
Copy the user data to an own buffer (convert from write_row() format).
[in] | columns | Metadata for the columns that constitute this row. |
[in] | mysql_row_length | Length of the mysql row in bytes (m_ptr). |
Copy assignment is disabled because it is too expensive.
Move assignment.
rhs
is undefined after this call.
Swaps contents of two rows.
[in,out] | r1 | First row to swap. |
[in,out] | r2 | Seconds row to swap. |
|
private |
Allocator to use when copying from MySQL row to our own memory.
|
mutableprivate |
Indicate whether this object is lightweight, with just pointers to the MySQL row buffer or not.
|
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