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

fetch_columns with partitionned table compatibility

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.1.16
    • Tasks
    • MOODLE_401_STABLE

      When partitionning table in postgresql there are errors appearing in the moodle cron log.

      Here is an example of error with the partitionned table question_attempt_steps:

      Execute scheduled task: Mise à jour des tentatives de test en retard (mod_quiz\task\update_overdue_attempts)
      ... started 10:32:14. Current memory use 30.3 Mo.
        Looking for quiz overdue quiz attempts...
      Error while processing attempt 2988236 at 16989 quiz:
      La table « question_attempt_steps » n’existe pas
      #0 /opt/moodle/question/engine/datalib.php(240): pgsql_native_moodle_database->insert_record()
      #1 /opt/moodle/question/engine/datalib.php(1596): question_engine_data_mapper->insert_question_attempt_step()
      #2 /opt/moodle/question/engine/lib.php(98): question_engine_unit_of_work->save()
      #3 /opt/moodle/mod/quiz/attemptlib.php(2199): question_engine::save_questions_usage_by_activity()
      #4 /opt/moodle/mod/quiz/attemptlib.php(2030): quiz_attempt->process_finish()
      #5 /opt/moodle/mod/quiz/cronlib.php(79): quiz_attempt->handle_if_time_expired()
      #6 /opt/moodle/mod/quiz/classes/task/update_overdue_attempts.php(61): mod_quiz_overdue_attempt_updater->update_overdue_attempts()
      #7 /opt/moodle/lib/cronlib.php(263): mod_quiz\task\update_overdue_attempts->execute()
      #8 /opt/moodle/lib/cronlib.php(120): cron_run_inner_scheduled_task()
      #9 /opt/moodle/lib/cronlib.php(73): cron_run_scheduled_tasks()
      #10 /opt/moodle/admin/cli/cron.php(178): cron_run()
      #11 {main}

       

      When I execute the query that is used in pgsql_native_moodle_database.php->fetch_columns it returns no result.

      I try this patch (adding the relkind = 'p') and the error disappeared (the query worked and return the table structure).

      $sql = "SELECT a.attnum, a.attname AS field, t.typname AS type, a.attlen, a.atttypmod, a.attnotnull, a.atthasdef,
                             CASE WHEN a.atthasdef THEN pg_catalog.pg_get_expr(d.adbin, d.adrelid) ELSE '' END AS adsrc
                        FROM pg_catalog.pg_class c
                        JOIN pg_catalog.pg_namespace as ns ON ns.oid = c.relnamespace
                        JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid
                        JOIN pg_catalog.pg_type t ON t.oid = a.atttypid
                   LEFT JOIN pg_catalog.pg_attrdef d ON (d.adrelid = c.oid AND d.adnum = a.attnum)
                       WHERE (relkind = 'r' OR relkind='p') AND c.relname = '$tablename' AND c.reltype > 0 AND a.attnum > 0
                             AND (ns.nspname = current_schema() OR ns.oid = pg_my_temp_schema())
                    ORDER BY a.attnum";

       

      Do you think it's an appropriate correction?

      Thanks

            Unassigned Unassigned
            ahubert agathe hubert
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

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