Re: [sqlite] GROUP_CONCAT with DISTINCT bug

2018-01-02 Thread Cezary H. Noweta
Hello, On 2018-01-03 01:44, Cezary H. Noweta wrote: MySQL has a separator specified by a distinct clause. I'm sorry -- I meant ``distinct'' == ``separate/different'' (a clause named ``SEPARATOR''). Not to be confused with ``DISTINCT'' clause in SQLite's ``group_concat(DISTINCT...)''. --

Re: [sqlite] GROUP_CONCAT with DISTINCT bug

2018-01-02 Thread petern
Scott. I almost forgot about this example. Consider group_concat's orthogonal function group_replace. I adapted this from SQLite replace and group_concat. The author disclaims all rights to the following code: --- struct StrRepl { const unsigned char* zStr; u32 nStr; u8

Re: [sqlite] GROUP_CONCAT with DISTINCT bug

2018-01-02 Thread Scott Robison
On Tue, Jan 2, 2018 at 5:46 PM, petern wrote: > Hi Scott. > >>Are there other aggregate functions that take multiple arguments? > > Absolutely. I've got a few in my code which deserialize table rows into > runtime objects. Fortunately, the DISTINCT filter makes no

Re: [sqlite] GROUP_CONCAT with DISTINCT bug

2018-01-02 Thread petern
Hi Scott. >Are there other aggregate functions that take multiple arguments? Absolutely. I've got a few in my code which deserialize table rows into runtime objects. Fortunately, the DISTINCT filter makes no sense in that use case, so I didn't bump into this issue myself. If you're looking

Re: [sqlite] GROUP_CONCAT with DISTINCT bug

2018-01-02 Thread Cezary H. Noweta
Hello, On 2018-01-03 00:02, Tony Papadimitriou wrote: MySQL does not seem to have a problem with it. MySQL has a separator specified by a distinct clause. In SQLite it is specified by a second expression, which, in a canonical and intuitive point of view, is a constant string. However it

Re: [sqlite] GROUP_CONCAT with DISTINCT bug

2018-01-02 Thread Scott Robison
On Tue, Jan 2, 2018 at 4:15 PM, petern wrote: > Hi Tony. Good. Yes, simpler test case is always better when posting > possible bugs. > > Unfortunately, as Cezary points out, this error is by design (from > select.c): > >if( pFunc->iDistinct>=0 ){ > Expr *pE

Re: [sqlite] GROUP_CONCAT with DISTINCT bug

2018-01-02 Thread petern
Hi Tony. Good. Yes, simpler test case is always better when posting possible bugs. Unfortunately, as Cezary points out, this error is by design (from select.c): if( pFunc->iDistinct>=0 ){ Expr *pE = pFunc->pExpr; assert( !ExprHasProperty(pE, EP_xIsSelect) ); if(

Re: [sqlite] GROUP_CONCAT with DISTINCT bug

2018-01-02 Thread Tony Papadimitriou
MySQL does not seem to have a problem with it. -Original Message- From: Scott Robison On Tue, Jan 2, 2018 at 1:36 PM, Tony Papadimitriou wrote: create table t(s); insert into t values ('A'),('A'),('B'); select group_concat(s,', ') from t group by null; --

Re: [sqlite] GROUP_CONCAT with DISTINCT bug

2018-01-02 Thread Tony Papadimitriou
Even simpler, then... select group_concat(distinct 1,','); -Original Message- From: petern Simpler one line test case also parses incorrectly: WITH t(c) AS (VALUES (1)) SELECT group_concat(DISTINCT c) FROM t; "group_concat(DISTINCT c)" 1 WITH t(c) AS (VALUES (1)) SELECT

Re: [sqlite] GROUP_CONCAT with DISTINCT bug

2018-01-02 Thread Cezary H. Noweta
Hello, On 2018-01-02 22:39, Scott Robison wrote: On Tue, Jan 2, 2018 at 1:36 PM, Tony Papadimitriou wrote: create table t(s); insert into t values ('A'),('A'),('B'); select group_concat(s,', ') from t group by null; -- OK select group_concat(distinct s) from t group

Re: [sqlite] GROUP_CONCAT with DISTINCT bug

2018-01-02 Thread petern
Simpler one line test case also parses incorrectly: WITH t(c) AS (VALUES (1)) SELECT group_concat(DISTINCT c) FROM t; "group_concat(DISTINCT c)" 1 WITH t(c) AS (VALUES (1)) SELECT group_concat(DISTINCT c,',') FROM t; Error: DISTINCT aggregates must have exactly one argument On Tue, Jan 2, 2018

Re: [sqlite] GROUP_CONCAT with DISTINCT bug

2018-01-02 Thread Scott Robison
On Tue, Jan 2, 2018 at 1:36 PM, Tony Papadimitriou wrote: > create table t(s); > insert into t values ('A'),('A'),('B'); > > select group_concat(s,', ') from t group by null; -- OK > select group_concat(distinct s) from t group by null; -- OK > select

[sqlite] GROUP_CONCAT with DISTINCT bug

2018-01-02 Thread Tony Papadimitriou
create table t(s); insert into t values ('A'),('A'),('B'); select group_concat(s,', ') from t group by null; -- OK select group_concat(distinct s) from t group by null; -- OK select group_concat(distinct s,', ') from t group by null; -- ERROR -- The moment the optional delimiter