Cli identical command question

i realize i am but a mere newbie, so this is either a question or a suggestion.

when using the CLI, i noticed that if i keep doing the same command (via up arrow) over and over again such as:
SELECT * FROM cockroachIsTotallyAsesome WHERE TRUE; that command seems to be saved in the command-line-recall buffer over and over again, even though each one is identical.

is there any way to suppress this behavior of saving identical contiguous commands? linux and mariadb don’t seem to do this.

the problem of course is that there are important commands such as a CREATE TABLE that get pushed pretty far down the stack.

Sounds like a legitimate improvement we could make! Could you file an issue and mention @knz on it?


is this correct? and sorry i am not sure how to “mention” @knz.

Hi Edward!
Thank you for your suggestion, it does seem interesting indeed.
For now CockroachDB delegates history handling entirely to our dependency package readline from here:

I have filed an issue on your behalf here:
Feel free to follow-up as comments on that issue or subscribe to it to track progress.

Thank you again

thanks knz!

note that github readline has this for a description:

Readline is a pure go(golang) implementation for GNU-Readline kind library

and yet linux suppresses the duplicate commands.

is cockroach also using readline for the internal cli history buffer? from what little i saw, readline may not be what is storing the commands.

is it just a matter of finding where the commands are getting “pushed” onto a command history array? if so, i should think it’s just an extra line of code:

if ( current_command != history_commands[length_of_history_command] ) {

or maybe i have totally oversimplified this in my newbie brain.

Hi Edward.
Thanks for filing to track this.
As I explain in that issue, even our in-memory buffer is delegated to the external package.
If this is important to you, I encourage you to attempt to provide a patch to the upstream library.

thank you very much knz -

after this one gets resolved, i will ask them if we can use something like “set -o vi” and use vi to recall the cockroachdb history buffer like we can on the linux command line (well maybe that is a longshot…)