Re: poc - possibility to write window function in PL languages

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: poc - possibility to write window function in PL languages
Дата
Msg-id CAFj8pRDFJ_3jPW5yUAAwvKKia7fomod=e7zmNtC5P=P1Wghh9g@mail.gmail.com
обсуждение исходный текст
Ответ на Re: poc - possibility to write window function in PL languages  (Pavel Stehule <pavel.stehule@gmail.com>)
Ответы Re: poc - possibility to write window function in PL languages  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-hackers


pá 28. 8. 2020 v 8:14 odesílatel Pavel Stehule <pavel.stehule@gmail.com> napsal:


st 26. 8. 2020 v 17:06 odesílatel Pavel Stehule <pavel.stehule@gmail.com> napsal:
Hi

I simplified access to results of  winfuncargs functions by proxy type "typedvalue". This type can hold any Datum value, and allows fast cast to basic buildin types or it can use (slower) generic cast functions. It is used in cooperation with a plpgsql assign statement that can choose the correct cast implicitly. When the winfuncarg function returns a value of the same type, that is expected by the variable on the left side of the assign statement, then (for basic types), the value is just copied without casts. With this proxy type is not necessary to have special statement for assigning returned value from winfuncargs functions, so source code of window function in plpgsql looks intuitive to me.

Example - implementation of "lag" function in plpgsql

create or replace function pl_lag(numeric)
returns numeric as $$
declare v numeric;
begin
  v := get_input_value_in_partition(windowobject, 1, -1, 'seek_current', false);
  return v;
end;
$$ language plpgsql window;

I think this code is usable, and I assign this patch to commitfest.

Regards

Pavel

fix regress tests and some doc

update - refactored implementation typedvalue type


Вложения

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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: Allow ERROR from heap_prepare_freeze_tuple to be downgraded to WARNING
Следующее
От: Anastasia Lubennikova
Дата:
Сообщение: Re: MultiXact\SLRU buffers configuration