Lists: | pgsql-bugspgsql-patches |
---|
From: | Kris Jurka <books(at)ejurka(dot)com> |
---|---|
To: | <pgsql-bugs(at)postgresql(dot)org> |
Subject: | COPY allows parameters which corrupt output |
Date: | 2004-01-12 18:32:16 |
Message-ID: | Pine.LNX.4.33.0401121326400.10270-200000@leary.csoft.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs pgsql-patches |
COPY allows DELIMITER and NULL to be specified which don't allow the data
to be copied back in properly. Using any delimiter that could be part of
a backslash escape sequence (\n \0 \t) will break if any of the data has a
character matching the delimiter because it will be escaped and then be
read as a special character.
It also allows DELIMITER and NULL to overlap. No character in the NULL
specification should be the DELIMITER.
Kris Jurka
Attachment | Content-Type | Size |
---|---|---|
copytest.sql | text/plain | 209 bytes |
From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Kris Jurka <books(at)ejurka(dot)com> |
Cc: | PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | Re: [BUGS] COPY allows parameters which corrupt output |
Date: | 2004-04-06 13:21:59 |
Message-ID: | 200404061321.i36DLxL14289@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs pgsql-patches |
Kris Jurka wrote:
>
> COPY allows DELIMITER and NULL to be specified which don't allow the data
> to be copied back in properly. Using any delimiter that could be part of
> a backslash escape sequence (\n \0 \t) will break if any of the data has a
> character matching the delimiter because it will be escaped and then be
> read as a special character.
>
> It also allows DELIMITER and NULL to overlap. No character in the NULL
> specification should be the DELIMITER.
The attached applied patch throws an error if the delimiter appears in
the COPY NULL string:
test=> copy pg_language to '/tmp/x' with delimiter '|';
COPY
test=> copy pg_language to '/tmp/x' with delimiter '|' null '|x';
ERROR: COPY delimiter must not appear in the NULL specification
test=> copy pg_language from '/tmp/x' with delimiter '|' null '|x';
ERROR: COPY delimiter must not appear in the NULL specification
It also throws an error if it conflicts with the default NULL string:
test=> copy pg_language to '/tmp/x' with delimiter '\\';
ERROR: COPY delimiter must not appear in the NULL specification
test=> copy pg_language to '/tmp/x' with delimiter '\\' NULL 'x';
COPY
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Attachment | Content-Type | Size |
---|---|---|
unknown_filename | text/plain | 838 bytes |