From f325962908b885181b08a10463482b1f8c1b66e2 Mon Sep 17 00:00:00 2001 From: Andreas Karlsson Date: Tue, 10 Jun 2025 13:18:47 +0200 Subject: [PATCH 1/4] Use strcmp() instead of strncmp() Since we know that both strings are zero termianted there is no reason to use strncmp(). --- contrib/pg_tde/src/catalog/tde_principal_key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/pg_tde/src/catalog/tde_principal_key.c b/contrib/pg_tde/src/catalog/tde_principal_key.c index e115bfb7b4097..b0ff19c0ed2c2 100644 --- a/contrib/pg_tde/src/catalog/tde_principal_key.c +++ b/contrib/pg_tde/src/catalog/tde_principal_key.c @@ -1007,7 +1007,7 @@ pg_tde_verify_provider_keys_in_use(GenericKeyring *modified_provider) static bool pg_tde_is_same_principal_key(TDEPrincipalKey *a, TDEPrincipalKey *b) { - return a != NULL && b != NULL && strncmp(a->keyInfo.name, b->keyInfo.name, PRINCIPAL_KEY_NAME_LEN) == 0 && a->keyInfo.keyringId == b->keyInfo.keyringId; + return a != NULL && b != NULL && strcmp(a->keyInfo.name, b->keyInfo.name) == 0 && a->keyInfo.keyringId == b->keyInfo.keyringId; } static void From 25a8b9a3e4b0a8cc92d0eb6b3c9be9ff5d554a47 Mon Sep 17 00:00:00 2001 From: Andreas Karlsson Date: Tue, 10 Jun 2025 13:19:01 +0200 Subject: [PATCH 2/4] Fix argument name in header file to match that of implementation I forgot to update the name of the argument in the header file. --- contrib/pg_tde/src/include/access/pg_tde_tdemap.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/contrib/pg_tde/src/include/access/pg_tde_tdemap.h b/contrib/pg_tde/src/include/access/pg_tde_tdemap.h index dcf834c995fb3..eed5b7bc569d0 100644 --- a/contrib/pg_tde/src/include/access/pg_tde_tdemap.h +++ b/contrib/pg_tde/src/include/access/pg_tde_tdemap.h @@ -77,13 +77,11 @@ typedef struct WALKeyCacheRec } WALKeyCacheRec; extern InternalKey *pg_tde_read_last_wal_key(void); - extern WALKeyCacheRec *pg_tde_get_last_wal_key(void); extern WALKeyCacheRec *pg_tde_fetch_wal_keys(XLogRecPtr start_lsn); extern WALKeyCacheRec *pg_tde_get_wal_cache_keys(void); extern void pg_tde_wal_last_key_set_lsn(XLogRecPtr lsn, const char *keyfile_path); - -extern void pg_tde_create_wal_key(InternalKey *rel_key_data, const RelFileLocator *newrlocator, TDEMapEntryType flags); +extern void pg_tde_create_wal_key(InternalKey *rel_key_data, const RelFileLocator *newrlocator, TDEMapEntryType entry_type); #define PG_TDE_MAP_FILENAME "%d_keys" From 0998b17c52edd1249da2fd14f35b57b729356db0 Mon Sep 17 00:00:00 2001 From: Andreas Karlsson Date: Tue, 10 Jun 2025 13:19:15 +0200 Subject: [PATCH 3/4] Remove pointless comment The comment just says the same thing as the function name. --- contrib/pg_tde/src/catalog/tde_principal_key.c | 1 - 1 file changed, 1 deletion(-) diff --git a/contrib/pg_tde/src/catalog/tde_principal_key.c b/contrib/pg_tde/src/catalog/tde_principal_key.c index b0ff19c0ed2c2..2ccaff88a4347 100644 --- a/contrib/pg_tde/src/catalog/tde_principal_key.c +++ b/contrib/pg_tde/src/catalog/tde_principal_key.c @@ -1018,7 +1018,6 @@ pg_tde_rotate_default_key_for_database(TDEPrincipalKey *oldKey, TDEPrincipalKey *newKey = *newKeyTemplate; newKey->keyInfo.databaseId = oldKey->keyInfo.databaseId; - /* key rotation */ pg_tde_perform_rotate_key(oldKey, newKey, true); clear_principal_key_cache(oldKey->keyInfo.databaseId); From 5909b207d4872e270bf88ff3ac2baa383eac6e46 Mon Sep 17 00:00:00 2001 From: Andreas Karlsson Date: Tue, 10 Jun 2025 13:19:24 +0200 Subject: [PATCH 4/4] Fix code formatting issue --- contrib/pg_tde/src/keyring/keyring_curl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/pg_tde/src/keyring/keyring_curl.c b/contrib/pg_tde/src/keyring/keyring_curl.c index 5c2a58e76c686..2a4abb601e532 100644 --- a/contrib/pg_tde/src/keyring/keyring_curl.c +++ b/contrib/pg_tde/src/keyring/keyring_curl.c @@ -16,8 +16,7 @@ CURL *keyringCurl = NULL; -static -size_t +static size_t write_func(void *ptr, size_t size, size_t nmemb, struct CurlString *s) { size_t new_len = s->len + size * nmemb;