diff -Nrup pgsql_perl5-1.9.0-orig/Pg.pm pgsql_perl5-1.9.0/Pg.pm --- pgsql_perl5-1.9.0-orig/Pg.pm 2000-04-04 12:41:52.000000000 -0700 +++ pgsql_perl5-1.9.0/Pg.pm 2006-04-04 12:00:48.000000000 -0700 @@ -351,6 +351,15 @@ been received from the backend using get Returns a newly allocated, initialized result with given status. + $dbsafe_string = Pg::escapeString($unsafe); + +Returns an escaped string for use within an SQL command. This is +useful when inserting data values as literal constants in SQL +commands. Certain characters (such as quotes and backslashes) +must be escaped to prevent them from being interpreted specially +by the SQL parser. Pg::escapeString performs this operation. + + =head2 2. Result diff -Nrup pgsql_perl5-1.9.0-orig/Pg.xs pgsql_perl5-1.9.0/Pg.xs --- pgsql_perl5-1.9.0-orig/Pg.xs 2000-04-04 12:08:46.000000000 -0700 +++ pgsql_perl5-1.9.0/Pg.xs 2006-04-04 12:00:48.000000000 -0700 @@ -182,6 +182,23 @@ resStatus(status) RETVAL +void +escapeString(str) + const char* str + PREINIT: + size_t s; + SV* tmp; + SV* dbsafe_str; + PPCODE: + tmp = newSVpv("", strlen(str)*2 + 1); + s = PQescapeString(SvPV_nolen(tmp), str, strlen(str)); + + dbsafe_str = newSVpv(SvPV_nolen(tmp), 0); + SvREFCNT_dec(tmp); + + EXTEND(SP, 1); + PUSHs(sv_2mortal(dbsafe_str)); + MODULE = Pg PACKAGE = PG_conn PREFIX = PQ