Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-7845

Aliases tables should be referenced with the alias names in multi table deletes

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.3, 1.6.4
    • Fix Version/s: 1.7
    • Component/s: General
    • Labels:
      None
    • Environment:
      MySQL 5.0.27
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_16_STABLE
    • Fixed Branches:
      MOODLE_17_STABLE

      Description

      From MySQL 5.0."someversion" it became illegal to do
      "DELETE FROM mdl_forum_posts USING mdl_forum_discussions fd, mdl_forum_posts fp, mdl_forum f WHERE fp.discussion=fd.id and f.course=1336 AND f.id=fd.forum" (the example is from function forum_delete_userdata)

      It returns "Unknown table 'mdl_forum_posts' in MULTI DELETE".

      Instead, use
      "DELETE FROM fp USING mdl_forum_discussions fd, mdl_forum_posts fp, mdl_forum f WHERE fp.discussion=fd.id and f.course=1336 AND f.id=fd.forum"

      This kind of make sense, even... though not very nice of MySQL to break these bits of Moodle. I think there are other instances as well. Maybe in 1.7 also. They don't usually show as errors in Moodle, stuff just doesn't get deleted.

      From MySQL 5.0 manual:
      " Note: If you provide an alias for a table, you must use the alias when referring to the table:
      DELETE t1 FROM test AS t1, test2 WHERE ..."
      (http://dev.mysql.com/doc/refman/5.0/en/delete.html)

        Attachments

          Activity

            People

            • Assignee:
              skodak Petr Skoda
              Reporter:
              samulik Samuli Karevaara
              Tester:
              Nobody
              Participants:
              Component watchers:
              Jake Dallimore, Jun Pataleta
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                7/Nov/06