From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | Clover White <mywhiteclover(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: why was the VAR 'optind' never changed in initdb? |
Date: | 2012-04-09 17:19:31 |
Message-ID: | 4F831A23.8080709@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 04/09/2012 12:36 PM, Clover White wrote:
> 2012/4/9 Andrew Dunstan <andrew(at)dunslane(dot)net <mailto:andrew(at)dunslane(dot)net>>
>
>
>
> On 04/09/2012 07:38 AM, Clover White wrote:
>
> Hi,
> I'm debugging initdb using gdb.
> I found that I could not step in the function getopt_long in
> line 2572 in initdb.c.
> I also found that the value of VAR optind never be changed.
> VAR optind is always equal to 1 but how could optind be larger
> than the value of argc(the value of argc is 6) in line 2648
> and 2654.
>
> I was so confused. Could someone give me some help? Thank you~
>
>
>
> Why do you expect it to be? Perhaps if you tell us what problem
> you're actually trying to solve we can help you better.
>
> cheers
>
> andrew
>
>
> Hi, this is my story, it may be a little long :)
> I mistook the parameter -W of initdb at the first time and used it
> like this:
> initdb -U pgsql -W 12345 -D /home/pgsql/pg_data
> And I found the database was not created in the right directory, but
> I could not find a log file to find out why.
> So, I debug initdb and found out I have mistook the parameter -W, I
> should use it like this:
> initdb -U pgsql -W -D /home/pgsql/pg_data
This is arguably a bug. Maybe we should change this:
if (optind < argc)
{
pg_data = xstrdup(argv[optind]);
optind++;
}
to
if (optind < argc && strlen(pg_data) == 0)
{
pg_data = xstrdup(argv[optind]);
optind++;
}
i.e. we'd forbid:
initdb -D foo bar
which the OP's error more or less devolves to.
cheers
andrew
From | Date | Subject | |
---|---|---|---|
Next Message | Atri Sharma | 2012-04-09 17:25:58 | Re: [JDBC] Regarding GSoc Application |
Previous Message | Kevin Grittner | 2012-04-09 17:19:10 | Re: [JDBC] Regarding GSoc Application |