Function taking compound type defined on a view with ORDER BY

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Function taking compound type defined on a view with ORDER BY
Дата
Msg-id 43566E26.7030302@archonet.com
обсуждение исходный текст
Ответы Re: Function taking compound type defined on a view with ORDER BY  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
Earlier today Hakan Kocaman (Hakan.Kocaman@digame.de) posted a query on
general "Issue with functions in Rule".

Turned out the problem is with a function that takes a compound type
based on a view with ORDER BY. If you add/remove ORDER BY to the view
definition in the attached it doesn't recognise the type (I think)

The error is different in 8.0.x and 8.1.x but occurs in both.

--
   Richard Huxton
   Archonet Ltd

CREATE TABLE test_table (a int4, b text);
COPY test_table FROM stdin;
1    aaa
2    bbb
3    ccc
4    ddd
\.

CREATE OR REPLACE VIEW test_view AS SELECT a,b FROM test_table WHERE (a % 2) = 1 ORDER BY a;


CREATE OR REPLACE FUNCTION test_upd_fn(test_view, test_view) RETURNS boolean AS $$
BEGIN
    RAISE NOTICE 'test_upd_fn(a1=%, b1=%, a2=%, b2=%)', $1.a,$1.b, $2.a,$2.b;
    UPDATE test_table SET b=b || 'x' WHERE a=$1.a;
    RETURN true;
END;
$$ LANGUAGE plpgsql;

CREATE OR REPLACE RULE my_upd_rule AS ON UPDATE TO test_view
DO INSTEAD
SELECT test_upd_fn(v1.*, v2.*) FROM test_view v1, test_view v2 WHERE v1.a=NEW.a AND v2.a=OLD.a;


SELECT * FROM test_table;
SELECT * FROM test_view;

UPDATE test_view SET b='ccc2' WHERE a=3;

SELECT * FROM test_view;


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

Предыдущее
От: Ivan
Дата:
Сообщение: union bug
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #1976: steps to reproduce BUG #1438: Non UTF-8 client encoding problem