pg_checkdestroy
check sql drop&delete&truncate table
pg_checkdestroy · check sql drop&delete&truncate table
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100177 | pg_checkdestroy | pg_checkdestroy | 1.0 | ADMIN | Unknown | C |
Usage
Sources:
pg_checkdestroy is an experimental hook module that attempts to suppress table DROP, TRUNCATE, and unqualified DELETE statements. It installs parser, executor, and utility hooks only when loaded through shared_preload_libraries; the extension SQL itself is empty.
Configuration
After restarting PostgreSQL, register the extension and confirm that its session switch is enabled:
pg_checkdestroy.work defaults to on, but it is a PGC_USERSET setting and can be disabled in any session with sufficient access to connect.
Caveats
- Upstream explicitly says the code is not fully tested and advises against online/production use. The source dates from 2018 and depends on old PostgreSQL internal hook APIs.
- The hook suppresses selected commands by skipping normal execution rather than raising a clear policy error. A client can therefore receive misleading completion behavior.
- This is not a security boundary:
pg_checkdestroy.workis user-settable, coverage is based on particular parse/plan shapes, and privileged users can bypass or unload the module. - The implementation chains several global hooks and assumes per-query state that may interact badly with errors, nested statements, prepared plans, or other hook extensions. Use native privileges, ownership controls, and tested auditing instead of relying on this module to protect data.