Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added

- Support for PostgreSQL 19 Beta 3 ([PG-2536](https://perconadev.atlassian.net/browse/PG-2536))
- Make pg_tde_waldump recognise and print proper data for the pg_tde custom resource manager ([PG-2754](https://perconadev.atlassian.net/browse/PG-2754))

## 2.2.2

Expand Down
8 changes: 8 additions & 0 deletions fetools/pg16/pg_waldump/pg_waldump.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "storage/bufpage.h"

#include "pg_tde_fe.h"
#include "access/pg_tde_xlog.h"
#include "access/pg_tde_xlog_smgr.h"
#include "access/xlog_smgr.h"
#include "catalog/tde_global_space.h"
Expand Down Expand Up @@ -108,6 +109,8 @@ print_rmgr_list(void)
{
printf("%s\n", GetRmgrDesc(i)->rm_name);
}

printf("%s\n", RM_TDERMGR_NAME);
}

/*
Expand Down Expand Up @@ -991,6 +994,11 @@ main(int argc, char **argv)
config.filter_by_rmgr[rmid] = true;
config.filter_by_rmgr_enabled = true;
}
else if (pg_strcasecmp(optarg, RM_TDERMGR_NAME) == 0)
{
config.filter_by_rmgr[RM_TDERMGR_ID] = true;
config.filter_by_rmgr_enabled = true;
}
else
{
/* then look for builtin rmgrs */
Expand Down
8 changes: 8 additions & 0 deletions fetools/pg16/pg_waldump/rmgrdesc.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "storage/standbydefs.h"
#include "utils/relmapper.h"

#include "access/pg_tde_xlog.h"

#define PG_RMGR(symname,name,redo,desc,identify,startup,cleanup,mask,decode) \
{ name, desc, identify},

Expand Down Expand Up @@ -80,6 +82,12 @@ initialize_custom_rmgrs(void)
CustomRmgrDesc[i].rm_desc = default_desc;
CustomRmgrDesc[i].rm_identify = default_identify;
}

/* Initialize pg_tde resource manager */
CustomRmgrDesc[RM_TDERMGR_ID - RM_MIN_CUSTOM_ID].rm_name = RM_TDERMGR_NAME;
CustomRmgrDesc[RM_TDERMGR_ID - RM_MIN_CUSTOM_ID].rm_desc = tdeheap_rmgr_desc;
CustomRmgrDesc[RM_TDERMGR_ID - RM_MIN_CUSTOM_ID].rm_identify = tdeheap_rmgr_identify;

CustomRmgrDescInitialized = true;
}

Expand Down
8 changes: 8 additions & 0 deletions fetools/pg17/pg_waldump/pg_waldump.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "storage/bufpage.h"

#include "pg_tde_fe.h"
#include "access/pg_tde_xlog.h"
#include "access/pg_tde_xlog_smgr.h"
#include "access/xlog_smgr.h"
#include "catalog/tde_global_space.h"
Expand Down Expand Up @@ -108,6 +109,8 @@ print_rmgr_list(void)
{
printf("%s\n", GetRmgrDesc(i)->rm_name);
}

printf("%s\n", RM_TDERMGR_NAME);
}

/*
Expand Down Expand Up @@ -995,6 +998,11 @@ main(int argc, char **argv)
config.filter_by_rmgr[rmid] = true;
config.filter_by_rmgr_enabled = true;
}
else if (pg_strcasecmp(optarg, RM_TDERMGR_NAME) == 0)
{
config.filter_by_rmgr[RM_TDERMGR_ID] = true;
config.filter_by_rmgr_enabled = true;
}
else
{
/* then look for builtin rmgrs */
Expand Down
8 changes: 8 additions & 0 deletions fetools/pg17/pg_waldump/rmgrdesc.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "storage/standbydefs.h"
#include "utils/relmapper.h"

#include "access/pg_tde_xlog.h"

#define PG_RMGR(symname,name,redo,desc,identify,startup,cleanup,mask,decode) \
{ name, desc, identify},

Expand Down Expand Up @@ -80,6 +82,12 @@ initialize_custom_rmgrs(void)
CustomRmgrDesc[i].rm_desc = default_desc;
CustomRmgrDesc[i].rm_identify = default_identify;
}

/* Initialize pg_tde resource manager */
CustomRmgrDesc[RM_TDERMGR_ID - RM_MIN_CUSTOM_ID].rm_name = RM_TDERMGR_NAME;
CustomRmgrDesc[RM_TDERMGR_ID - RM_MIN_CUSTOM_ID].rm_desc = tdeheap_rmgr_desc;
CustomRmgrDesc[RM_TDERMGR_ID - RM_MIN_CUSTOM_ID].rm_identify = tdeheap_rmgr_identify;

CustomRmgrDescInitialized = true;
}

Expand Down
8 changes: 8 additions & 0 deletions fetools/pg18/pg_waldump/pg_waldump.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "storage/bufpage.h"

#include "pg_tde_fe.h"
#include "access/pg_tde_xlog.h"
#include "access/pg_tde_xlog_smgr.h"
#include "access/xlog_smgr.h"
#include "catalog/tde_global_space.h"
Expand Down Expand Up @@ -108,6 +109,8 @@ print_rmgr_list(void)
{
printf("%s\n", GetRmgrDesc(i)->rm_name);
}

printf("%s\n", RM_TDERMGR_NAME);
}

/*
Expand Down Expand Up @@ -995,6 +998,11 @@ main(int argc, char **argv)
config.filter_by_rmgr[rmid] = true;
config.filter_by_rmgr_enabled = true;
}
else if (pg_strcasecmp(optarg, RM_TDERMGR_NAME) == 0)
{
config.filter_by_rmgr[RM_TDERMGR_ID] = true;
config.filter_by_rmgr_enabled = true;
}
else
{
/* then look for builtin rmgrs */
Expand Down
8 changes: 8 additions & 0 deletions fetools/pg18/pg_waldump/rmgrdesc.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "storage/standbydefs.h"
#include "utils/relmapper.h"

#include "access/pg_tde_xlog.h"

#define PG_RMGR(symname,name,redo,desc,identify,startup,cleanup,mask,decode) \
{ name, desc, identify},

Expand Down Expand Up @@ -80,6 +82,12 @@ initialize_custom_rmgrs(void)
CustomRmgrDesc[i].rm_desc = default_desc;
CustomRmgrDesc[i].rm_identify = default_identify;
}

/* Initialize pg_tde resource manager */
CustomRmgrDesc[RM_TDERMGR_ID - RM_MIN_CUSTOM_ID].rm_name = RM_TDERMGR_NAME;
CustomRmgrDesc[RM_TDERMGR_ID - RM_MIN_CUSTOM_ID].rm_desc = tdeheap_rmgr_desc;
CustomRmgrDesc[RM_TDERMGR_ID - RM_MIN_CUSTOM_ID].rm_identify = tdeheap_rmgr_identify;

CustomRmgrDescInitialized = true;
}

Expand Down
8 changes: 8 additions & 0 deletions fetools/pg19/pg_waldump/pg_waldump.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "storage/bufpage.h"

#include "pg_tde_fe.h"
#include "access/pg_tde_xlog.h"
#include "access/pg_tde_xlog_smgr.h"
#include "access/xlog_smgr.h"
#include "catalog/tde_global_space.h"
Expand Down Expand Up @@ -102,6 +103,8 @@ print_rmgr_list(void)
{
printf("%s\n", GetRmgrDesc(i)->rm_name);
}

printf("%s\n", RM_TDERMGR_NAME);
}

/*
Expand Down Expand Up @@ -1138,6 +1141,11 @@ main(int argc, char **argv)
config.filter_by_rmgr[rmid] = true;
config.filter_by_rmgr_enabled = true;
}
else if (pg_strcasecmp(optarg, RM_TDERMGR_NAME) == 0)
{
config.filter_by_rmgr[RM_TDERMGR_ID] = true;
config.filter_by_rmgr_enabled = true;
}
else
{
/* then look for builtin rmgrs */
Expand Down
8 changes: 8 additions & 0 deletions fetools/pg19/pg_waldump/rmgrdesc.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "storage/standbydefs.h"
#include "utils/relmapper.h"

#include "access/pg_tde_xlog.h"

#define PG_RMGR(symname,name,redo,desc,identify,startup,cleanup,mask,decode) \
{ name, desc, identify},

Expand Down Expand Up @@ -80,6 +82,12 @@ initialize_custom_rmgrs(void)
CustomRmgrDesc[i].rm_desc = default_desc;
CustomRmgrDesc[i].rm_identify = default_identify;
}

/* Initialize pg_tde resource manager */
CustomRmgrDesc[RM_TDERMGR_ID - RM_MIN_CUSTOM_ID].rm_name = RM_TDERMGR_NAME;
CustomRmgrDesc[RM_TDERMGR_ID - RM_MIN_CUSTOM_ID].rm_desc = tdeheap_rmgr_desc;
CustomRmgrDesc[RM_TDERMGR_ID - RM_MIN_CUSTOM_ID].rm_identify = tdeheap_rmgr_identify;

CustomRmgrDescInitialized = true;
}

Expand Down
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ pg_tde_frontend = static_library('pg_tde_frontend',
files(
'src/pg_tde_fe.c',
'src/access/pg_tde_tdemap.c',
'src/access/pg_tde_xlog.c',
'src/access/pg_tde_xlog_keys.c',
'src/catalog/tde_keyring.c',
'src/catalog/tde_keyring_parse_opts.c',
Expand Down Expand Up @@ -378,6 +379,7 @@ tap_tests = [
't/pg_tde_upgrade.pl',
't/pg_waldump_basic.pl',
't/pg_waldump_fullpage.pl',
't/pg_waldump_tde_rmgr.pl',
't/regress.pl',
't/replication.pl',
't/reuse_relfilenode_in_cache.pl',
Expand Down
15 changes: 10 additions & 5 deletions src/access/pg_tde_xlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

#include "postgres.h"

#ifndef FRONTEND
#include "access/xlog.h"
#include "access/xlog_internal.h"
#include "access/xloginsert.h"
#include "storage/bufmgr.h"
#include "storage/shmem.h"
#include "utils/guc.h"
#include "utils/memutils.h"
#endif

#include "access/pg_tde_xlog_keys.h"
#include "access/pg_tde_xlog.h"
Expand All @@ -21,12 +23,14 @@
#include "pg_tde_defines.h"
#include "smgr/pg_tde_smgr.h"

#ifdef FRONTEND
#include "pg_tde_fe.h"
#else

static void tdeheap_rmgr_redo(XLogReaderState *record);
static void tdeheap_rmgr_desc(StringInfo buf, XLogReaderState *record);
static const char *tdeheap_rmgr_identify(uint8 info);

static const RmgrData tdeheap_rmgr = {
.rm_name = "pg_tde",
.rm_name = RM_TDERMGR_NAME,
.rm_redo = tdeheap_rmgr_redo,
.rm_desc = tdeheap_rmgr_desc,
.rm_identify = tdeheap_rmgr_identify,
Expand Down Expand Up @@ -93,8 +97,9 @@ tdeheap_rmgr_redo(XLogReaderState *record)
elog(PANIC, "pg_tde_redo: unknown op code %u", info);
}
}
#endif /* !FRONTEND */

static void
void
tdeheap_rmgr_desc(StringInfo buf, XLogReaderState *record)
{
uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
Expand Down Expand Up @@ -143,7 +148,7 @@ tdeheap_rmgr_desc(StringInfo buf, XLogReaderState *record)
}
}

static const char *
const char *
tdeheap_rmgr_identify(uint8 info)
{
switch (info & ~XLR_INFO_MASK)
Expand Down
9 changes: 7 additions & 2 deletions src/include/access/pg_tde_xlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef PG_TDE_XLOG_H
#define PG_TDE_XLOG_H

#ifndef FRONTEND
#include "access/xlogreader.h"

/* TDE XLOG record types */
#define XLOG_TDE_CREATE_RELATION_KEY 0x00
Expand All @@ -18,13 +18,18 @@

/* ID 140 is registered for Percona TDE extension: https://wiki.postgresql.org/wiki/CustomWALResourceManagers */
#define RM_TDERMGR_ID 140
#define RM_TDERMGR_NAME "pg_tde"

typedef struct XLogRelKey
{
RelFileLocator rlocator;
} XLogRelKey;

extern void RegisterTdeRmgr(void);
extern void tdeheap_rmgr_desc(StringInfo buf, XLogReaderState *record);
extern const char *tdeheap_rmgr_identify(uint8 info);

#ifndef FRONTEND
extern void RegisterTdeRmgr(void);
#endif /* !FRONTEND */

#endif /* PG_TDE_XLOG_H */
Loading