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

Add Type_handler::create_literal_item()

Details

    Description

      The code for creation of temporal literals, such as:

      • TIME'10:20:30'
      • {t'10:20:30'}

      currently resides in:
      1. create_temporal_literal() in item_create.cc
      2. Item_string::odbc_temporal_literal_type()
      3. Item_string::make_odbc_literal()

      and has various switches on MYSQL_TYPE_XXX

      This is not friendly to data type plugins.

      New data types will support their own literals:

      • INET6'0::0'
      • {guid 'nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn'}

      Under terms of this task we'll move the code to Type_handler by adding the following methods:

      static const Type_handler *odbc_literal_type_handler(const LEX_CSTRING *str);
       
      virtual Item_literal *create_literal_item(THD *thd,
                                                const char *str, size_t length,
                                                CHARSET_INFO *cs,
                                                bool send_error) const;
      

      This task is only about moving the code to class Type_handler.

      Limitations:

      • odbc_literal_type_handler() will still resolve only TIME, DATE and DATETIME literals, as before.
      • The code in sql_yacc.yy will still create literals for hard-coded builtin data types TIME, DATE, DATETIME, like this:

        temporal_literal:
                DATE_SYM TEXT_STRING
                  {
                    if (unlikely(!($$= type_handler_newdate.create_literal_item(thd,
                                                                   $2.str, $2.length,
                                                                   YYCSCL, true))))
                      MYSQL_YYABORT;
                  }
        

      The following changes will be done separately, later:

      • Extend odbc_literal_type_handler() with a hash for additional data types that want ODBC literals, so a user plugin (such as guid) can register itself in this hash, telling the server that it wants to support ODBC style literals.
      • Fix the parser to support pluggable data types.

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov created issue -
            bar Alexander Barkov made changes -
            Field Original Value New Value
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            Description The code for creation of temporal literals, such as:
            - {{TIME'10:20:30'}}
            - {t'10:20:30'}
            currently resides in:
            1. create_temporal_literal() in item_create.cc
            2. Item_string::odbc_temporal_literal_type()
            3. Item_string::make_odbc_literal()

            and has various switches on {{MYSQL_TYPE_XXX}}

            This is not friendly to data type plugins.

            New data types will support their own literals:
            - {{INET6'0::0'}}
            - {guid 'nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn'}


            Under terms of this task we'll move the code to Type_handler by adding the following methods:
            {code:cpp}
            static const Type_handler *odbc_literal_type_handler(const LEX_CSTRING *str);

            virtual Item_literal *create_literal_item(THD *thd,
                                                      const char *str, size_t length,
                                                      CHARSET_INFO *cs,
                                                      bool send_error) const;
            {code}


            This task is only about moving the code to class Type_handler.

            Limitations:

            - {{odbc_literal_type_handler()}} will still resolve only TIME, DATE and DATETIME literals, as before.

            - The code in sql_yacc.yy will still create literals for hard-coded builtin data types TIME, DATE, DATETIME, like this:
            {code:sql}
            temporal_literal:
                    DATE_SYM TEXT_STRING
                      {
                        if (unlikely(!($$= type_handler_newdate.create_literal_item(thd,
                                                                       $2.str, $2.length,
                                                                       YYCSCL, true))))
                          MYSQL_YYABORT;
                      }
            {code}

            The following changes will be done separately, later:
            - Extend {{odbc_literal_type_handler()}} with a hash for additional data types that want ODBC literals, so a user plugin (such as {{guid}}) can register itself in this hash, telling the server that it wants to support ODBC style literals.
            - Fix the parser to support pluggable data types.
            The code for creation of temporal literals, such as:
            - {{TIME'10:20:30'}}
            - {t'10:20:30'}

            currently resides in:
            1. create_temporal_literal() in item_create.cc
            2. Item_string::odbc_temporal_literal_type()
            3. Item_string::make_odbc_literal()

            and has various switches on {{MYSQL_TYPE_XXX}}

            This is not friendly to data type plugins.

            New data types will support their own literals:
            - {{INET6'0::0'}}
            - {guid 'nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn'}


            Under terms of this task we'll move the code to Type_handler by adding the following methods:
            {code:cpp}
            static const Type_handler *odbc_literal_type_handler(const LEX_CSTRING *str);

            virtual Item_literal *create_literal_item(THD *thd,
                                                      const char *str, size_t length,
                                                      CHARSET_INFO *cs,
                                                      bool send_error) const;
            {code}


            This task is only about moving the code to class Type_handler.

            Limitations:

            - {{odbc_literal_type_handler()}} will still resolve only TIME, DATE and DATETIME literals, as before.

            - The code in sql_yacc.yy will still create literals for hard-coded builtin data types TIME, DATE, DATETIME, like this:
            {code:sql}
            temporal_literal:
                    DATE_SYM TEXT_STRING
                      {
                        if (unlikely(!($$= type_handler_newdate.create_literal_item(thd,
                                                                       $2.str, $2.length,
                                                                       YYCSCL, true))))
                          MYSQL_YYABORT;
                      }
            {code}

            The following changes will be done separately, later:
            - Extend {{odbc_literal_type_handler()}} with a hash for additional data types that want ODBC literals, so a user plugin (such as {{guid}}) can register itself in this hash, telling the server that it wants to support ODBC style literals.
            - Fix the parser to support pluggable data types.
            bar Alexander Barkov made changes -
            issue.field.resolutiondate 2018-07-24 08:04:10.0 2018-07-24 08:04:10.952
            bar Alexander Barkov made changes -
            Fix Version/s 10.4.0 [ 23115 ]
            Fix Version/s 10.4 [ 22408 ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 88536 ] MariaDB v4 [ 133634 ]

            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.