Make CREATE AGGREGATE check validity of initcond value?

Started by Tom Laneover 13 years ago2 messages
#1Tom Lane
tgl@sss.pgh.pa.us

In http://archives.postgresql.org/pgsql-general/2012-10/msg00138.php
we see an example where a user tried to create an aggregate whose
"initcond" (initial transition value) wasn't valid for the transition
data type. CREATE AGGREGATE didn't complain because it just stores the
initial condition as a text string. It seems to me that it'd be a lot
more user-friendly if it did check the value, as per the attached
proposed patch.

Does anyone have an objection to this? I can imagine cases where the
check would reject values that would get accepted at runtime, if the
type's input function was sensitive to the phase of the moon or
something. But it doesn't seem very probable, whereas checking the
value seems like an eminently useful thing to do. Or maybe I'm just
overreacting to the report --- I can't recall any previous complaints
like this, so maybe entering a bogus initcond is a corner case too.

regards, tom lane

#2Jaime Casanova
jaime@2ndquadrant.com
In reply to: Tom Lane (#1)
Re: Make CREATE AGGREGATE check validity of initcond value?

El 03/10/2012 21:38, "Tom Lane" <tgl@sss.pgh.pa.us> escribió:

Does anyone have an objection to this? I can imagine cases where the
check would reject values that would get accepted at runtime, if the
type's input function was sensitive to the phase of the moon or
something. But it doesn't seem very probable, whereas checking the
value seems like an eminently useful thing to do. Or maybe I'm just
overreacting to the report --- I can't recall any previous complaints
like this, so maybe entering a bogus initcond is a corner case too.

I guess a wrong initcond value, probably is a pilot error.
So, my first reaction is +1 to make it an error.

But if you feel there a corner cases maybe at least a warning

--
Jaime Casanova
2ndQuadrant: Your PostgreSQL partner