Company
Date Published
Author
Steve Chavez
Word count
1829
Language
English
Hacker News points
None

Summary

The SupaUtils extension for PostgreSQL uses hooks to extend internal functionality, specifically the ProcessUtility_hook, which allows it to hook into utility statements such as alter role and drop role. The extension defines a configuration parameter "supautils.reserved_roles" that can be modified by editing the postgresql.conf file, allowing users to define their own reserved roles. When an alter or drop role statement is executed, the extension checks if the affected role is in the reserved roles list, reporting an error and aborting the statement execution if it is. The supautils hook also calls the previous hook defined by another extension, ensuring that any previously set hooks are run before its own logic.