1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# 2021-09-29
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# Test cases for varying separator handling by group_concat().
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix windowC
ifcapable !windowfunc {
finish_test
return
}
do_execsql_test 1.0 {
CREATE TABLE x1(i INTEGER PRIMARY KEY, x);
}
foreach {tn bBlob seps} {
1 0 {a b c def g}
2 0 {abcdefg {} {} abcdefg}
3 0 {a bc def ghij klmno pqrstu}
4 1 {a bc def ghij klmno pqrstu}
5 1 {, , , , , , , , , , , , ....... , ,}
} {
foreach type {text blob} {
do_test 1.$type.$tn.1 {
execsql { DELETE FROM x1 }
foreach s $seps {
if {$type=="text"} {
execsql {INSERT INTO x1 VALUES(NULL, $s)}
} else {
execsql {INSERT INTO x1 VALUES(NULL, CAST ($s AS blob))}
}
}
} {}
foreach {tn2 win} {
1 "ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING"
2 "ROWS BETWEEN 2 PRECEDING AND CURRENT ROW"
3 "ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING"
} {
do_test 1.$type.$tn.2.$tn2 {
db eval "
SELECT group_concat('val', x) OVER ( ORDER BY i $win ) AS val FROM x1
" {
if {[string range $val 0 2]!="val"
|| [string range $val end-2 end]!="val"
} {
error "unexpected return value: $val"
}
}
} {}
}
}
}
# 2021-10-12 dbsqlfuzz 6c31db077a14149a7b22a1069294bdb068be8a96
#
reset_db
do_execsql_test 2.0 {
PRAGMA encoding=UTF16le;
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}
reset_db
do_execsql_test 2.1 {
PRAGMA encoding=UTF16be;
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
|