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

Commit5f73d72

Browse files
committed
Fix RelationIdGetRelation calls that weren't bothering with error checks.
Some of these are quite old, but that doesn't make them not bugs.We'd rather report a failure via elog than SIGSEGV.While at it, uniformly spell the error check as !RelationIsValid(rel)rather than a bare rel == NULL test. The machine code is the samebut it seems better to be consistent.Coverity complained about this today, not sure why, because themistake is in fact old.
1 parent1df4123 commit5f73d72

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

‎src/backend/access/heap/heapam.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7470,6 +7470,10 @@ ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_changed, bool *
74707470
}
74717471

74727472
idx_rel=RelationIdGetRelation(replidindex);
7473+
7474+
if (!RelationIsValid(idx_rel))
7475+
elog(ERROR,"could not open relation with OID %u",replidindex);
7476+
74737477
idx_desc=RelationGetDescr(idx_rel);
74747478

74757479
/* deform tuple, so we have fast access to columns */

‎src/backend/replication/logical/reorderbuffer.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,7 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
15351535

15361536
relation=RelationIdGetRelation(reloid);
15371537

1538-
if (relation==NULL)
1538+
if (!RelationIsValid(relation))
15391539
elog(ERROR,"could not open relation with OID %u (for filenode \"%s\")",
15401540
reloid,
15411541
relpathperm(change->data.tp.relnode,
@@ -2814,6 +2814,10 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn,
28142814
desc=RelationGetDescr(relation);
28152815

28162816
toast_rel=RelationIdGetRelation(relation->rd_rel->reltoastrelid);
2817+
if (!RelationIsValid(toast_rel))
2818+
elog(ERROR,"could not open relation with OID %u",
2819+
relation->rd_rel->reltoastrelid);
2820+
28172821
toast_desc=RelationGetDescr(toast_rel);
28182822

28192823
/* should we allocate from stack instead? */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp