Skip to content

Commit 872ed4e

Browse files
feat: Drop support for pg 9.6
1 parent adb5119 commit 872ed4e

File tree

19 files changed

+449
-604
lines changed

19 files changed

+449
-604
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
strategy:
7171
fail-fast: false
7272
matrix:
73-
pgVersion: [9.6, 10, 11, 12, 13, 14, 15, 16]
73+
pgVersion: [10, 11, 12, 13, 14, 15, 16]
7474
name: Test PG ${{ matrix.pgVersion }} (Nix)
7575
runs-on: ubuntu-latest
7676
defaults:

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1818
- #2815, Build static executable with GSSAPI support - @wolfgangwalther
1919
- #3205, Fix wrong subquery error returning a status of 400 Bad Request - @steve-chavez
2020

21+
### Changed
22+
- #2052, Dropped support for PostgreSQL 9.6 - @wolfgangwalther
23+
2124
### Deprecated
2225

2326
- `Prefer: params=single-object` is deprecated. Use [a function with a single unnamed JSON parameter](https://postgrest.org/en/latest/references/api/stored_procedures.html#s-proc-single-json) instead. - @steve-chavez

default.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ let
6363
{ name = "postgresql-12"; postgresql = pkgs.postgresql_12.withPackages (p: [ p.postgis p.pg_safeupdate ]); }
6464
{ name = "postgresql-11"; postgresql = pkgs.postgresql_11.withPackages (p: [ p.postgis p.pg_safeupdate ]); }
6565
{ name = "postgresql-10"; postgresql = pkgs.postgresql_10.withPackages (p: [ p.postgis p.pg_safeupdate ]); }
66-
{ name = "postgresql-9.6"; postgresql = pkgs.postgresql_9_6.withPackages (p: [ p.postgis p.pg_safeupdate ]); }
6766
];
6867

6968
# Dynamic derivation for PostgREST

nix/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ postgrest-coverage postgrest-with-postgresql-10
7979
postgrest-lint postgrest-with-postgresql-11
8080
postgrest-run postgrest-with-postgresql-12
8181
postgrest-style postgrest-with-postgresql-13
82-
postgrest-style-check postgrest-with-postgresql-9.6
82+
postgrest-style-check postgrest-with-postgresql-14
8383
postgrest-test-io
8484
...
8585

@@ -103,7 +103,7 @@ postgrest-coverage postgrest-with-postgresql-10
103103
postgrest-lint postgrest-with-postgresql-11
104104
postgrest-run postgrest-with-postgresql-12
105105
postgrest-style postgrest-with-postgresql-13
106-
postgrest-style-check postgrest-with-postgresql-9.6
106+
postgrest-style-check postgrest-with-postgresql-14
107107
postgrest-test-io
108108
postgrest-test-memory
109109
...

nix/overlays/postgis.nix

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,4 @@ in
2020
postgis = prev.postgresql_10.pkgs.postgis.overrideAttrs (_: postgis_3_2_3);
2121
};
2222
};
23-
postgresql_9_6 = prev.postgresql_9_6.override { this = final.postgresql_11; } // {
24-
pkgs = prev.postgresql_9_6.pkgs // {
25-
postgis = prev.postgresql_9_6.pkgs.postgis.overrideAttrs (_: postgis_3_2_3);
26-
};
27-
};
2823
}

nix/overlays/postgresql-legacy.nix

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,6 @@ self: super:
22
# Overlay that adds legacy versions of PostgreSQL that are supported by
33
# PostgREST.
44
{
5-
# PostgreSQL 9.6 was removed from Nixpkgs with
6-
# https://github.com/NixOS/nixpkgs/commit/757dd008b2f2926fc0f7688fa8189f930ea47521
7-
# We pin its parent commit to get the last version that was available.
8-
postgresql_9_6 =
9-
let
10-
rev = "571cbf3d1db477058303cef8754fb85a14e90eb7";
11-
tarballHash = "0q74wn418i1bn5sssacmw8ykpmqvzr0s93sj6pbs3rf6bf134fkz";
12-
pinnedPkgs =
13-
builtins.fetchTarball {
14-
url = "https://github.com/nixos/nixpkgs/archive/${rev}.tar.gz";
15-
sha256 = tarballHash;
16-
};
17-
in
18-
(import pinnedPkgs { }).pkgs.postgresql_9_6;
19-
205
# PostgreSQL 10 was removed from Nixpkgs with
216
# https://github.com/NixOS/nixpkgs/commit/aa1483114bb329fee7e1266100b8d8921ed4723f
227
# We pin its parent commit to get the last version that was available.

src/PostgREST/Config/PgVersion.hs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
module PostgREST.Config.PgVersion
44
( PgVersion(..)
55
, minimumPgVersion
6-
, pgVersion96
7-
, pgVersion100
86
, pgVersion109
97
, pgVersion110
108
, pgVersion112
@@ -32,10 +30,7 @@ instance Ord PgVersion where
3230

3331
-- | Tells the minimum PostgreSQL version required by this version of PostgREST
3432
minimumPgVersion :: PgVersion
35-
minimumPgVersion = pgVersion96
36-
37-
pgVersion96 :: PgVersion
38-
pgVersion96 = PgVersion 90600 "9.6"
33+
minimumPgVersion = pgVersion100
3934

4035
pgVersion100 :: PgVersion
4136
pgVersion100 = PgVersion 100000 "10"

src/PostgREST/Query.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ openApiQuery :: SchemaCache -> PgVersion -> AppConfig -> Schema -> DbHandler (Ma
176176
openApiQuery sCache pgVer AppConfig{..} tSchema =
177177
lift $ case configOpenApiMode of
178178
OAFollowPriv -> do
179-
tableAccess <- SQL.statement [tSchema] (SchemaCache.accessibleTables pgVer configDbPreparedStatements)
179+
tableAccess <- SQL.statement [tSchema] (SchemaCache.accessibleTables configDbPreparedStatements)
180180
Just <$> ((,,)
181181
(HM.filterWithKey (\qi _ -> S.member qi tableAccess) $ SchemaCache.dbTables sCache)
182182
<$> SQL.statement tSchema (SchemaCache.accessibleFuncs pgVer configDbPreparedStatements)

src/PostgREST/SchemaCache.hs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ import PostgREST.Config (AppConfig (..))
4848
import PostgREST.Config.Database (TimezoneNames,
4949
pgVersionStatement,
5050
toIsolationLevel)
51-
import PostgREST.Config.PgVersion (PgVersion, pgVersion100,
52-
pgVersion110,
51+
import PostgREST.Config.PgVersion (PgVersion, pgVersion110,
5352
pgVersion120)
5453
import PostgREST.SchemaCache.Identifiers (AccessSet, FieldName,
5554
QualifiedIdentifier (..),
@@ -478,8 +477,8 @@ schemaDescription =
478477
where
479478
n.nspname = $1 |]
480479

481-
accessibleTables :: PgVersion -> Bool -> SQL.Statement [Schema] AccessSet
482-
accessibleTables pgVer =
480+
accessibleTables :: Bool -> SQL.Statement [Schema] AccessSet
481+
accessibleTables =
483482
SQL.Statement sql (arrayParam HE.text) decodeAccessibleIdentifiers
484483
where
485484
sql = [q|
@@ -495,10 +494,9 @@ accessibleTables pgVer =
495494
pg_has_role(c.relowner, 'USAGE')
496495
or has_table_privilege(c.oid, 'SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER')
497496
or has_any_column_privilege(c.oid, 'SELECT, INSERT, UPDATE, REFERENCES')
498-
) |] <>
499-
relIsPartition <>
500-
"ORDER BY table_schema, table_name"
501-
relIsPartition = if pgVer >= pgVersion100 then " AND not c.relispartition " else mempty
497+
)
498+
AND not c.relispartition
499+
ORDER BY table_schema, table_name|]
502500

503501
{-
504502
Adds M2O and O2O relationships for views to tables, tables to views, and views to views. The example below is taken from the test fixtures, but the views names/colnames were modified.
@@ -810,11 +808,10 @@ tablesSqlQuery pgVer =
810808
LEFT JOIN tbl_pk_cols tpks ON n.nspname = tpks.table_schema AND c.relname = tpks.table_name
811809
LEFT JOIN columns_agg cols_agg ON n.nspname = cols_agg.table_schema AND c.relname = cols_agg.table_name
812810
WHERE c.relkind IN ('v','r','m','f','p')
813-
AND n.nspname NOT IN ('pg_catalog', 'information_schema') |] <>
814-
relIsPartition <>
815-
"ORDER BY table_schema, table_name"
811+
AND n.nspname NOT IN ('pg_catalog', 'information_schema')
812+
AND not c.relispartition
813+
ORDER BY table_schema, table_name|]
816814
where
817-
relIsPartition = if pgVer >= pgVersion100 then " AND not c.relispartition " else mempty
818815
columnDefault -- typbasetype and typdefaultbin handles `CREATE DOMAIN .. DEFAULT val`, attidentity/attgenerated handles generated columns, pg_get_expr gets the default of a column
819816
| pgVer >= pgVersion120 = [q|
820817
CASE
@@ -823,17 +820,12 @@ tablesSqlQuery pgVer =
823820
WHEN a.attgenerated = 's' THEN null
824821
ELSE pg_get_expr(ad.adbin, ad.adrelid)::text
825822
END|]
826-
| pgVer >= pgVersion100 = [q|
823+
| otherwise = [q|
827824
CASE
828825
WHEN t.typbasetype != 0 THEN pg_get_expr(t.typdefaultbin, 0)
829826
WHEN a.attidentity = 'd' THEN format('nextval(%s)', quote_literal(seqsch.nspname || '.' || seqclass.relname))
830827
ELSE pg_get_expr(ad.adbin, ad.adrelid)::text
831828
END|]
832-
| otherwise = [q|
833-
CASE
834-
WHEN t.typbasetype != 0 THEN pg_get_expr(t.typdefaultbin, 0)
835-
ELSE pg_get_expr(ad.adbin, ad.adrelid)::text
836-
END|]
837829

838830
-- | Gets many-to-one relationships and one-to-one(O2O) relationships, which are a refinement of the many-to-one's
839831
allM2OandO2ORels :: PgVersion -> Bool -> SQL.Statement () [Relationship]

test/spec/Feature/OpenApi/OpenApiSpec.hs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import Network.HTTP.Types
1111
import Test.Hspec hiding (pendingWith)
1212
import Test.Hspec.Wai
1313

14-
import PostgREST.Config.PgVersion (PgVersion, pgVersion100,
15-
pgVersion110)
14+
import PostgREST.Config.PgVersion (PgVersion, pgVersion110)
1615

1716
import PostgREST.Version (docsVersion)
1817
import Protolude hiding (get)
@@ -254,31 +253,30 @@ spec actualPgVersion = describe "OpenAPI" $ do
254253
]
255254
|]
256255

257-
when (actualPgVersion >= pgVersion100) $ do
258-
describe "Partitioned table" $
256+
describe "Partitioned table" $
259257

260-
it "includes partitioned table properties" $ do
261-
r <- simpleBody <$> get "/"
258+
it "includes partitioned table properties" $ do
259+
r <- simpleBody <$> get "/"
262260

263-
let method s = key "paths" . key "/car_models" . key s
264-
getSummary = r ^? method "get" . key "summary"
265-
getDescription = r ^? method "get" . key "description"
266-
getParameterName = r ^? method "get" . key "parameters" . nth 0 . key "$ref"
267-
getParameterYear = r ^? method "get" . key "parameters" . nth 1 . key "$ref"
268-
getParameterRef = r ^? method "get" . key "parameters" . nth 2 . key "$ref"
261+
let method s = key "paths" . key "/car_models" . key s
262+
getSummary = r ^? method "get" . key "summary"
263+
getDescription = r ^? method "get" . key "description"
264+
getParameterName = r ^? method "get" . key "parameters" . nth 0 . key "$ref"
265+
getParameterYear = r ^? method "get" . key "parameters" . nth 1 . key "$ref"
266+
getParameterRef = r ^? method "get" . key "parameters" . nth 2 . key "$ref"
269267

270-
liftIO $ do
268+
liftIO $ do
271269

272-
getSummary `shouldBe` Just "A partitioned table"
270+
getSummary `shouldBe` Just "A partitioned table"
273271

274-
getDescription `shouldBe` Just "A test for partitioned tables"
272+
getDescription `shouldBe` Just "A test for partitioned tables"
275273

276-
getParameterName `shouldBe` Just "#/parameters/rowFilter.car_models.name"
274+
getParameterName `shouldBe` Just "#/parameters/rowFilter.car_models.name"
277275

278-
getParameterYear `shouldBe` Just "#/parameters/rowFilter.car_models.year"
276+
getParameterYear `shouldBe` Just "#/parameters/rowFilter.car_models.year"
279277

280-
when (actualPgVersion >= pgVersion110) $
281-
getParameterRef `shouldBe` Just "#/parameters/rowFilter.car_models.car_brand_name"
278+
when (actualPgVersion >= pgVersion110) $
279+
getParameterRef `shouldBe` Just "#/parameters/rowFilter.car_models.car_brand_name"
282280

283281
describe "Materialized view" $
284282

0 commit comments

Comments
 (0)