Skip to content

Commit b8f1675

Browse files
committed
Rename rel_type field for internal keys to type
This type has nothing to do with relations so the rel_ prefix only served to add confusion.
1 parent 1ea23b4 commit b8f1675

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

contrib/pg_tde/src/access/pg_tde_tdemap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ pg_tde_create_smgr_key_perm_redo(const RelFileLocator *newrlocator)
218218
static void
219219
pg_tde_generate_internal_key(InternalKey *int_key, uint32 entry_type)
220220
{
221-
int_key->rel_type = entry_type;
221+
int_key->type = entry_type;
222222
int_key->start_lsn = InvalidXLogRecPtr;
223223

224224
if (!RAND_bytes(int_key->key, INTERNAL_KEY_LEN))
@@ -399,7 +399,7 @@ pg_tde_initialize_map_entry(TDEMapEntry *map_entry, const TDEPrincipalKey *princ
399399
{
400400
map_entry->spcOid = rlocator->spcOid;
401401
map_entry->relNumber = rlocator->relNumber;
402-
map_entry->flags = rel_key_data->rel_type;
402+
map_entry->flags = rel_key_data->type;
403403
map_entry->enc_key = *rel_key_data;
404404

405405
if (!RAND_bytes(map_entry->entry_iv, MAP_ENTRY_EMPTY_IV_SIZE))
@@ -534,7 +534,7 @@ pg_tde_free_key_map_entry(const RelFileLocator *rlocator)
534534
TDEMapEntry empty_map_entry = {
535535
.flags = MAP_ENTRY_EMPTY,
536536
.enc_key = {
537-
.rel_type = MAP_ENTRY_EMPTY,
537+
.type = MAP_ENTRY_EMPTY,
538538
},
539539
};
540540

@@ -1146,7 +1146,7 @@ pg_tde_get_key_from_cache(const RelFileLocator *rlocator, uint32 key_type)
11461146
{
11471147
RelKeyCacheRec *rec = tde_rel_key_cache.data + i;
11481148

1149-
if (RelFileLocatorEquals(rec->locator, *rlocator) && rec->key.rel_type & key_type)
1149+
if (RelFileLocatorEquals(rec->locator, *rlocator) && rec->key.type & key_type)
11501150
{
11511151
return &rec->key;
11521152
}

contrib/pg_tde/src/access/pg_tde_xlog_smgr.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static EncryptionStateData *EncryptionState = NULL;
7373
/* TODO: can be swapped out to the disk */
7474
static InternalKey EncryptionKey =
7575
{
76-
.rel_type = MAP_ENTRY_EMPTY,
76+
.type = MAP_ENTRY_EMPTY,
7777
.start_lsn = InvalidXLogRecPtr,
7878
};
7979
static void *EncryptionCryptCtx = NULL;
@@ -202,7 +202,7 @@ TDEXLogSmgrInit(void)
202202
pg_tde_create_wal_key(&EncryptionKey, &GLOBAL_SPACE_RLOCATOR(XLOG_TDE_OID),
203203
TDE_KEY_TYPE_WAL_ENCRYPTED);
204204
}
205-
else if (key && key->rel_type & TDE_KEY_TYPE_WAL_ENCRYPTED)
205+
else if (key && key->type & TDE_KEY_TYPE_WAL_ENCRYPTED)
206206
{
207207
pg_tde_create_wal_key(&EncryptionKey, &GLOBAL_SPACE_RLOCATOR(XLOG_TDE_OID),
208208
TDE_KEY_TYPE_WAL_UNENCRYPTED);
@@ -233,7 +233,7 @@ tdeheap_xlog_seg_write(int fd, const void *buf, size_t count, off_t offset,
233233
*
234234
* This func called with WALWriteLock held, so no need in any extra sync.
235235
*/
236-
if (EncryptionKey.rel_type & TDE_KEY_TYPE_GLOBAL &&
236+
if (EncryptionKey.type & TDE_KEY_TYPE_GLOBAL &&
237237
pg_atomic_read_u64(&EncryptionState->enc_key_lsn) == 0)
238238
{
239239
XLogRecPtr lsn;
@@ -314,11 +314,11 @@ tdeheap_xlog_seg_read(int fd, void *buf, size_t count, off_t offset,
314314
elog(DEBUG1, "WAL key %X/%X-%X/%X, encrypted: %s",
315315
LSN_FORMAT_ARGS(curr_key->start_lsn),
316316
LSN_FORMAT_ARGS(curr_key->end_lsn),
317-
curr_key->key->rel_type & TDE_KEY_TYPE_WAL_ENCRYPTED ? "yes" : "no");
317+
curr_key->key->type & TDE_KEY_TYPE_WAL_ENCRYPTED ? "yes" : "no");
318318
#endif
319319

320320
if (curr_key->key->start_lsn != InvalidXLogRecPtr &&
321-
(curr_key->key->rel_type & TDE_KEY_TYPE_WAL_ENCRYPTED))
321+
(curr_key->key->type & TDE_KEY_TYPE_WAL_ENCRYPTED))
322322
{
323323
/*
324324
* Check if the key's range overlaps with the buffer's and decypt

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ typedef struct InternalKey
2727
{
2828
uint8 key[INTERNAL_KEY_LEN];
2929
uint8 base_iv[INTERNAL_KEY_IV_LEN];
30-
uint32 rel_type;
30+
uint32 type;
3131

3232
XLogRecPtr start_lsn;
3333
} InternalKey;
3434

3535
#define WALKeySetInvalid(key) \
36-
((key)->rel_type &= ~(TDE_KEY_TYPE_WAL_ENCRYPTED | TDE_KEY_TYPE_WAL_UNENCRYPTED))
36+
((key)->type &= ~(TDE_KEY_TYPE_WAL_ENCRYPTED | TDE_KEY_TYPE_WAL_UNENCRYPTED))
3737
#define WALKeyIsValid(key) \
38-
(((key)->rel_type & TDE_KEY_TYPE_WAL_UNENCRYPTED) != 0 || \
39-
((key)->rel_type & TDE_KEY_TYPE_WAL_ENCRYPTED) != 0)
38+
(((key)->type & TDE_KEY_TYPE_WAL_UNENCRYPTED) != 0 || \
39+
((key)->type & TDE_KEY_TYPE_WAL_ENCRYPTED) != 0)
4040

4141
#define MAP_ENTRY_EMPTY_IV_SIZE 16
4242
#define MAP_ENTRY_EMPTY_AEAD_TAG_SIZE 16

0 commit comments

Comments
 (0)