Re: problem with escaping "

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrei Ivanov <andrei(dot)ivanov(at)ines(dot)ro>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: problem with escaping "
Date: 2002-10-22 14:31:09
Message-ID: 18760.1035297069@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Andrei Ivanov <andrei(dot)ivanov(at)ines(dot)ro> writes:
> If I try to insert some text with " inside, I try to escape it with a \
> INSERT INTO pp VALUES ('(1, "aa \" bb", "fghij")')
> But I get an error:
> Bad movie_property external representation '(1, "aa " bb", "fghij")'
> which means that my movie_property_in function receives the string
> '(1, "aa " bb", "fghij")', without the \ in it.

Yup. The backslash will be eaten by the string-literal parser.

> The same exact thing works for varchar or text fields.

No it doesn't. Observe:

regression=# select ('(1, "aa \" bb", "fghij")')::text;
text
-------------------------
(1, "aa " bb", "fghij")
(1 row)

You'll need to double the backslash if you want the type's I/O function
to see it. Compare for example the discussion of array quoting at the
bottom of this page:
http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/arrays.html

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2002-10-22 14:34:42 Re: Hot Backup
Previous Message Evert Carton 2002-10-22 14:30:56 Function Calling Using OIDS