[Monetdb-developers] [PATCH] MapiClient bugfix && copy from stdin
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.
On Wed, Aug 09, 2006 at 03:13:13PM -0400, Luis Zarrabeitia wrote:
I wanted to open a feature request for this, but it seems I forgot my sourceforge password.
Many thanks for your patches.
I attach two patches (cvs -uN):
I aplied the interactive patch. Not the '.' copyfrom patch, as it changes a sql specific issue in MapiClient which is a more general tool (also for xquery and mil/mal). I made some more changes in the sql frontend and ascii_io library to solve the proces | MapiClient problem with out '.' (just end of file should do).
Niels
===== 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.
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&da... _______________________________________________ Monetdb-developers mailing list Monetdb-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-developers
Many thanks for your patches.
A pleasure.
I attach two patches (cvs -uN):
I aplied the interactive patch.
Cool!
Not the '.' copyfrom patch, as it changes a sql specific issue in MapiClient which is a more general tool (also for xquery and mil/mal). I made some more changes in the sql frontend and ascii_io library to solve the proces | MapiClient problem with out '.' (just end of file should do).
I imagined that . could cause some semantic trouble. I went ahead anyway because I wanted "myprocess |" (or a "cat myfile |") to be able to execute more than one copyfrom and . seemed a good choice (postgres). I shouldn't have touched the MapiClient, though. I like that you fixed it. Would be acceptable to introduce the . without touching the MapiClient? (changes could be confined to ascii_io.mx)
Niels
Zarrabeitia.
On 16-08-2006 17:30:30 -0400, Luis Zarrabeitia wrote:
I imagined that . could cause some semantic trouble. I went ahead anyway because I wanted "myprocess |" (or a "cat myfile |") to be able to execute more than one copyfrom and . seemed a good choice (postgres). I shouldn't have touched the MapiClient, though. I like that you fixed it. Would be acceptable to introduce the . without touching the MapiClient? (changes could be confined to ascii_io.mx)
In fact, the PostgreSQL dump format contains other things like \NULL or \0 (not sure which one) together with the . to "terminate" the dump. Supporting this (in the back-end) probably means writing/patching another ascii_io called postgres_io or something :) I haven't looked into it too deep, but maybe this is for now with the current state one bridge too far.
On Wed, Aug 16, 2006 at 05:30:30PM -0400, Luis Zarrabeitia wrote:
Not the '.' copyfrom patch, as it changes a sql specific issue in MapiClient which is a more general tool (also for xquery and mil/mal). I made some more changes in the sql frontend and ascii_io library to solve the proces | MapiClient problem with out '.' (just end of file should do).
I imagined that . could cause some semantic trouble. I went ahead anyway because I wanted "myprocess |" (or a "cat myfile |") to be able to execute more than one copyfrom and . seemed a good choice (postgres). I shouldn't have touched the MapiClient, though. I like that you fixed it. Would be acceptable to introduce the . without touching the MapiClient? (changes could be confined to ascii_io.mx)
Adding the '.' handling in ascii_io sounds fine with me. As long as its only an extra bonus, ie ascii_io should end with reaching the number of records, end of file or hitting . (be sure to see if it doesn't give problems with single non quoted string columns.
Niels
Niels
Zarrabeitia.
participants (3)
-
Fabian Groffen
-
Luis Zarrabeitia
-
Niels Nes