summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane2000-07-18 05:02:19 +0000
committerTom Lane2000-07-18 05:02:19 +0000
commitba930a016c96f8cf57255b6f3adaa73564a7965d (patch)
treefefdc8473c7c634f664a281253ad1cb43825f122 /src
parent8b1b34f6c0828f196fe5768e23dfeb3ad3ddf2d0 (diff)
Add an opr_sanity check for misdefined aggregates that have transition
type different from input type but are expecting ExecAgg to insert the first non-null input as the starting transition value. This has always been verboten, but wasn't checked for until now...
Diffstat (limited to 'src')
-rw-r--r--src/test/regress/expected/opr_sanity.out11
-rw-r--r--src/test/regress/sql/opr_sanity.sql9
2 files changed, 20 insertions, 0 deletions
diff --git a/src/test/regress/expected/opr_sanity.out b/src/test/regress/expected/opr_sanity.out
index 70f0134693e..e784486f81d 100644
--- a/src/test/regress/expected/opr_sanity.out
+++ b/src/test/regress/expected/opr_sanity.out
@@ -479,6 +479,17 @@ WHERE p1.aggfinalfn = p2.oid AND
-----+---------+-----+---------
(0 rows)
+-- If transfn is strict then either initval should be non-NULL, or
+-- basetype should equal transtype so that the first non-null input
+-- can be assigned as the state value.
+SELECT p1.oid, p1.aggname, p2.oid, p2.proname
+FROM pg_aggregate AS p1, pg_proc AS p2
+WHERE p1.aggtransfn = p2.oid AND p2.proisstrict AND
+ p1.agginitval IS NULL AND p1.aggbasetype != p1.aggtranstype;
+ oid | aggname | oid | proname
+-----+---------+-----+---------
+(0 rows)
+
-- **************** pg_opclass ****************
-- There should not be multiple entries in pg_opclass with the same
-- nonzero opcdeftype value, because there can be only one default opclass
diff --git a/src/test/regress/sql/opr_sanity.sql b/src/test/regress/sql/opr_sanity.sql
index d655e02eb89..fb43748a1cb 100644
--- a/src/test/regress/sql/opr_sanity.sql
+++ b/src/test/regress/sql/opr_sanity.sql
@@ -400,6 +400,15 @@ WHERE p1.aggfinalfn = p2.oid AND
p2.pronargs != 1 OR
p1.aggtranstype != p2.proargtypes[0]);
+-- If transfn is strict then either initval should be non-NULL, or
+-- basetype should equal transtype so that the first non-null input
+-- can be assigned as the state value.
+
+SELECT p1.oid, p1.aggname, p2.oid, p2.proname
+FROM pg_aggregate AS p1, pg_proc AS p2
+WHERE p1.aggtransfn = p2.oid AND p2.proisstrict AND
+ p1.agginitval IS NULL AND p1.aggbasetype != p1.aggtranstype;
+
-- **************** pg_opclass ****************
-- There should not be multiple entries in pg_opclass with the same