/ Check-in [73391283]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a problem in the xInverse method of window-function group_concat(1).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:73391283101288251fe5d030ba12bcdabe8a781d41086afe3564c58c05d0fd5c
User & Date: dan 2018-07-05 18:19:29
Context
2018-07-05
18:34
Return an error if a "RANGE" window-frame uses "<expr> PRECEDING" or "<expr> FOLLOWING". check-in: 786c87ba user: dan tags: trunk
18:19
Fix a problem in the xInverse method of window-function group_concat(1). check-in: 73391283 user: dan tags: trunk
17:35
Fix the .dump command in the command-line shell so that it does not show extraneous SELECT statements when ".echo on" is enabled. check-in: 11763cac user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/func.c.

1724
1725
1726
1727
1728
1729
1730


1731
1732
1733
1734
1735
1736
1737
  StrAccum *pAccum;
  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
  pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));
  if( pAccum ){
    n = sqlite3_value_bytes(argv[0]);
    if( argc==2 ){
      n += sqlite3_value_bytes(argv[1]);


    }
    if( n>=pAccum->nChar ){
      pAccum->nChar = 0;
    }else{
      pAccum->nChar -= n;
      memmove(pAccum->zText, &pAccum->zText[n], pAccum->nChar);
    }







>
>







1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
  StrAccum *pAccum;
  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
  pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));
  if( pAccum ){
    n = sqlite3_value_bytes(argv[0]);
    if( argc==2 ){
      n += sqlite3_value_bytes(argv[1]);
    }else{
      n++;
    }
    if( n>=pAccum->nChar ){
      pAccum->nChar = 0;
    }else{
      pAccum->nChar -= n;
      memmove(pAccum->zText, &pAccum->zText[n], pAccum->nChar);
    }

Changes to test/window6.test.

205
206
207
208
209
210
211
212








213
  SELECT SUM("value") OVER 
  (ORDER BY "id" ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) 
    FROM "sample" 
  ORDER BY "id"
} {
  10.0   30.0   31.0   24.0   104.0
}









finish_test








>
>
>
>
>
>
>
>

205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
  SELECT SUM("value") OVER 
  (ORDER BY "id" ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) 
    FROM "sample" 
  ORDER BY "id"
} {
  10.0   30.0   31.0   24.0   104.0
}

do_execsql_test 9.0 {
  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
  SELECT x, group_concat(x) OVER (ORDER BY x ROWS 2 PRECEDING)
  FROM c;
} {
  1 1  2 1,2  3 1,2,3  4 2,3,4  5 3,4,5
}

finish_test