From b192ee15ebd37a669e55c534b02b229f1a35b73a Mon Sep 17 00:00:00 2001
From: Bobbie Soedirgo
Date: Fri, 26 Jan 2024 12:33:33 +0800
Subject: [PATCH] feat: remove pg12 support
---
.github/workflows/main.yml | 2 +-
.github/workflows/release.yml | 2 +-
Makefile | 3 ---
README.md | 9 +++------
shell.nix | 1 -
src/constrained_extensions.c | 13 +++----------
src/supautils.c | 14 +-------------
src/utils.h | 13 +------------
8 files changed, 10 insertions(+), 47 deletions(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 8ea8eaf..9339925 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- pg-version: ['12', '13', '14', '15']
+ pg-version: ['13', '14', '15']
steps:
- uses: actions/checkout@v3
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 68b876e..e35cc98 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -31,7 +31,7 @@ jobs:
matrix:
extension_name:
- supautils
- postgres: [12, 13, 14, 15]
+ postgres: [13, 14, 15]
box:
- { runner: ubuntu-20.04, arch: amd64 }
- { runner: arm-runner, arch: arm64 }
diff --git a/Makefile b/Makefile
index f3b774c..7da490d 100644
--- a/Makefile
+++ b/Makefile
@@ -11,13 +11,10 @@ MODULE_big = supautils
OBJS = src/supautils.o src/privileged_extensions.o src/constrained_extensions.o src/utils.o
PG_VERSION = $(strip $(shell $(PG_CONFIG) --version | $(GREP) -oP '(?<=PostgreSQL )[0-9]+'))
-PG_GE13 = $(shell test $(PG_VERSION) -ge 13; echo $$?)
SYSTEM = $(shell uname -s)
ifneq ($(SYSTEM), Linux)
TESTS = $(filter-out test/sql/ge13_%.sql, $(wildcard test/sql/*.sql))
-else ifneq ($(PG_GE13), 0)
-TESTS = $(filter-out test/sql/ge13_%.sql, $(wildcard test/sql/*.sql))
else
TESTS = $(wildcard test/sql/*.sql)
endif
diff --git a/README.md b/README.md
index 1960173..526e4c6 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
-
+
@@ -12,7 +12,7 @@ Supautils is an extension that secures a PostgreSQL cluster on a cloud environme
It doesn't require creating database objects. It's a shared library that modifies PostgreSQL behavior through "hooks", not through tables or functions.
-It's tested to work on PostgreSQL 12, 13, 14 and 15.
+It's tested to work on PostgreSQL 13, 14 and 15.
## Installation
@@ -170,9 +170,6 @@ For testing the module locally, execute:
# might take a while in downloading all the dependencies
$ nix-shell
-# test on pg 12
-$ supautils-with-pg-12 make installcheck
-
# test on pg 13
$ supautils-with-pg-13 make installcheck
@@ -180,5 +177,5 @@ $ supautils-with-pg-13 make installcheck
$ supautils-with-pg-14 make installcheck
# you can also test manually with
-$ supautils-with-pg-12 psql -U rolecreator
+$ supautils-with-pg-13 psql -U rolecreator
```
diff --git a/shell.nix b/shell.nix
index 3575e3d..3870b41 100644
--- a/shell.nix
+++ b/shell.nix
@@ -5,7 +5,6 @@ with import (builtins.fetchTarball {
}) {};
let
supportedPgVersions = [
- postgresql_12
postgresql_13
postgresql_14
postgresql_15
diff --git a/src/constrained_extensions.c b/src/constrained_extensions.c
index f0e8730..50318e0 100644
--- a/src/constrained_extensions.c
+++ b/src/constrained_extensions.c
@@ -1,16 +1,11 @@
-#include "utils.h"
-
-#if PG13_GTE
-
#include
-#include
-#include
-#include
#include
-#include
#include
#include
#include
+#include
+#include
+#include
#include
#ifdef __linux__
@@ -240,5 +235,3 @@ void constrain_extension(
}
}
}
-
-#endif
diff --git a/src/supautils.c b/src/supautils.c
index 19967c0..914c39d 100644
--- a/src/supautils.c
+++ b/src/supautils.c
@@ -18,14 +18,10 @@
#include
#include
+#include "constrained_extensions.h"
#include "privileged_extensions.h"
-
#include "utils.h"
-#if PG13_GTE
-#include "constrained_extensions.h"
-#endif
-
#define EREPORT_RESERVED_MEMBERSHIP(name) \
ereport(ERROR, \
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), \
@@ -61,14 +57,12 @@ static char *privileged_role = NULL;
static char *privileged_role_allowed_configs = NULL;
static ProcessUtility_hook_type prev_hook = NULL;
-#if PG13_GTE
static char *constrained_extensions_str = NULL;
static constrained_extension cexts[MAX_CONSTRAINED_EXTENSIONS] = {0};
static size_t total_cexts = 0;
static void
constrained_extensions_assign_hook(const char *newval, void *extra);
-#endif
void _PG_init(void);
void _PG_fini(void);
@@ -207,7 +201,6 @@ _PG_init(void)
NULL,
NULL);
-#if PG13_GTE
DefineCustomStringVariable("supautils.constrained_extensions",
"Extensions that require a minimum amount of CPUs, memory and free disk to be installed",
NULL,
@@ -217,7 +210,6 @@ _PG_init(void)
NULL,
constrained_extensions_assign_hook,
NULL);
-#endif
if(placeholders){
List* comma_separated_list;
@@ -551,11 +543,9 @@ supautils_hook(PROCESS_UTILITY_PARAMS)
case T_CreateExtensionStmt:
{
-#if PG13_GTE
CreateExtensionStmt *stmt = (CreateExtensionStmt *)utility_stmt;
constrain_extension(stmt->extname, cexts, total_cexts);
-#endif
handle_create_extension(prev_hook,
PROCESS_UTILITY_ARGS,
@@ -893,7 +883,6 @@ check_parameter(char *val, char *name)
}
}
-#if PG13_GTE
void constrained_extensions_assign_hook(const char *newval, void *extra){
if (total_cexts > 0) {
for (size_t i = 0; i < total_cexts; i++){
@@ -911,7 +900,6 @@ void constrained_extensions_assign_hook(const char *newval, void *extra){
}
}
}
-#endif
static void
confirm_reserved_roles(const char *target, bool allow_configurable_roles)
diff --git a/src/utils.h b/src/utils.h
index 56d1b6d..e82d9f0 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -12,7 +12,6 @@
#include
#include
-#define PG13_GTE (PG_VERSION_NUM >= 130000)
#define PG14_GTE (PG_VERSION_NUM >= 140000)
#define PG15_GTE (PG_VERSION_NUM >= 150000)
@@ -25,7 +24,7 @@
#define PROCESS_UTILITY_ARGS \
pstmt, queryString, readOnlyTree, context, params, queryEnv, dest, qc
-#elif PG13_GTE
+#else // PG13
#define PROCESS_UTILITY_PARAMS \
PlannedStmt *pstmt, const char *queryString, \
@@ -34,16 +33,6 @@
#define PROCESS_UTILITY_ARGS \
pstmt, queryString, context, params, queryEnv, dest, qc
-#else
-
-#define PROCESS_UTILITY_PARAMS \
- PlannedStmt *pstmt, const char *queryString, \
- ProcessUtilityContext context, ParamListInfo params, \
- QueryEnvironment *queryEnv, DestReceiver *dest, char *completionTag
-
-#define PROCESS_UTILITY_ARGS \
- pstmt, queryString, context, params, queryEnv, dest, completionTag
-
#endif
#define run_process_utility_hook(process_utility_hook) \