Fix remaining PostgreSQL reference bugs

Make temporal, upgrade, and replication examples runnable without omitted dependencies or misleading worker rows.
This commit is contained in:
sav-maya
2026-08-20 13:26:53 -07:00
parent 01c9ee75a3
commit a8b6fd65a9
3 changed files with 10 additions and 2 deletions
@@ -382,7 +382,10 @@ SELECT
now() - st.latest_end_time AS time_lag
FROM pg_subscription s
JOIN pg_stat_subscription st ON st.subid = s.oid
WHERE st.pid IS NOT NULL;
WHERE st.pid IS NOT NULL
AND st.relid IS NULL
-- PG17+ can also expose parallel apply workers; keep only the leader.
AND coalesce(to_jsonb(st)->>'worker_type', 'apply') = 'apply';
```
## Schema Changes During Replication
@@ -226,8 +226,11 @@ Never upgrade production first. Test on a copy:
# Create a test copy
pg_basebackup -D /tmp/upgrade_test -Fp -Xs -P
# Initialize an empty target cluster with the new version's binaries
/usr/lib/postgresql/17/bin/initdb -D /tmp/new_cluster
# Run pg_upgrade --check against the copy
pg_upgrade --check \
/usr/lib/postgresql/17/bin/pg_upgrade --check \
--old-datadir /tmp/upgrade_test \
--new-datadir /tmp/new_cluster \
--old-bindir /usr/lib/postgresql/16/bin \
@@ -173,6 +173,8 @@ This prevents overlapping bookings for the same room at the database level.
PG18 adds built-in temporal constraint support, simplifying the exclusion constraint pattern above:
```sql
CREATE EXTENSION IF NOT EXISTS btree_gist;
CREATE TABLE room_bookings (
room_id int NOT NULL,
during tstzrange NOT NULL,