Menu

#4 Redirection should affect output, not messages

open
None
5
2004-10-21
2004-07-08
Ed Avis
No

set showplan on
go
select 5
go >out

I expected this to print the query results to the file
'out' and the query plan messages to the console. But
they both go to the file.

Discussion

  • DavidZ

    DavidZ - 2004-08-17

    Logged In: YES
    user_id=1102906

    I'm going to have to disagree on this one - I would expect
    both the query results and the query output to go to the file.

     
  • DavidZ

    DavidZ - 2004-08-17

    Logged In: YES
    user_id=1102906

    I'm going to have to disagree on this one - I would expect
    both the query results and the query output to go to the file.

     
  • Ed Avis

    Ed Avis - 2004-08-17

    Logged In: YES
    user_id=10769

    I think it is analogous to running a command from the shell:

    % foo >out

    output from foo goes to 'out', but messages printed on
    stderr still go to the terminal.

    After all, the showplan messages are not part of the query
    results, they're not rows and columns and they can't be
    processed in the same way (eg when you use 'go -m bcp', the
    bcp formatting does not affect the showplan output... this
    suggests to me that showplan should be treated separately
    and go somewhere else).

     
  • DavidZ

    DavidZ - 2004-08-17

    Logged In: YES
    user_id=1102906

    I agree that output messages should be directed to stdout
    and error messages should be directed to stderr. The
    question is ... Are showplan messages "output" or
    "error"? I believe they are output and not error.

    The following section of a bourne shell script puts all the
    messages from sqsh in stdout (file sqsh.out) and nothing in
    stderr (file sqsh.err).

    sqsh -Se0acg11_srvr -P - -Uusername <<-END 1>sqsh.out
    2>sqsh.err
    thepassword
    set showplan on
    go
    select 5
    go
    END

    The authors of isql similarly placed showplan output in
    stdout and not in stderr.

    Given that perspective, I would expect the following script
    segment to put nothing in stdout (sqsh.out2), nothing in
    stderr (sqsh.err2), but everything in the redirected output
    (sqsh.out3). That's what I expected and that's what sqsh did.

    sqsh -Se0acg11_srvr -P - -Uusername <<-END 1>sqsh.out2
    2>sqsh.err2
    thepassword
    set showplan on
    go
    select 5
    go > sqsh.out3
    END

     
  • Ed Avis

    Ed Avis - 2004-08-18

    Logged In: YES
    user_id=10769

    My feeling is that showplan messages are 'chatter' which is
    somewhere between output and error, but most of the time,
    you don't want them mixed up with the output. 'Output' is
    meant to follow a consistent format (eg go -m bcp), while
    'error' or 'chatter' is free text intended for a human to read.

    There are some Unix or GNU programs which normally follow
    'no news is good news' but you can run them with a --verbose
    flag or equivalent, in these cases the chatter messages go
    to stderr, even though you explicitly asked for them.

    I think the isql authors got it wrong, however, if you feel
    otherwise could I request this as a feature enhancement? I
    would find it useful for query debugging to put the output
    somewhere (often /dev/null) but print the showplan and
    'statistics io' output to the terminal. I am not sure of
    the best syntax, if you think that >x should redirect all
    three things; perhaps o>x to redirect only the query results
    to file x.

     
  • Michael Peppler

    Michael Peppler - 2004-10-21
    • assigned_to: nobody --> mpeppler
     

Log in to post a comment.