Refactor pg_os into single SQL file and improve documentation - #67
Merged
Conversation
The extension failed to install at all and CI never actually ran the regression tests, so a number of real defects had gone unnoticed. This makes `CREATE EXTENSION pg_os` work, gets the full suite passing, and removes the divergent duplicate sources. Correctness fixes (pg_os--1.0.sql): - Rename the reserved-prefix roles pg_os_admin/pg_os_limited to pgos_admin/pgos_limited. CREATE ROLE rejects the reserved "pg_" prefix, which aborted CREATE EXTENSION entirely. - Qualify ambiguous column references that errored under the default plpgsql.variable_conflict=error: create_file, version_file, unlock_file, process_count_by_state, handle_signals, free_memory. - Point the SECURITY DEFINER lock/semaphore helpers' search_path at @extschema@ instead of pg_catalog so they can see the extension's own tables, and grant pgos_admin the privileges those helpers need so an unprivileged role can use the API without direct table access. - Stop schedule_threads() from looping forever by terminating threads after they run instead of returning them to 'ready'. Tests: - Regenerate the stale expected output for create_file, file_versioning, lock_file and locks_security to match the corrected behaviour. - Add the orphaned allocate_page test to REGRESS and drop the duplicate create_process entry. CI: - Build, install and actually run `make installcheck` (the previous workflow only started PostgreSQL), with a superuser role for the runner and regression diffs printed on failure. Cleanup: - Make pg_os--1.0.sql the single source of truth and remove the unused, drifted root-level module fragments (os.sql, fs.sql, processes.sql, …). - Rewrite README to document the real API instead of nonexistent functions, and drop the empty resultmap file. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ty3Rkif9Vfe95w8TMiKB4b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR consolidates the modular SQL files into a single
pg_os--1.0.sqlextension file, updates the README with clearer project description and usage examples, and fixes several bugs and inconsistencies in the codebase.Key Changes
Consolidated SQL modules: Merged all separate SQL files (
usersrolespermissions.sql,processes.sql,scheduler.sql,locks.sql,signals.sql,memory.sql,fs.sql,ipc.sql,audit.sql,gc.sql,io.sql,network.sql,modules.sql,power.sql) into a singlepg_os--1.0.sqlfile for simpler installation and maintenance.Renamed admin role: Changed
pg_os_admintopgos_adminthroughout the codebase for consistency.Fixed scheduler bug: Modified
schedule_threads()to mark threads asterminatedinstead ofreadyafter execution, preventing infinite loops in the scheduler.Fixed type casting: Added explicit
::INTEGERcast inprocess_count_by_state()to resolve type inference issues.Improved README:
Updated CI workflow: Changed PostgreSQL development headers package from
postgresql-server-dev-16topostgresql-server-dev-allfor better compatibility across versions.Updated test expectations: Fixed expected output files to match actual function behavior and formatting.
Updated Makefile: Reformatted REGRESS variable for better readability.
Updated .gitignore: Added regression test output files.
Notable Implementation Details
pgos_adminrolehttps://claude.ai/code/session_01Ty3Rkif9Vfe95w8TMiKB4b