Skip to content

sql: cockroach sql ignores --user flag in --insecure mode #74704

@ZhouXing19

Description

@ZhouXing19

Describe the problem
When cockroach server is started in --insecure mode, and the user tries to enter the SQL console as a specific user in --insecure mode with --user flag, they always enter as the root user.

To reproduce
I started cockroachDB server with

./cockroach start-single-node --insecure --cache=25% --max-sql-memory=25% --store=type=mem,size=0.2 --advertise-addr=localhost --http-addr :8081 --listen-addr localhost:26257

and then I entered the SQL interface and created a user jane without password:

./cockroach sql --insecure 

root@:26257/defaultdb> CREATE USER jane;
CREATE ROLE

root@:26257/defaultdb> \du
  username | options | member_of
-----------+---------+------------
  admin    |         | {}
  jane     |         | {}
  root     |         | {admin}

Then I exited the SQL interface and tried enter the SQL interface with --user=jane, but I still entered it as the root:

./cockroach sql --insecure --user=jane

root@:26257/defaultdb> \du
  username | options | member_of
-----------+---------+------------
  admin    |         | {}
  jane     |         | {}
  root     |         | {admin}
(3 rows)

root@:26257/defaultdb> select current_user();
  current_user
----------------
  root

Environment:

  • CockroachDB version
❯ ./cockroach --version                 
cockroach version details:
Build Tag:        v22.1.0-alpha.00000000-2786-geb6685e4e0-dirty
Build Time:       
Distribution:     CCL
Platform:         darwin amd64 (x86_64-apple-darwin20.6.0)
Go Version:       go1.17.1
C Compiler:       Apple LLVM 13.0.0 (clang-1300.0.29.30)
Build Commit ID:  eb6685e4e055f18a66dc83068ca3c0483af9c14e
Build Type:       development
(use './cockroach version --build-tag' to display only the build tag)
  • Server OS: MacOS 11.6.2 (20G314)
  • Client app: cockroach sql

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions