0
0
mirror of https://github.com/sqlite/sqlite.git synced 2024-11-25 08:59:33 +01:00
sqlite/test/gcfault.test
drh d5e040b6f0 Add string_agg(X,Y) as an alias for group_concat(X,Y), for compatibility
with SQLServer and PG.

FossilOrigin-Name: b91c19bf2680f60d7826ab5d9e7902e2dc2a55d847bbea565a6489d47f2cc8f1
2023-10-20 20:19:30 +00:00

57 lines
1.5 KiB
Plaintext

# 2016 December 30
#
# 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.
#
#***********************************************************************
# This file implements regression tests for SQLite library. The
# focus of this file is testing OOM error handling within the built-in
# group_concat() and string_agg() functions.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix gcfault
foreach {enc} {
utf16
utf8
} {
reset_db
sqlite3_db_config_lookaside db 0 0 0
execsql "PRAGMA encoding = $enc"
do_execsql_test 1.$enc.1 {
CREATE TABLE s(i, s);
INSERT INTO s VALUES(1, ',0123456789,');
INSERT INTO s VALUES(2, X'2c303132333435363738392c');
CREATE TABLE e(e);
INSERT INTO e VALUES('v1'), ('v2');
} {}
do_faultsim_test 1.$enc.1 -faults oom* -body {
execsql { SELECT group_concat(e, (SELECT s FROM s WHERE i=1)) FROM e }
}
do_faultsim_test 1.$enc.2 -faults oom-t* -body {
execsql { SELECT string_agg(e, (SELECT s FROM s WHERE i=2)) FROM e }
}
do_faultsim_test 1.$enc.3 -faults oom-t* -prep {
set ::STMT [sqlite3_prepare db {SELECT group_concat(e, ?) FROM e} -1 dummy]
sqlite3_bind_text $::STMT 1 ",0123456789," 12
} -body {
while { "SQLITE_ROW"==[sqlite3_step $::STMT] } { }
} -test {
sqlite3_finalize $::STMT
}
}
finish_test