diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c
index 437fa4d663ae6c5b61f967542402c5ff1cc7a0fa..e3771040072f6ad4bf10cfff7336cd397cb7a004 100644
--- a/src/bin/psql/input.c
+++ b/src/bin/psql/input.c
@@ -378,10 +378,10 @@ initializeInput(int flags)
  *
  * max_lines: if >= 0, limit history file to that many entries.
  */
+#ifdef USE_READLINE
 static bool
 saveHistory(char *fname, int max_lines)
 {
-#ifdef USE_READLINE
 	int			errnum;
 
 	/*
@@ -446,10 +446,10 @@ saveHistory(char *fname, int max_lines)
 		psql_error("could not save history to file \"%s\": %s\n",
 				   fname, strerror(errnum));
 	}
-#endif
-
 	return false;
 }
+#endif
+
 
 
 /*