Is it safe to use the extended protocol with COPY?

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Is it safe to use the extended protocol with COPY?
Date: 2021-09-01 16:25:29
Message-ID: CA+mi_8Y3Kpb-hViZ5EXdyS9LfeTNWAwkMF1VD-Ttw7n8nJB9oA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

in psycopg 3 we are currently using PQexecParams - although with no
params - to send COPY commands. The reason is mostly to avoid people
to send COPY together with other statements. Especially if other
operations are chained after COPY: we would only notice them after
copy is finished. Data changes might have been applied by then, so
throwing an exception seems impolite (the result might have been
applied already) but managing the result is awkward too.

Someone [1] has pointed out this conversation [2] which suggests that
COPY with extended protocol might break in the future.

[1] https://github.com/psycopg/psycopg/issues/78
[2] https://www.postgresql.org/message-id/flat/CAMsr%2BYGvp2wRx9pPSxaKFdaObxX8DzWse%2BOkWk2xpXSvT0rq-g%40mail(dot)gmail(dot)com#CAMsr+YGvp2wRx9pPSxaKFdaObxX8DzWse+OkWk2xpXSvT0rq-g(at)mail(dot)gmail(dot)com

As far as PostgreSQL is concerned, would it be better to stick to
PQexec with COPY, and if people append statements afterwards they
would be the ones to deal with the consequences? (being the server
applying the changes, the client throwing an exception)

Thank you very much

-- Daniele

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2021-09-01 16:32:38 Re: 2021-09 Commitfest
Previous Message Jacob Champion 2021-09-01 16:12:44 Re: [PATCH] test/ssl: rework the sslfiles Makefile target