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: cockroach user and other SQL CLI commands erroneously requires defaultdb to exist #40967

Closed
dbpaul opened this issue Sep 22, 2019 · 2 comments · Fixed by #41121
Closed
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community

Comments

@dbpaul
Copy link

dbpaul commented Sep 22, 2019

Describe the problem
"cockroach user set ...." requires the defaultdb database, but the documentation says
"The postgres and defaultdb databases can be deleted if they are not needed."

Please describe the issue you observed, and any steps we can take to reproduce it:
cockroach sql --insecure --execute="create database mydatabase;"
cockroach init --insecure --host=127.0.0.1
cockroach sql --insecure --execute="drop database IF EXISTS defaultdb;"
cockroach sql --insecure --execute="drop database IF EXISTS postgres;"
cockroach user set username --insecure

Error: pq: database "defaultdb" does not exist
Failed running "user set"

Expected behavior
user set should not need defaultdb or the documentation should be updated that defaultdb can not be deleted for insecure(?) cluster

Additional data / screenshots
Environment:
Build Tag: v19.1.3
Build Time: 2019/07/08 18:24:39
Distribution: CCL
Platform: linux amd64 (x86_64-unknown-linux-gnu)
Go Version: go1.11.6
C Compiler: gcc 6.3.0
Build SHA-1: 1a14d34
Build Type: release

@ricardocrdb ricardocrdb added the O-community Originated from the community label Sep 24, 2019
@ricardocrdb ricardocrdb self-assigned this Sep 24, 2019
@ricardocrdb
Copy link

ricardocrdb commented Sep 24, 2019

Hey @dbpaul

I believe you just need to set another database before you are set a new user. So basically, you would run:

cockroach sql --insecure --execute="CREATE DATABASE mydatabase;"
cockroach sql --insecure --execute="DROP DATABASE IF EXISTS defaultdb;"
cockroach sql --insecure --execute="DROP DATABASE IF EXISTS postgres;"
cockroach sql  --insecure --database mydatabase
cockroach user set username --insecure

Let me know how that works out for you, or if you have any other questions.

@knz
Copy link
Contributor

knz commented Sep 26, 2019

@ricardocrdb I confirm that the steps you provided do not work. This is actually a bug in cockroach user which we must fix in 19.1/19.2.

@dbpaul note that cockroach user will be deprecated in CockroachDB 19.2 and will be removed in 20.1. Even if we fix this bug you should change your workflow to use the SQL user management statements instead.

In any case thanks for reporting this issue.

@knz knz changed the title cockroach user set requires defaultdb cli: cockroach user and other SQL CLI commands erroneously requires defaultdb to exist Sep 26, 2019
@craig craig bot closed this as completed in 1b63084 Sep 26, 2019
@knz knz added A-cli C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. labels Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants