Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check access to masked columns in bulk when analyzing masks
The `getColumnMasks` SPI call was added in order to reduce the number of SPI calls in cases of tables with large number of columns, similar to how `checkCanSelectFromColumns` does it. This is an important performance optimization for access controls like OPA. But, once we discover the column masks, we check whether the current session has access to the masked columns - if not, we skip analyzing it further. The problem was that each column mask was inspected in isolation, resulting in multiple checks to `checkCanSelectFromColumns` with just a single column. I believe this is contrary to the goals of the change which introduced `getColumnMasks`. This PR adds a fast path with a single check for all masked columns instead of one check per each masked column. If that single check fails, though, we enter the slow path, in which we analyze masks on all the accessible columns to see if they reference any other columns. This is relevant when the `hide-inaccessible-columns` option is set, in which case we cannot assume that an inaccessible masked column will fail the query.
- Loading branch information