|
|
|
@ -605,9 +605,10 @@ static void RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid, |
|
|
|
|
Oid oldRelOid, void *arg); |
|
|
|
|
static void RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid, |
|
|
|
|
Oid oldrelid, void *arg); |
|
|
|
|
static PartitionSpec *transformPartitionSpec(Relation rel, PartitionSpec *partspec, char *strategy); |
|
|
|
|
static PartitionSpec *transformPartitionSpec(Relation rel, PartitionSpec *partspec); |
|
|
|
|
static void ComputePartitionAttrs(ParseState *pstate, Relation rel, List *partParams, AttrNumber *partattrs, |
|
|
|
|
List **partexprs, Oid *partopclass, Oid *partcollation, char strategy); |
|
|
|
|
List **partexprs, Oid *partopclass, Oid *partcollation, |
|
|
|
|
PartitionStrategy strategy); |
|
|
|
|
static void CreateInheritance(Relation child_rel, Relation parent_rel); |
|
|
|
|
static void RemoveInheritance(Relation child_rel, Relation parent_rel, |
|
|
|
|
bool expect_detached); |
|
|
|
@ -1122,7 +1123,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, |
|
|
|
|
if (partitioned) |
|
|
|
|
{ |
|
|
|
|
ParseState *pstate; |
|
|
|
|
char strategy; |
|
|
|
|
int partnatts; |
|
|
|
|
AttrNumber partattrs[PARTITION_MAX_KEYS]; |
|
|
|
|
Oid partopclass[PARTITION_MAX_KEYS]; |
|
|
|
@ -1147,14 +1147,14 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, |
|
|
|
|
* and CHECK constraints, we could not have done the transformation |
|
|
|
|
* earlier. |
|
|
|
|
*/ |
|
|
|
|
stmt->partspec = transformPartitionSpec(rel, stmt->partspec, |
|
|
|
|
&strategy); |
|
|
|
|
stmt->partspec = transformPartitionSpec(rel, stmt->partspec); |
|
|
|
|
|
|
|
|
|
ComputePartitionAttrs(pstate, rel, stmt->partspec->partParams, |
|
|
|
|
partattrs, &partexprs, partopclass, |
|
|
|
|
partcollation, strategy); |
|
|
|
|
partcollation, stmt->partspec->strategy); |
|
|
|
|
|
|
|
|
|
StorePartitionKey(rel, strategy, partnatts, partattrs, partexprs, |
|
|
|
|
StorePartitionKey(rel, stmt->partspec->strategy, partnatts, partattrs, |
|
|
|
|
partexprs, |
|
|
|
|
partopclass, partcollation); |
|
|
|
|
|
|
|
|
|
/* make it all visible */ |
|
|
|
@ -17132,10 +17132,10 @@ RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid, Oid oldrelid, |
|
|
|
|
/*
|
|
|
|
|
* Transform any expressions present in the partition key |
|
|
|
|
* |
|
|
|
|
* Returns a transformed PartitionSpec, as well as the strategy code |
|
|
|
|
* Returns a transformed PartitionSpec. |
|
|
|
|
*/ |
|
|
|
|
static PartitionSpec * |
|
|
|
|
transformPartitionSpec(Relation rel, PartitionSpec *partspec, char *strategy) |
|
|
|
|
transformPartitionSpec(Relation rel, PartitionSpec *partspec) |
|
|
|
|
{ |
|
|
|
|
PartitionSpec *newspec; |
|
|
|
|
ParseState *pstate; |
|
|
|
@ -17148,21 +17148,8 @@ transformPartitionSpec(Relation rel, PartitionSpec *partspec, char *strategy) |
|
|
|
|
newspec->partParams = NIL; |
|
|
|
|
newspec->location = partspec->location; |
|
|
|
|
|
|
|
|
|
/* Parse partitioning strategy name */ |
|
|
|
|
if (pg_strcasecmp(partspec->strategy, "hash") == 0) |
|
|
|
|
*strategy = PARTITION_STRATEGY_HASH; |
|
|
|
|
else if (pg_strcasecmp(partspec->strategy, "list") == 0) |
|
|
|
|
*strategy = PARTITION_STRATEGY_LIST; |
|
|
|
|
else if (pg_strcasecmp(partspec->strategy, "range") == 0) |
|
|
|
|
*strategy = PARTITION_STRATEGY_RANGE; |
|
|
|
|
else |
|
|
|
|
ereport(ERROR, |
|
|
|
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
|
|
|
|
errmsg("unrecognized partitioning strategy \"%s\"", |
|
|
|
|
partspec->strategy))); |
|
|
|
|
|
|
|
|
|
/* Check valid number of columns for strategy */ |
|
|
|
|
if (*strategy == PARTITION_STRATEGY_LIST && |
|
|
|
|
if (partspec->strategy == PARTITION_STRATEGY_LIST && |
|
|
|
|
list_length(partspec->partParams) != 1) |
|
|
|
|
ereport(ERROR, |
|
|
|
|
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), |
|
|
|
@ -17208,7 +17195,7 @@ transformPartitionSpec(Relation rel, PartitionSpec *partspec, char *strategy) |
|
|
|
|
static void |
|
|
|
|
ComputePartitionAttrs(ParseState *pstate, Relation rel, List *partParams, AttrNumber *partattrs, |
|
|
|
|
List **partexprs, Oid *partopclass, Oid *partcollation, |
|
|
|
|
char strategy) |
|
|
|
|
PartitionStrategy strategy) |
|
|
|
|
{ |
|
|
|
|
int attn; |
|
|
|
|
ListCell *lc; |
|
|
|
|