This is an automated email from the ASF dual-hosted git repository.

lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git


The following commit(s) were added to refs/heads/main by this push:
     new fcfef54178 fix(c/driver/postgresql): show temporary schemas in 
GetObjects (#4824)
fcfef54178 is described below

commit fcfef54178ebd3ad7d22cb6207155b60e12ea3df
Author: David Li <[email protected]>
AuthorDate: Tue Sep 29 19:33:26 2026 -0700

    fix(c/driver/postgresql): show temporary schemas in GetObjects (#4824)
    
    Depends on adbc-drivers/validation#311.
    Depends on #4823.
    
    Fixes #4821.
---
 .github/workflows/integration.yml                   |  2 +-
 c/driver/postgresql/connection.cc                   |  3 ++-
 c/driver/postgresql/validation/pyproject.toml       |  2 +-
 c/driver/postgresql/validation/tests/conftest.py    |  7 +++++++
 c/driver/postgresql/validation/tests/postgresql.py  | 15 ++++++++++++++-
 c/driver/postgresql/validation/tests/test_ingest.py | 17 ++++++++++++-----
 c/driver/postgresql/validation/uv.lock              |  4 ++--
 7 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/.github/workflows/integration.yml 
b/.github/workflows/integration.yml
index 9a3cb95187..c0e4a76ef7 100644
--- a/.github/workflows/integration.yml
+++ b/.github/workflows/integration.yml
@@ -330,7 +330,7 @@ jobs:
           - name: CockroachDB
             service: cockroachdb-test
             vendor: cockroachdb
-            uri: postgresql://root@localhost:5435/postgres?sslmode=disable
+            uri: 
postgresql://root@localhost:5435/postgres?sslmode=disable&options=-c%20experimental_enable_temp_tables%3Don
             experimental: false
           - name: CrateDB
             service: cratedb-test
diff --git a/c/driver/postgresql/connection.cc 
b/c/driver/postgresql/connection.cc
index 3a6ecd9284..d58906b1f2 100644
--- a/c/driver/postgresql/connection.cc
+++ b/c/driver/postgresql/connection.cc
@@ -73,7 +73,8 @@ static const char* kCatalogQueryAll = "SELECT datname FROM 
pg_catalog.pg_databas
 // because it will always be the currently connected database.
 static const char* kSchemaQueryAll =
     "SELECT nspname FROM pg_catalog.pg_namespace WHERE "
-    "nspname !~ '^pg_' AND nspname <> 'information_schema'";
+    "(nspname !~ '^pg_' OR oid = pg_my_temp_schema()) "
+    "AND nspname <> 'information_schema'";
 
 // Parameterized on schema_name, relkind
 // Note that when binding relkind as a string it must look like {"r", "v", ...}
diff --git a/c/driver/postgresql/validation/pyproject.toml 
b/c/driver/postgresql/validation/pyproject.toml
index 3ef01bb134..0184deafbf 100644
--- a/c/driver/postgresql/validation/pyproject.toml
+++ b/c/driver/postgresql/validation/pyproject.toml
@@ -24,4 +24,4 @@ dependencies = [
 ]
 
 [tool.uv.sources]
-adbc-drivers-validation = { git = 
"https://github.com/adbc-drivers/validation";, rev = 
"c56b861a8b154eb6be3b159778a61f529b392e2f" }
+adbc-drivers-validation = { git = 
"https://github.com/adbc-drivers/validation";, rev = 
"82bca5acbedbef21fadceb5f1022e87561e1c185" }
diff --git a/c/driver/postgresql/validation/tests/conftest.py 
b/c/driver/postgresql/validation/tests/conftest.py
index b7cc21df7b..011c91d43d 100644
--- a/c/driver/postgresql/validation/tests/conftest.py
+++ b/c/driver/postgresql/validation/tests/conftest.py
@@ -77,3 +77,10 @@ def driver_path(driver: 
adbc_drivers_validation.model.DriverQuirks) -> str:
             return str(path)
 
     return str(possible_paths[0])
+
+
[email protected](scope="session", autouse=True)
+def _setup_backend(request, conn_factory) -> None:  # noqa: F811
+    with conn_factory() as conn:  # noqa: F811
+        with conn.cursor() as cursor:
+            cursor.execute("CREATE SCHEMA IF NOT EXISTS secondary")
diff --git a/c/driver/postgresql/validation/tests/postgresql.py 
b/c/driver/postgresql/validation/tests/postgresql.py
index 306dc539e2..c87b27a1be 100644
--- a/c/driver/postgresql/validation/tests/postgresql.py
+++ b/c/driver/postgresql/validation/tests/postgresql.py
@@ -51,7 +51,7 @@ class PostgreSQLQuirks(model.DriverQuirks):
         statement_bulk_ingest=True,
         statement_bulk_ingest_catalog=False,
         statement_bulk_ingest_schema=False,
-        statement_bulk_ingest_temporary=False,
+        statement_bulk_ingest_temporary=True,
         statement_bind=True,
         statement_execute_schema=True,
         statement_get_parameter_schema=True,
@@ -60,6 +60,7 @@ class PostgreSQLQuirks(model.DriverQuirks):
         statement_rows_affected_ddl=False,
         current_catalog="postgres",
         current_schema="public",
+        secondary_schema="secondary",
         supported_xdbc_fields=["xdbc_type_name"],
     )
     setup = model.DriverSetup(
@@ -93,6 +94,18 @@ class PostgreSQLQuirks(model.DriverQuirks):
             or ("undefined_table" in error_str and table_name.lower() in 
error_str)
         )
 
+    def qualify_temp_table(
+        self, cursor: adbc_driver_manager.dbapi.Cursor, name: str
+    ) -> list[str]:
+        cursor.execute(
+            "SELECT nspname FROM pg_namespace WHERE oid = pg_my_temp_schema()"
+        )
+        row = cursor.fetchone()
+        if row is None:
+            raise RuntimeError("Could not determine temporary schema")
+        (schema,) = row
+        return [self.features.current_catalog, schema, name]
+
     def quote_one_identifier(self, identifier: str) -> str:
         """Quote an identifier using PostgreSQL's double-quote syntax."""
         identifier = identifier.replace('"', '""')
diff --git a/c/driver/postgresql/validation/tests/test_ingest.py 
b/c/driver/postgresql/validation/tests/test_ingest.py
index 9a799db41c..c07f843e93 100644
--- a/c/driver/postgresql/validation/tests/test_ingest.py
+++ b/c/driver/postgresql/validation/tests/test_ingest.py
@@ -15,14 +15,21 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from adbc_drivers_validation.tests.ingest import (
-    TestIngest,  # noqa: F401
-    generate_tests,
-)
+import adbc_drivers_validation.tests.ingest as test_ingest
+import pytest
 
 from . import postgresql
 
 
+class TestIngest(test_ingest.TestIngest):
+    def test_temporary_get_objects(self, driver, conn_factory, query) -> None:
+        if isinstance(driver, postgresql.CedarDBQuirks):
+            pytest.xfail(
+                "CedarDB does not expose temporary tables in 
pg_catalog.pg_class"
+            )
+        super().test_temporary_get_objects(driver, conn_factory, query)
+
+
 def pytest_generate_tests(metafunc) -> None:
     vendor = metafunc.config.getoption("vendor")
-    return generate_tests([postgresql.get_quirks(vendor)], metafunc)
+    return test_ingest.generate_tests([postgresql.get_quirks(vendor)], 
metafunc)
diff --git a/c/driver/postgresql/validation/uv.lock 
b/c/driver/postgresql/validation/uv.lock
index 67953761ab..7c0c35ce13 100644
--- a/c/driver/postgresql/validation/uv.lock
+++ b/c/driver/postgresql/validation/uv.lock
@@ -31,7 +31,7 @@ wheels = [
 [[package]]
 name = "adbc-drivers-validation"
 version = "0.1"
-source = { git = 
"https://github.com/adbc-drivers/validation?rev=c56b861a8b154eb6be3b159778a61f529b392e2f#c56b861a8b154eb6be3b159778a61f529b392e2f";
 }
+source = { git = 
"https://github.com/adbc-drivers/validation?rev=82bca5acbedbef21fadceb5f1022e87561e1c185#82bca5acbedbef21fadceb5f1022e87561e1c185";
 }
 dependencies = [
     { name = "adbc-driver-manager" },
     { name = "bidict" },
@@ -203,7 +203,7 @@ dependencies = [
 ]
 
 [package.metadata]
-requires-dist = [{ name = "adbc-drivers-validation", git = 
"https://github.com/adbc-drivers/validation?rev=c56b861a8b154eb6be3b159778a61f529b392e2f";
 }]
+requires-dist = [{ name = "adbc-drivers-validation", git = 
"https://github.com/adbc-drivers/validation?rev=82bca5acbedbef21fadceb5f1022e87561e1c185";
 }]
 
 [[package]]
 name = "pyarrow"

Reply via email to