Skip to content

The URL database engine and the s3_base setting: relative URLs and uniform scheme handling - #111512

Merged
alexey-milovidov merged 26 commits into
masterfrom
url-database-engine
Aug 2, 2026
Merged

alexey-milovidov merged 26 commits into
masterfrom
url-database-engine

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • New Feature

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Implement the remaining items of the URL unification (issue #59617). The new s3_base setting resolves relative URLs in the s3 table function and the S3 table engine (and the functions sharing their configuration: s3Cluster, gcs, oss), similarly to url_base. The new URL database engine treats table names as URLs, resolves them against an optional base URL, and dispatches by the URL scheme, so files, web and object storage are handled uniformly. It replaces Filesystem in the default (Overlay) database of clickhouse-local with a file:// base URL, so plain file names keep working, and you can also write SELECT * FROM 'https://example.com/data.csv'.

This completes #59617. Items 1 and 2 — the scheme dispatch in the url function / URL engine and the url_base setting — were implemented earlier (e.g. #106093); this PR implements the remaining items 3 and 4:

  • Item 3: the s3_base setting. When set, a URL without a scheme passed to the s3 table function (or the S3 engine, s3Cluster, gcs, oss, and named collections) is resolved against it per RFC 3986, reusing StorageURL::resolveURLBase. For the S3 table engine the resolved URL is materialized into the persisted DDL (like the URL engine does with url_base), so tables do not depend on the setting after creation; resolved URLs embedding credentials (user:pass@) are not persisted.

    SET s3_base = 's3://clickhouse-public-datasets/';
    SELECT count() FROM s3('hits_compatible/hits.csv');
  • Item 4: the URL database engine. A database that treats table names as URLs and executes them through the url table function, which dispatches by scheme (file:// -> File, s3:// -> S3, az:// -> AzureBlobStorage, hdfs:// -> HDFS, everything else -> URL). An optional engine argument gives the base URL for resolving relative table names. Reading requires the corresponding read source grant, and INSERT requires the corresponding write source grant.

    The default (Overlay) database of clickhouse-local now consists of Atomic and URL with the file:// base URL, replacing Filesystem in the chain: a plain table name resolves to file://<name> — a path relative to the current directory, read by the File engine with the same semantics as before (globs, dot segments, absolute paths, existence checks, UNKNOWN_TABLE for missing names) — while a name with a URL scheme is dispatched to the matching engine. For file://-resolved names the database checks the existence of the file before claiming the table, so CREATE TABLE is not shadowed; for remote schemes the claim is syntactic and access errors propagate from the delegate engine.

    clickhouse-local -q "SELECT * FROM 'https://example.com/data.csv'"
    clickhouse-local -q "SELECT count() FROM 's3://clickhouse-public-datasets/hits_compatible/athena_partitioned/hits_1.parquet'"
    CREATE DATABASE web ENGINE = URL('https://example.com/data/');
    SELECT * FROM web.`daily.csv`; -- reads https://example.com/data/daily.csv

    To support the file:// base, resolveURLBase gets a rule for scheme-only bases: an authority-less base resolves a path-relative reference by simple concatenation (file:// + data.csv = file://data.csv, a path relative to the user_files directory / the current directory in clickhouse-local), because strict RFC 3986 merging would produce an absolute path, making relative references useless with such a base.

Closes: #59617

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.8.1.645 (included in 26.8 and later)

alexey-milovidov and others added 2 commits July 23, 2026 02:45
…unctions

When set, a URL without a scheme passed to the `s3` table function (or the
`S3` table engine, `s3Cluster`, `gcs`, `oss`, and named collections sharing
the S3 configuration) is resolved against `s3_base` per RFC 3986, reusing
`StorageURL::resolveURLBase` - the same mechanism as the `url_base` setting.
For the `S3` table engine, the resolved URL is materialized into the
persisted DDL (like the `URL` engine does with `url_base`), so tables do not
depend on the setting after creation; resolved URLs embedding credentials
(`user:pass@`) are not persisted.

`resolveURLBase` also gets a new rule for scheme-only bases: an
authority-less base like `file://` resolves a path-relative reference by
simple concatenation (`file://` + `data.csv` = `file://data.csv`, a path
relative to the user_files directory), because strict RFC 3986 merging would
produce an absolute path, making relative references useless with such a
base. The error message for a base without a scheme now names the setting
the base came from.

This implements item 3 of #59617

Co-Authored-By: Claude Fable 5 <[email protected]>
A read-only database that treats table names as URLs and executes them
through the `url` table function, which dispatches by the URL scheme to the
matching engine (`file://` -> `File`, `s3://` -> `S3`, `az://` ->
`AzureBlobStorage`, `hdfs://` -> `HDFS`, everything else -> `URL`), so
files, web and object storage are handled uniformly. An optional engine
argument gives the base URL for resolving relative table names:

    CREATE DATABASE web ENGINE = URL('https://example.com/data/');
    SELECT * FROM web.`daily.csv`;

The default (`Overlay`) database of clickhouse-local now consists of
`Atomic` and `URL` with the `file://` base URL, replacing
`DatabaseFilesystem` in the chain: a plain table name resolves to
`file://<name>` - a path relative to the current directory, read by the
`File` engine with the same semantics as before (globs, dot segments,
absolute paths, existence checks) - while a name with a URL scheme is
dispatched to the matching engine:

    clickhouse-local -q "SELECT * FROM 'https://example.com/data.csv'"
    clickhouse-local -q "SELECT count() FROM 's3://bucket/data.parquet'"

For `file://`-resolved names the database checks the existence of the file
before claiming the table (mirroring `DatabaseFilesystem`), so unknown table
names keep failing with `UNKNOWN_TABLE` and `CREATE TABLE` is not shadowed.
For remote schemes the claim is syntactic, and access errors propagate from
the delegate engine.

This implements item 4 of #59617

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [764ed58]

Summary: ✅


AI Review

Summary

This PR finishes the remaining URL-unification work by adding s3_base, introducing the URL database engine, and switching the default clickhouse-local overlay from Filesystem to URL('file://'). The current head is close and the earlier review issues look fixed, but one access-control gap remains: EXISTS TABLE still bypasses the new read-source-grant contract for URL-database tables. The PR body is also stale after the late grant-model change.

PR Metadata
  • Changelog category: New Feature is correct for the actual change.
  • Changelog entry: required for New Feature, present, and sufficiently specific.
  • The long description is stale after 6448f21166d: Item 4 still says that INSERT requires only the corresponding write source grant, but the current code and tests require READ to resolve the table and WRITE in addition to insert. Replace that sentence with: Resolving a table requires the corresponding read source grant, and INSERT additionally requires the corresponding write source grant.
Findings
  • ⚠️ Majors
    • [src/Databases/DatabaseURL.cpp:326] DatabaseURL now treats table resolution as a read-gated operation, but EXISTS TABLE still reaches isTableExist after only SHOW TABLES and this path probes local file:// targets directly. A user without READ ON FILE can still distinguish whether db.\path.csv`exists underuser_files, which reopens a metadata oracle after 04658fixedDESCRIBE/EXPLAIN/SELECT/INSERT`.
    • Suggested fix: make the existence probe enforce the same read-source check as getTableImpl, or route EXISTS TABLE for URL-database tables through a single read-gated lookup instead of DatabaseCatalog::isTableExist.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
    1. Close the EXISTS TABLE read-grant bypass for DatabaseURL.
    2. Update the PR description sentence about INSERT grants so it matches the final behavior.

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Jul 23, 2026
@mintlify

mintlify Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
ClickHouse-docs 🟢 Ready View Preview Jul 23, 2026, 3:14 AM

…ection `S3` engine tables

When a table is created as `CREATE TABLE ... ENGINE = S3(nc)` with a relative
`url` in the named collection, the resolution against `s3_base` happened only
at runtime and the persisted DDL kept depending on the setting after
DETACH/ATTACH or a server restart. Record the resolved URL in
`StorageParsedArguments` and let `StorageObjectStorageConfiguration::initialize`
materialize it back into the engine args as a `url='...'` override, with the
same userinfo-suppression rule as the positional form.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111512&sha=latest&name_0=PR
…or `URL` database tables

Under `parallel_replicas_for_cluster_engines`, the `url` table function executed
by the `URL` database engine created `StorageURLCluster`, but a table referenced
by an identifier (`db.table`) cannot be rewritten into a `urlCluster(...)` call,
so `updateQueryToSendIfNeeded` threw the logical error "Expected SELECT query
from table function urlCluster" (and aborted the server in the coverage build).
Disable the parallel-replicas cluster auto-conversion for tables resolved
through the `URL` database.

Failure: 04627_url_database_engine in https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111512&sha=d72583d7ed1e4f291fe4c453ed6b4445139357cd&name_0=PR&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Updated the PR:

  • Merged master.
  • Addressed the AI review blocker: the s3_base-resolved URL is now materialized into the persisted DDL also for pure named-collection S3/GCS/OSS engine tables (ENGINE = S3(nc)), with a test covering DETACH/ATTACH without s3_base.
  • Fixed the Stateless tests (amd_llvm_coverage, ParallelReplicas) failure: under parallel_replicas_for_cluster_engines, reading a table of the URL database engine created StorageURLCluster, whose updateQueryToSendIfNeeded threw a logical error for a table referenced by an identifier (a db.table reference cannot be rewritten into a urlCluster(...) call). Tables resolved through the URL database now opt out of the cluster auto-conversion.

The remaining failures are unrelated:

Comment thread src/Databases/DatabaseURL.cpp Resolved
…le://` base URL

A table name like `//tmp/data.csv` in a URL database with a `file://` base
(the default database of clickhouse-local) took the scheme-relative branch of
`StorageURL::resolveURLBase` and became `file://tmp/data.csv` -- a path
relative to the user files directory -- silently reading the wrong file. A
`file://` base has no meaningful authority, so such a name is a POSIX absolute
path with redundant leading slashes: collapse them and resolve to an absolute
local path, preserving the semantics that the `Filesystem` database had for
absolute paths.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111512&sha=69b03b553d7e6539fc8a59af11aa2c6feef94f7a&name_0=PR&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.

The failure is Logical error '!part.empty()' (with "Server died") — it is unrelated to this PR: per the CI database it has occurred 148 times since 2026-06-28 across master (pull_request_number = 0) and many unrelated PRs, mostly in the amd_llvm_coverage ParallelReplicas / old-analyzer stateless jobs. I found no open issue or fix PR for it.

The other red, 02477_single_value_data_string_regression in the amd_asan_ubsan, distributed plan job, is a known flaky test (38 failures across PRs in the last 14 days), also unrelated.

Comment thread src/Databases/DatabaseURL.cpp Resolved
@groeneai

Copy link
Copy Markdown
Collaborator

The Logical error: '!part.empty()' + "Server died" here is the chronic parallel-replicas "unknown stream" abort, tracked in #110518 (STID 5217-5b3d). Not caused by this PR: the URL database engine cannot reach the parallel-replicas reading coordinator, consistent with the widespread master + unrelated-PR spread you already noted (almost all in the amd_llvm_coverage, ParallelReplicas coverage jobs).

Root cause (source-verified against the one master hit I traced, an azure amd_tsan no-ORDER-BY SELECT count()): !part.empty() is only the visible symptom. The real abort is ParallelReplicasReadingCoordinator::handleRequest() throwing Got read request from replica N for unknown stream <db>.<table> because getCoordinator(stream_id) == null. It is a registration-timing race in pure Default mode, not reading-mode divergence: a non-snapshot follower announces the bare Default stream, the coordinator drops it under snapshot-pinning (announcer is not the snapshot replica and the stream is not yet registered), the initiator sends no announcement response in Default mode, and the Default read pool issues its read request regardless. If that request beats the initiator registering the bare stream, the guard fires; stress and thread-fuzzer widen the window.

Fix status: no open fixing PR to link. The prior fix #109202 was closed WONTFIX by the coordinator owner (premise: divergent reading modes for one table should never happen, so the guard must keep throwing). That premise does not cover the Default-mode race above (there is no mode divergence there), so on 2026-07-10 I posted the falsifying master evidence plus two source-fix directions on #109202, and it is awaiting the owner's direction. I have not opened a speculative PR: I could not reproduce it locally (a single-process pseudo-cluster serializes the announce-vs-request ordering, so a real repro needs genuinely networked replicas, which only the Stress and coverage ParallelReplicas jobs provide), and the fix belongs in the coordinator once the owner confirms the direction.

alexey-milovidov and others added 3 commits July 24, 2026 06:35
…ranch cut

The Upgrade check on https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111512&sha=109acb5bbe74f3059d0e2f5f1e4048e1f935a923&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29 flagged `s3_base` as a new setting not reflected in the settings changes history: master moved to version 26.8 and the 26.7 release no longer picks up this PR, so the entry must live in the 26.8 block.

Co-Authored-By: Claude Fable 5 <[email protected]>
…` database table

A table of a `URL` database is resolved through `ITableFunction::execute` with `is_insert_query = false`, which performs only the READ source-access check, while the returned delegate storage is writable. `INSERT INTO web.`s3://...`` then checked only the INSERT privilege on the logical table name, so a user could write to an external source without the corresponding `WRITE ON S3` / `FILE` / `URL` grant.

Wrap the resolved storage in a proxy that repeats the source-access check in write mode on every write entry point (`INSERT`, async insert, a materialized view target, `TRUNCATE`). Reads are unaffected, and `INSERT INTO `file.csv`` in clickhouse-local keeps working (the default user has all grants), matching the behavior of the `Filesystem` database it replaces.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Pushed a9d76f5:

The other CI reds are unrelated to this PR:

Comment thread src/Databases/DatabaseURL.cpp Resolved
alexey-milovidov and others added 3 commits July 25, 2026 16:17
…against the base URL in shared logic

A relative name whose first path segment contains a colon (e.g. `report:2026.csv`)
parses as an absolute URI with the scheme `report` per RFC 3986, so
`StorageURL::resolveURLBase` returned it unchanged and `s3_base`/`url_base` were
silently ignored, while the `URL` database patched around it locally. Now
`resolveURLBase` treats only `scheme://` names as absolute and resolves such names
as relative references, and the local fallback in `DatabaseURL` is removed.
Also guard `TableFunctionURL::tryGetFormatFromFirstArgument` against resolved URLs
that `Poco::URI` rejects (e.g. `file://report:2026.csv`, whose authority parses as a
host with an invalid port): failing to detect the format from the file name is not
an error.

With a regression test for `url_base`, `s3_base` and the default database of
clickhouse-local, and a note in the `url_base` documentation.

Co-Authored-By: Claude Fable 5 <[email protected]>
…tables, logical storage ID for access checks

Resolving a table of a `URL` database went through `ITableFunction::execute`,
which requires the `CREATE TEMPORARY TABLE` privilege — an unrelated global grant
for a table referenced by an identifier and governed by the grants on the database
and the source access. `execute` takes a new `check_create_temporary_table`
parameter, the `URL` database passes false, and the `url` scheme-dispatch delegate
no longer repeats the check already done by the outer call.

Also give `StorageURLDatabaseTable` the logical storage ID (`db`.`name`) instead of
the nested `_table_function` one, so the SELECT privilege check in
`InterpreterSelectQuery` (the old analyzer path) matches the user's grants.
This fixes the 04642_url_database_insert_write_access failure in the old-analyzer
stateless run:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111512&sha=a9d76f50c5900c6d919a4bb2558d2fa55a1e6a11&name_0=PR&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%20old%20analyzer%2C%20s3%20storage%2C%20DBReplicated%2C%20WasmEdge%2C%20parallel%2C%203%2F3%29

The test no longer grants `CREATE TEMPORARY TABLE`.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Pushed 94b61db:

Verified locally: tests 04626, 04627, 04641, 04642 and the new 04645 pass, including the RBAC scenarios under both the old and the new analyzer.

Comment thread src/Databases/DatabaseURL.cpp Resolved
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The 04642_url_database_insert_write_access failure in Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DBReplicated, WasmEdge, parallel, 3/3) (reproducible 3/3) is fixed in c6f3c12 as well — that commit carries the test change too, which the commit message does not mention.

Root cause: the test relied on a read-only source grant (GRANT READ ON FILE, no WRITE) to prove that INSERT requires the write source access. That distinction does not survive on a server with access_control_improvements.enable_read_write_grants disabled, which is the default and what CI runs with: AccessRightsElement::makeBackwardCompatible converts READ/WRITE on a named source into the old-style whole-source grant (GRANT FILE ON *.*), which allows writing. It only showed up in the DBReplicated job because that job installs tests/config/config.d/replicated_access_storage.xml, and the replicated access storage round-trips the entity through its serialized (backward-compatible) SQL text, so the granted user really ended up with the whole FILE source. With the on-disk access storage the in-memory entity is kept as granted, so the granular READ survives and the test passed everywhere else.

The test now asserts "no source grant" vs. "the source is granted" instead, which is deterministic under both settings, and additionally covers SELECT being denied without a read source grant:

  • SELECT / INSERT / asynchronous INSERT without any source grant -> ACCESS_DENIED;
  • GRANT READ ON FILE -> SELECT works;
  • GRANT WRITE ON FILE -> INSERT works.

Verified locally on a server built from this branch: 04627_url_database_engine, 04641_url_database_double_slash_absolute_path, 04642_url_database_insert_write_access and 04647_url_database_planner_capabilities all pass. 04626/04645 need minio and were not runnable on this host.

Comment thread src/Storages/StorageURL.cpp Resolved
Comment thread src/Storages/StorageProxy.h Resolved
…; keep engine classification out of `StorageProxy`

Two findings from the AI review:

* The HTTP-index-page wildcard branch of `registerStorageURL` called
  `StorageURL::overrideURLInEngineArgs` with `skip_userinfo = false` on
  `args.engine_args`, which is a reference to the arguments of the `CREATE`
  AST. A URL resolved through `url_base` may carry `user:pass@`, so this
  persisted the credentials into the table metadata and exposed them via
  `SHOW CREATE TABLE`. The real arguments are now materialized with the same
  `skip_userinfo = true` policy as the other `url_base` paths, and the object
  storage is initialized from a scratch copy of the arguments that holds the
  fully resolved URL and never reaches the AST.

* Forwarding `isDataLake`, `isExternalDatabase`, `isObjectStorage` and
  `isMessageQueue` in `StorageProxy` would make the lazy proxies
  (`StorageTableProxy`, `StorageTableFunctionProxy`) materialize and start up
  the nested storage just to answer a classification query - e.g. the
  `disable_insertion_and_mutation` guard in `InterpreterInsertQuery` consults
  them before anything else and could then report a table-load error instead
  of `QUERY_IS_PROHIBITED`. The overrides moved to the two eager URL wrappers
  that need them, `StorageURLSchemeDispatch` and `StorageURLDatabaseTable`.

New test `04652_url_wildcard_index_pages_userinfo`: a userinfo-free `url_base`
is still materialized into the engine arguments, while a `url_base` with
credentials leaves the relative URL in the persisted DDL.
Comment thread src/Databases/DatabaseURL.cpp Resolved
alexey-milovidov and others added 2 commits July 31, 2026 00:30
…write source grant

Table resolution in DatabaseURL executed the url table function with
is_insert_query = false, so the READ source-access check ran before the
write-specific check of StorageURLDatabaseTable could: a user with INSERT on
the database plus only WRITE ON FILE / S3 / URL was denied on
INSERT INTO db.`...`, although INSERT INTO FUNCTION file(...) needs only
WRITE ON FILE.

The resolution now requires either of the READ / WRITE source grants (the
check still gates the schema inference the table function performs on the
external resource), skips the check inside ITableFunction::execute (new
check_source_access parameter), and the operation-specific entry points of
the proxy enforce the exact grant: read re-checks READ, and write /
checkInsertIsAllowed / truncate check WRITE as before. The delegate call in
TableFunctionURL::executeImpl no longer repeats the source check: the outer
function reports the delegate's engine name and access URI, so the outer
check covers exactly the delegate's source.

Adds ContextAccess::isGrantedWithFilter, the non-throwing counterpart of
checkAccessWithFilter, and ITableFunction::isSourceAccessGranted on top
of it.

New test: 04658_url_database_write_only_source_grant (WRITE ON FILE alone
allows INSERT, SELECT still requires READ ON FILE).

Co-Authored-By: Claude Fable 5 <[email protected]>
Comment thread src/Databases/DatabaseURL.cpp Resolved
Resolution of a table of a `URL` database accepted either of the READ / WRITE
source grants and left the operation-specific check to the proxy, but the
structure of such a table is inferred from the data of the source and the
catalog exposes it to the user without ever reaching
`StorageURLDatabaseTable::read` - `DESCRIBE`, `EXPLAIN` and the analyzer read
the metadata of the resolved storage. `SHOW COLUMNS` plus only
`WRITE ON FILE` / `S3` / `AZURE` was therefore enough to inspect a source the
user cannot read.

Resolution now requires the READ source grant again (fail-close: the name of
the table alone exposes the inferred structure), and the write entry points -
`write`, `truncate`, and `checkInsertIsAllowed` for the initiator side of an
asynchronous insert - additionally require WRITE, exactly as before. An
`INSERT` into a table of a `URL` database consequently needs both source
grants, while `INSERT INTO FUNCTION file(...)` keeps needing only `WRITE ON
FILE`: the table form is the one that publishes the structure.

The write paths no longer write through the storage resolved in read mode.
The backends of the `url` table function construct different clients for reads
and writes - `azureBlobStorage` creates the container only when it is not
built read-only - so `INSERT INTO db.`az://...`` lost the container-creation
behavior of the direct table function. The delegate of a write is now built
separately, in write mode, on the first write.

Reverts the now unused `ContextAccess::isGrantedWithFilter` and
`ITableFunction::isSourceAccessGranted`.

Test 04658 is repurposed accordingly: a user with `SHOW COLUMNS` and only
`WRITE ON FILE` gets `ACCESS_DENIED` on `DESCRIBE`, `EXPLAIN`, `SELECT` and
`INSERT`, and everything works after `GRANT READ ON FILE`. The full grant
matrix (no source grant / read / read + write, including the asynchronous
insert) stays in 04642.
…e requires the read source grant

The structure of a table is inferred from the data, so `INSERT` needs the read
source grant in addition to the write one.
@alexey-milovidov
alexey-milovidov requested a review from a team as a code owner August 1, 2026 01:07

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks amazing! Approved.

@alexey-milovidov alexey-milovidov self-assigned this Aug 1, 2026
Comment thread src/Databases/DatabaseURL.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.70% 78.70% +0.00%

Changed lines: Changed C/C++ lines covered: 276/313 (88.18%) · Uncovered code

Full report · Diff report

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 2, 2026
Merged via the queue into master with commit c2c9039 Aug 2, 2026
180 checks passed
@alexey-milovidov
alexey-milovidov deleted the url-database-engine branch August 2, 2026 17:04
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 2, 2026
alexey-milovidov added a commit to UberDever/ClickHouse that referenced this pull request Aug 9, 2026
…rant

`EXISTS TABLE` requires only the `SHOW TABLES` privilege, and
`InterpreterExistsQuery` answers it from `DatabaseCatalog::isTableExist`,
which for a `URL` database lands in `DatabaseURL::checkFileURLExists` and
probes the local filesystem. A user without the read source grant could
therefore tell whether a file exists under `user_files`. The same probe also
runs on the resolution path, where it reports `FILE_DOESNT_EXIST` before the
source access of the delegate is checked.

Now the probe is performed only after the read source grant is confirmed,
using the new non-throwing `ContextAccess::isGrantedWithFilter` and
`ITableFunction::isSourceAccessGranted`. Without the grant the table is
claimed to exist, exactly as it is for a remote URL (which is not probed
either) and for a path outside of `user_files`, so an attempt to resolve it
fails with the access error instead of disclosing anything.

Follows up the review of ClickHouse#111512

This branch was successfully deployed

1 active deployment
staging - docs — 764ed586 Deployed Aug 1, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature Pull request with new product feature pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extending schemas and relative URLs in the URL engine

3 participants