[MDEV-8177] Remove Lex_input_stream::m_cpp_buf Created: 2015-05-18  Updated: 2021-05-11

Status: Open
Project: MariaDB Server
Component/s: Parser
Fix Version/s: None

Type: Task Priority: Minor
Reporter: Alexander Barkov Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: performance, refactoring


 Description   

We can try to get rid of all m_cpp_xxx members in Lex_input_stream.
It seems that the main purpose for these members is to cut comments from SELECT list item names:

MariaDB [test]> SELECT 1 /* +2 */ + 3;
+--------+
| 1  + 3 |
+--------+
|      4 |
+--------+
1 row in set (4.69 sec)

Notice, the column name does not include the comment part.

The current code copies the original query into m_cpp_buf (removing comments on the way), so the second copy of the original query is always created. This affects performance negatively.

Moreover, in most cases queries do not have comments at all.

Related pieces of the code:

  void skip_binary(int n)
  {
    if (m_echo)
    {
      memcpy(m_cpp_ptr, m_ptr, n);
      m_cpp_ptr += n;
    }
    m_ptr += n;
  }
 
 ...
 
 
  unsigned char yyGet()
  {  
    char c= *m_ptr++;
    if (m_echo)
      *m_cpp_ptr++ = c;
    return c;  
  }
 
  ...
  void yySkipn(int n)
  {
    if (m_echo)
    {
      memcpy(m_cpp_ptr, m_ptr, n);
      m_cpp_ptr += n;
    }
    m_ptr += n;
  }
 


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