Allow COPY FROM to filter data using WHERE conditions

Enterprise / PostgreSQL - Tomas Vondra [postgresql.org] - 19 January 2019 23:22 EST

Extends the COPY FROM command with a WHERE condition, which allows doing
various types of filtering while importing the data (random sampling, condition on a data column, etc.). Until now such filtering required either preprocessing of the input data, or importing all data and then filtering in the database. COPY FROM ... WHERE is an easy-to-use and low-overhead alternative for most simple cases.

Author: Surafel Temesgen

31f3817402 Allow COPY FROM to filter data using WHERE conditions
doc/src/sgml/ref/copy.sgml | 27 ++++++++++++++++++
src/backend/commands/copy.c | 49 +++++++++++++++++++++++++++++++++
src/backend/nodes/copyfuncs.c | 1 +
src/backend/nodes/equalfuncs.c | 1 +
src/backend/parser/gram.y | 10 ++++++-
src/backend/parser/parse_agg.c | 11 ++++++++
src/backend/parser/parse_expr.c | 5 ++++
src/backend/parser/parse_func.c | 3 ++
src/include/nodes/parsenodes.h | 1 +
src/include/parser/parse_node.h | 3 +-
src/interfaces/ecpg/preproc/ecpg.addons | 2 +-
src/test/regress/expected/copy2.out | 40 ++++++++++++++++++++++++++-
src/test/regress/sql/copy2.sql | 26 +++++++++++++++++
13 files changed, 175 insertions(+), 4 deletions(-)

Upstream: git.postgresql.org


  • Share