Skip to content

Commit 13b191a

Browse files
committed
Consistently use create/delete for keys
We used a mix of create, add, delete and remove. We still use free and save in pg_tde_tdemap.c but that is soemthing we can fix later.
1 parent a392dbc commit 13b191a

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

contrib/pg_tde/src/access/pg_tde_tdemap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ pg_tde_save_principal_key(const TDEPrincipalKey *principal_key, bool write_xlog)
195195
{
196196
XLogBeginInsert();
197197
XLogRegisterData((char *) &signed_key_Info, sizeof(TDESignedPrincipalKeyInfo));
198-
XLogInsert(RM_TDERMGR_ID, XLOG_TDE_ADD_PRINCIPAL_KEY);
198+
XLogInsert(RM_TDERMGR_ID, XLOG_TDE_CREATE_PRINCIPAL_KEY);
199199
}
200200

201201
map_fd = pg_tde_open_file_write(db_map_path, &signed_key_Info, true, &curr_pos);

contrib/pg_tde/src/access/pg_tde_xlog.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ tdeheap_rmgr_redo(XLogReaderState *record)
4343
{
4444
uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
4545

46-
if (info == XLOG_TDE_ADD_RELATION_KEY)
46+
if (info == XLOG_TDE_CREATE_RELATION_KEY)
4747
{
4848
XLogRelKey *xlrec = (XLogRelKey *) XLogRecGetData(record);
4949

5050
tde_smgr_create_key_redo(&xlrec->rlocator);
5151
}
52-
else if (info == XLOG_TDE_ADD_PRINCIPAL_KEY)
52+
else if (info == XLOG_TDE_CREATE_PRINCIPAL_KEY)
5353
{
5454
TDESignedPrincipalKeyInfo *mkey = (TDESignedPrincipalKeyInfo *) XLogRecGetData(record);
5555

@@ -62,7 +62,7 @@ tdeheap_rmgr_redo(XLogReaderState *record)
6262
{
6363
XLogRelKey *xlrec = (XLogRelKey *) XLogRecGetData(record);
6464

65-
tde_smgr_remove_leftover_key_redo(&xlrec->rlocator);
65+
tde_smgr_delete_leftover_key_redo(&xlrec->rlocator);
6666
}
6767
else if (info == XLOG_TDE_ROTATE_PRINCIPAL_KEY)
6868
{
@@ -99,13 +99,13 @@ tdeheap_rmgr_desc(StringInfo buf, XLogReaderState *record)
9999
{
100100
uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
101101

102-
if (info == XLOG_TDE_ADD_RELATION_KEY)
102+
if (info == XLOG_TDE_CREATE_RELATION_KEY)
103103
{
104104
XLogRelKey *xlrec = (XLogRelKey *) XLogRecGetData(record);
105105

106106
appendStringInfo(buf, "rel: %u/%u/%u", xlrec->rlocator.spcOid, xlrec->rlocator.dbOid, xlrec->rlocator.relNumber);
107107
}
108-
else if (info == XLOG_TDE_ADD_PRINCIPAL_KEY)
108+
else if (info == XLOG_TDE_CREATE_PRINCIPAL_KEY)
109109
{
110110
TDEPrincipalKeyInfo *xlrec = (TDEPrincipalKeyInfo *) XLogRecGetData(record);
111111

@@ -148,10 +148,10 @@ tdeheap_rmgr_identify(uint8 info)
148148
{
149149
switch (info & ~XLR_INFO_MASK)
150150
{
151-
case XLOG_TDE_ADD_RELATION_KEY:
152-
return "ADD_RELATION_KEY";
153-
case XLOG_TDE_ADD_PRINCIPAL_KEY:
154-
return "ADD_PRINCIPAL_KEY";
151+
case XLOG_TDE_CREATE_RELATION_KEY:
152+
return "CREATE_RELATION_KEY";
153+
case XLOG_TDE_CREATE_PRINCIPAL_KEY:
154+
return "CREATE_PRINCIPAL_KEY";
155155
case XLOG_TDE_ROTATE_PRINCIPAL_KEY:
156156
return "ROTATE_PRINCIPAL_KEY";
157157
case XLOG_TDE_DELETE_RELATION_KEY:

contrib/pg_tde/src/access/pg_tde_xlog_keys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ pg_tde_save_server_key(const TDEPrincipalKey *principal_key, bool write_xlog)
743743
{
744744
XLogBeginInsert();
745745
XLogRegisterData((char *) &signed_key_Info, sizeof(TDESignedPrincipalKeyInfo));
746-
XLogInsert(RM_TDERMGR_ID, XLOG_TDE_ADD_PRINCIPAL_KEY);
746+
XLogInsert(RM_TDERMGR_ID, XLOG_TDE_CREATE_PRINCIPAL_KEY);
747747
}
748748

749749
fd = pg_tde_open_wal_key_file_write(get_wal_key_file_path(), &signed_key_Info, true, &curr_pos);

contrib/pg_tde/src/include/access/pg_tde_xlog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#ifndef FRONTEND
99

1010
/* TDE XLOG record types */
11-
#define XLOG_TDE_ADD_RELATION_KEY 0x00
12-
#define XLOG_TDE_ADD_PRINCIPAL_KEY 0x10
11+
#define XLOG_TDE_CREATE_RELATION_KEY 0x00
12+
#define XLOG_TDE_CREATE_PRINCIPAL_KEY 0x10
1313
#define XLOG_TDE_ROTATE_PRINCIPAL_KEY 0x20
1414
#define XLOG_TDE_WRITE_KEY_PROVIDER 0x30
1515
#define XLOG_TDE_INSTALL_EXTENSION 0x40

contrib/pg_tde/src/include/smgr/pg_tde_smgr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
extern void RegisterStorageMgr(void);
88
extern void tde_smgr_create_key_redo(const RelFileLocator *rlocator);
9-
extern void tde_smgr_remove_leftover_key_redo(const RelFileLocator *rlocator);
9+
extern void tde_smgr_delete_leftover_key_redo(const RelFileLocator *rlocator);
1010
extern bool tde_smgr_rel_is_encrypted(SMgrRelation reln);
1111

1212
#endif /* PG_TDE_SMGR_H */

contrib/pg_tde/src/smgr/pg_tde_smgr.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static SMgrId OurSMgrId = MaxSMgrId;
6767
static void tde_smgr_save_temp_key(const RelFileLocator *newrlocator, const InternalKey *key);
6868
static InternalKey *tde_smgr_get_temp_key(const RelFileLocator *rel);
6969
static bool tde_smgr_has_temp_key(const RelFileLocator *rel);
70-
static void tde_smgr_remove_temp_key(const RelFileLocator *rel);
70+
static void tde_smgr_delete_temp_key(const RelFileLocator *rel);
7171
static void CalcBlockIv(ForkNumber forknum, BlockNumber bn, const unsigned char *base_iv, unsigned char *iv);
7272

7373
static void
@@ -77,11 +77,11 @@ tde_smgr_log_create_key(const RelFileLocator *rlocator)
7777

7878
XLogBeginInsert();
7979
XLogRegisterData((char *) &xlrec, sizeof(xlrec));
80-
XLogInsert(RM_TDERMGR_ID, XLOG_TDE_ADD_RELATION_KEY);
80+
XLogInsert(RM_TDERMGR_ID, XLOG_TDE_CREATE_RELATION_KEY);
8181
}
8282

8383
static void
84-
tde_smgr_log_remove_leftover_key(const RelFileLocator *rlocator)
84+
tde_smgr_log_delete_leftover_key(const RelFileLocator *rlocator)
8585
{
8686
XLogRelKey xlrec = {.rlocator = *rlocator};
8787

@@ -122,26 +122,26 @@ tde_smgr_create_key_redo(const RelFileLocator *rlocator)
122122
}
123123

124124
static void
125-
tde_smgr_remove_key(const RelFileLocatorBackend *smgr_rlocator)
125+
tde_smgr_delete_key(const RelFileLocatorBackend *smgr_rlocator)
126126
{
127127
if (RelFileLocatorBackendIsTemp(*smgr_rlocator))
128-
tde_smgr_remove_temp_key(&smgr_rlocator->locator);
128+
tde_smgr_delete_temp_key(&smgr_rlocator->locator);
129129
else
130130
pg_tde_free_key_map_entry(smgr_rlocator->locator);
131131
}
132132

133133
static void
134-
tde_smgr_remove_leftover_key(const RelFileLocatorBackend *smgr_rlocator)
134+
tde_smgr_delete_leftover_key(const RelFileLocatorBackend *smgr_rlocator)
135135
{
136136
if (!RelFileLocatorBackendIsTemp(*smgr_rlocator))
137137
{
138138
pg_tde_free_key_map_entry(smgr_rlocator->locator);
139-
tde_smgr_log_remove_leftover_key(&smgr_rlocator->locator);
139+
tde_smgr_log_delete_leftover_key(&smgr_rlocator->locator);
140140
}
141141
}
142142

143143
void
144-
tde_smgr_remove_leftover_key_redo(const RelFileLocator *rlocator)
144+
tde_smgr_delete_leftover_key_redo(const RelFileLocator *rlocator)
145145
{
146146
pg_tde_free_key_map_entry(*rlocator);
147147
}
@@ -271,7 +271,7 @@ tde_mdunlink(RelFileLocatorBackend rlocator, ForkNumber forknum, bool isRedo)
271271
if (forknum == MAIN_FORKNUM || forknum == InvalidForkNumber)
272272
{
273273
if (tde_smgr_is_encrypted(&rlocator))
274-
tde_smgr_remove_key(&rlocator);
274+
tde_smgr_delete_key(&rlocator);
275275
}
276276
}
277277

@@ -391,7 +391,7 @@ tde_mdcreate(RelFileLocator relold, SMgrRelation reln, ForkNumber forknum, bool
391391
* If we're in redo, a separate WAL record will make sure the key is
392392
* removed.
393393
*/
394-
tde_smgr_remove_leftover_key(&reln->smgr_rlocator);
394+
tde_smgr_delete_leftover_key(&reln->smgr_rlocator);
395395

396396
if (!tde_smgr_should_encrypt(&reln->smgr_rlocator, &relold))
397397
{
@@ -514,7 +514,7 @@ tde_smgr_has_temp_key(const RelFileLocator *rel)
514514
}
515515

516516
static void
517-
tde_smgr_remove_temp_key(const RelFileLocator *rel)
517+
tde_smgr_delete_temp_key(const RelFileLocator *rel)
518518
{
519519
Assert(TempRelKeys);
520520
hash_search(TempRelKeys, rel, HASH_REMOVE, NULL);

0 commit comments

Comments
 (0)