Re: Solaris getopt_long and PostgreSQL

From: Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM>
To: Chuck McDevitt <cmcdevitt(at)greenplum(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Solaris getopt_long and PostgreSQL
Date: 2009-03-17 16:13:41
Message-ID: 49BFCC35.8030108@sun.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zdenek Kotala 2009-03-17 16:24:38 Re: Solaris getopt_long and PostgreSQL
Previous Message Robert Haas 2009-03-17 16:00:57 Re: small but useful patches for text search