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

Add methods make() and append_uniq() to Row_definition_list

    XMLWordPrintable

Details

    • Task
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.4.6
    • Parser
    • 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

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

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.