Skip to content

Fix segfault in MySQLDump format on CREATE TABLE without column definitions - #126905

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
aschoube:fix-mysqldump-create-without-columns
Oct 23, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
aschoube:fix-mysqldump-create-without-columns

Conversation

@aschoube

@aschoube aschoube commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Reading a MySQL dump with the MySQLDump format crashed the server with a segmentation fault when the first CREATE TABLE had no column definitions: CREATE TABLE ... LIKE ..., or a definition list with only indexes or constraints. tryToExtractStructureFromCreateQuery dereferenced the missing column list. Now such a CREATE TABLE gives no structure, and the structure is inferred from the INSERT data, as for a CREATE TABLE that cannot be parsed.

Closes: #126832

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC)

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

Fix a segmentation fault when reading the MySQLDump format if the dump contains CREATE TABLE ... LIKE or a CREATE TABLE without column definitions. The structure is now inferred from the INSERT data.


Workflow [PR]
Sync PR [sync-upstream/pr/126905]

Version info

  • Merged into: 26.11.1.678-master (included in 26.11 and later)
  • Backported to: 26.10.2.101, 26.9.26.14, 26.8.35.10, 26.7.38.18, 26.3.61.7

…efinitions

`tryToExtractStructureFromCreateQuery` dereferenced the column list, which is missing
for `CREATE TABLE ... LIKE`, and the columns, which are missing when the definition
list has only indexes or constraints. Such a `CREATE TABLE` now gives no structure,
and the structure is inferred from the `INSERT` data.

Closes: ClickHouse#126832
@clickhouse-gh clickhouse-gh Bot added the comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). label Oct 20, 2026
@m-selmi m-selmi added the can be tested Allows running workflows for external contributors label Oct 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [56c89ae]

Summary: ✅


AI Review

Summary

The PR prevents null dereferences when MySQLDump encounters a CREATE TABLE without column definitions and preserves the first following INSERT. Reviewed head 56c89aef04c7acde025aa5425d0f3cee5a0d840b; no unresolved findings remain. The focused regression 05428_mysqldump_create_without_columns passes in Fast test. The previous row-loss finding is fixed and its thread has been resolved.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Oct 20, 2026
@clickhouse-gh clickhouse-gh Bot added the external Author is not a member of the ClickHouse organization label Oct 21, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 22, 2026
`tryToExtractStructureFromCreateQuery` reads the `CREATE TABLE` query up to and
including its `;`, but `readFirstCreateAndInsertQueries` then called `skipQuery`,
discarding the next statement. In real dumps this is the harmless
`/*!40101 SET ... */;` comment, but if an `INSERT` immediately follows the
`CREATE TABLE`, its rows were silently lost (or `EMPTY_DATA_PASSED` was thrown
if it was the only `INSERT`). This affected both the new recovery paths
(`CREATE TABLE ... LIKE`, definitions with only indexes or constraints) and
regular `CREATE TABLE` with columns.

Address review: ClickHouse#126905

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 23, 2026
Merged via the queue into ClickHouse:master with commit 8cd8fcf Oct 23, 2026
178 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 23, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 23, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 23, 2026
@nickitat nickitat linked an issue Oct 23, 2026 that may be closed by this pull request
clickhouse-gh Bot added a commit that referenced this pull request Oct 23, 2026
Backport #126905 to 26.10: Fix segfault in `MySQLDump` format on `CREATE TABLE` without column definitions
clickhouse-gh Bot added a commit that referenced this pull request Oct 23, 2026
Backport #126905 to 26.9: Fix segfault in `MySQLDump` format on `CREATE TABLE` without column definitions
clickhouse-gh Bot added a commit that referenced this pull request Oct 23, 2026
Backport #126905 to 26.8: Fix segfault in `MySQLDump` format on `CREATE TABLE` without column definitions
alexey-milovidov added a commit that referenced this pull request Oct 23, 2026
Backport #126905 to 26.3: Fix segfault in `MySQLDump` format on `CREATE TABLE` without column definitions
clickhouse-gh Bot added a commit that referenced this pull request Oct 24, 2026
Backport #126905 to 26.7: Fix segfault in `MySQLDump` format on `CREATE TABLE` without column definitions
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). external Author is not a member of the ClickHouse organization pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

5 participants