Rename helper function

This function counts the number of encryption keys in the key file
associated with the given OID. Name it accordingly.

Also remove comment about only user which is no longer true.
pull/238/head
Anders Åstrand 2 months ago committed by AndersAstrand
parent 3cb397447e
commit 11dcde6722
  1. 12
      contrib/pg_tde/src/access/pg_tde_tdemap.c
  2. 4
      contrib/pg_tde/src/catalog/tde_principal_key.c
  3. 2
      contrib/pg_tde/src/include/access/pg_tde_tdemap.h
  4. 2
      contrib/pg_tde/src/pg_tde_event_capture.c

@ -529,7 +529,7 @@ pg_tde_delete_principal_key(Oid dbOid)
char path[MAXPGPATH]; char path[MAXPGPATH];
Assert(LWLockHeldByMeInMode(tde_lwlock_enc_keys(), LW_EXCLUSIVE)); Assert(LWLockHeldByMeInMode(tde_lwlock_enc_keys(), LW_EXCLUSIVE));
Assert(pg_tde_count_relations(dbOid) == 0); Assert(pg_tde_count_encryption_keys(dbOid) == 0);
pg_tde_set_db_file_path(dbOid, path); pg_tde_set_db_file_path(dbOid, path);
@ -672,17 +672,15 @@ pg_tde_find_map_entry(const RelFileLocator *rlocator, TDEMapEntryType key_type,
} }
/* /*
* Counts number of encrypted objects in a database. * Counts number of encryption keys in a key file.
* *
* Does not check if objects actually exist but just that they have keys in * Does not check if objects actually exist but just that they have keys in
* the map file. For the only current caller, checking if we can use * the key file.
* FILE_COPY, this is good enough but for other workloads where a false
* positive is more harmful this might not be.
* *
* Works even if the database has no map file. * Works even if the database has no key file.
*/ */
int int
pg_tde_count_relations(Oid dbOid) pg_tde_count_encryption_keys(Oid dbOid)
{ {
char db_map_path[MAXPGPATH]; char db_map_path[MAXPGPATH];
File map_fd; File map_fd;

@ -700,7 +700,7 @@ pg_tde_delete_key(PG_FUNCTION_ARGS)
* If database has something encryted, we can try to fallback to the * If database has something encryted, we can try to fallback to the
* default principal key * default principal key
*/ */
if (pg_tde_count_relations(MyDatabaseId) != 0) if (pg_tde_count_encryption_keys(MyDatabaseId) != 0)
{ {
default_principal_key = GetPrincipalKeyNoDefault(DEFAULT_DATA_TDE_OID, LW_EXCLUSIVE); default_principal_key = GetPrincipalKeyNoDefault(DEFAULT_DATA_TDE_OID, LW_EXCLUSIVE);
if (default_principal_key == NULL) if (default_principal_key == NULL)
@ -785,7 +785,7 @@ pg_tde_delete_default_key(PG_FUNCTION_ARGS)
* delete default principal key if there are encrypted tables in * delete default principal key if there are encrypted tables in
* the database. * the database.
*/ */
if (pg_tde_count_relations(dbOid) != 0) if (pg_tde_count_encryption_keys(dbOid) != 0)
{ {
ereport(ERROR, ereport(ERROR,
errmsg("cannot delete default principal key"), errmsg("cannot delete default principal key"),

@ -92,7 +92,7 @@ extern bool pg_tde_has_smgr_key(RelFileLocator rel);
extern InternalKey *pg_tde_get_smgr_key(RelFileLocator rel); extern InternalKey *pg_tde_get_smgr_key(RelFileLocator rel);
extern void pg_tde_free_key_map_entry(RelFileLocator rel); extern void pg_tde_free_key_map_entry(RelFileLocator rel);
extern int pg_tde_count_relations(Oid dbOid); extern int pg_tde_count_encryption_keys(Oid dbOid);
extern void pg_tde_delete_tde_files(Oid dbOid); extern void pg_tde_delete_tde_files(Oid dbOid);

@ -643,7 +643,7 @@ pg_tde_proccess_utility(PlannedStmt *pstmt,
int count; int count;
LWLockAcquire(tde_lwlock_enc_keys(), LW_SHARED); LWLockAcquire(tde_lwlock_enc_keys(), LW_SHARED);
count = pg_tde_count_relations(dbOid); count = pg_tde_count_encryption_keys(dbOid);
LWLockRelease(tde_lwlock_enc_keys()); LWLockRelease(tde_lwlock_enc_keys());
if (count > 0) if (count > 0)

Loading…
Cancel
Save