diff --git a/docs/generated/settings/settings-for-tenants.txt b/docs/generated/settings/settings-for-tenants.txt index c86d6bc2770a..6f551082e981 100644 --- a/docs/generated/settings/settings-for-tenants.txt +++ b/docs/generated/settings/settings-for-tenants.txt @@ -296,4 +296,4 @@ trace.jaeger.agent string the address of a Jaeger agent to receive traces using trace.opentelemetry.collector string address of an OpenTelemetry trace collector to receive traces using the otel gRPC protocol, as :. If no port is specified, 4317 will be used. trace.span_registry.enabled boolean true if set, ongoing traces can be seen at https:///#/debug/tracez trace.zipkin.collector string the address of a Zipkin instance to receive traces, as :. If no port is specified, 9411 will be used. -version version 1000022.2-44 set the active cluster version in the format '.' +version version 1000022.2-48 set the active cluster version in the format '.' diff --git a/docs/generated/settings/settings.html b/docs/generated/settings/settings.html index 00ad25da61df..e061e6b272a8 100644 --- a/docs/generated/settings/settings.html +++ b/docs/generated/settings/settings.html @@ -239,6 +239,6 @@
trace.opentelemetry.collector
stringaddress of an OpenTelemetry trace collector to receive traces using the otel gRPC protocol, as <host>:<port>. If no port is specified, 4317 will be used.
trace.span_registry.enabled
booleantrueif set, ongoing traces can be seen at https://<ui>/#/debug/tracez
trace.zipkin.collector
stringthe address of a Zipkin instance to receive traces, as <host>:<port>. If no port is specified, 9411 will be used. -
version
version1000022.2-44set the active cluster version in the format '<major>.<minor>' +
version
version1000022.2-48set the active cluster version in the format '<major>.<minor>' diff --git a/pkg/ccl/multiregionccl/regional_by_row_system_database_test.go b/pkg/ccl/multiregionccl/regional_by_row_system_database_test.go index 822a95737215..9eb628b0f068 100644 --- a/pkg/ccl/multiregionccl/regional_by_row_system_database_test.go +++ b/pkg/ccl/multiregionccl/regional_by_row_system_database_test.go @@ -57,14 +57,15 @@ UNION ALL SELECT create_statement FROM [SHOW CREATE TABLE system.namespace] "revokedAt" TIMESTAMP NULL, "lastUsedAt" TIMESTAMP NOT NULL DEFAULT now():::TIMESTAMP, "auditInfo" STRING NULL, + user_id OID NULL, crdb_region system.public.crdb_internal_region NOT VISIBLE NOT NULL DEFAULT default_to_database_primary_region(gateway_region())::system.public.crdb_internal_region, CONSTRAINT "primary" PRIMARY KEY (id ASC), INDEX "web_sessions_expiresAt_idx" ("expiresAt" ASC), INDEX "web_sessions_createdAt_idx" ("createdAt" ASC), INDEX "web_sessions_revokedAt_idx" ("revokedAt" ASC), INDEX "web_sessions_lastUsedAt_idx" ("lastUsedAt" ASC), - FAMILY "fam_0_id_hashedSecret_username_createdAt_expiresAt_revokedAt_lastUsedAt_auditInfo" (id, "hashedSecret", username, "createdAt", "expiresAt", "revokedAt", "lastUsedAt", "auditInfo"), - FAMILY fam_9_crdb_region (crdb_region) + FAMILY "fam_0_id_hashedSecret_username_createdAt_expiresAt_revokedAt_lastUsedAt_auditInfo" (id, "hashedSecret", username, "createdAt", "expiresAt", "revokedAt", "lastUsedAt", "auditInfo", user_id), + FAMILY fam_10_crdb_region (crdb_region) ) LOCALITY REGIONAL BY ROW`}, {`CREATE TABLE public.namespace ( "parentID" INT8 NOT NULL, diff --git a/pkg/cli/auth.go b/pkg/cli/auth.go index 215627afd34d..c5faebc4b00e 100644 --- a/pkg/cli/auth.go +++ b/pkg/cli/auth.go @@ -12,6 +12,7 @@ package cli import ( "context" + "database/sql/driver" "fmt" "net/http" "os" @@ -19,6 +20,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/cli/clierrorplus" "github.com/cockroachdb/cockroach/pkg/cli/clisqlclient" "github.com/cockroachdb/cockroach/pkg/cli/clisqlexec" + "github.com/cockroachdb/cockroach/pkg/clusterversion" "github.com/cockroachdb/cockroach/pkg/server" "github.com/cockroachdb/cockroach/pkg/server/serverpb" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" @@ -122,28 +124,64 @@ func createAuthSessionToken( expiration := timeutil.Now().Add(authCtx.validityPeriod) // Create the session on the server to the server. - insertSessionStmt := ` + var id int64 + err = sqlConn.ExecTxn(ctx, func(ctx context.Context, conn clisqlclient.TxBoundConn) error { + rows, err := conn.Query(ctx, fmt.Sprintf( + "SELECT crdb_internal.is_at_least_version('%s')", + clusterversion.ByKey(clusterversion.V23_1WebSessionsTableHasUserIDColumn))) + if err != nil { + return err + } + row := make([]driver.Value, 1) + if err := rows.Next(row); err != nil { + return err + } + if err := rows.Close(); err != nil { + return err + } + webSessionsHasUserIDCol, ok := row[0].(bool) + if !ok { + return errors.Newf("expected bool, got %T", row[0]) + } + insertSessionStmt := ` INSERT INTO system.web_sessions ("hashedSecret", username, "expiresAt") -VALUES($1, $2, $3) +VALUES ($1, $2, $3) RETURNING id ` - var id int64 - row, err := sqlConn.QueryRow(ctx, - insertSessionStmt, - hashedSecret, - username, - expiration, - ) + if webSessionsHasUserIDCol { + insertSessionStmt = ` +INSERT INTO system.web_sessions ("hashedSecret", username, "expiresAt", user_id) +VALUES ($1, $2, $3, (SELECT user_id FROM system.users WHERE username = $2)) +RETURNING id +` + } + rows, err = conn.Query(ctx, + insertSessionStmt, + hashedSecret, + username, + expiration, + ) + if err != nil { + return err + } + if err := rows.Next(row); err != nil { + return err + } + if err := rows.Close(); err != nil { + return err + } + if len(row) != 1 { + return errors.Newf("expected 1 column, got %d", len(row)) + } + id, ok = row[0].(int64) + if !ok { + return errors.Newf("expected integer, got %T", row[0]) + } + return nil + }) if err != nil { return -1, nil, err } - if len(row) != 1 { - return -1, nil, errors.Newf("expected 1 column, got %d", len(row)) - } - id, ok := row[0].(int64) - if !ok { - return -1, nil, errors.Newf("expected integer, got %T", row[0]) - } // Spell out the cookie. sCookie := &serverpb.SessionCookie{ID: id, Secret: secret} @@ -204,17 +242,19 @@ func runAuthList(cmd *cobra.Command, args []string) (resErr error) { } defer func() { resErr = errors.CombineErrors(resErr, sqlConn.Close()) }() - logoutQuery := clisqlclient.MakeQuery(` + // TODO(yang): Change this to read the user_id directly from the table in 23.2. + authListQuery := clisqlclient.MakeQuery(` SELECT username, + (SELECT user_id FROM system.users AS u WHERE w.username = u.username) AS "user ID", id AS "session ID", "createdAt" as "created", "expiresAt" as "expires", "revokedAt" as "revoked", "lastUsedAt" as "last used" - FROM system.web_sessions`) + FROM system.web_sessions AS w`) return sqlExecCtx.RunQueryAndFormatResults( context.Background(), - sqlConn, os.Stdout, os.Stdout, stderr, logoutQuery) + sqlConn, os.Stdout, os.Stdout, stderr, authListQuery) } var authCmds = []*cobra.Command{ diff --git a/pkg/cli/democluster/session_persistence.go b/pkg/cli/democluster/session_persistence.go index 000dc6e61396..b1d92b3e31cb 100644 --- a/pkg/cli/democluster/session_persistence.go +++ b/pkg/cli/democluster/session_persistence.go @@ -209,8 +209,8 @@ func (c *transientCluster) restoreWebSessionsInternal( } if _, err := db.ExecContext(ctx, ` -INSERT INTO system.web_sessions(id, "hashedSecret", username, "expiresAt") -VALUES ($1, $2, $3, $4)`, +INSERT INTO system.web_sessions(id, "hashedSecret", username, "expiresAt", user_id) +VALUES ($1, $2, $3, $4, (SELECT user_id FROM system.users WHERE username = $3))`, row.ID, row.HashedSecret, row.Username, diff --git a/pkg/clusterversion/cockroach_versions.go b/pkg/clusterversion/cockroach_versions.go index b37727b290da..87b9d0e5f708 100644 --- a/pkg/clusterversion/cockroach_versions.go +++ b/pkg/clusterversion/cockroach_versions.go @@ -418,6 +418,14 @@ const ( // user_id column in the system.privileges table has been backfilled. V23_1SystemPrivilegesTableUserIDColumnBackfilled + // V23_1WebSessionsTableHasUserIDColumn is the version where the + // user_id column has been added to the system.web_sessions table. + V23_1WebSessionsTableHasUserIDColumn + + // V23_1WebSessionsTableUserIDColumnBackfilled is the version where the + // user_id column in the system.web_sessions table has been backfilled. + V23_1WebSessionsTableUserIDColumnBackfilled + // ************************************************* // Step (1): Add new versions here. // Do not add new versions to a patch release. @@ -719,6 +727,14 @@ var rawVersionsSingleton = keyedVersions{ Key: V23_1SystemPrivilegesTableUserIDColumnBackfilled, Version: roachpb.Version{Major: 22, Minor: 2, Internal: 44}, }, + { + Key: V23_1WebSessionsTableHasUserIDColumn, + Version: roachpb.Version{Major: 22, Minor: 2, Internal: 46}, + }, + { + Key: V23_1WebSessionsTableUserIDColumnBackfilled, + Version: roachpb.Version{Major: 22, Minor: 2, Internal: 48}, + }, // ************************************************* // Step (2): Add new versions here. diff --git a/pkg/server/authentication.go b/pkg/server/authentication.go index 784d9d256ee8..488276e17f4a 100644 --- a/pkg/server/authentication.go +++ b/pkg/server/authentication.go @@ -23,6 +23,7 @@ import ( "time" "github.com/cockroachdb/cockroach/pkg/base" + "github.com/cockroachdb/cockroach/pkg/clusterversion" "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/security" "github.com/cockroachdb/cockroach/pkg/security/password" @@ -489,6 +490,9 @@ func CreateAuthSecret() (secret, hashedSecret []byte, err error) { func (s *authenticationServer) newAuthSession( ctx context.Context, userName username.SQLUsername, ) (int64, []byte, error) { + webSessionsTableHasUserIDCol := s.sqlServer.execCfg.Settings.Version.IsActive(ctx, + clusterversion.V23_1WebSessionsTableHasUserIDColumn) + secret, hashedSecret, err := CreateAuthSecret() if err != nil { return 0, nil, err @@ -501,6 +505,13 @@ INSERT INTO system.web_sessions ("hashedSecret", username, "expiresAt") VALUES($1, $2, $3) RETURNING id ` + if webSessionsTableHasUserIDCol { + insertSessionStmt = ` +INSERT INTO system.web_sessions ("hashedSecret", username, "expiresAt", user_id) +VALUES($1, $2, $3, (SELECT user_id FROM system.users WHERE username = $2)) +RETURNING id +` + } var id int64 row, err := s.sqlServer.internalExecutor.QueryRowEx( diff --git a/pkg/sql/catalog/bootstrap/testdata/testdata b/pkg/sql/catalog/bootstrap/testdata/testdata index b99aeb9e5949..af34878fbb03 100644 --- a/pkg/sql/catalog/bootstrap/testdata/testdata +++ b/pkg/sql/catalog/bootstrap/testdata/testdata @@ -1,4 +1,4 @@ -system hash=f651d6dd6213a41e6ba67f07eef32350c4dbcc4a5fdba69b025e3f31198a3533 +system hash=e383f08cb75d8719d4bf52d685badd8de0282857770bb8a4e6cc3e25aa8a29d3 ---- [{"key":"04646573632d696467656e","value":"01c801"} ,{"key":"8b"} @@ -14,7 +14,7 @@ system hash=f651d6dd6213a41e6ba67f07eef32350c4dbcc4a5fdba69b025e3f31198a3533 ,{"key":"8b89958a89","value":"030ad9060a0872616e67656c6f67180d200128013a00422f0a0974696d657374616d7010011a0d080510001800300050da08600020003000680070007800800100880100980100422c0a0772616e6765494410021a0c08011040180030005014600020003000680070007800800100880100980100422c0a0773746f7265494410031a0c08011040180030005014600020003000680070007800800100880100980100422e0a096576656e745479706510041a0c0807100018003000501960002000300068007000780080010088010098010042310a0c6f7468657252616e6765494410051a0c0801104018003000501460002001300068007000780080010088010098010042290a04696e666f10061a0c08071000180030005019600020013000680070007800800100880100980100423d0a08756e69717565494410071a0c08011040180030005014600020002a0e756e697175655f726f77696428293000680070007800800100880100980100480852a9010a077072696d61727910011801220974696d657374616d702208756e6971756549442a0772616e676549442a0773746f726549442a096576656e74547970652a0c6f7468657252616e676549442a04696e666f30013007400040004a10080010001a00200028003000380040005a00700270037004700570067a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e0010060026a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651802800101880103980100b201260a077072696d61727910001a0974696d657374616d701a08756e697175654944200120072800b2011e0a0d66616d5f325f72616e6765494410021a0772616e6765494420022802b2011e0a0d66616d5f335f73746f7265494410031a0773746f7265494420032803b201220a0f66616d5f345f6576656e745479706510041a096576656e745479706520042804b201280a1266616d5f355f6f7468657252616e6765494410051a0c6f7468657252616e6765494420052805b201180a0a66616d5f365f696e666f10061a04696e666f20062806b80107c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300"} ,{"key":"8b89968a89","value":"030ad1030a027569180e200128013a0042280a036b657910011a0c08071000180030005019600020003000680070007800800100880100980100422a0a0576616c756510021a0c0808100018003000501160002001300068007000780080010088010098010042310a0b6c6173745570646174656410031a0d080510001800300050da08600020003000680070007800800100880100980100480452720a077072696d6172791001180122036b65792a0576616c75652a0b6c61737455706461746564300140004a10080010001a00200028003000380040005a00700270037a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e0010060026a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651802800101880103980100b201140a077072696d61727910001a036b657920012800b2011a0a0b66616d5f325f76616c756510021a0576616c756520022802b201260a1166616d5f335f6c6173745570646174656410031a0b6c6173745570646174656420032803b80104c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300"} ,{"key":"8b89978a89","value":"030a990f0a046a6f6273180f200128013a0042370a02696410011a0c08011040180030005014600020002a0e756e697175655f726f77696428293000680070007800800100880100980100422b0a0673746174757310021a0c0807100018003000501960002000300068007000780080010088010098010042400a076372656174656410031a0d080510001800300050da08600020002a116e6f7728293a3a3a54494d455354414d503000680070007800800100880100980100422c0a077061796c6f616410041a0c08081000180030005011600020003000680070007800800100880100980100422d0a0870726f677265737310051a0c0808100018003000501160002001300068007000780080010088010098010042340a0f637265617465645f62795f7479706510061a0c0807100018003000501960002001300068007000780080010088010098010042320a0d637265617465645f62795f696410071a0c0801104018003000501460002001300068007000780080010088010098010042350a10636c61696d5f73657373696f6e5f696410081a0c0808100018003000501160002001300068007000780080010088010098010042360a11636c61696d5f696e7374616e63655f696410091a0c08011040180030005014600020013000680070007800800100880100980100422d0a086e756d5f72756e73100a1a0c08011040180030005014600020013000680070007800800100880100980100422e0a086c6173745f72756e100b1a0d080510001800300050da08600020013000680070007800800100880100980100422d0a086a6f625f74797065100c1a0c08071000180030005019600020013000680070007800800100880100980100480d52f6010a077072696d61727910011801220269642a067374617475732a07637265617465642a077061796c6f61642a0870726f67726573732a0f637265617465645f62795f747970652a0d637265617465645f62795f69642a10636c61696d5f73657373696f6e5f69642a11636c61696d5f696e7374616e63655f69642a086e756d5f72756e732a086c6173745f72756e2a086a6f625f74797065300140004a10080010001a00200028003000380040005a0070027003700470057006700770087009700a700b700c7a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e001005a7c0a176a6f62735f7374617475735f637265617465645f696478100218002206737461747573220763726561746564300230033801400040004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005aa4010a266a6f62735f637265617465645f62795f747970655f637265617465645f62795f69645f69647810031800220f637265617465645f62795f74797065220d637265617465645f62795f69642a06737461747573300630073801400040004a10080010001a00200028003000380040005a0070027a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005abc020a126a6f62735f72756e5f73746174735f696478100418002210636c61696d5f73657373696f6e5f696422067374617475732207637265617465642a086c6173745f72756e2a086e756d5f72756e732a11636c61696d5f696e7374616e63655f696430083002300338014000400040004a10080010001a00200028003000380040005a00700b700a70097a0408002000800100880100900103980100a20106080012001800a80100b20100ba01810173746174757320494e20282772756e6e696e67273a3a3a535452494e472c2027726576657274696e67273a3a3a535452494e472c202770656e64696e67273a3a3a535452494e472c202770617573652d726571756573746564273a3a3a535452494e472c202763616e63656c2d726571756573746564273a3a3a535452494e4729c00100c80100d00100e001005a6b0a116a6f62735f6a6f625f747970655f6964781005180022086a6f625f74797065300c380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e0010060066a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651802800101880103980100b2017b0a1f66616d5f305f69645f7374617475735f637265617465645f7061796c6f616410001a0269641a067374617475731a07637265617465641a077061796c6f61641a0f637265617465645f62795f747970651a0d637265617465645f62795f69641a086a6f625f74797065200120022003200420062007200c2800b2011a0a0870726f677265737310011a0870726f677265737320052805b2014c0a05636c61696d10021a10636c61696d5f73657373696f6e5f69641a11636c61696d5f696e7374616e63655f69641a086e756d5f72756e731a086c6173745f72756e20082009200a200b2800b80103c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300"} -,{"key":"8b899b8a89","value":"030a8e0b0a0c7765625f73657373696f6e731813200128013a0042370a02696410011a0c08011040180030005014600020002a0e756e697175655f726f7769642829300068007000780080010088010098010042310a0c68617368656453656372657410021a0c08081000180030005011600020003000680070007800800100880100980100422d0a08757365726e616d6510031a0c0807100018003000501960002000300068007000780080010088010098010042420a0963726561746564417410041a0d080510001800300050da08600020002a116e6f7728293a3a3a54494d455354414d503000680070007800800100880100980100422f0a0965787069726573417410051a0d080510001800300050da08600020003000680070007800800100880100980100422f0a097265766f6b6564417410061a0d080510001800300050da0860002001300068007000780080010088010098010042430a0a6c61737455736564417410071a0d080510001800300050da08600020002a116e6f7728293a3a3a54494d455354414d503000680070007800800100880100980100422e0a096175646974496e666f10081a0c08071000180030005019600020013000680070007800800100880100980100480952b7010a077072696d61727910011801220269642a0c6861736865645365637265742a08757365726e616d652a096372656174656441742a096578706972657341742a097265766f6b656441742a0a6c6173745573656441742a096175646974496e666f300140004a10080010001a00200028003000380040005a0070027003700470057006700770087a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e001005a750a1a7765625f73657373696f6e735f6578706972657341745f6964781002180022096578706972657341743005380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a750a1a7765625f73657373696f6e735f6372656174656441745f6964781003180022096372656174656441743004380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a750a1a7765625f73657373696f6e735f7265766f6b656441745f6964781004180022097265766f6b656441743006380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a770a1b7765625f73657373696f6e735f6c6173745573656441745f69647810051800220a6c6173745573656441743007380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e0010060066a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651802800101880103980100b201bb010a5166616d5f305f69645f6861736865645365637265745f757365726e616d655f6372656174656441745f6578706972657341745f7265766f6b656441745f6c6173745573656441745f6175646974496e666f10001a0269641a0c6861736865645365637265741a08757365726e616d651a096372656174656441741a096578706972657341741a097265766f6b656441741a0a6c6173745573656441741a096175646974496e666f200120022003200420052006200720082800b80101c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300"} +,{"key":"8b899b8a89","value":"030ad20b0a0c7765625f73657373696f6e731813200128013a0042370a02696410011a0c08011040180030005014600020002a0e756e697175655f726f7769642829300068007000780080010088010098010042310a0c68617368656453656372657410021a0c08081000180030005011600020003000680070007800800100880100980100422d0a08757365726e616d6510031a0c0807100018003000501960002000300068007000780080010088010098010042420a0963726561746564417410041a0d080510001800300050da08600020002a116e6f7728293a3a3a54494d455354414d503000680070007800800100880100980100422f0a0965787069726573417410051a0d080510001800300050da08600020003000680070007800800100880100980100422f0a097265766f6b6564417410061a0d080510001800300050da0860002001300068007000780080010088010098010042430a0a6c61737455736564417410071a0d080510001800300050da08600020002a116e6f7728293a3a3a54494d455354414d503000680070007800800100880100980100422e0a096175646974496e666f10081a0c08071000180030005019600020013000680070007800800100880100980100422c0a07757365725f696410091a0c080c100018003000501a600020013000680070007800800100880100980100480a52c2010a077072696d61727910011801220269642a0c6861736865645365637265742a08757365726e616d652a096372656174656441742a096578706972657341742a097265766f6b656441742a0a6c6173745573656441742a096175646974496e666f2a07757365725f6964300140004a10080010001a00200028003000380040005a00700270037004700570067007700870097a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e001005a750a1a7765625f73657373696f6e735f6578706972657341745f6964781002180022096578706972657341743005380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a750a1a7765625f73657373696f6e735f6372656174656441745f6964781003180022096372656174656441743004380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a750a1a7765625f73657373696f6e735f7265766f6b656441745f6964781004180022097265766f6b656441743006380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a770a1b7765625f73657373696f6e735f6c6173745573656441745f69647810051800220a6c6173745573656441743007380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e0010060066a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651802800101880103980100b201c6010a5166616d5f305f69645f6861736865645365637265745f757365726e616d655f6372656174656441745f6578706972657341745f7265766f6b656441745f6c6173745573656441745f6175646974496e666f10001a0269641a0c6861736865645365637265741a08757365726e616d651a096372656174656441741a096578706972657341741a097265766f6b656441741a0a6c6173745573656441741a096175646974496e666f1a07757365725f69642001200220032004200520062007200820092800b80101c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300"} ,{"key":"8b899c8a89","value":"030a960a0a107461626c655f737461746973746963731814200128013a00422c0a077461626c65494410011a0c0801104018003000501460002000300068007000780080010088010098010042400a0b737461746973746963494410021a0c08011040180030005014600020002a0e756e697175655f726f7769642829300068007000780080010088010098010042290a046e616d6510031a0c08071000180030005019600020013000680070007800800100880100980100423f0a09636f6c756d6e49447310041a1d080f104018003000380150f8075a0c08011040180030005014600060002000300068007000780080010088010098010042420a0963726561746564417410051a0d080510001800300050da08600020002a116e6f7728293a3a3a54494d455354414d503000680070007800800100880100980100422d0a08726f77436f756e7410061a0c0801104018003000501460002000300068007000780080010088010098010042320a0d64697374696e6374436f756e7410071a0c08011040180030005014600020003000680070007800800100880100980100422e0a096e756c6c436f756e7410081a0c08011040180030005014600020003000680070007800800100880100980100422e0a09686973746f6772616d10091a0c0808100018003000501160002001300068007000780080010088010098010042360a0761766753697a65100a1a0c08011040180030005014600020002a08303a3a3a494e5438300068007000780080010088010098010042350a107061727469616c507265646963617465100b1a0c0807100018003000501960002001300068007000780080010088010098010042340a0f66756c6c5374617469737469634944100c1a0c08011040180030005014600020013000680070007800800100880100980100480d52fa010a077072696d6172791001180122077461626c654944220b73746174697374696349442a046e616d652a09636f6c756d6e4944732a096372656174656441742a08726f77436f756e742a0d64697374696e6374436f756e742a096e756c6c436f756e742a09686973746f6772616d2a0761766753697a652a107061727469616c5072656469636174652a0f66756c6c537461746973746963494430013002400040004a10080010001a00200028003000380040005a007003700470057006700770087009700a700b700c7a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e0010060026a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651802800101880103980100b20188020a5d66616d5f305f7461626c6549445f73746174697374696349445f6e616d655f636f6c756d6e4944735f6372656174656441745f726f77436f756e745f64697374696e6374436f756e745f6e756c6c436f756e745f686973746f6772616d10001a077461626c6549441a0b73746174697374696349441a046e616d651a09636f6c756d6e4944731a096372656174656441741a08726f77436f756e741a0d64697374696e6374436f756e741a096e756c6c436f756e741a09686973746f6772616d1a0761766753697a651a107061727469616c5072656469636174651a0f66756c6c5374617469737469634944200120022003200420052006200720082009200a200b200c2800b80101c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300"} ,{"key":"8b899d8a89","value":"030aca040a096c6f636174696f6e731815200128013a0042300a0b6c6f63616c6974794b657910011a0c0807100018003000501960002000300068007000780080010088010098010042320a0d6c6f63616c69747956616c756510021a0c08071000180030005019600020003000680070007800800100880100980100422e0a086c6174697475646510031a0d0803100f1812300050a40d600020003000680070007800800100880100980100422f0a096c6f6e67697475646510041a0d0803100f1812300050a40d6000200030006800700078008001008801009801004805528e010a077072696d61727910011801220b6c6f63616c6974794b6579220d6c6f63616c69747956616c75652a086c617469747564652a096c6f6e67697475646530013002400040004a10080010001a00200028003000380040005a00700370047a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e0010060026a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651802800101880103980100b201710a3266616d5f305f6c6f63616c6974794b65795f6c6f63616c69747956616c75655f6c617469747564655f6c6f6e67697475646510001a0b6c6f63616c6974794b65791a0d6c6f63616c69747956616c75651a086c617469747564651a096c6f6e67697475646520012002200320042800b80101c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300"} ,{"key":"8b899f8a89","value":"030ad6090a0c726f6c655f6d656d626572731817200128013a0042290a04726f6c6510011a0c08071000180030005019600020003000680070007800800100880100980100422b0a066d656d62657210021a0c08071000180030005019600020003000680070007800800100880100980100422c0a07697341646d696e10031a0c08001000180030005010600020003000680070007800800100880100980100422c0a07726f6c655f696410041a0c080c100018003000501a600020003000680070007800800100880100980100422e0a096d656d6265725f696410051a0c080c100018003000501a6000200030006800700078008001008801009801004806528a010a077072696d617279100118012204726f6c6522066d656d6265722a07697341646d696e2a07726f6c655f69642a096d656d6265725f696430013002400040004a10080010001a00200028003000380040005a007003700470057a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00102e001005a6b0a15726f6c655f6d656d626572735f726f6c655f696478100218002204726f6c653001380240004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a6f0a17726f6c655f6d656d626572735f6d656d6265725f6964781003180022066d656d6265723002380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a730a18726f6c655f6d656d626572735f726f6c655f69645f696478100418002207726f6c655f696430043801380240004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a770a1a726f6c655f6d656d626572735f6d656d6265725f69645f6964781005180022096d656d6265725f696430053801380240004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a8c010a22726f6c655f6d656d626572735f726f6c655f69645f6d656d6265725f69645f6b6579100618012207726f6c655f696422096d656d6265725f69643004300538013802400040004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00101e0010060076a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651802800101880103980100b2011f0a077072696d61727910001a04726f6c651a066d656d626572200120022800b2011e0a0d66616d5f335f697341646d696e10031a07697341646d696e20032803b2011e0a0d66616d5f345f726f6c655f696410041a07726f6c655f696420042804b201220a0f66616d5f355f6d656d6265725f696410051a096d656d6265725f696420052805b80106c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880303a80300b00300"} @@ -163,7 +163,7 @@ system hash=f651d6dd6213a41e6ba67f07eef32350c4dbcc4a5fdba69b025e3f31198a3533 ,{"key":"c1"} ] -tenant hash=e72b08635e4484cbcb48fc6281e5ad27c568f6b70c3d871529aea0c3ead6e8f0 +tenant hash=3315db13938e5b046466ae3cd8167ab9a9241301743e1637f948716d43fa03dc ---- [{"key":""} ,{"key":"8b89898a89","value":"0312390a0673797374656d10011a250a0d0a0561646d696e1080101880100a0c0a04726f6f7410801018801012046e6f646518022200280140004a00"} @@ -177,7 +177,7 @@ tenant hash=e72b08635e4484cbcb48fc6281e5ad27c568f6b70c3d871529aea0c3ead6e8f0 ,{"key":"8b89958a89","value":"030ad9060a0872616e67656c6f67180d200128013a00422f0a0974696d657374616d7010011a0d080510001800300050da08600020003000680070007800800100880100980100422c0a0772616e6765494410021a0c08011040180030005014600020003000680070007800800100880100980100422c0a0773746f7265494410031a0c08011040180030005014600020003000680070007800800100880100980100422e0a096576656e745479706510041a0c0807100018003000501960002000300068007000780080010088010098010042310a0c6f7468657252616e6765494410051a0c0801104018003000501460002001300068007000780080010088010098010042290a04696e666f10061a0c08071000180030005019600020013000680070007800800100880100980100423d0a08756e69717565494410071a0c08011040180030005014600020002a0e756e697175655f726f77696428293000680070007800800100880100980100480852a9010a077072696d61727910011801220974696d657374616d702208756e6971756549442a0772616e676549442a0773746f726549442a096576656e74547970652a0c6f7468657252616e676549442a04696e666f30013007400040004a10080010001a00200028003000380040005a00700270037004700570067a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e0010060026a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651802800101880103980100b201260a077072696d61727910001a0974696d657374616d701a08756e697175654944200120072800b2011e0a0d66616d5f325f72616e6765494410021a0772616e6765494420022802b2011e0a0d66616d5f335f73746f7265494410031a0773746f7265494420032803b201220a0f66616d5f345f6576656e745479706510041a096576656e745479706520042804b201280a1266616d5f355f6f7468657252616e6765494410051a0c6f7468657252616e6765494420052805b201180a0a66616d5f365f696e666f10061a04696e666f20062806b80107c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300"} ,{"key":"8b89968a89","value":"030ad1030a027569180e200128013a0042280a036b657910011a0c08071000180030005019600020003000680070007800800100880100980100422a0a0576616c756510021a0c0808100018003000501160002001300068007000780080010088010098010042310a0b6c6173745570646174656410031a0d080510001800300050da08600020003000680070007800800100880100980100480452720a077072696d6172791001180122036b65792a0576616c75652a0b6c61737455706461746564300140004a10080010001a00200028003000380040005a00700270037a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e0010060026a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651802800101880103980100b201140a077072696d61727910001a036b657920012800b2011a0a0b66616d5f325f76616c756510021a0576616c756520022802b201260a1166616d5f335f6c6173745570646174656410031a0b6c6173745570646174656420032803b80104c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300"} ,{"key":"8b89978a89","value":"030a990f0a046a6f6273180f200128013a0042370a02696410011a0c08011040180030005014600020002a0e756e697175655f726f77696428293000680070007800800100880100980100422b0a0673746174757310021a0c0807100018003000501960002000300068007000780080010088010098010042400a076372656174656410031a0d080510001800300050da08600020002a116e6f7728293a3a3a54494d455354414d503000680070007800800100880100980100422c0a077061796c6f616410041a0c08081000180030005011600020003000680070007800800100880100980100422d0a0870726f677265737310051a0c0808100018003000501160002001300068007000780080010088010098010042340a0f637265617465645f62795f7479706510061a0c0807100018003000501960002001300068007000780080010088010098010042320a0d637265617465645f62795f696410071a0c0801104018003000501460002001300068007000780080010088010098010042350a10636c61696d5f73657373696f6e5f696410081a0c0808100018003000501160002001300068007000780080010088010098010042360a11636c61696d5f696e7374616e63655f696410091a0c08011040180030005014600020013000680070007800800100880100980100422d0a086e756d5f72756e73100a1a0c08011040180030005014600020013000680070007800800100880100980100422e0a086c6173745f72756e100b1a0d080510001800300050da08600020013000680070007800800100880100980100422d0a086a6f625f74797065100c1a0c08071000180030005019600020013000680070007800800100880100980100480d52f6010a077072696d61727910011801220269642a067374617475732a07637265617465642a077061796c6f61642a0870726f67726573732a0f637265617465645f62795f747970652a0d637265617465645f62795f69642a10636c61696d5f73657373696f6e5f69642a11636c61696d5f696e7374616e63655f69642a086e756d5f72756e732a086c6173745f72756e2a086a6f625f74797065300140004a10080010001a00200028003000380040005a0070027003700470057006700770087009700a700b700c7a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e001005a7c0a176a6f62735f7374617475735f637265617465645f696478100218002206737461747573220763726561746564300230033801400040004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005aa4010a266a6f62735f637265617465645f62795f747970655f637265617465645f62795f69645f69647810031800220f637265617465645f62795f74797065220d637265617465645f62795f69642a06737461747573300630073801400040004a10080010001a00200028003000380040005a0070027a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005abc020a126a6f62735f72756e5f73746174735f696478100418002210636c61696d5f73657373696f6e5f696422067374617475732207637265617465642a086c6173745f72756e2a086e756d5f72756e732a11636c61696d5f696e7374616e63655f696430083002300338014000400040004a10080010001a00200028003000380040005a00700b700a70097a0408002000800100880100900103980100a20106080012001800a80100b20100ba01810173746174757320494e20282772756e6e696e67273a3a3a535452494e472c2027726576657274696e67273a3a3a535452494e472c202770656e64696e67273a3a3a535452494e472c202770617573652d726571756573746564273a3a3a535452494e472c202763616e63656c2d726571756573746564273a3a3a535452494e4729c00100c80100d00100e001005a6b0a116a6f62735f6a6f625f747970655f6964781005180022086a6f625f74797065300c380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e0010060066a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651802800101880103980100b2017b0a1f66616d5f305f69645f7374617475735f637265617465645f7061796c6f616410001a0269641a067374617475731a07637265617465641a077061796c6f61641a0f637265617465645f62795f747970651a0d637265617465645f62795f69641a086a6f625f74797065200120022003200420062007200c2800b2011a0a0870726f677265737310011a0870726f677265737320052805b2014c0a05636c61696d10021a10636c61696d5f73657373696f6e5f69641a11636c61696d5f696e7374616e63655f69641a086e756d5f72756e731a086c6173745f72756e20082009200a200b2800b80103c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300"} -,{"key":"8b899b8a89","value":"030a8e0b0a0c7765625f73657373696f6e731813200128013a0042370a02696410011a0c08011040180030005014600020002a0e756e697175655f726f7769642829300068007000780080010088010098010042310a0c68617368656453656372657410021a0c08081000180030005011600020003000680070007800800100880100980100422d0a08757365726e616d6510031a0c0807100018003000501960002000300068007000780080010088010098010042420a0963726561746564417410041a0d080510001800300050da08600020002a116e6f7728293a3a3a54494d455354414d503000680070007800800100880100980100422f0a0965787069726573417410051a0d080510001800300050da08600020003000680070007800800100880100980100422f0a097265766f6b6564417410061a0d080510001800300050da0860002001300068007000780080010088010098010042430a0a6c61737455736564417410071a0d080510001800300050da08600020002a116e6f7728293a3a3a54494d455354414d503000680070007800800100880100980100422e0a096175646974496e666f10081a0c08071000180030005019600020013000680070007800800100880100980100480952b7010a077072696d61727910011801220269642a0c6861736865645365637265742a08757365726e616d652a096372656174656441742a096578706972657341742a097265766f6b656441742a0a6c6173745573656441742a096175646974496e666f300140004a10080010001a00200028003000380040005a0070027003700470057006700770087a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e001005a750a1a7765625f73657373696f6e735f6578706972657341745f6964781002180022096578706972657341743005380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a750a1a7765625f73657373696f6e735f6372656174656441745f6964781003180022096372656174656441743004380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a750a1a7765625f73657373696f6e735f7265766f6b656441745f6964781004180022097265766f6b656441743006380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a770a1b7765625f73657373696f6e735f6c6173745573656441745f69647810051800220a6c6173745573656441743007380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e0010060066a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651802800101880103980100b201bb010a5166616d5f305f69645f6861736865645365637265745f757365726e616d655f6372656174656441745f6578706972657341745f7265766f6b656441745f6c6173745573656441745f6175646974496e666f10001a0269641a0c6861736865645365637265741a08757365726e616d651a096372656174656441741a096578706972657341741a097265766f6b656441741a0a6c6173745573656441741a096175646974496e666f200120022003200420052006200720082800b80101c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300"} +,{"key":"8b899b8a89","value":"030ad20b0a0c7765625f73657373696f6e731813200128013a0042370a02696410011a0c08011040180030005014600020002a0e756e697175655f726f7769642829300068007000780080010088010098010042310a0c68617368656453656372657410021a0c08081000180030005011600020003000680070007800800100880100980100422d0a08757365726e616d6510031a0c0807100018003000501960002000300068007000780080010088010098010042420a0963726561746564417410041a0d080510001800300050da08600020002a116e6f7728293a3a3a54494d455354414d503000680070007800800100880100980100422f0a0965787069726573417410051a0d080510001800300050da08600020003000680070007800800100880100980100422f0a097265766f6b6564417410061a0d080510001800300050da0860002001300068007000780080010088010098010042430a0a6c61737455736564417410071a0d080510001800300050da08600020002a116e6f7728293a3a3a54494d455354414d503000680070007800800100880100980100422e0a096175646974496e666f10081a0c08071000180030005019600020013000680070007800800100880100980100422c0a07757365725f696410091a0c080c100018003000501a600020013000680070007800800100880100980100480a52c2010a077072696d61727910011801220269642a0c6861736865645365637265742a08757365726e616d652a096372656174656441742a096578706972657341742a097265766f6b656441742a0a6c6173745573656441742a096175646974496e666f2a07757365725f6964300140004a10080010001a00200028003000380040005a00700270037004700570067007700870097a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e001005a750a1a7765625f73657373696f6e735f6578706972657341745f6964781002180022096578706972657341743005380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a750a1a7765625f73657373696f6e735f6372656174656441745f6964781003180022096372656174656441743004380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a750a1a7765625f73657373696f6e735f7265766f6b656441745f6964781004180022097265766f6b656441743006380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a770a1b7765625f73657373696f6e735f6c6173745573656441745f69647810051800220a6c6173745573656441743007380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e0010060066a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651802800101880103980100b201c6010a5166616d5f305f69645f6861736865645365637265745f757365726e616d655f6372656174656441745f6578706972657341745f7265766f6b656441745f6c6173745573656441745f6175646974496e666f10001a0269641a0c6861736865645365637265741a08757365726e616d651a096372656174656441741a096578706972657341741a097265766f6b656441741a0a6c6173745573656441741a096175646974496e666f1a07757365725f69642001200220032004200520062007200820092800b80101c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300"} ,{"key":"8b899c8a89","value":"030a960a0a107461626c655f737461746973746963731814200128013a00422c0a077461626c65494410011a0c0801104018003000501460002000300068007000780080010088010098010042400a0b737461746973746963494410021a0c08011040180030005014600020002a0e756e697175655f726f7769642829300068007000780080010088010098010042290a046e616d6510031a0c08071000180030005019600020013000680070007800800100880100980100423f0a09636f6c756d6e49447310041a1d080f104018003000380150f8075a0c08011040180030005014600060002000300068007000780080010088010098010042420a0963726561746564417410051a0d080510001800300050da08600020002a116e6f7728293a3a3a54494d455354414d503000680070007800800100880100980100422d0a08726f77436f756e7410061a0c0801104018003000501460002000300068007000780080010088010098010042320a0d64697374696e6374436f756e7410071a0c08011040180030005014600020003000680070007800800100880100980100422e0a096e756c6c436f756e7410081a0c08011040180030005014600020003000680070007800800100880100980100422e0a09686973746f6772616d10091a0c0808100018003000501160002001300068007000780080010088010098010042360a0761766753697a65100a1a0c08011040180030005014600020002a08303a3a3a494e5438300068007000780080010088010098010042350a107061727469616c507265646963617465100b1a0c0807100018003000501960002001300068007000780080010088010098010042340a0f66756c6c5374617469737469634944100c1a0c08011040180030005014600020013000680070007800800100880100980100480d52fa010a077072696d6172791001180122077461626c654944220b73746174697374696349442a046e616d652a09636f6c756d6e4944732a096372656174656441742a08726f77436f756e742a0d64697374696e6374436f756e742a096e756c6c436f756e742a09686973746f6772616d2a0761766753697a652a107061727469616c5072656469636174652a0f66756c6c537461746973746963494430013002400040004a10080010001a00200028003000380040005a007003700470057006700770087009700a700b700c7a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e0010060026a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651802800101880103980100b20188020a5d66616d5f305f7461626c6549445f73746174697374696349445f6e616d655f636f6c756d6e4944735f6372656174656441745f726f77436f756e745f64697374696e6374436f756e745f6e756c6c436f756e745f686973746f6772616d10001a077461626c6549441a0b73746174697374696349441a046e616d651a09636f6c756d6e4944731a096372656174656441741a08726f77436f756e741a0d64697374696e6374436f756e741a096e756c6c436f756e741a09686973746f6772616d1a0761766753697a651a107061727469616c5072656469636174651a0f66756c6c5374617469737469634944200120022003200420052006200720082009200a200b200c2800b80101c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300"} ,{"key":"8b899d8a89","value":"030aca040a096c6f636174696f6e731815200128013a0042300a0b6c6f63616c6974794b657910011a0c0807100018003000501960002000300068007000780080010088010098010042320a0d6c6f63616c69747956616c756510021a0c08071000180030005019600020003000680070007800800100880100980100422e0a086c6174697475646510031a0d0803100f1812300050a40d600020003000680070007800800100880100980100422f0a096c6f6e67697475646510041a0d0803100f1812300050a40d6000200030006800700078008001008801009801004805528e010a077072696d61727910011801220b6c6f63616c6974794b6579220d6c6f63616c69747956616c75652a086c617469747564652a096c6f6e67697475646530013002400040004a10080010001a00200028003000380040005a00700370047a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e0010060026a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651802800101880103980100b201710a3266616d5f305f6c6f63616c6974794b65795f6c6f63616c69747956616c75655f6c617469747564655f6c6f6e67697475646510001a0b6c6f63616c6974794b65791a0d6c6f63616c69747956616c75651a086c617469747564651a096c6f6e67697475646520012002200320042800b80101c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300"} ,{"key":"8b899f8a89","value":"030ad6090a0c726f6c655f6d656d626572731817200128013a0042290a04726f6c6510011a0c08071000180030005019600020003000680070007800800100880100980100422b0a066d656d62657210021a0c08071000180030005019600020003000680070007800800100880100980100422c0a07697341646d696e10031a0c08001000180030005010600020003000680070007800800100880100980100422c0a07726f6c655f696410041a0c080c100018003000501a600020003000680070007800800100880100980100422e0a096d656d6265725f696410051a0c080c100018003000501a6000200030006800700078008001008801009801004806528a010a077072696d617279100118012204726f6c6522066d656d6265722a07697341646d696e2a07726f6c655f69642a096d656d6265725f696430013002400040004a10080010001a00200028003000380040005a007003700470057a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00102e001005a6b0a15726f6c655f6d656d626572735f726f6c655f696478100218002204726f6c653001380240004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a6f0a17726f6c655f6d656d626572735f6d656d6265725f6964781003180022066d656d6265723002380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a730a18726f6c655f6d656d626572735f726f6c655f69645f696478100418002207726f6c655f696430043801380240004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a770a1a726f6c655f6d656d626572735f6d656d6265725f69645f6964781005180022096d656d6265725f696430053801380240004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00100e001005a8c010a22726f6c655f6d656d626572735f726f6c655f69645f6d656d6265725f69645f6b6579100618012207726f6c655f696422096d656d6265725f69643004300538013802400040004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00101e0010060076a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651802800101880103980100b2011f0a077072696d61727910001a04726f6c651a066d656d626572200120022800b2011e0a0d66616d5f335f697341646d696e10031a07697341646d696e20032803b2011e0a0d66616d5f345f726f6c655f696410041a07726f6c655f696420042804b201220a0f66616d5f355f6d656d6265725f696410051a096d656d6265725f696420052805b80106c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880303a80300b00300"} diff --git a/pkg/sql/catalog/systemschema/system.go b/pkg/sql/catalog/systemschema/system.go index 654fd5f3bc46..9175de2d2c19 100644 --- a/pkg/sql/catalog/systemschema/system.go +++ b/pkg/sql/catalog/systemschema/system.go @@ -243,12 +243,13 @@ CREATE TABLE system.web_sessions ( "revokedAt" TIMESTAMP, "lastUsedAt" TIMESTAMP NOT NULL DEFAULT now(), "auditInfo" STRING, + user_id OID, CONSTRAINT "primary" PRIMARY KEY (id), INDEX ("expiresAt"), INDEX ("createdAt"), INDEX ("revokedAt"), INDEX ("lastUsedAt"), - FAMILY (id, "hashedSecret", username, "createdAt", "expiresAt", "revokedAt", "lastUsedAt", "auditInfo") + FAMILY "fam_0_id_hashedSecret_username_createdAt_expiresAt_revokedAt_lastUsedAt_auditInfo" (id, "hashedSecret", username, "createdAt", "expiresAt", "revokedAt", "lastUsedAt", "auditInfo", user_id) );` // table_statistics is used to track statistics collected about individual @@ -1583,6 +1584,7 @@ var ( {Name: "revokedAt", ID: 6, Type: types.Timestamp, Nullable: true}, {Name: "lastUsedAt", ID: 7, Type: types.Timestamp, DefaultExpr: &nowString}, {Name: "auditInfo", ID: 8, Type: types.String, Nullable: true}, + {Name: "user_id", ID: 9, Type: types.Oid, Nullable: true}, }, []descpb.ColumnFamilyDescriptor{ { @@ -1597,8 +1599,9 @@ var ( "revokedAt", "lastUsedAt", "auditInfo", + "user_id", }, - ColumnIDs: []descpb.ColumnID{1, 2, 3, 4, 5, 6, 7, 8}, + ColumnIDs: []descpb.ColumnID{1, 2, 3, 4, 5, 6, 7, 8, 9}, }, }, pk("id"), diff --git a/pkg/sql/catalog/systemschema_test/testdata/bootstrap b/pkg/sql/catalog/systemschema_test/testdata/bootstrap index 85b774433225..f656122a85b8 100644 --- a/pkg/sql/catalog/systemschema_test/testdata/bootstrap +++ b/pkg/sql/catalog/systemschema_test/testdata/bootstrap @@ -123,12 +123,13 @@ CREATE TABLE public.web_sessions ( "revokedAt" TIMESTAMP NULL, "lastUsedAt" TIMESTAMP NOT NULL DEFAULT now():::TIMESTAMP, "auditInfo" STRING NULL, + user_id OID NULL, CONSTRAINT "primary" PRIMARY KEY (id ASC), INDEX "web_sessions_expiresAt_idx" ("expiresAt" ASC), INDEX "web_sessions_createdAt_idx" ("createdAt" ASC), INDEX "web_sessions_revokedAt_idx" ("revokedAt" ASC), INDEX "web_sessions_lastUsedAt_idx" ("lastUsedAt" ASC), - FAMILY "fam_0_id_hashedSecret_username_createdAt_expiresAt_revokedAt_lastUsedAt_auditInfo" (id, "hashedSecret", username, "createdAt", "expiresAt", "revokedAt", "lastUsedAt", "auditInfo") + FAMILY "fam_0_id_hashedSecret_username_createdAt_expiresAt_revokedAt_lastUsedAt_auditInfo" (id, "hashedSecret", username, "createdAt", "expiresAt", "revokedAt", "lastUsedAt", "auditInfo", user_id) ); CREATE TABLE public.table_statistics ( "tableID" INT8 NOT NULL, @@ -490,7 +491,7 @@ schema_telemetry {"table":{"name":"transaction_statistics","id":43,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"aggregated_ts","id":1,"type":{"family":"TimestampTZFamily","oid":1184}},{"name":"fingerprint_id","id":2,"type":{"family":"BytesFamily","oid":17}},{"name":"app_name","id":3,"type":{"family":"StringFamily","oid":25}},{"name":"node_id","id":4,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"agg_interval","id":5,"type":{"family":"IntervalFamily","oid":1186,"intervalDurationField":{}}},{"name":"metadata","id":6,"type":{"family":"JsonFamily","oid":3802}},{"name":"statistics","id":7,"type":{"family":"JsonFamily","oid":3802}},{"name":"crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8","id":8,"type":{"family":"IntFamily","width":32,"oid":23},"hidden":true,"computeExpr":"mod(fnv32(crdb_internal.datums_to_bytes(aggregated_ts, app_name, fingerprint_id, node_id)), _:::INT8)"}],"nextColumnId":9,"families":[{"name":"primary","columnNames":["crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8","aggregated_ts","fingerprint_id","app_name","node_id","agg_interval","metadata","statistics"],"columnIds":[8,1,2,3,4,5,6,7]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8","aggregated_ts","fingerprint_id","app_name","node_id"],"keyColumnDirections":["ASC","ASC","ASC","ASC","ASC"],"storeColumnNames":["agg_interval","metadata","statistics"],"keyColumnIds":[8,1,2,3,4],"storeColumnIds":[5,6,7],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{"isSharded":true,"name":"crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8","shardBuckets":8,"columnNames":["aggregated_ts","app_name","fingerprint_id","node_id"]},"geoConfig":{},"constraintId":1},"indexes":[{"name":"fingerprint_stats_idx","id":2,"version":3,"keyColumnNames":["fingerprint_id"],"keyColumnDirections":["ASC"],"keyColumnIds":[2],"keySuffixColumnIds":[8,1,3,4],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"32","withGrantOption":"32"},{"userProto":"root","privileges":"32","withGrantOption":"32"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"checks":[{"expr":"crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8 IN (_:::INT8, _:::INT8, _:::INT8, _:::INT8, _:::INT8, _:::INT8, _:::INT8, _:::INT8)","name":"check_crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8","columnIds":[8],"fromHashShardedColumn":true,"constraintId":2}],"replacementOf":{"time":{}},"createAsOfTime":{"wallTime":"0"},"nextConstraintId":3}} {"table":{"name":"ui","id":14,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"key","id":1,"type":{"family":"StringFamily","oid":25}},{"name":"value","id":2,"type":{"family":"BytesFamily","oid":17},"nullable":true},{"name":"lastUpdated","id":3,"type":{"family":"TimestampFamily","oid":1114}}],"nextColumnId":4,"families":[{"name":"primary","columnNames":["key"],"columnIds":[1]},{"name":"fam_2_value","id":2,"columnNames":["value"],"columnIds":[2],"defaultColumnId":2},{"name":"fam_3_lastUpdated","id":3,"columnNames":["lastUpdated"],"columnIds":[3],"defaultColumnId":3}],"nextFamilyId":4,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["key"],"keyColumnDirections":["ASC"],"storeColumnNames":["value","lastUpdated"],"keyColumnIds":[1],"storeColumnIds":[2,3],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{"wallTime":"0"},"nextConstraintId":2}} {"table":{"name":"users","id":4,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"username","id":1,"type":{"family":"StringFamily","oid":25}},{"name":"hashedPassword","id":2,"type":{"family":"BytesFamily","oid":17},"nullable":true},{"name":"isRole","id":3,"type":{"oid":16},"defaultExpr":"false"},{"name":"user_id","id":4,"type":{"family":"OidFamily","oid":26}}],"nextColumnId":5,"families":[{"name":"primary","columnNames":["username","user_id"],"columnIds":[1,4],"defaultColumnId":4},{"name":"fam_2_hashedPassword","id":2,"columnNames":["hashedPassword"],"columnIds":[2],"defaultColumnId":2},{"name":"fam_3_isRole","id":3,"columnNames":["isRole"],"columnIds":[3],"defaultColumnId":3}],"nextFamilyId":4,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["username"],"keyColumnDirections":["ASC"],"storeColumnNames":["hashedPassword","isRole","user_id"],"keyColumnIds":[1],"storeColumnIds":[2,3,4],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":2},"indexes":[{"name":"users_user_id_idx","id":2,"unique":true,"version":3,"keyColumnNames":["user_id"],"keyColumnDirections":["ASC"],"keyColumnIds":[4],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"constraintId":1}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{"wallTime":"0"},"nextConstraintId":3}} -{"table":{"name":"web_sessions","id":19,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"unique_rowid()"},{"name":"hashedSecret","id":2,"type":{"family":"BytesFamily","oid":17}},{"name":"username","id":3,"type":{"family":"StringFamily","oid":25}},{"name":"createdAt","id":4,"type":{"family":"TimestampFamily","oid":1114},"defaultExpr":"now():::TIMESTAMP"},{"name":"expiresAt","id":5,"type":{"family":"TimestampFamily","oid":1114}},{"name":"revokedAt","id":6,"type":{"family":"TimestampFamily","oid":1114},"nullable":true},{"name":"lastUsedAt","id":7,"type":{"family":"TimestampFamily","oid":1114},"defaultExpr":"now():::TIMESTAMP"},{"name":"auditInfo","id":8,"type":{"family":"StringFamily","oid":25},"nullable":true}],"nextColumnId":9,"families":[{"name":"fam_0_id_hashedSecret_username_createdAt_expiresAt_revokedAt_lastUsedAt_auditInfo","columnNames":["id","hashedSecret","username","createdAt","expiresAt","revokedAt","lastUsedAt","auditInfo"],"columnIds":[1,2,3,4,5,6,7,8]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["hashedSecret","username","createdAt","expiresAt","revokedAt","lastUsedAt","auditInfo"],"keyColumnIds":[1],"storeColumnIds":[2,3,4,5,6,7,8],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"indexes":[{"name":"web_sessions_expiresAt_idx","id":2,"version":3,"keyColumnNames":["expiresAt"],"keyColumnDirections":["ASC"],"keyColumnIds":[5],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"web_sessions_createdAt_idx","id":3,"version":3,"keyColumnNames":["createdAt"],"keyColumnDirections":["ASC"],"keyColumnIds":[4],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"web_sessions_revokedAt_idx","id":4,"version":3,"keyColumnNames":["revokedAt"],"keyColumnDirections":["ASC"],"keyColumnIds":[6],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"web_sessions_lastUsedAt_idx","id":5,"version":3,"keyColumnNames":["lastUsedAt"],"keyColumnDirections":["ASC"],"keyColumnIds":[7],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}}],"nextIndexId":6,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{"wallTime":"0"},"nextConstraintId":2}} +{"table":{"name":"web_sessions","id":19,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20},"defaultExpr":"unique_rowid()"},{"name":"hashedSecret","id":2,"type":{"family":"BytesFamily","oid":17}},{"name":"username","id":3,"type":{"family":"StringFamily","oid":25}},{"name":"createdAt","id":4,"type":{"family":"TimestampFamily","oid":1114},"defaultExpr":"now():::TIMESTAMP"},{"name":"expiresAt","id":5,"type":{"family":"TimestampFamily","oid":1114}},{"name":"revokedAt","id":6,"type":{"family":"TimestampFamily","oid":1114},"nullable":true},{"name":"lastUsedAt","id":7,"type":{"family":"TimestampFamily","oid":1114},"defaultExpr":"now():::TIMESTAMP"},{"name":"auditInfo","id":8,"type":{"family":"StringFamily","oid":25},"nullable":true},{"name":"user_id","id":9,"type":{"family":"OidFamily","oid":26},"nullable":true}],"nextColumnId":10,"families":[{"name":"fam_0_id_hashedSecret_username_createdAt_expiresAt_revokedAt_lastUsedAt_auditInfo","columnNames":["id","hashedSecret","username","createdAt","expiresAt","revokedAt","lastUsedAt","auditInfo","user_id"],"columnIds":[1,2,3,4,5,6,7,8,9]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["hashedSecret","username","createdAt","expiresAt","revokedAt","lastUsedAt","auditInfo","user_id"],"keyColumnIds":[1],"storeColumnIds":[2,3,4,5,6,7,8,9],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"indexes":[{"name":"web_sessions_expiresAt_idx","id":2,"version":3,"keyColumnNames":["expiresAt"],"keyColumnDirections":["ASC"],"keyColumnIds":[5],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"web_sessions_createdAt_idx","id":3,"version":3,"keyColumnNames":["createdAt"],"keyColumnDirections":["ASC"],"keyColumnIds":[4],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"web_sessions_revokedAt_idx","id":4,"version":3,"keyColumnNames":["revokedAt"],"keyColumnDirections":["ASC"],"keyColumnIds":[6],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}},{"name":"web_sessions_lastUsedAt_idx","id":5,"version":3,"keyColumnNames":["lastUsedAt"],"keyColumnDirections":["ASC"],"keyColumnIds":[7],"keySuffixColumnIds":[1],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{}}],"nextIndexId":6,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{"wallTime":"0"},"nextConstraintId":2}} {"table":{"name":"zones","id":5,"version":"1","modificationTime":{"wallTime":"0"},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"config","id":2,"type":{"family":"BytesFamily","oid":17},"nullable":true}],"nextColumnId":3,"families":[{"name":"primary","columnNames":["id"],"columnIds":[1]},{"name":"fam_2_config","id":2,"columnNames":["config"],"columnIds":[2],"defaultColumnId":2}],"nextFamilyId":3,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["config"],"keyColumnIds":[1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":2},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{"wallTime":"0"},"nextConstraintId":2}} {"schema":{"name":"public","id":101,"modificationTime":{"wallTime":"0"},"version":"1","parentId":100,"privileges":{"users":[{"userProto":"admin","privileges":"2","withGrantOption":"2"},{"userProto":"public","privileges":"516"},{"userProto":"root","privileges":"2","withGrantOption":"2"}],"ownerProto":"admin","version":2}}} {"schema":{"name":"public","id":103,"modificationTime":{"wallTime":"0"},"version":"1","parentId":102,"privileges":{"users":[{"userProto":"admin","privileges":"2","withGrantOption":"2"},{"userProto":"public","privileges":"516"},{"userProto":"root","privileges":"2","withGrantOption":"2"}],"ownerProto":"admin","version":2}}} diff --git a/pkg/sql/logictest/testdata/logic_test/crdb_internal_catalog b/pkg/sql/logictest/testdata/logic_test/crdb_internal_catalog index ebb5a4da54da..ebd16c10fd55 100644 --- a/pkg/sql/logictest/testdata/logic_test/crdb_internal_catalog +++ b/pkg/sql/logictest/testdata/logic_test/crdb_internal_catalog @@ -115,7 +115,7 @@ SELECT id, strip_volatile(descriptor) FROM crdb_internal.kv_catalog_descriptor 13 {"table": {"columns": [{"id": 1, "name": "timestamp", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 2, "name": "rangeID", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 3, "name": "storeID", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 4, "name": "eventType", "type": {"family": "StringFamily", "oid": 25}}, {"id": 5, "name": "otherRangeID", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 6, "name": "info", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"defaultExpr": "unique_rowid()", "id": 7, "name": "uniqueID", "type": {"family": "IntFamily", "oid": 20, "width": 64}}], "formatVersion": 3, "id": 13, "name": "rangelog", "nextColumnId": 8, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "parentId": 1, "primaryIndex": {"constraintId": 1, "encodingType": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "keyColumnDirections": ["ASC", "ASC"], "keyColumnIds": [1, 7], "keyColumnNames": ["timestamp", "uniqueID"], "name": "primary", "partitioning": {}, "sharded": {}, "storeColumnIds": [2, 3, 4, 5, 6], "storeColumnNames": ["rangeID", "storeID", "eventType", "otherRangeID", "info"], "unique": true, "version": 4}, "privileges": {"ownerProto": "node", "users": [{"privileges": "480", "userProto": "admin", "withGrantOption": "480"}, {"privileges": "480", "userProto": "root", "withGrantOption": "480"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 29, "version": "1"}} 14 {"table": {"columns": [{"id": 1, "name": "key", "type": {"family": "StringFamily", "oid": 25}}, {"id": 2, "name": "value", "nullable": true, "type": {"family": "BytesFamily", "oid": 17}}, {"id": 3, "name": "lastUpdated", "type": {"family": "TimestampFamily", "oid": 1114}}], "formatVersion": 3, "id": 14, "name": "ui", "nextColumnId": 4, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "parentId": 1, "primaryIndex": {"constraintId": 1, "encodingType": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [1], "keyColumnNames": ["key"], "name": "primary", "partitioning": {}, "sharded": {}, "storeColumnIds": [2, 3], "storeColumnNames": ["value", "lastUpdated"], "unique": true, "version": 4}, "privileges": {"ownerProto": "node", "users": [{"privileges": "480", "userProto": "admin", "withGrantOption": "480"}, {"privileges": "480", "userProto": "root", "withGrantOption": "480"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 29, "version": "1"}} 15 {"table": {"columns": [{"defaultExpr": "unique_rowid()", "id": 1, "name": "id", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 2, "name": "status", "type": {"family": "StringFamily", "oid": 25}}, {"defaultExpr": "now():::TIMESTAMP", "id": 3, "name": "created", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 4, "name": "payload", "type": {"family": "BytesFamily", "oid": 17}}, {"id": 5, "name": "progress", "nullable": true, "type": {"family": "BytesFamily", "oid": 17}}, {"id": 6, "name": "created_by_type", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 7, "name": "created_by_id", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 8, "name": "claim_session_id", "nullable": true, "type": {"family": "BytesFamily", "oid": 17}}, {"id": 9, "name": "claim_instance_id", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 10, "name": "num_runs", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 11, "name": "last_run", "nullable": true, "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 12, "name": "job_type", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}], "formatVersion": 3, "id": 15, "indexes": [{"foreignKey": {}, "geoConfig": {}, "id": 2, "interleave": {}, "keyColumnDirections": ["ASC", "ASC"], "keyColumnIds": [2, 3], "keyColumnNames": ["status", "created"], "keySuffixColumnIds": [1], "name": "jobs_status_created_idx", "partitioning": {}, "sharded": {}, "version": 3}, {"foreignKey": {}, "geoConfig": {}, "id": 3, "interleave": {}, "keyColumnDirections": ["ASC", "ASC"], "keyColumnIds": [6, 7], "keyColumnNames": ["created_by_type", "created_by_id"], "keySuffixColumnIds": [1], "name": "jobs_created_by_type_created_by_id_idx", "partitioning": {}, "sharded": {}, "storeColumnIds": [2], "storeColumnNames": ["status"], "version": 3}, {"foreignKey": {}, "geoConfig": {}, "id": 4, "interleave": {}, "keyColumnDirections": ["ASC", "ASC", "ASC"], "keyColumnIds": [8, 2, 3], "keyColumnNames": ["claim_session_id", "status", "created"], "keySuffixColumnIds": [1], "name": "jobs_run_stats_idx", "partitioning": {}, "predicate": "status IN ('running':::STRING, 'reverting':::STRING, 'pending':::STRING, 'pause-requested':::STRING, 'cancel-requested':::STRING)", "sharded": {}, "storeColumnIds": [11, 10, 9], "storeColumnNames": ["last_run", "num_runs", "claim_instance_id"], "version": 3}, {"foreignKey": {}, "geoConfig": {}, "id": 5, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [12], "keyColumnNames": ["job_type"], "keySuffixColumnIds": [1], "name": "jobs_job_type_idx", "partitioning": {}, "sharded": {}, "version": 3}], "name": "jobs", "nextColumnId": 13, "nextConstraintId": 2, "nextIndexId": 6, "nextMutationId": 1, "parentId": 1, "primaryIndex": {"constraintId": 1, "encodingType": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [1], "keyColumnNames": ["id"], "name": "primary", "partitioning": {}, "sharded": {}, "storeColumnIds": [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], "storeColumnNames": ["status", "created", "payload", "progress", "created_by_type", "created_by_id", "claim_session_id", "claim_instance_id", "num_runs", "last_run", "job_type"], "unique": true, "version": 4}, "privileges": {"ownerProto": "node", "users": [{"privileges": "480", "userProto": "admin", "withGrantOption": "480"}, {"privileges": "480", "userProto": "root", "withGrantOption": "480"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 29, "version": "1"}} -19 {"table": {"columns": [{"defaultExpr": "unique_rowid()", "id": 1, "name": "id", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 2, "name": "hashedSecret", "type": {"family": "BytesFamily", "oid": 17}}, {"id": 3, "name": "username", "type": {"family": "StringFamily", "oid": 25}}, {"defaultExpr": "now():::TIMESTAMP", "id": 4, "name": "createdAt", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 5, "name": "expiresAt", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 6, "name": "revokedAt", "nullable": true, "type": {"family": "TimestampFamily", "oid": 1114}}, {"defaultExpr": "now():::TIMESTAMP", "id": 7, "name": "lastUsedAt", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 8, "name": "auditInfo", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}], "formatVersion": 3, "id": 19, "indexes": [{"foreignKey": {}, "geoConfig": {}, "id": 2, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [5], "keyColumnNames": ["expiresAt"], "keySuffixColumnIds": [1], "name": "web_sessions_expiresAt_idx", "partitioning": {}, "sharded": {}, "version": 3}, {"foreignKey": {}, "geoConfig": {}, "id": 3, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [4], "keyColumnNames": ["createdAt"], "keySuffixColumnIds": [1], "name": "web_sessions_createdAt_idx", "partitioning": {}, "sharded": {}, "version": 3}, {"foreignKey": {}, "geoConfig": {}, "id": 4, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [6], "keyColumnNames": ["revokedAt"], "keySuffixColumnIds": [1], "name": "web_sessions_revokedAt_idx", "partitioning": {}, "sharded": {}, "version": 3}, {"foreignKey": {}, "geoConfig": {}, "id": 5, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [7], "keyColumnNames": ["lastUsedAt"], "keySuffixColumnIds": [1], "name": "web_sessions_lastUsedAt_idx", "partitioning": {}, "sharded": {}, "version": 3}], "name": "web_sessions", "nextColumnId": 9, "nextConstraintId": 2, "nextIndexId": 6, "nextMutationId": 1, "parentId": 1, "primaryIndex": {"constraintId": 1, "encodingType": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [1], "keyColumnNames": ["id"], "name": "primary", "partitioning": {}, "sharded": {}, "storeColumnIds": [2, 3, 4, 5, 6, 7, 8], "storeColumnNames": ["hashedSecret", "username", "createdAt", "expiresAt", "revokedAt", "lastUsedAt", "auditInfo"], "unique": true, "version": 4}, "privileges": {"ownerProto": "node", "users": [{"privileges": "480", "userProto": "admin", "withGrantOption": "480"}, {"privileges": "480", "userProto": "root", "withGrantOption": "480"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 29, "version": "1"}} +19 {"table": {"columns": [{"defaultExpr": "unique_rowid()", "id": 1, "name": "id", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 2, "name": "hashedSecret", "type": {"family": "BytesFamily", "oid": 17}}, {"id": 3, "name": "username", "type": {"family": "StringFamily", "oid": 25}}, {"defaultExpr": "now():::TIMESTAMP", "id": 4, "name": "createdAt", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 5, "name": "expiresAt", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 6, "name": "revokedAt", "nullable": true, "type": {"family": "TimestampFamily", "oid": 1114}}, {"defaultExpr": "now():::TIMESTAMP", "id": 7, "name": "lastUsedAt", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 8, "name": "auditInfo", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 9, "name": "user_id", "nullable": true, "type": {"family": "OidFamily", "oid": 26}}], "formatVersion": 3, "id": 19, "indexes": [{"foreignKey": {}, "geoConfig": {}, "id": 2, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [5], "keyColumnNames": ["expiresAt"], "keySuffixColumnIds": [1], "name": "web_sessions_expiresAt_idx", "partitioning": {}, "sharded": {}, "version": 3}, {"foreignKey": {}, "geoConfig": {}, "id": 3, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [4], "keyColumnNames": ["createdAt"], "keySuffixColumnIds": [1], "name": "web_sessions_createdAt_idx", "partitioning": {}, "sharded": {}, "version": 3}, {"foreignKey": {}, "geoConfig": {}, "id": 4, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [6], "keyColumnNames": ["revokedAt"], "keySuffixColumnIds": [1], "name": "web_sessions_revokedAt_idx", "partitioning": {}, "sharded": {}, "version": 3}, {"foreignKey": {}, "geoConfig": {}, "id": 5, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [7], "keyColumnNames": ["lastUsedAt"], "keySuffixColumnIds": [1], "name": "web_sessions_lastUsedAt_idx", "partitioning": {}, "sharded": {}, "version": 3}], "name": "web_sessions", "nextColumnId": 10, "nextConstraintId": 2, "nextIndexId": 6, "nextMutationId": 1, "parentId": 1, "primaryIndex": {"constraintId": 1, "encodingType": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [1], "keyColumnNames": ["id"], "name": "primary", "partitioning": {}, "sharded": {}, "storeColumnIds": [2, 3, 4, 5, 6, 7, 8, 9], "storeColumnNames": ["hashedSecret", "username", "createdAt", "expiresAt", "revokedAt", "lastUsedAt", "auditInfo", "user_id"], "unique": true, "version": 4}, "privileges": {"ownerProto": "node", "users": [{"privileges": "480", "userProto": "admin", "withGrantOption": "480"}, {"privileges": "480", "userProto": "root", "withGrantOption": "480"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 29, "version": "1"}} 20 {"table": {"columns": [{"id": 1, "name": "tableID", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"defaultExpr": "unique_rowid()", "id": 2, "name": "statisticID", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 3, "name": "name", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 4, "name": "columnIDs", "type": {"arrayContents": {"family": "IntFamily", "oid": 20, "width": 64}, "arrayElemType": "IntFamily", "family": "ArrayFamily", "oid": 1016, "width": 64}}, {"defaultExpr": "now():::TIMESTAMP", "id": 5, "name": "createdAt", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 6, "name": "rowCount", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 7, "name": "distinctCount", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 8, "name": "nullCount", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 9, "name": "histogram", "nullable": true, "type": {"family": "BytesFamily", "oid": 17}}, {"defaultExpr": "0:::INT8", "id": 10, "name": "avgSize", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 11, "name": "partialPredicate", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 12, "name": "fullStatisticID", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}], "formatVersion": 3, "id": 20, "name": "table_statistics", "nextColumnId": 13, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "parentId": 1, "primaryIndex": {"constraintId": 1, "encodingType": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "keyColumnDirections": ["ASC", "ASC"], "keyColumnIds": [1, 2], "keyColumnNames": ["tableID", "statisticID"], "name": "primary", "partitioning": {}, "sharded": {}, "storeColumnIds": [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], "storeColumnNames": ["name", "columnIDs", "createdAt", "rowCount", "distinctCount", "nullCount", "histogram", "avgSize", "partialPredicate", "fullStatisticID"], "unique": true, "version": 4}, "privileges": {"ownerProto": "node", "users": [{"privileges": "480", "userProto": "admin", "withGrantOption": "480"}, {"privileges": "480", "userProto": "root", "withGrantOption": "480"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 29, "version": "1"}} 21 {"table": {"columns": [{"id": 1, "name": "localityKey", "type": {"family": "StringFamily", "oid": 25}}, {"id": 2, "name": "localityValue", "type": {"family": "StringFamily", "oid": 25}}, {"id": 3, "name": "latitude", "type": {"family": "DecimalFamily", "oid": 1700, "precision": 18, "width": 15}}, {"id": 4, "name": "longitude", "type": {"family": "DecimalFamily", "oid": 1700, "precision": 18, "width": 15}}], "formatVersion": 3, "id": 21, "name": "locations", "nextColumnId": 5, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "parentId": 1, "primaryIndex": {"constraintId": 1, "encodingType": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "keyColumnDirections": ["ASC", "ASC"], "keyColumnIds": [1, 2], "keyColumnNames": ["localityKey", "localityValue"], "name": "primary", "partitioning": {}, "sharded": {}, "storeColumnIds": [3, 4], "storeColumnNames": ["latitude", "longitude"], "unique": true, "version": 4}, "privileges": {"ownerProto": "node", "users": [{"privileges": "480", "userProto": "admin", "withGrantOption": "480"}, {"privileges": "480", "userProto": "root", "withGrantOption": "480"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 29, "version": "1"}} 23 {"table": {"columns": [{"id": 1, "name": "role", "type": {"family": "StringFamily", "oid": 25}}, {"id": 2, "name": "member", "type": {"family": "StringFamily", "oid": 25}}, {"id": 3, "name": "isAdmin", "type": {"oid": 16}}, {"id": 4, "name": "role_id", "type": {"family": "OidFamily", "oid": 26}}, {"id": 5, "name": "member_id", "type": {"family": "OidFamily", "oid": 26}}], "formatVersion": 3, "id": 23, "indexes": [{"foreignKey": {}, "geoConfig": {}, "id": 2, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [1], "keyColumnNames": ["role"], "keySuffixColumnIds": [2], "name": "role_members_role_idx", "partitioning": {}, "sharded": {}, "version": 3}, {"foreignKey": {}, "geoConfig": {}, "id": 3, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [2], "keyColumnNames": ["member"], "keySuffixColumnIds": [1], "name": "role_members_member_idx", "partitioning": {}, "sharded": {}, "version": 3}, {"foreignKey": {}, "geoConfig": {}, "id": 4, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [4], "keyColumnNames": ["role_id"], "keySuffixColumnIds": [1, 2], "name": "role_members_role_id_idx", "partitioning": {}, "sharded": {}, "version": 3}, {"foreignKey": {}, "geoConfig": {}, "id": 5, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [5], "keyColumnNames": ["member_id"], "keySuffixColumnIds": [1, 2], "name": "role_members_member_id_idx", "partitioning": {}, "sharded": {}, "version": 3}, {"constraintId": 1, "foreignKey": {}, "geoConfig": {}, "id": 6, "interleave": {}, "keyColumnDirections": ["ASC", "ASC"], "keyColumnIds": [4, 5], "keyColumnNames": ["role_id", "member_id"], "keySuffixColumnIds": [1, 2], "name": "role_members_role_id_member_id_key", "partitioning": {}, "sharded": {}, "unique": true, "version": 3}], "name": "role_members", "nextColumnId": 6, "nextConstraintId": 3, "nextIndexId": 7, "nextMutationId": 1, "parentId": 1, "primaryIndex": {"constraintId": 2, "encodingType": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "keyColumnDirections": ["ASC", "ASC"], "keyColumnIds": [1, 2], "keyColumnNames": ["role", "member"], "name": "primary", "partitioning": {}, "sharded": {}, "storeColumnIds": [3, 4, 5], "storeColumnNames": ["isAdmin", "role_id", "member_id"], "unique": true, "version": 4}, "privileges": {"ownerProto": "node", "users": [{"privileges": "480", "userProto": "admin", "withGrantOption": "480"}, {"privileges": "480", "userProto": "root", "withGrantOption": "480"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 29, "version": "1"}} diff --git a/pkg/sql/logictest/testdata/logic_test/information_schema b/pkg/sql/logictest/testdata/logic_test/information_schema index 6b7e5ce6cf04..6910ba72e50e 100644 --- a/pkg/sql/logictest/testdata/logic_test/information_schema +++ b/pkg/sql/logictest/testdata/logic_test/information_schema @@ -2397,6 +2397,7 @@ system public web_sessions hashedSecret system public web_sessions id 1 system public web_sessions lastUsedAt 7 system public web_sessions revokedAt 6 +system public web_sessions user_id 9 system public web_sessions username 3 system public zones config 2 system public zones id 1 diff --git a/pkg/upgrade/upgrades/BUILD.bazel b/pkg/upgrade/upgrades/BUILD.bazel index 717b8e363e35..5126ffe541ff 100644 --- a/pkg/upgrade/upgrades/BUILD.bazel +++ b/pkg/upgrade/upgrades/BUILD.bazel @@ -33,6 +33,7 @@ go_library( "upgrades.go", "wait_for_del_range_in_gc_job.go", "wait_for_schema_changes.go", + "web_sessions_table_user_id_migration.go", ], importpath = "github.com/cockroachdb/cockroach/pkg/upgrade/upgrades", visibility = ["//visibility:public"], @@ -112,6 +113,7 @@ go_test( "upgrade_sequence_to_be_referenced_by_ID_external_test.go", "wait_for_del_range_in_gc_job_test.go", "wait_for_schema_changes_test.go", + "web_sessions_table_user_id_migration_test.go", ], args = ["-test.timeout=895s"], data = glob(["testdata/**"]), diff --git a/pkg/upgrade/upgrades/upgrades.go b/pkg/upgrade/upgrades/upgrades.go index ce2567cf31d1..0d8ae3b47c95 100644 --- a/pkg/upgrade/upgrades/upgrades.go +++ b/pkg/upgrade/upgrades/upgrades.go @@ -274,6 +274,18 @@ var upgrades = []upgradebase.Upgrade{ upgrade.NoPrecondition, backfillSystemPrivilegesUserIDColumn, ), + upgrade.NewTenantUpgrade( + "add user_id column to system.web_sessions table", + toCV(clusterversion.V23_1WebSessionsTableHasUserIDColumn), + upgrade.NoPrecondition, + alterWebSessionsTableAddUserIDColumn, + ), + upgrade.NewTenantUpgrade( + "backfill user_id column in system.web_sessions table", + toCV(clusterversion.V23_1WebSessionsTableUserIDColumnBackfilled), + upgrade.NoPrecondition, + backfillWebSessionsTableUserIDColumn, + ), } func init() { diff --git a/pkg/upgrade/upgrades/web_sessions_table_user_id_migration.go b/pkg/upgrade/upgrades/web_sessions_table_user_id_migration.go new file mode 100644 index 000000000000..d6ef6697c2fc --- /dev/null +++ b/pkg/upgrade/upgrades/web_sessions_table_user_id_migration.go @@ -0,0 +1,74 @@ +// Copyright 2023 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package upgrades + +import ( + "context" + + "github.com/cockroachdb/cockroach/pkg/clusterversion" + "github.com/cockroachdb/cockroach/pkg/keys" + "github.com/cockroachdb/cockroach/pkg/sql/catalog/systemschema" + "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" + "github.com/cockroachdb/cockroach/pkg/upgrade" +) + +const addUserIDColumnToWebSessionsTableStmt = ` +ALTER TABLE system.web_sessions +ADD COLUMN IF NOT EXISTS user_id OID +FAMILY "fam_0_id_hashedSecret_username_createdAt_expiresAt_revokedAt_lastUsedAt_auditInfo" +` + +func alterWebSessionsTableAddUserIDColumn( + ctx context.Context, cs clusterversion.ClusterVersion, d upgrade.TenantDeps, +) error { + for _, op := range []operation{ + { + name: "add-user-id-column-web-sessions-table", + schemaList: []string{"user_id"}, + query: addUserIDColumnToWebSessionsTableStmt, + schemaExistsFn: columnExists, + }, + } { + if err := migrateTable(ctx, cs, d, op, keys.WebSessionsTableID, systemschema.WebSessionsTable); err != nil { + return err + } + } + + return nil +} + +const backfillUserIDColumnWebSessionsTableStmt = ` +UPDATE system.web_sessions AS w +SET user_id = u.user_id +FROM system.users AS u +WHERE w.user_id IS NULL AND w.username = u.username +LIMIT 1000 +` + +func backfillWebSessionsTableUserIDColumn( + ctx context.Context, cs clusterversion.ClusterVersion, d upgrade.TenantDeps, +) error { + ie := d.DB.Executor() + for { + rowsAffected, err := ie.ExecEx(ctx, "backfill-user-id-col-web-sessions-table", nil, /* txn */ + sessiondata.NodeUserSessionDataOverride, + backfillUserIDColumnWebSessionsTableStmt, + ) + if err != nil { + return err + } + if rowsAffected == 0 { + break + } + } + + return nil +} diff --git a/pkg/upgrade/upgrades/web_sessions_table_user_id_migration_test.go b/pkg/upgrade/upgrades/web_sessions_table_user_id_migration_test.go new file mode 100644 index 000000000000..d8b73284516e --- /dev/null +++ b/pkg/upgrade/upgrades/web_sessions_table_user_id_migration_test.go @@ -0,0 +1,248 @@ +// Copyright 2023 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package upgrades_test + +import ( + "context" + "fmt" + "strconv" + "testing" + + "github.com/cockroachdb/cockroach/pkg/base" + "github.com/cockroachdb/cockroach/pkg/clusterversion" + "github.com/cockroachdb/cockroach/pkg/keys" + "github.com/cockroachdb/cockroach/pkg/security/username" + "github.com/cockroachdb/cockroach/pkg/server" + "github.com/cockroachdb/cockroach/pkg/settings/cluster" + "github.com/cockroachdb/cockroach/pkg/sql/catalog/catenumpb" + "github.com/cockroachdb/cockroach/pkg/sql/catalog/catpb" + "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" + "github.com/cockroachdb/cockroach/pkg/sql/catalog/systemschema" + "github.com/cockroachdb/cockroach/pkg/sql/privilege" + "github.com/cockroachdb/cockroach/pkg/sql/sem/catconstants" + "github.com/cockroachdb/cockroach/pkg/sql/types" + "github.com/cockroachdb/cockroach/pkg/testutils/skip" + "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" + "github.com/cockroachdb/cockroach/pkg/testutils/testcluster" + "github.com/cockroachdb/cockroach/pkg/upgrade/upgrades" + "github.com/cockroachdb/cockroach/pkg/util/leaktest" + "github.com/stretchr/testify/require" +) + +func TestWebSessionsUserIDMigrationNoUsers(t *testing.T) { + runTestWebSessionsUserIDMigration(t, 0) +} + +func TestWebSessionsUserIDMigration10Users(t *testing.T) { + runTestWebSessionsUserIDMigration(t, 10) +} + +func TestWebSessionsUserIDMigration1500Users(t *testing.T) { + skip.UnderRace(t) + skip.UnderStress(t) + runTestWebSessionsUserIDMigration(t, 1500) +} + +func runTestWebSessionsUserIDMigration(t *testing.T, numUsers int) { + defer leaktest.AfterTest(t)() + ctx := context.Background() + + settings := cluster.MakeTestingClusterSettingsWithVersions( + clusterversion.TestingBinaryVersion, + clusterversion.ByKey(clusterversion.V23_1WebSessionsTableHasUserIDColumn-1), + false, /* initializeVersion */ + ) + + tc := testcluster.StartTestCluster(t, 1 /* nodes */, base.TestClusterArgs{ + ServerArgs: base.TestServerArgs{ + Settings: settings, + Knobs: base.TestingKnobs{ + Server: &server.TestingKnobs{ + DisableAutomaticVersionUpgrade: make(chan struct{}), + BinaryVersionOverride: clusterversion.ByKey(clusterversion.V23_1WebSessionsTableHasUserIDColumn - 1), + }, + }, + }, + }) + defer tc.Stopper().Stop(ctx) + + db := tc.ServerConn(0) + defer db.Close() + tdb := sqlutils.MakeSQLRunner(db) + s := tc.Server(0) + + // Inject the descriptor for the system.web_sessions table from before the + // user_id column was added. + upgrades.InjectLegacyTable(ctx, t, s, systemschema.WebSessionsTable, getTableDescForSystemWebSessionsTableBeforeUserIDCol) + + // Create test users. + tx, err := db.BeginTx(ctx, nil /* opts */) + require.NoError(t, err) + txRunner := sqlutils.MakeSQLRunner(tx) + for i := 0; i < numUsers; i++ { + // Group statements into transactions of 100 users to speed up creation. + if i != 0 && i%100 == 0 { + err := tx.Commit() + require.NoError(t, err) + tx, err = db.BeginTx(ctx, nil /* opts */) + require.NoError(t, err) + txRunner = sqlutils.MakeSQLRunner(tx) + } + txRunner.Exec(t, fmt.Sprintf("CREATE USER testuser%d", i)) + + // Simulate the INSERT that happens in the actual authentication code. + txRunner.Exec(t, fmt.Sprintf(` +INSERT INTO system.web_sessions ("hashedSecret", username, "createdAt", "expiresAt", "lastUsedAt") +VALUES ( + '\xe77edd369fc3a955a129d2ced69d97717eeee49912e4369a2b687a4d8c36f798', + 'testuser%d', + '2023-02-14 20:56:30.699447', + '2023-02-21 20:56:30.699242', + '2023-02-14 20:56:30.699447' +) +`, i)) + } + err = tx.Commit() + require.NoError(t, err) + tdb.CheckQueryResults(t, "SELECT count(*) FROM system.web_sessions", [][]string{{strconv.Itoa(numUsers)}}) + + // Run migrations. + _, err = tc.Conns[0].ExecContext(ctx, `SET CLUSTER SETTING version = $1`, + clusterversion.ByKey(clusterversion.V23_1WebSessionsTableHasUserIDColumn).String()) + require.NoError(t, err) + _, err = tc.Conns[0].ExecContext(ctx, `SET CLUSTER SETTING version = $1`, + clusterversion.ByKey(clusterversion.V23_1WebSessionsTableUserIDColumnBackfilled).String()) + require.NoError(t, err) + + // Verify that the final schema matches the expected one. + expectedSchema := `CREATE TABLE public.web_sessions ( + id INT8 NOT NULL DEFAULT unique_rowid(), + "hashedSecret" BYTES NOT NULL, + username STRING NOT NULL, + "createdAt" TIMESTAMP NOT NULL DEFAULT now():::TIMESTAMP, + "expiresAt" TIMESTAMP NOT NULL, + "revokedAt" TIMESTAMP NULL, + "lastUsedAt" TIMESTAMP NOT NULL DEFAULT now():::TIMESTAMP, + "auditInfo" STRING NULL, + user_id OID NULL, + CONSTRAINT "primary" PRIMARY KEY (id ASC), + INDEX "web_sessions_expiresAt_idx" ("expiresAt" ASC), + INDEX "web_sessions_createdAt_idx" ("createdAt" ASC), + INDEX "web_sessions_revokedAt_idx" ("revokedAt" ASC), + INDEX "web_sessions_lastUsedAt_idx" ("lastUsedAt" ASC), + FAMILY "fam_0_id_hashedSecret_username_createdAt_expiresAt_revokedAt_lastUsedAt_auditInfo" (id, "hashedSecret", username, "createdAt", "expiresAt", "revokedAt", "lastUsedAt", "auditInfo", user_id) +)` + r := tdb.QueryRow(t, "SELECT create_statement FROM [SHOW CREATE TABLE system.web_sessions]") + var actualSchema string + r.Scan(&actualSchema) + require.Equal(t, expectedSchema, actualSchema) + + // Check that the backfill was successful and correct. + tdb.CheckQueryResults(t, "SELECT * FROM system.web_sessions WHERE user_id IS NULL", [][]string{}) + tdb.CheckQueryResults(t, "SELECT count(*) FROM system.web_sessions", [][]string{{strconv.Itoa(numUsers)}}) + tdb.CheckQueryResults(t, "SELECT count(*) FROM system.web_sessions AS a JOIN system.users AS b ON a.username = b.username AND a.user_id <> b.user_id", [][]string{{"0"}}) +} + +func getTableDescForSystemWebSessionsTableBeforeUserIDCol() *descpb.TableDescriptor { + uniqueRowIDString := "unique_rowid()" + nowString := "now():::TIMESTAMP" + return &descpb.TableDescriptor{ + Name: string(catconstants.WebSessionsTableName), + ID: keys.WebSessionsTableID, + ParentID: keys.SystemDatabaseID, + UnexposedParentSchemaID: keys.PublicSchemaID, + Version: 1, + Columns: []descpb.ColumnDescriptor{ + {Name: "id", ID: 1, Type: types.Int, DefaultExpr: &uniqueRowIDString}, + {Name: "hashedSecret", ID: 2, Type: types.Bytes}, + {Name: "username", ID: 3, Type: types.String}, + {Name: "createdAt", ID: 4, Type: types.Timestamp, DefaultExpr: &nowString}, + {Name: "expiresAt", ID: 5, Type: types.Timestamp}, + {Name: "revokedAt", ID: 6, Type: types.Timestamp, Nullable: true}, + {Name: "lastUsedAt", ID: 7, Type: types.Timestamp, DefaultExpr: &nowString}, + {Name: "auditInfo", ID: 8, Type: types.String, Nullable: true}, + }, + NextColumnID: 9, + Families: []descpb.ColumnFamilyDescriptor{ + { + Name: "fam_0_id_hashedSecret_username_createdAt_expiresAt_revokedAt_lastUsedAt_auditInfo", + ID: 0, + ColumnNames: []string{ + "id", + "hashedSecret", + "username", + "createdAt", + "expiresAt", + "revokedAt", + "lastUsedAt", + "auditInfo", + }, + ColumnIDs: []descpb.ColumnID{1, 2, 3, 4, 5, 6, 7, 8}, + }, + }, + NextFamilyID: 1, + PrimaryIndex: descpb.IndexDescriptor{ + Name: "primary", + ID: 1, + Unique: true, + KeyColumnNames: []string{"id"}, + KeyColumnDirections: []catenumpb.IndexColumn_Direction{catenumpb.IndexColumn_ASC}, + KeyColumnIDs: []descpb.ColumnID{1}, + }, + Indexes: []descpb.IndexDescriptor{ + { + Name: "web_sessions_expiresAt_idx", + ID: 2, + Unique: false, + KeyColumnNames: []string{"expiresAt"}, + KeyColumnDirections: []catenumpb.IndexColumn_Direction{catenumpb.IndexColumn_ASC}, + KeyColumnIDs: []descpb.ColumnID{5}, + KeySuffixColumnIDs: []descpb.ColumnID{1}, + Version: descpb.StrictIndexColumnIDGuaranteesVersion, + }, + { + Name: "web_sessions_createdAt_idx", + ID: 3, + Unique: false, + KeyColumnNames: []string{"createdAt"}, + KeyColumnDirections: []catenumpb.IndexColumn_Direction{catenumpb.IndexColumn_ASC}, + KeyColumnIDs: []descpb.ColumnID{4}, + KeySuffixColumnIDs: []descpb.ColumnID{1}, + Version: descpb.StrictIndexColumnIDGuaranteesVersion, + }, + { + Name: "web_sessions_revokedAt_idx", + ID: 4, + Unique: false, + KeyColumnNames: []string{"revokedAt"}, + KeyColumnDirections: []catenumpb.IndexColumn_Direction{catenumpb.IndexColumn_ASC}, + KeyColumnIDs: []descpb.ColumnID{6}, + KeySuffixColumnIDs: []descpb.ColumnID{1}, + Version: descpb.StrictIndexColumnIDGuaranteesVersion, + }, + { + Name: "web_sessions_lastUsedAt_idx", + ID: 5, + Unique: false, + KeyColumnNames: []string{"lastUsedAt"}, + KeyColumnDirections: []catenumpb.IndexColumn_Direction{catenumpb.IndexColumn_ASC}, + KeyColumnIDs: []descpb.ColumnID{7}, + KeySuffixColumnIDs: []descpb.ColumnID{1}, + Version: descpb.StrictIndexColumnIDGuaranteesVersion, + }, + }, + NextIndexID: 6, + Privileges: catpb.NewCustomSuperuserPrivilegeDescriptor(privilege.ReadWriteData, username.NodeUserName()), + FormatVersion: descpb.InterleavedFormatVersion, + NextMutationID: 1, + NextConstraintID: 1, + } +}