@@ -819,47 +819,40 @@ TDEPrincipalKey *
819
819
GetPrincipalKey (Oid dbOid , LWLockMode lockMode )
820
820
{
821
821
TDEPrincipalKey * principalKey = GetPrincipalKeyNoDefault (dbOid , lockMode );
822
- #ifndef FRONTEND
823
- TDEPrincipalKey * newPrincipalKey = NULL ;
824
- #endif
825
-
826
- if (principalKey != NULL )
827
- {
828
- return principalKey ;
829
- }
830
822
831
823
#ifndef FRONTEND
832
-
833
- /*
834
- * If database doesn't have dedicated principal key we should try to
835
- * fallback to default principal key.
836
- */
837
-
838
- /* Lock is already updated to exclusive at this point */
839
- principalKey = GetPrincipalKeyNoDefault (DEFAULT_DATA_TDE_OID , LW_EXCLUSIVE );
840
-
841
824
if (principalKey == NULL )
842
825
{
843
- return NULL ;
844
- }
826
+ /*
827
+ * If database doesn't have dedicated principal key we should try to
828
+ * fallback to default principal key.
829
+ */
830
+ TDEPrincipalKey * newPrincipalKey ;
845
831
846
- newPrincipalKey = palloc_object (TDEPrincipalKey );
847
- * newPrincipalKey = * principalKey ;
848
- newPrincipalKey -> keyInfo .databaseId = dbOid ;
832
+ /* Lock is already updated to exclusive at this point */
833
+ principalKey = GetPrincipalKeyNoDefault (DEFAULT_DATA_TDE_OID , LW_EXCLUSIVE );
849
834
850
- /*
851
- * We have to write default principal key info to database keys file.
852
- * However we cannot write XLOG records about this operation as current
853
- * funcion may be invoked during server startup/recovery where WAL writes
854
- * forbidden.
855
- */
856
- pg_tde_save_principal_key (newPrincipalKey , false);
835
+ if (principalKey == NULL )
836
+ return NULL ;
857
837
858
- push_principal_key_to_cache (newPrincipalKey );
838
+ newPrincipalKey = palloc_object (TDEPrincipalKey );
839
+ * newPrincipalKey = * principalKey ;
840
+ newPrincipalKey -> keyInfo .databaseId = dbOid ;
859
841
860
- pfree (newPrincipalKey );
842
+ /*
843
+ * We have to write default principal key info to database keys file.
844
+ * However we cannot write XLOG records about this operation as
845
+ * current funcion may be invoked during server startup/recovery where
846
+ * WAL writes forbidden.
847
+ */
848
+ pg_tde_save_principal_key (newPrincipalKey , false);
849
+
850
+ push_principal_key_to_cache (newPrincipalKey );
861
851
862
- principalKey = GetPrincipalKeyNoDefault (dbOid , LW_EXCLUSIVE );
852
+ pfree (newPrincipalKey );
853
+
854
+ principalKey = GetPrincipalKeyNoDefault (dbOid , LW_EXCLUSIVE );
855
+ }
863
856
#endif
864
857
865
858
return principalKey ;
0 commit comments