diff options
Diffstat (limited to 'src/backend/utils/adt/partitionfuncs.c')
-rw-r--r-- | src/backend/utils/adt/partitionfuncs.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/backend/utils/adt/partitionfuncs.c b/src/backend/utils/adt/partitionfuncs.c index 98c8ef77f17..714a0242a18 100644 --- a/src/backend/utils/adt/partitionfuncs.c +++ b/src/backend/utils/adt/partitionfuncs.c @@ -189,8 +189,16 @@ pg_partition_root(PG_FUNCTION_ARGS) if (!check_rel_can_be_partition(relid)) PG_RETURN_NULL(); - /* Fetch the top-most parent */ + /* fetch the list of ancestors */ ancestors = get_partition_ancestors(relid); + + /* + * If the input relation is already the top-most parent, just return + * itself. + */ + if (ancestors == NIL) + PG_RETURN_OID(relid); + rootrelid = llast_oid(ancestors); list_free(ancestors); |