src/backend/utils/init/miscinit.c
/*
 * Get user name from user oid
 */
Get user name from user oid
Get user name from user oid
char *
GetUserNameFromId(Oid roleid)
{
	HeapTuple	tuple;
	char	   *result;
	tuple = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
	if (!HeapTupleIsValid(tuple))
		ereport(ERROR,
				(errcode(ERRCODE_UNDEFINED_OBJECT),
				 errmsg("invalid role OID: %u", roleid)));
	result = pstrdup(NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname));
	ReleaseSysCache(tuple);
	return result;
}
char * GetUserNameFromId ( Oid roleid ) { HeapTuple tuple ; char * result ; tuple = SearchSysCache1 ( AUTHOID , ObjectIdGetDatum ( roleid ) ) ; if ( ! HeapTupleIsValid ( tuple ) ) ereport ( ERROR , ( errcode ( ERRCODE_UNDEFINED_OBJECT ) , errmsg ( " " , roleid ) ) ) ; result = pstrdup ( NameStr ( ( ( Form_pg_authid ) GETSTRUCT ( tuple ) ) -> rolname ) ) ; ReleaseSysCache ( tuple ) ; return result ; }
Get user name from user oid
Get user name from user oid