mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
Add two IO wait events for COPY FROM/TO on a pipe/file/program
Two wait events are added to the COPY FROM/TO code: * COPY_FROM_READ: reading data from a copy_file. * COPY_TO_WRITE: writing data to a copy_file. In the COPY code, copy_file can be set when processing a command through the pipe mode (for the non-DestRemote case), the program mode or the file mode, when processing fread() or fwrite() on it. Author: Nikolay Samokhvalov <nik@postgres.ai> Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com> Reviewed-by: Sami Imseih <samimseih@gmail.com> Discussion: https://postgr.es/m/CAM527d_iDzz0Kqyi7HOfqa-Xzuq29jkR6AGXqfXLqA5PR5qsng@mail.gmail.com
This commit is contained in:
@@ -249,7 +249,9 @@ CopyGetData(CopyFromState cstate, void *databuf, int minread, int maxread)
|
||||
switch (cstate->copy_src)
|
||||
{
|
||||
case COPY_FILE:
|
||||
pgstat_report_wait_start(WAIT_EVENT_COPY_FROM_READ);
|
||||
bytesread = fread(databuf, 1, maxread, cstate->copy_file);
|
||||
pgstat_report_wait_end();
|
||||
if (ferror(cstate->copy_file))
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
|
||||
@@ -454,6 +454,7 @@ CopySendEndOfRow(CopyToState cstate)
|
||||
switch (cstate->copy_dest)
|
||||
{
|
||||
case COPY_FILE:
|
||||
pgstat_report_wait_start(WAIT_EVENT_COPY_TO_WRITE);
|
||||
if (fwrite(fe_msgbuf->data, fe_msgbuf->len, 1,
|
||||
cstate->copy_file) != 1 ||
|
||||
ferror(cstate->copy_file))
|
||||
@@ -486,6 +487,7 @@ CopySendEndOfRow(CopyToState cstate)
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not write to COPY file: %m")));
|
||||
}
|
||||
pgstat_report_wait_end();
|
||||
break;
|
||||
case COPY_FRONTEND:
|
||||
/* Dump the accumulated row as one CopyData message */
|
||||
|
||||
@@ -213,6 +213,8 @@ CONTROL_FILE_WRITE_UPDATE "Waiting for a write to update the <filename>pg_contro
|
||||
COPY_FILE_COPY "Waiting for a file copy operation."
|
||||
COPY_FILE_READ "Waiting for a read during a file copy operation."
|
||||
COPY_FILE_WRITE "Waiting for a write during a file copy operation."
|
||||
COPY_FROM_READ "Waiting to read data from a pipe, a file or a program during COPY FROM."
|
||||
COPY_TO_WRITE "Waiting to write data to a pipe, a file or a program during COPY TO."
|
||||
DATA_FILE_EXTEND "Waiting for a relation data file to be extended."
|
||||
DATA_FILE_FLUSH "Waiting for a relation data file to reach durable storage."
|
||||
DATA_FILE_IMMEDIATE_SYNC "Waiting for an immediate synchronization of a relation data file to durable storage."
|
||||
|
||||
Reference in New Issue
Block a user