SQLite

Check-in [38a1326b]
Login

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

Overview
Comment:Fix the group_concat() inverse function implementation so that it correctly handles BLOB inputs when database text encoding is UTF16.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 38a1326b4bd11bbe2846990d099c28520d17ab4cace1af67248c2472f89df929
User & Date: drh 2021-10-12 22:55:04
Context
2021-10-13
13:00
The sqlite3_result_text() routine (and similar) should record OOM errors in addition to SQLITE_TOOBIG errors. dbsqlfuzz (check-in: eca43436 user: drh tags: trunk)
2021-10-12
22:55
Fix the group_concat() inverse function implementation so that it correctly handles BLOB inputs when database text encoding is UTF16. (check-in: 38a1326b user: drh tags: trunk)
18:05
Fix an incorrect assert() in SQLITE_ENABLE_SORTER_REFERENCES logic - a new assert() introduced 5 days ago by [87e2f5eb436fc448]. (check-in: 7cfc839e user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/func.c.

1816
1817
1818
1819
1820
1821
1822




1823
1824
1825
1826
1827
1828
1829
1830
  assert( argc==1 || argc==2 );
  (void)argc;  /* Suppress unused parameter warning */
  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
  pGCC = (GroupConcatCtx*)sqlite3_aggregate_context(context, sizeof(*pGCC));
  /* pGCC is always non-NULL since groupConcatStep() will have always
  ** run frist to initialize it */
  if( ALWAYS(pGCC) ){




    int nVS = sqlite3_value_bytes(argv[0]);
    pGCC->nAccum -= 1;
    if( pGCC->pnSepLengths!=0 ){
      assert(pGCC->nAccum >= 0);
      if( pGCC->nAccum>0 ){
        nVS += *pGCC->pnSepLengths;
        memmove(pGCC->pnSepLengths, pGCC->pnSepLengths+1,
               (pGCC->nAccum-1)*sizeof(int));







>
>
>
>
|







1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
  assert( argc==1 || argc==2 );
  (void)argc;  /* Suppress unused parameter warning */
  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
  pGCC = (GroupConcatCtx*)sqlite3_aggregate_context(context, sizeof(*pGCC));
  /* pGCC is always non-NULL since groupConcatStep() will have always
  ** run frist to initialize it */
  if( ALWAYS(pGCC) ){
    int nVS;
    /* Must call sqlite3_value_text() to convert the argument into text prior
    ** to invoking sqlite3_value_bytes(), in case the text encoding is UTF16 */
    (void)sqlite3_value_text(argv[0]);
    nVS = sqlite3_value_bytes(argv[0]);
    pGCC->nAccum -= 1;
    if( pGCC->pnSepLengths!=0 ){
      assert(pGCC->nAccum >= 0);
      if( pGCC->nAccum>0 ){
        nVS += *pGCC->pnSepLengths;
        memmove(pGCC->pnSepLengths, pGCC->pnSepLengths+1,
               (pGCC->nAccum-1)*sizeof(int));

Changes to test/windowC.test.

58
59
60
61
62
63
64











65
66
              error "unexpected return value: $val"
            }
          }
      } {} 
    }
  }
}












finish_test







>
>
>
>
>
>
>
>
>
>
>


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
              error "unexpected return value: $val"
            }
          }
      } {} 
    }
  }
}

# 2021-10-12 dbsqlfuzz 6c31db077a14149a7b22a1069294bdb068be8a96
#
reset_db
do_execsql_test 2.0 {
  PRAGMA encoding=UTF16;
  WITH separator(x) AS (VALUES(',a,'),(',bc,')),
       value(y) AS (VALUES(1),(x'5585d09013455178cd11ce4a'))
  SELECT group_concat(y,x) OVER (ORDER BY x ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
  FROM separator, value;
} {{} 1 蕕郐䔓硑ᇍ䫎 1}

finish_test