Re: raw output from copy

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: raw output from copy
Дата
Msg-id CAFj8pRAsqOzq=0+RfvEHUTtfdZbftQrfb5uvKW9wSkZ4nhuqGQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: raw output from copy  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-hackers


2016-03-04 18:06 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:


2016-03-04 15:54 GMT+01:00 Daniel Verite <daniel@manitou-mail.org>:
        Corey Huinker wrote:

> So, for me, RAW is the right solution, or at least *a* right solution.

Questions on how to extract from a bytea column come up on a regular
basis, as in [1] [2] [3], or [4] a few days ago, and so far the answers
are to encode the contents in text and decode them in an additional
step, or use COPY BINARY and filter out the headers.

But none of this is as straightforward and efficient as the proposed
COPY RAW.
Also the conversion to text can't be used at all on very large
contents (>512MB), as mentioned in another recent thread [5]
(this is the same reason why pg_dump can't dump such rows),
but COPY RAW doesn't have this limitation.

Technically COPY BINARY should be sufficient, but it seems that
people dislike having to deal with its headers.
Also it's not supported by any of the drivers of popular
script languages that otherwise provide COPY in text format
(DBD::Pg, php, psycopg2...)
Maybe the RAW format would have a better chance to get support
there, because of its simplicity.

exactly - I would to decrease dependency on PostgreSQL internals. Working with clean content is simple and possible with any environment without unclean operations.

COPY RAW can be used for import. I am not sure if this use case was tested.

cat image.jpg | psql -c "CREATE TEMP TABLE auxbuf(image bytea); COPY auxbuf(image) FROM stdin RAW; ..." postgres

Regards

Pavel


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

Предыдущее
От: Fabien COELHO
Дата:
Сообщение: Re: extend pgbench expressions with functions
Следующее
От: Tom Lane
Дата:
Сообщение: Re: WIP: Upper planner pathification