public inbox for [email protected]help / color / mirror / Atom feed
[PATCH v8 5/8] Invalidate parent indexes 2+ messages / 2 participants [nested] [flat]
* [PATCH v8 5/8] Invalidate parent indexes @ 2020-11-06 00:58 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 2+ messages in thread From: Justin Pryzby @ 2020-11-06 00:58 UTC (permalink / raw) --- src/backend/commands/cluster.c | 21 +++++++++++++++++++++ src/test/regress/expected/cluster.out | 26 ++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 8 ++++++++ 3 files changed, 55 insertions(+) diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 5c08f0642e..60272bc010 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -600,6 +600,27 @@ mark_index_clustered(Relation rel, Oid indexOid, bool is_internal) } list_free(inh); + /* + * Set parent of all indexes as unclustered when a rel is unclustered; and, + * when an index is clustered, set parents of all /other/ indexes as + * unclustered. + */ + indexes = RelationGetIndexList(rel); + foreach (lc, indexes) + { + Oid thisIndexOid = lfirst_oid(lc); + + if (thisIndexOid == indexOid) + continue; + + while (get_rel_relispartition(thisIndexOid)) + { + thisIndexOid = get_partition_parent(thisIndexOid); + set_indisclustered(thisIndexOid, false, pg_index); + } + } + list_free(indexes); + table_close(pg_index, RowExclusiveLock); } diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 1d436dfaae..6cba3cc4f9 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -541,6 +541,32 @@ Indexes: "clstrpart1_idx_2" btree (a) CLUSTER Number of partitions: 2 (Use \d+ to list them.) +-- Check that the parent index is marked not clustered after clustering a partition on a different index: +ALTER TABLE clstrpart CLUSTER ON clstrpart_idx; +CLUSTER clstrpart1 USING clstrpart1_idx_2; +\d clstrpart + Partitioned table "public.clstrpart" + Column | Type | Collation | Nullable | Default +--------+---------+-----------+----------+--------- + a | integer | | | +Partition key: RANGE (a) +Indexes: + "clstrpart_idx" btree (a) +Number of partitions: 3 (Use \d+ to list them.) + +-- Check that the parent index is marked not clustered after setting a partition not clustered: +ALTER TABLE clstrpart CLUSTER ON clstrpart_idx; +ALTER TABLE clstrpart1 SET WITHOUT CLUSTER; +\d clstrpart + Partitioned table "public.clstrpart" + Column | Type | Collation | Nullable | Default +--------+---------+-----------+----------+--------- + a | integer | | | +Partition key: RANGE (a) +Indexes: + "clstrpart_idx" btree (a) +Number of partitions: 3 (Use \d+ to list them.) + -- Test CLUSTER with external tuplesorting create table clstr_4 as select * from tenk1; create index cluster_sort on clstr_4 (hundred, thousand, tenthous); diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 0ded2be1ca..a1d132f288 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -231,6 +231,14 @@ CREATE INDEX clstrpart1_idx_2 ON clstrpart1(a); ALTER TABLE clstrpart CLUSTER ON clstrpart_idx; ALTER TABLE clstrpart1 CLUSTER ON clstrpart1_idx_2; \d clstrpart1 +-- Check that the parent index is marked not clustered after clustering a partition on a different index: +ALTER TABLE clstrpart CLUSTER ON clstrpart_idx; +CLUSTER clstrpart1 USING clstrpart1_idx_2; +\d clstrpart +-- Check that the parent index is marked not clustered after setting a partition not clustered: +ALTER TABLE clstrpart CLUSTER ON clstrpart_idx; +ALTER TABLE clstrpart1 SET WITHOUT CLUSTER; +\d clstrpart -- Test CLUSTER with external tuplesorting -- 2.17.0 --O5XBE6gyVG5Rl6Rj Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v8-0006-Invalidate-parent-index-cluster-on-attach.patch" ^ permalink raw reply [nested|flat] 2+ messages in thread
* Tab completion for ALTER MATERIALIZED VIEW ... SET ACCESS METHOD @ 2022-03-16 04:33 Yugo NAGATA <[email protected]> 0 siblings, 0 replies; 2+ messages in thread From: Yugo NAGATA @ 2022-03-16 04:33 UTC (permalink / raw) To: pgsql-hackers Hello hackers, SET ACCESS METHOD is supported in ALTER TABLE since the commit b0483263dd. Since that time, this also has be allowed SET ACCESS METHOD in ALTER MATERIALIZED VIEW. Although it is not documented, this works. I cannot found any reasons to prohibit SET ACCESS METHOD in ALTER MATERIALIZED VIEW, so I think it is better to support this in psql tab-completion and be documented. I attached a patch to fix the tab-completion and the documentation about this syntax. Also, I added description about SET TABLESPACE syntax that would have been overlooked. Regards, Yugo Nagata -- Yugo NAGATA <[email protected]> Attachments: [text/x-diff] tab_complete_alter_matview.patch (2.3K, ../../[email protected]/2-tab_complete_alter_matview.patch) download | inline diff: diff --git a/doc/src/sgml/ref/alter_materialized_view.sgml b/doc/src/sgml/ref/alter_materialized_view.sgml index 7011a0e7da..cae135c27a 100644 --- a/doc/src/sgml/ref/alter_materialized_view.sgml +++ b/doc/src/sgml/ref/alter_materialized_view.sgml @@ -43,6 +43,8 @@ ALTER MATERIALIZED VIEW ALL IN TABLESPACE <replaceable class="parameter">name</r ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET COMPRESSION <replaceable class="parameter">compression_method</replaceable> CLUSTER ON <replaceable class="parameter">index_name</replaceable> SET WITHOUT CLUSTER + SET ACCESS METHOD <replaceable class="parameter">new_access_method</replaceable> + SET TABLESPACE <replaceable class="parameter">new_tablespace</replaceable> SET ( <replaceable class="parameter">storage_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) RESET ( <replaceable class="parameter">storage_parameter</replaceable> [, ... ] ) OWNER TO { <replaceable class="parameter">new_owner</replaceable> | CURRENT_ROLE | CURRENT_USER | SESSION_USER } diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 6957567264..daf4206caa 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2124,7 +2124,7 @@ psql_completion(const char *text, int start, int end) COMPLETE_WITH("TO"); /* ALTER MATERIALIZED VIEW xxx SET */ else if (Matches("ALTER", "MATERIALIZED", "VIEW", MatchAny, "SET")) - COMPLETE_WITH("(", "SCHEMA", "TABLESPACE", "WITHOUT CLUSTER"); + COMPLETE_WITH("(", "ACCESS METHOD", "SCHEMA", "TABLESPACE", "WITHOUT CLUSTER"); /* ALTER POLICY <name> */ else if (Matches("ALTER", "POLICY")) COMPLETE_WITH_QUERY(Query_for_list_of_policies); @@ -2485,6 +2485,13 @@ psql_completion(const char *text, int start, int end) else if (Matches("ALTER", "TYPE", MatchAny, "RENAME", "VALUE")) COMPLETE_WITH_ENUM_VALUE(prev3_wd); + /* + * If we have ALTER MATERIALIZED VIEW <sth> SET ACCESS METHOD provide a list of table + * AMs. + */ + else if (Matches("ALTER", "MATERIALIZED", "VIEW", MatchAny, "SET", "ACCESS", "METHOD")) + COMPLETE_WITH_QUERY(Query_for_list_of_table_access_methods); + /* * ANALYZE [ ( option [, ...] ) ] [ table_and_columns [, ...] ] * ANALYZE [ VERBOSE ] [ table_and_columns [, ...] ] ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2022-03-16 04:33 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-11-06 00:58 [PATCH v8 5/8] Invalidate parent indexes Justin Pryzby <[email protected]> 2022-03-16 04:33 Tab completion for ALTER MATERIALIZED VIEW ... SET ACCESS METHOD Yugo NAGATA <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox