Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id XAA66302; Thu, 24 Feb 2000 23:48:54 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id XAA06300; Thu, 24 Feb 2000 23:48:29 -0500 (EST) To: Tim Kane cc: PSQL Interfaces , pgsql-sql@postgreSQL.org Reply-To: pgsql-sql@postgreSQL.org Subject: Re: [INTERFACES] arrays of varchar and " In-reply-to: <23718.951440617@sss.pgh.pa.us> References: <38B5C4AA.A84809F2@hotgames.com> <23718.951440617@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Thu, 24 Feb 2000 20:03:37 -0500" Date: Thu, 24 Feb 2000 23:48:29 -0500 Message-ID: <6297.951454109@sss.pgh.pa.us> From: Tom Lane I wrote: > Tim Kane 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.