On Monday, October 21, 2002, at 01:28  PM, Bruce Momjian wrote:

Yes PQescapeString was new in 7.2, released 2002-02-04.  Not sure how
DBD-pg calls libpq, but if PQescapeString is in libpq, you can use it,
if not, you will have to roll your own.
Well, right now, DBD::Pg::quote() is pure Perl, and looks like this:

my %esc = ( "'" => '\\047', # '\\' . sprintf("%03o", ord("'")), # ISO SQL 2
'\\' => '\\134', # '\\' . sprintf("%03o", ord("\\")),
"\0" => '\\000' # '\\' . sprintf("%03o", ord("\0")),
);

sub quote {
my ($dbh, $str, $data_type) = @_;
return "NULL" unless defined $str;

return $str if $data_type && $no_escape[$data_type];
$str =~ s/(['\\\0])/$esc{$1}/g;
return "'$str'";
}

This seems to work just fine. So if want to just leave it like this until such time as we're ready to declare the minimum installation of PostgreSQL to be 7.2, I think it'll continue to work fine.

If, OTOH, DBD::Pg can determine what's available and what's not when it's compiled, we can use the above for pre 7.2 and PQescapeString for 7.2 or later.

It looks like I might soon need to find the tuits to learn enough C and XS to be able to supply patches for such an idea. :-)

Regards,

David

--
David Wheeler AIM: dwTheory
[EMAIL PROTECTED] ICQ: 15726394
http://david.wheeler.net/ Yahoo!: dew7e
Jabber: [EMAIL PROTECTED]



Reply via email to