Skip to main content

howto make vsql return a non-zero RC when error in SQL file name?

  • July 12, 2017
  • 4 replies
  • 9 views

peterjansens
Forum|alt.badge.img

interesting question from a current Vertica customer: when i execute
vsql -f nonexistentfile.sql
the vsql proces returns a zero RC, indicating all is well, while trying to execute a non-existent SQL file can be perceived as an error. Is there a (relatively easy) way to have vsql flag this error to the calling script?

4 replies

skeswani
Forum|alt.badge.img
  • Participating Frequently
  • July 12, 2017

[skeswani@skeswani vertica] [@:/]$ function v() { if [ -e "${1}" ];then vsql -X -v ON_ERROR_STOP=1 -f "${1}" ;else return 1; fi }; v file.sql
[skeswani@skeswani vertica] [@:/]$ echo $?
1


Car1os
Forum|alt.badge.img
  • Participating Frequently
  • July 12, 2017

I think this is a bug, it shouldn't return 0.


skeswani
Forum|alt.badge.img
  • Participating Frequently
  • July 12, 2017

agreed, VER-40945


peterjansens
Forum|alt.badge.img
  • Author
  • Participating Frequently
  • July 13, 2017

Agreed and thanks very much!
Sumeet, thank you for the workaround....