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

Function generateRangePartitions

src/backend/parser/parse_partition_gp.c:942–1087  ·  view source on GitHub ↗

Generate partitions for START (..) END (..) EVERY (..) */

Source from the content-addressed store, hash-verified

940
941/* Generate partitions for START (..) END (..) EVERY (..) */
942static List *
943generateRangePartitions(ParseState *pstate,
944 Relation parentrel,
945 GpPartDefElem *elem,
946 PartitionSpec *subPart,
947 partname_comp *partnamecomp,
948 bool *hasImplicitRangeBounds,
949 CreateStmtOrigin origin)
950{
951 GpPartitionRangeSpec *boundspec;
952 List *result = NIL;
953 PartitionKey partkey;
954 char *partcolname;
955 PartEveryIterator *boundIter;
956 Node *start = NULL;
957 bool startExclusive = false;
958 Node *end = NULL;
959 bool endInclusive = false;
960 Node *every = NULL;
961 int i;
962
963 if (elem->boundSpec == NULL)
964 ereport(ERROR,
965 (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
966 errmsg("missing boundary specification in partition \"%s\" of type RANGE",
967 elem->partName),
968 parser_errposition(pstate, elem->location)));
969
970 if (!IsA(elem->boundSpec, GpPartitionRangeSpec))
971 ereport(ERROR,
972 (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
973 errmsg("invalid boundary specification for RANGE partition"),
974 parser_errposition(pstate, elem->location)));
975
976 boundspec = (GpPartitionRangeSpec *) elem->boundSpec;
977 partkey = RelationGetPartitionKey(parentrel);
978
979 /*
980 * GPDB_12_MERGE_FEATURE_NOT_SUPPORTED: We currently disabled support for multi-column
981 * range partitioned tables. If user want to define partition table with multi-column
982 * range, can use PostgreSQL's grammar:
983 *
984 * create table z (a int, b int, c int) partition by range(b, c);
985 * create table z1 partition of z for values from (10, 10) TO (20, 20);
986 */
987 if (partkey->partnatts != 1)
988 ereport(ERROR,
989 (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
990 errmsg("too many columns for RANGE partition -- only one column is allowed")));
991
992 /* Syntax doesn't allow expressions in partition key */
993 Assert(partkey->partattrs[0] != 0);
994 partcolname = NameStr(TupleDescAttr(RelationGetDescr(parentrel), partkey->partattrs[0] - 1)->attname);
995
996 if (boundspec->partStart)
997 {
998 if (list_length(boundspec->partStart->val) != partkey->partnatts)
999 ereport(ERROR,

Callers 1

generatePartitionsFunction · 0.85

Calls 12

parser_errpositionFunction · 0.85
RelationGetPartitionKeyFunction · 0.85
list_lengthFunction · 0.85
initPartEveryIteratorFunction · 0.85
nextPartBoundFunction · 0.85
datums_to_constsFunction · 0.85
makeStringFunction · 0.85
makePartitionCreateStmtFunction · 0.85
lappendFunction · 0.85
freePartEveryIteratorFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected