pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: David Rowley <david.rowley@2ndquadrant.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Cc: Jesper Pedersen <jesper.pedersen@redhat.com>
Cc: Simon Riggs <simon@2ndquadrant.com>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Cc: Maksim Milyutin <milyutinma@gmail.com>
Cc: Jaime Casanova <jaime.casanova@2ndquadrant.com>
Subject: Re: [HACKERS] Proposal: Local indexes for partitioned table
Date: Thu, 18 Jan 2018 18:43:59 -0300
Message-ID: <20180118214359.w3ojltwyms5n4m5o@alvherre.pgsql> (raw )
In-Reply-To: <20180118155625.npteaei5gdcv6ngl@alvherre.pgsql >
Here's a patch to add pg_dump tests. This verifies that the
CREATE INDEX on parent and partition appear, as well as ALTER INDEX ..
ATTACH PARTITION.
While doing this, I noticed a small bug: the ALTER INDEX would not be
dumped when only one of the schemas are specified to pg_dump (schema of
parent and schema of partition), but it would be if both were specified.
This patch fixes that problem too. AFAICS the test is correct after
that fix (ie. the "like" and "unlike" sets are correct now.)
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:
0001-Add-tests-for-pg_dump-fix-minor-bug-discovered-while.patch (text/plain, 5.4K) download
From f969224f403e317e9e96b519e02d1d215c651b9b Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: Thu, 18 Jan 2018 18:39:52 -0300
Subject: [PATCH] Add tests for pg_dump; fix minor bug discovered while at it
---
src/bin/pg_dump/common.c | 5 ++-
src/bin/pg_dump/pg_dump.c | 10 ++++-
src/bin/pg_dump/t/002_pg_dump.pl | 95 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 107 insertions(+), 3 deletions(-)
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index 9483053680..2ec3627a68 100644
--- a/src/bin/pg_dump/common.c
+++ b/src/bin/pg_dump/common.c
@@ -349,7 +349,10 @@ flagInhTables(Archive *fout, TableInfo *tblinfo, int numTables,
if (find_parents)
findParentsByOid(&tblinfo[i], inhinfo, numInherits);
- /* If needed, mark the parents as interesting for getTableAttrs. */
+ /*
+ * If needed, mark the parents as interesting for getTableAttrs
+ * and getIndexes.
+ */
if (mark_parents)
{
int numParents = tblinfo[i].numParents;
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 92b29e2e5f..40beb3bd48 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -6535,8 +6535,14 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
if (!tbinfo->hasindex)
continue;
- /* Ignore indexes of tables whose definitions are not to be dumped */
- if (!(tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION))
+ /*
+ * Ignore indexes of tables whose definitions are not to be dumped.
+ *
+ * We also need indexes on partitioned tables which have partitions to
+ * be dumped, in order to dump the indexes on the partitions.
+ */
+ if (!(tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION) &&
+ !tbinfo->interesting)
continue;
if (g_verbose)
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index 7cf9bdadb2..6e36b73174 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -5203,6 +5203,101 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog
section_pre_data => 1,
test_schema_plus_blobs => 1, }, },
+ 'CREATE INDEX ON ONLY measurement' => {
+ all_runs => 1,
+ catch_all => 'CREATE ... commands',
+ create_order => 92,
+ create_sql => 'CREATE INDEX ON dump_test.measurement (city_id, logdate);',
+ regexp => qr/^
+ \QCREATE INDEX measurement_city_id_logdate_idx ON ONLY measurement USING\E
+ /xm,
+ like => {
+ binary_upgrade => 1,
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ exclude_dump_test_schema => 1,
+ exclude_test_table => 1,
+ exclude_test_table_data => 1,
+ no_blobs => 1,
+ no_privs => 1,
+ no_owner => 1,
+ only_dump_test_schema => 1,
+ pg_dumpall_dbprivs => 1,
+ schema_only => 1,
+ section_post_data => 1,
+ test_schema_plus_blobs => 1,
+ with_oids => 1, },
+ unlike => {
+ only_dump_test_table => 1,
+ pg_dumpall_globals => 1,
+ pg_dumpall_globals_clean => 1,
+ role => 1,
+ section_pre_data => 1, }, },
+
+ 'CREATE INDEX ... ON measurement_y2006_m2' => {
+ all_runs => 1,
+ catch_all => 'CREATE ... commands',
+ regexp => qr/^
+ \QCREATE INDEX measurement_y2006m2_city_id_logdate_idx ON measurement_y2006m2 \E
+ /xm,
+ like => {
+ binary_upgrade => 1,
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ exclude_dump_test_schema => 1,
+ exclude_test_table => 1,
+ exclude_test_table_data => 1,
+ no_blobs => 1,
+ no_privs => 1,
+ no_owner => 1,
+ pg_dumpall_dbprivs => 1,
+ role => 1,
+ schema_only => 1,
+ section_post_data => 1,
+ with_oids => 1, },
+ unlike => {
+ only_dump_test_schema => 1,
+ only_dump_test_table => 1,
+ pg_dumpall_globals => 1,
+ pg_dumpall_globals_clean => 1,
+ section_pre_data => 1,
+ test_schema_plus_blobs => 1, }, },
+
+ 'ALTER INDEX ... ATTACH PARTITION' => {
+ all_runs => 1,
+ catch_all => 'CREATE ... commands',
+ regexp => qr/^
+ \QALTER INDEX dump_test.measurement_city_id_logdate_idx ATTACH PARTITION dump_test_second_schema.measurement_y2006m2_city_id_logdate_idx\E
+ /xm,
+ like => {
+ binary_upgrade => 1,
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ exclude_dump_test_schema => 1,
+ exclude_test_table => 1,
+ exclude_test_table_data => 1,
+ no_blobs => 1,
+ no_privs => 1,
+ no_owner => 1,
+ pg_dumpall_dbprivs => 1,
+ role => 1,
+ schema_only => 1,
+ section_post_data => 1,
+ with_oids => 1, },
+ unlike => {
+ only_dump_test_schema => 1,
+ only_dump_test_table => 1,
+ pg_dumpall_globals => 1,
+ pg_dumpall_globals_clean => 1,
+ section_pre_data => 1,
+ test_schema_plus_blobs => 1, }, },
+
'CREATE VIEW test_view' => {
all_runs => 1,
catch_all => 'CREATE ... commands',
--
2.11.0
view thread (142+ messages) latest in thread
Message-ID: <20180118214359.w3ojltwyms5n4m5o@alvherre.pgsql>
Permalink: ../20180118214359.w3ojltwyms5n4m5o@alvherre.pgsql/
Also on: postgresql.org/message-id/20180118214359.w3ojltwyms5n4m5o@alvherre.pgsql
copy link · copy postgr.es · copy git am
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 using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@alvh.no-ip.org, peter.eisentraut@2ndquadrant.com, david.rowley@2ndquadrant.com, robertmhaas@gmail.com, Langote_Amit_f8@lab.ntt.co.jp, jesper.pedersen@redhat.com, simon@2ndquadrant.com, milyutinma@gmail.com, jaime.casanova@2ndquadrant.com
Subject: Re: [HACKERS] Proposal: Local indexes for partitioned table
In-Reply-To: <20180118214359.w3ojltwyms5n4m5o@alvherre.pgsql>
* 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