@@ -161,8 +161,8 @@ pg_tde_create_key_map_entry(const RelFileLocator *newrlocator, uint32 entry_type
161161 if (principal_key == NULL )
162162 {
163163 ereport (ERROR ,
164- ( errmsg ("principal key not configured" ),
165- errhint ("create one using pg_tde_set_principal_key before using encrypted tables" ) ));
164+ errmsg ("principal key not configured" ),
165+ errhint ("create one using pg_tde_set_principal_key before using encrypted tables" ));
166166 }
167167
168168 /*
@@ -192,14 +192,14 @@ pg_tde_generate_internal_key(InternalKey *int_key, uint32 entry_type)
192192
193193 if (!RAND_bytes (int_key -> key , INTERNAL_KEY_LEN ))
194194 ereport (ERROR ,
195- ( errcode (ERRCODE_INTERNAL_ERROR ),
196- errmsg ("could not generate internal key: %s" ,
197- ERR_error_string (ERR_get_error (), NULL ) )));
195+ errcode (ERRCODE_INTERNAL_ERROR ),
196+ errmsg ("could not generate internal key: %s" ,
197+ ERR_error_string (ERR_get_error (), NULL )));
198198 if (!RAND_bytes (int_key -> base_iv , INTERNAL_KEY_IV_LEN ))
199199 ereport (ERROR ,
200- ( errcode (ERRCODE_INTERNAL_ERROR ),
201- errmsg ("could not generate IV: %s" ,
202- ERR_error_string (ERR_get_error (), NULL ) )));
200+ errcode (ERRCODE_INTERNAL_ERROR ),
201+ errmsg ("could not generate IV: %s" ,
202+ ERR_error_string (ERR_get_error (), NULL )));
203203}
204204
205205const char *
@@ -234,8 +234,8 @@ pg_tde_create_wal_key(InternalKey *rel_key_data, const RelFileLocator *newrlocat
234234 if (principal_key == NULL )
235235 {
236236 ereport (ERROR ,
237- ( errmsg ("principal key not configured" ),
238- errhint ("create one using pg_tde_set_server_principal_key before using encrypted WAL" ) ));
237+ errmsg ("principal key not configured" ),
238+ errhint ("create one using pg_tde_set_server_principal_key before using encrypted WAL" ));
239239 }
240240
241241 /* TODO: no need in generating key if TDE_KEY_TYPE_WAL_UNENCRYPTED */
@@ -300,7 +300,7 @@ pg_tde_save_principal_key(const TDEPrincipalKey *principal_key)
300300 /* Set the file paths */
301301 pg_tde_set_db_file_path (principal_key -> keyInfo .databaseId , db_map_path );
302302
303- ereport (DEBUG2 , ( errmsg ("pg_tde_save_principal_key" ) ));
303+ ereport (DEBUG2 , errmsg ("pg_tde_save_principal_key" ));
304304
305305 pg_tde_sign_principal_key_info (& signed_key_Info , principal_key );
306306
@@ -329,19 +329,18 @@ pg_tde_file_header_write(const char *tde_filename, int fd, const TDESignedPrinci
329329 if (* bytes_written != TDE_FILE_HEADER_SIZE )
330330 {
331331 ereport (ERROR ,
332- (errcode_for_file_access (),
333- errmsg ("could not write tde file \"%s\": %m" ,
334- tde_filename )));
332+ errcode_for_file_access (),
333+ errmsg ("could not write tde file \"%s\": %m" , tde_filename ));
335334 }
336335
337336 if (pg_fsync (fd ) != 0 )
338337 {
339338 ereport (data_sync_elevel (ERROR ),
340- ( errcode_for_file_access (),
341- errmsg ("could not fsync file \"%s\": %m" , tde_filename ) ));
339+ errcode_for_file_access (),
340+ errmsg ("could not fsync file \"%s\": %m" , tde_filename ));
342341 }
343- ereport ( DEBUG2 ,
344- ( errmsg ("Wrote the header to %s" , tde_filename ) ));
342+
343+ ereport ( DEBUG2 , errmsg ("Wrote the header to %s" , tde_filename ));
345344
346345 return fd ;
347346}
@@ -353,8 +352,8 @@ pg_tde_sign_principal_key_info(TDESignedPrincipalKeyInfo *signed_key_info, const
353352
354353 if (!RAND_bytes (signed_key_info -> sign_iv , MAP_ENTRY_EMPTY_IV_SIZE ))
355354 ereport (ERROR ,
356- ( errcode (ERRCODE_INTERNAL_ERROR ),
357- errmsg ("could not generate iv for key map: %s" , ERR_error_string (ERR_get_error (), NULL ) )));
355+ errcode (ERRCODE_INTERNAL_ERROR ),
356+ errmsg ("could not generate iv for key map: %s" , ERR_error_string (ERR_get_error (), NULL )));
358357
359358 AesGcmEncrypt (principal_key -> keyData , signed_key_info -> sign_iv , (unsigned char * ) & signed_key_info -> data , sizeof (signed_key_info -> data ), NULL , 0 , NULL , signed_key_info -> aead_tag );
360359}
@@ -369,8 +368,8 @@ pg_tde_initialize_map_entry(TDEMapEntry *map_entry, const TDEPrincipalKey *princ
369368
370369 if (!RAND_bytes (map_entry -> entry_iv , MAP_ENTRY_EMPTY_IV_SIZE ))
371370 ereport (ERROR ,
372- ( errcode (ERRCODE_INTERNAL_ERROR ),
373- errmsg ("could not generate iv for key map: %s" , ERR_error_string (ERR_get_error (), NULL ) )));
371+ errcode (ERRCODE_INTERNAL_ERROR ),
372+ errmsg ("could not generate iv for key map: %s" , ERR_error_string (ERR_get_error (), NULL )));
374373
375374 AesGcmEncrypt (principal_key -> keyData , map_entry -> entry_iv , (unsigned char * ) map_entry , offsetof(TDEMapEntry , enc_key ), rel_key_data -> key , INTERNAL_KEY_LEN , map_entry -> enc_key .key , map_entry -> aead_tag );
376375}
@@ -389,15 +388,14 @@ pg_tde_write_one_map_entry(int fd, const TDEMapEntry *map_entry, off_t *offset,
389388 if (bytes_written != MAP_ENTRY_SIZE )
390389 {
391390 ereport (ERROR ,
392- (errcode_for_file_access (),
393- errmsg ("could not write tde map file \"%s\": %m" ,
394- db_map_path )));
391+ errcode_for_file_access (),
392+ errmsg ("could not write tde map file \"%s\": %m" , db_map_path ));
395393 }
396394 if (pg_fsync (fd ) != 0 )
397395 {
398396 ereport (data_sync_elevel (ERROR ),
399- ( errcode_for_file_access (),
400- errmsg ("could not fsync file \"%s\": %m" , db_map_path ) ));
397+ errcode_for_file_access (),
398+ errmsg ("could not fsync file \"%s\": %m" , db_map_path ));
401399 }
402400
403401 return (* offset + bytes_written );
@@ -565,9 +563,9 @@ pg_tde_delete_map_entry(const RelFileLocator *rlocator, char *db_map_path, off_t
565563 if (curr_pos == -1 )
566564 {
567565 ereport (ERROR ,
568- ( errcode_for_file_access (),
569- errmsg ("could not seek in tde map file \"%s\": %m" ,
570- db_map_path ) ));
566+ errcode_for_file_access (),
567+ errmsg ("could not seek in tde map file \"%s\": %m" ,
568+ db_map_path ));
571569 }
572570 }
573571
@@ -641,11 +639,11 @@ pg_tde_free_key_map_entry(const RelFileLocator *rlocator, off_t offset)
641639 if (!found )
642640 {
643641 ereport (WARNING ,
644- ( errcode (ERRCODE_NO_DATA_FOUND ),
645- errmsg ("could not find the required map entry for deletion of relation %d in tablespace %d in tde map file \"%s\": %m" ,
646- rlocator -> relNumber ,
647- rlocator -> spcOid ,
648- db_map_path ) ));
642+ errcode (ERRCODE_NO_DATA_FOUND ),
643+ errmsg ("could not find the required map entry for deletion of relation %d in tablespace %d in tde map file \"%s\": %m" ,
644+ rlocator -> relNumber ,
645+ rlocator -> spcOid ,
646+ db_map_path ));
649647
650648 }
651649}
@@ -751,8 +749,8 @@ pg_tde_perform_rotate_key(TDEPrincipalKey *principal_key, TDEPrincipalKey *new_p
751749
752750 if (pg_pread (new_fd , xlrec -> buff , xlrec -> file_size , 0 ) == -1 )
753751 ereport (ERROR ,
754- ( errcode_for_file_access (),
755- errmsg ("could not write WAL for key rotation: %m" ) ));
752+ errcode_for_file_access (),
753+ errmsg ("could not write WAL for key rotation: %m" ));
756754
757755 close (new_fd );
758756
@@ -792,16 +790,16 @@ pg_tde_write_map_keydata_file(off_t file_size, char *file_data)
792790 if (pg_pwrite (fd_new , file_data , file_size , 0 ) != file_size )
793791 {
794792 ereport (WARNING ,
795- ( errcode_for_file_access (),
796- errmsg ("could not write tde file \"%s\": %m" , path_new ) ));
793+ errcode_for_file_access (),
794+ errmsg ("could not write tde file \"%s\": %m" , path_new ));
797795 is_err = true;
798796 goto FINALIZE ;
799797 }
800798 if (pg_fsync (fd_new ) != 0 )
801799 {
802800 ereport (WARNING ,
803- ( errcode_for_file_access (),
804- errmsg ("could not fsync file \"%s\": %m" , path_new ) ));
801+ errcode_for_file_access (),
802+ errmsg ("could not fsync file \"%s\": %m" , path_new ));
805803 is_err = true;
806804 goto FINALIZE ;
807805 }
@@ -835,8 +833,8 @@ pg_tde_wal_last_key_set_lsn(XLogRecPtr lsn, const char *keyfile_path)
835833 if (pg_pwrite (fd , & lsn , sizeof (XLogRecPtr ), write_pos ) != sizeof (XLogRecPtr ))
836834 {
837835 ereport (ERROR ,
838- ( errcode_for_file_access (),
839- errmsg ("could not write tde key data file: %m" ) ));
836+ errcode_for_file_access (),
837+ errmsg ("could not write tde key data file: %m" ));
840838 }
841839
842840 /*
@@ -852,8 +850,8 @@ pg_tde_wal_last_key_set_lsn(XLogRecPtr lsn, const char *keyfile_path)
852850 if (pg_pread (fd , & prev_map_entry , MAP_ENTRY_SIZE , prev_key_pos ) != MAP_ENTRY_SIZE )
853851 {
854852 ereport (ERROR ,
855- ( errcode_for_file_access (),
856- errmsg ("could not read previous WAL key: %m" ) ));
853+ errcode_for_file_access (),
854+ errmsg ("could not read previous WAL key: %m" ));
857855 }
858856
859857 if (prev_map_entry .enc_key .start_lsn >= lsn )
@@ -863,17 +861,17 @@ pg_tde_wal_last_key_set_lsn(XLogRecPtr lsn, const char *keyfile_path)
863861 if (pg_pwrite (fd , & prev_map_entry , MAP_ENTRY_SIZE , prev_key_pos ) != MAP_ENTRY_SIZE )
864862 {
865863 ereport (ERROR ,
866- ( errcode_for_file_access (),
867- errmsg ("could not write invalidated key: %m" ) ));
864+ errcode_for_file_access (),
865+ errmsg ("could not write invalidated key: %m" ));
868866 }
869867 }
870868 }
871869
872870 if (pg_fsync (fd ) != 0 )
873871 {
874872 ereport (data_sync_elevel (ERROR ),
875- ( errcode_for_file_access (),
876- errmsg ("could not fsync file: %m" ) ));
873+ errcode_for_file_access (),
874+ errmsg ("could not fsync file: %m" ));
877875 }
878876
879877 LWLockRelease (lock_pk );
@@ -959,8 +957,8 @@ pg_tde_get_key_from_file(const RelFileLocator *rlocator, uint32 key_type)
959957 principal_key = GetPrincipalKey (rlocator -> dbOid , LW_SHARED );
960958 if (principal_key == NULL )
961959 ereport (ERROR ,
962- ( errmsg ("principal key not configured" ),
963- errhint ("create one using pg_tde_set_principal_key before using encrypted tables" ) ));
960+ errmsg ("principal key not configured" ),
961+ errhint ("create one using pg_tde_set_principal_key before using encrypted tables" ));
964962
965963 rel_key = tde_decrypt_rel_key (principal_key , map_entry );
966964
@@ -1033,7 +1031,7 @@ tde_decrypt_rel_key(TDEPrincipalKey *principal_key, TDEMapEntry *map_entry)
10331031
10341032 if (!AesGcmDecrypt (principal_key -> keyData , map_entry -> entry_iv , (unsigned char * ) map_entry , offsetof(TDEMapEntry , enc_key ), map_entry -> enc_key .key , INTERNAL_KEY_LEN , rel_key_data -> key , map_entry -> aead_tag ))
10351033 ereport (ERROR ,
1036- ( errmsg ("Failed to decrypt key, incorrect principal key or corrupted key file" ) ));
1034+ errmsg ("Failed to decrypt key, incorrect principal key or corrupted key file" ));
10371035
10381036
10391037 return rel_key_data ;
@@ -1078,9 +1076,8 @@ pg_tde_open_file_basic(const char *tde_filename, int fileFlags, bool ignore_miss
10781076 if (fd < 0 && !(errno == ENOENT && ignore_missing == true))
10791077 {
10801078 ereport (ERROR ,
1081- (errcode_for_file_access (),
1082- errmsg ("could not open tde file \"%s\": %m" ,
1083- tde_filename )));
1079+ errcode_for_file_access (),
1080+ errmsg ("could not open tde file \"%s\": %m" , tde_filename ));
10841081 }
10851082
10861083 return fd ;
@@ -1107,9 +1104,8 @@ pg_tde_file_header_read(const char *tde_filename, int fd, TDEFileHeader *fheader
11071104 /* Corrupt file */
11081105 close (fd );
11091106 ereport (FATAL ,
1110- (errcode_for_file_access (),
1111- errmsg ("TDE map file \"%s\" is corrupted: %m" ,
1112- tde_filename )));
1107+ errcode_for_file_access (),
1108+ errmsg ("TDE map file \"%s\" is corrupted: %m" , tde_filename ));
11131109 }
11141110}
11151111
@@ -1171,9 +1167,9 @@ pg_tde_read_one_map_entry2(int fd, int32 key_index, TDEMapEntry *map_entry, Oid
11711167
11721168 pg_tde_set_db_file_path (databaseId , db_map_path );
11731169 ereport (FATAL ,
1174- ( errcode_for_file_access (),
1175- errmsg ("could not find the required key at index %d in tde data file \"%s\": %m" ,
1176- key_index , db_map_path ) ));
1170+ errcode_for_file_access (),
1171+ errmsg ("could not find the required key at index %d in tde data file \"%s\": %m" ,
1172+ key_index , db_map_path ));
11771173 }
11781174}
11791175
0 commit comments