Skip to content

Commit e78e951

Browse files
author
Marina Polyakova
committed
Merge remote-tracking branch 'origin/PGPRO-9874'
2 parents 07f0a98 + ba5c4c7 commit e78e951

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/partition_creation.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,8 @@ spawn_partitions_val(Oid parent_relid, /* parent's Oid */
606606

607607
/* Get typname of range_bound_type to perform cast */
608608
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(range_bound_type));
609-
Assert(HeapTupleIsValid(typeTuple));
609+
if (!HeapTupleIsValid(typeTuple))
610+
elog(ERROR, "cache lookup failed for type %u", range_bound_type);
610611
typname = pstrdup(NameStr(((Form_pg_type) GETSTRUCT(typeTuple))->typname));
611612
ReleaseSysCache(typeTuple);
612613

src/relation_info.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ invalidate_bounds_cache(void)
11671167
/*
11681168
* Get constraint expression tree of a partition.
11691169
*
1170-
* build_check_constraint_name_internal() is used to build conname.
1170+
* build_check_constraint_name_relid_internal() is used to build conname.
11711171
*/
11721172
Expr *
11731173
get_partition_constraint_expr(Oid partition, bool raise_error)
@@ -1193,6 +1193,16 @@ get_partition_constraint_expr(Oid partition, bool raise_error)
11931193
}
11941194

11951195
con_tuple = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conid));
1196+
if (!HeapTupleIsValid(con_tuple))
1197+
{
1198+
if (!raise_error)
1199+
return NULL;
1200+
1201+
ereport(ERROR,
1202+
(errmsg("cache lookup failed for constraint \"%s\" of partition \"%s\"",
1203+
conname, get_rel_name_or_relid(partition))));
1204+
}
1205+
11961206
conbin_datum = SysCacheGetAttr(CONSTROID, con_tuple,
11971207
Anum_pg_constraint_conbin,
11981208
&conbin_isnull);
@@ -1204,9 +1214,6 @@ get_partition_constraint_expr(Oid partition, bool raise_error)
12041214
ereport(ERROR,
12051215
(errmsg("constraint \"%s\" of partition \"%s\" has NULL conbin",
12061216
conname, get_rel_name_or_relid(partition))));
1207-
pfree(conname);
1208-
1209-
return NULL; /* could not parse */
12101217
}
12111218
pfree(conname);
12121219

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy