1/*-------------------------------------------------------------------------
2 *
3 * dbasedesc.c
4 * rmgr descriptor routines for commands/dbcommands.c
5 *
6 * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 *
10 * IDENTIFICATION
11 * src/backend/access/rmgrdesc/dbasedesc.c
12 *
13 *-------------------------------------------------------------------------
14 */
15#include "postgres.h"
16
17#include "commands/dbcommands_xlog.h"
18#include "lib/stringinfo.h"
19
20
21void
22dbase_desc(StringInfo buf, XLogReaderState *record)
23{
24 char *rec = XLogRecGetData(record);
25 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
26
27 if (info == XLOG_DBASE_CREATE)
28 {
29 xl_dbase_create_rec *xlrec = (xl_dbase_create_rec *) rec;
30
31 appendStringInfo(buf, "copy dir %u/%u to %u/%u",
32 xlrec->src_tablespace_id, xlrec->src_db_id,
33 xlrec->tablespace_id, xlrec->db_id);
34 }
35 else if (info == XLOG_DBASE_DROP)
36 {
37 xl_dbase_drop_rec *xlrec = (xl_dbase_drop_rec *) rec;
38
39 appendStringInfo(buf, "dir %u/%u",
40 xlrec->tablespace_id, xlrec->db_id);
41 }
42}
43
44const char *
45dbase_identify(uint8 info)
46{
47 const char *id = NULL;
48
49 switch (info & ~XLR_INFO_MASK)
50 {
51 case XLOG_DBASE_CREATE:
52 id = "CREATE";
53 break;
54 case XLOG_DBASE_DROP:
55 id = "DROP";
56 break;
57 }
58
59 return id;
60}
61