[MDEV-27712] Reduce the size of Lex_length_and_dec_st from 16 to 8 Created: 2022-02-01  Updated: 2022-03-23  Resolved: 2022-03-23

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

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

Issue Links:
Relates
relates to MDEV-27009 Add UCA-14.0.0 collations Closed

 Description   

We want to use Bison stack more efficiently and pass more structures through the stack instead of using Lex members.

In particular, we want to get rid of Lex->charset. This change is really overdue.

To be able to do this, we want to pass through the Bison stack a structure with data type handler and its basic attributes, consisting of the following four members:

struct {
  const Type_handler *handler;
  CHARSET_INFO *charset;
  Lex_length_and_dec_st length_and_dec;
};

This structure should fit into the Bison variable limitation (see sql_yacc.yy):

/* avoid unintentional %union size increases, it's what a parser stack made of */
static_assert(sizeof(YYSTYPE) == sizeof(void*)*2+8, "%union size check");

Currently this structure would not fit because Lex_length_and_dec_st consists of two pointers and therefore occupies 16 bytes (on 64bit platforms):

struct Lex_length_and_dec_st
{
private:
  const char *m_length;
  const char *m_dec;
public:

Let's reduce the size of Lex_length_and_dec_st from current 16 bytes as follows:

struct Lex_length_and_dec_st
{
private:
  uint32 m_length;
  uint8  m_dec;
  bool   m_has_explicit_length:1;
  bool   m_has_explicit_dec:1;
public:

After this change, the future structure consisting of the four fields (mentioned above) will occupy 24 bytes:

struct {
  const Type_handler *handler;          // 8 bytes
  CHARSET_INFO *charset;                // 8 bytes
  Lex_length_and_dec_st length_and_dec; // 8 bytes
};

Note, this task is only about changing Lex_length_and_dec_st. The new structure (with handler, charset, length and dec) will be added later, under terms of a separate task.


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