Skip to content

Commit

Permalink
Merge pull request #227 from dutow/smgrmerge
Browse files Browse the repository at this point in the history
Merge the smgr branch back to main
  • Loading branch information
dutow authored Jun 26, 2024
2 parents fefe7b7 + 4312c48 commit a21bfac
Show file tree
Hide file tree
Showing 30 changed files with 1,574 additions and 323 deletions.
3 changes: 3 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ src/keyring/keyring_curl.o \
src/keyring/keyring_file.o \
src/keyring/keyring_vault.o \
src/keyring/keyring_api.o \
src/catalog/tde_global_catalog.o \
src/catalog/tde_keyring.o \
src/catalog/tde_master_key.o \
src/common/pg_tde_shmem.o \
src/common/pg_tde_utils.o \
src/smgr/pg_tde_smgr.o \
src/pg_tde_defs.o \
src/pg_tde_event_capture.o \
src/pg_tde.o

override PG_CPPFLAGS += @tde_CPPFLAGS@
Expand Down
4 changes: 4 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ pg_tde_sources = files(
'src/keyring/keyring_vault.c',
'src/keyring/keyring_api.c',

'src/smgr/pg_tde_smgr.c',

'src/catalog/tde_global_catalog.c',
'src/catalog/tde_keyring.c',
'src/catalog/tde_master_key.c',
'src/common/pg_tde_shmem.c',
'src/common/pg_tde_utils.c',
'src/pg_tde_defs.c',
'src/pg_tde.c',
'src/pg_tde_event_capture.c',
)

incdir = include_directories('src/include', '.')
Expand Down
27 changes: 27 additions & 0 deletions pg_tde--1.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ RETURNS table_am_handler
AS 'MODULE_PATHNAME'
LANGUAGE C;

-- Table access method
CREATE FUNCTION pg_tde2am_handler(internal)
RETURNS table_am_handler
AS 'MODULE_PATHNAME'
LANGUAGE C;

CREATE FUNCTION pgtde_is_encrypted(table_name VARCHAR)
RETURNS boolean
AS $$
Expand Down Expand Up @@ -129,5 +135,26 @@ CREATE FUNCTION pg_tde_version() RETURNS TEXT AS 'MODULE_PATHNAME' LANGUAGE C;
CREATE ACCESS METHOD pg_tde TYPE TABLE HANDLER pg_tdeam_handler;
COMMENT ON ACCESS METHOD pg_tde IS 'pg_tde table access method';

CREATE ACCESS METHOD pg_tde2 TYPE TABLE HANDLER pg_tde2am_handler;
COMMENT ON ACCESS METHOD pg_tde2 IS 'pg_tde2 table access method';

-- Per database extension initialization
SELECT pg_tde_extension_initialize();

CREATE OR REPLACE FUNCTION pg_tde_ddl_command_start_capture()
RETURNS event_trigger
AS 'MODULE_PATHNAME'
LANGUAGE C;

CREATE OR REPLACE FUNCTION pg_tde_ddl_command_end_capture()
RETURNS event_trigger
AS 'MODULE_PATHNAME'
LANGUAGE C;

CREATE EVENT TRIGGER pg_tde_trigger_create_index
ON ddl_command_start
EXECUTE FUNCTION pg_tde_ddl_command_start_capture();

CREATE EVENT TRIGGER pg_tde_trigger_create_index_2
ON ddl_command_end
EXECUTE FUNCTION pg_tde_ddl_command_end_capture();
12 changes: 7 additions & 5 deletions src/access/pg_tde_prune.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ pg_tde_page_prune_opt(Relation relation, Buffer buffer)
if (RecoveryInProgress())
return;

#if PG_VERSION_NUM < 170000
/*
* XXX: Magic to keep old_snapshot_threshold tests appear "working". They
* currently are broken, and discussion of what to do about them is
Expand All @@ -135,7 +136,7 @@ pg_tde_page_prune_opt(Relation relation, Buffer buffer)
*/
if (old_snapshot_threshold == 0)
SnapshotTooOldMagicForTest();

#endif
/*
* First check whether there's any chance there's something to prune,
* determining the appropriate horizon is a waste if there's no prune_xid
Expand Down Expand Up @@ -166,14 +167,14 @@ pg_tde_page_prune_opt(Relation relation, Buffer buffer)

if (!GlobalVisTestIsRemovableXid(vistest, prune_xid))
{
if (!OldSnapshotThresholdActive())
#if PG_VERSION_NUM < 170000
if ( !OldSnapshotThresholdActive())
return;

if (!TransactionIdLimitedForOldSnapshots(GlobalVisTestNonRemovableHorizon(vistest),
relation,
&limited_xmin, &limited_ts))
return;

#endif
if (!TransactionIdPrecedes(prune_xid, limited_xmin))
return;
}
Expand Down Expand Up @@ -539,6 +540,7 @@ heap_prune_satisfies_vacuum(PruneState *prstate, HeapTuple tup, Buffer buffer)
*/
if (GlobalVisTestIsRemovableXid(prstate->vistest, dead_after))
res = HEAPTUPLE_DEAD;
#if PG_VERSION_NUM < 170000
else if (OldSnapshotThresholdActive())
{
/* haven't determined limited horizon yet, requests */
Expand Down Expand Up @@ -566,7 +568,7 @@ heap_prune_satisfies_vacuum(PruneState *prstate, HeapTuple tup, Buffer buffer)
res = HEAPTUPLE_DEAD;
}
}

#endif
return res;
}

Expand Down
Loading

0 comments on commit a21bfac

Please sign in to comment.