MySQL 9.1.0
Source Code Documentation
|
SQL data field and tuple. More...
#include "univ.i"
#include "data0type.h"
#include "data0types.h"
#include "dict0types.h"
#include "mem0mem.h"
#include "trx0types.h"
#include "ut0bitset.h"
#include <ostream>
#include "data0data.ic"
Go to the source code of this file.
Classes | |
struct | multi_value_data |
Structure to hold number of multiple values. More... | |
class | Multi_value_logger |
Class to log the multi-value data and read it from the log. More... | |
struct | dfield_t |
Structure for an SQL data field. More... | |
struct | dtuple_t |
Structure for an SQL data tuple of fields (logical record) More... | |
struct | big_rec_field_t |
A slot for a field in a big rec vector. More... | |
struct | big_rec_t |
Storage format for overflow data in a big record, that is, a clustered index record which needs external storage of data fields. More... | |
Macros | |
#define | DTUPLE_EST_ALLOC(n_fields) (sizeof(dtuple_t) + (n_fields) * sizeof(dfield_t)) |
Functions | |
static dtype_t * | dfield_get_type (const dfield_t *field) |
Gets pointer to the type struct of SQL data field. More... | |
static void * | dfield_get_data (const dfield_t *field) |
Gets pointer to the data in a field. More... | |
static void | dfield_set_type (dfield_t *field, const dtype_t *type) |
Sets the type struct of SQL data field. More... | |
static uint32_t | dfield_get_len (const dfield_t *field) |
Gets length of field data. More... | |
static void | dfield_set_len (dfield_t *field, ulint len) |
Sets length in a field. More... | |
static ulint | dfield_is_null (const dfield_t *field) |
Determines if a field is SQL NULL. More... | |
static bool | dfield_is_ext (const dfield_t *field) |
Determines if a field is externally stored. More... | |
static void | dfield_set_ext (dfield_t *field) |
Sets the "external storage" flag. More... | |
static spatial_status_t | dfield_get_spatial_status (const dfield_t *field) |
Gets spatial status for "external storage". More... | |
static void | dfield_set_spatial_status (dfield_t *field, spatial_status_t spatial_status) |
Sets spatial status for "external storage". More... | |
static void | dfield_set_data (dfield_t *field, const void *data, ulint len) |
Sets pointer to the data and length in a field. More... | |
static void | dfield_write_mbr (dfield_t *field, const double *mbr) |
Sets pointer to the data and length in a field. More... | |
static void | dfield_set_null (dfield_t *field) |
Sets a data field to SQL NULL. More... | |
static void | data_write_sql_null (byte *data, ulint len) |
Writes an SQL null field full of zeros. More... | |
static void | dfield_copy_data (dfield_t *field1, const dfield_t *field2) |
Copies the data and len fields. More... | |
static void | dfield_copy (dfield_t *field1, const dfield_t *field2) |
Copies a data field to another. More... | |
static void | dfield_dup (dfield_t *field, mem_heap_t *heap) |
Copies the data pointed to by a data field. More... | |
static void | dfield_multi_value_dup (dfield_t *field, mem_heap_t *heap) |
Copies the data pointed to by a data field. More... | |
static bool | dfield_is_multi_value (const dfield_t *field) |
Determine if a field is of multi-value type. More... | |
bool | dfield_datas_are_binary_equal (const dfield_t *field1, const dfield_t *field2, ulint len) |
Tests if two data fields are equal. More... | |
static bool | dfield_data_is_binary_equal (const dfield_t *field, ulint len, const byte *data) |
Tests if dfield data length and content is equal to the given. More... | |
static ulint | dtuple_get_n_fields (const dtuple_t *tuple) |
Gets number of fields in a data tuple. More... | |
static ulint | dtuple_get_n_v_fields (const dtuple_t *tuple) |
Gets number of virtual fields in a data tuple. More... | |
static dfield_t * | dtuple_get_nth_field (const dtuple_t *tuple, ulint n) |
Gets nth field of a tuple. More... | |
static dfield_t * | dtuple_get_nth_v_field (const dtuple_t *tuple, ulint n) |
Gets nth virtual field of a tuple. More... | |
static ulint | dtuple_get_info_bits (const dtuple_t *tuple) |
Gets info bits in a data tuple. More... | |
static void | dtuple_set_info_bits (dtuple_t *tuple, ulint info_bits) |
Sets info bits in a data tuple. More... | |
static ulint | dtuple_get_n_fields_cmp (const dtuple_t *tuple) |
Gets number of fields used in record comparisons. More... | |
static void | dtuple_set_n_fields_cmp (dtuple_t *tuple, ulint n_fields_cmp) |
Gets number of fields used in record comparisons. More... | |
static dtuple_t * | dtuple_create_from_mem (void *buf, ulint buf_size, ulint n_fields, ulint n_v_fields) |
Creates a data tuple from an already allocated chunk of memory. More... | |
static dtuple_t * | dtuple_create (mem_heap_t *heap, ulint n_fields) |
Creates a data tuple to a memory heap. More... | |
static void | dtuple_init_v_fld (const dtuple_t *vrow) |
Initialize the virtual field data in a dtuple_t. More... | |
static void | dtuple_dup_v_fld (const dtuple_t *vrow, mem_heap_t *heap) |
Duplicate the virtual field data in a dtuple_t. More... | |
static dtuple_t * | dtuple_create_with_vcol (mem_heap_t *heap, ulint n_fields, ulint n_v_fields) |
Creates a data tuple with possible virtual columns to a memory heap. More... | |
void | dtuple_set_n_fields (dtuple_t *tuple, ulint n_fields) |
Sets number of fields used in a tuple. More... | |
static void | dtuple_copy_v_fields (dtuple_t *d_tuple, const dtuple_t *s_tuple) |
Copies a data tuple's virtual fields to another. More... | |
static dtuple_t * | dtuple_copy (const dtuple_t *tuple, mem_heap_t *heap) |
Copies a data tuple to another. More... | |
static ulint | dtuple_get_data_size (const dtuple_t *tuple, ulint comp) |
The following function returns the sum of data lengths of a tuple. More... | |
bool | dtuple_coll_eq (const dtuple_t *tuple1, const dtuple_t *tuple2) |
Compare two data tuples. More... | |
static uint64_t | dtuple_hash (const dtuple_t *tuple, ulint n_fields, ulint n_bytes, uint64_t hash_value) |
Compute a hash value of a prefix of an index record. More... | |
static void | dtuple_set_types_binary (dtuple_t *tuple, ulint n) |
Sets types of fields binary in a tuple. More... | |
static bool | dtuple_contains_null (const dtuple_t *tuple) |
Checks if a dtuple contains an SQL null value. More... | |
bool | dfield_check_typed (const dfield_t *field) |
Checks that a data field is typed. More... | |
bool | dtuple_check_typed (const dtuple_t *tuple) |
Checks that a data tuple is typed. More... | |
bool | dtuple_validate (const dtuple_t *tuple) |
Validates the consistency of a tuple which must be complete, i.e, all fields must have been set. More... | |
void | dfield_print_also_hex (const dfield_t *dfield) |
Pretty prints a dfield value according to its data type. More... | |
void | dtuple_print (FILE *f, const dtuple_t *tuple) |
The following function prints the contents of a tuple. More... | |
void | dfield_print (std::ostream &o, const dfield_t *field, ulint n) |
Print the contents of a tuple. More... | |
void | dtuple_print (std::ostream &o, const dtuple_t *tuple) |
Print the contents of a tuple. More... | |
std::ostream & | operator<< (std::ostream &o, const dtuple_t &tuple) |
Print the contents of a tuple. More... | |
big_rec_t * | dtuple_convert_big_rec (dict_index_t *index, upd_t *upd, dtuple_t *entry) |
Moves parts of long fields in entry to the big record vector so that the size of tuple drops below the maximum record size allowed in the database. More... | |
void | dtuple_convert_back_big_rec (dtuple_t *entry, big_rec_t *vector) |
Puts back to entry the data stored in vector. More... | |
static void | dtuple_big_rec_free (big_rec_t *vector) |
Frees the memory in a big rec vector. More... | |
bool | is_multi_value_clust_and_sec_equal (const byte *clust_field, uint64_t clust_len, const byte *sec_field, uint64_t sec_len, const dict_col_t *col) |
Compare a multi-value clustered index field with a secondary index field, to see if they are equal. More... | |
std::ostream & | operator<< (std::ostream &out, const dfield_t &obj) |
Overloading the global output operator to easily print the given dfield_t object into the given output stream. More... | |
std::ostream & | operator<< (std::ostream &out, const big_rec_field_t &obj) |
Overloading the global output operator to easily print the given big_rec_field_t object into the given output stream. More... | |
std::ostream & | operator<< (std::ostream &out, const big_rec_t &obj) |
Overloading the global output operator to easily print the given big_rec_t object into the given output stream. More... | |
Variables | |
constexpr uint32_t | DATA_TUPLE_MAGIC_N = 65478679 |
Value of dtuple_t::magic_n. More... | |
SQL data field and tuple.
Created 5/30/1994 Heikki Tuuri
Writes an SQL null field full of zeros.
[in] | data | pointer to a buffer of size len |
[in] | len | SQL null size in bytes |
bool dfield_check_typed | ( | const dfield_t * | field | ) |
Checks that a data field is typed.
Asserts an error if not.
Copies a data field to another.
[out] | field1 | field to copy to |
[in] | field2 | field to copy from |
Copies the data and len fields.
[out] | field1 | field to copy to |
[in] | field2 | field to copy from |
|
inlinestatic |
Tests if dfield data length and content is equal to the given.
[in] | field | Field |
[in] | len | Data length or UNIV_SQL_NULL |
[in] | data | Data |
|
inline |
Tests if two data fields are equal.
If len==0, tests the data length and content for equality. If len>0, tests the first len bytes of the content for equality.
[in] | field1 | first field to compare |
[in] | field2 | second field to compare |
[in] | len | maximum prefix to compare, or 0 to compare the whole field length. This works only if !multi_val |
|
inlinestatic |
Copies the data pointed to by a data field.
[in,out] | field | data field |
[in] | heap | memory heap where allocated |
|
inlinestatic |
Gets pointer to the data in a field.
|
inlinestatic |
Gets length of field data.
|
inlinestatic |
Gets spatial status for "external storage".
[in,out] | field | field |
Gets pointer to the type struct of SQL data field.
|
inlinestatic |
Determines if a field is externally stored.
|
inlinestatic |
Determine if a field is of multi-value type.
[in] | field | data field |
Determines if a field is SQL NULL.
|
inlinestatic |
Copies the data pointed to by a data field.
This function works for multi-value fields only.
[in,out] | field | data field |
[in] | heap | memory heap where allocated |
Print the contents of a tuple.
[out] | o | output stream |
[in] | field | array of data fields |
[in] | n | number of data fields |
void dfield_print_also_hex | ( | const dfield_t * | dfield | ) |
Pretty prints a dfield value according to its data type.
Also the hex string is printed if a string contains non-printable characters. in: dfield
Sets pointer to the data and length in a field.
[in] | field | field |
[in] | data | data |
[in] | len | length or UNIV_SQL_NULL |
|
inlinestatic |
Sets the "external storage" flag.
in/out: field
Sets length in a field.
[in] | field | field |
[in] | len | length or UNIV_SQL_NULL |
|
inlinestatic |
Sets a data field to SQL NULL.
in/out: field
|
inlinestatic |
Sets spatial status for "external storage".
[in,out] | field | field |
[in] | spatial_status | spatial status |
Sets the type struct of SQL data field.
[in] | field | SQL data field |
[in] | type | pointer to data type struct |
|
inlinestatic |
Sets pointer to the data and length in a field.
[in] | field | field |
[in] | mbr | data |
|
inlinestatic |
Frees the memory in a big rec vector.
in, own: big rec vector; it is freed in this function
bool dtuple_check_typed | ( | const dtuple_t * | tuple | ) |
Checks that a data tuple is typed.
Asserts an error if not.
Compare two data tuples.
[in] | tuple1 | first data tuple |
[in] | tuple2 | second data tuple |
|
inlinestatic |
Checks if a dtuple contains an SQL null value.
Puts back to entry the data stored in vector.
Note that to ensure the fields in entry can accommodate the data, vector must have been created from entry with dtuple_convert_big_rec.
[in] | entry | Entry whose data was put to vector. |
[in] | vector | Big rec vector; it is freed in this function |
big_rec_t * dtuple_convert_big_rec | ( | dict_index_t * | index, |
upd_t * | upd, | ||
dtuple_t * | entry | ||
) |
Moves parts of long fields in entry to the big record vector so that the size of tuple drops below the maximum record size allowed in the database.
Moves data only from those fields which are not necessary to determine uniquely the insertion place of the tuple in the index.
[in,out] | index | Index that owns the record. |
[in,out] | upd | Update vector. |
[in,out] | entry | Index entry. |
|
inlinestatic |
Copies a data tuple to another.
This is a shallow copy; if a deep copy is desired, dfield_dup() will have to be invoked on each field.
tuple | in: tuple to copy from |
heap | in: memory heap where the tuple is created |
Copies a data tuple's virtual fields to another.
This is a shallow copy;
[in,out] | d_tuple | destination tuple |
[in] | s_tuple | source tuple |
|
inlinestatic |
Creates a data tuple to a memory heap.
The default value for number of fields used in record comparisons for this tuple is n_fields.
heap | in: memory heap where the tuple is created, DTUPLE_EST_ALLOC(n_fields) bytes will be allocated from this heap |
n_fields | in: number of fields |
|
inlinestatic |
Creates a data tuple from an already allocated chunk of memory.
The size of the chunk must be at least DTUPLE_EST_ALLOC(n_fields). The default value for number of fields used in record comparisons for this tuple is n_fields.
[in,out] | buf | buffer to use |
[in] | buf_size | buffer size |
[in] | n_fields | number of field |
[in] | n_v_fields | number of fields on virtual columns |
|
inlinestatic |
Creates a data tuple with possible virtual columns to a memory heap.
[in] | heap | memory heap where the tuple is created |
[in] | n_fields | number of fields |
[in] | n_v_fields | number of fields on virtual col |
|
inlinestatic |
Duplicate the virtual field data in a dtuple_t.
[in,out] | vrow | dtuple contains the virtual fields |
[in] | heap | heap memory to use |
The following function returns the sum of data lengths of a tuple.
The space occupied by the field structs or the tuple struct is not counted.
[in] | tuple | typed data tuple |
[in] | comp | nonzero=ROW_FORMAT=COMPACT |
Gets info bits in a data tuple.
Gets number of fields in a data tuple.
Gets number of fields used in record comparisons.
Gets number of virtual fields in a data tuple.
[in] | tuple | dtuple to check |
Gets nth field of a tuple.
[in] | tuple | tuple |
[in] | n | index of field |
Gets nth virtual field of a tuple.
[in] | tuple | tuple |
[in] | n | the nth field to get |
|
inlinestatic |
Compute a hash value of a prefix of an index record.
[in] | tuple | index record |
[in] | n_fields | number of fields to include |
[in] | n_bytes | number of bytes to hash in the last field |
[in] | hash_value | hash value of the index identifier |
|
inlinestatic |
Initialize the virtual field data in a dtuple_t.
[in,out] | vrow | dtuple contains the virtual fields |
void dtuple_print | ( | FILE * | f, |
const dtuple_t * | tuple | ||
) |
The following function prints the contents of a tuple.
[in,out] | f | Output stream. |
[in] | tuple | Tuple to print. |
void dtuple_print | ( | std::ostream & | o, |
const dtuple_t * | tuple | ||
) |
Print the contents of a tuple.
[out] | o | output stream |
[in] | tuple | data tuple |
Sets info bits in a data tuple.
[in] | tuple | tuple |
[in] | info_bits | info bits |
Sets number of fields used in a tuple.
Normally this is set in dtuple_create, but if you want later to set it smaller, you can use this.
[in] | tuple | Tuple. |
[in] | n_fields | Number of fields. |
Gets number of fields used in record comparisons.
[in] | tuple | tuple |
[in] | n_fields_cmp | number of fields used in comparisons in rem0cmp |
Sets types of fields binary in a tuple.
[in] | tuple | data tuple |
[in] | n | number of fields to set |
bool dtuple_validate | ( | const dtuple_t * | tuple | ) |
Validates the consistency of a tuple which must be complete, i.e, all fields must have been set.
bool is_multi_value_clust_and_sec_equal | ( | const byte * | clust_field, |
uint64_t | clust_len, | ||
const byte * | sec_field, | ||
uint64_t | sec_len, | ||
const dict_col_t * | col | ||
) |
Compare a multi-value clustered index field with a secondary index field, to see if they are equal.
If the clustered index field is the array, then equal means it contains the secondary index field
[in] | clust_field | clustered index field |
[in] | clust_len | clustered index field length |
[in] | sec_field | secondary index field |
[in] | sec_len | secondary index field length |
[in] | col | the column tied to this field |
|
inline |
Print the contents of a tuple.
[out] | o | output stream |
[in] | tuple | data tuple |
|
inline |
Overloading the global output operator to easily print the given big_rec_field_t object into the given output stream.
[in] | out | the output stream |
[in] | obj | the given object to print. |
|
inline |
Overloading the global output operator to easily print the given big_rec_t object into the given output stream.
[in] | out | the output stream |
[in] | obj | the given object to print. |
|
inline |
Overloading the global output operator to easily print the given dfield_t object into the given output stream.
[in] | out | the output stream |
[in] | obj | the given object to print. |
|
constexpr |
Value of dtuple_t::magic_n.