@ -523,6 +523,9 @@ BaseInit(void)
* name can be returned to the caller in out_dbname . If out_dbname isn ' t
* NULL , it must point to a buffer of size NAMEDATALEN .
*
* Similarly , the username can be passed by name , using the username parameter ,
* or by OID using the useroid parameter .
*
* In bootstrap mode no parameters are used . The autovacuum launcher process
* doesn ' t use any parameters either , because it only goes far enough to be
* able to read pg_database ; it doesn ' t connect to any particular database .
@ -537,7 +540,7 @@ BaseInit(void)
*/
void
InitPostgres ( const char * in_dbname , Oid dboid , const char * username ,
char * out_dbname )
Oid useroid , char * out_dbname )
{
bool bootstrap = IsBootstrapProcessingMode ( ) ;
bool am_superuser ;
@ -692,18 +695,18 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
( errcode ( ERRCODE_UNDEFINED_OBJECT ) ,
errmsg ( " no roles are defined in this database system " ) ,
errhint ( " You should immediately run CREATE USER \" %s \" SUPERUSER;. " ,
username ) ) ) ;
username ! = NULL ? username : " postgres " ) ) ) ;
}
else if ( IsBackgroundWorker )
{
if ( username = = NULL )
if ( username = = NULL & & ! OidIsValid ( useroid ) )
{
InitializeSessionUserIdStandalone ( ) ;
am_superuser = true ;
}
else
{
InitializeSessionUserId ( username ) ;
InitializeSessionUserId ( username , useroid ) ;
am_superuser = superuser ( ) ;
}
}
@ -712,7 +715,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
/* normal multiuser case */
Assert ( MyProcPort ! = NULL ) ;
PerformAuthentication ( MyProcPort ) ;
InitializeSessionUserId ( username ) ;
InitializeSessionUserId ( username , useroid ) ;
am_superuser = superuser ( ) ;
}