On May 6, 2008, at 20:16, Greg Sabino Mullane wrote:
Here's some possible solutions, just to throw out there for thought:
Couldn't DBD::Pg just switch to using ' to escape quotes? I mean, the problem is DBD::Pg escaping in $dbh->quote(), is it not? In that case, Just escape ' and not \ if SCS is on.
Or am I missing something?
1) Check SCS on startup, and if on, use E'' from that point onward. 2) Check SCS via libpq before every quote call. If libpq is too old to know about SCS, check ourself via a SHOW call. 3) Check SCS via libpq before every quote call. If libpq is too old to know about SCS, do the same logic as #1 4) Have a switch that allows it to be toggled between #1 and #2/#3. 5) If the server version supports E'' (e.g. >= 8.2), use that all the time, period.
Bleh. I'm so glad I use placeholders. The E'' syntax is just so ugly.
6) Do #5, but allow a switch to turn it off or do some other behavior. #5 is probably the "safest", but also the least backwards compatible for anything generating quotes to use on an older version, and may very well break applications that aren't expecting the 'E'. I'm leaning towards #1 at the moment, but want to get some other minds to look at the problem. Also imagine a future world in which this is on by default and people routinely use backslashes to mean backslashes - should that weigh in our decision now?
YES!
Finally, remember that long term we want to support custom types and custom quoting, so relying on the libpq quoting is probably not wise.
It's a start. I mean, for 99% of the cases, it's exactly what's needed. Anyone creating or using custom types probably know what they're doing and can do the quoting properly (or use placeholders!).
Best, David
