Re: Allow SQL/plpgsql functions to accept record
От | Merlin Moncure |
---|---|
Тема | Re: Allow SQL/plpgsql functions to accept record |
Дата | |
Msg-id | CAHyXU0zpFvRJEg3DYG9FHZbshRMySL_ViD-tToVSoD7BrZfQQg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Allow SQL/plpgsql functions to accept record (Andrew Dunstan <andrew@dunslane.net>) |
Ответы |
Re: Allow SQL/plpgsql functions to accept record
|
Список | pgsql-hackers |
On Wed, Apr 22, 2015 at 11:20 AM, Andrew Dunstan <andrew@dunslane.net> wrote: > > On 04/22/2015 11:29 AM, Jim Nasby wrote: >> >> On 4/20/15 2:04 PM, David G. Johnston wrote: >>> >>> >>> SELECT (src.v).* FROM ( VALUES (ROW(1,2,3)) ) src (v); >>> ERROR: record type has not been registered >>> >>> While it may not be necessary to solve both problems I suspect they have >>> the same underlying root cause - specifically the separation of concerns >>> between the planner and the executor. >> >> I don't think they're related at all. C functions have the ability to >> accept a record, so the executor must be able to support it. It's just that >> SQL and plpgsql functions don't have that support. I suspect that's just >> because no one has gotten around to it. > > Well, that's assuming everyone else thinks it would be a good idea. Maybe > they do, but I wouldn't assume it. > > The answer in the past has been to use more dynamically typed languages such > as perl for which this problem is well suited. I've never really been satisfied with this answer. The two languages with really good core support are perl and python, neither of which are my cup of tea. Also, there is no chance of inlining any of the dynamic languages which has serious performance ramifications. In a perfect world, pl/v8 would be a good choice for a general purpose database support language as javascript has a number of properties that make it attractive for integration. Even if we had that though (and it's unlikely), a large percentage of postgres devs, including myself, dislike coding in any language except sql plus extensions. That being said, I think json types with their associated API, given that they are core types, will ultimately handle these types of problems. That way, at least, we can avoid adding syntax and functionality that will basically do the same thing. This reminds me a little bit of the json_build() vs enhanced row() syntax we discussed some time back. I didn't say so at the time, but for posterity, I think you were right...json_build() is working fine for building arbitrary record types and moving a record to json and deconstructing it should work just as well. merlin merlin
В списке pgsql-hackers по дате отправления: