MCPcopy Create free account
hub / github.com/apache/cloudberry / transformPartitionBound

Function transformPartitionBound

src/backend/parser/parse_utilcmd.c:5210–5356  ·  view source on GitHub ↗

* transformPartitionBound * * Transform a partition bound specification */

Source from the content-addressed store, hash-verified

5208 * Transform a partition bound specification
5209 */
5210PartitionBoundSpec *
5211transformPartitionBound(ParseState *pstate, Relation parent, PartitionKey key,
5212 PartitionBoundSpec *spec)
5213{
5214 PartitionBoundSpec *result_spec;
5215 char strategy = get_partition_strategy(key);
5216 int partnatts = get_partition_natts(key);
5217 List *partexprs = get_partition_exprs(key);
5218
5219 /* Avoid scribbling on input */
5220 result_spec = copyObject(spec);
5221
5222 if (spec->is_default)
5223 {
5224 /*
5225 * Hash partitioning does not support a default partition; there's no
5226 * use case for it (since the set of partitions to create is perfectly
5227 * defined), and if users do get into it accidentally, it's hard to
5228 * back out from it afterwards.
5229 */
5230 if (strategy == PARTITION_STRATEGY_HASH)
5231 ereport(ERROR,
5232 (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
5233 errmsg("a hash-partitioned table may not have a default partition")));
5234
5235 /*
5236 * In case of the default partition, parser had no way to identify the
5237 * partition strategy. Assign the parent's strategy to the default
5238 * partition bound spec.
5239 */
5240 result_spec->strategy = strategy;
5241
5242 return result_spec;
5243 }
5244
5245 if (strategy == PARTITION_STRATEGY_HASH)
5246 {
5247 if (spec->strategy != PARTITION_STRATEGY_HASH)
5248 ereport(ERROR,
5249 (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
5250 errmsg("invalid bound specification for a hash partition"),
5251 parser_errposition(pstate, exprLocation((Node *) spec))));
5252
5253 if (spec->modulus <= 0)
5254 ereport(ERROR,
5255 (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
5256 errmsg("modulus for hash partition must be an integer value greater than zero")));
5257
5258 Assert(spec->remainder >= 0);
5259
5260 if (spec->remainder >= spec->modulus)
5261 ereport(ERROR,
5262 (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
5263 errmsg("remainder for hash partition must be less than modulus")));
5264 }
5265 else if (strategy == PARTITION_STRATEGY_LIST)
5266 {
5267 ListCell *cell;

Callers 3

DefineRelationFunction · 0.85
transformPartitionCmdFunction · 0.85
generateListPartitionFunction · 0.85

Calls 15

get_partition_strategyFunction · 0.85
get_partition_nattsFunction · 0.85
get_partition_exprsFunction · 0.85
parser_errpositionFunction · 0.85
exprLocationFunction · 0.85
get_attnameFunction · 0.85
deparse_expressionFunction · 0.85
deparse_context_forFunction · 0.85
get_partition_col_typidFunction · 0.85
get_partition_col_typmodFunction · 0.85

Tested by

no test coverage detected