Skip to content

Commit

Permalink
Merge #43851 #43903
Browse files Browse the repository at this point in the history
43851: colexec: use the same struct for buffering tuples r=yuzefovich a=yuzefovich

Previously, all buffering components (allSpooler, chunker, merge joiner,
hash table) were using custom ways to store the buffered tuples (as
a slice of coldata.Vec's with uint64 length). However, the intention is
the same, and this commit renames existing mjBufferedGroup to
bufferedBatch. The latter is now used in all buffering components.

Release note: None

43903: cli: remove the `cockroach user` sub-command r=knz a=knz

Fixes #33594.

Release note (backward-incompatible change): The `cockroach user` CLI
command has been removed. It had been deprecated in CockroachDB 19.2.
Note that a 19.2 client (supporting `cockroach user`) can still
operate user accounts in a 20.1 server.

Co-authored-by: Yahor Yuzefovich <yahor@cockroachlabs.com>
Co-authored-by: Raphael 'kena' Poss <knz@thaumogen.net>
  • Loading branch information
3 people committed Jan 13, 2020
3 parents e1f7338 + 591f5bc + 7be56b1 commit 19e35f9
Show file tree
Hide file tree
Showing 16 changed files with 181 additions and 603 deletions.
1 change: 0 additions & 1 deletion pkg/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ func init() {
quitCmd,

sqlShellCmd,
userCmd,
nodeCmd,
dumpCmd,
nodeLocalCmd,
Expand Down
169 changes: 1 addition & 168 deletions pkg/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func isSQLCommand(args []string) bool {
return false
}
switch args[0] {
case "user", "sql", "dump", "workload", "nodelocal":
case "sql", "dump", "workload", "nodelocal":
return true
case "node":
if len(args) == 0 {
Expand Down Expand Up @@ -483,8 +483,6 @@ func Example_sql() {
c.RunWithArgs([]string{`sql`, `-d`, `nonexistent`, `-e`, `create database nonexistent; create table foo(x int); select * from foo`})
// COPY should return an intelligible error message.
c.RunWithArgs([]string{`sql`, `-e`, `copy t.f from stdin`})
// --echo-sql should print out the SQL statements.
c.RunWithArgs([]string{`user`, `ls`, `--echo-sql`})
// --set changes client-side variables before executing commands.
c.RunWithArgs([]string{`sql`, `--set=errexit=0`, `-e`, `select nonexistent`, `-e`, `select 123 as "123"`})
c.RunWithArgs([]string{`sql`, `--set`, `echo=true`, `-e`, `select 123 as "123"`})
Expand Down Expand Up @@ -534,11 +532,6 @@ func Example_sql() {
// x
// sql -e copy t.f from stdin
// ERROR: woops! COPY has confused this client! Suggestion: use 'psql' for COPY
// user ls --echo-sql
// warning: This command is deprecated. Use SHOW USERS or SHOW ROLES in a SQL session.
// > SHOW USERS
// user_name
// root
// sql --set=errexit=0 -e select nonexistent -e select 123 as "123"
// ERROR: column "nonexistent" does not exist
// SQLSTATE: 42703
Expand Down Expand Up @@ -1333,165 +1326,6 @@ func Example_misc_table() {
// (6 rows)
}

func Example_user() {
c := newCLITest(cliTestParams{})
defer c.cleanup()

c.Run("user ls")
c.Run("user ls --format=table")
c.Run("user ls --format=tsv")
c.Run("user set FOO")
c.RunWithArgs([]string{"sql", "-e", "create user if not exists 'FOO'"})
c.Run("user set Foo")
c.Run("user set fOo")
c.Run("user set foO")
c.Run("user set foo")
c.Run("user set _foo")
c.Run("user set f_oo")
c.Run("user set foo_")
c.Run("user set ,foo")
c.Run("user set f,oo")
c.Run("user set foo,")
c.Run("user set 0foo")
c.Run("user set 0123")
c.Run("user set foo0")
c.Run("user set f0oo")
c.Run("user set foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoof")
c.Run("user set foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo")
c.Run("user set Ομηρος")
// Try some reserved keywords.
c.Run("user set and")
c.Run("user set table")
// Don't use get, since the output of hashedPassword is random.
// c.Run("user get foo")
c.Run("user ls --format=table")
c.Run("user rm foo")
c.Run("user ls --format=table")
c.RunWithArgs([]string{"sql", "-e", "drop database defaultdb"})
c.Run("user set foo")

// Output:
// user ls
// warning: This command is deprecated. Use SHOW USERS or SHOW ROLES in a SQL session.
// user_name
// root
// user ls --format=table
// warning: This command is deprecated. Use SHOW USERS or SHOW ROLES in a SQL session.
// user_name
// -------------
// root
// (1 row)
// user ls --format=tsv
// warning: This command is deprecated. Use SHOW USERS or SHOW ROLES in a SQL session.
// user_name
// root
// user set FOO
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// CREATE USER 1
// sql -e create user if not exists 'FOO'
// CREATE USER 0
// user set Foo
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// CREATE USER 0
// user set fOo
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// CREATE USER 0
// user set foO
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// CREATE USER 0
// user set foo
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// CREATE USER 0
// user set _foo
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// CREATE USER 1
// user set f_oo
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// CREATE USER 1
// user set foo_
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// CREATE USER 1
// user set ,foo
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// ERROR: username ",foo" invalid; usernames are case insensitive, must start with a letter, digit or underscore, may contain letters, digits, dashes, or underscores, and must not exceed 63 characters
// user set f,oo
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// ERROR: username "f,oo" invalid; usernames are case insensitive, must start with a letter, digit or underscore, may contain letters, digits, dashes, or underscores, and must not exceed 63 characters
// user set foo,
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// ERROR: username "foo," invalid; usernames are case insensitive, must start with a letter, digit or underscore, may contain letters, digits, dashes, or underscores, and must not exceed 63 characters
// user set 0foo
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// CREATE USER 1
// user set 0123
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// CREATE USER 1
// user set foo0
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// CREATE USER 1
// user set f0oo
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// CREATE USER 1
// user set foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoof
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// ERROR: username "foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoof" invalid; usernames are case insensitive, must start with a letter, digit or underscore, may contain letters, digits, dashes, or underscores, and must not exceed 63 characters
// user set foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// CREATE USER 1
// user set Ομηρος
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// CREATE USER 1
// user set and
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// CREATE USER 1
// user set table
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// CREATE USER 1
// user ls --format=table
// warning: This command is deprecated. Use SHOW USERS or SHOW ROLES in a SQL session.
// user_name
// -------------------------------------------------------------------
// 0123
// 0foo
// _foo
// and
// f0oo
// f_oo
// foo
// foo0
// foo_
// foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo
// root
// table
// ομηρος
// (13 rows)
// user rm foo
// warning: This command is deprecated. Use DROP USER or DROP ROLE in a SQL session.
// DROP USER 1
// user ls --format=table
// warning: This command is deprecated. Use SHOW USERS or SHOW ROLES in a SQL session.
// user_name
// -------------------------------------------------------------------
// 0123
// 0foo
// _foo
// and
// f0oo
// f_oo
// foo0
// foo_
// foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo
// root
// table
// ομηρος
// (12 rows)
// sql -e drop database defaultdb
// DROP DATABASE
// user set foo
// warning: This command is deprecated. Use CREATE USER or ALTER USER ... WITH PASSWORD ... in a SQL session.
// CREATE USER 1
}

func Example_cert() {
c := newCLITest(cliTestParams{})
defer c.cleanup()
Expand Down Expand Up @@ -1525,7 +1359,6 @@ Available Commands:
quit drain and shutdown node
sql open a sql shell
user get, set, list and remove users (deprecated)
node list, inspect or remove nodes
dump dump sql tables
Expand Down
5 changes: 0 additions & 5 deletions pkg/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,6 @@ func init() {
// PKCS8 key format is only available for the client cert command.
BoolFlag(createClientCertCmd.Flags(), &generatePKCS8Key, cliflags.GeneratePKCS8Key, false)

BoolFlag(setUserCmd.Flags(), &password, cliflags.Password, false)

clientCmds := []*cobra.Command{
debugGossipValuesCmd,
debugTimeSeriesDumpCmd,
Expand All @@ -457,7 +455,6 @@ func init() {
sqlShellCmd,
/* StartCmds are covered above */
}
clientCmds = append(clientCmds, userCmds...)
clientCmds = append(clientCmds, nodeCmds...)
clientCmds = append(clientCmds, systemBenchCmds...)
clientCmds = append(clientCmds, initCmd)
Expand Down Expand Up @@ -542,7 +539,6 @@ func init() {

// Commands that establish a SQL connection.
sqlCmds := []*cobra.Command{sqlShellCmd, dumpCmd, demoCmd}
sqlCmds = append(sqlCmds, userCmds...)
sqlCmds = append(sqlCmds, demoCmd.Commands()...)
sqlCmds = append(sqlCmds, nodeLocalCmds...)
for _, cmd := range sqlCmds {
Expand Down Expand Up @@ -573,7 +569,6 @@ func init() {
tableOutputCommands := append(
[]*cobra.Command{sqlShellCmd, genSettingsListCmd, demoCmd},
demoCmd.Commands()...)
tableOutputCommands = append(tableOutputCommands, userCmds...)
tableOutputCommands = append(tableOutputCommands, nodeCmds...)

// By default, these commands print their output as pretty-formatted
Expand Down
34 changes: 1 addition & 33 deletions pkg/cli/interactive_tests/test_secure.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -44,41 +44,9 @@ eexpect "1 row"
eexpect $prompt
end_test

start_test "Cannot create users with empty passwords."
send "$argv user set carl --password --certs-dir=$certs_dir\r"
eexpect "Enter password:"
send "\r"
eexpect "empty passwords are not permitted"
eexpect $prompt
end_test

start_test "Make the user without password."
send "$argv user set carl --certs-dir=$certs_dir\r"
eexpect "CREATE USER"
eexpect $prompt
end_test

start_test "Check a password can be changed."
send "$argv user set carl --password --certs-dir=$certs_dir\r"
eexpect "Enter password:"
send "woof\r"
eexpect "Confirm password:"
send "woof\r"
eexpect "ALTER USER"
eexpect $prompt
end_test

start_test "Check a password is requested by the client."
send "$argv sql --certs-dir=$certs_dir --user=carl\r"
eexpect "Enter password:"
send "woof\r"
eexpect "carl@"
send "\\q\r"
eexpect $prompt
end_test

start_test "Can create users without passwords."
send "$argv user set testuser --certs-dir=$certs_dir\r"
send "$argv sql -e 'create user testuser' --certs-dir=$certs_dir\r"
eexpect $prompt
end_test

Expand Down
3 changes: 1 addition & 2 deletions pkg/cli/interactive_tests/test_url_db_override.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ start_server $argv
# This is run as an acceptance test to ensure that the code path
# that opens the SQL connection by URL is exercised.

system "$argv sql -e 'create database test'"
system "$argv user set test"
system "$argv sql -e 'create database test; create user test'"
set certs_dir "/certs"

start_test "Check that the SSL settings come from flags is URL does not set them already."
Expand Down
Loading

0 comments on commit 19e35f9

Please sign in to comment.