diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index 0a589f8db74..6dbae583ecc 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -6024,7 +6024,7 @@ remattrmap_cmp(const void *v1, const void *v2)
 	const RemoteAttributeMapping *r1 = v1;
 	const RemoteAttributeMapping *r2 = v2;
 
-	return strncmp(r1->remote_attname, r2->remote_attname, NAMEDATALEN);
+	return strcmp(r1->remote_attname, r2->remote_attname);
 }
 
 /*
