/**********************************************************************//** This function populates a dict_col_t memory structure with supplied information. */ UNIV_INTERN void dict_mem_fill_column_struct( /*========================*/ dict_col_t* column, /*!< out: column struct to be filled */ ulint col_pos, /*!< in: column position */ ulint mtype, /*!< in: main data type */ ulint prtype, /*!< in: precise type */ ulint col_len) /*!< in: column length */ { #ifndef UNIV_HOTBACKUP ulint mbminlen; ulint mbmaxlen; #endif /* !UNIV_HOTBACKUP */ column->ind = (unsigned int) col_pos; column->ord_part = 0; column->max_prefix = 0; column->mtype = (unsigned int) mtype; column->prtype = (unsigned int) prtype; column->len = (unsigned int) col_len; #ifndef UNIV_HOTBACKUP dtype_get_mblen(mtype, prtype, &mbminlen, &mbmaxlen); dict_col_set_mbminmaxlen(column, mbminlen, mbmaxlen); #endif /* !UNIV_HOTBACKUP */ }
/**********************************************************************//** Adds a column definition to a table. */ UNIV_INTERN void dict_mem_table_add_col( /*===================*/ dict_table_t* table, /*!< in: table */ mem_heap_t* heap, /*!< in: temporary memory heap, or NULL */ const char* name, /*!< in: column name, or NULL */ ulint mtype, /*!< in: main datatype */ ulint prtype, /*!< in: precise type */ ulint len) /*!< in: precision */ { dict_col_t* col; #ifndef UNIV_HOTBACKUP ulint mbminlen; ulint mbmaxlen; #endif /* !UNIV_HOTBACKUP */ ulint i; ut_ad(table); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); ut_ad(!heap == !name); i = table->n_def++; if (name) { if (UNIV_UNLIKELY(table->n_def == table->n_cols)) { heap = table->heap; } if (UNIV_LIKELY(i) && UNIV_UNLIKELY(!table->col_names)) { /* All preceding column names are empty. */ char* s = mem_heap_zalloc(heap, table->n_def); table->col_names = s; } table->col_names = dict_add_col_name(table->col_names, i, name, heap); } col = dict_table_get_nth_col(table, i); col->ind = (unsigned int) i; col->ord_part = 0; col->mtype = (unsigned int) mtype; col->prtype = (unsigned int) prtype; col->len = (unsigned int) len; #ifndef UNIV_HOTBACKUP dtype_get_mblen(mtype, prtype, &mbminlen, &mbmaxlen); col->mbminlen = (unsigned int) mbminlen; col->mbmaxlen = (unsigned int) mbmaxlen; #endif /* !UNIV_HOTBACKUP */ }