Skip to content

PostgreSQL: detect FreshRSS tables by visibility rather than owner - #9535

Merged
Alkarex merged 6 commits into
FreshRSS:edgefrom
quinnypig:fix/pgsql-installation-check
Nov 16, 2026
Merged

Alkarex merged 6 commits into
FreshRSS:edgefrom
quinnypig:fix/pgsql-installation-check

Conversation

@quinnypig

Copy link
Copy Markdown
Contributor

On PostgreSQL, the install check could report the connection as working and all six per-table checks as passing while the overall “tables” check failed.

FreshRSS_DatabaseDAOPGSQL::tablesAreCorrect() listed tables from pg_tables filtered on tableowner = <configured db user>. That assumption breaks when a connection gateway's login name differs from the PostgreSQL role, or when the application has been granted access to tables owned by another role.

The method now enumerates base and partitioned tables from pg_class that are visible in the session's active search_path, matching the DAO's unqualified queries. Views and foreign tables remain excluded. Tables outside search_path are now correctly reported as missing.

Added a PostgreSQL integration test covering tables owned by another role, a table outside search_path, and a view with the expected table name. The tests workflow provides PostgreSQL; local runs skip this test unless FRESHRSS_TEST_PGSQL_DSN is configured. All test objects are rolled back.

Validation on PHP 8.5.12 and PostgreSQL 18.6:

  • The regression test fails against the previous implementation and passes with this change.
  • composer test passes: 845 tests, 1,763 assertions, PHP/PHTML lint, PHPCS and PHPStan.
  • npm test passes: JavaScript, CSS and Markdown checks.

…e tables

For as long as the install check has existed, it asked pg_tables who owned
the tables and compared that against the database login. Nobody asked why.
The login is a gateway user, the tables belong to whatever role ran the
install, and whenever those two names diverged the check reported the schema
as missing. Visibility was the question all along.

tablesAreCorrect() now asks pg_class which ordinary and partitioned tables
are visible on the search_path. If PostgreSQL can see it, it counts. A table
parked in a schema outside the path does not hide a missing one, and a view
named like a table is not a table.

The new test builds a role, a visible schema, a hidden schema, and a view
with a suspicious name, then checks that each answer is the true one. It runs
against a real PostgreSQL 18 service in CI. Locally it skips unless
FRESHRSS_TEST_PGSQL_DSN is set.
@quinnypig
quinnypig force-pushed the fix/pgsql-installation-check branch from 7d61b9d to 070bf34 Compare November 5, 2026 22:04
@quinnypig
quinnypig marked this pull request as ready for review November 5, 2026 22:05
@Alkarex Alkarex added this to the 1.31.0 milestone Nov 5, 2026
Comment thread .github/workflows/tests.yml Fixed
quinnypig and others added 5 commits November 6, 2026 03:19
For the record: nobody announced it. The postgres:18-alpine tag sat in
tests.yml like a loaded gun pointed at every CI run, and zizmor was the
first thing to notice it had no fixed identity at all. Remember the
Denver Airport. Remember that tags are not promises.

This commit replaces the mutable tag with the exact multi-arch digest the
suite was already tested against:

  postgres:18-alpine@sha256:eaef288f54a90a909e49f0121d5d047a5e974e922699de4249625cf7cde34f36

This is not a version bump. Same image, same PostgreSQL 18, same Alpine
base. The only thing that changed is that the image can no longer be
swapped out from under us between Tuesday's green run and Thursday's
mystery failure.

Verification: all pre-commit PHP, test, JS, CSS and Markdown checks pass.
Local pedantic offline zizmor reports no findings. This resolves the
unpinned-service-image blocker on PR FreshRSS#9535.
@Alkarex

Alkarex commented Nov 14, 2026

Copy link
Copy Markdown
Member

Thanks!
I have made a few changes. Double-check welcome

@quinnypig

Copy link
Copy Markdown
Contributor Author

Looks good to me; thanks @Alkarex.

@Alkarex
Alkarex merged commit e7fe44b into FreshRSS:edge Nov 16, 2026
4 checks passed
@Alkarex

Alkarex commented Nov 16, 2026

Copy link
Copy Markdown
Member

Alkarex added a commit that referenced this pull request Nov 21, 2026
To avoid skipped tests.
Follow-up of:
* #9576
* #9535
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants