Re: Solaris getopt_long and PostgreSQL - Mailing list pgsql-hackers

From Zdenek Kotala
Subject Re: Solaris getopt_long and PostgreSQL
Date
Msg-id 49BFCC35.8030108@sun.com
Whole thread Raw
In response to Solaris getopt_long and PostgreSQL  (Chuck McDevitt <cmcdevitt@greenplum.com>)
Responses Re: Solaris getopt_long and PostgreSQL  (Zdenek Kotala <Zdenek.Kotala@Sun.COM>)
List pgsql-hackers
Dne 17.03.09 16:38, Chuck McDevitt napsal(a):
> About a year ago, you talked to the PostgreSQL people about some problem 
> with Solaris getopt_long, and they changed the build to use the internal 
> getopt_long instead of the Solaris one?
> 

The problem was with getopt which is works little bit differently when - 
is specified in optstring. If you look in POSIX it does not define how 
getopt should work in this case. Solaris getopt implementation has 
extension for long args. Unfortunately PostgreSQL clashes with it, 
because it does not use getopt_long for long argument, but getopt(argc, 
argv,"xy-").

> 
> What was the problem with Solaris getopt_long?  Does the problem still 
> exist in Solaris 10?

yes and it will exist forever, because it is public API.

see  man -s3C getopt

> 
>  
> 
> My users are unhappy at the change, since normal getopt_long reorders 
> the args, and apparently the built-in one doesn’t, so “psql database –p 
> port” no longer works, since it treats –p as the user name.

I understand, I'm not happy too :(, but how Tom mentioned it has been 
never supposed to work. See documentation

> I don’t know if I should revert that change, or port netBSD getopt_long 
> and replace the PostgreSQL one with that.

getopt_long is OK. Problem is getopt. getopt in core is currently taken 
from *BSD but it could be updated.

One possible solution should be to use internal getopt only for postgres 
binary and for other to use solaris libc version.
Zdenek



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Ignore -- testing message-id on footer
Next
From: Zdenek Kotala
Date:
Subject: Re: Solaris getopt_long and PostgreSQL