Open Focus1337 opened 2 months ago
Update. We fixed the problem as follows:
drop table if exists trip_airline_cache;
CREATE TABLE airline_versions2
(
LIKE airline_versions INCLUDING ALL
);
and this table airline_versions2 now has sequential numbering without gaps.
However, this solution is bad. Because if we need to make changes in other tables, we will have to repeat this procedure again.
We came to the conclusion that the problem lies in working with attributes in the pg_ivm extension.
We still hope to receive detailed comments from you. Thank you.
We create and use immv as a cache: airline_trip_cache.
Before:
airline_trip_cache uses the following tables (DDL):
We create immv airline_trip_cache like this:
Everything worked great, but we needed to make changes.
After:
We alter airline_versions - add 1 column, drop 3 columns, create a new table airline_version_employees, change airline_trip_cache according to the new changes - first drop the table, and then create:
Problem:
We are faced with a problem that after altering the airline_versions table, when we try to insert/change/delete into it, we encounter the error "ERROR: could not find attribute 43 in subquery targetlist".
We tried to create all the tables at once in their final form (without alter, etc.), and in this case everything works. This problem only occurs when we modify the main tables. And also, apparently, the presence of records does not affect the occurrence of the problem.
I'm guessing the issue is that immv cannot process the table correctly when there are gaps in the attribute numbering. Checked the airline_versions table attributes. Results: Before:
After:
refresh_immv, re-creating airline_trip_cache, and re-creating the extension didn't help us. Only if we don’t use airline_trip_cache, then everything works.
We tried it on Postgres 15.3, 16, as well as pg_ivm versions: 1.5, 1.7, 1.8 - none of them solved the problem.
If you need even more input, let me know. Perhaps, you need information from pg_ivm_immv. I hope you can tell me what we are missing or doing wrong.