pgsql: Allow "COPY table TO" command to copy rows from materialized vie

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Allow "COPY table TO" command to copy rows from materialized vie
Date: 2025-04-04 10:33:00
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Allow "COPY table TO" command to copy rows from materialized views.

Previously, "COPY table TO" command worked only with plain tables and
did not support materialized views, even when they were populated and
had physical storage. To copy rows from materialized views,
"COPY (query) TO" command had to be used, instead.

This commit extends "COPY table TO" to support populated materialized
views directly, improving usability and performance, as "COPY table TO"
is generally faster than "COPY (query) TO". Note that copying from
unpopulated materialized views will still result in an error.

Author: jian he <jian(dot)universality(at)gmail(dot)com>
Reviewed-by: Kirill Reshke <reshkekirill(at)gmail(dot)com>
Reviewed-by: David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
Reviewed-by: Vignesh C <vignesh21(at)gmail(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/CACJufxHVxnyRYy67hiPePNCPwVBMzhTQ6FaL9_Te5On9udG=yg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/534874fac0b34535c9a5ab9257d6574f78423578

Modified Files
--------------
doc/src/sgml/ref/copy.sgml | 20 ++++++++++----------
src/backend/commands/copyto.c | 13 ++++++++-----
src/test/regress/expected/copy.out | 12 ++++++++++++
src/test/regress/sql/copy.sql | 9 +++++++++
4 files changed, 39 insertions(+), 15 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2025-04-04 11:04:49 pgsql: Relax assertion in finding correct GiST parent
Previous Message Peter Eisentraut 2025-04-04 10:31:12 pgsql: Support non-btree indexes in get_actual_variable_range()