I understand how to use GRANT
to control who can do what to a DB object.
I have a case where it would be useful to have specific functions that modify a table's contents while preventing a user from directly accessing the table.
Let's say I have a stock control table and I want a function increase_stock(int)
that modifies only one column. There would be other functions that modify other columns, too.
My actual table has arrays of ltrees and arrays of ints, making a trigger an undesirable option as that does not present a clean way of directly manipulating only one field without testing for changes on each. More importantly, it doesn't create the APIs I desire.
Regardless of the approach, can I create a function that is visible to a user while that function accesses a table that is NOT visible to that user?
I'm using PG 10.