diff --git a/src/gausskernel/optimizer/commands/tablecmds.cpp b/src/gausskernel/optimizer/commands/tablecmds.cpp index 6b840dee..4d3be9c3 100644 --- a/src/gausskernel/optimizer/commands/tablecmds.cpp +++ b/src/gausskernel/optimizer/commands/tablecmds.cpp @@ -12456,7 +12456,8 @@ static void ATExecSetRelOptions(Relation rel, List* defList, AlterTableType oper /* Validate */ switch (rel->rd_rel->relkind) { - case RELKIND_RELATION: { + case RELKIND_RELATION: + case RELKIND_MATVIEW: { /* this options only can be used when define a new relation. * forbid to change or reset these options. */ @@ -12485,8 +12486,7 @@ static void ATExecSetRelOptions(Relation rel, List* defList, AlterTableType oper break; } case RELKIND_TOASTVALUE: - case RELKIND_VIEW: - case RELKIND_MATVIEW:{ + case RELKIND_VIEW: { (void)heap_reloptions(rel->rd_rel->relkind, newOptions, true); break; } diff --git a/src/include/utils/rel_gs.h b/src/include/utils/rel_gs.h index a1153193..f804449a 100755 --- a/src/include/utils/rel_gs.h +++ b/src/include/utils/rel_gs.h @@ -195,7 +195,7 @@ typedef struct RelationMetaData { StdRdOptionsGetStringData((relation)->rd_options, filesystem, FILESYSTEM_GENERAL) #define RelationIsCUFormat(relation) \ - ((RELKIND_RELATION == relation->rd_rel->relkind) && \ + ((RELKIND_RELATION == relation->rd_rel->relkind || RELKIND_MATVIEW == relation->rd_rel->relkind) && \ pg_strcasecmp(RelationGetOrientation(relation), ORIENTATION_COLUMN) == 0) #define RelationIsRowFormat(relation) \ @@ -259,14 +259,15 @@ static inline RedisHtlAction RelationGetAppendMode(Relation rel) * Return the relations' orientation. Pax format includes ORC format. */ #define RelationIsPAXFormat(relation) \ - ((RELKIND_RELATION == relation->rd_rel->relkind) && \ + ((RELKIND_RELATION == relation->rd_rel->relkind || RELKIND_MATVIEW == relation->rd_rel->relkind) && \ pg_strcasecmp(RelationGetOrientation(relation), ORIENTATION_ORC) == 0) /* RelationIsColStore * Return relation whether is column store, which includes CU format and PAX format. */ #define RelationIsColStore(relation) \ - ((RELKIND_RELATION == relation->rd_rel->relkind) && (RelationIsCUFormat(relation) || RelationIsPAXFormat(relation))) + ((RELKIND_RELATION == relation->rd_rel->relkind || RELKIND_MATVIEW == relation->rd_rel->relkind) && \ + (RelationIsCUFormat(relation) || RelationIsPAXFormat(relation))) #define RelationOptionIsDfsStore(optionValue) (optionValue && 0 == pg_strncasecmp(optionValue, HDFS, strlen(HDFS))) diff --git a/src/test/regress/expected/matview.out b/src/test/regress/expected/matview.out index fa9700ba..aaaf4f30 100644 --- a/src/test/regress/expected/matview.out +++ b/src/test/regress/expected/matview.out @@ -34,6 +34,9 @@ SELECT * FROM mvtest_tm ORDER BY type; (0 rows) REFRESH MATERIALIZED VIEW mvtest_tm; +ALTER MATERIALIZED VIEW mvtest_tm set (orientation=column); --error +ERROR: Un-support feature +DETAIL: Option "orientation" doesn't allow ALTER CREATE UNIQUE INDEX mvtest_tm_type ON mvtest_tm (type); SELECT * FROM mvtest_tm ORDER BY type; type | totamt diff --git a/src/test/regress/sql/matview.sql b/src/test/regress/sql/matview.sql index 75607719..ac32ce35 100644 --- a/src/test/regress/sql/matview.sql +++ b/src/test/regress/sql/matview.sql @@ -16,6 +16,7 @@ EXPLAIN (analyze on, costs off) CREATE MATERIALIZED VIEW mvtest_tm AS SELECT type, sum(amt) AS totamt FROM mvtest_t GROUP BY type WITH NO DATA; SELECT * FROM mvtest_tm ORDER BY type; REFRESH MATERIALIZED VIEW mvtest_tm; +ALTER MATERIALIZED VIEW mvtest_tm set (orientation=column); --error CREATE UNIQUE INDEX mvtest_tm_type ON mvtest_tm (type); SELECT * FROM mvtest_tm ORDER BY type;