Project: moodle
Issue MDL-31625: Overfilling DB entries with a replace causes error
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. {noformat} 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() {noformat} 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.
Story points: 13