Skip to content

Commit 3d90419

Browse files
committed
Constify some function arguments
Some of the functions which take a principal key should take a const pointer.
1 parent 1d12fe4 commit 3d90419

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

contrib/pg_tde/src/access/pg_tde_tdemap.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ typedef struct TDEMapEntry
8585

8686
static void pg_tde_set_db_file_path(Oid dbOid, char *path);
8787
static bool pg_tde_find_map_entry(const RelFileLocator *rlocator, char *db_map_path, TDEMapEntry *map_entry);
88-
static InternalKey *tde_decrypt_rel_key(TDEPrincipalKey *principal_key, TDEMapEntry *map_entry);
88+
static InternalKey *tde_decrypt_rel_key(const TDEPrincipalKey *principal_key, TDEMapEntry *map_entry);
8989
static int pg_tde_open_file_basic(const char *tde_filename, int fileFlags, bool ignore_missing);
9090
static int pg_tde_open_file_read(const char *tde_filename, bool ignore_missing, off_t *curr_pos);
9191
static void pg_tde_file_header_read(const char *tde_filename, int fd, TDEFileHeader *fheader, off_t *bytes_read);
@@ -96,7 +96,7 @@ static void pg_tde_write_one_map_entry(int fd, const TDEMapEntry *map_entry, off
9696
static int pg_tde_file_header_write(const char *tde_filename, int fd, const TDESignedPrincipalKeyInfo *signed_key_info, off_t *bytes_written);
9797
static void pg_tde_initialize_map_entry(TDEMapEntry *map_entry, const TDEPrincipalKey *principal_key, const RelFileLocator *rlocator, const InternalKey *rel_key_data);
9898
static int pg_tde_open_file_write(const char *tde_filename, const TDESignedPrincipalKeyInfo *signed_key_info, bool truncate, off_t *curr_pos);
99-
static void pg_tde_write_key_map_entry(const RelFileLocator *rlocator, const InternalKey *rel_key_data, TDEPrincipalKey *principal_key);
99+
static void pg_tde_write_key_map_entry(const RelFileLocator *rlocator, const InternalKey *rel_key_data, const TDEPrincipalKey *principal_key);
100100

101101
void
102102
pg_tde_save_smgr_key(RelFileLocator rel, const InternalKey *rel_key_data)
@@ -243,7 +243,7 @@ pg_tde_free_key_map_entry(const RelFileLocator rlocator)
243243
* Rotate keys and generates the WAL record for it.
244244
*/
245245
void
246-
pg_tde_perform_rotate_key(TDEPrincipalKey *principal_key, TDEPrincipalKey *new_principal_key, bool write_xlog)
246+
pg_tde_perform_rotate_key(const TDEPrincipalKey *principal_key, const TDEPrincipalKey *new_principal_key, bool write_xlog)
247247
{
248248
TDESignedPrincipalKeyInfo new_signed_key_info;
249249
off_t old_curr_pos,
@@ -451,7 +451,7 @@ pg_tde_write_one_map_entry(int fd, const TDEMapEntry *map_entry, off_t *offset,
451451
* concurrent in place updates leading to data conflicts.
452452
*/
453453
void
454-
pg_tde_write_key_map_entry(const RelFileLocator *rlocator, const InternalKey *rel_key_data, TDEPrincipalKey *principal_key)
454+
pg_tde_write_key_map_entry(const RelFileLocator *rlocator, const InternalKey *rel_key_data, const TDEPrincipalKey *principal_key)
455455
{
456456
char db_map_path[MAXPGPATH];
457457
int map_fd;
@@ -579,7 +579,7 @@ pg_tde_verify_principal_key_info(TDESignedPrincipalKeyInfo *signed_key_info, con
579579
}
580580

581581
static InternalKey *
582-
tde_decrypt_rel_key(TDEPrincipalKey *principal_key, TDEMapEntry *map_entry)
582+
tde_decrypt_rel_key(const TDEPrincipalKey *principal_key, TDEMapEntry *map_entry)
583583
{
584584
InternalKey *rel_key_data = palloc_object(InternalKey);
585585

contrib/pg_tde/src/access/pg_tde_xlog_keys.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static WALKeyCacheRec *tde_wal_key_cache = NULL;
4646
static WALKeyCacheRec *tde_wal_key_last_rec = NULL;
4747

4848
static WALKeyCacheRec *pg_tde_add_wal_key_to_cache(WalEncryptionKey *cached_key);
49-
static WalEncryptionKey *pg_tde_decrypt_wal_key(TDEPrincipalKey *principal_key, WalKeyFileEntry *entry);
49+
static WalEncryptionKey *pg_tde_decrypt_wal_key(const TDEPrincipalKey *principal_key, WalKeyFileEntry *entry);
5050
static void pg_tde_initialize_wal_key_file_entry(WalKeyFileEntry *entry, const TDEPrincipalKey *principal_key, const WalEncryptionKey *rel_key_data);
5151
static int pg_tde_open_wal_key_file_basic(const char *filename, int flags, bool ignore_missing);
5252
static int pg_tde_open_wal_key_file_read(const char *filename, bool ignore_missing, off_t *curr_pos);
@@ -56,7 +56,7 @@ static void pg_tde_read_one_wal_key_file_entry2(int fd, int32 key_index, WalKeyF
5656
static void pg_tde_wal_key_file_header_read(const char *filename, int fd, WalKeyFileHeader *fheader, off_t *bytes_read);
5757
static int pg_tde_wal_key_file_header_write(const char *filename, int fd, const TDESignedPrincipalKeyInfo *signed_key_info, off_t *bytes_written);
5858
static void pg_tde_write_one_wal_key_file_entry(int fd, const WalKeyFileEntry *entry, off_t *offset, const char *db_map_path);
59-
static void pg_tde_write_wal_key_file_entry(const WalEncryptionKey *rel_key_data, TDEPrincipalKey *principal_key);
59+
static void pg_tde_write_wal_key_file_entry(const WalEncryptionKey *rel_key_data, const TDEPrincipalKey *principal_key);
6060

6161
static char *
6262
get_wal_key_file_path(void)
@@ -526,7 +526,7 @@ pg_tde_read_one_wal_key_file_entry2(int fd,
526526

527527
static void
528528
pg_tde_write_wal_key_file_entry(const WalEncryptionKey *rel_key_data,
529-
TDEPrincipalKey *principal_key)
529+
const TDEPrincipalKey *principal_key)
530530
{
531531
int fd;
532532
off_t curr_pos = 0;
@@ -551,7 +551,7 @@ pg_tde_write_wal_key_file_entry(const WalEncryptionKey *rel_key_data,
551551
}
552552

553553
static WalEncryptionKey *
554-
pg_tde_decrypt_wal_key(TDEPrincipalKey *principal_key, WalKeyFileEntry *entry)
554+
pg_tde_decrypt_wal_key(const TDEPrincipalKey *principal_key, WalKeyFileEntry *entry)
555555
{
556556
WalEncryptionKey *key = palloc_object(WalEncryptionKey);
557557

@@ -623,8 +623,8 @@ pg_tde_initialize_wal_key_file_entry(WalKeyFileEntry *entry,
623623
* Rotate keys and generates the WAL record for it.
624624
*/
625625
void
626-
pg_tde_perform_rotate_server_key(TDEPrincipalKey *principal_key,
627-
TDEPrincipalKey *new_principal_key,
626+
pg_tde_perform_rotate_server_key(const TDEPrincipalKey *principal_key,
627+
const TDEPrincipalKey *new_principal_key,
628628
bool write_xlog)
629629
{
630630
TDESignedPrincipalKeyInfo new_signed_key_info;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ extern TDESignedPrincipalKeyInfo *pg_tde_get_principal_key_info(Oid dbOid);
3838
extern bool pg_tde_verify_principal_key_info(TDESignedPrincipalKeyInfo *signed_key_info, const KeyData *principal_key_data);
3939
extern void pg_tde_save_principal_key(const TDEPrincipalKey *principal_key, bool write_xlog);
4040
extern void pg_tde_save_principal_key_redo(const TDESignedPrincipalKeyInfo *signed_key_info);
41-
extern void pg_tde_perform_rotate_key(TDEPrincipalKey *principal_key, TDEPrincipalKey *new_principal_key, bool write_xlog);
41+
extern void pg_tde_perform_rotate_key(const TDEPrincipalKey *principal_key, const TDEPrincipalKey *new_principal_key, bool write_xlog);
4242
extern void pg_tde_delete_principal_key(Oid dbOid);
4343
extern void pg_tde_delete_principal_key_redo(Oid dbOid);
4444

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ extern WALKeyCacheRec *pg_tde_fetch_wal_keys(WalLocation start);
7878
extern WALKeyCacheRec *pg_tde_get_last_wal_key(void);
7979
extern TDESignedPrincipalKeyInfo *pg_tde_get_server_key_info(void);
8080
extern WALKeyCacheRec *pg_tde_get_wal_cache_keys(void);
81-
extern void pg_tde_perform_rotate_server_key(TDEPrincipalKey *principal_key, TDEPrincipalKey *new_principal_key, bool write_xlog);
81+
extern void pg_tde_perform_rotate_server_key(const TDEPrincipalKey *principal_key, const TDEPrincipalKey *new_principal_key, bool write_xlog);
8282
extern WalEncryptionKey *pg_tde_read_last_wal_key(void);
8383
extern void pg_tde_save_server_key(const TDEPrincipalKey *principal_key, bool write_xlog);
8484
extern void pg_tde_save_server_key_redo(const TDESignedPrincipalKeyInfo *signed_key_info);

0 commit comments

Comments
 (0)