Skip to content

Reject data type names that start with a digit - #109720

Merged
alexey-milovidov merged 1 commit into
masterfrom
reject-numeric-data-type-name
Jul 8, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
reject-numeric-data-type-name

Conversation

@alexey-milovidov

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

Copy link
Copy Markdown
Member

Closes: #108372
Related: #109158

The AST fuzzer produced a column type like Nullable(multiply(Decimal(76, 12), `8`)) that triggered an Inconsistent AST formatting logical error (STID 1941-26fa) on master.

ParserDataType accepts a quoted identifier as a type name, so `8` parses into an ASTDataType named 8. The formatter prints type names unquoted (there is already a comment about this in ParserDataType), so the node becomes a bare 8, which re-parses as a numeric literal instead of a type name. This breaks the format/parse round-trip consistency check in executeQueryImpl that runs in debug/sanitizer builds.

The fix extends the parse-time guard that already rejects other non-round-trippable quoted type names (Array(`x.y`), `Null`) to also reject a name whose first character is a digit: such a name is only reachable via quoting and can never survive unquoted formatting.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=02d808ad2d907c2f4a513b19e0850a6c1c68bf29&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_debug%2C%20distributed%20plan%2C%20s3%20storage%2C%20parallel%29

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

Reject data type names that start with a digit (e.g. `8`), which could not survive AST formatting round-trip and produced an Inconsistent AST formatting logical error under the fuzzer.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

🤖 Generated with Claude Code

Version info

  • Merged into: 26.7.1.692 (included in 26.7 and later)

The AST fuzzer produced a column type like
`Nullable(multiply(Decimal(76, 12), `8`))` that triggered an
`Inconsistent AST formatting` logical error (STID 1941-26fa).

`ParserDataType` accepts a quoted identifier as a type name, so `8`
parses into an `ASTDataType` named `8`. The formatter prints type names
unquoted (see the existing comment in `ParserDataType`), so it becomes a
bare `8`, which re-parses as a numeric literal instead of a type name.
This breaks the format/parse round-trip consistency check in
`executeQueryImpl` (debug/sanitizer builds).

Extend the parse-time guard that already rejects other
non-round-trippable quoted type names (`Array(`x.y`)`, `` `Null` ``) to
also reject a name whose first character is a digit, since such a name is
only reachable via quoting and can never round-trip through unquoted
formatting.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=02d808ad2d907c2f4a513b19e0850a6c1c68bf29&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_debug%2C%20distributed%20plan%2C%20s3%20storage%2C%20parallel%29

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [14f2cf0]

Summary: ✅


AI Review

Summary

This PR fixes the fuzzer-reported AST round-trip failure for purely numeric quoted type names such as `8` by rejecting some quoted spellings earlier in ParserDataType. The current guard is broader than the formatter/parser mismatch it is trying to fix, though: it also rejects digit-leading alphanumeric names that still round-trip as a single identifier token.

Findings

⚠️ Majors

  • [src/Parsers/ParserDataType.cpp:253-255] isNumericASCII(type_name[0]) rejects every digit-leading quoted type name, but the lexer reparses alphanumeric spellings like 1abc as TokenType::BareWord, so `1abc` still round-trips cleanly through ASTDataType::formatImpl. This turns a targeted fix for pure numeric literals into a parser regression for any current or future custom type family whose unquoted name starts with a digit.
    Suggested fix: reject names whose unquoted spelling is not a single identifier token (for example by reusing isUnquotedIdentifier(type_name) together with the existing keyword block), instead of rejecting everything whose first character is numeric.
Final Verdict

Changes requested: narrow the new rejection to the non-round-trippable numeric-literal shapes rather than all digit-prefixed names.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 7, 2026
Comment thread src/Parsers/ParserDataType.cpp Resolved

@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.

LGTM

@clickhouse-gh

clickhouse-gh Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.90% 85.80% -0.10%
Functions 92.70% 92.70% +0.00%
Branches 78.00% 78.00% +0.00%

Changed lines: Changed C/C++ lines covered: 5/5 (100.00%) · Uncovered code

Full report · Diff report

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 8, 2026
@alexey-milovidov alexey-milovidov self-assigned this Jul 8, 2026
Merged via the queue into master with commit a9c6dd9 Jul 8, 2026
175 checks passed
@alexey-milovidov
alexey-milovidov deleted the reject-numeric-data-type-name branch July 8, 2026 22:36
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 8, 2026
alexey-milovidov added a commit that referenced this pull request Jul 11, 2026
Pulls in the `ParserDataType` fix from #109720, which resolves the
`AST fuzzer (amd_debug, targeted)` failure seen on this PR
(`Inconsistent AST formatting`, STID 1941-1bfa, issue #109501).

Co-Authored-By: Claude Fable 5 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…ata-type-name

Reject data type names that start with a digit
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Pulls in the `ParserDataType` fix from ClickHouse#109720, which resolves the
`AST fuzzer (amd_debug, targeted)` failure seen on this PR
(`Inconsistent AST formatting`, STID 1941-1bfa, issue ClickHouse#109501).

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci 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.

Logical error: 'Inconsistent AST formatting: the original AST: (STID: 1941-26fa)

2 participants