From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tim Kane <timk@hotgames.com>
Cc: PSQL Interfaces <pgsql-interfaces@postgreSQL.org>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [INTERFACES] arrays of varchar and "
Date: Thu, 24 Feb 2000 23:48:29 -0500
Message-ID: <6297.951454109@sss.pgh.pa.us> (raw)
In-Reply-To: <23718.951440617@sss.pgh.pa.us>
References: <38B5C4AA.A84809F2@hotgames.com>
<23718.951440617@sss.pgh.pa.us>
I wrote:
> Tim Kane <timk@hotgames.com> writes:
>> I want to insert a number of array elements here...
>> insert into my_table values ('{"value 1", "value 2", "value 3"}');
>> Fine.
>> What do I do however, when I want to insert an array element that
>> contains a " character?
> Hmm. It looks like array_in tries to deal with backslashed quotes in
> array elements; not sure why it's not working exactly.
Ah, I see ;-) The correct expression if you want, say, `value "22"a'
in your middle array item is
insert into my_table values ('{"value 1", "value \\"22\\"a", "value 3"}');
You need double backslashes because one level of backslashing will get
stripped off when the lexer handles the string constant '{...}'.
Then what arrives at the array-datatype input converter will be
{"value 1", "value \"22\"a", "value 3"}
which accomplishes what you want.
There is actually a bug here: when you write it with zero or one
backslashes, the array input converter is presented with
{"value 1", "value "22"a", "value 3"}
which by all rights should trigger a "malformed array constant"
error message. But it fails to do so; instead the `"value "22'
part is just dropped on the floor, and the "a" part is taken as
the second array element value. The input converter should
complain about this input, I think --- though I'm not quite sure
what it should complain about and what it should accept as an
unquoted array element, as in {123.45, 456.66}. Comments anyone?
regards, tom lane
PS: if you want to comment, please reply to the pgsql-sql list,
which seems more appropriate for this issue.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: tgl@sss.pgh.pa.us, timk@hotgames.com, pgsql-sql@postgreSQL.org
Subject: Re: [INTERFACES] arrays of varchar and "
In-Reply-To: <6297.951454109@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox