[MDEV-15971] Split the code for CHARACTER_OCTET_LENGTH and CHARACTER_MAXIMUM_LENGTH into methods in Field Created: 2018-04-22  Updated: 2018-04-22  Resolved: 2018-04-22

Status: Closed
Project: MariaDB Server
Component/s: Data types, Information Schema
Fix Version/s: 10.3.7

Type: Task Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed
Relates
relates to MDEV-13232 Assertion `(&(&share->intern_lock)->m... Closed

 Description   

The code in sql_show.cc displaying INFORMATION_SCHEMA.COLUMNS.CHARACTER_OCTET_LENGTH and INFORMATION_SCHEMA.COLUMNS.CHARACTER_MAXIMUM_LENGTH:

  • tests field->type() and field->real_type() for various hard-coded constant MYSQL_TYPE_XXX
  • uses max_display_length() with special tricks for the BLOB data types, e.g.:

      uint32 octet_max_length= field->max_display_length();
      if (is_blob && octet_max_length != (uint32) UINT_MAX32)
        octet_max_length /= field->charset()->mbmaxlen;
    

    where the test for UINT_MAX32 is a workaround to address a special behavior of Field_blob::max_display_length() for LONGBLOB.

  • Uses has_charset() to detect data types which need NULL to be displayed in the mentioned I_S columns.

This is non friendly to pluggable data types.

Also, this makes it hard to fix bugs in max_display_length().

Under terms of this task we'll move the code in sql_show.cc into a new virtual method in Field:

  virtual Information_schema_character_attributes
    information_schema_character_attributes();

where Information_schema_character_attributes is a new class with approximately this structure:

class Information_schema_character_attributes
{
  uint32 m_octet_length;
  uint32 m_char_length;
  bool m_has_octet_length;
  bool m_has_char_length;
public:
  .. constructors and access methods ..
}


Generated at Thu Feb 08 08:25:24 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.