[MDEV-20706] Store scale in Column_definition::decimals rather than Column_definition::pack_flag Created: 2019-10-01  Updated: 2019-10-04  Resolved: 2019-10-01

Status: Closed
Project: MariaDB Server
Component/s: Data types
Fix Version/s: 10.5.0

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

 Description   

In order to simplify the unification of these Type_handler methods:

   virtual Field *make_table_field(MEM_ROOT *root,
                                  const LEX_CSTRING *name,
                                  const Record_addr &addr,
                                  const Type_all_attributes &attr,
                                  TABLE *table) const= 0;

and

  virtual Field *
  make_table_field_from_def(TABLE_SHARE *share,
                            MEM_ROOT *mem_root,
                            const LEX_CSTRING *name,
                            const Record_addr &addr,
                            const Bit_addr &bit,
                            const Column_definition_attributes *attr,
                            uint32 flags) const= 0;

let's do the following:

  • Move Column_definition::decimals to the parent class Column_definition_attributes
  • When loading a column definition from a FRM file, instead of mixing numeric scale to Column_definition_attributes::pack_flag, store it to Column_definition_attributes::decimals. This will be done in virtual implementation of Type_handler_xxx::Column_definition_attributes_frm_unpack().
  • Mix (decimals << FIELDFLAG_DEC_SHIFT) to pack_flag only before storing it to the FRM. This will be done in virtual implementation of Type_handler_xxx::Column_definition_attributes_frm_pack().

As a result:

  • Column_definition_attributes::decimals will always be up-to-date.
  • Column_definition_attributes::pack_flag will never contain the decimal scale

Generated at Thu Feb 08 09:01:33 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.