|
|
|
|
@ -389,22 +389,23 @@ create function tcl_int4add(int4,int4) returns int4 as ' |
|
|
|
|
-- We use split(n) as a quick-and-dirty way of parsing the input array |
|
|
|
|
-- value, which comes in as a string like '{1,2}'. There are better ways... |
|
|
|
|
|
|
|
|
|
create function tcl_int4_accum(_int4,int4) returns _int4 as ' |
|
|
|
|
create function tcl_int4_accum(int4[], int4) returns int4[] as ' |
|
|
|
|
set state [split $1 "{,}"] |
|
|
|
|
set newsum [expr {[lindex $state 1] + $2}] |
|
|
|
|
set newcnt [expr {[lindex $state 2] + 1}] |
|
|
|
|
return "{$newsum,$newcnt}" |
|
|
|
|
' language 'pltcl'; |
|
|
|
|
|
|
|
|
|
create function tcl_int4_avg(_int4) returns int4 as ' |
|
|
|
|
create function tcl_int4_avg(int4[]) returns int4 as ' |
|
|
|
|
set state [split $1 "{,}"] |
|
|
|
|
if {[lindex $state 2] == 0} { return_null } |
|
|
|
|
return [expr {[lindex $state 1] / [lindex $state 2]}] |
|
|
|
|
' language 'pltcl'; |
|
|
|
|
|
|
|
|
|
create aggregate tcl_avg ( |
|
|
|
|
sfunc = tcl_int4_accum, |
|
|
|
|
basetype = int4, |
|
|
|
|
stype = _int4, |
|
|
|
|
stype = int4[], |
|
|
|
|
finalfunc = tcl_int4_avg, |
|
|
|
|
initcond = '{0,0}' |
|
|
|
|
); |
|
|
|
|
@ -413,7 +414,7 @@ create aggregate tcl_sum ( |
|
|
|
|
sfunc = tcl_int4add, |
|
|
|
|
basetype = int4, |
|
|
|
|
stype = int4, |
|
|
|
|
initcond1 = '0' |
|
|
|
|
initcond1 = 0 |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
create function tcl_int4lt(int4,int4) returns bool as ' |
|
|
|
|
|