diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c
index 6cba34350a..eda84a20d8 100644
--- a/contrib/postgres_fdw/deparse.c
+++ b/contrib/postgres_fdw/deparse.c
@@ -3870,8 +3870,17 @@ appendLimitClause(deparse_expr_cxt *context)
 
 	if (root->parse->limitCount)
 	{
-		appendStringInfoString(buf, " LIMIT ");
-		deparseExpr((Expr *) root->parse->limitCount, context);
+		if (root->parse->limitOption == LIMIT_OPTION_WITH_TIES)
+		{
+			appendStringInfoString(buf, " FETCH FIRST (");
+			deparseExpr((Expr *) root->parse->limitCount, context);
+			appendStringInfoString(buf, ") ROW WITH TIES");
+		}
+		else
+		{
+			appendStringInfoString(buf, " LIMIT ");
+			deparseExpr((Expr *) root->parse->limitCount, context);
+		}
 	}
 	if (root->parse->limitOffset)
 	{
