What happens to an index built on a function when I change the underlying function?
Say, I have a function clean_name()
defined as:
CREATE OR REPLACE FUNCTION clean_name(n text)
RETURNS TEXT AS
$BODY$
DECLARE
rec TEXT;
BEGIN
EXECUTE
'SELECT Regexp_replace(' || quote_literal(n) || ', ''[a-z]'', '''', ''g'');'
INTO rec;
RETURN rec;
END;
$BODY$ LANGUAGE plpgsql IMMUTABLE
;
Then create an index:
CREATE INDEX my_table_upper_name_btree
ON schema.my_table USING GIST (my_text_field);
But then I decide to redefine the function to remove upper case letters instead. What happens to the index I created? Does it change on its own? Do I DROP
and CREATE
again? VACUUM [ANALYZE] [FULL]
?
(The function in question is similar, using instead a rather lengthy series of replacements that are still being tweaked but expected to be stable.)