本文整理汇总了C++中dfield_set_data函数的典型用法代码示例。如果您正苦于以下问题:C++ dfield_set_data函数的具体用法?C++ dfield_set_data怎么用?C++ dfield_set_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dfield_set_data函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trx_undo_rec_get_partial_row
byte*
trx_undo_rec_get_partial_row(
/*=========================*/
/* out: pointer to remaining part of undo
record */
byte* ptr, /* in: remaining part in update undo log
record of a suitable type, at the start of
the stored index columns;
NOTE that this copy of the undo log record must
be preserved as long as the partial row is
used, as we do NOT copy the data in the
record! */
dict_index_t* index, /* in: clustered index */
dtuple_t** row, /* out, own: partial row */
mem_heap_t* heap) /* in: memory heap from which the memory
needed is allocated */
{
dfield_t* dfield;
byte* field;
ulint len;
ulint field_no;
ulint col_no;
ulint row_len;
ulint total_len;
byte* start_ptr;
ulint i;
ut_ad(index && ptr && row && heap);
row_len = dict_table_get_n_cols(index->table);
*row = dtuple_create(heap, row_len);
dict_table_copy_types(*row, index->table);
start_ptr = ptr;
total_len = mach_read_from_2(ptr);
ptr += 2;
for (i = 0;; i++) {
if (ptr == start_ptr + total_len) {
break;
}
ptr = trx_undo_update_rec_get_field_no(ptr, &field_no);
col_no = dict_index_get_nth_col_no(index, field_no);
ptr = trx_undo_rec_get_col_val(ptr, &field, &len);
dfield = dtuple_get_nth_field(*row, col_no);
dfield_set_data(dfield, field, len);
}
return(ptr);
}
示例2: row_upd_clust_index_replace_new_col_vals
void
row_upd_clust_index_replace_new_col_vals(
/*=====================================*/
dtuple_t* entry, /* in/out: index entry where replaced */
upd_t* update) /* in: update vector */
{
upd_field_t* upd_field;
dfield_t* dfield;
dfield_t* new_val;
ulint field_no;
ulint i;
dtuple_set_info_bits(entry, update->info_bits);
for (i = 0; i < upd_get_n_fields(update); i++) {
upd_field = upd_get_nth_field(update, i);
field_no = upd_field->field_no;
dfield = dtuple_get_nth_field(entry, field_no);
new_val = &(upd_field->new_val);
dfield_set_data(dfield, new_val->data, new_val->len);
}
}
示例3: row_rec_to_index_entry
dtuple_t*
row_rec_to_index_entry(
/*===================*/
/* out, own: index entry built; see the
NOTE below! */
ulint type, /* in: ROW_COPY_DATA, or ROW_COPY_POINTERS:
the former copies also the data fields to
heap as the latter only places pointers to
data fields on the index page */
dict_index_t* index, /* in: index */
rec_t* rec, /* in: record in the index;
NOTE: in the case ROW_COPY_POINTERS
the data fields in the row will point
directly into this record, therefore,
the buffer page of this record must be
at least s-latched and the latch held
as long as the dtuple is used! */
mem_heap_t* heap) /* in: memory heap from which the memory
needed is allocated */
{
dtuple_t* entry;
dfield_t* dfield;
ulint i;
byte* field;
ulint len;
ulint rec_len;
byte* buf;
ut_ad(rec && heap && index);
if (type == ROW_COPY_DATA) {
/* Take a copy of rec to heap */
buf = mem_heap_alloc(heap, rec_get_size(rec));
rec = rec_copy(buf, rec);
}
rec_len = rec_get_n_fields(rec);
entry = dtuple_create(heap, rec_len);
dtuple_set_n_fields_cmp(entry,
dict_index_get_n_unique_in_tree(index));
ut_ad(rec_len == dict_index_get_n_fields(index));
dict_index_copy_types(entry, index, rec_len);
dtuple_set_info_bits(entry, rec_get_info_bits(rec));
for (i = 0; i < rec_len; i++) {
dfield = dtuple_get_nth_field(entry, i);
field = rec_get_nth_field(rec, i, &len);
dfield_set_data(dfield, field, len);
}
ut_ad(dtuple_check_typed(entry));
return(entry);
}
示例4: rec_copy_prefix_to_dtuple
void
rec_copy_prefix_to_dtuple(
/*======================*/
dtuple_t* tuple, /* in: data tuple */
rec_t* rec, /* in: physical record */
ulint n_fields, /* in: number of fields to copy */
mem_heap_t* heap) /* in: memory heap */
{
dfield_t* field;
byte* data;
ulint len;
byte* buf = NULL;
ulint i;
ut_ad(rec_validate(rec));
ut_ad(dtuple_check_typed(tuple));
dtuple_set_info_bits(tuple, rec_get_info_bits(rec));
for (i = 0; i < n_fields; i++) {
field = dtuple_get_nth_field(tuple, i);
data = rec_get_nth_field(rec, i, &len);
if (len != UNIV_SQL_NULL) {
buf = mem_heap_alloc(heap, len);
ut_memcpy(buf, data, len);
}
dfield_set_data(field, buf, len);
}
}
示例5: dfield_set_data_noninline
/* Some non-inlined functions used in the MySQL interface: */
void
dfield_set_data_noninline(
dfield_t* field, /* in: field */
void* data, /* in: data */
ulint len) /* in: length or UNIV_SQL_NULL */
{
dfield_set_data(field, data, len);
}
示例6: row_rec_to_index_entry_low
/*******************************************************************//**
Converts an index record to a typed data tuple.
@return index entry built; does not set info_bits, and the data fields
in the entry will point directly to rec */
UNIV_INTERN
dtuple_t*
row_rec_to_index_entry_low(
/*=======================*/
const rec_t* rec, /*!< in: record in the index */
const dict_index_t* index, /*!< in: index */
const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */
ulint* n_ext, /*!< out: number of externally
stored columns */
mem_heap_t* heap) /*!< in: memory heap from which
the memory needed is allocated */
{
dtuple_t* entry;
dfield_t* dfield;
ulint i;
const byte* field;
ulint len;
ulint rec_len;
ut_ad(rec && heap && index);
/* Because this function may be invoked by row0merge.c
on a record whose header is in different format, the check
rec_offs_validate(rec, index, offsets) must be avoided here. */
ut_ad(n_ext);
*n_ext = 0;
rec_len = rec_offs_n_fields(offsets);
entry = dtuple_create(heap, rec_len);
dtuple_set_n_fields_cmp(entry,
dict_index_get_n_unique_in_tree(index));
ut_ad(rec_len == dict_index_get_n_fields(index));
dict_index_copy_types(entry, index, rec_len);
for (i = 0; i < rec_len; i++) {
dfield = dtuple_get_nth_field(entry, i);
field = rec_get_nth_field(rec, offsets, i, &len);
dfield_set_data(dfield, field, len);
if (rec_offs_nth_extern(offsets, i)) {
dfield_set_ext(dfield);
(*n_ext)++;
}
}
ut_ad(dtuple_check_typed(entry));
return(entry);
}
示例7: row_build_to_tuple
void
row_build_to_tuple(
/*===============*/
dtuple_t* row, /* in/out: row built; see the NOTE below! */
dict_index_t* index, /* in: clustered index */
rec_t* rec) /* in: record in the clustered index;
NOTE: the data fields in the row will point
directly into this record, therefore,
the buffer page of this record must be
at least s-latched and the latch held
as long as the row dtuple is used!
NOTE 2: does not work with externally
stored fields! */
{
dict_table_t* table;
ulint n_fields;
ulint i;
dfield_t* dfield;
byte* field;
ulint len;
ulint row_len;
dict_col_t* col;
ut_ad(index && rec);
ut_ad(index->type & DICT_CLUSTERED);
table = index->table;
row_len = dict_table_get_n_cols(table);
dtuple_set_info_bits(row, rec_get_info_bits(rec));
n_fields = dict_index_get_n_fields(index);
ut_ad(n_fields == rec_get_n_fields(rec));
dict_table_copy_types(row, table);
for (i = 0; i < n_fields; i++) {
col = dict_field_get_col(dict_index_get_nth_field(index, i));
dfield = dtuple_get_nth_field(row, dict_col_get_no(col));
field = rec_get_nth_field(rec, i, &len);
dfield_set_data(dfield, field, len);
}
ut_ad(dtuple_check_typed(row));
}
示例8: sym_tab_add_str_lit
/******************************************************************//**
Adds a string literal to a symbol table.
@return symbol table node */
UNIV_INTERN
sym_node_t*
sym_tab_add_str_lit(
/*================*/
sym_tab_t* sym_tab, /*!< in: symbol table */
byte* str, /*!< in: string with no quotes around
it */
ulint len) /*!< in: string length */
{
sym_node_t* node;
byte* data;
node = mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t));
node->common.type = QUE_NODE_SYMBOL;
node->resolved = TRUE;
node->token_type = SYM_LIT;
node->indirection = NULL;
dtype_set(dfield_get_type(&node->common.val),
DATA_VARCHAR, DATA_ENGLISH, 0);
if (len) {
data = mem_heap_alloc(sym_tab->heap, len);
ut_memcpy(data, str, len);
} else {
data = NULL;
}
dfield_set_data(&(node->common.val), data, len);
node->common.val_buf_size = 0;
node->prefetch_buf = NULL;
node->cursor_def = NULL;
UT_LIST_ADD_LAST(sym_list, sym_tab->sym_list, node);
node->sym_table = sym_tab;
return(node);
}
示例9: row_upd_index_replace_new_col_vals
void
row_upd_index_replace_new_col_vals(
/*===============================*/
dtuple_t* entry, /* in/out: index entry where replaced */
dict_index_t* index, /* in: index; NOTE that may also be a
non-clustered index */
upd_t* update) /* in: update vector */
{
upd_field_t* upd_field;
dfield_t* dfield;
dfield_t* new_val;
ulint field_no;
dict_index_t* clust_index;
ulint i;
ut_ad(index);
clust_index = dict_table_get_first_index(index->table);
dtuple_set_info_bits(entry, update->info_bits);
for (i = 0; i < upd_get_n_fields(update); i++) {
upd_field = upd_get_nth_field(update, i);
field_no = dict_index_get_nth_col_pos(index,
dict_index_get_nth_col_no(clust_index,
upd_field->field_no));
if (field_no != ULINT_UNDEFINED) {
dfield = dtuple_get_nth_field(entry, field_no);
new_val = &(upd_field->new_val);
dfield_set_data(dfield, new_val->data, new_val->len);
}
}
}
示例10: sym_tab_add_int_lit
/******************************************************************//**
Adds an integer literal to a symbol table.
@return symbol table node */
UNIV_INTERN
sym_node_t*
sym_tab_add_int_lit(
/*================*/
sym_tab_t* sym_tab, /*!< in: symbol table */
ulint val) /*!< in: integer value */
{
sym_node_t* node;
byte* data;
node = mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t));
node->common.type = QUE_NODE_SYMBOL;
node->resolved = TRUE;
node->token_type = SYM_LIT;
node->indirection = NULL;
dtype_set(dfield_get_type(&node->common.val), DATA_INT, 0, 4);
data = mem_heap_alloc(sym_tab->heap, 4);
mach_write_to_4(data, val);
dfield_set_data(&(node->common.val), data, 4);
node->common.val_buf_size = 0;
node->prefetch_buf = NULL;
node->cursor_def = NULL;
UT_LIST_ADD_LAST(sym_list, sym_tab->sym_list, node);
node->sym_table = sym_tab;
return(node);
}
示例11: dict_load_foreign
/***************************************************************************
Loads a foreign key constraint to the dictionary cache. */
static
ulint
dict_load_foreign(
/*==============*/
/* out: DB_SUCCESS or error code */
char* id) /* in: foreign constraint id as a null-terminated
string */
{
dict_foreign_t* foreign;
dict_table_t* sys_foreign;
btr_pcur_t pcur;
dict_index_t* sys_index;
dtuple_t* tuple;
mem_heap_t* heap2;
dfield_t* dfield;
rec_t* rec;
byte* field;
ulint len;
ulint err;
mtr_t mtr;
ut_ad(mutex_own(&(dict_sys->mutex)));
heap2 = mem_heap_create(1000);
mtr_start(&mtr);
sys_foreign = dict_table_get_low("SYS_FOREIGN");
sys_index = UT_LIST_GET_FIRST(sys_foreign->indexes);
tuple = dtuple_create(heap2, 1);
dfield = dtuple_get_nth_field(tuple, 0);
dfield_set_data(dfield, id, ut_strlen(id));
dict_index_copy_types(tuple, sys_index, 1);
btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE,
BTR_SEARCH_LEAF, &pcur, &mtr);
rec = btr_pcur_get_rec(&pcur);
if (!btr_pcur_is_on_user_rec(&pcur, &mtr)
|| rec_get_deleted_flag(rec)) {
/* Not found */
fprintf(stderr,
"InnoDB: Error A: cannot load foreign constraint %s\n", id);
btr_pcur_close(&pcur);
mtr_commit(&mtr);
mem_heap_free(heap2);
return(DB_ERROR);
}
field = rec_get_nth_field(rec, 0, &len);
/* Check if the id in record is the searched one */
if (len != ut_strlen(id) || ut_memcmp(id, field, len) != 0) {
fprintf(stderr,
"InnoDB: Error B: cannot load foreign constraint %s\n", id);
btr_pcur_close(&pcur);
mtr_commit(&mtr);
mem_heap_free(heap2);
return(DB_ERROR);
}
/* Read the table names and the number of columns associated
with the constraint */
mem_heap_free(heap2);
foreign = dict_mem_foreign_create();
foreign->n_fields = mach_read_from_4(rec_get_nth_field(rec, 5, &len));
ut_a(len == 4);
foreign->id = mem_heap_alloc(foreign->heap, ut_strlen(id) + 1);
ut_memcpy(foreign->id, id, ut_strlen(id) + 1);
field = rec_get_nth_field(rec, 3, &len);
foreign->foreign_table_name = mem_heap_alloc(foreign->heap, 1 + len);
ut_memcpy(foreign->foreign_table_name, field, len);
foreign->foreign_table_name[len] = '\0';
field = rec_get_nth_field(rec, 4, &len);
foreign->referenced_table_name = mem_heap_alloc(foreign->heap, 1 + len);
ut_memcpy(foreign->referenced_table_name, field, len);
foreign->referenced_table_name[len] = '\0';
//.........这里部分代码省略.........
示例12: dtuple_convert_big_rec
//.........这里部分代码省略.........
/* Decide which fields to shorten: the algorithm is to look for
a variable-length field that yields the biggest savings when
stored externally */
n_fields = 0;
while (page_zip_rec_needs_ext(rec_get_converted_size(index, entry,
*n_ext),
dict_table_is_comp(index->table),
dict_index_get_n_fields(index),
dict_table_zip_size(index->table))) {
ulint i;
ulint longest = 0;
ulint longest_i = ULINT_MAX;
byte* data;
big_rec_field_t* b;
for (i = dict_index_get_n_unique_in_tree(index);
i < dtuple_get_n_fields(entry); i++) {
ulint savings;
dfield = dtuple_get_nth_field(entry, i);
ifield = dict_index_get_nth_field(index, i);
/* Skip fixed-length, NULL, externally stored,
or short columns */
if (ifield->fixed_len
|| dfield_is_null(dfield)
|| dfield_is_ext(dfield)
|| dfield_get_len(dfield) <= local_len
|| dfield_get_len(dfield)
<= BTR_EXTERN_FIELD_REF_SIZE * 2) {
goto skip_field;
}
savings = dfield_get_len(dfield) - local_len;
/* Check that there would be savings */
if (longest >= savings) {
goto skip_field;
}
longest_i = i;
longest = savings;
skip_field:
continue;
}
if (!longest) {
/* Cannot shorten more */
mem_heap_free(heap);
return(NULL);
}
/* Move data from field longest_i to big rec vector.
We store the first bytes locally to the record. Then
we can calculate all ordering fields in all indexes
from locally stored data. */
dfield = dtuple_get_nth_field(entry, longest_i);
ifield = dict_index_get_nth_field(index, longest_i);
local_prefix_len = local_len - BTR_EXTERN_FIELD_REF_SIZE;
b = &vector->fields[n_fields];
b->field_no = longest_i;
b->len = dfield_get_len(dfield) - local_prefix_len;
b->data = (char*) dfield_get_data(dfield) + local_prefix_len;
/* Allocate the locally stored part of the column. */
data = mem_heap_alloc(heap, local_len);
/* Copy the local prefix. */
memcpy(data, dfield_get_data(dfield), local_prefix_len);
/* Clear the extern field reference (BLOB pointer). */
memset(data + local_prefix_len, 0, BTR_EXTERN_FIELD_REF_SIZE);
#if 0
/* The following would fail the Valgrind checks in
page_cur_insert_rec_low() and page_cur_insert_rec_zip().
The BLOB pointers in the record will be initialized after
the record and the BLOBs have been written. */
UNIV_MEM_ALLOC(data + local_prefix_len,
BTR_EXTERN_FIELD_REF_SIZE);
#endif
dfield_set_data(dfield, data, local_len);
dfield_set_ext(dfield);
n_fields++;
(*n_ext)++;
ut_ad(n_fields < dtuple_get_n_fields(entry));
}
vector->n_fields = n_fields;
return(vector);
}
示例13: row_build_row_ref
dtuple_t*
row_build_row_ref(
/*==============*/
/* out, own: row reference built; see the
NOTE below! */
ulint type, /* in: ROW_COPY_DATA, or ROW_COPY_POINTERS:
the former copies also the data fields to
heap, whereas the latter only places pointers
to data fields on the index page */
dict_index_t* index, /* in: index */
rec_t* rec, /* in: record in the index;
NOTE: in the case ROW_COPY_POINTERS
the data fields in the row will point
directly into this record, therefore,
the buffer page of this record must be
at least s-latched and the latch held
as long as the row reference is used! */
mem_heap_t* heap) /* in: memory heap from which the memory
needed is allocated */
{
dict_table_t* table;
dict_index_t* clust_index;
dfield_t* dfield;
dtuple_t* ref;
byte* field;
ulint len;
ulint ref_len;
ulint pos;
byte* buf;
ulint i;
ut_ad(index && rec && heap);
if (type == ROW_COPY_DATA) {
/* Take a copy of rec to heap */
buf = mem_heap_alloc(heap, rec_get_size(rec));
rec = rec_copy(buf, rec);
}
table = index->table;
clust_index = dict_table_get_first_index(table);
ref_len = dict_index_get_n_unique(clust_index);
ref = dtuple_create(heap, ref_len);
dict_index_copy_types(ref, clust_index, ref_len);
for (i = 0; i < ref_len; i++) {
dfield = dtuple_get_nth_field(ref, i);
pos = dict_index_get_nth_field_pos(index, clust_index, i);
ut_a(pos != ULINT_UNDEFINED);
field = rec_get_nth_field(rec, pos, &len);
dfield_set_data(dfield, field, len);
}
ut_ad(dtuple_check_typed(ref));
return(ref);
}
示例14: dict_create_sys_columns_tuple
/*********************************************************************
Based on a table object, this function builds the entry to be inserted
in the SYS_COLUMNS system table. */
static
dtuple_t*
dict_create_sys_columns_tuple(
/*==========================*/
/* out: the tuple which should be inserted */
dict_table_t* table, /* in: table */
ulint i, /* in: column number */
mem_heap_t* heap) /* in: memory heap from which the memory for
the built tuple is allocated */
{
dict_table_t* sys_columns;
dtuple_t* entry;
const dict_col_t* column;
dfield_t* dfield;
byte* ptr;
const char* col_name;
ut_ad(table && heap);
column = dict_table_get_nth_col(table, i);
sys_columns = dict_sys->sys_columns;
entry = dtuple_create(heap, 7 + DATA_N_SYS_COLS);
/* 0: TABLE_ID -----------------------*/
dfield = dtuple_get_nth_field(entry, 0);
ptr = mem_heap_alloc(heap, 8);
mach_write_to_8(ptr, table->id);
dfield_set_data(dfield, ptr, 8);
/* 1: POS ----------------------------*/
dfield = dtuple_get_nth_field(entry, 1);
ptr = mem_heap_alloc(heap, 4);
mach_write_to_4(ptr, i);
dfield_set_data(dfield, ptr, 4);
/* 4: NAME ---------------------------*/
dfield = dtuple_get_nth_field(entry, 2);
col_name = dict_table_get_col_name(table, i);
dfield_set_data(dfield, col_name, ut_strlen(col_name));
/* 5: MTYPE --------------------------*/
dfield = dtuple_get_nth_field(entry, 3);
ptr = mem_heap_alloc(heap, 4);
mach_write_to_4(ptr, column->mtype);
dfield_set_data(dfield, ptr, 4);
/* 6: PRTYPE -------------------------*/
dfield = dtuple_get_nth_field(entry, 4);
ptr = mem_heap_alloc(heap, 4);
mach_write_to_4(ptr, column->prtype);
dfield_set_data(dfield, ptr, 4);
/* 7: LEN ----------------------------*/
dfield = dtuple_get_nth_field(entry, 5);
ptr = mem_heap_alloc(heap, 4);
mach_write_to_4(ptr, column->len);
dfield_set_data(dfield, ptr, 4);
/* 8: PREC ---------------------------*/
dfield = dtuple_get_nth_field(entry, 6);
ptr = mem_heap_alloc(heap, 4);
mach_write_to_4(ptr, 0/* unused */);
dfield_set_data(dfield, ptr, 4);
/*---------------------------------*/
dict_table_copy_types(entry, sys_columns);
return(entry);
}
示例15: dict_create_sys_tables_tuple
/*********************************************************************
Based on a table object, this function builds the entry to be inserted
in the SYS_TABLES system table. */
static
dtuple_t*
dict_create_sys_tables_tuple(
/*=========================*/
/* out: the tuple which should be inserted */
dict_table_t* table, /* in: table */
mem_heap_t* heap) /* in: memory heap from which the memory for
the built tuple is allocated */
{
dict_table_t* sys_tables;
dtuple_t* entry;
dfield_t* dfield;
byte* ptr;
ut_ad(table && heap);
sys_tables = dict_sys->sys_tables;
entry = dtuple_create(heap, 8 + DATA_N_SYS_COLS);
/* 0: NAME -----------------------------*/
dfield = dtuple_get_nth_field(entry, 0);
dfield_set_data(dfield, table->name, ut_strlen(table->name));
/* 3: ID -------------------------------*/
dfield = dtuple_get_nth_field(entry, 1);
ptr = mem_heap_alloc(heap, 8);
mach_write_to_8(ptr, table->id);
dfield_set_data(dfield, ptr, 8);
/* 4: N_COLS ---------------------------*/
dfield = dtuple_get_nth_field(entry, 2);
#if DICT_TF_COMPACT != 1
#error
#endif
ptr = mem_heap_alloc(heap, 4);
mach_write_to_4(ptr, table->n_def
| ((table->flags & DICT_TF_COMPACT) << 31));
dfield_set_data(dfield, ptr, 4);
/* 5: TYPE -----------------------------*/
dfield = dtuple_get_nth_field(entry, 3);
ptr = mem_heap_alloc(heap, 4);
mach_write_to_4(ptr, DICT_TABLE_ORDINARY);
dfield_set_data(dfield, ptr, 4);
/* 6: MIX_ID (obsolete) ---------------------------*/
dfield = dtuple_get_nth_field(entry, 4);
ptr = mem_heap_alloc(heap, 8);
memset(ptr, 0, 8);
dfield_set_data(dfield, ptr, 8);
/* 7: MIX_LEN (obsolete) --------------------------*/
dfield = dtuple_get_nth_field(entry, 5);
ptr = mem_heap_alloc(heap, 4);
memset(ptr, 0, 4);
dfield_set_data(dfield, ptr, 4);
/* 8: CLUSTER_NAME ---------------------*/
dfield = dtuple_get_nth_field(entry, 6);
dfield_set_data(dfield, NULL, UNIV_SQL_NULL); /* not supported */
/* 9: SPACE ----------------------------*/
dfield = dtuple_get_nth_field(entry, 7);
ptr = mem_heap_alloc(heap, 4);
mach_write_to_4(ptr, table->space);
dfield_set_data(dfield, ptr, 4);
/*----------------------------------*/
dict_table_copy_types(entry, sys_tables);
return(entry);
}