VSQL command does not return exit code -1 even if it fails internally

I have a use-case where i am executing .vsql query using VSQL Client . Even if the query fails for whatever reason for example -
ERROR 4568: Relation "xxx.xxx" does not exist

Still it is returning exit status 0 which is incorrect , could anyone please tell me what is the solution to handle this ?



  • Options
    DaveTDaveT Vertica Employee Employee

    If you are using "vsql -c" then you should get an exit code of 1 for the single statement that failed. If you are using something like "vsql << eof" to run multiple statements then you can use "\set ON_ERROR_STOP on" or \set ON_ERROR_STOP off" depending on whether you want the script to fail or not at that point. While ON_ERROR_STOP is toggled to "on" vsql will terminate on a SQL statement error and you will get an exit code of 3. There was a Vertica tip just shared on the use of ON_ERROR_STOP:

Leave a Comment

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