The following bug has been logged on the website:
Bug reference: 8606
Logged by: Jaroslav Rejda
Email address: j.rejda@konektel.cz
PostgreSQL version: 9.3.1
Operating system: MS Windows XP SP3
Description:
-- Hi,
-- please, check this example:
-- simple table
CREATE TABLE test (cislo integer);
INSERT INTO test VALUES (10);
-- immutable "long time" math func
CREATE FUNCTION long_test(_n bigint)
RETURNS bigint AS
$BODY$DECLARE
_result bigint := 0;
_i bigint := 2;
BEGIN
_n := !! _n;
WHILE _i < _n LOOP
IF _n % _i = 0 THEN
_result := _result + 1;
END IF;
_i := _i + 1;
END LOOP;
RETURN _result;
END;$BODY$
LANGUAGE plpgsql IMMUTABLE STRICT
COST 100;
-- this returns "immediately"
CREATE MATERIALIZED VIEW test1 AS SELECT long_test(cislo) FROM test WITH NO
DATA;
-- this returns "after some time" (as long as normal "SELECT long_test(10);"
do)
CREATE MATERIALIZED VIEW test2 AS SELECT long_test(10) WITH NO DATA;
-- it's ok or bug?
-- Thanks ... JR