Wrong values in generated columns in postgres 15.1
0
votes
0
answers
37
views
I have a problem with generated column in one of my tables. The column value is calculated basing on other column in the row (which is of type varchar). Most of the time it works fine. But sometimes the generated value is wrong - I can't find any specific steps that cause such issue. Simple non-updating update like 'update column=column where [[generated_column_value]][[generated_column_expression]]' fixes the issue, but after some time the problem occurs again.
I tried recreate the column (drop it and create again), but it didn't help. Does any of you have similar problem or can you give me some recommendation, what should I check?
Following the alter that I used (the table has already column with name
of type varchar(1)):
alter table my_table
add column is_active boolean generated always as (status = 'A') stored;
After some time, when I execute following select:
select *
from my_table
where is_active
and status 'A'
I can receive some rows, but I expect no rows (as rows which have true in
column should all have value 'A' in column
). What can be the cause of the issue or what should I check?
Thanks a lot
Asked by trefkar
(1 rep)
Oct 1, 2024, 09:13 PM