pgsql: Allow COPY FROM to filter data using WHERE conditions

From: Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Allow COPY FROM to filter data using WHERE conditions
Date: 2019-01-19 23:22:26
Message-ID: E1gkzwY-0006NV-EH@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Allow COPY FROM to filter data using WHERE conditions

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
Reviewed-by: Tomas Vondra, Masahiko Sawada, Lim Myungkyu
Discussion: https://www.postgresql.org/message-id/flat/CALAY4q_DdpWDuB5-Zyi-oTtO2uSk8pmy+dupiRe3AvAc++1imA(at)mail(dot)gmail(dot)com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/31f3817402da736b29014ace470cf70aeb126ac5

Modified Files
--------------
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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Etsuro Fujita 2019-01-21 08:15:09 pgsql: Postpone generating tlists and EC members for inheritance dummy
Previous Message Tom Lane 2019-01-19 20:53:33 Re: pgsql: Remove references to Majordomo