Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli/sql: properly support special COPY input mode #93057

Merged
merged 1 commit into from
Dec 6, 2022

Conversation

knz
Copy link
Contributor

@knz knz commented Dec 5, 2022

Fixes #93031.
Epic: CRDB-22182
When in COPY mode, multi-line input is disabled and the tab key inputs raw ASCII TAB characters.

This commit achieves this by redirecting the input to either the interactive editor or the bufio-based editor, depending on whether the current mode is COPY.

NB: using ctrl+c while in COPY mode will not work with this patch, but that is caused by a separate issue #93053 and the behavior will be restored when that separate issue is fixed. In the meantime the user can use \. or ctrl+d to terminate their input.

Release note: None

@knz knz requested review from otan and a team December 5, 2022 17:08
@knz knz requested a review from a team as a code owner December 5, 2022 17:08
@cockroach-teamcity
Copy link
Member

This change is Reviewable

// (outside of COPY mode) or a "copy" editor (inside COPY).
// This is because the main editor may be multi-line and
// thus inadequate for input of COPY data.
type copyEditor struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm not sure about the naming of this - it sounds like it handles copy but if i read this right it's really a mux of some sort where we redirect traffic based on the mode we're in. can we do something like editorRouter or something? file name has a similar issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went for bimodalEditor. Do you like it?

When in COPY mode, multi-line input is disabled and the tab key inputs
raw ASCII TAB characters.

This commit achieves this by redirecting the input to either the
interactive editor or the bufio-based editor, depending on whether
the current mode is COPY.

NB: using ctrl+c while in COPY mode will not work with this patch, but
that is caused by a separate issue cockroachdb#93053 and the behavior will be
restored when that separate issue is fixed. In the meantime the user
can use `\.` or ctrl+d to terminate their input.

Release note: None
@knz knz force-pushed the 20221205-sql-copy branch from a0fd120 to 3fd75b4 Compare December 6, 2022 13:09
@blathers-crl blathers-crl bot requested a review from otan December 6, 2022 13:09
@knz
Copy link
Contributor Author

knz commented Dec 6, 2022

TFYR!

bors r=otan

@craig
Copy link
Contributor

craig bot commented Dec 6, 2022

Build succeeded:

@craig craig bot merged commit 52145a4 into cockroachdb:master Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cli/sql: tab key ignored in COPY mode
3 participants