Skip to content

Commit ffe97c4

Browse files
nicolagigheine
andauthored
FDN-2062: Add support for Postgres 15 (#23)
* FDN-2062: Add support for Postgres 15 In Postgres 15, the `pg_class` table does not have `relhasoids`, so Partman's code from this repository does not work in Postgres 15. None of our tables were created WITH OIDS, according to the query shown here and grepping the source code, so just removing the part that checks for OIDS will work. (This code that I'm removing hasn't been completely removed in recent versions of Partman, but it is guarded by a version check.) The change to `journal.quote_column` reflects type changes from Postgres 11 to Postgres 15, but also works against Postgres 11 (as in, this package still builds fine against PG 11 with this change). The install script needs to grant permissions to the public schema in Postgres 15. An additional `Dockerfile-15` has been added to create a Postgres 15 based image. The Travis configuration has been updated to build that image. New scripts have been added to recreate the modified functions in production: - `journal.quote_column` - `partman.create_partition_id` - `partman.create_partition_time` [so]: https://stackoverflow.com/questions/70257495/postgresql-how-can-i-check-if-table-was-created-with-oids * update hg check --------- Co-authored-by: Gregor Heine <gregor@flow.io>
1 parent 05bb4c0 commit ffe97c4

11 files changed

Lines changed: 698 additions & 42 deletions

.github/pr-validator.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/pr-validator.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: "PR Title and Description Check"
2+
on:
3+
pull_request:
4+
types: [opened, edited, synchronize]
5+
6+
jobs:
7+
check-title-and-description:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Check PR title and description
11+
uses: actions/github-script@v4
12+
with:
13+
github-token: ${{ secrets.GITHUB_TOKEN }}
14+
script: |
15+
const payload = context.payload;
16+
const prTitle = payload.pull_request.title;
17+
const prDescription = payload.pull_request.body;
18+
19+
// The pattern for JIRA ticket format
20+
const jiraPattern = /\b[A-Z]+-\d+\b|breakglass/gi;
21+
22+
// Check PR title
23+
const hasJiraTitle = jiraPattern.test(prTitle);
24+
console.log(`PR title: ${hasJiraTitle ? 'Valid' : 'Invalid'}`);
25+
26+
// Check PR description
27+
const hasJiraDescription = prDescription ? prDescription.match(jiraPattern) : false;
28+
console.log(`PR description: ${hasJiraDescription ? 'Valid' : 'Invalid'}`);
29+
30+
if (hasJiraTitle || hasJiraDescription) {
31+
console.log('PR title or description format is correct.');
32+
} else {
33+
const errorMessage = [];
34+
errorMessage.push('The PR title and description do not include a valid JIRA ticket!');
35+
console.log(errorMessage.join('\n'));
36+
37+
core.setFailed(errorMessage.join('\n'));
38+
}

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# for caching, see: http://www.scala-sbt.org/0.13/docs/Travis-CI-with-sbt.html
22
# sudo:false necessary for travis container-based infra, allowing caching
33
sudo: false
4+
dist: jammy
45
services:
56
- docker
67
script:
78
- docker build .
9+
- docker build -f Dockerfile-15 .
810
branches:
911
only:
1012
- main

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM flowdocker/postgresql:0.1.63
1+
FROM flowdocker/postgresql:latest
22

33
ADD . /opt/schema
44
WORKDIR /opt/schema

Dockerfile-15

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM flowdocker/postgresql15:latest
2+
3+
ADD . /opt/schema
4+
WORKDIR /opt/schema
5+
6+
RUN service postgresql start && \
7+
./install.sh && \
8+
service postgresql stop
9+
10+
USER "postgres"
11+
CMD ["/usr/lib/postgresql/15/bin/postgres", "-i", "-D", "/var/lib/postgresql/15/main"]

install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
psql -U postgres -c 'create database dependencydb' postgres
44
psql -U postgres -c 'create role api login PASSWORD NULL' postgres > /dev/null
55
psql -U postgres -c 'GRANT ALL ON DATABASE dependencydb TO api' postgres
6+
psql -U postgres -c 'grant all on schema public to api' dependencydb
67
sem-apply --url postgresql://api@localhost/dependencydb

scripts/20151107-131159.sql

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,14 +2361,6 @@ FOREACH v_id IN ARRAY p_partition_ids LOOP
23612361
, v_partition_name
23622362
, v_parent_schema
23632363
, v_parent_tablename);
2364-
SELECT relhasoids INTO v_hasoids
2365-
FROM pg_catalog.pg_class c
2366-
JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid
2367-
WHERE c.relname = v_parent_tablename
2368-
AND n.nspname = v_parent_schema;
2369-
IF v_hasoids IS TRUE THEN
2370-
v_sql := v_sql || ' WITH (OIDS)';
2371-
END IF;
23722364
EXECUTE v_sql;
23732365
IF v_parent_tablespace IS NOT NULL THEN
23742366
EXECUTE format('ALTER TABLE %I.%I SET TABLESPACE %I', v_parent_schema, v_partition_name, v_parent_tablespace);
@@ -2694,14 +2686,6 @@ FOREACH v_time IN ARRAY p_partition_times LOOP
26942686
, v_partition_name
26952687
, v_parent_schema
26962688
, v_parent_tablename);
2697-
SELECT relhasoids INTO v_hasoids
2698-
FROM pg_catalog.pg_class c
2699-
JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid
2700-
WHERE c.relname = v_parent_tablename
2701-
AND n.nspname = v_parent_schema;
2702-
IF v_hasoids IS TRUE THEN
2703-
v_sql := v_sql || ' WITH (OIDS)';
2704-
END IF;
27052689
EXECUTE v_sql;
27062690
IF v_parent_tablespace IS NOT NULL THEN
27072691
EXECUTE format('ALTER TABLE %I.%I SET TABLESPACE %I', v_parent_schema, v_partition_name, v_parent_tablespace);

scripts/20181029-115650.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create or replace function journal.quote_column(name in varchar) returns varchar language plpgsql as $$
1+
create or replace function journal.quote_column(name in information_schema.sql_identifier) returns text language plpgsql as $$
22
begin
33
return '"' || name || '"';
44
end;

scripts/20240201-173934.sql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- Drop the function first, can't replace it because the signature changed.
2+
-- Can't assume the function exists either (e.g., tokendb doesn't have it).
3+
DROP FUNCTION IF EXISTS journal.quote_column;
4+
CREATE FUNCTION journal.quote_column(name information_schema.sql_identifier)
5+
RETURNS text
6+
LANGUAGE plpgsql
7+
AS $function$
8+
begin
9+
return '"' || name || '"';
10+
end;
11+
$function$

0 commit comments

Comments
 (0)