Multiple psql -c / -f options - Mailing list pgsql-hackers

From Jim Nasby
Subject Multiple psql -c / -f options
Date
Msg-id 52606D34.3070506@nasby.net
Whole thread Raw
Responses Re: Multiple psql -c / -f options  (Fabien COELHO <coelho@cri.ensmp.fr>)
List pgsql-hackers
IMHO the current behavior is broken:

decibel@decina:[17:46]~/pgsql/HEAD/i$bin/psql -c 'select 1' -c 'select 2' ?column?
----------        2
(1 row)


I would expect psql to either run both commands or throw an error.

What I'd personally prefer is that psql execute -c and -f (and arguably -v) in the order they're encountered, within
thesame session. I realize you can get the same behavior by creating a .sql file, but for simple needs that's sometimes
morehassle than it's worth.
 

If we don't want to support that, we should throw an error if we encounter more than one -c|-f. Not doing so allows for
subtle,silent breakage.
 

Related to this, there's a bunch of other options that should only be allowed once (ie: -d).

BTW, why do we special-case -? and -V at the top of main?
if (argc > 1){    if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)    {        usage();
exit(EXIT_SUCCESS);   }    if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)    {
showVersion();       exit(EXIT_SUCCESS);    }}
 
-- 
Jim C. Nasby, Data Architect                       jim@nasby.net
512.569.9461 (cell)                         http://jim.nasby.net



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: signed vs. unsigned in TYPEALIGN (was Re: space reserved for WAL record does not match what was written: panic on windows)
Next
From: Jaime Casanova
Date:
Subject: Re: Turning recovery.conf into GUCs