mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03:00
Assorted code improvements for table partitioning.
Michael Paquier, per Coverity.
This commit is contained in:
parent
18fc5192a6
commit
3633b3f656
@ -3248,6 +3248,10 @@ StorePartitionBound(Relation rel, Relation parent, Node *bound)
|
|||||||
classRel = heap_open(RelationRelationId, RowExclusiveLock);
|
classRel = heap_open(RelationRelationId, RowExclusiveLock);
|
||||||
tuple = SearchSysCacheCopy1(RELOID,
|
tuple = SearchSysCacheCopy1(RELOID,
|
||||||
ObjectIdGetDatum(RelationGetRelid(rel)));
|
ObjectIdGetDatum(RelationGetRelid(rel)));
|
||||||
|
if (!HeapTupleIsValid(tuple))
|
||||||
|
elog(ERROR, "cache lookup failed for relation %u",
|
||||||
|
RelationGetRelid(rel));
|
||||||
|
|
||||||
#ifdef USE_ASSERT_CHECKING
|
#ifdef USE_ASSERT_CHECKING
|
||||||
{
|
{
|
||||||
Form_pg_class classForm;
|
Form_pg_class classForm;
|
||||||
|
@ -200,6 +200,8 @@ RelationBuildPartitionDesc(Relation rel)
|
|||||||
Node *boundspec;
|
Node *boundspec;
|
||||||
|
|
||||||
tuple = SearchSysCache1(RELOID, inhrelid);
|
tuple = SearchSysCache1(RELOID, inhrelid);
|
||||||
|
if (!HeapTupleIsValid(tuple))
|
||||||
|
elog(ERROR, "cache lookup failed for relation %u", inhrelid);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* It is possible that the pg_class tuple of a partition has not been
|
* It is possible that the pg_class tuple of a partition has not been
|
||||||
@ -1516,6 +1518,10 @@ generate_partition_qual(Relation rel)
|
|||||||
elog(ERROR, "relation \"%s\" has relispartition = false",
|
elog(ERROR, "relation \"%s\" has relispartition = false",
|
||||||
RelationGetRelationName(rel));
|
RelationGetRelationName(rel));
|
||||||
tuple = SearchSysCache1(RELOID, RelationGetRelid(rel));
|
tuple = SearchSysCache1(RELOID, RelationGetRelid(rel));
|
||||||
|
if (!HeapTupleIsValid(tuple))
|
||||||
|
elog(ERROR, "cache lookup failed for relation %u",
|
||||||
|
RelationGetRelid(rel));
|
||||||
|
|
||||||
boundDatum = SysCacheGetAttr(RELOID, tuple,
|
boundDatum = SysCacheGetAttr(RELOID, tuple,
|
||||||
Anum_pg_class_relpartbound,
|
Anum_pg_class_relpartbound,
|
||||||
&isnull);
|
&isnull);
|
||||||
|
@ -5736,7 +5736,7 @@ getPartitions(Archive *fout, int *numPartitions)
|
|||||||
PGresult *res;
|
PGresult *res;
|
||||||
int ntups;
|
int ntups;
|
||||||
int i;
|
int i;
|
||||||
PQExpBuffer query = createPQExpBuffer();
|
PQExpBuffer query;
|
||||||
PartInfo *partinfo;
|
PartInfo *partinfo;
|
||||||
|
|
||||||
int i_partrelid;
|
int i_partrelid;
|
||||||
@ -5750,6 +5750,8 @@ getPartitions(Archive *fout, int *numPartitions)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query = createPQExpBuffer();
|
||||||
|
|
||||||
/* Make sure we are in proper schema */
|
/* Make sure we are in proper schema */
|
||||||
selectSourceSchema(fout, "pg_catalog");
|
selectSourceSchema(fout, "pg_catalog");
|
||||||
|
|
||||||
@ -7067,7 +7069,7 @@ getTransforms(Archive *fout, int *numTransforms)
|
|||||||
void
|
void
|
||||||
getTablePartitionKeyInfo(Archive *fout, TableInfo *tblinfo, int numTables)
|
getTablePartitionKeyInfo(Archive *fout, TableInfo *tblinfo, int numTables)
|
||||||
{
|
{
|
||||||
PQExpBuffer q = createPQExpBuffer();
|
PQExpBuffer q;
|
||||||
int i;
|
int i;
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
|
|
||||||
@ -7075,6 +7077,8 @@ getTablePartitionKeyInfo(Archive *fout, TableInfo *tblinfo, int numTables)
|
|||||||
if (fout->remoteVersion < 100000)
|
if (fout->remoteVersion < 100000)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
q = createPQExpBuffer();
|
||||||
|
|
||||||
for (i = 0; i < numTables; i++)
|
for (i = 0; i < numTables; i++)
|
||||||
{
|
{
|
||||||
TableInfo *tbinfo = &(tblinfo[i]);
|
TableInfo *tbinfo = &(tblinfo[i]);
|
||||||
@ -7094,6 +7098,8 @@ getTablePartitionKeyInfo(Archive *fout, TableInfo *tblinfo, int numTables)
|
|||||||
Assert(PQntuples(res) == 1);
|
Assert(PQntuples(res) == 1);
|
||||||
tbinfo->partkeydef = pg_strdup(PQgetvalue(res, 0, 0));
|
tbinfo->partkeydef = pg_strdup(PQgetvalue(res, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
destroyPQExpBuffer(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user