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

Support SELECT ... FROM table_func(...)" in the parser

Details

    • Task
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • N/A
    • OTHER
    • None

    Description

      This is a part of dj's GSoC project.

      Make the parser support

      SELECT ... FROM table_func(parameters)

      There is no execution yet. Attempt to run the statement should return an error.

      The following is expected to work:

      • The parser should allow this statement
      • setup_tables() in SELECT code should check if parameters are base constants.
        • If they are not, emit an error.
        • If they are constants (i.e. everything would be ok), emit an error anyway. This way, we can have a minimal test suite.
      • name resolution in other parts e.g. UPDATE/DELETE can be ignored for now.

      Attachments

        Issue Links

          Activity

            dj diwas joshi added a comment -

            This task required adding another rule for, using table functions in select queries, under table_factor in sql_yacc, but that was creating shift/reduce conflicts. Based on my discussion with Sergei on irc, we realized the problem seems to be in how the grammar handles bison's limitations. So we fixed it by factoring out the conflicting code in two rules into table_factor_part2. This fixed the problem. There was one more requirement of checking if the parameters are base constants or not. This was done by iterating over item_list and using basic_const_item(). Finally the input is getting parsed.

            dj diwas joshi added a comment - This task required adding another rule for, using table functions in select queries, under table_factor in sql_yacc, but that was creating shift/reduce conflicts. Based on my discussion with Sergei on irc, we realized the problem seems to be in how the grammar handles bison's limitations. So we fixed it by factoring out the conflicting code in two rules into table_factor_part2. This fixed the problem. There was one more requirement of checking if the parameters are base constants or not. This was done by iterating over item_list and using basic_const_item(). Finally the input is getting parsed.

            diwas, It would be nice if you submitted a separate patch for this task. The patch should do what is described in the description, and nothing else.

            The patch you've sent as "changes3.diff" is not good - it does a part of this task, a part of MDEV-8344, and maybe something else. When I applied your patch and tried to run the query

            select * from table_func('abc');

            I got this crash:

              Program received signal SIGSEGV, Segmentation fault.
              [Switching to Thread 0x7ffff7eb8700 (LWP 10443)]
              0x0000555555be4eec in MYSQLparse (thd=0x55555ab07b90) at /home/psergey/dev-git/10.1-gsoc/sql/sql_yacc.yy:10826
            (gdb) p sel
              $2 = (SELECT_LEX *) 0x0
            (gdb) p sel->get_item_list()
              Cannot access memory at address 0x0
            (gdb) wher
              #0  0x0000555555be4eec in MYSQLparse (thd=0x55555ab07b90) at /home/psergey/dev-git/10.1-gsoc/sql/sql_yacc.yy:10826
              #1  0x0000555555a26e62 in parse_sql (thd=0x55555ab07b90, parser_state=0x7ffff7eb7110, creation_ctx=0x0, do_pfs_digest=true) at /home/psergey/dev-git/10.1-gsoc/sql/sql_parse.cc:9103
              #2  0x0000555555a22ea5 in mysql_parse (thd=0x55555ab07b90, rawbuf=0x7fff500051b8 "select * from table_func('abc')", length=31, parser_state=0x7ffff7eb7110) at /home/psergey/dev-git/10.1-gsoc/sql/sql_parse.cc:7116
              #3  0x0000555555a12061 in dispatch_command (command=COM_QUERY, thd=0x55555ab07b90, packet=0x55555ab0f2f1 "select * from table_func('abc')", packet_length=31) at /home/psergey/dev-git/10.1-gsoc/sql/sql_parse.cc:1462
              #4  0x0000555555a10e2b in do_command (thd=0x55555ab07b90) at /home/psergey/dev-git/10.1-gsoc/sql/sql_parse.cc:1090
              #5  0x0000555555b3dd04 in do_handle_one_connection (thd_arg=0x55555ab07b90) at /home/psergey/dev-git/10.1-gsoc/sql/sql_connect.cc:1347
              #6  0x0000555555b3da49 in handle_one_connection (arg=0x55555ab07b90) at /home/psergey/dev-git/10.1-gsoc/sql/sql_connect.cc:1258
              #7  0x00007ffff691de9a in start_thread (arg=0x7ffff7eb8700) at pthread_create.c:308
              #8  0x00007ffff604e3fd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
              #9  0x0000000000000000 in ?? ()

            psergei Sergei Petrunia added a comment - diwas , It would be nice if you submitted a separate patch for this task. The patch should do what is described in the description, and nothing else. The patch you've sent as "changes3.diff" is not good - it does a part of this task, a part of MDEV-8344 , and maybe something else. When I applied your patch and tried to run the query select * from table_func('abc'); I got this crash: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7ffff7eb8700 (LWP 10443)] 0x0000555555be4eec in MYSQLparse (thd=0x55555ab07b90) at /home/psergey/dev-git/10.1-gsoc/sql/sql_yacc.yy:10826 (gdb) p sel $2 = (SELECT_LEX *) 0x0 (gdb) p sel->get_item_list() Cannot access memory at address 0x0 (gdb) wher #0 0x0000555555be4eec in MYSQLparse (thd=0x55555ab07b90) at /home/psergey/dev-git/10.1-gsoc/sql/sql_yacc.yy:10826 #1 0x0000555555a26e62 in parse_sql (thd=0x55555ab07b90, parser_state=0x7ffff7eb7110, creation_ctx=0x0, do_pfs_digest=true) at /home/psergey/dev-git/10.1-gsoc/sql/sql_parse.cc:9103 #2 0x0000555555a22ea5 in mysql_parse (thd=0x55555ab07b90, rawbuf=0x7fff500051b8 "select * from table_func('abc')", length=31, parser_state=0x7ffff7eb7110) at /home/psergey/dev-git/10.1-gsoc/sql/sql_parse.cc:7116 #3 0x0000555555a12061 in dispatch_command (command=COM_QUERY, thd=0x55555ab07b90, packet=0x55555ab0f2f1 "select * from table_func('abc')", packet_length=31) at /home/psergey/dev-git/10.1-gsoc/sql/sql_parse.cc:1462 #4 0x0000555555a10e2b in do_command (thd=0x55555ab07b90) at /home/psergey/dev-git/10.1-gsoc/sql/sql_parse.cc:1090 #5 0x0000555555b3dd04 in do_handle_one_connection (thd_arg=0x55555ab07b90) at /home/psergey/dev-git/10.1-gsoc/sql/sql_connect.cc:1347 #6 0x0000555555b3da49 in handle_one_connection (arg=0x55555ab07b90) at /home/psergey/dev-git/10.1-gsoc/sql/sql_connect.cc:1258 #7 0x00007ffff691de9a in start_thread (arg=0x7ffff7eb8700) at pthread_create.c:308 #8 0x00007ffff604e3fd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112 #9 0x0000000000000000 in ?? ()

            Before submitting the patch, please add a testcase into it (the same request as in MDEV-8343).

            psergei Sergei Petrunia added a comment - Before submitting the patch, please add a testcase into it (the same request as in MDEV-8343 ).
            dj diwas joshi added a comment -

            The reviewed patch for this task has been pushed to https://github.com/djdij123/server.git this task can be closed now.

            dj diwas joshi added a comment - The reviewed patch for this task has been pushed to https://github.com/djdij123/server.git this task can be closed now.

            People

              Unassigned Unassigned
              psergei Sergei Petrunia
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.