pl/python invalidate functions with composite arguments

Поиск
Список
Период
Сортировка
От Jan Urbański
Тема pl/python invalidate functions with composite arguments
Дата
Msg-id 4D1353B6.1050806@wulczer.org
обсуждение исходный текст
Ответы Re: pl/python invalidate functions with composite arguments  (Jan Urbański <wulczer@wulczer.org>)
Список pgsql-hackers
Here's a patch implementing properly invalidating functions that have
composite type arguments after the type changes, as mentioned in
http://archives.postgresql.org/pgsql-hackers/2010-12/msg01991.php. It's
an incremental patch on top of the plpython-refactor patch sent eariler.

Git branch for this patch:
https://github.com/wulczer/postgres/tree/invalidate-composites.

The idea in general is for this to work (taken straight from the unit
tests, btw)

CREATE TABLE employee (
    name text,
    basesalary integer,
    bonus integer
);
INSERT INTO employee VALUES ('John', 100, 10), ('Mary', 200, 10);

CREATE OR REPLACE FUNCTION test_composite_table_input(e employee)
RETURNS integer AS $$
return e['basesalary'] + e['bonus']
$$ LANGUAGE plpythonu;

SELECT name, test_composite_table_input(employee.*) FROM employee;
ALTER TABLE employee DROP bonus;
-- this fails
SELECT name, test_composite_table_input(employee.*) FROM employee;
ALTER TABLE employee ADD bonus integer;
UPDATE employee SET bonus = 10;
-- this works again
SELECT name, test_composite_table_input(employee.*) FROM employee;

It's a long-standing TODO item, and a generally good thing to do.

Cheers,
Jan

Вложения

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

Предыдущее
От: Jie Li
Дата:
Сообщение: Why is sorting on two columns so slower than sorting on one column?
Следующее
От: Jan Urbański
Дата:
Сообщение: pl/python tracebacks