okbob / pspg

Unix pager (with very rich functionality) designed for work with tables. Designed for PostgreSQL, but MySQL is supported too. Works well with pgcli too. Can be used as CSV or TSV viewer too. It supports searching, selecting rows, columns, or block and export selected area to clipboard.
BSD 2-Clause "Simplified" License
2.43k stars 85 forks source link

segfault when watching non existing --querystream file #222

Closed ahirner closed 1 year ago

ahirner commented 1 year ago

Repro:

$ pspg --querystream -f doesnotexist -w 2
cannot to open file "doesnotexist" (No such file or directory)
pspg crashed by signal 11
Segmentation fault: 11
okbob commented 1 year ago

should be fixed by c4f743444fe09db61979feb860330c4f90d6d7ec commit, please check

ahirner commented 1 year ago

Thanks! It doesn't crash on a non existing file. Watching an existing file at fixed time intervals also works now. This is great!

One edge case: when the file doesn't exist at first, but is created after the error displays, the file's contents aren't picked up.

I got a crude patch that makes this work, and also if you only want to watch for changes with kqueue/inotify (--querystream -f query.sql): https://github.com/ahirner/nix-trickle/blob/main/patches/pspg.patch

So far it works for me, but I'm not sure if the fix is correct and elegant. I can file another issue, if you like.

okbob commented 1 year ago

bba16a3943f1eb9884d9a74e12488c40c81c89b8 should to fix it. Please, check

ahirner commented 1 year ago

That fixed it