| 1609 | */ |
| 1610 | |
| 1611 | static bool prepare_blob_field(THD *thd, Create_field *sql_field) |
| 1612 | { |
| 1613 | DBUG_ENTER("prepare_blob_field"); |
| 1614 | |
| 1615 | if (sql_field->length > MAX_FIELD_VARCHARLENGTH && |
| 1616 | !(sql_field->flags & BLOB_FLAG)) |
| 1617 | { |
| 1618 | /* Convert long VARCHAR columns to TEXT or BLOB */ |
| 1619 | char warn_buff[MYSQL_ERRMSG_SIZE]; |
| 1620 | |
| 1621 | if (sql_field->def || thd->is_strict_mode()) |
| 1622 | { |
| 1623 | my_error(ER_TOO_BIG_FIELDLENGTH, MYF(0), sql_field->field_name, |
| 1624 | static_cast<ulong>(MAX_FIELD_VARCHARLENGTH / |
| 1625 | sql_field->charset->mbmaxlen)); |
| 1626 | DBUG_RETURN(1); |
| 1627 | } |
| 1628 | sql_field->sql_type= MYSQL_TYPE_BLOB; |
| 1629 | sql_field->flags|= BLOB_FLAG; |
| 1630 | my_snprintf(warn_buff, sizeof(warn_buff), ER(ER_AUTO_CONVERT), sql_field->field_name, |
| 1631 | (sql_field->charset == &my_charset_bin) ? "VARBINARY" : "VARCHAR", |
| 1632 | (sql_field->charset == &my_charset_bin) ? "BLOB" : "TEXT"); |
| 1633 | push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, ER_AUTO_CONVERT, |
| 1634 | warn_buff); |
| 1635 | } |
| 1636 | |
| 1637 | if ((sql_field->flags & BLOB_FLAG) && sql_field->length) |
| 1638 | { |
| 1639 | if (sql_field->sql_type == FIELD_TYPE_BLOB || |
| 1640 | sql_field->sql_type == FIELD_TYPE_TINY_BLOB || |
| 1641 | sql_field->sql_type == FIELD_TYPE_MEDIUM_BLOB) |
| 1642 | { |
| 1643 | /* The user has given a length to the blob column */ |
| 1644 | sql_field->sql_type= get_blob_type_from_length(sql_field->length); |
| 1645 | sql_field->pack_length= calc_pack_length(sql_field->sql_type, 0); |
| 1646 | } |
| 1647 | sql_field->length= 0; |
| 1648 | } |
| 1649 | DBUG_RETURN(0); |
| 1650 | } |
| 1651 | |
| 1652 | |
| 1653 | /* |
no test coverage detected