diff --git a/src/common/backend/parser/parse_utilcmd.cpp b/src/common/backend/parser/parse_utilcmd.cpp index 58558e134..361a31c75 100644 --- a/src/common/backend/parser/parse_utilcmd.cpp +++ b/src/common/backend/parser/parse_utilcmd.cpp @@ -3910,6 +3910,16 @@ List* transformAlterTableStmt(Oid relid, AlterTableStmt* stmt, const char* query break; case AT_SplitPartition: + if (!RELATION_IS_PARTITIONED(rel)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), + errmodule(MOD_OPT), + errmsg("can not split partition against NON-PARTITIONED table"))); + if (rel->partMap->type == PART_TYPE_LIST || rel->partMap->type == PART_TYPE_HASH) { + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("can not split LIST/HASH partition table"))); + } + /* transform the boundary of range partition: from A_Const into Const */ splitDefState = (SplitPartitionState*)cmd->def; if (!PointerIsValid(splitDefState->split_point)) { @@ -3930,12 +3940,6 @@ List* transformAlterTableStmt(Oid relid, AlterTableStmt* stmt, const char* query Const* upBound = NULL; Oid srcPartOid = InvalidOid; - if (!RELATION_IS_PARTITIONED(rel)) - ereport(ERROR, - (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmodule(MOD_OPT), - errmsg("can not split partition against NON-PARTITIONED table"))); - /* get partition number */ partNum = getNumberOfPartitions(rel); @@ -5369,6 +5373,7 @@ static void get_src_partition_bound(Relation partTableRel, Oid srcPartOid, Const errcode(ERRCODE_INVALID_OBJECT_DEFINITION), errmsg("CAN NOT get detail info from a partitioned relation WITHOUT specified partition."))); + Assert(partTableRel->partMap->type == PART_TYPE_RANGE || partTableRel->partMap->type == PART_TYPE_INTERVAL); partMap = (RangePartitionMap*)partTableRel->partMap; srcPartSeq = partOidGetPartSequence(partTableRel, srcPartOid) - 1; diff --git a/src/common/backend/utils/adt/formatting.cpp b/src/common/backend/utils/adt/formatting.cpp index bd22c598f..177cf83a5 100644 --- a/src/common/backend/utils/adt/formatting.cpp +++ b/src/common/backend/utils/adt/formatting.cpp @@ -5561,7 +5561,7 @@ static void NUM_numpart_from_char(NUMProc* Np, int id, int plen, int& tmp_len) * locale sign expected - last read char was NUM_0/9 or NUM_DEC - and * next char is not digit */ - if (IS_LSIGN(Np->Num) && isread && (Np->inout_p + 1) <= Np->inout + plen && + if (IS_LSIGN(Np->Num) && isread && (Np->inout_p + 1) < Np->inout + plen && !isdigit((unsigned char)*(Np->inout_p + 1))) { int x; char* tmp = Np->inout_p++;