Обсуждение: setof type and later table bug??

Поиск
Список
Период
Сортировка

setof type and later table bug??

От
"Sergiusz Michalski"
Дата:
Hi!
Guys please help me, it this example I create function sergi() thats return
a rows, and everything is OK, function works well, but
if I execute a SQL query : ALTER TABLE DUPA DROP COLUMN nazwa; or everything
using ALTER TABLE, my function
crashes and error is sth. like query type and function type do not match !
What's it??? How to solve it withought reloading table.

Is it a bug????

PZDR;
Sergiusz.

CREATE TABLE dupa (id int NOT NULL, nazwa varchar(44) NOT NULL, primary
key(id) );
INSERT INTO dupa VALUES(1, 'a');
INSERT INTO dupa VALUES(2, 'b');
INSERT INTO dupa VALUES(3, 'c');
INSERT INTO dupa VALUES(4, 'd');
INSERT INTO dupa VALUES(5, 'e');
INSERT INTO dupa VALUES(6, 'f');
INSERT INTO dupa VALUES(7, 'g');
INSERT INTO dupa VALUES(8, 'h');

CREATE OR REPLACE FUNCTION sergi()
RETURNS SETOF DUPA
AS '
DECLARE
   rec RECORD;
BEGIN
   FOR rec IN SELECT * FROM DUPA LOOP
      RETURN NEXT rec; /* Each RETURN NEXT command returns a row */
   END LOOP;
   RETURN;
END;
' LANGUAGE 'plpgsql';