From 22cf7e48bb4e88639e307cf61a1234ea3e10d5ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabr=C3=ADzio=20de=20Royes=20Mello?= Date: Mon, 29 Apr 2024 15:50:48 -0300 Subject: [PATCH] Release notes header 2.15.0 --- .unreleased/RELEASE_NOTES_HEADER.md.j2 | 91 +++++++++++++++++++ ...es.j2 => template.release_notes_header.j2} | 0 scripts/merge_changelogs.sh | 8 +- 3 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 .unreleased/RELEASE_NOTES_HEADER.md.j2 rename .unreleased/{template.release_notes.j2 => template.release_notes_header.j2} (100%) diff --git a/.unreleased/RELEASE_NOTES_HEADER.md.j2 b/.unreleased/RELEASE_NOTES_HEADER.md.j2 new file mode 100644 index 00000000000..5ed21c5ae22 --- /dev/null +++ b/.unreleased/RELEASE_NOTES_HEADER.md.j2 @@ -0,0 +1,91 @@ +## {{ release_current }} ({{ release_date }}) + +This release contains performance improvements and bug fixes since +the {{ release_previous }} release. We recommend that you upgrade at the next +available opportunity. + +In addition, it includes these noteworthy features: +* foo +* bar + +**For on-premise users and this release only**, you will need to run the following SQL script after running `ALTER EXTENSION`. More details can be found in the pull request [#6786](https://github.com/timescale/timescaledb/pull/6797). + +```sql +CREATE OR REPLACE FUNCTION pg_temp.constraint_columns(regclass, int2[]) RETURNS text[] AS +$$ + SELECT array_agg(attname) FROM unnest($2) un(attnum) LEFT JOIN pg_attribute att ON att.attrelid=$1 AND att.attnum = un.attnum; +$$ LANGUAGE SQL SET search_path TO pg_catalog, pg_temp; + +DO $$ +DECLARE + ht_id int; + ht regclass; + chunk regclass; + con_oid oid; + con_frelid regclass; + con_name text; + con_columns text[]; + chunk_id int; + +BEGIN + + -- iterate over all hypertables that have foreign key constraints + FOR ht_id, ht in + SELECT + ht.id, + format('%I.%I',ht.schema_name,ht.table_name)::regclass + FROM _timescaledb_catalog.hypertable ht + WHERE + EXISTS ( + SELECT FROM pg_constraint con + WHERE + con.contype='f' AND + con.conrelid=format('%I.%I',ht.schema_name,ht.table_name)::regclass + ) + LOOP + RAISE NOTICE 'Hypertable % has foreign key constraint', ht; + + -- iterate over all foreign key constraints on the hypertable + -- and check that they are present on every chunk + FOR con_oid, con_frelid, con_name, con_columns IN + SELECT con.oid, con.confrelid, con.conname, pg_temp.constraint_columns(con.conrelid,con.conkey) + FROM pg_constraint con + WHERE + con.contype='f' AND + con.conrelid=ht + LOOP + RAISE NOTICE 'Checking constraint % %', con_name, con_columns; + -- check that the foreign key constraint is present on the chunk + + FOR chunk_id, chunk IN + SELECT + ch.id, + format('%I.%I',ch.schema_name,ch.table_name)::regclass + FROM _timescaledb_catalog.chunk ch + WHERE + ch.hypertable_id=ht_id + LOOP + RAISE NOTICE 'Checking chunk %', chunk; + IF NOT EXISTS ( + SELECT FROM pg_constraint con + WHERE + con.contype='f' AND + con.conrelid=chunk AND + con.confrelid=con_frelid AND + pg_temp.constraint_columns(con.conrelid,con.conkey) = con_columns + ) THEN + RAISE WARNING 'Restoring constraint % on chunk %', con_name, chunk; + PERFORM _timescaledb_functions.constraint_clone(con_oid, chunk); + INSERT INTO _timescaledb_catalog.chunk_constraint(chunk_id, dimension_slice_id, constraint_name, hypertable_constraint_name) VALUES (chunk_id, NULL, con_name, con_name); + END IF; + + END LOOP; + END LOOP; + + END LOOP; + +END +$$; + +DROP FUNCTION pg_temp.constraint_columns(regclass, int2[]); +``` diff --git a/.unreleased/template.release_notes.j2 b/.unreleased/template.release_notes_header.j2 similarity index 100% rename from .unreleased/template.release_notes.j2 rename to .unreleased/template.release_notes_header.j2 diff --git a/scripts/merge_changelogs.sh b/scripts/merge_changelogs.sh index 2b97f1ba780..7d1ca1f2c89 100755 --- a/scripts/merge_changelogs.sh +++ b/scripts/merge_changelogs.sh @@ -4,14 +4,14 @@ # This script build a CHANGELOG.md entry for a new release # -RELEASE_NOTES_TEMPLATE='.unreleased/RELEASE_NOTES.md.j2' +RELEASE_NOTES_HEADER_TEMPLATE='.unreleased/RELEASE_NOTES_HEADER.md.j2' echo_changelog() { echo "${1}" # skip the template and release notes files grep -i "${2}" .unreleased/* | \ grep -v '.unreleased/template.*' | \ - grep -v "${RELEASE_NOTES_TEMPLATE}" | \ + grep -v "${RELEASE_NOTES_HEADER_TEMPLATE}" | \ cut -d: -f3- | sort | uniq | sed -e 's/^[[:space:]]*//' -e 's/^/* /' echo } @@ -28,12 +28,12 @@ RELEASE_DATE=$(date +"%Y-%m-%d") # To install jinja template client: # $ pip install jinja-cli # -if [ -f "${RELEASE_NOTES_TEMPLATE}" ]; +if [ -f "${RELEASE_NOTES_HEADER_TEMPLATE}" ]; then jinja \ -D release_current "${RELEASE_CURRENT}" \ -D release_previous "${RELEASE_PREVIOUS}" \ - -D release_date "${RELEASE_DATE}" ${RELEASE_NOTES_TEMPLATE} + -D release_date "${RELEASE_DATE}" ${RELEASE_NOTES_HEADER_TEMPLATE} echo fi