Re: [PATCH] initdb: Treat empty -U argument as unset username - Mailing list pgsql-hackers

From Dagfinn Ilmari Mannsåker
Subject Re: [PATCH] initdb: Treat empty -U argument as unset username
Date
Msg-id 87wm8q3crt.fsf@wibble.ilmari.org
Whole thread Raw
In response to [PATCH] initdb: Treat empty -U argument as unset username  (Jianghua Yang <yjhjstz@gmail.com>)
Responses Re: [PATCH] initdb: Treat empty -U argument as unset username
List pgsql-hackers
Jianghua Yang <yjhjstz@gmail.com> writes:

> - A regression test is added to `src/bin/initdb/t/001_initdb.pl` to verify
> that the case `initdb -U ''` fails as expected.
[ ... ]
> diff --git a/src/bin/initdb/t/001_initdb.pl b/src/bin/initdb/t/001_initdb.pl
> index 15dd10ce40a..67eb53064f6 100644
> --- a/src/bin/initdb/t/001_initdb.pl
> +++ b/src/bin/initdb/t/001_initdb.pl
> @@ -37,6 +37,10 @@ command_fails(
>  command_fails([ 'initdb', '--username' => 'pg_test', $datadir ],
>      'role names cannot begin with "pg_"');
>  
> +command_fails(
> +    [ 'initdb', '-U', '', $datadir ],
> +    'empty username not allowed');
> +

This only tests that it fails, not that it fails as expected.  It should
use command_fails_like() to check that stderr contains the expected
error.  Also, it shoud use => between the -U option and its argument, as
seen in the above test with --username.

- ilmari



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Add progressive backoff to XactLockTableWait functions
Next
From: jian he
Date:
Subject: Re: gcc 15 "array subscript 0" warning at level -O3