Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-19533

Add methods make() and append_uniq() to Row_definition_list

    Details

    • Type: Task
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Fix Version/s: 10.4.6
    • Component/s: Parser
    • Labels:
      None

      Description

      There is a duplicate code in sql_yacc.yy and sql_yacc_ora.yy related to ROW variable defintion:

      row_field_name:
                ident // or ident_directly_assignable
                {
                  if (unlikely(check_string_char_length(&$1, 0, NAME_CHAR_LEN,
                                                        system_charset_info, 1)))
                    my_yyabort_error((ER_TOO_LONG_IDENT, MYF(0), $1.str));
                  if (unlikely(!($$= new (thd->mem_root) Spvar_definition())))
                    MYSQL_YYABORT;
                  Lex->init_last_field($$, &$1, thd->variables.collation_database);
                }
              ;
       
      row_field_definition_list:
                row_field_definition
                {
                  if (unlikely(!($$= new (thd->mem_root) Row_definition_list())) ||
                      unlikely($$->push_back($1, thd->mem_root)))
                    MYSQL_YYABORT;
                }
              | row_field_definition_list ',' row_field_definition
                {
                  uint unused;
                  if (unlikely($1->find_row_field_by_name(&$3->field_name, &unused)))
                    my_yyabort_error((ER_DUP_FIELDNAME, MYF(0), $3->field_name.str));
                  $$= $1;
                  if (unlikely($$->push_back($3, thd->mem_root)))
                    MYSQL_YYABORT;
                }
              ;
      

      There is a difference though:

      • in sql_yacc.yy row_field_name is defined as ident
      • in sql_yacc_ora.yy row_field_name is defined as ident_directly_assignable

      In order to join the two *.yy files easier, let's move the C++ code into new Row_definition_list methods and simplify the grammar as follows:

      row_field_name:
                ident  // or ident_directly_assignable
                {
                  if (!($$= Lex->row_field_name(thd, $1)))
                    MYSQL_YYABORT;
                }
              ;
       
      row_field_definition_list:
                row_field_definition
                {
                  if (!($$= Row_definition_list::make(thd->mem_root, $1)))
                    MYSQL_YYABORT;
                }
              | row_field_definition_list ',' row_field_definition
                {
                  if (($$= $1)->append_uniq(thd->mem_root, $3))
                    MYSQL_YYABORT;
                }
              ;
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                bar Alexander Barkov
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: