Corruption with IMMUTABLE functions in index expression. - Mailing list pgsql-hackers

From Prabhat Sahu
Subject Corruption with IMMUTABLE functions in index expression.
Date
Msg-id CANEvxPo__EAAtjO6SWmRD-nvTLGQ6r6q2JFyT2cmpOY0-aqATA@mail.gmail.com
Whole thread Raw
Responses Re: Corruption with IMMUTABLE functions in index expression.  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-hackers
Hi All,

While using IMMUTABLE functions in index expression, we are getting below corruption on HEAD.

postgres=# CREATE TABLE  tab1 (c1 numeric, c2 numeric);
CREATE TABLE

postgres=# INSERT INTO  tab1 values (10, 100);
INSERT 0 1

postgres=# CREATE OR REPLACE FUNCTION func1(var1 numeric)
RETURNS NUMERIC AS $$
DECLARE
result numeric;
BEGIN
 SELECT c2 into result FROM  tab1 WHERE c1=var1;
 RETURN result;
END;
$$ LANGUAGE plpgsql IMMUTABLE;
CREATE FUNCTION

-- When using the IMMUTABLE function in creating an index for the first time, it is working fine.
postgres=# CREATE INDEX idx1 ON  tab1(func1(c1));
CREATE INDEX

-- Executing the similar query for 2nd time, We are getting the error
postgres=# CREATE INDEX idx2 ON  tab1(func1(c1));
ERROR:  could not read block 0 in file "base/13675/16391": read only 0 of 8192 bytes
CONTEXT:  SQL statement "SELECT c2             FROM  tab1 WHERE c1=var1"
PL/pgSQL function func1(numeric) line 5 at SQL statement

--

With Regards,
Prabhat Kumar Sahu
EnterpriseDB: http://www.enterprisedb.com

pgsql-hackers by date:

Previous
From: Dilip Kumar
Date:
Subject: Re: row filtering for logical replication
Next
From: Andrew Dunstan
Date:
Subject: Re: More business with $Test::Builder::Level in the TAP tests