-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
87875: ccl/backupccl: add application name to backup/restore telemetry r=rhu713 a=rhu713 Add application name as a field in RecoveryEvent. Record the session application name for every invoked backup, restore, and backup schedule creation. 88098: sql: add missing obj_description case r=rafiss a=knz Needed for #88061. Found bug with the following query: ```sql COMMENT ON SCHEMA public IS 'hello'; SELECT obj_description(oid, 'pg_namespace') FROM pg_namespace WHERE nspname = 'public'; ``` Release note (sql change): The PostgreSQL compatibility function `obj_description` now supports retrieving comments on schemas. Co-authored-by: Rui Hu <[email protected]> Co-authored-by: Raphael 'kena' Poss <[email protected]>
- Loading branch information
Showing
16 changed files
with
217 additions
and
79 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// Copyright 2022 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 sql_test | ||
|
||
import ( | ||
"context" | ||
gosql "database/sql" | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/sql/tests" | ||
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils" | ||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
"github.com/cockroachdb/cockroach/pkg/util/log" | ||
"github.com/cockroachdb/errors" | ||
) | ||
|
||
func TestCommentOnSchema(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
defer log.Scope(t).Close(t) | ||
|
||
params, _ := tests.CreateTestServerParams() | ||
s, db, _ := serverutils.StartServer(t, params) | ||
defer s.Stopper().Stop(context.Background()) | ||
|
||
if _, err := db.Exec(` | ||
CREATE SCHEMA d; | ||
`); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
testCases := []struct { | ||
exec string | ||
query string | ||
expect gosql.NullString | ||
}{ | ||
{ | ||
`COMMENT ON SCHEMA d IS 'foo'`, | ||
`SELECT obj_description(oid, 'pg_namespace') FROM pg_namespace WHERE nspname = 'd'`, | ||
gosql.NullString{String: `foo`, Valid: true}, | ||
}, | ||
{ | ||
`ALTER SCHEMA d RENAME TO d2`, | ||
`SELECT obj_description(oid, 'pg_namespace') FROM pg_namespace WHERE nspname = 'd2'`, | ||
gosql.NullString{String: `foo`, Valid: true}, | ||
}, | ||
{ | ||
`COMMENT ON SCHEMA d2 IS NULL`, | ||
`SELECT obj_description(oid, 'pg_namespace') FROM pg_namespace WHERE nspname = 'd2'`, | ||
gosql.NullString{Valid: false}, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
if _, err := db.Exec(tc.exec); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
row := db.QueryRow(tc.query) | ||
var comment gosql.NullString | ||
if err := row.Scan(&comment); err != nil { | ||
t.Fatal(err) | ||
} | ||
if tc.expect != comment { | ||
t.Fatalf("expected comment %v, got %v", tc.expect, comment) | ||
} | ||
} | ||
} | ||
|
||
func TestCommentOnSchemaWhenDrop(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
defer log.Scope(t).Close(t) | ||
|
||
params, _ := tests.CreateTestServerParams() | ||
s, db, _ := serverutils.StartServer(t, params) | ||
defer s.Stopper().Stop(context.Background()) | ||
|
||
if _, err := db.Exec(` | ||
CREATE SCHEMA d; | ||
`); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if _, err := db.Exec(`COMMENT ON SCHEMA d IS 'foo'`); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if _, err := db.Exec(`DROP SCHEMA d`); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
row := db.QueryRow(`SELECT comment FROM system.comments LIMIT 1`) | ||
var comment string | ||
err := row.Scan(&comment) | ||
if !errors.Is(err, gosql.ErrNoRows) { | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
t.Fatal("comment remaining in system.comments despite drop") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters