diff --git a/contrib/postgres_fdw/connection.c b/contrib/postgres_fdw/connection.c
new file mode 100644
index bcdddc2..11ee50f
*** a/contrib/postgres_fdw/connection.c
--- b/contrib/postgres_fdw/connection.c
*************** static bool xact_got_connection = false;
*** 65,71 ****
  
  /* prototypes of private functions */
  static PGconn *connect_pg_server(ForeignServer *server, UserMapping *user);
! static void check_conn_params(const char **keywords, const char **values);
  static void configure_remote_session(PGconn *conn);
  static void do_sql_command(PGconn *conn, const char *sql);
  static void begin_remote_xact(ConnCacheEntry *entry);
--- 65,71 ----
  
  /* prototypes of private functions */
  static PGconn *connect_pg_server(ForeignServer *server, UserMapping *user);
! static void check_conn_params(const char **keywords, const char **values, UserMapping *user);
  static void configure_remote_session(PGconn *conn);
  static void do_sql_command(PGconn *conn, const char *sql);
  static void begin_remote_xact(ConnCacheEntry *entry);
*************** connect_pg_server(ForeignServer *server,
*** 222,228 ****
  		keywords[n] = values[n] = NULL;
  
  		/* verify connection parameters and make connection */
! 		check_conn_params(keywords, values);
  
  		conn = PQconnectdbParams(keywords, values, false);
  		if (!conn || PQstatus(conn) != CONNECTION_OK)
--- 222,228 ----
  		keywords[n] = values[n] = NULL;
  
  		/* verify connection parameters and make connection */
! 		check_conn_params(keywords, values, user);
  
  		conn = PQconnectdbParams(keywords, values, false);
  		if (!conn || PQstatus(conn) != CONNECTION_OK)
*************** connect_pg_server(ForeignServer *server,
*** 247,253 ****
  		 * otherwise, he's piggybacking on the postgres server's user
  		 * identity. See also dblink_security_check() in contrib/dblink.
  		 */
! 		if (!superuser() && !PQconnectionUsedPassword(conn))
  			ereport(ERROR,
  				  (errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED),
  				   errmsg("password is required"),
--- 247,253 ----
  		 * otherwise, he's piggybacking on the postgres server's user
  		 * identity. See also dblink_security_check() in contrib/dblink.
  		 */
! 		if (!superuser_arg(user->userid) && !PQconnectionUsedPassword(conn))
  			ereport(ERROR,
  				  (errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED),
  				   errmsg("password is required"),
*************** connect_pg_server(ForeignServer *server,
*** 280,286 ****
   * contrib/dblink.)
   */
  static void
! check_conn_params(const char **keywords, const char **values)
  {
  	int			i;
  
--- 280,286 ----
   * contrib/dblink.)
   */
  static void
! check_conn_params(const char **keywords, const char **values, UserMapping *user)
  {
  	int			i;
  
*************** check_conn_params(const char **keywords,
*** 288,293 ****
--- 288,296 ----
  	if (superuser())
  		return;
  
+ 	if (superuser_arg(user->userid))
+ 		return;
+ 
  	/* ok if params contain a non-empty password */
  	for (i = 0; keywords[i] != NULL; i++)
  	{
