MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / sp_prepare_create_field

Function sp_prepare_create_field

sql/sql_table.cc:1668–1701  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1666*/
1667
1668static void sp_prepare_create_field(THD *thd, Create_field *sql_field)
1669{
1670 if (sql_field->sql_type == MYSQL_TYPE_SET ||
1671 sql_field->sql_type == MYSQL_TYPE_ENUM)
1672 {
1673 uint32 field_length, dummy;
1674 if (sql_field->sql_type == MYSQL_TYPE_SET)
1675 {
1676 calculate_interval_lengths(sql_field->charset,
1677 sql_field->interval, &dummy,
1678 &field_length);
1679 sql_field->length= field_length +
1680 (sql_field->interval->count - 1);
1681 }
1682 else /* MYSQL_TYPE_ENUM */
1683 {
1684 calculate_interval_lengths(sql_field->charset,
1685 sql_field->interval,
1686 &field_length, &dummy);
1687 sql_field->length= field_length;
1688 }
1689 set_if_smaller(sql_field->length, MAX_FIELD_WIDTH-1);
1690 }
1691
1692 if (sql_field->sql_type == MYSQL_TYPE_BIT)
1693 {
1694 sql_field->pack_flag= FIELDFLAG_NUMBER |
1695 FIELDFLAG_TREAT_BIT_AS_CHAR;
1696 }
1697 sql_field->create_length_to_internal_length();
1698 DBUG_ASSERT(sql_field->def == 0);
1699 /* Can't go wrong as sql_field->def is not defined */
1700 (void) prepare_blob_field(thd, sql_field);
1701}

Callers 1

fill_field_definitionFunction · 0.85

Calls 3

prepare_blob_fieldFunction · 0.85

Tested by

no test coverage detected