Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5fd8d16

Browse files
committed
Remove optimization for catalog tables
Since we rely on the SMGR relation cache for fast key lookup when opening a SMGR relation and that the catalog should be open basically all the time this optimization adds little value and only complicates the code.
1 parent 8f522b2 commit 5fd8d16

File tree

1 file changed

+5
-25
lines changed

1 file changed

+5
-25
lines changed

contrib/pg_tde/src/smgr/pg_tde_smgr.c

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,6 @@ typedef struct TDESMgrRelation
4545

4646
static void CalcBlockIv(ForkNumber forknum, BlockNumber bn, const unsigned char *base_iv, unsigned char *iv);
4747

48-
static bool
49-
tde_smgr_is_encrypted(const RelFileLocatorBackend *smgr_rlocator)
50-
{
51-
/* Do not try to encrypt/decrypt catalog tables */
52-
if (IsCatalogRelationOid(smgr_rlocator->locator.relNumber))
53-
return false;
54-
55-
return IsSMGRRelationEncrypted(*smgr_rlocator);
56-
}
57-
58-
static InternalKey *
59-
tde_smgr_get_key(const RelFileLocatorBackend *smgr_rlocator)
60-
{
61-
/* Do not try to encrypt/decrypt catalog tables */
62-
if (IsCatalogRelationOid(smgr_rlocator->locator.relNumber))
63-
return NULL;
64-
65-
return GetSMGRRelationKey(*smgr_rlocator);
66-
}
67-
6848
static bool
6949
tde_smgr_should_encrypt(const RelFileLocatorBackend *smgr_rlocator, RelFileLocator *old_locator)
7050
{
@@ -110,7 +90,7 @@ tde_mdwritev(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
11090

11191
if (tdereln->encryption_status == RELATION_KEY_NOT_AVAILABLE)
11292
{
113-
InternalKey *int_key = tde_smgr_get_key(&reln->smgr_rlocator);
93+
InternalKey *int_key = GetSMGRRelationKey(reln->smgr_rlocator);
11494

11595
tdereln->relKey = *int_key;
11696
tdereln->encryption_status = RELATION_KEY_AVAILABLE;
@@ -181,7 +161,7 @@ tde_mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
181161

182162
if (tdereln->encryption_status == RELATION_KEY_NOT_AVAILABLE)
183163
{
184-
InternalKey *int_key = tde_smgr_get_key(&reln->smgr_rlocator);
164+
InternalKey *int_key = GetSMGRRelationKey(reln->smgr_rlocator);
185165

186166
tdereln->relKey = *int_key;
187167
tdereln->encryption_status = RELATION_KEY_AVAILABLE;
@@ -210,7 +190,7 @@ tde_mdreadv(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
210190
return;
211191
else if (tdereln->encryption_status == RELATION_KEY_NOT_AVAILABLE)
212192
{
213-
InternalKey *int_key = tde_smgr_get_key(&reln->smgr_rlocator);
193+
InternalKey *int_key = GetSMGRRelationKey(reln->smgr_rlocator);
214194

215195
tdereln->relKey = *int_key;
216196
tdereln->encryption_status = RELATION_KEY_AVAILABLE;
@@ -279,7 +259,7 @@ tde_mdcreate(RelFileLocator relold, SMgrRelation reln, ForkNumber forknum, bool
279259
* Since event triggers do not fire on the standby or in recovery we
280260
* do not try to generate any new keys and instead trust the xlog.
281261
*/
282-
InternalKey *key = tde_smgr_get_key(&reln->smgr_rlocator);
262+
InternalKey *key = GetSMGRRelationKey(reln->smgr_rlocator);
283263

284264
if (!isRedo && !key && tde_smgr_should_encrypt(&reln->smgr_rlocator, &relold))
285265
key = pg_tde_create_smgr_key(&reln->smgr_rlocator);
@@ -311,7 +291,7 @@ tde_mdopen(SMgrRelation reln)
311291

312292
mdopen(reln);
313293

314-
if (tde_smgr_is_encrypted(&reln->smgr_rlocator))
294+
if (IsSMGRRelationEncrypted(reln->smgr_rlocator))
315295
{
316296
tdereln->encryption_status = RELATION_KEY_NOT_AVAILABLE;
317297
}

0 commit comments

Comments
 (0)