Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2026-04-30 9f2ef60949ced4fab4d077a7e1c6d913f3620c9b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
CREATE OR REPLACE FUNCTION sumArrayIntTcl(a integer[]) RETURNS integer AS $$
set state [split $1 "{,}"]
return [expr {[lindex $state 1] + [lindex $state 2] + [lindex $state 3]}]
$$ LANGUAGE pltcl;
SELECT sumArrayIntTcl( ARRAY[4,1,5] ) = integer '10';
 
CREATE OR REPLACE FUNCTION sumArrayNumTcl(a numeric[]) RETURNS numeric AS $$
set state [split $1 "{,}"]
return [expr {[lindex $state 1] + [lindex $state 2] + [lindex $state 3]}]
$$ LANGUAGE pltcl;
SELECT sumArrayNumTcl( ARRAY[1.00002, 1.00003, 1.00004] ) = numeric '3.00009';
 
CREATE OR REPLACE FUNCTION sumArrayTextTcl(a text[]) RETURNS text AS $$
set state [split $1 "{,}"]
set state [split $state "{\"}"]
return [concat [lindex $state 1][lindex $state 2][lindex $state 3][lindex $state 4]]
$$ LANGUAGE pltcl;
SELECT sumArrayTextTcl( ARRAY['Rafael', 'da', 'Veiga', 'Cabral'] ) = varchar 'Rafael da Veiga Cabral';