[MDEV-8092] Change Column_definition::field_name from "const char *" to LEX_CSTRING Created: 2015-05-04  Updated: 2017-05-27  Resolved: 2017-05-27

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

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

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed
blocks MDEV-8095 Split Create_field Open
Sprint: 10.2.0-3

 Description   

This is needed as a pre-requisite for a few other tasks.
Create_field::field_name and Field::field_name will be changed from "const char *" to a LEX_CSTRNG-alike structure, so both pointer and length are stored.

This will help to:
1. Avoid strlen() in some cases
2. Put typical operations that are done on field names into method, to reuse the code (e.g. name comparision)
3. Improve performance of name comparison. Currently field names are compared as follows:

  if (!my_strcasecmp(system_charset_info, field->field_name, other->field_name))
  {
   // handle fields with equal names
  }

If we store length, the method comparing names could immediately return false if lengths are different.
4. Simplify sql_yacc.yy, so data in various formats (LEX_CSTRING, LEX_STRING, const char *) will be easier to reuse.
(in separate tasks)
5. Make Field and Create_field closer to sp_variable, which is useful for the data type handlers. All these three classes could share some members and methods.

Note, under terms of this task we won't change Item::name. It still will be of type "const char *".
That means that we'll have to use strlen(item->name) when creating a Create_field or a Field from Item.
This is Okey for now, in long terms we'll change Item::name as well and get rid of strlen().



 Comments   
Comment by Alexander Barkov [ 2017-05-27 ]

This was done as a part of Monty's patch, fixing many members in many structured to LEX_CSTRING.

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