eulerto / pg_restrict Goto Github PK
View Code? Open in Web Editor NEWrestrict some SQL commands on PostgreSQL
License: BSD 3-Clause "New" or "Revised" License
restrict some SQL commands on PostgreSQL
License: BSD 3-Clause "New" or "Revised" License
Restrict ROLE commands (CREATE, ALTER, and DROP) to a master role. There is a parameter to restrict DROP ROLE, however, this proposal is to avoid any role commands.
restrict CREATE TABLE command to a master role
restrict EXTENSION commands (CREATE, ALTER, and DROP) to a master role.
Restrict EVENT TRIGGER commands (CREATE, ALTER, and DROP) to a master role.
restrict PUBLICATION commands (CREATE, ALTER, and DROP) to a master role.
Restrict VACUUM FULL command to a master role.
restrict REVOKE command to a master role.
restrict SUBSCRIPTION commands (CREATE, ALTER, and DROP) to a master role.
restrict GRANT command to a master role.
Restrict DATABASE commands (CREATE, ALTER, and DROP) to a master role. There is a parameter to restrict DROP DATABASE, however, this proposal is to avoid any database commands.
restrict ALTER TABLE command to a master role
Restrict LOAD command to a master role.
Restrict CHECKPOINT command to a master role.
Restrict TABLESPACE commands (CREATE, ALTER, and DROP) to a master role.
solve
diff --git a/pg_restrict.c b/pg_restrict.c
index 0898ede..4d23231 100644
--- a/pg_restrict.c
+++ b/pg_restrict.c
@@ -56,7 +56,11 @@ static bool check_master_roles(char **newval, void **extra,
GucSource source);
static void assign_master_roles(const char *newval, void *extra);
-#if PG_VERSION_NUM >= 130000
+#if PG_VERSION_NUM >= 140000
+static void pgr_ProcessUtility(PlannedStmt *pstmt, const char *queryString, bool readOnlyTree,
+ ProcessUtilityContext context, ParamListInfo params, QueryEnvironment *queryEnv,
+ DestReceiver *dest, QueryCompletion *qc);
+#elif PG_VERSION_NUM >= 130000
static void pgr_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
ProcessUtilityContext context, ParamListInfo params, QueryEnvironment *queryEnv,
DestReceiver *dest, QueryCompletion *qc);
@@ -151,7 +155,14 @@ _PG_fini(void)
/*
* ProcessUtility hook
*/
-#if PG_VERSION_NUM >= 130000
+#if PG_VERSION_NUM >= 140000
+static void
+pgr_ProcessUtility(PlannedStmt *pstmt, const char *queryString, bool readOnlyTree,
+ ProcessUtilityContext context, ParamListInfo params, QueryEnvironment *queryEnv,
+ DestReceiver *dest, QueryCompletion *qc)
+{
+ Node *pst = (Node *) pstmt->utilityStmt;
+#elif PG_VERSION_NUM >= 130000
static void
pgr_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
ProcessUtilityContext context, ParamListInfo params, QueryEnvironment *queryEnv,
@@ -308,7 +319,16 @@ pgr_ProcessUtility(Node *pst, const char *queryString,
* Fallback to normal process, be it the previous hook loaded
* or the in-core code path if the previous hook does not exist.
*/
-#if PG_VERSION_NUM >= 130000
+#if PG_VERSION_NUM >= 140000
+ if (prev_ProcessUtility)
+ prev_ProcessUtility(pstmt, queryString, readOnlyTree,
+ context, params, queryEnv,
+ dest, qc);
+ else
+ standard_ProcessUtility(pstmt, queryString, readOnlyTree,
+ context, params, queryEnv,
+ dest, qc);
+#elif PG_VERSION_NUM >= 130000
if (prev_ProcessUtility)
prev_ProcessUtility(pstmt, queryString,
context, params, queryEnv,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.