Unix Technical Forum

BUG #2478: PQescapeStringConn

This is a discussion on BUG #2478: PQescapeStringConn within the pgsql Bugs forums, part of the PostgreSQL category; --> The following bug has been logged online: Bug reference: 2478 Logged by: Ian Howle Email address: Ian@qwizdom.com PostgreSQL version: ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Bugs

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 10:03 AM
Ian Howle
 
Posts: n/a
Default BUG #2478: PQescapeStringConn


The following bug has been logged online:

Bug reference: 2478
Logged by: Ian Howle
Email address: Ian@qwizdom.com
PostgreSQL version: 8.1.4
Operating system: Mac OS X 10.4.6
Description: PQescapeStringConn
Details:

When inserting into a TEXT or VARCHAR() table field, single quotes are
needed around the text. When using the PQescapeStringConn(), the beginning
and ending single quotes are escaped, causing the INSERT statement to fail.
I understand that this really isn't a bug and that the text being insterted
into the database should be scanned using PQescapeStringConn() before adding
the surrounding quotes.

I have a single method that deals with inserting data into the database,
which is called from many places throughout the application. It would be
nice if PQescapeStringConn() did not escape beginning and ending quotes,
just everything in between.

Thank you.

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 10:03 AM
Bruce Momjian
 
Posts: n/a
Default Re: BUG #2478: PQescapeStringConn

Ian Howle wrote:
>
> The following bug has been logged online:
>
> Bug reference: 2478
> Logged by: Ian Howle
> Email address: Ian@qwizdom.com
> PostgreSQL version: 8.1.4
> Operating system: Mac OS X 10.4.6
> Description: PQescapeStringConn
> Details:
>
> When inserting into a TEXT or VARCHAR() table field, single quotes are
> needed around the text. When using the PQescapeStringConn(), the beginning
> and ending single quotes are escaped, causing the INSERT statement to fail.
> I understand that this really isn't a bug and that the text being insterted
> into the database should be scanned using PQescapeStringConn() before adding
> the surrounding quotes.
>
> I have a single method that deals with inserting data into the database,
> which is called from many places throughout the application. It would be
> nice if PQescapeStringConn() did not escape beginning and ending quotes,
> just everything in between.


What if the string itself starts and ends with single quotes? How would
we know whether to escape them? What people usually do is to have the
single-quotes in their query, and just place the PQescapeStringConn()
inside those single quotes.

--
Bruce Momjian http://candle.pha.pa.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:41 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com