On 2/5/16 10:08 AM, David Fetter wrote:
On Wed, Feb 03, 2016 at 06:02:57PM -0600, Jim Nasby wrote:
I just discovered that ./configure will happily accept '--with-pgport=' (I
was actually doing =$PGPORT, and didn't realize $PGPORT was empty). What you
end up with is a compile error in guc.c, with no idea why it's broken. Any
reason not to have configure or at least make puke if pgport isn't valid?
That seems like a good idea.
Patch attached. I've verified it with --with-pgport=, =0, =77777 and =1.
It catches what you'd expect it to.
As the comment states, it doesn't catch things like --with-pgport=1a in
configure, but the compile error you get with that isn't too hard to
figure out, so I think it's OK.
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
diff --git a/configure b/configure
index b3f3abe..2beee31 100755
--- a/configure
+++ b/configure
@@ -3099,6 +3099,14 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
+# It's worth testing for this because it creates a very confusing error
+if test "$default_port" == ""; then
+ as_fn_error $? "Invalid empty string supplied for \$PGPORT or
--with-pgport" "$LINENO" 5
+# This won't catch something like "PGPORT=11a" but that produces a pretty easy
+# to understand compile error.
+elif test "$default_port" -lt "1" -o "$default_port" -gt "65535"; then
+ as_fn_error $? "port must be between 1 and 65535" "$LINENO" 5
+fi
#
# '-rpath'-like feature can be disabled
diff --git a/configure.in b/configure.in
index 0bd90d7..54e9a16 100644
--- a/configure.in
+++ b/configure.in
@@ -164,6 +164,14 @@ but it's convenient if your clients have the right default
compiled in.
AC_DEFINE_UNQUOTED(DEF_PGPORT_STR, "${default_port}",
[Define to the default TCP port number as a string
constant.])
AC_SUBST(default_port)
+# It's worth testing for this because it creates a very confusing error
+if test "$default_port" == ""; then
+ AC_MSG_ERROR([Invalid empty string supplied for \$PGPORT or
--with-pgport])
+# This won't catch something like "PGPORT=11a" but that produces a pretty easy
+# to understand compile error.
+elif test "$default_port" -lt "1" -o "$default_port" -gt "65535"; then
+ AC_MSG_ERROR([port must be between 1 and 65535])
+fi
#
# '-rpath'-like feature can be disabled
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers