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

Unify grammar rules: field_type_string and sp_param_field_type_string

    XMLWordPrintable

    Details

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

      Description

      sql_yacc_ora.yy has two separate set of rules to parse data types:

      • field_type, field_type_string - for table fields and SP local variables
      • sp_param_field_type, sp_param_field_type_string - SP parameters and SF return values

      Let's remove the second set of rules and use field_type/field_type_string for in all cases.
      Advantages:

      • Unification of sql_yacc.yy and sql_yacc_ora.yy
      • Move more code from the *.yy files to Type_handler, so data type plugins have more flexibility.

      In order to move the code from *.yy to Type_handler, let's introduce this enum:

      enum column_definition_type_t
      {
        COLUMN_DEFINITION_TABLE_FIELD,
        COLUMN_DEFINITION_ROUTINE_PARAM,
        COLUMN_DEFINITION_ROUTINE_LOCAL,
        COLUMN_DEFINITION_FUNCTION_RETURN
      };
      

      and this virtual method:

      virtual bool Column_definition_set_attributes(THD *thd,
                                                    Column_definition *def,
                                                    const Lex_field_type_st &attr,
                                                    CHARSET_INFO *cs,
                                                    column_definition_type_t type)
                                                    const;
      

      So, for example, Type_handler_varchar::Column_definition_set_attributes() will do the following:

      • If the length is specified explictly, set def->length accordingly.
      • If the length is not specified explicitly, then
        • In case of a table field type and a local variable type it will return a syntax error
        • In case of an SP parameter type and an SF return type and sql_mode=DEFAULT, it will return a syntax error.
        • In case of an SP parameter type and sql_mode=ORACLE, it will set def in the way that later the formal parameter length is adjusted to the actual parameter length.
        • In case of an SF return type and sql_mode=ORACLE, it will set def->length to the default value (4000).

        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: