sraoss / pgsql-ivm

IVM (Incremental View Maintenance) development for PostgreSQL
Other
129 stars 12 forks source link

Fix incorrect results of aggregate views withoug GROUP BY #90

Closed yugo-n closed 4 years ago

yugo-n commented 4 years ago

Views of aggregate without GROUP BY clause always have only one tuple as the result. Even when all tuples in base tables are deleted, the view must have a row whose result is 0 for count(), or NULL for others.

However, in the previous implementation, this resulted in deleting the tuple from the view. To fix this, don't allow to delete a tuple from a view when this is a aggregate view without GROUP BY.

Github issue #88

yugo-n commented 4 years ago

this work is fine. However, I'm concerned about 'tuptable_recalc' variable. Do you need this variable? I think it is not necessary.

Well, do you mean that we can use SPI_tuptable directly, instead of tuptable_recalc argument, in order to pass the query result from apply_old_delta() to its caller? As for it, you are right, this is not necessary, but we can conceal the SPI interface which uses the global variable via this function argument, and this is what I intend.

thoshiai commented 4 years ago

Thank you for your fix. I think it is no problem. I will merge it.