aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-10-17 21:23:09 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-10-17 21:23:09 +0000
commit8b6b414a5e112554f08394a0f814088e625cd191 (patch)
tree97f421c0049aeb75471d50b76b9c411b8ed8a878 /src
parent179b8e572296815b132b80f27d3be31b750f9d98 (diff)
downloadpostgresql-8b6b414a5e112554f08394a0f814088e625cd191.tar.gz
postgresql-8b6b414a5e112554f08394a0f814088e625cd191.zip
Update pltcl regress test to exercise return_null; also make use of
the fact that CREATE FUNCTION and CREATE AGGREGATE now allow array types to be named like int4[] rather than _int4.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/pl/tcl/test/runtest2
-rw-r--r--src/pl/tcl/test/test.expected6
-rw-r--r--src/pl/tcl/test/test_setup.sql9
3 files changed, 11 insertions, 6 deletions
diff --git a/src/pl/tcl/test/runtest b/src/pl/tcl/test/runtest
index d1cfb330826..c98402f0abd 100755
--- a/src/pl/tcl/test/runtest
+++ b/src/pl/tcl/test/runtest
@@ -21,7 +21,7 @@ psql -q -n -e $DBNAME <test_queries.sql > test.out 2>&1
if diff test.expected test.out >/dev/null 2>&1 ; then
echo " Tests passed O.K."
else
- echo " Tests faild - look at diffs between"
+ echo " Tests failed - look at diffs between"
echo " test.expected and test.out"
fi
diff --git a/src/pl/tcl/test/test.expected b/src/pl/tcl/test/test.expected
index 351643ade41..d7037a18486 100644
--- a/src/pl/tcl/test/test.expected
+++ b/src/pl/tcl/test/test.expected
@@ -133,7 +133,11 @@ select tcl_sum(key1) from T_pkey2;
(1 row)
select tcl_avg(key1) from T_pkey1 where key1 = 99;
-ERROR: pltcl: divide by zero
+ tcl_avg
+---------
+
+(1 row)
+
select tcl_sum(key1) from T_pkey1 where key1 = 99;
tcl_sum
---------
diff --git a/src/pl/tcl/test/test_setup.sql b/src/pl/tcl/test/test_setup.sql
index 7faabc12961..918e2212696 100644
--- a/src/pl/tcl/test/test_setup.sql
+++ b/src/pl/tcl/test/test_setup.sql
@@ -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 '