Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1b515b9
Add GitHub Actions workflow for testing PostgreSQL versions 13-17 and…
cursoragent Jul 15, 2025
e3be4b2
Improve GitHub Actions workflow for PostgreSQL testing
cursoragent Jul 15, 2025
b57de9f
Simplify GitHub Actions workflow for PostgreSQL testing
cursoragent Jul 15, 2025
d189092
Improve PostgreSQL configuration and error handling in CI workflow
cursoragent Jul 15, 2025
ab11877
Update CI to test multiple PostgreSQL versions with improved configur…
cursoragent Jul 15, 2025
be6de78
Update GitHub Actions to test PostgreSQL 13-17 and remove CircleCI
NikolayS Jul 15, 2025
37070d9
Fix GitHub Actions PostgreSQL configuration and test execution
NikolayS Jul 15, 2025
704f6b4
Fix PostgreSQL client installation for all versions
NikolayS Jul 15, 2025
e81f250
Simplify PostgreSQL client installation to fix version compatibility
NikolayS Jul 15, 2025
17c73b8
Fix GitHub Actions PostgreSQL client installation and remove beta ver…
NikolayS Sep 29, 2025
14f253e
Fix PostgreSQL configuration by running pg_ctl as postgres user
NikolayS Sep 29, 2025
0db8d88
Simplify PostgreSQL configuration using environment variables
NikolayS Sep 29, 2025
46d4be1
Fix Docker options and PostgreSQL configuration
NikolayS Sep 29, 2025
1717ff9
Fix PostgreSQL version compatibility issues
NikolayS Sep 29, 2025
9a33eeb
Fix PostgreSQL version detection using server_version_num
NikolayS Sep 29, 2025
51b1b7d
Use functions to handle PostgreSQL 17 version differences
NikolayS Sep 29, 2025
0c49aae
Remove final CircleCI reference from workflow
NikolayS Sep 29, 2025
68b1299
Update CHANGELOG for version 18.0 release
NikolayS Sep 29, 2025
59431c6
Remove CHANGELOG.md
NikolayS Sep 29, 2025
79b9a0c
Remove DDL functions and use informational messages for PG17+
NikolayS Sep 29, 2025
bea1d00
Test with minimal privileges (pg_monitor) and add PostgreSQL 18 beta
NikolayS Sep 29, 2025
856941a
Add PostgreSQL 18 stable to test matrix
NikolayS Sep 29, 2025
364184a
Fix PostgreSQL 17/18 compatibility using WHERE clauses
NikolayS Sep 29, 2025
7cd6072
Remove checkpoint statistics queries to ensure compatibility
NikolayS Sep 29, 2025
4c3bc28
Implement proper checkpoint statistics for PostgreSQL 17+
NikolayS Sep 29, 2025
1980cef
Fix binary units usage in checkpoint statistics
NikolayS Sep 29, 2025
0bafa64
Add supported PostgreSQL versions section to README
NikolayS Sep 29, 2025
ac89209
Update README to reference postgres_ai monitoring platform
NikolayS Sep 29, 2025
1d47ee5
Add backticks formatting for pg_stat_checkpointer in README
NikolayS Sep 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 0 additions & 77 deletions .circleci/config.yml

This file was deleted.

149 changes: 149 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: Test PostgreSQL Versions

on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
postgres-version: ['13', '14', '15', '16', '17', '18']
fail-fast: false

services:
postgres:
image: postgres:${{ matrix.postgres-version }}
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_INITDB_ARGS: --auth-host=trust --auth-local=trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install PostgreSQL client
run: |
# Install default PostgreSQL client (works for all versions)
sudo apt-get update
sudo apt-get install -y postgresql-client
# Verify installation
psql --version
- name: Prepare test database
run: |
# Wait for PostgreSQL to be ready
until pg_isready -h localhost -p 5432 -U postgres; do
echo "Waiting for postgres..."
sleep 2
done
# Check PostgreSQL version
psql -h localhost -U postgres -d test -c 'SELECT version();'
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

follow SQL code style (check .cursor)

# Create extensions (pg_stat_statements may not work without shared_preload_libraries)
psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;' || echo "Warning: pg_stat_statements extension not available"
psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;'
# Create minimal privilege user for testing
psql -h localhost -U postgres -d test -c "CREATE USER dba_user;"
psql -h localhost -U postgres -d test -c "GRANT pg_monitor TO dba_user;"
psql -h localhost -U postgres -d test -c "GRANT CONNECT ON DATABASE test TO dba_user;"
psql -h localhost -U postgres -d test -c "GRANT USAGE ON SCHEMA public TO dba_user;"
# Verify extensions
psql -h localhost -U postgres -d test -c 'SELECT extname FROM pg_extension ORDER BY extname;'
# Create test tables for alignment testing (as superuser)
psql -h localhost -U postgres -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);"
psql -h localhost -U postgres -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);"
# Grant access to test tables for dba_user
psql -h localhost -U postgres -d test -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO dba_user;"
# Test connection as dba_user
psql -h localhost -U dba_user -d test -c 'SELECT current_user, session_user;'
- name: Test wide mode
run: |
echo "\set postgres_dba_wide true" > ~/.psqlrc
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
echo "Testing all SQL files in wide mode with minimal privileges..."
for f in sql/*; do
echo " Testing $f..."
if ! psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1; then
echo "❌ FAILED: $f in wide mode"
echo "Error output:"
psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f "$f"
exit 1
fi
done
echo "✅ All tests passed in wide mode"
- name: Test normal mode
run: |
echo "\set postgres_dba_wide false" > ~/.psqlrc
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
echo "Testing all SQL files in normal mode with minimal privileges..."
for f in sql/*; do
echo " Testing $f..."
if ! psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1; then
echo "❌ FAILED: $f in normal mode"
echo "Error output:"
psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f "$f"
exit 1
fi
done
echo "✅ All tests passed in normal mode"
- name: Run regression tests
run: |
echo "\set postgres_dba_wide false" > ~/.psqlrc
echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
echo "Running regression tests with minimal privileges..."
echo " Testing 0_node.sql..."
OUTPUT=$(psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f sql/0_node.sql | grep Role)
if [[ "$OUTPUT" == *"Master"* ]]; then
echo " ✓ Role test passed"
else
echo " ✗ Role test failed: $OUTPUT"
exit 1
fi
echo " Testing p1_alignment_padding.sql..."
OUTPUT=$(psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f sql/p1_alignment_padding.sql | grep align)
if [[ "$OUTPUT" == *"align1"* && "$OUTPUT" == *"align2"* && "$OUTPUT" == *"int4, more, int8"* ]]; then
echo " ✓ Alignment padding test passed"
else
echo " ✗ Alignment padding test failed: $OUTPUT"
exit 1
fi
echo " Testing a1_activity.sql..."
OUTPUT=$(psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f sql/a1_activity.sql | grep User)
if [[ "$OUTPUT" == *"User"* ]]; then
echo " ✓ Activity test passed"
else
echo " ✗ Activity test failed: $OUTPUT"
exit 1
fi
echo "✅ All regression tests passed with minimal privileges"
41 changes: 27 additions & 14 deletions sql/0_node.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ For Postgres versions older than 10, run this first:
\set postgres_dba_is_wal_replay_paused pg_is_xlog_replay_paused
*/


with data as (
select s.*
from pg_stat_database s
Expand Down Expand Up @@ -50,26 +51,38 @@ select 'Uptime', (now() - pg_postmaster_start_time())::interval(0)::text
union all
select
'Checkpoints',
(select (checkpoints_timed + checkpoints_req)::text from pg_stat_bgwriter)
case
when current_setting('server_version_num')::int >= 170000
then 'See pg_stat_checkpointer (PG17+)'
else (select (checkpoints_timed + checkpoints_req)::text from pg_stat_bgwriter)
end
union all
select
'Forced Checkpoints',
(
select round(100.0 * checkpoints_req::numeric /
(nullif(checkpoints_timed + checkpoints_req, 0)), 1)::text || '%'
from pg_stat_bgwriter
)
case
when current_setting('server_version_num')::int >= 170000
then 'See pg_stat_checkpointer (PG17+)'
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's implement it?

else (
select round(100.0 * checkpoints_req::numeric /
(nullif(checkpoints_timed + checkpoints_req, 0)), 1)::text || '%'
from pg_stat_bgwriter
)
end
union all
select
'Checkpoint MB/sec',
(
select round((nullif(buffers_checkpoint::numeric, 0) /
((1024.0 * 1024 /
(current_setting('block_size')::numeric))
* extract('epoch' from now() - stats_reset)
))::numeric, 6)::text
from pg_stat_bgwriter
)
case
when current_setting('server_version_num')::int >= 170000
then 'See pg_stat_checkpointer (PG17+)'
else (
select round((nullif(buffers_checkpoint::numeric, 0) /
((1024.0 * 1024 /
(current_setting('block_size')::numeric))
* extract('epoch' from now() - stats_reset)
))::numeric, 6)::text
from pg_stat_bgwriter
)
end
union all
select repeat('-', 33), repeat('-', 88)
union all
Expand Down
Loading