Skip to content

Commit 3633b3f

Browse files
committed
Assorted code improvements for table partitioning.
Michael Paquier, per Coverity.
1 parent 18fc519 commit 3633b3f

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/backend/catalog/heap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3248,6 +3248,10 @@ StorePartitionBound(Relation rel, Relation parent, Node *bound)
32483248
classRel = heap_open(RelationRelationId, RowExclusiveLock);
32493249
tuple = SearchSysCacheCopy1(RELOID,
32503250
ObjectIdGetDatum(RelationGetRelid(rel)));
3251+
if (!HeapTupleIsValid(tuple))
3252+
elog(ERROR, "cache lookup failed for relation %u",
3253+
RelationGetRelid(rel));
3254+
32513255
#ifdef USE_ASSERT_CHECKING
32523256
{
32533257
Form_pg_class classForm;

src/backend/catalog/partition.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ RelationBuildPartitionDesc(Relation rel)
200200
Node *boundspec;
201201

202202
tuple = SearchSysCache1(RELOID, inhrelid);
203+
if (!HeapTupleIsValid(tuple))
204+
elog(ERROR, "cache lookup failed for relation %u", inhrelid);
203205

204206
/*
205207
* It is possible that the pg_class tuple of a partition has not been
@@ -1516,6 +1518,10 @@ generate_partition_qual(Relation rel)
15161518
elog(ERROR, "relation \"%s\" has relispartition = false",
15171519
RelationGetRelationName(rel));
15181520
tuple = SearchSysCache1(RELOID, RelationGetRelid(rel));
1521+
if (!HeapTupleIsValid(tuple))
1522+
elog(ERROR, "cache lookup failed for relation %u",
1523+
RelationGetRelid(rel));
1524+
15191525
boundDatum = SysCacheGetAttr(RELOID, tuple,
15201526
Anum_pg_class_relpartbound,
15211527
&isnull);

src/bin/pg_dump/pg_dump.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5736,7 +5736,7 @@ getPartitions(Archive *fout, int *numPartitions)
57365736
PGresult *res;
57375737
int ntups;
57385738
int i;
5739-
PQExpBuffer query = createPQExpBuffer();
5739+
PQExpBuffer query;
57405740
PartInfo *partinfo;
57415741

57425742
int i_partrelid;
@@ -5750,6 +5750,8 @@ getPartitions(Archive *fout, int *numPartitions)
57505750
return NULL;
57515751
}
57525752

5753+
query = createPQExpBuffer();
5754+
57535755
/* Make sure we are in proper schema */
57545756
selectSourceSchema(fout, "pg_catalog");
57555757

@@ -7067,14 +7069,16 @@ getTransforms(Archive *fout, int *numTransforms)
70677069
void
70687070
getTablePartitionKeyInfo(Archive *fout, TableInfo *tblinfo, int numTables)
70697071
{
7070-
PQExpBuffer q = createPQExpBuffer();
7072+
PQExpBuffer q;
70717073
int i;
70727074
PGresult *res;
70737075

70747076
/* No partitioned tables before 10 */
70757077
if (fout->remoteVersion < 100000)
70767078
return;
70777079

7080+
q = createPQExpBuffer();
7081+
70787082
for (i = 0; i < numTables; i++)
70797083
{
70807084
TableInfo *tbinfo = &(tblinfo[i]);
@@ -7094,6 +7098,8 @@ getTablePartitionKeyInfo(Archive *fout, TableInfo *tblinfo, int numTables)
70947098
Assert(PQntuples(res) == 1);
70957099
tbinfo->partkeydef = pg_strdup(PQgetvalue(res, 0, 0));
70967100
}
7101+
7102+
destroyPQExpBuffer(q);
70977103
}
70987104

70997105
/*

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