bug in 7.4.2, with Handling of Double Quotation Marks

Lists: pgsql-bugspgsql-general
From: Alexander S <sasha(at)in(dot)crimea(dot)ua>
To: pgsql-general(at)postgresql(dot)org, pgsql-bugs(at)postgresql(dot)org
Subject: bug in 7.4.2, with Handling of Double Quotation Marks
Date: 2004-03-31 08:39:52
Message-ID: 406A83D8.7050307@in.crimea.ua
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-general

Bug in 7.4.2.. Concern with handling of Double Quotation Marks (").
Escape of double quotation marks can't solve the problem.

----------
CREATE TABLE public.test
(
my_column varchar NOT NULL,
CONSTRAINT my_primary PRIMARY KEY (my_column)
) WITHOUT OIDS;
-----------
CREATE TABLE public.ref_test
(
my_column varchar[]
) WITH OIDS;
-----------
CREATE FUNCTION public."t-f_ref_test"()
RETURNS trigger AS
'BEGIN
FOR i IN 1..30 LOOP
IF NEW."my_column"[i] not in (select "my_column" from public.test) THEN
RAISE EXCEPTION \'error: my_column[] --> test.my_column \';
END IF;
END LOOP;
RETURN NEW;
END;'
LANGUAGE 'plpgsql' VOLATILE;
----------
CREATE TRIGGER t_ref_test
BEFORE INSERT OR UPDATE
ON public.ref_test
FOR EACH ROW
EXECUTE PROCEDURE public."t-f_ref_test"();
----------
insert into test values (' here \"some_text\" ');
----------
insert into ref_test values (' {here \"some_text\"} ');

But here postgres answers: error: my_column[] --> test.my_column.
So I think this exception should not appear here and this is bug.
Instead I can only insert:
--
insert into ref_test values (' {here \\"some_text\\"} '); -- but
this is not exactly that i want to have.
--
Without "" in row of public.test - all works fine, but its important for
me to use "" in my templates (database public.test).


From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Alexander S <sasha(at)in(dot)crimea(dot)ua>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-bugs(at)postgresql(dot)org
Subject: Re: bug in 7.4.2, with Handling of Double Quotation Marks
Date: 2004-04-06 00:00:07
Message-ID: 20040405165823.W19491@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-general


On Wed, 31 Mar 2004, Alexander S wrote:

> Bug in 7.4.2.. Concern with handling of Double Quotation Marks (").
> Escape of double quotation marks can't solve the problem.
>
> ----------
> CREATE TABLE public.test
> (
> my_column varchar NOT NULL,
> CONSTRAINT my_primary PRIMARY KEY (my_column)
> ) WITHOUT OIDS;
> -----------
> CREATE TABLE public.ref_test
> (
> my_column varchar[]
> ) WITH OIDS;
> -----------
> CREATE FUNCTION public."t-f_ref_test"()
> RETURNS trigger AS
> 'BEGIN
> FOR i IN 1..30 LOOP
> IF NEW."my_column"[i] not in (select "my_column" from public.test) THEN
> RAISE EXCEPTION \'error: my_column[] --> test.my_column \';
> END IF;
> END LOOP;
> RETURN NEW;
> END;'
> LANGUAGE 'plpgsql' VOLATILE;
> ----------
> CREATE TRIGGER t_ref_test
> BEFORE INSERT OR UPDATE
> ON public.ref_test
> FOR EACH ROW
> EXECUTE PROCEDURE public."t-f_ref_test"();
> ----------
> insert into test values (' here \"some_text\" ');
> ----------
> insert into ref_test values (' {here \"some_text\"} ');
>
> But here postgres answers: error: my_column[] --> test.my_column.
> So I think this exception should not appear here and this is bug.
> Instead I can only insert:
> --
> insert into ref_test values (' {here \\"some_text\\"} '); -- but
> this is not exactly that i want to have.

What is the specific problem you're having, is it needing the double
backslashes on insert? is it the output format backslash escaping
quotation marks?


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexander S <sasha(at)in(dot)crimea(dot)ua>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-bugs(at)postgresql(dot)org
Subject: Re: bug in 7.4.2, with Handling of Double Quotation Marks
Date: 2004-04-06 05:07:25
Message-ID: 19390.1081228045@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-general

Alexander S <sasha(at)in(dot)crimea(dot)ua> writes:
> Instead I can only insert:
> insert into ref_test values (' {here \\"some_text\\"} '); -- but
> this is not exactly that i want to have.

Unfortunately, that is what the syntax of array literals requires you to
say.

You might find it easier to work with the ARRAY[] constructor syntax.

regards, tom lane