mirror of
https://github.com/postgres/postgres.git
synced 2025-11-19 13:42:17 +03:00
Avoid including commands/dbcommands.h in so many places
This has been done historically because of get_database_name (which since commitcb98e6fb8fbelongs in lsyscache.c/h, so let's move it there) and get_database_oid (which is in the right place, but whose declaration should appear in pg_database.h rather than dbcommands.h). Clean this up. Also, xlogreader.h and stringinfo.h are no longer needed by dbcommands.h since commitf1fd515b39, so remove them. Author: Álvaro Herrera <alvherre@kurilemu.de> Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/202508191031.5ipojyuaswzt@alvherre.pgsql
This commit is contained in:
@@ -31,7 +31,6 @@
|
||||
#include "catalog/pg_proc.h"
|
||||
#include "catalog/pg_tablespace.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "commands/dbcommands.h"
|
||||
#include "commands/proclang.h"
|
||||
#include "commands/tablespace.h"
|
||||
#include "common/hashfn.h"
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
#include "catalog/pg_authid.h"
|
||||
#include "catalog/pg_database.h"
|
||||
#include "catalog/pg_tablespace.h"
|
||||
#include "commands/dbcommands.h"
|
||||
#include "commands/tablespace.h"
|
||||
#include "miscadmin.h"
|
||||
#include "storage/fd.h"
|
||||
#include "utils/acl.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/numeric.h"
|
||||
#include "utils/rel.h"
|
||||
#include "utils/relfilenumbermap.h"
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "catalog/pg_tablespace.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "catalog/system_fk_info.h"
|
||||
#include "commands/dbcommands.h"
|
||||
#include "commands/tablespace.h"
|
||||
#include "common/keywords.h"
|
||||
#include "funcapi.h"
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
#include "catalog/namespace.h"
|
||||
#include "catalog/pg_class.h"
|
||||
#include "catalog/pg_collation.h"
|
||||
#include "catalog/pg_database.h"
|
||||
#include "catalog/pg_operator.h"
|
||||
#include "catalog/pg_proc.h"
|
||||
#include "catalog/pg_ts_config.h"
|
||||
#include "catalog/pg_ts_dict.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "commands/dbcommands.h"
|
||||
#include "lib/stringinfo.h"
|
||||
#include "mb/pg_wchar.h"
|
||||
#include "miscadmin.h"
|
||||
|
||||
@@ -84,7 +84,6 @@
|
||||
#include "catalog/namespace.h"
|
||||
#include "catalog/pg_class.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "commands/dbcommands.h"
|
||||
#include "executor/spi.h"
|
||||
#include "executor/tablefunc.h"
|
||||
#include "fmgr.h"
|
||||
|
||||
27
src/backend/utils/cache/lsyscache.c
vendored
27
src/backend/utils/cache/lsyscache.c
vendored
@@ -26,6 +26,7 @@
|
||||
#include "catalog/pg_class.h"
|
||||
#include "catalog/pg_collation.h"
|
||||
#include "catalog/pg_constraint.h"
|
||||
#include "catalog/pg_database.h"
|
||||
#include "catalog/pg_index.h"
|
||||
#include "catalog/pg_language.h"
|
||||
#include "catalog/pg_namespace.h"
|
||||
@@ -1247,6 +1248,32 @@ get_constraint_type(Oid conoid)
|
||||
return contype;
|
||||
}
|
||||
|
||||
/* ---------- DATABASE CACHE ---------- */
|
||||
|
||||
/*
|
||||
* get_database_name - given a database OID, look up the name
|
||||
*
|
||||
* Returns a palloc'd string, or NULL if no such database.
|
||||
*/
|
||||
char *
|
||||
get_database_name(Oid dbid)
|
||||
{
|
||||
HeapTuple dbtuple;
|
||||
char *result;
|
||||
|
||||
dbtuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(dbid));
|
||||
if (HeapTupleIsValid(dbtuple))
|
||||
{
|
||||
result = pstrdup(NameStr(((Form_pg_database) GETSTRUCT(dbtuple))->datname));
|
||||
ReleaseSysCache(dbtuple);
|
||||
}
|
||||
else
|
||||
result = NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* ---------- LANGUAGE CACHE ---------- */
|
||||
|
||||
char *
|
||||
|
||||
Reference in New Issue
Block a user