diff options
-rw-r--r-- | doc/src/sgml/ref/alter_materialized_view.sgml | 1 | ||||
-rw-r--r-- | src/bin/psql/tab-complete.c | 6 | ||||
-rw-r--r-- | src/test/regress/expected/create_am.out | 26 | ||||
-rw-r--r-- | src/test/regress/sql/create_am.sql | 10 |
4 files changed, 42 insertions, 1 deletions
diff --git a/doc/src/sgml/ref/alter_materialized_view.sgml b/doc/src/sgml/ref/alter_materialized_view.sgml index c6a132de068..cae135c27a0 100644 --- a/doc/src/sgml/ref/alter_materialized_view.sgml +++ b/doc/src/sgml/ref/alter_materialized_view.sgml @@ -43,6 +43,7 @@ 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> [, ... ] ) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 380cbc0b1fc..7b331a38ae0 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2124,7 +2124,11 @@ 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 MATERIALIZED VIEW xxx SET ACCESS METHOD */ + else if (Matches("ALTER", "MATERIALIZED", "VIEW", MatchAny, "SET", "ACCESS", "METHOD")) + COMPLETE_WITH_QUERY(Query_for_list_of_table_access_methods); + /* ALTER POLICY <name> */ else if (Matches("ALTER", "POLICY")) COMPLETE_WITH_QUERY(Query_for_list_of_policies); diff --git a/src/test/regress/expected/create_am.out b/src/test/regress/expected/create_am.out index 32b7134080c..e9a9283d7ab 100644 --- a/src/test/regress/expected/create_am.out +++ b/src/test/regress/expected/create_am.out @@ -254,9 +254,35 @@ SELECT COUNT(a), COUNT(1) FILTER(WHERE a=1) FROM heaptable; 9 | 1 (1 row) +-- ALTER MATERIALIZED VIEW SET ACCESS METHOD +CREATE MATERIALIZED VIEW heapmv USING heap AS SELECT * FROM heaptable; +SELECT amname FROM pg_class c, pg_am am + WHERE c.relam = am.oid AND c.oid = 'heapmv'::regclass; + amname +-------- + heap +(1 row) + +ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap2; +SELECT amname FROM pg_class c, pg_am am + WHERE c.relam = am.oid AND c.oid = 'heapmv'::regclass; + amname +-------- + heap2 +(1 row) + +SELECT COUNT(a), COUNT(1) FILTER(WHERE a=1) FROM heapmv; + count | count +-------+------- + 9 | 1 +(1 row) + -- No support for multiple subcommands ALTER TABLE heaptable SET ACCESS METHOD heap, SET ACCESS METHOD heap2; ERROR: cannot have multiple SET ACCESS METHOD subcommands +ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap, SET ACCESS METHOD heap2; +ERROR: cannot have multiple SET ACCESS METHOD subcommands +DROP MATERIALIZED VIEW heapmv; DROP TABLE heaptable; -- No support for partitioned tables. CREATE TABLE am_partitioned(x INT, y INT) diff --git a/src/test/regress/sql/create_am.sql b/src/test/regress/sql/create_am.sql index 967bfac21a2..256884c9592 100644 --- a/src/test/regress/sql/create_am.sql +++ b/src/test/regress/sql/create_am.sql @@ -170,8 +170,18 @@ ALTER TABLE heaptable SET ACCESS METHOD heap2; SELECT amname FROM pg_class c, pg_am am WHERE c.relam = am.oid AND c.oid = 'heaptable'::regclass; SELECT COUNT(a), COUNT(1) FILTER(WHERE a=1) FROM heaptable; +-- ALTER MATERIALIZED VIEW SET ACCESS METHOD +CREATE MATERIALIZED VIEW heapmv USING heap AS SELECT * FROM heaptable; +SELECT amname FROM pg_class c, pg_am am + WHERE c.relam = am.oid AND c.oid = 'heapmv'::regclass; +ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap2; +SELECT amname FROM pg_class c, pg_am am + WHERE c.relam = am.oid AND c.oid = 'heapmv'::regclass; +SELECT COUNT(a), COUNT(1) FILTER(WHERE a=1) FROM heapmv; -- No support for multiple subcommands ALTER TABLE heaptable SET ACCESS METHOD heap, SET ACCESS METHOD heap2; +ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap, SET ACCESS METHOD heap2; +DROP MATERIALIZED VIEW heapmv; DROP TABLE heaptable; -- No support for partitioned tables. CREATE TABLE am_partitioned(x INT, y INT) |