pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gary Chambers <gwchamb@gmail.com>
To: ljb <lbayuk@pobox.com>
Cc: pgsql-php@postgresql.org
Subject: Re: pg_[un]escape_bytea, pgsql 8.2.1, php 5.1.6, Linux
Date: Fri, 2 Feb 2007 23:09:08 -0500
Message-ID: <302670f20702022009x417a210fm5e0fa36d860a225@mail.gmail.com> (raw)
In-Reply-To: <eq0ta7$15us$1@news.hub.org>
References: <302670f20702011827x28d9a689m388b2c8a703f31af@mail.gmail.com>
	<eq0ta7$15us$1@news.hub.org>

Thanks for the reply!

> pg_query_params() should have been made binary-safe, but it isn't. It only
> accepts and passes 'text' mode arguments to PostgreSQL.  So you cannot put
> raw bytea data into a query parameter.

Hmmm...  Disappointing.  Will pg_query_params ever become binary safe?
 I'm evaluating Postgres as an alternative to Oracle, so that's where
the majority of my experience lies.

> you need for a non-parameterized query, like "INSERT INTO mytable (bd)
> VALUES ('$data')" where bd is a bytea column, and $data went through
> pg_escape_bytea().

Understood.  I do not like for several reasons that method of
inserting data.  It exposes me to SQL injection attacks, it's very
inefficient (in Oracle, anyway -- perhaps you can correct me where
Postgres is concerned), it seems uncharacteristic of a database with
the qualities of Postgres, I can't have all my queries in a single
source file, and I can't take advantage of the ease with which I can
handle binary data with a bytea field.

> To me, this means that you should probably do non-parameterized queries
> instead, with pg_query() and pg_escape_bytea(), with your bytea data.

Would there be any advantage to simply using a text field and base64
encoding and decoding the binary data?  I really don't want to use
non-parameterized queries.

-- Gary Chambers

// Nothing fancy and nothing Microsoft!



view thread (10+ messages)  latest in thread

Message-ID: <302670f20702022009x417a210fm5e0fa36d860a225@mail.gmail.com>
Permalink:  ../302670f20702022009x417a210fm5e0fa36d860a225@mail.gmail.com/
Also on:    postgresql.org/message-id/302670f20702022009x417a210fm5e0fa36d860a225@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: gwchamb@gmail.com, lbayuk@pobox.com
  Subject: Re: pg_[un]escape_bytea, pgsql 8.2.1, php 5.1.6, Linux
  In-Reply-To: <302670f20702022009x417a210fm5e0fa36d860a225@mail.gmail.com>
  References: <302670f20702011827x28d9a689m388b2c8a703f31af@mail.gmail.com> <eq0ta7$15us$1@news.hub.org> <302670f20702022009x417a210fm5e0fa36d860a225@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox