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

Commitdeba7c6

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 parent92f6b49 commitdeba7c6

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
@@ -7976,6 +7976,10 @@ ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_changed, bool *
79767976
}
79777977

79787978
idx_rel=RelationIdGetRelation(replidindex);
7979+
7980+
if (!RelationIsValid(idx_rel))
7981+
elog(ERROR,"could not open relation with OID %u",replidindex);
7982+
79797983
idx_desc=RelationGetDescr(idx_rel);
79807984

79817985
/* 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
@@ -1561,7 +1561,7 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
15611561

15621562
relation=RelationIdGetRelation(reloid);
15631563

1564-
if (relation==NULL)
1564+
if (!RelationIsValid(relation))
15651565
elog(ERROR,"could not open relation with OID %u (for filenode \"%s\")",
15661566
reloid,
15671567
relpathperm(change->data.tp.relnode,
@@ -2969,6 +2969,10 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn,
29692969
desc=RelationGetDescr(relation);
29702970

29712971
toast_rel=RelationIdGetRelation(relation->rd_rel->reltoastrelid);
2972+
if (!RelationIsValid(toast_rel))
2973+
elog(ERROR,"could not open relation with OID %u",
2974+
relation->rd_rel->reltoastrelid);
2975+
29722976
toast_desc=RelationGetDescr(toast_rel);
29732977

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp