I have a procedural function (written in pl/python) which queries table A, does some calculations and then returns a set. I use this function as query for my materialized view B. Everything works perfectly except that when I want to restore my dump, I get the following error:
DETAIL: spiexceptions.UndefinedTable: relation "A" does not exist.
The line which raises this error is the last line of my sql dump:
REFRESH MATERIALIZED VIEW B;
I know that I can ignore this error and refresh my materialized view after restoration process, but I want to know why this happens? Is it because this function runs in another transaction which doesn't know anything about current restoration process? And what can I do to prevent this error?
Aand nota? Your view is calledbyet you refer to it asB. ("I use this function as query for my materialized view B.") butREFRESH MATERIALIZED VIEW Brefreshes a view calledbnotB. In case it's not clear, quoting an identifier makes it case sensitive, not quoting results in the identifier being all lowercase regardless of what you wrote. As you're not quotingBit will beb. Since it didn't say thatbdoesn't exist, thebview exists, butAdoesn't. Since your view is lowercase, I suspect your table is too.search_pathis different.