Skip to content

Commit

Permalink
Get rid of now obsolete interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
dAdAbird committed Jul 16, 2024
1 parent be3c77f commit f68aae3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 28 deletions.
14 changes: 4 additions & 10 deletions src/access/pg_tde_tdemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pg_tde_create_key_map_entry(const RelFileLocator *newrlocator)
TDEPrincipalKey *principal_key;
XLogRelKey xlrec;

principal_key = GetPrincipalKey(newrlocator->dbOid, newrlocator->spcOid, NULL);
principal_key = GetPrincipalKey(newrlocator->dbOid, newrlocator->spcOid);
if (principal_key == NULL)
{
ereport(ERROR,
Expand Down Expand Up @@ -163,12 +163,6 @@ RelKey *tde_rel_key_map = NULL;
*/
RelKeyData *
GetRelationKey(RelFileLocator rel)
{
return GetRelationKeyWithKeyring(rel, NULL);
}

RelKeyData *
GetRelationKeyWithKeyring(RelFileLocator rel, GenericKeyring *keyring)
{
RelKey *curr;
RelKeyData *key;
Expand All @@ -182,7 +176,7 @@ GetRelationKeyWithKeyring(RelFileLocator rel, GenericKeyring *keyring)
}
}

key = pg_tde_get_key_from_file(&rel, keyring);
key = pg_tde_get_key_from_file(&rel);

if (key != NULL)
{
Expand Down Expand Up @@ -996,7 +990,7 @@ pg_tde_free_key_map_entry(const RelFileLocator *rlocator, off_t offset)
* reads the key data from the keydata file.
*/
RelKeyData *
pg_tde_get_key_from_file(const RelFileLocator *rlocator, GenericKeyring *keyring)
pg_tde_get_key_from_file(const RelFileLocator *rlocator)
{
int32 key_index = 0;
TDEPrincipalKey *principal_key;
Expand All @@ -1012,7 +1006,7 @@ pg_tde_get_key_from_file(const RelFileLocator *rlocator, GenericKeyring *keyring
LWLockAcquire(lock_files, LW_SHARED);

/* Get/generate a principal key, create the key for relation and get the encrypted key with bytes to write */
principal_key = GetPrincipalKey(rlocator->dbOid, rlocator->spcOid, keyring);
principal_key = GetPrincipalKey(rlocator->dbOid, rlocator->spcOid);
if (principal_key == NULL)
{
LWLockRelease(lock_files);
Expand Down
3 changes: 1 addition & 2 deletions src/catalog/tde_global_catalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ TDEGlCatKeyInit(void)
{
RelKeyData *ikey;

ikey = pg_tde_get_key_from_file(&GLOBAL_SPACE_RLOCATOR(XLOG_TDE_OID),
NULL);
ikey = pg_tde_get_key_from_file(&GLOBAL_SPACE_RLOCATOR(XLOG_TDE_OID));
cache_internal_key(ikey, TDE_INTERNAL_XLOG_KEY);
}
}
Expand Down
22 changes: 10 additions & 12 deletions src/catalog/tde_principal_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ save_principal_key_info(TDEPrincipalKeyInfo *principal_key_info)
* throws an error.
*/
TDEPrincipalKey *
GetPrincipalKey(Oid dbOid, Oid spcOid, GenericKeyring *keyring)
GetPrincipalKey(Oid dbOid, Oid spcOid)
{
GenericKeyring *keyring;
TDEPrincipalKey *principalKey = NULL;
TDEPrincipalKeyInfo *principalKeyInfo = NULL;
const keyInfo *keyInfo = NULL;
Expand Down Expand Up @@ -276,17 +277,14 @@ GetPrincipalKey(Oid dbOid, Oid spcOid, GenericKeyring *keyring)
return NULL;
}

keyring = GetKeyProviderByID(principalKeyInfo->keyringId, dbOid, spcOid);
if (keyring == NULL)
{
keyring = GetKeyProviderByID(principalKeyInfo->keyringId, dbOid, spcOid);
if (keyring == NULL)
{
LWLockRelease(lock_cache);
LWLockRelease(lock_files);
LWLockRelease(lock_cache);
LWLockRelease(lock_files);

recursion--;
return NULL;
}
recursion--;
return NULL;
}

keyInfo = KeyringGetKey(keyring, principalKeyInfo->keyId.versioned_name, false, &keyring_ret);
Expand Down Expand Up @@ -743,7 +741,7 @@ pg_tde_rotate_database_key(PG_FUNCTION_ARGS)


ereport(LOG, (errmsg("Rotating principal key to [%s : %s] for the database", new_principal_key_name, new_provider_name)));
current_key = GetPrincipalKey(MyDatabaseId, MyDatabaseTableSpace, NULL);
current_key = GetPrincipalKey(MyDatabaseId, MyDatabaseTableSpace);
ret = RotatePrincipalKey(current_key, new_principal_key_name, new_provider_name, ensure_new_key);
PG_RETURN_BOOL(ret);
}
Expand All @@ -767,7 +765,7 @@ pg_tde_rotate_global_key(PG_FUNCTION_ARGS)


ereport(LOG, (errmsg("Rotating principal key to [%s : %s] for the database", new_principal_key_name, new_provider_name)));
current_key = GetPrincipalKey(GLOBAL_DATA_TDE_OID, GLOBALTABLESPACE_OID, NULL);
current_key = GetPrincipalKey(GLOBAL_DATA_TDE_OID, GLOBALTABLESPACE_OID);
ret = RotatePrincipalKey(current_key, new_principal_key_name, new_provider_name, ensure_new_key);
PG_RETURN_BOOL(ret);
}
Expand Down Expand Up @@ -820,7 +818,7 @@ pg_tde_get_key_info(PG_FUNCTION_ARGS, Oid dbOid, Oid spcOid)
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("function returning record called in context that cannot accept type record")));

principal_key = GetPrincipalKey(dbOid, spcOid, NULL);
principal_key = GetPrincipalKey(dbOid, spcOid);
if (principal_key == NULL)
{
ereport(ERROR,
Expand Down
3 changes: 1 addition & 2 deletions src/include/access/pg_tde_tdemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ extern void pg_tde_delete_key_map_entry(const RelFileLocator *rlocator);
extern void pg_tde_free_key_map_entry(const RelFileLocator *rlocator, off_t offset);

extern RelKeyData *GetRelationKey(RelFileLocator rel);
extern RelKeyData *GetRelationKeyWithKeyring(RelFileLocator rel, GenericKeyring *keyring);

extern void pg_tde_delete_tde_files(Oid dbOid, Oid spcOid);

Expand All @@ -64,7 +63,7 @@ extern bool pg_tde_write_map_keydata_files(off_t map_size, char *m_file_data, of
extern RelKeyData* tde_create_rel_key(Oid rel_id, InternalKey *key, TDEPrincipalKeyInfo *principal_key_info);
extern RelKeyData *tde_encrypt_rel_key(TDEPrincipalKey *principal_key, RelKeyData *rel_key_data, const RelFileLocator *rlocator);
extern RelKeyData *tde_decrypt_rel_key(TDEPrincipalKey *principal_key, RelKeyData *enc_rel_key_data, const RelFileLocator *rlocator);
extern RelKeyData *pg_tde_get_key_from_file(const RelFileLocator *rlocator, GenericKeyring *keyring);
extern RelKeyData *pg_tde_get_key_from_file(const RelFileLocator *rlocator);

extern void pg_tde_set_db_file_paths(const RelFileLocator *rlocator, char *map_path, char *keydata_path);

Expand Down
2 changes: 1 addition & 1 deletion src/include/catalog/tde_principal_key.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ extern LWLock *tde_lwlock_mk_cache(void);
extern bool save_principal_key_info(TDEPrincipalKeyInfo *principalKeyInfo);

extern Oid GetPrincipalKeyProviderId(void);
extern TDEPrincipalKey* GetPrincipalKey(Oid dbOid, Oid spcOid, GenericKeyring *keyring);
extern TDEPrincipalKey* GetPrincipalKey(Oid dbOid, Oid spcOid);
extern bool SetPrincipalKey(const char *key_name, const char *provider_name, bool ensure_new_key);
extern bool RotatePrincipalKey(TDEPrincipalKey *current_key, const char *new_key_name, const char *new_provider_name, bool ensure_new_key);
extern bool xl_tde_perform_rotate_key(XLogPrincipalKeyRotate *xlrec);
Expand Down
2 changes: 1 addition & 1 deletion src/smgr/pg_tde_smgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ tde_smgr_get_key(SMgrRelation reln)
recursion++;


if(GetPrincipalKey(reln->smgr_rlocator.locator.relNumber, reln->smgr_rlocator.locator.spcOid, NULL)==NULL)
if(GetPrincipalKey(reln->smgr_rlocator.locator.relNumber, reln->smgr_rlocator.locator.spcOid)==NULL)
{
recursion--;
return NULL;
Expand Down

0 comments on commit f68aae3

Please sign in to comment.