Skip site navigation (1) Skip section navigation (2)

Re: Trouble Escaping Quotes

From: "Haron, Charles" <charles(dot)haron(at)cognitive(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Cc: Richard Poole <rp(at)guests(dot)deus(dot)net>
Subject: Re: Trouble Escaping Quotes
Date: 2005-01-24 16:34:55
Message-ID: 593E515C9586D511BB4500010283D5E202564AC4@COG-MAIL (view raw or flat)
Thread:
Lists: pgsql-admin
Below is logging information from a client-side SQL monitor, as well as what
I found in <posgresqlhome>/data/serverlog:

I this particular instance the offending quote is in the problem_desc field.
The value of problem_desc being "Bob's Problem" (double quotes excluded).  

*** Client-Side SQL monitor data ***
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;SET DATESTYLE TO ISO;BEGIN;
insert into "rmas"
  ("id", "company_id", "repair_types_id", "printer_models_id",
"serial_number", "problem_desc")
values
  (1240916, 126, 3, 595, '45845384568', 'Bob''s Problem')
Command executed sucessfully
1 row(s) affected
Commiting transaction
END;
SELECT send_rma(rma_info) FROM rma_info WHERE rma = 1240916
server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.

*** Information From <posgresqlhome>/data/serverlog ***
server closed the connection unexpectedly
         This probably means the server terminated abnormally
         before or while processing the request.
The connection to the server was lost. Attempting reset: WARNING:  
Message from PostgreSQL backend:
         The Postmaster has informed me that some other backend
         died abnormally and possibly corrupted shared memory.
         I have rolled back the current transaction and am
         going to terminate your database system connection and exit.
         Please reconnect to the database system and repeat your query.
Failed.

> -----Original Message-----
> From: Richard Poole [mailto:rp(at)guests(dot)deus(dot)net] 
> Sent: Sunday, January 23, 2005 11:59 AM
> To: pgsql-admin(at)postgresql(dot)org
> Cc: Haron, Charles
> Subject: Re: Trouble Escaping Quotes
> 
> On Fri, Jan 21, 2005 at 08:43:00AM -0700, Haron, Charles wrote:
> > Yes, but how do you escape the quote when the value of the string 
> > isn't know until the function is run?
> > 
> > If $rma_data->{\'company_name\'} is returning Bob's Fixit 
> at run time, 
> > how do escape the quote BEFORE Perl interprets the string and 
> > generates an error?
> 
> Your quote-escaping looks fine to me; \' is just as good as 
> '', although less standard. I can't reproduce your problem 
> here; your function works for me under 8.0.0 and perl 5.8.6 . 
> What's your error message when you call it? Are you sure that 
> your problem isn't happening earlier, when you put the data 
> into the database in the first place?
> 
> 
> Richard
> 

Responses

pgsql-admin by date

Next:From: Pallav KalvaDate: 2005-01-24 16:47:16
Subject: Postgres 8.0 Backups
Previous:From: Stephan SzaboDate: 2005-01-24 14:28:47
Subject: Re: postgresql 7.4.6 - FATAL Database Startup Message

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group