logo       

Re: pg_[un]escape_bytea, pgsql 8.2.1, php 5.1.6, Linux: msg#00013

Subject: Re: pg_[un]escape_bytea, pgsql 8.2.1, php 5.1.6, Linux
On Thursday 08 February 2007, ljb wrote:
> gwchamb@xxxxxxxxx wrote:
> > Vincent...
> >
> >> This would be a problem related to php, not postgres. I'm handling
> >> binary data in parameterized and COPY queries just fine with c++.
> >
> > I'm not ruling-out PHP, but I've seen claims of pg_[un]escape_bytea
> > being only wrappers to the Pg functions.
>
> That is correct, the PHP function relies on the PostgreSQL library to do
> the work. But the problem of using a parameterized query with bytea data
> is specific to PHP. PostgreSQL allows you to either escape the bytea
> data for use as a text-mode parameter, or pass it 'raw' as a binary-mode
> parameter. I don't know a good way to do the first in PHP, and the PHP
> PostgreSQL interface doesn't support the second at all.

This sparked my interest, so I checked the libpq docs 
(http://www.postgresql.org/docs/8.2/interactive/libpq-exec.html) and wrote 
some php tests.

The postgres doc say that the escape functions should only be used "for 
Inclusion in SQL Commands", and that "it is not necessary nor correct to do 
escaping when a data value is passed as a separate parameter in 
PQexecParams".
But when I try to pass the raw data using pg_query_params(), postgres 
complains about UTF8 (on a supposedly bytea field). Makes you wonder which 
postgres function does pg_query_params() really wrap around...

I reallize I went all this way to just re-discover what has been said in this 
thread, but if I needed the extra research, maybe other will find it 
insightfull.
-- 
Vincent de Phily

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe