Index: src/func.c ================================================================== --- src/func.c +++ src/func.c @@ -1539,11 +1539,13 @@ } if( nSep ) sqlite3StrAccumAppend(pAccum, zSep, nSep); } zVal = (char*)sqlite3_value_text(argv[0]); nVal = sqlite3_value_bytes(argv[0]); - if( nVal ) sqlite3StrAccumAppend(pAccum, zVal, nVal); + if( nVal || (zVal="", firstTerm) ){ + sqlite3StrAccumAppend(pAccum, zVal, nVal); + } } } static void groupConcatFinalize(sqlite3_context *context){ StrAccum *pAccum; pAccum = sqlite3_aggregate_context(context, 0); Index: test/func.test ================================================================== --- test/func.test +++ test/func.test @@ -1192,10 +1192,22 @@ execsql { SELECT group_concat(CASE t1 WHEN 'this' THEN '' WHEN 'program' THEN null ELSE t1 END) FROM tbl1 } } {,is,free,software} +# Tests to verify ticket http://www.sqlite.org/src/tktview/55746f9e65f8587c0 +do_test func-24.13 { + execsql { + SELECT typeof(group_concat(x)) FROM (SELECT '' AS x); + } +} {text} +do_test func-24.14 { + execsql { + SELECT typeof(group_concat(x,'')) + FROM (SELECT '' AS x UNION ALL SELECT ''); + } +} {text} # Use the test_isolation function to make sure that type conversions # on function arguments do not effect subsequent arguments. #