Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli,sql/sem/builtins: emit_defaults to false for decode-proto, pb_to_json #69185

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pkg/ccl/backupccl/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6975,7 +6975,7 @@ func TestBackupRestoreTenant(t *testing.T) {
restoreDB.CheckQueryResults(t, `select * from system.tenants`, [][]string{})
restoreDB.Exec(t, `RESTORE TENANT 10 FROM 'nodelocal://1/t10'`)
restoreDB.CheckQueryResults(t,
`select id, active, crdb_internal.pb_to_json('cockroach.sql.sqlbase.TenantInfo', info) from system.tenants`,
`select id, active, crdb_internal.pb_to_json('cockroach.sql.sqlbase.TenantInfo', info, true) from system.tenants`,
[][]string{{`10`, `true`, `{"id": "10", "state": "ACTIVE"}`}},
)

Expand Down Expand Up @@ -7023,7 +7023,7 @@ func TestBackupRestoreTenant(t *testing.T) {

restoreDB.Exec(t, `RESTORE TENANT 10 FROM 'nodelocal://1/t10'`)
restoreDB.CheckQueryResults(t,
`select id, active, crdb_internal.pb_to_json('cockroach.sql.sqlbase.TenantInfo', info) from system.tenants`,
`select id, active, crdb_internal.pb_to_json('cockroach.sql.sqlbase.TenantInfo', info, true) from system.tenants`,
[][]string{{`10`, `true`, `{"id": "10", "state": "ACTIVE"}`}},
)

Expand All @@ -7050,7 +7050,7 @@ func TestBackupRestoreTenant(t *testing.T) {
restoreDB.CheckQueryResults(t, `select * from system.tenants`, [][]string{})
restoreDB.Exec(t, `RESTORE TENANT 10 FROM 'nodelocal://1/t10'`)
restoreDB.CheckQueryResults(t,
`select id, active, crdb_internal.pb_to_json('cockroach.sql.sqlbase.TenantInfo', info) from system.tenants`,
`select id, active, crdb_internal.pb_to_json('cockroach.sql.sqlbase.TenantInfo', info, true) from system.tenants`,
[][]string{{`10`, `true`, `{"id": "10", "state": "ACTIVE"}`}},
)
})
Expand All @@ -7065,7 +7065,7 @@ func TestBackupRestoreTenant(t *testing.T) {
restoreDB.CheckQueryResults(t, `select * from system.tenants`, [][]string{})
restoreDB.Exec(t, `RESTORE TENANT 10 FROM 'nodelocal://1/clusterwide'`)
restoreDB.CheckQueryResults(t,
`select id, active, crdb_internal.pb_to_json('cockroach.sql.sqlbase.TenantInfo', info) from system.tenants`,
`select id, active, crdb_internal.pb_to_json('cockroach.sql.sqlbase.TenantInfo', info, true) from system.tenants`,
[][]string{{`10`, `true`, `{"id": "10", "state": "ACTIVE"}`}},
)

Expand All @@ -7092,7 +7092,7 @@ func TestBackupRestoreTenant(t *testing.T) {
restoreDB.CheckQueryResults(t, `select * from system.tenants`, [][]string{})
restoreDB.Exec(t, `RESTORE FROM 'nodelocal://1/clusterwide'`)
restoreDB.CheckQueryResults(t,
`select id, active, crdb_internal.pb_to_json('cockroach.sql.sqlbase.TenantInfo', info) from system.tenants`,
`select id, active, crdb_internal.pb_to_json('cockroach.sql.sqlbase.TenantInfo', info, true) from system.tenants`,
[][]string{
{`10`, `true`, `{"id": "10", "state": "ACTIVE"}`},
{`11`, `true`, `{"id": "11", "state": "ACTIVE"}`},
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@ func init() {
f = debugDecodeProtoCmd.Flags()
f.StringVar(&debugDecodeProtoName, "schema", "cockroach.sql.sqlbase.Descriptor",
"fully qualified name of the proto to decode")
f.BoolVar(&debugDecodeProtoEmitDefaults, "emit-defaults", true,
f.BoolVar(&debugDecodeProtoEmitDefaults, "emit-defaults", false,
"encode default values for every field")

f = debugCheckLogConfigCmd.Flags()
Expand Down
6 changes: 3 additions & 3 deletions pkg/sql/logictest/testdata/logic_test/tenant
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SELECT crdb_internal.create_tenant(10)
10

query IBT colnames
SELECT id, active, crdb_internal.pb_to_json('cockroach.sql.sqlbase.TenantInfo', info)
SELECT id, active, crdb_internal.pb_to_json('cockroach.sql.sqlbase.TenantInfo', info, true)
FROM system.tenants
ORDER BY id
----
Expand All @@ -38,7 +38,7 @@ SELECT crdb_internal.destroy_tenant(5)
5

query IBT colnames
SELECT id, active, crdb_internal.pb_to_json('cockroach.sql.sqlbase.TenantInfo', info)
SELECT id, active, crdb_internal.pb_to_json('cockroach.sql.sqlbase.TenantInfo', info, true)
FROM system.tenants
ORDER BY id
----
Expand Down Expand Up @@ -145,7 +145,7 @@ query error pgcode 42704 tenant "5" does not exist
SELECT crdb_internal.gc_tenant(5)

query IBT colnames
SELECT id, active, crdb_internal.pb_to_json('cockroach.sql.sqlbase.TenantInfo', info)
SELECT id, active, crdb_internal.pb_to_json('cockroach.sql.sqlbase.TenantInfo', info, true)
FROM system.tenants
ORDER BY id
----
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/sem/builtins/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -3837,7 +3837,7 @@ value if you rely on the HLC for accuracy.`,
},
ReturnType: returnType,
Fn: func(context *tree.EvalContext, args tree.Datums) (tree.Datum, error) {
const emitDefaults = true
const emitDefaults = false
return pbToJSON(
string(tree.MustBeDString(args[0])),
[]byte(tree.MustBeDBytes(args[1])),
Expand Down