Details

    • Type: Task
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Fix Version/s: 10.2
    • Component/s: None
    • Labels:

      Description

      It is a well-known and very old MySQL/MariaDB limitation that temporary tables can only be used once in any query; for example, one cannot join a temporary table to itself. This task is about removing this limitation.

      original bug report:

      if I create temporary table a (id int); I cant select a1.* from a a1, a a2;

      I understand, that http://bugs.mysql.com/bug.php?id=10327 is in "feature" state for 8(!!!) years.
      But may be at least at mariadb someone to fix it.
      It is not so extraordinary type of select.
      I had bumped at almost all kind of problems about this, which are described about this bug. And any kind of rewrite selects/logic to avoid this error is a huge performance and logic issuse at hiload projects.
      Can anyone tell me if it would be fixed? when? where?
      Because I cant find any mention about it in mariadb.
      Sorry if I missed something.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            chombik tem added a comment -

            any chance to be fixed in 5.x?

            Show
            chombik tem added a comment - any chance to be fixed in 5.x?
            Hide
            serg Sergei Golubchik added a comment -

            Sorry, no. Not even in 10.0 — what you're talking about is a fundamental limitation of the current MySQL and MariaDB codebase, it would require serious changes to lift it. We cannot do that in a GA version. Not even in RC or Beta, it still would be too risky.

            Show
            serg Sergei Golubchik added a comment - Sorry, no. Not even in 10.0 — what you're talking about is a fundamental limitation of the current MySQL and MariaDB codebase, it would require serious changes to lift it. We cannot do that in a GA version. Not even in RC or Beta, it still would be too risky.
            Hide
            mmcclenn Michael McClennen added a comment -

            Can somebody please update the Mariadb documentation to mention this limitation? At least the MySQL documentation <a href="https://dev.mysql.com/doc/refman/5.7/en/temporary-table-problems.html">is explicit about it</a>.

            I have just added a vote for this issue: it is by far the MOST IMPORTANT issue for me in all of Mariadb. This has been a problem for far too long.

            Show
            mmcclenn Michael McClennen added a comment - Can somebody please update the Mariadb documentation to mention this limitation? At least the MySQL documentation <a href="https://dev.mysql.com/doc/refman/5.7/en/temporary-table-problems.html">is explicit about it</a>. I have just added a vote for this issue: it is by far the MOST IMPORTANT issue for me in all of Mariadb. This has been a problem for far too long.
            Hide
            kapil_chhajer kapil chhajer added a comment -

            Hi,
            I am Kapil Chhajer student from IIIT Hyderabad pursuing M.tech. CSE. I am comfortable with c, c++ and java. I want to work on this issue.

            Please suggest me some related material that helps me to know more about it

            Show
            kapil_chhajer kapil chhajer added a comment - Hi, I am Kapil Chhajer student from IIIT Hyderabad pursuing M.tech. CSE. I am comfortable with c, c++ and java. I want to work on this issue. Please suggest me some related material that helps me to know more about it
            Hide
            serg Sergei Golubchik added a comment -

            Normal tables are opened like this:

            1. table definition is read, parsed into a TABLE_SHARE object
            2. TABLE_SHARE object is stored in the table definition cache
            3. a TABLE object is created from the TABLE_SHARE, and a table is opened in the storage engine

            When the same table is opened again

            1. the TABLE_SHARE object is taken from the table definition cache
            2. a TABLE object is created from the TABLE_SHARE, and a table is opened in the storage engine

            That is, there is always one TABLE_SHARE per table, but there can be many TABLE objects, if the table is opened many times, say, is joined to itself.

            Temporary tables aren't cached in the table definition cache, and their TABLE_SHARE objects are, in a sense, part of the TABLE objects. That is, for temporary tables there can be only one TABLE per TABLE_SHARE. That's why temporary tables cannot be reopened.

            The fix is to decouple TABLE_SHARE from TABLE for temporary tables and store them separately in two different lists in THD.

            Show
            serg Sergei Golubchik added a comment - Normal tables are opened like this: table definition is read, parsed into a TABLE_SHARE object TABLE_SHARE object is stored in the table definition cache a TABLE object is created from the TABLE_SHARE, and a table is opened in the storage engine When the same table is opened again the TABLE_SHARE object is taken from the table definition cache a TABLE object is created from the TABLE_SHARE, and a table is opened in the storage engine That is, there is always one TABLE_SHARE per table, but there can be many TABLE objects, if the table is opened many times, say, is joined to itself. Temporary tables aren't cached in the table definition cache, and their TABLE_SHARE objects are, in a sense, part of the TABLE objects. That is, for temporary tables there can be only one TABLE per TABLE_SHARE. That's why temporary tables cannot be reopened. The fix is to decouple TABLE_SHARE from TABLE for temporary tables and store them separately in two different lists in THD.
            Hide
            kapil_chhajer kapil chhajer added a comment -

            Hi,
            Thanks Sergei for replying. I got a copy of source code with the help of
            this link https://code.launchpad.net/maria. I want to look
            the source code So I will get whole idea.

            please suggest me where to start.

            On Wed, Mar 11, 2015 at 8:17 PM, Sergei Golubchik (JIRA) <

            Show
            kapil_chhajer kapil chhajer added a comment - Hi, Thanks Sergei for replying. I got a copy of source code with the help of this link https://code.launchpad.net/maria . I want to look the source code So I will get whole idea. please suggest me where to start. On Wed, Mar 11, 2015 at 8:17 PM, Sergei Golubchik (JIRA) <
            Hide
            serg Sergei Golubchik added a comment -

            start from https://github.com/mariadb/server
            then see my previous comment, it has enough pointers for you to start exploring the source code

            Show
            serg Sergei Golubchik added a comment - start from https://github.com/mariadb/server then see my previous comment, it has enough pointers for you to start exploring the source code
            Hide
            kapil_chhajer kapil chhajer added a comment -

            Thanks sergei

            Show
            kapil_chhajer kapil chhajer added a comment - Thanks sergei

              People

              • Assignee:
                Unassigned
                Reporter:
                chombik tem
              • Votes:
                2 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated: