array quotation problem

From: Sim Zacks <sim(at)compulab(dot)co(dot)il>
To: pgsql-general(at)postgresql(dot)org
Subject: array quotation problem
Date: 2006-12-27 06:55:24
Message-ID: emt5ei$207f$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

select version();
"PostgreSQL 8.0.1 on i686-pc-linux-gnu, compiled by GCC i686-pc-linux-gnu-gcc (GCC) 3.3.5 (Gentoo
Linux 3.3.5-r1, ssp-3.3.2-3, pie-8.7.7.1)"

In short:
Does anyone have any idea of how to put non escaped quotes into a text array element in the same way
that the system puts non escaped quotes around the text of an element that has whitespace within?

Details:
I am using a text array and when there are spaces in the text, the parser automatically puts double
quotes around the element and when there are no special characters it doesn't, as is written in the
documentation.

I would like to put double quotes around all the elements, even the ones without special characters
and I can't figure out how. The double quotes that the system automatically puts in are not escaped
with a \, but when I add quotes they are escaped (again as written in the documentation). If have
tried using chr(32) and quote_ident() and they work the same way.

My specific problem is that I am passing the array into a python function and converting it to a
python list type. The array gets passed in as a comma delimited string. If the values are already
quoted (without escapes) then it can be converted automatically. Otherwise I have to write a parsing
routine to check which of the elements have quotes (the ones that had a space) and which don't and
then to put in the quotes manually before I can convert it to a list type.

According to the documentation:
> The array output routine will put double quotes around element values if they are empty strings,
> contain curly braces, delimiter characters, double quotes, backslashes, or white space, or
> match the word NULL. Double quotes and backslashes embedded in element values will be
backslash-escaped.
> For numeric data types it is safe to assume that double quotes will never appear, but for textual
> data types one should be prepared to cope with either presence or absence of quotes.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dennis 2006-12-27 07:41:08 Geographical redundancy
Previous Message Tom Lane 2006-12-27 03:26:03 Re: ORDER BY col is NULL in UNION causes error?