Repository navigation
fix(clickhouse): probe views with SELECT * so a view broken by ALTER is dropped - #23
Conversation
…is dropped A plain ClickHouse view keeps the column list it was created with. When the generator creates `v<n> AS SELECT * FROM t<k>` and then drops or renames a column of `t<k>`, every read of the view that needs its columns fails with `UNKNOWN_IDENTIFIER` (ClickHouse/ClickHouse#19087: intended). The 2026-10-13 master nightly reported exactly that through `TLPWhere` on `SELECT * FROM v7, t0`. `SQLProviderAdapter.checkViewsAreValid` already runs after database generation and drops any view it cannot read, but its probe is `SELECT 1 FROM <view> LIMIT 1`. ClickHouse prunes the unused columns of the view for that query, so the probe passes and the broken view stays in the schema for every oracle. Make the probe query overridable, keeping the default for the other providers, and use `SELECT * FROM <view> LIMIT 0` for ClickHouse. It resolves every column of the view without reading data. A view that fails it is dropped through the existing logged `DROP VIEW` path, which also frees its slot under the 3-view cap and refreshes the schema. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@fm4v I found another false positive from this provider. It is separate from this PR. It came from the 2026-10-19 master nightly,
The generator ran The fix is one line: build May I send this as a separate PR? Should it change (a) |
|
@fm4v one more provider-side false positive, also separate from this PR: It has the same one-row shape as the 08-25 finding that #13 could not reproduce (and the 09-25 one). The two estimates were read on two different part layouts:
On the same master build ( The fix I would send: when May I send this as a PR, together with the |
|
One more provider-side false positive from the same 2026-10-22 nightly, also separate from this PR: The server is fine here:
Why #18 misses it: The fix I would send is one line: May I send it in the same PR as the |
|
One more provider-side false positive, also separate from this PR, from the 2026-10-28 master nightly,
The server is right. Engine parameter columns are checked against the stored columns (
The first three are not expected errors for The fix I would send: in May I add it to the same PR as the three fixes above? |
|
One more provider-side false positive, also separate from this PR:
I replayed The fix I would send (one file): add the projection as the last sort key in both negative checks ( May I send this as a separate PR? |
The 2026-10-13 master nightly (
SQLancer (arm_release), reproducer) reportedTLPWhere/Code: 47 UNKNOWN_IDENTIFIERonSELECT * FROM v7, t0. The generator createdv7 AS SELECT * FROM t1and then ranALTER TABLE t1 DROP COLUMN IF EXISTS c2. A plain view keeps the columns it was created with (ClickHouse/ClickHouse#19087), so the view can no longer be read.RENAME COLUMNbreaks it the same way.SQLProviderAdapter.checkViewsAreValidalready runs after database generation and drops views it cannot read, but it probes withSELECT 1 FROM <view> LIMIT 1. ClickHouse prunes the view's unused columns for that query, so the probe passes on the brokenSELECT *view and the view stays in the schema. This PR makes the probe query overridable (the default stays the same for the other providers) and usesSELECT * FROM <view> LIMIT 0for ClickHouse, which resolves every column without reading data. A view that fails is dropped through the existing loggedDROP VIEWpath, which also frees its slot under the 3-view cap. That is option (b) from #22 (comment).ClickHouseSchema.fromConnectiondoes not need to change.Checked:
mvn verify -DskipTests=truepasses. I ran against master 26.10 (debug build, with the.claude/clickhouse-config/overrides as in the nightly), 6 threads, 8 min per run. For the A/B runs I added a local generator bias that is not in this PR: every database gets 2-3SELECT *views and 1-3DROP/RENAME COLUMNalters. Those runs used--oracle TLPWhere --num-queries 30:TLPWhereCode 47 findingsWithout the bias, the 100 curated oracles (excluding
TextIndexDirectRead, as the nightly does) ran with this PR over 191 databases with 0 reproducers. A healthySELECT *view still passes the probe afterADD COLUMN,MODIFY COLUMN,COMMENT COLUMN,ADD INDEXandADD PROJECTIONon its table.Not changed here: in the biased runs, a mutation generated after the
ALTERcan still read the broken view during database generation, before the check runs (DELETE ... WHERE c IN (SELECT ... FROM v<n>), 2 occurrences). That shape has not appeared in CI in the last 90 days.🤖 Generated with Claude Code