Fix performance problem with new COPY DEFAULT code
authorDavid Rowley <drowley@postgresql.org>
Thu, 27 Jul 2023 02:47:05 +0000 (14:47 +1200)
committerDavid Rowley <drowley@postgresql.org>
Thu, 27 Jul 2023 02:47:05 +0000 (14:47 +1200)
commitb635ac03e80237838bec8b224eb4dea97985fda3
tree869795c012da804e2d45acbc22fa462089893b80
parentf6a84546b1a0ae43c00a7f351bc45fbde342466a
Fix performance problem with new COPY DEFAULT code

9f8377f7a added code to allow COPY FROM insert a column's default value
when the input matches the DEFAULT string specified in the COPY command.

Here we fix some inefficient code which needlessly palloc0'd an array to
store if we should use the default value or input value for the given
column.  This array was being palloc0'd and pfree'd once per row.  It's
much more efficient to allocate this once and just reset the values once
per row.

Reported-by: Masahiko Sawada
Author: Masahiko Sawada
Discussion: https://postgr.es/m/CAD21AoDvDmUQeJtZrau1ovnT_smN940%3DKp6mszNGK3bq9yRN6g%40mail.gmail.com
Backpatch-through: 16, where 9f8377f7a was introduced.
src/backend/commands/copyfrom.c
src/backend/commands/copyfromparse.c