Re: BUG #16300: Text line order corruption with COPY command

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: BUG #16300: Text line order corruption with COPY command
Дата
Msg-id CAKFQuwZnzqUD2MapyvNO-dXknLRFp-o_x0FOTzpz+cEwrYjchg@mail.gmail.com
обсуждение исходный текст
Ответ на BUG #16300: Text line order corruption with COPY command  (PG Bug reporting form <noreply@postgresql.org>)
Ответы AW: BUG #16300: Text line order corruption with COPY command  (Hans Buschmann <buschmann@nidsa.net>)
Список pgsql-bugs
On Thu, Mar 12, 2020 at 1:05 PM PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:

Bug reference:      16300
Logged by:          Hans Buschmann
Email address:      buschmann@nidsa.net
PostgreSQL version: 12.2
Operating system:   Windows Server 2019 64bit
Description:       

A reproducable line order corruption occurs when copying a quite large test
file into Postgres.


IIUC you copied data into PostgreSQL and then immediately read it out using SELECT without an ORDER BY and expected to get the same physical row order as the inserted data.  Nothing promises that things will work this way though often times they do.

If order matters to you you need to add an ORDER BY.  Since there is nothing natural to order by here you have to decide on how you want to change your setup.  I believe that adding a bigserial column to the table will result in the sequence generator applying numbers in strictly ascending order matching the input order and then you can sort on that column.  This is probably the simplest solution.  You can add row numbers to the source file just before importing it.  Or you can import the entire file to a text field and then split_to_array and rely upon that ordering.

David J.

В списке pgsql-bugs по дате отправления:

Предыдущее
От: PG Bug reporting form
Дата:
Сообщение: BUG #16300: Text line order corruption with COPY command
Следующее
От: Hans Buschmann
Дата:
Сообщение: AW: BUG #16300: Text line order corruption with COPY command