Thread: Re: why -Fdance archive format option works with ./pg_restore but not with ./pg_dump?

./pg_dump postgres -Fp -f textdump

./pg_restore -Fp -d postgres textdump
pg_restore: error: unrecognized archive format "p"; please specify "c", "d", or "t"

./pg_restore -d postgres textdump
pg_restore: error: input file appears to be a text format dump. Please use psql.

wouldn't it be nice if we get the error message as same as when we didn't gave format option and pg_restore finds the format using _discoverArchiveFormat there it suggests to try psql ,instead of saying "p/plain text" format is a invalid format,as we are doing currently in pg.

thoughts?

Regards,
Srinath Reddy Sadipiralla,
On 2025-01-25 Sa 8:12 AM, Srinath Reddy wrote:
> ./pg_dump postgres -Fp -f textdump
>
> ./pg_restore -Fp -d postgres textdump
> pg_restore: error: unrecognized archive format "p"; please specify 
> "c", "d", or "t"
>
> ./pg_restore -d postgres textdump
> pg_restore: error: input file appears to be a text format dump. Please 
> use psql.
>
> wouldn't it be nice if we get the error message as same as when we 
> didn't gave format option and pg_restore finds the format 
> using _discoverArchiveFormat there it suggests to try psql ,instead of 
> saying "p/plain text" format is a invalid format,as we are doing 
> currently in pg.
>
> thoughts?
>


Probably not exactly the same, because in one case you're explicitly 
saying it's a text dump. But maybe something closer would work, like

    "text format not supported. Please use psql."


cheers


andrew

-- 

Andrew Dunstan
EDB: https://www.enterprisedb.com




Srinath Reddy <srinath2133@gmail.com> writes:
> wouldn't it be nice if we get the error message as same as when we didn't
> gave format option and pg_restore finds the format
> using _discoverArchiveFormat there it suggests to try psql ,instead of
> saying "p/plain text" format is a invalid format,as we are doing currently
> in pg.

Good idea.  I pushed your patch with that addition.

            regards, tom lane



Thanks Tom and Andrew.

Regards,
Srinath Reddy Sadipiralla,

On Sat, Jan 25, 2025 at 9:55 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Srinath Reddy <srinath2133@gmail.com> writes:
> wouldn't it be nice if we get the error message as same as when we didn't
> gave format option and pg_restore finds the format
> using _discoverArchiveFormat there it suggests to try psql ,instead of
> saying "p/plain text" format is a invalid format,as we are doing currently
> in pg.

Good idea.  I pushed your patch with that addition.

                        regards, tom lane