Age Owner TLA Line data Source code
1 : /*-------------------------------------------------------------------------
2 : *
3 : * dbasedesc.c
4 : * rmgr descriptor routines for commands/dbcommands.c
5 : *
6 : * Portions Copyright (c) 1996-2023, 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 :
21 : void
3062 heikki.linnakangas 22 CBC 23 : dbase_desc(StringInfo buf, XLogReaderState *record)
23 : {
3221 24 23 : char *rec = XLogRecGetData(record);
3062 25 23 : uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
26 :
376 rhaas 27 23 : if (info == XLOG_DBASE_CREATE_FILE_COPY)
28 : {
29 6 : xl_dbase_create_file_copy_rec *xlrec =
30 : (xl_dbase_create_file_copy_rec *) rec;
31 :
3124 andres 32 6 : appendStringInfo(buf, "copy dir %u/%u to %u/%u",
33 : xlrec->src_tablespace_id, xlrec->src_db_id,
34 : xlrec->tablespace_id, xlrec->db_id);
35 : }
376 rhaas 36 17 : else if (info == XLOG_DBASE_CREATE_WAL_LOG)
37 : {
376 rhaas 38 UBC 0 : xl_dbase_create_wal_log_rec *xlrec =
39 : (xl_dbase_create_wal_log_rec *) rec;
40 :
41 0 : appendStringInfo(buf, "create dir %u/%u",
42 : xlrec->tablespace_id, xlrec->db_id);
43 : }
3784 alvherre 44 CBC 17 : else if (info == XLOG_DBASE_DROP)
45 : {
46 17 : xl_dbase_drop_rec *xlrec = (xl_dbase_drop_rec *) rec;
47 : int i;
48 :
906 drowley 49 17 : appendStringInfoString(buf, "dir");
1235 fujii 50 34 : for (i = 0; i < xlrec->ntablespaces; i++)
51 17 : appendStringInfo(buf, " %u/%u",
52 : xlrec->tablespace_ids[i], xlrec->db_id);
53 : }
3124 andres 54 23 : }
55 :
56 : const char *
57 23 : dbase_identify(uint8 info)
58 : {
59 23 : const char *id = NULL;
60 :
3121 61 23 : switch (info & ~XLR_INFO_MASK)
62 : {
376 rhaas 63 6 : case XLOG_DBASE_CREATE_FILE_COPY:
64 6 : id = "CREATE_FILE_COPY";
65 6 : break;
376 rhaas 66 UBC 0 : case XLOG_DBASE_CREATE_WAL_LOG:
67 0 : id = "CREATE_WAL_LOG";
3124 andres 68 0 : break;
3124 andres 69 CBC 17 : case XLOG_DBASE_DROP:
70 17 : id = "DROP";
71 17 : break;
72 : }
73 :
74 23 : return id;
75 : }
|