X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 35A2911F625F for ; Tue, 4 Apr 2006 19:48:54 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66292-07 for ; Tue, 4 Apr 2006 19:48:53 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.225]) by postgresql.org (Postfix) with ESMTP id 0A9D111F622E for ; Tue, 4 Apr 2006 19:48:51 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 50so1437695wri for ; Tue, 04 Apr 2006 15:48:51 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=h7Cj2dU59iuBV7DCYslQ6VU3CP/lvoszn+xOpnJeKNRD1NphSMQwOwMq7PnxIqrH+5qwaybsecLPLQdXadsF9jUaSYRlubZSZ922NIip9f/rzDmUHFshZW4o4wZNxBLRKI8kTmytJg5+wClReCxxc/kCymuVWbM+L8nahA1E6Cc= Received: by 10.54.158.9 with SMTP id g9mr220826wre; Tue, 04 Apr 2006 15:48:51 -0700 (PDT) Received: by 10.54.157.2 with HTTP; Tue, 4 Apr 2006 15:47:48 -0700 (PDT) Message-ID: <53b425b00604041547s78b9bccdl6f95b9dfa4e5282b@mail.gmail.com> Date: Tue, 4 Apr 2006 15:47:48 -0700 From: "patrick keshishian" To: pgsql-interfaces@postgresql.org Subject: pgsql_perl5-1.9.0 / Pg - patch for PQescapeString MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_5738_15483098.1144190868955" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200604/7 X-Sequence-Number: 6098 ------=_Part_5738_15483098.1144190868955 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Greetings all, I just wanted to send you the attached patch which adds the PQescapeString interface to the Pg module. Earlier today, I forwarded this patch to Edmund Mergl , he suggested that I should forward this patch to the appropriate list, as he no longer maintains this module. I assume he meant this list, as I couldn't google another. I also noticed that last discussions pertaining to this Perl interfaces is years old. So, it may just be the case that it might be a deprecated interface (hopefully I'm wrong). Is there active maintenance of this module? Two files that are touched are Pg.xs, which does the work, and Pg.pm for the copy/paste documentation for PQescapeString() function from PostgreSQL pdf doc. I am not a XS expert, so I'd appreciate if you reviewed the patch and if you find anything wrong you would let me know. Hopefully you'll accept this change/patch :-) Thanks, --patrick ------=_Part_5738_15483098.1144190868955 Content-Type: application/octet-stream; name=pgsql_perl5-1.9.0-patch-20060404 Content-Transfer-Encoding: 7bit X-Attachment-Id: f_elmtfncj Content-Disposition: attachment; filename="pgsql_perl5-1.9.0-patch-20060404" 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 ------=_Part_5738_15483098.1144190868955--