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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 1.7
    • 1.6.3, 1.6.4
    • General
    • None
    • MySQL 5.0.27
    • MySQL
    • MOODLE_16_STABLE
    • MOODLE_17_STABLE

      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)

            skodak Petr Skoda
            samulik Samuli Karevaara
            Nobody Nobody (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.