-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code re-arrangement, Makefile fixes and implementing '.tde' relation …
…fork (#5) - Fixing the Makefile to link with ssl and crypto libs required by the extension. - An entry file pg_tde.c for all extension-related initialization functions - A new ".tde" relation fork to store the encryption key and related data. Currently, the relation fork gets created with new relations and a dummy encryption key gets stored in the fork. - Re-arranging the directory structure to separate source and header files
- Loading branch information
1 parent
19ee9a6
commit 9fa73a6
Showing
25 changed files
with
152 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,38 @@ | ||
# contrib/pg_tde/Makefile | ||
|
||
PGFILEDESC = "pg_tde access method" | ||
|
||
MODULE_big = pg_tde | ||
EXTENSION = pg_tde | ||
DATA = pg_tde--1.0.sql | ||
REGRESS = pg_tde | ||
TAP_TESTS = 0 | ||
|
||
SUBDIRS = src | ||
OBJS = src/encryption/enc_tuple.o \ | ||
src/encryption/enc_aes.o \ | ||
src/access/pg_tde_io.o \ | ||
src/access/pg_tdeam_visibility.o \ | ||
src/access/pg_tde_tdemap.o \ | ||
src/access/pg_tdeam.o \ | ||
src/access/pg_tdetoast.o \ | ||
src/access/pg_tde_prune.o \ | ||
src/access/pg_tde_vacuumlazy.o \ | ||
src/access/pg_tde_visibilitymap.o \ | ||
src/access/pg_tde_rewrite.o \ | ||
src/access/pg_tdeam_handler.o \ | ||
src/pg_tde.o | ||
|
||
|
||
ifdef USE_PGXS | ||
PG_CONFIG = pg_config | ||
PGXS := $(shell $(PG_CONFIG) --pgxs) | ||
override PG_CPPFLAGS += -I$(CURDIR)/src/include | ||
include $(PGXS) | ||
else | ||
subdir = contrib/postgres-tde-ext | ||
top_builddir = ../.. | ||
override PG_CPPFLAGS += -I$(top_srcdir)/$(subdir)/src/include | ||
include $(top_builddir)/src/Makefile.global | ||
include $(top_srcdir)/contrib/contrib-global.mk | ||
endif | ||
|
||
$(recurse) | ||
SHLIB_LINK += $(filter -lcrypto -lssl, $(LIBS)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/*------------------------------------------------------------------------- | ||
* | ||
* pg_tde_tdemap.c | ||
* tde relation fork manager code | ||
* | ||
* | ||
* IDENTIFICATION | ||
* src/access/pg_tde_tdemap.c | ||
* | ||
*------------------------------------------------------------------------- | ||
*/ | ||
|
||
#include "postgres.h" | ||
#include "access/pg_tde_tdemap.h" | ||
#include "storage/fd.h" | ||
#include "utils/wait_event.h" | ||
|
||
/* | ||
* Creates a relation fork file relfilenode.tde that contains the | ||
* encryption key for the relation. | ||
*/ | ||
void | ||
pg_tde_create_key_fork(const RelFileLocator *newrlocator, Relation rel) | ||
{ | ||
char *rel_file_path; | ||
char *key_file_path; | ||
File file = -1; | ||
char enc_key[256]; /* Dummy key */ | ||
|
||
/* We get a relation name for MAIN fork and manually append the | ||
* .tde postfix to the file name | ||
*/ | ||
rel_file_path = relpathperm(*newrlocator, MAIN_FORKNUM); | ||
key_file_path = psprintf("%s.tde", rel_file_path); | ||
pfree(rel_file_path); | ||
|
||
file = PathNameOpenFile(key_file_path, O_RDWR | O_CREAT | PG_BINARY); | ||
if (file < 0) | ||
{ | ||
ereport(FATAL, | ||
(errcode_for_file_access(), | ||
errmsg("could not open tde key file %s", key_file_path))); | ||
} | ||
/* TODO: | ||
* For now just write a dummy data to the file. We will write the actual | ||
* key later. | ||
*/ | ||
snprintf(enc_key, sizeof(enc_key), "Percona TDE Dummy key for relation:%s", RelationGetRelationName(rel)); | ||
if (FileWrite(file, enc_key, sizeof(enc_key), | ||
0, WAIT_EVENT_DATA_FILE_WRITE) != sizeof(enc_key)) | ||
ereport(FATAL, (errcode_for_file_access(), | ||
errmsg("Could not write key data to file: %s", | ||
key_file_path))); | ||
|
||
/* For now just clode the key file.*/ | ||
pfree(key_file_path); | ||
FileClose(file); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "access/pg_tde_defines.h" | ||
#include "pg_tde_defines.h" | ||
#define ENCRYPTION_DEBUG 1 | ||
|
||
#include "postgres.h" | ||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/*------------------------------------------------------------------------- | ||
* | ||
* pg_tde_tdemap.h | ||
* TDE relation fork manapulation. | ||
* | ||
*------------------------------------------------------------------------- | ||
*/ | ||
#ifndef PG_TDE_MAP_H | ||
#define PG_TDE_MAP_H | ||
|
||
#include "utils/rel.h" | ||
#include "storage/relfilelocator.h" | ||
|
||
extern void pg_tde_create_key_fork(const RelFileLocator *newrlocator, Relation rel); | ||
|
||
#endif /* PG_TDE_MAP_H */ |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/*------------------------------------------------------------------------- | ||
* | ||
* pg_tde.c | ||
* Main file: setup GUCs, shared memory, hooks and other general-purpose | ||
* routines. | ||
* | ||
* IDENTIFICATION | ||
* contrib/pg_tde/src/pg_tde.c | ||
* | ||
*------------------------------------------------------------------------- | ||
*/ | ||
|
||
#include "postgres.h" | ||
#include "funcapi.h" | ||
|
||
PG_MODULE_MAGIC; | ||
void _PG_init(void); | ||
|
||
void | ||
_PG_init(void) | ||
{ | ||
|
||
} |