* Construct a CreateStmt representing a single partition to be created as part * of a legacy style CREATE/ALTER statement. */
| 889 | * of a legacy style CREATE/ALTER statement. |
| 890 | */ |
| 891 | CreateStmt * |
| 892 | makePartitionCreateStmt(Relation parentrel, char *partname, PartitionBoundSpec *boundspec, |
| 893 | PartitionSpec *subPart, GpPartDefElem *elem, |
| 894 | partname_comp *partnamecomp, CreateStmtOrigin origin) |
| 895 | { |
| 896 | CreateStmt *childstmt; |
| 897 | RangeVar *parentrv; |
| 898 | RangeVar *childrv; |
| 899 | char *schemaname; |
| 900 | const char *final_part_name; |
| 901 | |
| 902 | if (partnamecomp->tablename) |
| 903 | final_part_name = partnamecomp->tablename; |
| 904 | else |
| 905 | final_part_name = ChoosePartitionName(RelationGetRelationName(parentrel), |
| 906 | partnamecomp->level, |
| 907 | RelationGetNamespace(parentrel), |
| 908 | partname, |
| 909 | ++partnamecomp->partnum); |
| 910 | |
| 911 | schemaname = get_namespace_name(parentrel->rd_rel->relnamespace); |
| 912 | parentrv = makeRangeVar(schemaname, pstrdup(RelationGetRelationName(parentrel)), -1); |
| 913 | parentrv->relpersistence = parentrel->rd_rel->relpersistence; |
| 914 | |
| 915 | childrv = makeRangeVar(schemaname, (char *)final_part_name, -1); |
| 916 | childrv->relpersistence = parentrel->rd_rel->relpersistence; |
| 917 | |
| 918 | childstmt = makeNode(CreateStmt); |
| 919 | childstmt->relation = childrv; |
| 920 | childstmt->tableElts = NIL; |
| 921 | childstmt->inhRelations = list_make1(parentrv); |
| 922 | childstmt->partbound = boundspec; |
| 923 | childstmt->partspec = subPart; |
| 924 | childstmt->ofTypename = NULL; |
| 925 | childstmt->constraints = NIL; |
| 926 | childstmt->options = elem->options ? copyObject(elem->options) : NIL; |
| 927 | childstmt->oncommit = ONCOMMIT_NOOP; |
| 928 | childstmt->tablespacename = elem->tablespacename ? pstrdup(elem->tablespacename) : NULL; |
| 929 | childstmt->accessMethod = elem->accessMethod ? pstrdup(elem->accessMethod) : NULL; |
| 930 | childstmt->if_not_exists = false; |
| 931 | childstmt->origin = origin; |
| 932 | childstmt->distributedBy = make_distributedby_for_rel(parentrel); |
| 933 | childstmt->partitionBy = NULL; |
| 934 | childstmt->relKind = 0; |
| 935 | childstmt->ownerid = parentrel->rd_rel->relowner; |
| 936 | childstmt->attr_encodings = copyObject(elem->colencs); |
| 937 | |
| 938 | return childstmt; |
| 939 | } |
| 940 | |
| 941 | /* Generate partitions for START (..) END (..) EVERY (..) */ |
| 942 | static List * |
no test coverage detected