pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedarrays of varchar and "
3+ messages / 2 participants
[nested] [flat]
* arrays of varchar and "
@ 2000-02-24 23:54 Tim Kane <timk@hotgames.com>
0 siblings, 1 reply; 3+ messages in thread
From: Tim Kane @ 2000-02-24 23:54 UTC (permalink / raw)
To: pgsql-interfaces
I don't recall seeing a response to this, so I'm posting it again.
Sorry if you've seen this twice!
(Assuming my original post made it here anyway).
I have.
create table my_table (
varchar stuff[]; # An array of varchar
};
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?
It seems I am unable to escape it it like \" as I normally would for a '
character.
Instead, the parser seems to chop out a portion of the query string...
Known bug?
Is there a workaround?
Thanks Heaps!!
Tim.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [INTERFACES] arrays of varchar and "
@ 2000-02-25 01:03 Tom Lane <tgl@sss.pgh.pa.us>
parent: Tim Kane <timk@hotgames.com>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2000-02-25 01:03 UTC (permalink / raw)
To: Tim Kane <timk@hotgames.com>; +Cc: pgsql-interfaces
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. Will put this
on the "bugs to look at" list. Expect a fix in 7.0.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [INTERFACES] arrays of varchar and "
@ 2000-02-25 04:48 Tom Lane <tgl@sss.pgh.pa.us>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Tom Lane @ 2000-02-25 04:48 UTC (permalink / raw)
To: Tim Kane <timk@hotgames.com>; +Cc: pgsql-interfaces; pgsql-sql@postgreSQL.org
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.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2000-02-25 04:48 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-02-24 23:54 arrays of varchar and " Tim Kane <timk@hotgames.com>
2000-02-25 01:03 ` Tom Lane <tgl@sss.pgh.pa.us>
2000-02-25 04:48 ` Tom Lane <tgl@sss.pgh.pa.us>
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