diff --git a/src/bin/pg_dump/pg_dumpall b/src/bin/pg_dump/pg_dumpall
index 976a05eebe1..0e3a1ef0ab2 100644
--- a/src/bin/pg_dump/pg_dumpall
+++ b/src/bin/pg_dump/pg_dumpall
@@ -18,11 +18,11 @@ fi
 #
 # get the postgres user id
 #
-POSTGRES_SUPER_USER_ID="`psql -A -q -t template1 <<END
-select datdba
-from pg_database
-where datname = 'template1';
-END`"
+POSTGRES_SUPER_USER_ID="`echo \" \
+			select datdba \
+			from pg_database \
+			where datname = 'template1'; \" | \
+			psql -A -q -t template1`"
 echo "${BS}connect template1"
 #
 # delete all users in case they run this twice