Skip to content

Commit 64b432a

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 630441e commit 64b432a

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

contrib/pg_tde/src/access/pg_tde_xlog.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ 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

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

65-
tde_smgr_delete_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,7 +99,7 @@ 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

@@ -148,8 +148,8 @@ 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";
151+
case XLOG_TDE_CREATE_RELATION_KEY:
152+
return "CREATE_RELATION_KEY";
153153
case XLOG_TDE_ADD_PRINCIPAL_KEY:
154154
return "ADD_PRINCIPAL_KEY";
155155
case XLOG_TDE_ROTATE_PRINCIPAL_KEY:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#ifndef FRONTEND
99

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

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_delete_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_delete_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_delete_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_delete_key(&smgr_rlocator->locator);
139+
tde_smgr_log_delete_leftover_key(&smgr_rlocator->locator);
140140
}
141141
}
142142

143143
void
144-
tde_smgr_delete_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_delete_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)