Re: pg_get__*_ddl consolidation
| От | Euler Taveira |
|---|---|
| Тема | Re: pg_get__*_ddl consolidation |
| Дата | |
| Msg-id | 6ecd7573-850d-424a-9794-3ee1f73851c0@app.fastmail.com обсуждение исходный текст |
| Ответ на | Re: pg_get__*_ddl consolidation ("Jelte Fennema-Nio" <postgres@jeltef.nl>) |
| Ответы |
Re: pg_get__*_ddl consolidation
|
| Список | pgsql-hackers |
On Mon, Apr 6, 2026, at 12:24 PM, Jelte Fennema-Nio wrote: > The thing I'm questioning is whether we need a new way of providing > key+value pairs as optional arguments to functions. IMO we already had a > perfectly fine one. Introducing another adds complexity (both to the > code and to the user) and I don't see any compelling reason to do so. > I did the same question when reviewing one of these patches. My first reaction was if we want flexibility to cover various use cases and maintainability to add/deprecate new options, we need a mechanism to avoid breaking compatibility or even overloading the function (complexity). My natural choice was key-value pair arguments. It needs new support code (although we already use this style in some of the backend functions -- e.g. pg_logical_slot_*_changes()). > Attached is a patch with roughly what I have in mind instead. By doing > this we can also make the functinos STRICT, so that we don't have to > worry about handling NULL values for the first argument. > That's a good point. > Afaict this named parameter approach only has benefits over the VARIADIC > argument one. But if I'm wrong about that, please let me know. > I also consider your approach but decided not to use it. The argument against named arguments is that you cannot add new argument *without* a DEFAULT value; if you do, all existing functions will fail. You also need to create another function with a different list of arguments to support a new option. If we are fine with this restriction, your proposal seems ok to me. One point in favor of your proposal is that the named arguments seems more intuitive than the key-value pair arguments. The first impression is that interchanging key and value is harder to figure out that the named argument notation. Of course, documentation and some examples can help the user to write these function calls. That's not the first function that uses this key-value argument approach. -- Euler Taveira EDB https://www.enterprisedb.com/
В списке pgsql-hackers по дате отправления: