Skip to content

Conversation

@corleyma
Copy link
Contributor

@corleyma corleyma commented Jan 5, 2026

Summary

Fix the PostgreSQL driver’s GetObjects table enumeration so db_schema / db_schema_filter does not depend on search_path.

Details

The tables query used pg_catalog.pg_table_is_visible(c.oid), which is search_path-dependent and can hide tables in non-current schemas even when a schema filter is provided. Remove that predicate and rely on the explicit schema predicate.

Tests

  • pre-commit run
  • ctest -L driver-postgresql (against postgres-test from docker compose)

Closes #3854

Remove pg_table_is_visible() from the tables query so schema filtering does not depend on search_path.\n\nAdd regression coverage in the C++ PostgreSQL driver tests and Python DBAPI tests.
@corleyma corleyma requested a review from lidavidm as a code owner January 5, 2026 00:41
@github-actions github-actions bot added this to the ADBC Libraries 22 milestone Jan 5, 2026
@lidavidm
Copy link
Member

lidavidm commented Jan 5, 2026

Thanks!

@lidavidm
Copy link
Member

lidavidm commented Jan 5, 2026

It seems other tests leave behind some stuff that causes the new test to fail. Maybe it can be a little more forgiving?

>       assert len(metadata) == 1
E       AssertionError: assert 3 == 1
E        +  where 3 = len([{'catalog_name': 'postgres', 'catalog_db_schemas': [{'db_schema_name': 'dbapi_get_objects_test', 'db_schema_tables': [{'table_name': 'schema_filter_table', 'table_type': 'table', 'table_columns': None, 'table_constraints': None}]}]}, {'catalog_name': 'template1', 'catalog_db_schemas': []}, {'catalog_name': 'template0', 'catalog_db_schemas': []}])

… extra catalogs

PostgreSQL exposes template catalogs (template0/template1) so GetObjects may return multiple catalog rows even when schema/table filters are used. Update the regression test to select the current catalog entry.
@corleyma
Copy link
Contributor Author

corleyma commented Jan 5, 2026

Pushed a follow-up commit to make the Python regression test tolerant of Postgres returning multiple catalogs (e.g., template0/template1). The test now selects the current catalog entry instead of assuming a single row.

@lidavidm
Copy link
Member

lidavidm commented Jan 5, 2026

The linter made a change 😅

 diff --git a/python/adbc_driver_postgresql/tests/test_dbapi.py b/python/adbc_driver_postgresql/tests/test_dbapi.py
index aae214275..5fe72cfa3 100644
--- a/python/adbc_driver_postgresql/tests/test_dbapi.py
+++ b/python/adbc_driver_postgresql/tests/test_dbapi.py
@@ -24,6 +24,7 @@ import numpy
 import pyarrow
 import pyarrow.dataset
 import pytest
+
 from adbc_driver_postgresql import ConnectionOptions, StatementOptions, dbapi
 
 
@@ -81,7 +82,9 @@ def test_get_objects_schema_filter_outside_search_path(
     )
 
     catalog_name = postgres.adbc_current_catalog
-    catalog = next((row for row in metadata if row["catalog_name"] == catalog_name), None)
+    catalog = next(
+        (row for row in metadata if row["catalog_name"] == catalog_name), None
+    )
     assert catalog is not None
 
     schemas = catalog["catalog_db_schemas"]

@lidavidm lidavidm merged commit a88614f into apache:main Jan 6, 2026
85 checks passed
@corleyma
Copy link
Contributor Author

corleyma commented Jan 7, 2026

Re-ran the CI-style flow locally (Ubuntu container + compose postgres-test): ci/scripts/python_build.sh then PYTEST_ADDOPTS=--error-for-skips ci/scripts/python_test.sh with only BUILD_DRIVER_POSTGRESQL=1. Result: 30 passed (includes the new test_get_objects_schema_filter_outside_search_path).

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.

postgresql: GetObjects schema filter depends on search_path

2 participants