Обсуждение: confused about backslashes

Поиск
Список
Период
Сортировка

confused about backslashes

От
"Frank Morton"
Дата:
can someone help me out here.

I want to put the real text data of "\\QM_RIP1\HEIDEL41"
in a text field.

If I put double backslashes representing one backslash
in an insert statement as in "\\\\QM_RIP1\\HEIDEL41"
and then do a select on that field with psql, I actually see
the double backslashes (unexpected). But, if i do a query
using JDBC, it does correctly revert to the single backslash
I originally was after. I still don't follow this, but it works, so
I could just ignore it.

However, then i I do a dump of the database with "pg_dump -d",
this same field comes back out with single backslashes, which
if you pipe as input to psql to reload, the field is missing the
backslashes again.

Could someone explain this to me.




Re: [INTERFACES] confused about backslashes

От
Peter T Mount
Дата:
On Tue, 8 Sep 1998, Frank Morton wrote:

> can someone help me out here.
>
> I want to put the real text data of "\\QM_RIP1\HEIDEL41"
> in a text field.
>
> If I put double backslashes representing one backslash
> in an insert statement as in "\\\\QM_RIP1\\HEIDEL41"
> and then do a select on that field with psql, I actually see
> the double backslashes (unexpected). But, if i do a query
> using JDBC, it does correctly revert to the single backslash
> I originally was after. I still don't follow this, but it works, so
> I could just ignore it.

JDBC simply returns what the backend sends it, so it should return the
single backslash.

PSQL however, postprocesses it so that you could pipe it back. This is the
behaviour I assumed pg_dump would use.

> However, then i I do a dump of the database with "pg_dump -d",
> this same field comes back out with single backslashes, which
> if you pipe as input to psql to reload, the field is missing the
> backslashes again.

Thinking about this, I think I'd better test JDBC on quoting, in case it
suffers from this problem when updating a table.

--
       Peter T Mount peter@retep.org.uk
      Main Homepage: http://www.retep.org.uk
PostgreSQL JDBC Faq: http://www.retep.org.uk/postgres
 Java PDF Generator: http://www.retep.org.uk/pdf