Open smurthys opened 7 years ago
I have in mind functions such as the following to be added to addHelpers.sql
because there are a few instances of such code in various files. I assume the exception propagates from a function to the calling transaction.
The code below is an example of an assertion function. And, it is quite possible the code needs some tweaks. Still showing it here to share the idea.
At this point, I will put this issue on backlog. We can reconsider before M1's release if an opportunity presents to add assertions.
CREATE OR REPLACE FUNCTION
classdb.assertSuperUser(message VARCHAR DEFAULT NULL,
roleName VARCHAR(63) DEFAULT current_user
)
RETURNS BOOLEAN AS
$$
BEGIN
IF NOT (SELECT classdb.isSuperUser(roleName)) THEN
RAISE EXCEPTION
COALESCE(message, format('Role %s is not a superuser', roleName));
END IF;
END;
$$ LANGUAGE plpgsql;
Removing from M2 due to time constraint.
Assertions on privilege, etc. repeat across db-level scripts. The repetition can be eliminated by adding assertion functions to
addHelpers.sql
and calling the assertion functions from all DB-level scripts exceptinitializeDB.sql
from PR #94