pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix missing call to table_finish_bulk_insert during COPY
Date: Mon, 01 Jul 2019 13:23:58 +0000
Message-ID: <E1hhwHm-0001QQ-Ue@gemulon.postgresql.org> (raw)

Fix missing call to table_finish_bulk_insert during COPY

86b85044e abstracted calls to heap functions in COPY FROM to support a
generic table AM.  However, when performing a copy into a partitioned
table, this commit neglected to call table_finish_bulk_insert for each
partition.  Before 86b85044e, when we always called the heap functions,
there was no need to call heapam_finish_bulk_insert for partitions since
it only did any work when performing a copy without WAL. For partitioned
tables, this was unsupported anyway, so there was no issue. With pluggable
storage, we can't make any assumptions about what the table AM might want
to do in its equivalent function, so we'd better ensure we always call
table_finish_bulk_insert each partition that's received a row.

For now, we make the table_finish_bulk_insert call whenever we evict a
CopyMultiInsertBuffer out of the CopyMultiInsertInfo.  This does mean
that it's possible that we call table_finish_bulk_insert multiple times
per partition, which is not a problem other than being an inefficiency.
Improving this requires a more invasive patch, so let's leave that for
another day.

In passing, move the table_finish_bulk_insert for the target of the COPY
command so that it's only called when we're actually performing bulk
inserts.  We don't need to call this when inserting 1 row at a time.

Reported-by: Robert Haas
Discussion: https://postgr.es/m/CA+TgmoYK=6BpxiJ0tN-p9wtH0BTAfbdxzHhwou0mdud4+BkYuQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4de60244e2fcdeb100afc7f8bf5c28b32923a637

Modified Files
--------------
src/backend/commands/copy.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1hhwHm-0001QQ-Ue@gemulon.postgresql.org>
Permalink:  ../E1hhwHm-0001QQ-Ue@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1hhwHm-0001QQ-Ue@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: drowley@postgresql.org
  Subject: Re: pgsql: Fix missing call to table_finish_bulk_insert during COPY
  In-Reply-To: <E1hhwHm-0001QQ-Ue@gemulon.postgresql.org>
  References: <E1hhwHm-0001QQ-Ue@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox