/ 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 Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/func.c.

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

Changes to test/window6.test.

   205    205     SELECT SUM("value") OVER 
   206    206     (ORDER BY "id" ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) 
   207    207       FROM "sample" 
   208    208     ORDER BY "id"
   209    209   } {
   210    210     10.0   30.0   31.0   24.0   104.0
   211    211   }
          212  +
          213  +do_execsql_test 9.0 {
          214  +  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)
          215  +  SELECT x, group_concat(x) OVER (ORDER BY x ROWS 2 PRECEDING)
          216  +  FROM c;
          217  +} {
          218  +  1 1  2 1,2  3 1,2,3  4 2,3,4  5 3,4,5
          219  +}
   212    220   
   213    221   finish_test