Re: remaining sql/json patches
От | Alvaro Herrera |
---|---|
Тема | Re: remaining sql/json patches |
Дата | |
Msg-id | 20230713165413.kj6vawaslldf25hp@alvherre.pgsql обсуждение исходный текст |
Ответ на | Re: remaining sql/json patches (Amit Langote <amitlangote09@gmail.com>) |
Ответы |
Re: remaining sql/json patches
|
Список | pgsql-hackers |
I looked at your 0001. My 0001 are some trivial comment cleanups to that. I scrolled through all of jsonfuncs.c to see if there was a better place for the new function than the end of the file. Man, is that one ugly file. There are almost no comments! I almost wish you would create a new file so that you don't have to put this new function in such bad company. But maybe it'll improve someday, so ... whatever. In the original code, the functions here being (re)moved do not need to return a type output function in a few cases. This works okay when the functions are each contained in a single file (because each function knows that the respective datum_to_json/datum_to_jsonb user of the returned values won't need the function OID in those other cases); but as an exported function, that strange API doesn't seem great. (It only works for 0002 because the only thing that the executor does with these cached values is call datum_to_json/b). That seems easy to solve, since we can return the hardcoded output function OID in those cases anyway. A possible complaint about this is that the OID so returned would be untested code, so they might be wrong and we'd never know. However, ISTM it's better to make a promise about always returning a function OID and later fixing any bogus function OID if we ever discover that we return one, rather than having to document in the function's comment that "we only return function OIDs in such and such cases". So I made this change my 0002. A similar complain can be made about which casts we look for. Right now, only an explicit cast to JSON is useful, so that's the only thing we do. But maybe one day a cast to JSONB would become useful if there's no cast to JSON for some datatype (in the is_jsonb case only?); and maybe another type of cast would be useful. However, that seems like going too much into uncharted territory with no useful use case, so let's just not go there for now. Maybe in the future we can improve this aspect of it, if need arises. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
Вложения
В списке pgsql-hackers по дате отправления: