Fixes build error

pull/7375/head
gindibay 2023-12-13 01:22:49 +03:00 committed by gurkanindibay
parent f8a332952d
commit 369756cfcb
1 changed files with 44 additions and 43 deletions

View File

@ -140,47 +140,48 @@ citus_internal_database_size(PG_FUNCTION_ARGS)
ClearResults(connection, failOnError); ClearResults(connection, failOnError);
PG_RETURN_INT64(size); PG_RETURN_INT64(size);
} }
}
/*
* Retrieves the groupId of a distributed database
* using databaseOid from the pg_dist_database table. /*
*/ * Retrieves the groupId of a distributed database
static int * using databaseOid from the pg_dist_database table.
GroupLookupFromDatabase(int64 databaseOid, bool missingOk) */
{ static int
ScanKeyData scanKey[1]; GroupLookupFromDatabase(int64 databaseOid, bool missingOk)
int scanKeyCount = 1; {
Form_pg_dist_database databaseForm = NULL; ScanKeyData scanKey[1];
Relation pgDistDatabase = table_open(PgDistDatabaseRelationId(), AccessShareLock); int scanKeyCount = 1;
int groupId = -1; Form_pg_dist_database databaseForm = NULL;
Relation pgDistDatabase = table_open(PgDistDatabaseRelationId(), AccessShareLock);
ScanKeyInit(&scanKey[0], Anum_pg_dist_database_databaseid, int groupId = -1;
BTEqualStrategyNumber, F_INT8EQ, Int64GetDatum(databaseOid));
ScanKeyInit(&scanKey[0], Anum_pg_dist_database_databaseid,
SysScanDesc scanDescriptor = systable_beginscan(pgDistDatabase, BTEqualStrategyNumber, F_INT8EQ, Int64GetDatum(databaseOid));
InvalidOid, true,
NULL, scanKeyCount, scanKey); SysScanDesc scanDescriptor = systable_beginscan(pgDistDatabase,
InvalidOid, true,
HeapTuple heapTuple = systable_getnext(scanDescriptor); NULL, scanKeyCount, scanKey);
if (!HeapTupleIsValid(heapTuple) && !missingOk)
{ HeapTuple heapTuple = systable_getnext(scanDescriptor);
ereport(ERROR, (errmsg("could not find valid entry for database " if (!HeapTupleIsValid(heapTuple) && !missingOk)
UINT64_FORMAT, databaseOid))); {
} ereport(ERROR, (errmsg("could not find valid entry for database "
UINT64_FORMAT, databaseOid)));
if (!HeapTupleIsValid(heapTuple)) }
{
groupId = -2; if (!HeapTupleIsValid(heapTuple))
} {
else groupId = -2;
{ }
databaseForm = (Form_pg_dist_database) GETSTRUCT(heapTuple); else
groupId = databaseForm->groupid; {
} databaseForm = (Form_pg_dist_database) GETSTRUCT(heapTuple);
groupId = databaseForm->groupid;
systable_endscan(scanDescriptor); }
table_close(pgDistDatabase, NoLock);
systable_endscan(scanDescriptor);
return groupId; table_close(pgDistDatabase, NoLock);
}
return groupId;
} }