InnoDB Plugin  1.0
Data Structures | Macros | Functions
data0data.h File Reference
#include "univ.i"
#include "data0types.h"
#include "data0type.h"
#include "mem0mem.h"
#include "dict0types.h"
#include "data0data.ic"
Include dependency graph for data0data.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dfield_t
struct  dtuple_t
struct  big_rec_field_t
struct  big_rec_t

Macros

#define DTUPLE_EST_ALLOC(n_fields)   (sizeof(dtuple_t) + (n_fields) * sizeof(dfield_t))
#define DATA_TUPLE_MAGIC_N   65478679

Functions

UNIV_INLINE dtype_tdfield_get_type (const dfield_t *field))
UNIV_INLINE void * dfield_get_data (const dfield_t *field))
UNIV_INLINE void dfield_set_type (dfield_t *field, const dtype_t *type))
UNIV_INLINE ulint dfield_get_len (const dfield_t *field))
UNIV_INLINE void dfield_set_len (dfield_t *field, ulint len))
UNIV_INLINE ulint dfield_is_null (const dfield_t *field))
UNIV_INLINE ulint dfield_is_ext (const dfield_t *field))
UNIV_INLINE void dfield_set_ext (dfield_t *field))
UNIV_INLINE void dfield_set_data (dfield_t *field, const void *data, ulint len)))
UNIV_INLINE void dfield_set_null (dfield_t *field))
UNIV_INLINE void data_write_sql_null (byte *data, ulint len))
UNIV_INLINE void dfield_copy_data (dfield_t *field1, const dfield_t *field2))
UNIV_INLINE void dfield_copy (dfield_t *field1, const dfield_t *field2))
UNIV_INLINE void dfield_dup (dfield_t *field, mem_heap_t *heap))
UNIV_INLINE ibool dfield_datas_are_binary_equal (const dfield_t *field1, const dfield_t *field2, ulint len))
UNIV_INLINE ibool dfield_data_is_binary_equal (const dfield_t *field, ulint len, const byte *data))
UNIV_INLINE ulint dtuple_get_n_fields (const dtuple_t *tuple))
UNIV_INLINE dfield_tdtuple_get_nth_field (const dtuple_t *tuple, ulint n)
UNIV_INLINE ulint dtuple_get_info_bits (const dtuple_t *tuple))
UNIV_INLINE void dtuple_set_info_bits (dtuple_t *tuple, ulint info_bits))
UNIV_INLINE ulint dtuple_get_n_fields_cmp (const dtuple_t *tuple))
UNIV_INLINE void dtuple_set_n_fields_cmp (dtuple_t *tuple, ulint n_fields_cmp))
UNIV_INLINE dtuple_tdtuple_create_from_mem (void *buf, ulint buf_size, ulint n_fields))
UNIV_INLINE dtuple_tdtuple_create (mem_heap_t *heap, ulint n_fields))
UNIV_INTERN void dtuple_set_n_fields (dtuple_t *tuple, ulint n_fields))
UNIV_INLINE dtuple_tdtuple_copy (const dtuple_t *tuple, mem_heap_t *heap))
UNIV_INLINE ulint dtuple_get_data_size (const dtuple_t *tuple, ulint comp))
UNIV_INLINE ulint dtuple_get_n_ext (const dtuple_t *tuple))
UNIV_INTERN int dtuple_coll_cmp (const dtuple_t *tuple1, const dtuple_t *tuple2))
UNIV_INLINE ulint dtuple_fold (const dtuple_t *tuple, ulint n_fields, ulint n_bytes, index_id_t tree_id))
UNIV_INLINE void dtuple_set_types_binary (dtuple_t *tuple, ulint n))
UNIV_INLINE ibool dtuple_contains_null (const dtuple_t *tuple))
UNIV_INTERN ibool dfield_check_typed (const dfield_t *field))
UNIV_INTERN ibool dtuple_check_typed (const dtuple_t *tuple))
UNIV_INTERN ibool dtuple_check_typed_no_assert (const dtuple_t *tuple))
UNIV_INTERN ibool dtuple_validate (const dtuple_t *tuple))
UNIV_INTERN void dfield_print (const dfield_t *dfield))
UNIV_INTERN void dfield_print_also_hex (const dfield_t *dfield))
UNIV_INTERN void dtuple_print (FILE *f, const dtuple_t *tuple))
UNIV_INTERN big_rec_tdtuple_convert_big_rec (dict_index_t *index, dtuple_t *entry, ulint *n_ext))
UNIV_INTERN void dtuple_convert_back_big_rec (dict_index_t *index, dtuple_t *entry, big_rec_t *vector))
UNIV_INLINE void dtuple_big_rec_free (big_rec_t *vector))

Detailed Description

SQL data field and tuple

Created 5/30/1994 Heikki Tuuri

Macro Definition Documentation

#define DATA_TUPLE_MAGIC_N   65478679

Function Documentation

UNIV_INLINE void data_write_sql_null ( byte *  data,
ulint  len 
)

Writes an SQL null field full of zeros.

Parameters
datain: pointer to a buffer of size len
lenin: SQL null size in bytes
UNIV_INTERN ibool dfield_check_typed ( const dfield_t field)

Checks that a data field is typed. Asserts an error if not.

Returns
TRUE if ok
Parameters
fieldin: data field
UNIV_INLINE void dfield_copy ( dfield_t field1,
const dfield_t field2 
)

Copies a data field to another.

Parameters
field1out: field to copy to
field2in: field to copy from
UNIV_INLINE void dfield_copy_data ( dfield_t field1,
const dfield_t field2 
)

Copies the data and len fields.

Parameters
field1out: field to copy to
field2in: field to copy from
UNIV_INLINE ibool 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.

Returns
TRUE if equal
Parameters
fieldin: field
lenin: data length or UNIV_SQL_NULL
datain: data
UNIV_INLINE ibool dfield_datas_are_binary_equal ( const dfield_t field1,
const dfield_t field2,
ulint  len 
)

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.

Returns
TRUE if both fields are NULL or if they are equal
Parameters
field1in: field
field2in: field
lenin: maximum prefix to compare, or 0 to compare the whole field length
UNIV_INLINE void dfield_dup ( dfield_t field,
mem_heap_t heap 
)

Copies the data pointed to by a data field.

Parameters
fieldin/out: data field
heapin: memory heap where allocated
UNIV_INLINE void* dfield_get_data ( const dfield_t field)

Gets pointer to the data in a field.

Returns
pointer to data
Parameters
fieldin: field
UNIV_INLINE ulint dfield_get_len ( const dfield_t field)

Gets length of field data.

Returns
length of data; UNIV_SQL_NULL if SQL null data
Parameters
fieldin: field
UNIV_INLINE dtype_t* dfield_get_type ( const dfield_t field)

Gets pointer to the type struct of SQL data field.

Returns
pointer to the type struct
Parameters
fieldin: SQL data field
UNIV_INLINE ulint dfield_is_ext ( const dfield_t field)

Determines if a field is externally stored

Returns
nonzero if externally stored
Parameters
fieldin: field
UNIV_INLINE ulint dfield_is_null ( const dfield_t field)

Determines if a field is SQL NULL

Returns
nonzero if SQL null data
Parameters
fieldin: field
UNIV_INTERN void dfield_print ( const dfield_t dfield)

Pretty prints a dfield value according to its data type.

Parameters
dfieldin: dfield
UNIV_INTERN 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.

Parameters
dfieldin: dfield
UNIV_INLINE void dfield_set_data ( dfield_t field,
const void *  data,
ulint  len 
)

Sets pointer to the data and length in a field.

Parameters
fieldin: field
datain: data
lenin: length or UNIV_SQL_NULL
UNIV_INLINE void dfield_set_ext ( dfield_t field)

Sets the "external storage" flag

Parameters
fieldin/out: field
UNIV_INLINE void dfield_set_len ( dfield_t field,
ulint  len 
)

Sets length in a field.

Parameters
fieldin: field
lenin: length or UNIV_SQL_NULL
UNIV_INLINE void dfield_set_null ( dfield_t field)

Sets a data field to SQL NULL.

Parameters
fieldin/out: field
UNIV_INLINE void dfield_set_type ( dfield_t field,
const dtype_t type 
)

Sets the type struct of SQL data field.

Parameters
fieldin: SQL data field
typein: pointer to data type struct
UNIV_INLINE void dtuple_big_rec_free ( big_rec_t vector)

Frees the memory in a big rec vector.

Parameters
vectorin, own: big rec vector; it is freed in this function
UNIV_INTERN ibool dtuple_check_typed ( const dtuple_t tuple)

Checks that a data tuple is typed. Asserts an error if not.

Returns
TRUE if ok
Parameters
tuplein: tuple
UNIV_INTERN ibool dtuple_check_typed_no_assert ( const dtuple_t tuple)

Checks that a data tuple is typed.

Returns
TRUE if ok
Parameters
tuplein: tuple
UNIV_INTERN int dtuple_coll_cmp ( const dtuple_t tuple1,
const dtuple_t tuple2 
)

Compare two data tuples, respecting the collation of character fields.

Returns
1, 0 , -1 if tuple1 is greater, equal, less, respectively, than tuple2
Parameters
tuple1in: tuple 1
tuple2in: tuple 2
UNIV_INLINE ibool dtuple_contains_null ( const dtuple_t tuple)

Checks if a dtuple contains an SQL null value.

Returns
TRUE if some field is SQL null
Parameters
tuplein: dtuple
UNIV_INTERN void dtuple_convert_back_big_rec ( dict_index_t index,
dtuple_t entry,
big_rec_t vector 
)

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.

Parameters
indexin: index
entryin: entry whose data was put to vector
vectorin, own: big rec vector; it is freed in this function
UNIV_INTERN big_rec_t* dtuple_convert_big_rec ( dict_index_t index,
dtuple_t entry,
ulint *  n_ext 
)

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.

Returns
own: created big record vector, NULL if we are not able to shorten the entry enough, i.e., if there are too many fixed-length or short fields in entry or the index is clustered
Parameters
indexin: index
entryin/out: index entry
n_extin/out: number of externally stored columns
UNIV_INLINE dtuple_t* dtuple_copy ( const dtuple_t tuple,
mem_heap_t heap 
)

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

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
UNIV_INLINE dtuple_t* dtuple_create_from_mem ( void *  buf,
ulint  buf_size,
ulint  n_fields 
)

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.

Returns
created tuple (inside buf)
Parameters
bufin, out: buffer to use
buf_sizein: buffer size
n_fieldsin: number of fields
UNIV_INLINE ulint dtuple_fold ( const dtuple_t tuple,
ulint  n_fields,
ulint  n_bytes,
index_id_t  tree_id 
)

Folds a prefix given as the number of fields of a tuple.

Returns
the folded value
Parameters
tuplein: the tuple
n_fieldsin: number of complete fields to fold
n_bytesin: number of bytes to fold in an incomplete last field
tree_idin: index tree id
UNIV_INLINE ulint dtuple_get_data_size ( const dtuple_t tuple,
ulint  comp 
)

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.

Returns
sum of data lens

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
UNIV_INLINE ulint dtuple_get_info_bits ( const dtuple_t tuple)

Gets info bits in a data tuple.

Returns
info bits
Parameters
tuplein: tuple
UNIV_INLINE ulint dtuple_get_n_ext ( const dtuple_t tuple)

Computes the number of externally stored fields in a data tuple.

Returns
number of fields

Computes the number of externally stored fields in a data tuple.

Returns
number of externally stored fields
Parameters
tuplein: tuple
UNIV_INLINE ulint dtuple_get_n_fields ( const dtuple_t tuple)

Gets number of fields in a data tuple.

Returns
number of fields
Parameters
tuplein: tuple
UNIV_INLINE ulint dtuple_get_n_fields_cmp ( const dtuple_t tuple)

Gets number of fields used in record comparisons.

Returns
number of fields used in comparisons in rem0cmp.*
Parameters
tuplein: tuple
UNIV_INLINE dfield_t* dtuple_get_nth_field ( const dtuple_t tuple,
ulint  n 
)

Gets nth field of a tuple.

Returns
nth field in: index of field

Gets nth field of a tuple.

Returns
nth field
Parameters
tuplein: tuple
nin: index of field
UNIV_INTERN void dtuple_print ( FILE *  f,
const dtuple_t tuple 
)

The following function prints the contents of a tuple.

Parameters
fin: output stream
tuplein: tuple
UNIV_INLINE void dtuple_set_info_bits ( dtuple_t tuple,
ulint  info_bits 
)

Sets info bits in a data tuple.

Parameters
tuplein: tuple
info_bitsin: info bits
UNIV_INTERN void dtuple_set_n_fields ( dtuple_t tuple,
ulint  n_fields 
)

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.

Parameters
tuplein: tuple
n_fieldsin: number of fields
UNIV_INLINE void dtuple_set_n_fields_cmp ( dtuple_t tuple,
ulint  n_fields_cmp 
)

Gets number of fields used in record comparisons.

Sets number of fields used in record comparisons.

Parameters
tuplein: tuple
n_fields_cmpin: number of fields used in comparisons in rem0cmp.*
UNIV_INLINE void dtuple_set_types_binary ( dtuple_t tuple,
ulint  n 
)

Sets types of fields binary in a tuple.

Parameters
tuplein: data tuple
nin: number of fields to set
UNIV_INTERN ibool dtuple_validate ( const dtuple_t tuple)

Validates the consistency of a tuple which must be complete, i.e, all fields must have been set.

Returns
TRUE if ok
Parameters
tuplein: tuple