MySQL 8.0.39
Source Code Documentation
data0data.ic File Reference

SQL data field and tuple. More...

#include "btr0types.h"
#include "mem0mem.h"

Functions

static dtype_tdfield_get_type (const dfield_t *field)
 Gets pointer to the type struct of SQL data field. More...
 
static void dfield_set_type (dfield_t *field, const dtype_t *type)
 Sets 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 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 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 bool dfield_is_multi_value (const dfield_t *field)
 
static void dfield_multi_value_dup (dfield_t *field, mem_heap_t *heap)
 Copies the data pointed to by a data field. 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)
 
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)
 
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 the number of virtual fields in a data tuple. More...
 
static dfield_tdtuple_get_nth_field (const dtuple_t *tuple, ulint n)
 
static dfield_tdtuple_get_nth_v_field (const dtuple_t *tuple, ulint n)
 
static dtuple_tdtuple_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 void dtuple_dup_v_fld (const dtuple_t *vrow, mem_heap_t *heap)
 Duplicate the virtual field data in a dtuple_t. More...
 
static void dtuple_init_v_fld (const dtuple_t *vrow)
 Initialize the virtual field data in a dtuple_t. More...
 
static dtuple_tdtuple_create (mem_heap_t *heap, ulint n_fields)
 Creates a data tuple to a memory heap. More...
 
static dtuple_tdtuple_create_with_vcol (mem_heap_t *heap, ulint n_fields, ulint n_v_fields)
 Creates a data tuple with virtual columns to a memory heap. 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_tdtuple_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...
 
static void dtuple_set_types_binary (dtuple_t *tuple, ulint n)
 Sets types of fields binary in a tuple. More...
 
static uint64_t dtuple_hash (const dtuple_t *tuple, ulint n_fields, ulint n_bytes, uint64_t hash_value)
 
static void data_write_sql_null (byte *data, ulint len)
 
static bool dtuple_contains_null (const dtuple_t *tuple)
 
void dtuple_big_rec_free (big_rec_t *vector)
 Frees the memory in a big rec vector. More...
 

Variables

byte data_error
 Dummy variable to catch access to uninitialized fields. More...
 

Detailed Description

SQL data field and tuple.

Created 5/30/1994 Heikki Tuuri

Function Documentation

◆ data_write_sql_null()

static void data_write_sql_null ( byte data,
ulint  len 
)
inlinestatic

◆ dfield_copy()

static void dfield_copy ( dfield_t field1,
const dfield_t field2 
)
inlinestatic

Copies a data field to another.

Parameters
field1out: field to copy to
field2in: field to copy from

◆ dfield_copy_data()

static void dfield_copy_data ( dfield_t field1,
const dfield_t field2 
)
inlinestatic

Copies the data and len fields.

Parameters
field1out: field to copy to
field2in: field to copy from

◆ dfield_data_is_binary_equal()

static bool dfield_data_is_binary_equal ( const dfield_t field,
ulint  len,
const byte data 
)
inlinestatic

◆ dfield_datas_are_binary_equal()

bool dfield_datas_are_binary_equal ( const dfield_t field1,
const dfield_t field2,
ulint  len 
)
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.

Parameters
[in]field1first field to compare
[in]field2second field to compare
[in]lenmaximum prefix to compare, or 0 to compare the whole field length. This works only if !multi_val
Returns
true if both fields are NULL or if they are equal

◆ dfield_dup()

static void dfield_dup ( dfield_t field,
mem_heap_t heap 
)
inlinestatic

Copies the data pointed to by a data field.

Parameters
fieldin/out: data field
heapin: memory heap where allocated

◆ dfield_get_data()

static void * dfield_get_data ( const dfield_t field)
inlinestatic

Gets pointer to the data in a field.

Returns
pointer to data
Parameters
fieldin: field

◆ dfield_get_len()

static uint32_t dfield_get_len ( const dfield_t field)
inlinestatic

Gets length of field data.

Returns
length of data; UNIV_SQL_NULL if SQL null data
Parameters
fieldin: field

◆ dfield_get_spatial_status()

static spatial_status_t dfield_get_spatial_status ( const dfield_t field)
inlinestatic

Gets spatial status for "external storage".

Parameters
[in,out]fieldfield

◆ dfield_get_type()

static dtype_t * dfield_get_type ( const dfield_t field)
inlinestatic

Gets pointer to the type struct of SQL data field.

Returns
pointer to the type struct
Parameters
fieldin: SQL data field

◆ dfield_is_ext()

static bool dfield_is_ext ( const dfield_t field)
inlinestatic

Determines if a field is externally stored.

Returns
nonzero if externally stored
Parameters
fieldin: field

◆ dfield_is_multi_value()

static bool dfield_is_multi_value ( const dfield_t field)
inlinestatic

◆ dfield_is_null()

static ulint dfield_is_null ( const dfield_t field)
inlinestatic

Determines if a field is SQL NULL.

Returns
nonzero if SQL null data
Parameters
fieldin: field

◆ dfield_multi_value_dup()

static void dfield_multi_value_dup ( dfield_t field,
mem_heap_t heap 
)
inlinestatic

Copies the data pointed to by a data field.

This function works for multi-value fields only.

Parameters
[in,out]fielddata field
[in]heapmemory heap where allocated

◆ dfield_set_data()

static void dfield_set_data ( dfield_t field,
const void *  data,
ulint  len 
)
inlinestatic

Sets pointer to the data and length in a field.

Parameters
fieldin: field
datain: data
lenin: length or UNIV_SQL_NULL

◆ dfield_set_ext()

static void dfield_set_ext ( dfield_t field)
inlinestatic

Sets the "external storage" flag.

Parameters
fieldin/out: field

◆ dfield_set_len()

static void dfield_set_len ( dfield_t field,
ulint  len 
)
inlinestatic

Sets length in a field.

Parameters
fieldin: field
lenin: length or UNIV_SQL_NULL

◆ dfield_set_null()

static void dfield_set_null ( dfield_t field)
inlinestatic

Sets a data field to SQL NULL.

Parameters
fieldin/out: field

◆ dfield_set_spatial_status()

static void dfield_set_spatial_status ( dfield_t field,
spatial_status_t  spatial_status 
)
inlinestatic

Sets spatial status for "external storage".

Parameters
[in,out]fieldfield
[in]spatial_statusspatial status

◆ dfield_set_type()

static void dfield_set_type ( dfield_t field,
const dtype_t type 
)
inlinestatic

Sets the type struct of SQL data field.

Parameters
fieldin: SQL data field
typein: pointer to data type struct

◆ dfield_write_mbr()

static void dfield_write_mbr ( dfield_t field,
const double *  mbr 
)
inlinestatic

Sets pointer to the data and length in a field.

Parameters
fieldin: field
mbrin: data

◆ dtuple_big_rec_free()

void dtuple_big_rec_free ( big_rec_t vector)
inline

Frees the memory in a big rec vector.

in, own: big rec vector; it is freed in this function

◆ dtuple_contains_null()

static bool dtuple_contains_null ( const dtuple_t tuple)
inlinestatic

◆ dtuple_copy()

static dtuple_t * dtuple_copy ( const dtuple_t tuple,
mem_heap_t heap 
)
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.

Returns
own: copy of tuple
Parameters
tuplein: tuple to copy from
heapin: memory heap where the tuple is created

◆ dtuple_copy_v_fields()

static void dtuple_copy_v_fields ( dtuple_t d_tuple,
const dtuple_t s_tuple 
)
inlinestatic

Copies a data tuple's virtual fields to another.

This is a shallow copy;

Parameters
[in,out]d_tupledestination tuple
[in]s_tuplesource tuple

◆ dtuple_create()

static dtuple_t * dtuple_create ( mem_heap_t heap,
ulint  n_fields 
)
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.

Returns
own: created tuple
Parameters
heapin: memory heap where the tuple is created, DTUPLE_EST_ALLOC(n_fields) bytes will be allocated from this heap
n_fieldsin: number of fields

◆ dtuple_create_from_mem()

static dtuple_t * dtuple_create_from_mem ( void *  buf,
ulint  buf_size,
ulint  n_fields,
ulint  n_v_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.

Parameters
[in,out]bufbuffer to use
[in]buf_sizebuffer size
[in]n_fieldsnumber of field
[in]n_v_fieldsnumber of fields on virtual columns
Returns
created tuple (inside buf)

◆ dtuple_create_with_vcol()

static dtuple_t * dtuple_create_with_vcol ( mem_heap_t heap,
ulint  n_fields,
ulint  n_v_fields 
)
inlinestatic

Creates a data tuple with virtual columns to a memory heap.

Parameters
[in]heapmemory heap where the tuple is created
[in]n_fieldsnumber of fields
[in]n_v_fieldsnumber of fields on virtual col
Returns
own: created tuple

◆ dtuple_dup_v_fld()

static void dtuple_dup_v_fld ( const dtuple_t vrow,
mem_heap_t heap 
)
inlinestatic

Duplicate the virtual field data in a dtuple_t.

Parameters
[in,out]vrowdtuple contains the virtual fields
[in]heapheap memory to use

◆ dtuple_get_data_size()

static ulint dtuple_get_data_size ( const dtuple_t tuple,
ulint  comp 
)
inlinestatic

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. Neither is possible space in externally stored parts of the field.

Returns
sum of data lengths
Parameters
tuplein: typed data tuple
compin: nonzero=ROW_FORMAT=COMPACT

◆ dtuple_get_info_bits()

static ulint dtuple_get_info_bits ( const dtuple_t tuple)
inlinestatic

Gets info bits in a data tuple.

Returns
info bits
Parameters
tuplein: tuple

◆ dtuple_get_n_fields()

static ulint dtuple_get_n_fields ( const dtuple_t tuple)
inlinestatic

Gets number of fields in a data tuple.

Returns
number of fields
Parameters
tuplein: tuple

◆ dtuple_get_n_fields_cmp()

static ulint dtuple_get_n_fields_cmp ( const dtuple_t tuple)
inlinestatic

Gets number of fields used in record comparisons.

Returns
number of fields used in comparisons in rem0cmp.*
Parameters
tuplein: tuple

◆ dtuple_get_n_v_fields()

static ulint dtuple_get_n_v_fields ( const dtuple_t tuple)
inlinestatic

Gets the number of virtual fields in a data tuple.

Parameters
[in]tupledtuple to check
Returns
number of fields

◆ dtuple_get_nth_field()

static dfield_t * dtuple_get_nth_field ( const dtuple_t tuple,
ulint  n 
)
inlinestatic

◆ dtuple_get_nth_v_field()

static dfield_t * dtuple_get_nth_v_field ( const dtuple_t tuple,
ulint  n 
)
inlinestatic

◆ dtuple_hash()

static uint64_t dtuple_hash ( const dtuple_t tuple,
ulint  n_fields,
ulint  n_bytes,
uint64_t  hash_value 
)
inlinestatic

◆ dtuple_init_v_fld()

static void dtuple_init_v_fld ( const dtuple_t vrow)
inlinestatic

Initialize the virtual field data in a dtuple_t.

Parameters
[in,out]vrowdtuple contains the virtual fields

◆ dtuple_set_info_bits()

static void dtuple_set_info_bits ( dtuple_t tuple,
ulint  info_bits 
)
inlinestatic

Sets info bits in a data tuple.

Parameters
tuplein: tuple
info_bitsin: info bits

◆ dtuple_set_n_fields_cmp()

static void dtuple_set_n_fields_cmp ( dtuple_t tuple,
ulint  n_fields_cmp 
)
inlinestatic

◆ dtuple_set_types_binary()

static void dtuple_set_types_binary ( dtuple_t tuple,
ulint  n 
)
inlinestatic

Sets types of fields binary in a tuple.

Parameters
tuplein: data tuple
nin: number of fields to set

Variable Documentation

◆ data_error

byte data_error
extern

Dummy variable to catch access to uninitialized fields.

In the debug version, dtuple_create() will make all fields of dtuple_t point to data_error.