Drizzled Public API Documentation

data0data.h File Reference
#include "univ.i"
#include "data0types.h"
#include "data0type.h"
#include "mem0mem.h"
#include "dict0types.h"

Go to the source code of this file.

Classes

struct  dfield_struct
 
struct  dtuple_struct
 
struct  big_rec_field_struct
 
struct  big_rec_struct
 

Macros

#define data0data_h
 
#define dfield_get_type(field)   (&(field)->type)
 
#define dfield_get_data(field)   ((field)->data)
 
#define dtuple_get_nth_field(tuple, n)   ((tuple)->fields + (n))
 

Typedefs

typedef struct big_rec_struct big_rec_t
 
typedef struct big_rec_field_struct big_rec_field_t
 

Functions

UNIV_INLINE void dfield_set_type (dfield_t *field, 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) __attribute__((nonnull
 
UNIV_INTERN 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 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 (mem_heap_t *heap, ulint n_fields)
 
UNIV_INLINE const dtuple_tdtuple_from_fields (dtuple_t *tuple, const dfield_t *fields, 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) __attribute__((pure))
 
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 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)
 

Variables

UNIV_INLINE ibool warn_unused_result
 

Detailed Description

SQL data field and tuple

Created 5/30/1994 Heikki Tuuri

Definition in file data0data.h.

Typedef Documentation

A slot for a field in a big rec vector

Definition at line 468 of file data0data.h.

typedef struct big_rec_struct big_rec_t
Storage for overflow data in a big record, that is, a clustered

index record which needs external storage of data fields

Definition at line 39 of file data0data.h.

Function Documentation

UNIV_INLINE void data_write_sql_null ( byte *  data,
ulint  len 
)

Writes an SQL null field full of zeros. in: SQL null size in bytes

Parameters
datain: pointer to a buffer of size len
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 in: data field
UNIV_INLINE void dfield_copy ( dfield_t field1,
const dfield_t field2 
)

Copies a data field to another. in: field to copy from

Parameters
field1out: field to copy to

Referenced by row_build_index_entry(), row_upd_build_difference_binary(), and row_upd_build_sec_rec_difference_binary().

UNIV_INLINE void dfield_copy_data ( dfield_t field1,
const dfield_t field2 
)

Copies the data and len fields. in: field to copy from

Parameters
field1out: field to copy to

Referenced by calc_row_difference(), and row_upd_replace().

UNIV_INTERN 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 in: 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

Definition at line 61 of file data0data.cc.

References dfield_get_len().

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. in: memory heap where allocated

Parameters
fieldin/out: data field
UNIV_INLINE ulint dfield_is_null ( const dfield_t field)
UNIV_INTERN void dfield_print ( const dfield_t dfield)

Pretty prints a dfield value according to its data type. in: dfield

Pretty prints a dfield value according to its data type.

Parameters
dfieldin: dfield

Definition at line 305 of file data0data.cc.

References dfield_get_len(), dfield_is_ext(), dfield_is_null(), dtype_get_mtype(), mach_read_from_4(), ut_a, and ut_error.

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. in: 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

Definition at line 346 of file data0data.cc.

References dfield_get_len(), dfield_is_ext(), dfield_is_null(), dtype_get_mtype(), dtype_get_prtype(), mach_read_from_1(), mach_read_from_2(), mach_read_from_3(), mach_read_from_4(), mach_read_from_6(), mach_read_from_7(), mach_read_from_8(), mach_ull_read_compressed(), and TRX_ID_FMT.

UNIV_INLINE void dfield_set_ext ( dfield_t field)
UNIV_INLINE void dfield_set_len ( dfield_t field,
ulint  len 
)

Sets length in a field. in: length or UNIV_SQL_NULL

Parameters
fieldin: field

Referenced by row_build_index_entry(), row_build_row_ref(), row_build_row_ref_in_tuple(), row_sel_convert_mysql_key_to_innobase(), and trx_undo_rec_get_partial_row().

UNIV_INLINE void dfield_set_type ( dfield_t field,
dtype_t type 
)

Sets the type struct of SQL data field. in: pointer to data type struct

Parameters
fieldin: SQL data field
UNIV_INLINE void dtuple_big_rec_free ( big_rec_t vector)

Frees the memory in a big rec vector. in, own: big rec vector; it is freed in this function

UNIV_INTERN ibool dtuple_check_typed_no_assert ( const dtuple_t tuple)

Checks that a data tuple is typed.

Returns
TRUE if ok in: tuple

Checks that a data tuple is typed.

Returns
TRUE if ok
Parameters
tuplein: tuple

Definition at line 170 of file data0data.cc.

References dtuple_get_n_fields().

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 in: tuple 2

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

Definition at line 91 of file data0data.cc.

References cmp_dfield_dfield(), dtuple_check_typed(), dtuple_get_n_fields(), and ut_ad.

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 in: dtuple

Referenced by row_search_for_mysql().

UNIV_INTERN void dtuple_convert_back_big_rec ( dict_index_t ,
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. in, own: big rec vector; it is freed in this function

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
entryin: entry whose data was put to vector
vectorin, own: big rec vector; it is freed in this function

Definition at line 768 of file data0data.cc.

References BTR_EXTERN_FIELD_REF_SIZE, big_rec_field_struct::data, dfield_get_len(), dfield_is_ext(), dfield_set_data(), DICT_MAX_INDEX_COL_LEN, big_rec_field_struct::field_no, big_rec_struct::fields, big_rec_struct::heap, big_rec_field_struct::len, mem_heap_free, big_rec_struct::n_fields, and ut_ad.

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 in/out: number of externally stored columns

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

Definition at line 566 of file data0data.cc.

References BTR_EXTERN_FIELD_REF_SIZE, dict_field_struct::col, big_rec_field_struct::data, dfield_get_len(), dfield_is_ext(), dfield_is_null(), dfield_set_data(), dfield_set_ext(), dict_index_get_n_fields(), dict_index_get_n_unique_in_tree(), dict_index_is_clust(), DICT_MAX_INDEX_COL_LEN, dict_table_get_format(), dict_table_is_comp(), dict_table_zip_size(), DICT_TF_FORMAT_ZIP, dtuple_get_n_fields(), big_rec_field_struct::field_no, big_rec_struct::fields, dict_field_struct::fixed_len, big_rec_struct::heap, dict_col_struct::len, big_rec_field_struct::len, mem_heap_alloc(), mem_heap_create, mem_heap_free, dict_col_struct::mtype, big_rec_struct::n_fields, page_zip_rec_needs_ext(), rec_get_converted_size(), dict_index_struct::table, ut_a, and ut_ad.

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 in: memory heap where the tuple is created
Parameters
tuplein: tuple to copy from

Referenced by row_undo_search_clust_to_pcur().

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 in: number of fields
Parameters
heapin: memory heap where the tuple is created

Referenced by dict_get_first_table_name_in_db(), dict_index_build_data_tuple(), dict_index_build_node_ptr(), dict_load_foreigns(), dict_load_table(), dict_load_table_on_id(), pars_insert_statement(), ha_innobase::records_in_range(), row_build(), row_build_index_entry(), row_build_row_ref(), row_create_prebuilt(), row_rec_to_index_entry_low(), row_truncate_table_for_mysql(), trx_undo_rec_get_partial_row(), and trx_undo_rec_get_row_ref().

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

Referenced by btr_search_guess_on_hash().

UNIV_INLINE const dtuple_t* dtuple_from_fields ( dtuple_t tuple,
const dfield_t fields,
ulint  n_fields 
)

Wrap data fields in a tuple. The default value for number of fields used in record comparisons for this tuple is n_fields.

Returns
data tuple in: number of fields
Parameters
tuplein: storage for data tuple
fieldsin: fields
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 in: nonzero=ROW_FORMAT=COMPACT
Parameters
tuplein: typed data tuple
UNIV_INLINE ulint dtuple_get_info_bits ( const dtuple_t tuple)

Gets info bits in a data tuple.

Returns
info bits in: tuple

Referenced by btr_root_raise_and_insert(), cmp_dtuple_rec_with_match(), and dict_index_build_node_ptr().

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 in: 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.* in: tuple

Referenced by cmp_dtuple_rec_with_match(), page_cur_search_with_match(), row_ins_check_foreign_constraint(), and row_search_for_mysql().

UNIV_INTERN void dtuple_print ( FILE *  f,
const dtuple_t tuple 
)

The following function prints the contents of a tuple. in: tuple

The following function prints the contents of a tuple.

Parameters
fin: output stream
tuplein: tuple

Definition at line 532 of file data0data.cc.

References dtuple_get_n_fields(), and ut_ad.

UNIV_INLINE void dtuple_set_info_bits ( dtuple_t tuple,
ulint  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. in: number of 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

Definition at line 132 of file data0data.cc.

References dtuple_struct::n_fields, dtuple_struct::n_fields_cmp, and ut_ad.

UNIV_INLINE void dtuple_set_n_fields_cmp ( dtuple_t tuple,
ulint  n_fields_cmp 
)

Gets number of fields used in record comparisons. in: number of fields used in comparisons in rem0cmp.*

Parameters
tuplein: tuple

Referenced by dict_index_build_node_ptr(), row_build_index_entry(), row_ins_check_foreign_constraint(), and row_rec_to_index_entry_low().

UNIV_INLINE void dtuple_set_types_binary ( dtuple_t tuple,
ulint  n 
)

Sets types of fields binary in a tuple. in: number of fields to set

Parameters
tuplein: data tuple

Referenced by dict_index_copy_types(), and row_vers_impl_x_locked_off_kernel().