Skip to content

Commit 0b2dbd2

Browse files
committed
Consistently update the position in a pointer passed to the function
This UX is not nice but let's at least be consistent about it.
1 parent 676d637 commit 0b2dbd2

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

contrib/pg_tde/src/access/pg_tde_tdemap.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static InternalKey *pg_tde_create_local_key(const RelFileLocator *newrlocator, u
126126
static void pg_tde_generate_internal_key(InternalKey *int_key, uint32 entry_type);
127127
static int pg_tde_file_header_write(const char *tde_filename, int fd, const TDESignedPrincipalKeyInfo *signed_key_info, off_t *bytes_written);
128128
static void pg_tde_sign_principal_key_info(TDESignedPrincipalKeyInfo *signed_key_info, const TDEPrincipalKey *principal_key);
129-
static off_t pg_tde_write_one_map_entry(int fd, const TDEMapEntry *map_entry, off_t *offset, const char *db_map_path);
129+
static void pg_tde_write_one_map_entry(int fd, const TDEMapEntry *map_entry, off_t *offset, const char *db_map_path);
130130
static void pg_tde_write_key_map_entry(const RelFileLocator *rlocator, InternalKey *rel_key_data, TDEPrincipalKey *principal_key, bool write_xlog);
131131
static int keyrotation_init_file(const TDESignedPrincipalKeyInfo *signed_key_info, char *rotated_filename, const char *filename, off_t *curr_pos);
132132
static void finalize_key_rotation(const char *path_old, const char *path_new);
@@ -380,7 +380,7 @@ pg_tde_initialize_map_entry(TDEMapEntry *map_entry, const TDEPrincipalKey *princ
380380
/*
381381
* Based on the given arguments,write the entry into the key map file.
382382
*/
383-
static off_t
383+
static void
384384
pg_tde_write_one_map_entry(int fd, const TDEMapEntry *map_entry, off_t *offset, const char *db_map_path)
385385
{
386386
int bytes_written = 0;
@@ -401,7 +401,7 @@ pg_tde_write_one_map_entry(int fd, const TDEMapEntry *map_entry, off_t *offset,
401401
errmsg("could not fsync file \"%s\": %m", db_map_path));
402402
}
403403

404-
return (*offset + bytes_written);
404+
*offset += bytes_written;
405405
}
406406

407407
/*
@@ -633,7 +633,6 @@ pg_tde_perform_rotate_key(TDEPrincipalKey *principal_key, TDEPrincipalKey *new_p
633633
while (1)
634634
{
635635
InternalKey *rel_key_data;
636-
off_t new_prev_pos;
637636
TDEMapEntry read_map_entry,
638637
write_map_entry;
639638
RelFileLocator rloc;
@@ -652,9 +651,7 @@ pg_tde_perform_rotate_key(TDEPrincipalKey *principal_key, TDEPrincipalKey *new_p
652651
rel_key_data = tde_decrypt_rel_key(principal_key, &read_map_entry);
653652
pg_tde_initialize_map_entry(&write_map_entry, new_principal_key, &rloc, rel_key_data);
654653

655-
/* Write the given entry at the location pointed by prev_pos */
656-
new_prev_pos = new_curr_pos;
657-
new_curr_pos = pg_tde_write_one_map_entry(new_fd, &write_map_entry, &new_prev_pos, new_path);
654+
pg_tde_write_one_map_entry(new_fd, &write_map_entry, &new_curr_pos, new_path);
658655

659656
pfree(rel_key_data);
660657
}

0 commit comments

Comments
 (0)