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

Overfilling DB entries with a replace causes error

    XMLWordPrintable

Details

    • PostgreSQL
    • MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_26_STABLE
    • MOODLE_26_STABLE
    • w50_MDL-31625_m27_replace
    • Hide

      do not use longer replacement than the original text

      Show
      do not use longer replacement than the original text
    • Hide

      1/ run phpunit tests
      2/ try the replacement UI - use both shorter and longer replacements

      Note: Oracle is not supported - the tests are skipped and UI does not allow you to continue.

      Show
      1/ run phpunit tests 2/ try the replacement UI - use both shorter and longer replacements Note: Oracle is not supported - the tests are skipped and UI does not allow you to continue.
    • 13
    • BACKEND Sprint 7

    Description

      If a column is at the constrained limit like mdl_log - url, then if you replace it with a new url larger, that the search url will fail.

      Error writing to database
       
      More information about this error
       
      Debug info: ERROR: value too long for type character varying(100)
      UPDATE mdl_log SET url = REPLACE(url, $1, $2)
      [array (
      0 => 'http://localhost/moodle',
      1 => 'http://localhost/moodle21',
      )]
      Stack trace:
      line 397 of /lib/dml/moodle_database.php: dml_write_exception thrown
      line 232 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      line 596 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      line 6281 of /lib/adminlib.php: call to pgsql_native_moodle_database->execute()
      line 47 of /admin/replace.php: call to db_replace()
      

      Jason Ilicic and I have made some fixes to the db_replace() function to fix database issues when running it.

      • Running the replace command on fields that don't have the search url in it.
        • In PostgreSQL, update creates another row and tags the old row was re-usable but effectively doubling the Database size.
      • Replacing a URL that is greater than original and making the column larger that DB constraints.
        • If column is 100 chars (mdl_log - url) and data is 100 chars, an update will fail if replace url is greater that search url.
      • Replace the search url if the column is equal or greater that the size of the search url.

      Attachments

        Issue Links

          Activity

            People

              skodak Petr Skoda (Inactive)
              tlock Tim Lock
              Marina Glancy Marina Glancy
              Sam Hemelryk Sam Hemelryk
              Damyon Wiese Damyon Wiese
              Votes:
              7 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Clockify

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