-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error after alter main table: "ERROR: could not find attribute 43 in subquery targetlist" #85
Comments
Update.
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. |
I have the same issue I saw one of the tables I wanna use in |
I solved this issue for me like that: SELECT create_immv('immv_assignments','SELECT a.id id, a.user_id user_id, u.position position, r.code role_code, r.id role_id, g.code agency_code, g.acronym agency_acronym FROM ' ||
'(SELECT id, user_id, role_id, agency_id FROM assignments) a ' ||
'INNER JOIN users u ON u.id = a.user_id ' ||
'INNER JOIN roles r ON r.id = a.role_id ' ||
'INNER JOIN agencies g ON g.id = a.agency_id');
|
Thank you for your reports and sorry for the late response. I can reproduce it in a simple way as following. test=# create table t (i int, j int);
CREATE TABLE
test=# alter table t drop column i, add column k int;
ALTER TABLE
test=# select create_immv('mv','select * from t');
...(sinp)...
create_immv
-------------
0
(1 row)
test=# insert into t values (1,1);
ERROR: could not find attribute 3 in subquery targetlist This is definitely a bug, so I'll fix it. |
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.
The text was updated successfully, but these errors were encountered: