Skip to content

Commit

Permalink
[apache#5498] improvement(storage): Modify the length limit of privil…
Browse files Browse the repository at this point in the history
…eges column (apache#5500)

### What changes were proposed in this pull request?

Modify the length limit of privileges column
According to the privilege interface, our privilege max value is 64 *
64. Every privilege name is about 14 character. So I use 64* 64 * 20 as
new length limit.

### Why are the changes needed?

Fix: apache#5498 

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?

Manual test.
  • Loading branch information
jerqi authored Nov 11, 2024
1 parent d017a12 commit c0502f1
Show file tree
Hide file tree
Showing 12 changed files with 1,145 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,8 @@ void testCreateAllPrivilegesRole() throws InterruptedException {
Privileges.ModifyTable.allow(),
Privileges.ManageUsers.allow(),
Privileges.ManageGroups.allow(),
Privileges.CreateRole.allow()));
Privileges.CreateRole.allow(),
Privileges.ManageGrants.allow()));
metalake.createRole(roleName, Collections.emptyMap(), Lists.newArrayList(securableObject));

// Granted this role to the spark execution user `HADOOP_USER_NAME`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,7 @@ private ConfigConstants() {}

/** The version number for the 0.7.0 release. */
public static final String VERSION_0_7_0 = "0.7.0";

/** The version number for the 0.8.0 release. */
public static final String VERSION_0_8_0 = "0.8.0";
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public String startH2Database(Config config) {
Statement statement = connection.createStatement()) {
String sqlContent =
FileUtils.readFileToString(
new File(gravitinoHome + "/scripts/h2/schema-0.7.0-h2.sql"), StandardCharsets.UTF_8);
new File(gravitinoHome + "/scripts/h2/schema-0.8.0-h2.sql"), StandardCharsets.UTF_8);

statement.execute(sqlContent);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void init() {

private static void prepareJdbcTable() {
// Read the ddl sql to create table
String scriptPath = "h2/schema-0.7.0-h2.sql";
String scriptPath = "h2/schema-0.8.0-h2.sql";
try (SqlSession sqlSession =
SqlSessionFactoryHelper.getInstance().getSqlSessionFactory().openSession(true);
Connection connection = sqlSession.getConnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static void setup() {
new File(
gravitinoHome
+ String.format(
"/scripts/mysql/schema-%s-mysql.sql", ConfigConstants.VERSION_0_5_0)),
"/scripts/mysql/schema-%s-mysql.sql", ConfigConstants.VERSION_0_8_0)),
"UTF-8");
String[] initMySQLBackendSqls =
Arrays.stream(mysqlContent.split(";"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public String startAndInitPGBackend() {
gravitinoHome
+ String.format(
"/scripts/postgresql/schema-%s-postgresql.sql",
ConfigConstants.VERSION_0_7_0)),
ConfigConstants.VERSION_0_8_0)),
"UTF-8");

String[] initPGBackendSqls =
Expand Down Expand Up @@ -239,7 +239,7 @@ public String startAndInitMySQLBackend() {
new File(
gravitinoHome
+ String.format(
"/scripts/mysql/schema-%s-mysql.sql", ConfigConstants.VERSION_0_7_0)),
"/scripts/mysql/schema-%s-mysql.sql", ConfigConstants.VERSION_0_8_0)),
"UTF-8");

String[] initMySQLBackendSqls =
Expand Down
291 changes: 291 additions & 0 deletions scripts/h2/schema-0.8.0-h2.sql

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions scripts/h2/upgrade-0.7.0-to-0.8.0-h2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file--
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"). You may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing,
-- software distributed under the License is distributed on an
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-- KIND, either express or implied. See the License for the
-- specific language governing permissions and limitations
-- under the License.
--
ALTER TABLE `role_meta_securable_object` ALTER COLUMN `privilege_names` TEXT(81920);
ALTER TABLE `role_meta_securable_object` ALTER COLUMN `privilege_conditions` TEXT(81920);
282 changes: 282 additions & 0 deletions scripts/mysql/schema-0.8.0-mysql.sql

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions scripts/mysql/upgrade-0.7.0-to-0.8.0-mysql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file--
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"). You may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing,
-- software distributed under the License is distributed on an
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-- KIND, either express or implied. See the License for the
-- specific language governing permissions and limitations
-- under the License.
--
ALTER TABLE `role_meta_securable_object` MODIFY COLUMN `privilege_names` TEXT(81920);
ALTER TABLE `role_meta_securable_object` MODIFY COLUMN `privilege_conditions` TEXT(81920);
Loading

0 comments on commit c0502f1

Please sign in to comment.