I wanted to open a feature request for this, but it seems I forgot my sourceforge password.
I attach two patches (cvs -uN):
===== interactive.patch It fixes what I would consider a bug in MapiClient: if the '-s' and '-i' switches are both given, and the argument to '-s' is not finished in the command line (mid->active is not null, i.e, if the -s is a copyfrom construct), MapiClient will segfault instead of finishing the command from stdin.
before: $ MapiClient -l sql -i -s "copy 1 records into v from stdin" sql>dfjk Segmentation fault
after: $ MapiClient -l sql -i -s "copy 1 records into v from stdin" more>dfjk [ 1 ] sql>
There is a remaining issue if the copyfrom ends in a semicolon in the -s switch, because MapiClient will insert another semicolon after that... I did not touch that piece of code buecasue from thhe comments around it, it seemed like it was done on purpose.
======= copyfrom.patch Allows a copy from stdin without specifying the number of records. End of input will be marked with a '.' on an empty line, as in postgres. Additionally, if stdin ends (or a ctrl-D is received), MapiClient will feed the end-of-input to the backend. =====
Thus, with both patches applied, it should be now possible to do
myprocess | MapiClient -l sql -i -s "copy into v from stdin"
If interactive is not applied, it should still be possible to do:
( echo "copy into v from stdin;"; myprocess ) | MapiClient -l sql
Please tell me how to proceed.
Cheers,
Zarrabeitia.