Skip to content

the last row is repeated on the PGCopyInputStream  #2016

@leozhang123

Description

@leozhang123

Describe the issue
When use PGCopyInputStream to get data, the last row is repeated.

Driver Version?
postgresql-42.2.18
Java Version?
jdk8
OS Version?
windows 10
PostgreSQL Version?
PostgreSQL 8.3.23 (Greenplum Database 5.21.5 build 9999) (HashData Warehouse 2.5.5 build dev)
To Reproduce

this my code:

String copyUCmd="COPY (SELECT casing_tally_id FROM btest limit 1) TO STDOUT WITH CSV DELIMITER AS '|' QUOTE AS '\"'";
try(PGCopyInputStream pgUOut = new PGCopyInputStream(  (PGConnection) con, copyUCmd )){
byte[] readFromCopy = pgUOut.readFromCopy();
			while(readFromCopy!=null) {
				System.out.print(new String(readFromCopy));
				readFromCopy = pgUOut.readFromCopy();
			}
			System.out.println(pgUOut.getHandledRowCount());
}

the console print:

ZJDRM02BESCUCZ
ZJDRM02BESCUCZ
1

Expected behaviour
I think the right print:

ZJDRM02BESCUCZ
1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions