Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion c/driver/postgresql/connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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", ...}
Expand Down
2 changes: 1 addition & 1 deletion c/driver/postgresql/validation/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
7 changes: 7 additions & 0 deletions c/driver/postgresql/validation/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,10 @@ def driver_path(driver: adbc_drivers_validation.model.DriverQuirks) -> str:
return str(path)

return str(possible_paths[0])


@pytest.fixture(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")
15 changes: 14 additions & 1 deletion c/driver/postgresql/validation/tests/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -93,6 +94,18 @@ def is_table_not_found(self, table_name: str, error: Exception) -> bool:
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('"', '""')
Expand Down
17 changes: 12 additions & 5 deletions c/driver/postgresql/validation/tests/test_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions c/driver/postgresql/validation/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading