cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.11k stars 3.81k forks source link

CLI prints out previous error message when quitting #85613

Closed smcvey closed 3 weeks ago

smcvey commented 2 years ago

Describe the problem

The SQL cli prints out the last error message when quitting the client.

root@:26257/defaultdb> CREATE DATABASE mydb_1 PRIMARY REGION "central" REGIONS "west", "east" PLACEMENT RESTRICTED;
ERROR: PLACEMENT requires that the session setting enable_multiregion_placement_policy is enabled
SQLSTATE: 0A000
HINT: to use PLACEMENT, enable the session setting with SET enable_multiregion_placement_policy = true or enable the cluster setting sql.defaults.multiregion_placement_policy.enabled
root@:26257/defaultdb> \q
ERROR: PLACEMENT requires that the session setting enable_multiregion_placement_policy is enabled
SQLSTATE: 0A000
HINT: to use PLACEMENT, enable the session setting with SET enable_multiregion_placement_policy = true or enable the cluster setting sql.defaults.multiregion_placement_policy.enabled
Failed running "sql"

Quitting the client should not repeat a previous seen error message. Running \q or exit should only display an error message if those commands specifically generated their own error message.

To Reproduce

Run the above commands on a new cluster.

Expected behavior Quitting the client should not produce a previously seen error message which could potentially be from a while ago and is also unrelated to quitting the client.

Jira issue: CRDB-18342

smcvey commented 2 years ago

Another example of this is when running cockroach sql --file <FILE>:

(error encountered after some results were delivered)
ERROR: relation "defaultdb.public.t475" already exists
SQLSTATE: 42P07
ERROR: relation "defaultdb.public.t475" already exists
SQLSTATE: 42P07
Failed running "sql"

Again the message is just printed twice.

VishalMCF commented 4 months ago

Do we have to assign it or just jump in directly? I am interested.