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

Function generateListPartition

src/backend/parser/parse_partition_gp.c:1089–1153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1087}
1088
1089static List *
1090generateListPartition(ParseState *pstate,
1091 Relation parentrel,
1092 GpPartDefElem *elem,
1093 PartitionSpec *subPart,
1094 partname_comp *partnamecomp,
1095 CreateStmtOrigin origin)
1096{
1097 GpPartitionListSpec *gpvaluesspec;
1098 PartitionBoundSpec *boundspec;
1099 CreateStmt *childstmt;
1100 PartitionKey partkey;
1101 ListCell *lc;
1102 List *listdatums;
1103
1104 if (elem->boundSpec == NULL)
1105 ereport(ERROR,
1106 (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
1107 errmsg("missing boundary specification in partition \"%s\" of type LIST",
1108 elem->partName),
1109 parser_errposition(pstate, elem->location)));
1110
1111 if (!IsA(elem->boundSpec, GpPartitionListSpec))
1112 ereport(ERROR,
1113 (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
1114 errmsg("invalid boundary specification for LIST partition"),
1115 parser_errposition(pstate, elem->location)));
1116
1117 gpvaluesspec = (GpPartitionListSpec *) elem->boundSpec;
1118
1119 partkey = RelationGetPartitionKey(parentrel);
1120
1121 boundspec = makeNode(PartitionBoundSpec);
1122 boundspec->strategy = PARTITION_STRATEGY_LIST;
1123 boundspec->is_default = false;
1124
1125 /*
1126 * GPDB_12_MERGE_FEATURE_NOT_SUPPORTED: We currently disabled support for multi-column
1127 * range partitioned tables. If user want to define partition table with multi-column
1128 * range, can use PostgreSQL's grammar:
1129 *
1130 * create table z (a int, b int, c int) partition by range(b, c);
1131 * create table z1 partition of z for values from (10, 10) TO (20, 20);
1132 */
1133
1134 listdatums = NIL;
1135 foreach (lc, gpvaluesspec->partValues)
1136 {
1137 List *thisvalue = lfirst(lc);
1138
1139 if (list_length(thisvalue) != 1)
1140 elog(ERROR, "VALUES specification with more than one column not allowed");
1141
1142 listdatums = lappend(listdatums, linitial(thisvalue));
1143 }
1144
1145 boundspec->listdatums = listdatums;
1146 boundspec->location = -1;

Callers 1

generatePartitionsFunction · 0.85

Calls 9

parser_errpositionFunction · 0.85
RelationGetPartitionKeyFunction · 0.85
list_lengthFunction · 0.85
lappendFunction · 0.85
transformPartitionBoundFunction · 0.85
makePartitionCreateStmtFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50
foreachFunction · 0.50

Tested by

no test coverage detected