ToDo: allow to get a number of processed rows by COPY statement - Mailing list pgsql-hackers

From Pavel Stehule
Subject ToDo: allow to get a number of processed rows by COPY statement
Date
Msg-id CAFj8pRAeEUSP8zuNkNcMP1gkr_i9KVN76S+A+13ehj=Z8E5Wow@mail.gmail.com
Whole thread Raw
Responses Re: ToDo: allow to get a number of processed rows by COPY statement
Re: ToDo: allow to get a number of processed rows by COPY statement
List pgsql-hackers
Hello

There is not possible to get a number of processed rows when COPY is
evaluated via SPI. Client can use a tag, but SPI doesn't use a tag.

I propose a small change a ProcessUtility to return a processed rows.

Note: I found a small inconsistency between SPI and Utility interface.
SPI still use a 4 byte unsign int for storing a number of processed
rows. Utility use a 8bytes unsign int.

Motivation:

 postgres=# \sf fx
CREATE OR REPLACE FUNCTION public.fx(tablename text, filename text)
 RETURNS integer
 LANGUAGE plpgsql
AS $function$
declare r int;
begin
  execute format('COPY %s FROM %s', quote_ident(tablename),
quote_literal(filename));
  get diagnostics r = row_count;
  return r;
end;
$function$

Regards

Pavel Stehule

Attachment

pgsql-hackers by date:

Previous
From: Shigeru Hanada
Date:
Subject: Re: WIP: Join push-down for foreign tables
Next
From: Fujii Masao
Date:
Subject: Re: [REVIEW] pg_last_xact_insert_timestamp