added a comment - - edited
yes, problem is that until 8.4 PGSQL have allowed both backslash () and single quote (') to be used as escape chars. While the later is the SQL-standard one, we have been using the former since the beginning of Moodle (mainly to share all the DB code with MySQL without any transformation).
Main problem is that right now, in the middle of the 1.9.x series I think it's too much risky to change that behavior, as far as it involves changing the way addslashes() work, review how 1.9.x underlying DB driver is performing with that escape char and review potential uses of custom escaping here and there, so I'm not sure if to perform that change is a good idea right now. Instead, configuring the server seems "safer".
If you take a look to the configure_dbconnection() function (lib/dmllib.php), you' ll see that, for mssql and oracle, both using the single quote as escape char, we are doing this:
So, perhaps, if you want to try it... you could add that code in the 'postgres7' section, and also set magic_quotes = off and play with it. If we get positive reports from some POSTGRES servers running it ok and without problems... we could add it upstream.
Finally, note that under Moodle 2.0 we have changed the whole DB layer, and we are using proper prepared statements, so that escaping won't be a problem anymore.
Hope this helps, ciao