BUG #19403: psql fails when trying to import a file that - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #19403: psql fails when trying to import a file that
Date
Msg-id 19403-59b4099e771c1f2e@postgresql.org
Whole thread Raw
Responses Re: BUG #19403: psql fails when trying to import a file that
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      19403
Logged by:          Daniel Adeniji
Email address:      daniel_adeniji@hotmail.com
PostgreSQL version: 17.6
Operating system:   MS Windows 10 ( PostgreSQL 17.6 on x86_64-windows
Description:

Database Table
--------------------
CREATE TABLE public.codeblock
(
        id int4 NULL,
        body text NULL
);

Text File
-----------
Id,Body
1,"{}
\.
"


Command
--------------
psql.exe --host  --command "\copy public.codeblock from
'c:\tmp\codeblock.csv'  WITH (HEADER, FORMAT CSV, ENCODING 'UTF8', DELIMITER
','   )"

Error Message reads:-

ERROR:  unterminated CSV quoted field
CONTEXT:  COPY codeblock, line 4: "1,"{}
\.
"

The same data works when inserted within an insert statement:-

delete

from public.codeblock

where id = 1;

insert into public.codeblock
(
    Id,Body
)
values
(

  1
  ,'{}
\.
'
)
;

It also works when the server-side copy statement is used:-

psql.exe --host  --command "copy public.codeblock from
'c:\tmp\codeblock.csv'  WITH (HEADER, FORMAT CSV, ENCODING 'UTF8', DELIMITER
','   )"

In the example above, \copy is replaced with the copy command and file is
availed on the server.

Data file availed at

1) One Compiler

https://onecompiler.com/text/44dbtdb52

2) GitLab

https://gitlab.com/-/snippets/5933548





pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #19402: CREATE TABLE IF NOT EXISTS raises DuplicateTable error under concurrent partition creation
Next
From: surya poondla
Date:
Subject: Re: Two issues with REFRESH MATERIALIZED VIEW CONCURRENTLY