array_push is just stupid ...

Поиск
Список
Период
Сортировка
От Tom Lane
Тема array_push is just stupid ...
Дата
Msg-id 21591.1424305678@sss.pgh.pa.us
обсуждение исходный текст
Список pgsql-hackers
While hacking around with expanded arrays, I realized that array_push()
is just a horribly badly designed function.  There is no reason at all
for the same C function to underlie both array_append and array_prepend:
the function spends significant time and effort reverse-engineering which
way it was called, and there's very little logic-in-common that would
justify merging the two code paths.  If we split it apart into separate
array_append and array_prepend functions, I think we'd actually end up
with less code.  And it would certainly be noticeably faster because
we'd not need to be doing get_fn_expr_argtype and get_element_type (the
latter of which is a syscache lookup, hence not so cheap) on *both*
arguments every time through.  (Admittedly, some of that could be bought
back with a bit more effort on locally caching the result, but it would be
better to know which input is the array a priori.)

Barring objections, I'm going to go fix this independently of the
expanded-array changes.
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Kevin Grittner
Дата:
Сообщение: Re: Allow "snapshot too old" error, to prevent bloat
Следующее
От: Peter Geoghegan
Дата:
Сообщение: INSERT ... ON CONFLICT UPDATE and logical decoding