Please take this survey to help us learn more about how you use third party tools. Your input is greatly appreciated!

vsql exit status for "No such file or directory"

Please add non zero exit status for vsql if specified file is not exists

$ vsql -f nonexisting.sql && echo OK || echo FAIL
nonexisting.sql: No such file or directory
OK

Same problem with included files

$ vsql -a -f error.sql && echo OK || echo FAIL
\set ON_ERROR_STOP on
\i nonexisting.sql
vsql:error.sql:2: nonexisting.sql: No such file or directory
select 2;
 ?column?
----------
        2
(1 row)

OK

vsql continues execution without stopping

Answers

  • Jim_KnicelyJim_Knicely Administrator

    Maybe check if the file exists prior to running vsql?

    Example:

    [[email protected] ~]$ FILE=/home/dbadmin/run_me.sql
    
    [[email protected] ~]$ ll $FILE
    ls: cannot access '/home/dbadmin/run_me.sql': No such file or directory
    
    [[email protected] ~]$ [ -f $FILE ] && vsql -f $FILE || echo "$FILE does not exist."
    /home/dbadmin/run_me.sql does not exist.
    
    [[email protected] ~]$ echo "SELECT 1 AS some_column;" > $FILE
    
    [[email protected] ~]$ [ -f $FILE ] && vsql -f $FILE || echo "$FILE does not exist."
     some_column
    -------------
               1
    (1 row)
    
  • Maybe check if the file exists prior to running vsql?

    1. We do that. But this is workaround. And such trick didn't saves us if file became unavailable after check and before vsql starts.
    2. What about included files? Same problem. We do another check via parsing of output. But this is weird.
      Process must return correct exit code. All programs do that.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.