cli: support multi-line copy/paste #28235
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #24965.
The introduction of support for bracketed paste (#23116 /
cedff23) has broken an invariant in
the SQL shell: that the readline function can return at most one line
of input. The shell was not organized to "peek" within that line and
detect that it needs different handling for different parts of the
pasted input, for example when pasting:
the
\set
must be executed client-side, and thevalues
server-side. This was not possible and the entire string was sent to
the server, and the server reported an error upon encountering
\set
.To address this, this patch recognizes multi-line results of
Readline() and ensures the lines are processed one by one.
Release note (bug fix):
cockroach sql
andcockroach demo
now againproperly handles copy-pasting a mixture of client-side
commands (e.g.
\set
) and SQL statements.