Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcb03fa3

Browse files
committed
Fix assorted syscache lookup sloppiness in partition-related code.
heap_drop_with_catalog and ATExecDetachPartition neglected to check forSearchSysCache failures, as noted in bugs #14927 and #14928 from Pan Bian.Such failures are pretty unlikely, since we should already have some sortof lock on the rel at these points, but it's neither a good idea norper project style to omit a check for failure.Also, StorePartitionKey contained a syscache lookup that it never didanything with, including never releasing the result. Presumably thereason why we don't see refcount-leak complaints is that the lookupalways fails; but in any case it's pretty useless, so remove it.All of these errors were evidently introduced by the relationpartitioning feature. Back-patch to v10 where that came in.Amit Langote and Tom LaneDiscussion:https://postgr.es/m/20171127090105.1463.3962@wrigleys.postgresql.orgDiscussion:https://postgr.es/m/20171127091341.1468.72696@wrigleys.postgresql.org
1 parent9a785ad commitcb03fa3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

‎src/backend/catalog/heap.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,6 +1772,8 @@ heap_drop_with_catalog(Oid relid)
17721772
* shared-cache-inval notice that will make them update their index lists.
17731773
*/
17741774
tuple=SearchSysCache1(RELOID,ObjectIdGetDatum(relid));
1775+
if (!HeapTupleIsValid(tuple))
1776+
elog(ERROR,"cache lookup failed for relation %u",relid);
17751777
if (((Form_pg_class)GETSTRUCT(tuple))->relispartition)
17761778
{
17771779
parentOid=get_partition_parent(relid);
@@ -3131,9 +3133,6 @@ StorePartitionKey(Relation rel,
31313133

31323134
Assert(rel->rd_rel->relkind==RELKIND_PARTITIONED_TABLE);
31333135

3134-
tuple=SearchSysCache1(PARTRELID,
3135-
ObjectIdGetDatum(RelationGetRelid(rel)));
3136-
31373136
/* Copy the partition attribute numbers, opclass OIDs into arrays */
31383137
partattrs_vec=buildint2vector(partattrs,partnatts);
31393138
partopclass_vec=buildoidvector(partopclass,partnatts);

‎src/backend/commands/tablecmds.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14111,6 +14111,9 @@ ATExecDetachPartition(Relation rel, RangeVar *name)
1411114111
classRel=heap_open(RelationRelationId,RowExclusiveLock);
1411214112
tuple=SearchSysCacheCopy1(RELOID,
1411314113
ObjectIdGetDatum(RelationGetRelid(partRel)));
14114+
if (!HeapTupleIsValid(tuple))
14115+
elog(ERROR,"cache lookup failed for relation %u",
14116+
RelationGetRelid(partRel));
1411414117
Assert(((Form_pg_class)GETSTRUCT(tuple))->relispartition);
1411514118

1411614119
(void)SysCacheGetAttr(RELOID,tuple,Anum_pg_class_relpartbound,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp