I have setup a new Moodle instance version 3.9.2 Build: 20200914 and Postgres 12.4.
Everything seemed to work well with no issues, till today one of the Moodle Admins created a new user with a customized role, when attempting to log in as this user a "ERROR Reading from database" occurs.
In the Postgres Logs I can see the following.
ERROR: syntax error at or near "REGEXP" at character 173
STATEMENT: SELECT count(ra.id) teacher FROM mdl_role_assignments ra
JOIN mdl_role r ON ra.roleid = r.id
WHERE ra.userid = $1
AND r.archetype REGEXP 'editingteacher|teacher'
Any advice as to what is causing this or how to fix this ?