Deny rollback table if conditions are not met

I would like to ask if it is possible to process the dropping table command and break it if some conditions are not met?

0
source share
1 answer

I'm going to assume that you are trying to ask:

How can I prevent DROP TABLE from succeeding based on specific application conditions

If so, your only built-in option is to use permissions. See GRANT and REVOKE in the PostgreSQL manual.

If you need something more complex, you can write ProcessUtility_hook , but for this you need to write a C extension that is compiled and uploaded to the server.

The ProcessUtility_hook entry is actually not too complicated, but there are differences between the PostgreSQL 9.2 and 9.3 definitions, which mean you will need separate extensions. Here is a basic example: https://github.com/ringerc/scrapcode/tree/master/postgresql/example_processutility_hook , and here is a ProcessUtility hook that really does something useful: https://github.com/ringerc/postgres/blob /bdr-reject-unsafe-commands/contrib/bdr/bdr_commandfilter.c

If you have no C programming experience and some time, ProcessUtility_hook not for you.

See also: How to prevent table deletion?

+2
source

Source: https://habr.com/ru/post/1488468/


All Articles