On Fri, Nov 9, 2018 at 6:39 PM Kyotaro HORIGUCHI
<horiguchi.kyotaro@lab.ntt.co.jp> wrote:
> Mmm..I didn't get an error at hand on both CentOS7 and High Sierra.
>
> | $ perl -e 'for (my $i=0; $i< 1000000; $i++) { print "$i\n"; }' | head -5
> ...
> | 4
> | $ echo $?
> | 0
That's the exit code from head. You can see python or perl's exit
code by adding strace in front (on Linux):
$ strace python -c "for i in range(1000000): print i" | head -5
...
+++ exited with 1 +++
$ strace perl -e 'for (my $i=0; $i< 1000000; $i++) { print "$i\n"; }' | head -5
...
+++ killed by SIGPIPE +++
> create foreign table ft5 (a text) server svf1 options (program 'ruby -e "for i in 1..1000 do puts i; end"');
> select * from ft5 limit 5;
> a
> ---
> 1
> ...
> 5
> (5 rows)
> (no error)
1000 is not enough... due to buffering, it works. Try 1000000:
postgres=# create foreign table ft5 (a text) server svf1 options
(program 'ruby -e "for i in 1..1000000 do puts i; end"');
CREATE FOREIGN TABLE
postgres=# select * from ft5 limit 5;
ERROR: program "ruby -e "for i in 1..1000000 do puts i; end"" failed
DETAIL: child process exited with exit code 1
--
Thomas Munro
http://www.enterprisedb.com