Re: Domains versus polymorphic functions, redux
От | Noah Misch |
---|---|
Тема | Re: Domains versus polymorphic functions, redux |
Дата | |
Msg-id | 20110525111504.GA6657@tornado.leadboat.com обсуждение исходный текст |
Ответ на | Re: Domains versus polymorphic functions, redux (Noah Misch <noah@leadboat.com>) |
Ответы |
Re: Domains versus polymorphic functions, redux
|
Список | pgsql-hackers |
On Tue, May 24, 2011 at 02:00:54PM -0400, Noah Misch wrote: > On Tue, May 24, 2011 at 01:28:38PM -0400, Tom Lane wrote: > > Noah Misch <noah@leadboat.com> writes: > > > On Tue, May 24, 2011 at 12:12:55PM -0400, Tom Lane wrote: > > >> This is a consequence of the changes I made to fix bug #5717, > > >> particularly the issues around ANYARRAY matching discussed here: > > >> http://archives.postgresql.org/pgsql-hackers/2010-10/msg01545.php > > > > > We discussed this a few weeks ago: > > > http://archives.postgresql.org/message-id/20110511093217.GB26552@tornado.gateway.2wire.net > > > > > What's to recommend #1 over what I proposed then? Seems like a discard of > > > functionality for little benefit. > > > > I am unwilling to commit to making #2 work, especially not under time > > constraints; and you apparently aren't either, since you haven't > > produced the patch you alluded to at the end of that thread. > > I took your lack of any response as non-acceptance of the plan I outlined. > Alas, the wrong conclusion. I'll send a patch this week. See attached arrdom1v1-polymorphism.patch. This currently adds one syscache lookup per array_append, array_prepend or array_cat call when the anyarray type is not a domain. When the type is a domain, it adds a few more. We could add caching without too much trouble. I suppose someone out there uses these functions in bulk operations, though I've yet to see it. Is it worth optimizing this straightway? For a function like CREATE FUNCTION f(anyarray, VARIADIC anyarray) RETURNS int LANGUAGE sql AS 'SELECT array_length($1, 1) + array_length($2, 1)' we must coerce the variadic argument array to a domain type when the other anyarray argument(s) compel it. Having implemented that, it was nearly free to re-support a VARIADIC parameter specifically declared with a domain over an array. Consequently, I've done that as well. See here for previously-disclosed rationale: http://archives.postgresql.org/message-id/20110511191249.GA29592@tornado.gateway.2wire.net I audited remaining get_element_type() callers. CheckAttributeType() needs to recurse into domains over array types just like any other array type. Fixed trivially in arrdom2v1-checkattr.patch; see its test case for an example hole. nm
Вложения
В списке pgsql-hackers по дате отправления: