Skip to content

Commit

Permalink
[#21326] YSQL: Fix PG15 PgCatalogVersionTest.DBCatalogVersionGlobalDD…
Browse files Browse the repository at this point in the history
…L failure

Summary:
The test PgCatalogVersionTest.DBCatalogVersionGlobalDDL and PgCatalogVersionTest.DBCatalogVersionDisableGlobalDDL currently fail in PG15 branch with an error like:

```
Bad status: Network error (yb/yql/pgwrapper/libpq_utils.cc:340): Execute of 'CREATE TABLE t4(id INT) TABLESPACE test_tsp' failed: 7, message: ERROR:  permission denied for schema public
LINE 1: CREATE TABLE t4(id INT) TABLESPACE test_tsp
                     ^ (pgsql error 42501) (aux msg ERROR:  permission denied for schema public
LINE 1: CREATE TABLE t4(id INT) TABLESPACE test_tsp
                     ^)

```

This is because SCHEMA public is more restrictive in PG15 compared with PG11
where the current YSQL master branch is based upon.

This diff adjust the test by granting CREATE privilege on SCHEMA public to all
users so that these two tests can pass in both master branch (PG11 based) and
the PG15 branch.
Jira: DB-10229

Test Plan:
(1) In master branch
./yb_build.sh --cxx-test pg_catalog_version-test

(2) Apply the patch to PG15 branch
./yb_build.sh --cxx-test pg_catalog_version-test

Reviewers: jason

Reviewed By: jason

Subscribers: aagrawal, yql

Differential Revision: https://phorge.dev.yugabyte.com/D32897
  • Loading branch information
myang2021 committed Mar 6, 2024
1 parent 61f1d25 commit 29b34f0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/yb/yql/pgwrapper/pg_catalog_version-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@ class PgCatalogVersionTest : public LibPqTestBase {
conn_yugabyte = ASSERT_RESULT(EnableCacheEventLog(ConnectToDB(kYugabyteDatabase)));
LOG(INFO) << "Create a new database";
ASSERT_OK(conn_yugabyte.ExecuteFormat("CREATE DATABASE $0", kTestDatabase));
{
// In PG15, SCHEMA public by default is more restrictive, grant CREATE privilege
// to all users to allow this test to run successfully in both PG11 and PG15.
auto conn_yugabyte_on_test = ASSERT_RESULT(ConnectToDB(kTestDatabase));
ASSERT_OK(conn_yugabyte_on_test.Execute("GRANT CREATE ON SCHEMA public TO public"));
}
LOG(INFO) << "Create two new test users";
ASSERT_OK(conn_yugabyte.ExecuteFormat("CREATE USER $0", kTestUser1));
ASSERT_OK(conn_yugabyte.ExecuteFormat("CREATE USER $0", kTestUser2));
Expand Down

0 comments on commit 29b34f0

Please sign in to comment.