Escaping

Поиск
Список
Период
Сортировка
От Maciek Sakrejda
Тема Escaping
Дата
Msg-id AANLkTikFQco_q1mK32XHPf6WJxTR_DTZ8_f5Wo9MzDxf@mail.gmail.com
обсуждение исходный текст
Список pgsql-jdbc
I need to format some data as text (since it's going into a textual
COPY), and I'm having a hard time escaping the input. My target column
is an array of UDTs. The UDTs are composed of two integers and an
hstore (yes, relational algebra weeps at what I'm doing). With the
ARRAY[ ... ] notation, this is fairly straightforward.

cqdb=# create type foo as (a int, b int, c hstore);
CREATE TYPE
cqdb=# select (ARRAY[ (1,2,E'foo=>bar,"=>\\""=>quux')::foo,
(3,4,'baz=>xyzzy')::foo ])::foo[];
                                                      array
-----------------------------------------------------------------------------------------------------------------
 {"(1,2,\"\"\"=>\\\\\"\"\"\"=>\"\"quux\"\",
\"\"foo\"\"=>\"\"bar\"\"\")","(3,4,\"\"\"baz\"\"=>\"\"xyzzy\"\"\")"}
(1 row)

However, in order to feed this in as text, I need to use the array
literal notation and the way the escaping stacks is lost on me. I've
read the UDT docs, the array input docs, and the hstore input docs,
but somewhere my logic is going south. My standard_conforming_strings
is off, for what it's worth.

Anyway, to get to the JDBC part of this: are there utility functions
in the JDBC code that can help with this? It seems like escaping is a
relatively common scenario, but I don't see anything relevant except
for Utils.appendEscapedLiteral(), which doesn't seem quite what I'm
looking for (it does not deal with double quotes).

Thanks,
---
Maciek Sakrejda | System Architect | Truviso

1065 E. Hillsdale Blvd., Suite 215
Foster City, CA 94404
(650) 242-3500 Main
www.truviso.com

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Devrim GÜNDÜZ
Дата:
Сообщение: Re: 9.0 JDBC drivers
Следующее
От: Thomas Kellerer
Дата:
Сообщение: Bug in getIndexInfo() with 9.0 JDBC driver