[Monetdb-developers] [ monetdb-Bugs-2787825 ] mclient: stdin + statement

Sjoerd Mullender sjoerd at acm.org
Thu Jul 23 13:01:01 CEST 2009


I'll repeat: You cannot start a query with -s and finish it on stdin.

A semicolon is added automatically by mclient, but that is immaterial
since you cannot start a query with -s and finish it on stdin.

Wouter Alink wrote:
> To get back to the original issue:
> 
> $ cat data.dat
> 1
> 2
> 3
> 4
> 5
> $ N=4; head -n $N data.dat | mclient -lsql -p50151 -dtest -s "copy $N
> records into aap from STDIN;"
> 
> Am i correct in that the above is not allowed, because it doesn't
> specify "-i", so it won't read stdin after "-s"? This is indeed what I
> would expect. Initially I wasn't aware of the "-i" feature, that was
> the reason for the original request.
> 
> But it confuses me that even with specifying "-i" it wouldn't be
> correct, as the copy command should not be followed by a semi-colon?
> This seems odd to me, why is a semi-colon not allowed? Am I missing
> something?
> 
> Wouter
> 
> 
> 2009/7/23 Sjoerd Mullender <sjoerd at acm.org>:
>> Wouter Alink wrote:
>>> The bug (#2787825) seems to be closed for comments, but I think this
>>> bug should not be closed until the documentation gets updated.
>>>
>>> typing "man mclient" on the stable branch tells me:
>>>
>>> --statement=stmt (-s stmt)
>>>     Execute the specified query. The query is run before any queries
>>> from files specified on the command line are run, and before the
>>> interactive session is started (if the --interactive option is given).
>>>
>>> This is not in line with Martin's latest comment. Martin, could you
>>> re-open the bug (I don't have the permissions to do so)?
>> Standard input is not ignored if the -i (--interactive) flag is passed.
>>  However, you cannot start a query with -s and finish it from stdin
>> which is what you originally wanted.  And I don't see in the
>> documentation that you can.  If you see it, please point it out.
>>
>> As far as I can see, the text you quoted above is correct.
>>
>>> Greetings,
>>> Wouter
>>>
>>>
>>>
>>> 2009/7/20 SourceForge.net <noreply at sourceforge.net>:
>>>> Bugs item #2787825, was opened at 2009-05-06 14:21
>>>> Message generated for change (Comment added) made by mlkersten
>>>> You can respond by visiting:
>>>> https://sourceforge.net/tracker/?func=detail&atid=482468&aid=2787825&group_id=56967
>>>>
>>>> Please note that this message will contain a full copy of the comment thread,
>>>> including the initial issue submission, for this request,
>>>> not just the latest update.
>>>> Category: Mapi
>>>> Group: Clients CVS Head
>>>>> Status: Closed
>>>>> Resolution: Wont Fix
>>>> Priority: 5
>>>> Private: No
>>>> Submitted By: Wouter Alink (vzzzbx)
>>>> Assigned to: Nobody/Anonymous (nobody)
>>>> Summary: mclient: stdin + statement
>>>>
>>>> Initial Comment:
>>>> It seems that there is a  problem with both providing data via stdin and via the -s feature in mclient.  (see example below).
>>>>
>>>> A possible solution could perhaps be to forbid this use. Another solution would be to define a behaviour: either read the '-s' first or the stdin first. (perhaps this already is the case, but I couldn't find any documentation about it)
>>>>
>>>> $ cat data.dat
>>>> 1
>>>> 2
>>>> 3
>>>> 4
>>>> 5
>>>> $ N=4; head -n $N data.dat | mclient -lsql -p50151 -dtest -s "copy $N records into aap from STDIN;"
>>>> MAPI  = monetdb at localhost:50151
>>>> QUERY = copy 4 records into aap from STDIN;
>>>> ERROR = !SQLException:sql:value ';' while parsing ';' from line 0 field 0 not inserted, expecting type int
>>>>        !SQLException:importTable:failed to import table
>>>>
>>>>
>>>> ----------------------------------------------------------------------
>>>>
>>>>> Comment By: Martin Kersten (mlkersten)
>>>> Date: 2009-07-20 21:48
>>>>
>>>> Message:
>>>> Standard input is ignored in combination with -s.
>>>> Closing it as at best it can be considered a niche feature request.
>>>>
>>>> ----------------------------------------------------------------------
>>>>
>>>> Comment By: Wouter Alink (vzzzbx)
>>>> Date: 2009-05-07 21:55
>>>>
>>>> Message:
>>>> as discussed on the monetdb-users list, using either the -s _or_ the stdin
>>>> works fine (except for other reported/unreported bugs), but the combination
>>>> fails. (stefan's example works fine).
>>>>
>>>> I can very well imagine that using a combination should not be allowed
>>>> (and should not even become a feature request), but I feel that the current
>>>> message is not very helpful.
>>>>
>>>> And, actually (I hadn't thought of this option before), if I would have
>>>> specified "-i" then the documentation (mclient --help) says it reads from
>>>> stdin _after_ reading the command line args, but it generates the same
>>>> error.
>>>>
>>>> After some more tests I discovered that:
>>>> - when using the command line args + stdin + mentioning '-i', the
>>>> semi-colon after "copy $N records into aap from STDIN;" should be left out,
>>>> so the following does work:
>>>>
>>>> $ echo "1
>>>> 2
>>>> 3
>>>> 4
>>>> 5" | mclient -lsql -dtest -hskadi -p50151 -i -s "COPY 5 RECORDS INTO aap
>>>> FROM STDIN"
>>>>
>>>> (notice the omission of ';' after the COPY statement)
>>>>
>>>> If I do exactly the same, but leave out the '-i', no error is displayed,
>>>> but nothing gets inserted either.
>>>>
>>>> If I use only stdin only:
>>>>
>>>> $ echo "COPY 5 RECORDS INTO aap FROM STDIN;
>>>> 1
>>>> 2
>>>> 3
>>>> 4
>>>> 5" | mclient -lsql -dtest -hskadi -p50151
>>>>
>>>> then this works (only if the ';' after the COPY statement is present).
>>>>
>>>> I don't know whether there are two different bugs mentioned in this
>>>> explanation, but I think there definitely is something wrong.
>>>>
>>>> by the way: the create statement for aap is: "CREATE TABLE aap (x int);"
>>>>
>>>> ----------------------------------------------------------------------
>>>>
>>>> Comment By: Stefan Manegold (stmane)
>>>> Date: 2009-05-07 19:30
>>>>
>>>> Message:
>>>> What about:
>>>>
>>>> { N=4 ; echo "copy $N records into aap from STDIN;" ; head -n $N data.dat
>>>> ; } | mclient -lsql -p50151 -dtest
>>>>
>>>> ?
>>>>
>>>>
>>>> ----------------------------------------------------------------------
>>>>
>>>> Comment By: Sjoerd Mullender (sjoerd)
>>>> Date: 2009-05-07 14:26
>>>>
>>>> Message:
>>>> Where does it say that this is supported?
>>>> If it doesn't say anywhere, this is a feature request, not a bug.
>>>>
>>>> ----------------------------------------------------------------------
>>>>
>>>> You can respond by visiting:
>>>> https://sourceforge.net/tracker/?func=detail&atid=482468&aid=2787825&group_id=56967
>>>>
>>> ------------------------------------------------------------------------------
>>> _______________________________________________
>>> Monetdb-developers mailing list
>>> Monetdb-developers at lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/monetdb-developers
>>
>> --
>> Sjoerd Mullender
>>
>>


-- 
Sjoerd Mullender

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 369 bytes
Desc: OpenPGP digital signature
URL: <http://www.monetdb.org/pipermail/developers-list/attachments/20090723/d9266900/attachment.sig>


More information about the developers-list mailing list