Skip to content

Do not append stdin to INSERT ... FROM INFILE - #126564

Merged
alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
JayPokale:local-infile-no-stdin
Oct 31, 2026
Merged

alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
JayPokale:local-infile-no-stdin

Conversation

@JayPokale

@JayPokale JayPokale commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #125137
Related: #36254

INSERT ... FROM INFILE inserted the file and then everything piped to stdin, and when stdin was a pipe that stayed open, the query waited for it to close. Both come from ClientBase::sendData: it checks isStdinNotEmptyAndValid (which blocks until data or EOF arrives) and sends stdin after the INFILE data.

As suggested in review, FROM INFILE now never reads stdin, in both clickhouse-client and clickhouse-local: the file names the data source. For an INFILE insert, stdin is not checked at all, so an open pipe cannot block it. Inserts with inline data or from stdin are unchanged. This reverts the stdin-after-INFILE part of #36254 for clickhouse-client.

  • 02270_stdin_with_query_or_infile_data checked the old client behaviour (echo "(42)" | clickhouse-client -q "INSERT ... FROM INFILE ..." inserted both rows); it now expects only the file's row.
  • 05409_local_infile_ignores_stdin covers the three forms from the issue in clickhouse-local (several queries, a single INSERT INTO FUNCTION file(...) FROM INFILE, and --queries-file) with data on stdin, and a stdin pipe that stays open for a minute under timeout 30. On the current master build the first three insert the stdin row too and the last one exits with 124.

Changelog category (leave one):

  • Backward Incompatible Change

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

INSERT ... FROM INFILE in clickhouse-client and clickhouse-local inserts only the data from the file and no longer also inserts the data piped to stdin. This also fixes the query waiting for an open stdin pipe to close.


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

Version info

  • Merged into: 26.11.1.972-master (included in 26.11 and later)

`ClientBase::sendData` appended the data piped to stdin after the `INFILE` data, and checking stdin waited for an
open pipe to close. `clickhouse-client` does this on purpose (`02270_stdin_with_query_or_infile_data`);
`clickhouse-local` now reads only the file and does not check stdin at all for such a query.

Closes: ClickHouse#125137
@clickhouse-gh clickhouse-gh Bot added the comp-local clickhouse-local / embedded modes (incl. local file processing). label Oct 18, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should never append stdin to INFILE.

@alexey-milovidov alexey-milovidov self-assigned this Oct 19, 2026
@clickhouse-gh clickhouse-gh Bot added the external Author is not a member of the ClickHouse organization label Oct 19, 2026
As suggested in review: `FROM INFILE` names the data source, so neither `clickhouse-client` nor `clickhouse-local`
reads stdin for it, and stdin is not checked at all, so an open pipe cannot block the query. Remove
`ClientBase::appendsStdinToInfileData`; `02270_stdin_with_query_or_infile_data` now expects only the file's row.
@JayPokale JayPokale changed the title clickhouse-local: insert only the file for INSERT ... FROM INFILE Do not append stdin to INSERT ... FROM INFILE Oct 20, 2026
@JayPokale

Copy link
Copy Markdown
Contributor Author

Done in 8afb409: FROM INFILE no longer reads stdin in either clickhouse-client or clickhouse-local, and stdin is not checked for such a query, so an open pipe can't block it. appendsStdinToInfileData is gone, 02270_stdin_with_query_or_infile_data now expects only the file's row, and I changed the changelog category to Backward Incompatible Change since it reverts that part of #36254.

@clickhouse-gh clickhouse-gh Bot added comp-cli clickhouse-client (interactive CLI) and client library. and removed comp-local clickhouse-local / embedded modes (incl. local file processing). labels Oct 20, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Checked 8afb409: it addresses the review (FROM INFILE never reads or checks stdin), merges cleanly with current master, builds, and 05409_local_infile_ignores_stdin passes locally. CI has not run yet: the PR workflow for this fork is waiting for maintainer approval (https://github.com/ClickHouse/ClickHouse/actions/runs/39380870264).

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Merged current master (9a348d8) into the branch; it merged without conflicts. clickhouse builds and 05409_local_infile_ignores_stdin passes locally. The review request (FROM INFILE never reads stdin) was already addressed in 8afb409. CI has still not run: the PR workflow for this fork needs maintainer approval (https://github.com/ClickHouse/ClickHouse/actions/runs/40471878917).

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 31, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1b526c1]

Summary: ✅


AI Review

Summary

INSERT ... FROM INFILE now uses only file data in clickhouse-client and clickhouse-local, avoiding unintended stdin rows and blocking on an open stdin pipe. The compatibility change matches the maintainer's explicit decision. No actionable findings; both affected regression tests passed in the PR's Fast test job.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-backward-incompatible Pull request with backwards incompatible changes label Oct 31, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 1b526c10c with master 9a348d8c2 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

41 translation units recompiled, 54 s compile time in total, 7 of them have a recent master baseline.

Job report

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 31, 2026
Merged via the queue into ClickHouse:master with commit 977ed4e Oct 31, 2026
178 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 31, 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-cli clickhouse-client (interactive CLI) and client library. external Author is not a member of the ClickHouse organization pr-backward-incompatible Pull request with backwards incompatible changes 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.

clickhouse-local: INSERT ... FROM INFILE also inserts the data from stdin

3 participants