From: | Michael J Davis <michael(dot)j(dot)davis(at)tvguide(dot)com> |
---|---|
To: | "'Mark Dalphin'" <mdalphin(at)amgen(dot)com>, pgsql-general(at)postgreSQL(dot)org |
Subject: | RE: [GENERAL] Suggested "minor" change to psql |
Date: | 1999-12-08 18:27:41 |
Message-ID: | 93C04F1F5173D211A27900105AA8FCFC29949C@lambic.prevuenet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Try:
psql < mySchema.sql >& myOutput 2> myOutput.err
Michael Davis
BackOffice Development, TV Guide Networks
Office: 303-267-6809 Fax: 303-267-6889
Home Office: 303-460-7360 Fax: 303-460-7362
Pager: 303-461-4002
Email: Michael(dot)J(dot)Davis(at)tvguide(dot)com
> -----Original Message-----
> From: Mark Dalphin [SMTP:mdalphin(at)amgen(dot)com]
> Sent: Wednesday, December 08, 1999 11:04 AM
> To: pgsql-general(at)postgreSQL(dot)org
> Subject: [GENERAL] Suggested "minor" change to psql
>
> Hi,
>
> Ever since I began working with Postgres, I have had one little irritating
> problem with psql. It may be that I am mis-using this program; if so, my
> suggestion is not helpful, however, if others have encountered this
> problem,
> perhaps the developers can look at a fix for 7.0?
>
> When I develop a new DB schema using psql, I usually first create a file,
> say
> "mySchema.sql". I then "createdb" the database, start up psql, and use the
> command "\i mySchema.sql" to load in my new schema. There will be,
> needless to
> say, several errors. These fall nicely below the offending line and I can
> look
> at fixing them. I drop the DB, re-edit my SQL file and re-do the "\i"
> command.
>
> Sometimes, however, rather than using the "\i" command, I would like to
> simply
> load my schema directly into psql and capture the output on STDOUT (ie
> "psql <
> mySchema.sql >& myOutput"). The problem that arises is that the errors
> and
> notices all come out on STDERR. I am not sure this is the right choice.
> Because
> of the lack of synchronization between STDOUT and STDERR, it becomes
> impossible
> to associate an SQL statement with either a CREATE or an ERROR message.
> The
> option, "-e", is supposed to echo the query, but it doesn't help.
>
> While I can see wanting to separate STDERR and STDOUT when one uses psql
> to run
> an SQL query against a DB from within a shell script, it makes it much
> more
> difficult when developing, and if I were to run several SQL queries into
> psql,
> exactly the same association problem would occur.
>
> Perhaps a combination of the function "isatty()" plus the -e flag would
> work? So
> that if STDOUT "isatty()" then echo errors to STDOUT, otherwise send them
> to
> STDERR. And if the -e flag is set, echo the queries to STDERR, so the
> correlation between ERROR, CREATE, etc and SQL could be made.
>
> Just my $0.02.
>
> Mark
>
> PS I only recently learned of the setting of the PAGER environment
> variable to
> make it so I needn't scroll back up 400 lines to find my errors; perhaps
> this
> could be made more prominent in the documentation as it would be a big
> help.
> Then again, perhaps I should completely re-read the docs to see if this is
> mentioned; I haven't done that for several releases now.
>
> --
> Mark Dalphin email: mdalphin(at)amgen(dot)com
> Mail Stop: 29-2-A phone: +1-805-447-4951 (work)
> One Amgen Center Drive +1-805-375-0680 (home)
> Thousand Oaks, CA 91320 fax: +1-805-499-9955 (work)
>
>
>
>
> ************
From | Date | Subject | |
---|---|---|---|
Next Message | Sanchez Diaz Sonia | 1999-12-08 18:27:44 | Size of database |
Previous Message | Mark Dalphin | 1999-12-08 18:03:46 | Suggested "minor" change to psql |