Skip to content

Commit f1fd515

Browse files
committed
Move WAL-related definitions from dbcommands.h to separate header file.
This makes it easier to write frontend programs that needs to understand the WAL record format of CREATE/DROP DATABASE. dbcommands.h cannot easily be #included in a frontend program, because it pulls in other header files that need backend stuff, but the new dbcommands_xlog.h header file has fewer dependencies.
1 parent b9e538b commit f1fd515

File tree

6 files changed

+48
-27
lines changed

6 files changed

+48
-27
lines changed

contrib/pg_xlogdump/rmgrdesc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "access/xact.h"
2323
#include "access/xlog_internal.h"
2424
#include "catalog/storage_xlog.h"
25-
#include "commands/dbcommands.h"
25+
#include "commands/dbcommands_xlog.h"
2626
#include "commands/sequence.h"
2727
#include "commands/tablespace.h"
2828
#include "rmgrdesc.h"

src/backend/access/rmgrdesc/dbasedesc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
#include "postgres.h"
1616

17-
#include "commands/dbcommands.h"
17+
#include "commands/dbcommands_xlog.h"
1818
#include "lib/stringinfo.h"
1919

2020

src/backend/access/transam/rmgr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "access/xact.h"
2121
#include "access/xlog_internal.h"
2222
#include "catalog/storage_xlog.h"
23-
#include "commands/dbcommands.h"
23+
#include "commands/dbcommands_xlog.h"
2424
#include "commands/sequence.h"
2525
#include "commands/tablespace.h"
2626
#include "storage/standby.h"

src/backend/commands/dbcommands.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "catalog/pg_tablespace.h"
4141
#include "commands/comment.h"
4242
#include "commands/dbcommands.h"
43+
#include "commands/dbcommands_xlog.h"
4344
#include "commands/defrem.h"
4445
#include "commands/seclabel.h"
4546
#include "commands/tablespace.h"

src/include/commands/dbcommands.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,6 @@
1919
#include "lib/stringinfo.h"
2020
#include "nodes/parsenodes.h"
2121

22-
/* XLOG stuff */
23-
#define XLOG_DBASE_CREATE 0x00
24-
#define XLOG_DBASE_DROP 0x10
25-
26-
typedef struct xl_dbase_create_rec
27-
{
28-
/* Records copying of a single subdirectory incl. contents */
29-
Oid db_id;
30-
Oid tablespace_id;
31-
Oid src_db_id;
32-
Oid src_tablespace_id;
33-
} xl_dbase_create_rec;
34-
35-
typedef struct xl_dbase_drop_rec
36-
{
37-
/* Records dropping of a single subdirectory incl. contents */
38-
Oid db_id;
39-
Oid tablespace_id;
40-
} xl_dbase_drop_rec;
41-
4222
extern Oid createdb(const CreatedbStmt *stmt);
4323
extern void dropdb(const char *dbname, bool missing_ok);
4424
extern ObjectAddress RenameDatabase(const char *oldname, const char *newname);
@@ -49,10 +29,6 @@ extern ObjectAddress AlterDatabaseOwner(const char *dbname, Oid newOwnerId);
4929
extern Oid get_database_oid(const char *dbname, bool missingok);
5030
extern char *get_database_name(Oid dbid);
5131

52-
extern void dbase_redo(XLogReaderState *rptr);
53-
extern void dbase_desc(StringInfo buf, XLogReaderState *rptr);
54-
extern const char *dbase_identify(uint8 info);
55-
5632
extern void check_encoding_locale_matches(int encoding, const char *collate, const char *ctype);
5733

5834
#endif /* DBCOMMANDS_H */
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* dbcommands_xlog.h
4+
* Database resource manager XLOG definitions (create/drop database).
5+
*
6+
*
7+
* Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
8+
* Portions Copyright (c) 1994, Regents of the University of California
9+
*
10+
* src/include/commands/dbcommands_xlog.h
11+
*
12+
*-------------------------------------------------------------------------
13+
*/
14+
#ifndef DBCOMMANDS_XLOG_H
15+
#define DBCOMMANDS_XLOG_H
16+
17+
#include "access/xlogreader.h"
18+
#include "lib/stringinfo.h"
19+
20+
/* record types */
21+
#define XLOG_DBASE_CREATE 0x00
22+
#define XLOG_DBASE_DROP 0x10
23+
24+
typedef struct xl_dbase_create_rec
25+
{
26+
/* Records copying of a single subdirectory incl. contents */
27+
Oid db_id;
28+
Oid tablespace_id;
29+
Oid src_db_id;
30+
Oid src_tablespace_id;
31+
} xl_dbase_create_rec;
32+
33+
typedef struct xl_dbase_drop_rec
34+
{
35+
/* Records dropping of a single subdirectory incl. contents */
36+
Oid db_id;
37+
Oid tablespace_id;
38+
} xl_dbase_drop_rec;
39+
40+
extern void dbase_redo(XLogReaderState *rptr);
41+
extern void dbase_desc(StringInfo buf, XLogReaderState *rptr);
42+
extern const char *dbase_identify(uint8 info);
43+
44+
#endif /* DBCOMMANDS_XLOG_H */

0 commit comments

Comments
 (0)