Skip to content

Commit

Permalink
Adds dist_database to metadata cache
Browse files Browse the repository at this point in the history
  • Loading branch information
gurkanindibay committed Dec 26, 2023
1 parent 1cc19a4 commit fba4e65
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/backend/distributed/commands/citus_database_size.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ GroupLookupFromDatabase(int64 databaseOid, bool missingOk)
ScanKeyData scanKey[1];
int scanKeyCount = 1;
Form_pg_dist_database databaseForm = NULL;
Relation pgDistDatabase = table_open(PgDistDatabaseRelationId(), AccessShareLock);
Relation pgDistDatabase = table_open(DistDatabaseRelationId(), AccessShareLock);
int groupId = -1;

ScanKeyInit(&scanKey[0], Anum_pg_dist_database_databaseid,
Expand Down
12 changes: 12 additions & 0 deletions src/backend/distributed/metadata/metadata_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ typedef struct MetadataCacheData
Oid distCleanupPrimaryKeyIndexId;
Oid distColocationRelationId;
Oid distColocationConfigurationIndexId;
Oid distDatabaseRelationId;
Oid distPartitionRelationId;
Oid distTenantSchemaRelationId;
Oid distPartitionLogicalRelidIndexId;
Expand Down Expand Up @@ -2903,6 +2904,17 @@ DistColocationConfigurationIndexId(void)
}


/* return oid of pg_dist_database relation */
Oid
DistDatabaseRelationId(void)
{
CachedRelationLookup("pg_dist_database",
&MetadataCache.distDatabaseRelationId);

return MetadataCache.distDatabaseRelationId;
}


/* return oid of pg_dist_schema relation */
Oid
DistTenantSchemaRelationId(void)
Expand Down
1 change: 1 addition & 0 deletions src/include/distributed/metadata_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ extern Oid CitusCatalogNamespaceId(void);
extern Oid DistCleanupRelationId(void);
extern Oid DistColocationRelationId(void);
extern Oid DistColocationConfigurationIndexId(void);
extern Oid DistDatabaseRelationId(void);
extern Oid DistPartitionRelationId(void);
extern Oid DistShardRelationId(void);
extern Oid DistPlacementRelationId(void);
Expand Down
2 changes: 0 additions & 2 deletions src/include/distributed/pg_dist_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,4 @@ typedef struct FormData_pg_dist_database
typedef FormData_pg_dist_database *Form_pg_dist_database;


#define PgDistDatabaseRelationId() (get_relname_relid("pg_dist_database", \
PG_CATALOG_NAMESPACE))
#endif /* CITUS_PG_DIST_DATABASE_H */

0 comments on commit fba4e65

Please sign in to comment.