Behaviours: epgsql_command.
Tells server to switch to "COPY-in" mode
See https://www.postgresql.org/docs/current/sql-copy.html. See https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-COPY.
When Format
is text
, copy data should then be delivered using Erlang
io protocol.
See file:write/2
, io:put_chars/2
.
"End-of-data" marker \.
at the end of TEXT or CSV data stream is not needed.
When Format
is {binary, [epgsql_type()]}
, recommended way to deliver data is
epgsql:copy_send_rows/3
. IO-protocol can be used as well, as long as you can
do proper binary encoding of data tuples (header and trailer are sent automatically),
see https://www.postgresql.org/docs/current/sql-copy.html#id-1.9.3.55.9.4.6.
When you don't know what are the correct type names for your columns, you could try to
construct equivalent INSERT
or SELECT
statement and call epgsql:parse/2
command.
It will return #statement{columns = [#column{type = TypeName}]}
with correct type names.
epgsql_cmd_copy_done
should be called in the end.
This command should not be used with command pipelining!
> SQuery COPY ... FROM STDIN ... < CopyInResponse > CopyData* -- implemented in io protocol, not here > CopyDone | CopyFail -- implemented in epgsql_cmd_copy_done < CommandComplete -- implemented in epgsql_cmd_copy_done
response() = {ok, [text | binary]} | {error, epgsql:query_error()}
execute/2 | |
handle_message/4 | |
init/1 |
execute(Sock, Copy_stdin) -> any()
handle_message(X1, Error, Sock, Copy_stdin) -> any()
init(X1) -> any()
Generated by EDoc