diff --git a/contrib/pax_storage/expected/cluster.out b/contrib/pax_storage/expected/cluster.out index c541db45bc2..c037dfc72c5 100644 --- a/contrib/pax_storage/expected/cluster.out +++ b/contrib/pax_storage/expected/cluster.out @@ -295,3 +295,32 @@ select ptblockname,ptstatistics,ptisclustered from get_pax_aux_table('t_lexical_ (6 rows) drop table t_lexical_cluster; +-- Reject unsupported options before changing any PAX micro-partitions. +create table t_cluster_options(c1 int, c2 int) using pax + with (minmax_columns='c1,c2', cluster_columns='c1,c2') + distributed by (c1); +insert into t_cluster_options select i, 1001-i from generate_series(1,1000) i; +select bool_and(ptisclustered) as clustered from get_pax_aux_table('t_cluster_options'); + clustered +----------- + f +(1 row) + +cluster (bogus) t_cluster_options; +ERROR: unrecognized CLUSTER option "bogus" +LINE 1: cluster (bogus) t_cluster_options; + ^ +select bool_and(ptisclustered) as clustered from get_pax_aux_table('t_cluster_options'); + clustered +----------- + f +(1 row) + +cluster (verbose false) t_cluster_options; +select bool_and(ptisclustered) as clustered from get_pax_aux_table('t_cluster_options'); + clustered +----------- + t +(1 row) + +drop table t_cluster_options; diff --git a/contrib/pax_storage/sql/cluster.sql b/contrib/pax_storage/sql/cluster.sql index 9b44fbdc6be..5124bfe3112 100644 --- a/contrib/pax_storage/sql/cluster.sql +++ b/contrib/pax_storage/sql/cluster.sql @@ -146,4 +146,15 @@ alter table t_lexical_cluster set(cluster_columns='c1,c2', cluster_type='lexical cluster t_lexical_cluster; select ptblockname,ptstatistics,ptisclustered from get_pax_aux_table('t_lexical_cluster'); -drop table t_lexical_cluster; \ No newline at end of file +drop table t_lexical_cluster; +-- Reject unsupported options before changing any PAX micro-partitions. +create table t_cluster_options(c1 int, c2 int) using pax + with (minmax_columns='c1,c2', cluster_columns='c1,c2') + distributed by (c1); +insert into t_cluster_options select i, 1001-i from generate_series(1,1000) i; +select bool_and(ptisclustered) as clustered from get_pax_aux_table('t_cluster_options'); +cluster (bogus) t_cluster_options; +select bool_and(ptisclustered) as clustered from get_pax_aux_table('t_cluster_options'); +cluster (verbose false) t_cluster_options; +select bool_and(ptisclustered) as clustered from get_pax_aux_table('t_cluster_options'); +drop table t_cluster_options; diff --git a/contrib/pax_storage/src/cpp/access/pax_access_handle.cc b/contrib/pax_storage/src/cpp/access/pax_access_handle.cc index ee8553b7a7e..344ed1ea77d 100644 --- a/contrib/pax_storage/src/cpp/access/pax_access_handle.cc +++ b/contrib/pax_storage/src/cpp/access/pax_access_handle.cc @@ -925,6 +925,27 @@ static void paxProcessUtility(PlannedStmt *pstmt, const char *queryString, switch (nodeTag(pstmt->utilityStmt)) { case T_ClusterStmt: { ClusterStmt *stmt = (ClusterStmt *)pstmt->utilityStmt; + ListCell *lc; + + /* + * Column-based clustering bypasses cluster(), so validate options + * before either the single-table or database-wide PAX path runs. + */ + foreach (lc, stmt->params) { + DefElem *opt = (DefElem *)lfirst(lc); + + if (strcmp(opt->defname, "verbose") == 0) { + (void)defGetBoolean(opt); + } else { + ParseState *pstate = make_parsestate(NULL); + pstate->p_sourcetext = queryString; + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("unrecognized CLUSTER option \"%s\"", opt->defname), + parser_errposition(pstate, opt->location))); + } + } + if (stmt->relation) { Relation rel = table_openrv(stmt->relation, AccessShareLock); if (RelationIsPAX(rel)) {