Skip to content

Commit eceba33

Browse files
committed
Merge remote-tracking branch 'origin/master' into add-s3-support
2 parents 656d93e + a27666c commit eceba33

File tree

25 files changed

+197
-178
lines changed

25 files changed

+197
-178
lines changed

core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcAdminTestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private void execute(String sql) throws SQLException {
9090
@Override
9191
public boolean tableExists(String namespace, String table) throws Exception {
9292
String fullTableName = rdbEngine.encloseFullTableName(namespace, table);
93-
String sql = rdbEngine.tableExistsInternalTableCheckSql(fullTableName);
93+
String sql = rdbEngine.internalTableExistsCheckSql(fullTableName);
9494
try (Connection connection = dataSource.getConnection();
9595
Statement statement = connection.createStatement()) {
9696
statement.execute(sql);

core/src/integration-test/java/com/scalar/db/storage/multistorage/MultiStorageAdminTestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ private boolean tableExistsOnCassandra(String namespace, String table) {
227227

228228
private boolean tableExistsOnJdbc(String namespace, String table) throws Exception {
229229
String fullTableName = rdbEngine.encloseFullTableName(namespace, table);
230-
String sql = rdbEngine.tableExistsInternalTableCheckSql(fullTableName);
230+
String sql = rdbEngine.internalTableExistsCheckSql(fullTableName);
231231
try (Connection connection = dataSource.getConnection();
232232
Statement statement = connection.createStatement()) {
233233
statement.execute(sql);

core/src/main/java/com/scalar/db/api/AuthAdmin.java

Lines changed: 61 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -198,23 +198,23 @@ default void dropRole(String roleName) throws ExecutionException {
198198
}
199199

200200
/**
201-
* Retrieves a list of {@link RoleDetail}s.
201+
* Retrieves a list of {@link Role}s.
202202
*
203-
* @return a list of {@link RoleDetail}s
203+
* @return a list of {@link Role}s
204204
* @throws ExecutionException if the operation fails
205205
*/
206-
default List<RoleDetail> getRoles() throws ExecutionException {
206+
default List<Role> getRoles() throws ExecutionException {
207207
throw new UnsupportedOperationException(CoreError.AUTH_NOT_ENABLED.buildMessage());
208208
}
209209

210210
/**
211-
* Retrieves a list of {@link UserRoleDetail}s for the given user.
211+
* Retrieves a list of {@link RoleForUser}s for the given user.
212212
*
213213
* @param username the username
214-
* @return a list of {@link UserRoleDetail}s for the given user
214+
* @return a list of {@link RoleForUser}s for the given user
215215
* @throws ExecutionException if the operation fails
216216
*/
217-
default List<UserRoleDetail> getRolesForUser(String username) throws ExecutionException {
217+
default List<RoleForUser> getRolesForUser(String username) throws ExecutionException {
218218
throw new UnsupportedOperationException(CoreError.AUTH_NOT_ENABLED.buildMessage());
219219
}
220220

@@ -258,13 +258,13 @@ default void revokeAdminOptionFromUser(String username, String roleName)
258258
}
259259

260260
/**
261-
* Retrieves a list of {@link UserRole}s for the given role.
261+
* Retrieves a list of {@link GranteeUserRef}s for the given role.
262262
*
263263
* @param roleName the role name
264-
* @return a list of {@link UserRole}s for the given role
264+
* @return a list of {@link GranteeUserRef}s for the given role
265265
* @throws ExecutionException if the operation fails
266266
*/
267-
default List<UserRole> getUsersForRole(String roleName) throws ExecutionException {
267+
default List<GranteeUserRef> getGranteeUsersForRole(String roleName) throws ExecutionException {
268268
throw new UnsupportedOperationException(CoreError.AUTH_NOT_ENABLED.buildMessage());
269269
}
270270

@@ -399,53 +399,83 @@ default void revokePrivilegeFromRole(
399399

400400
/** Represents a user. */
401401
interface User {
402+
/**
403+
* Returns the username.
404+
*
405+
* @return the username
406+
*/
402407
String getName();
403408

409+
/**
410+
* Returns whether the user is a superuser.
411+
*
412+
* @return whether the user is a superuser
413+
*/
404414
boolean isSuperuser();
405415
}
406416

407-
/** Represents a role. */
417+
/** Represents a role, including its granted roles. */
408418
interface Role {
419+
/**
420+
* Returns the role name.
421+
*
422+
* @return the role name
423+
*/
409424
String getName();
410-
}
411-
412-
/** Represents a role with its hierarchy information. */
413-
interface RoleDetail {
414-
Role getRole();
415425

416-
List<RoleHierarchy> getRoleHierarchies();
426+
/**
427+
* Returns the roles granted to the role.
428+
*
429+
* @return the roles granted to the role
430+
*/
431+
List<GrantedRoleRef> getGrantedRoles();
417432
}
418433

419434
/**
420-
* Represents a role detail for a specific user, including whether the user has admin option for
435+
* Represents a role granted to a specific user, including whether the user has admin option for
421436
* this role.
422437
*/
423-
interface UserRoleDetail extends RoleDetail {
438+
interface RoleForUser extends Role {
424439
/**
425440
* Returns whether the user has admin option for this role. This is distinct from the admin
426441
* option in role hierarchies, which applies to role-to-role grants.
442+
*
443+
* @return whether the user has admin option for this role
427444
*/
428445
boolean hasAdminOptionOnUser();
429446
}
430447

431-
/** Represents a user-role assignment. */
432-
interface UserRole {
433-
String getUsername();
434-
435-
String getRoleName();
448+
/** A reference to a grantee user of a role. */
449+
interface GranteeUserRef {
450+
/**
451+
* Returns the username.
452+
*
453+
* @return the username
454+
*/
455+
String getName();
436456

457+
/**
458+
* Returns whether admin option is granted for this assignment.
459+
*
460+
* @return whether admin option is granted for this assignment
461+
*/
437462
boolean hasAdminOption();
438463
}
439464

440-
/** Represents a role hierarchy (role-to-role assignment). */
441-
interface RoleHierarchy {
442-
/** Returns the role name. */
443-
String getRoleName();
444-
445-
/** Returns the member role name granted to the role. */
446-
String getMemberRoleName();
465+
/** A reference to a granted role. */
466+
interface GrantedRoleRef {
467+
/**
468+
* Returns the granted role name.
469+
*
470+
* @return the granted role name
471+
*/
472+
String getName();
447473

448-
/** Returns whether admin option is granted for this hierarchy. */
474+
/**
475+
* Returns whether admin option is granted for this role grant.
476+
*
477+
* @return whether admin option is granted for this role grant
478+
*/
449479
boolean hasAdminOption();
450480
}
451481

core/src/main/java/com/scalar/db/common/CoreError.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ public enum CoreError implements ScalarDbError {
434434
CONSENSUS_COMMIT_CONDITION_NOT_ALLOWED_TO_TARGET_TRANSACTION_METADATA_COLUMNS(
435435
Category.USER_ERROR,
436436
"0100",
437-
"The condition is not allowed to target transaction metadata columns. Column: %s",
437+
"The condition is not allowed to target transaction metadata columns. Table: %s; Column: %s",
438438
"",
439439
""),
440440
CONSENSUS_COMMIT_COLUMN_RESERVED_AS_TRANSACTION_METADATA(
@@ -898,7 +898,7 @@ public enum CoreError implements ScalarDbError {
898898
OBJECT_STORAGE_PRIMARY_KEY_CONTAINS_ILLEGAL_CHARACTER(
899899
Category.USER_ERROR,
900900
"0257",
901-
"The value of the column %s in the primary key contains an illegal character.",
901+
"The value of the column %s in the primary key contains an illegal character. Value: %s",
902902
"",
903903
""),
904904
CONSENSUS_COMMIT_SPECIFYING_TRANSACTION_METADATA_COLUMNS_IN_PROJECTION_NOT_ALLOWED(
@@ -1244,7 +1244,11 @@ public enum CoreError implements ScalarDbError {
12441244
"",
12451245
""),
12461246
JDBC_MYSQL_GETTING_CONNECTION_METADATA_FAILED(
1247-
Category.INTERNAL_ERROR, "0063", "Getting the MySQL JDBC connection metadata failed", "", ""),
1247+
Category.INTERNAL_ERROR,
1248+
"0063",
1249+
"Getting the MySQL JDBC connection metadata failed. Details: %s",
1250+
"",
1251+
""),
12481252
OBJECT_STORAGE_ERROR_OCCURRED_IN_SELECTION(
12491253
Category.INTERNAL_ERROR, "0064", "An error occurred in the selection. Details: %s", "", ""),
12501254
OBJECT_STORAGE_ERROR_OCCURRED_IN_MUTATION(

core/src/main/java/com/scalar/db/common/DecoratedDistributedTransactionAdmin.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,12 @@ public void dropRole(String roleName) throws ExecutionException {
394394
}
395395

396396
@Override
397-
public List<RoleDetail> getRoles() throws ExecutionException {
397+
public List<Role> getRoles() throws ExecutionException {
398398
return distributedTransactionAdmin.getRoles();
399399
}
400400

401401
@Override
402-
public List<UserRoleDetail> getRolesForUser(String username) throws ExecutionException {
402+
public List<RoleForUser> getRolesForUser(String username) throws ExecutionException {
403403
return distributedTransactionAdmin.getRolesForUser(username);
404404
}
405405

@@ -421,8 +421,8 @@ public void revokeAdminOptionFromUser(String username, String roleName)
421421
}
422422

423423
@Override
424-
public List<UserRole> getUsersForRole(String roleName) throws ExecutionException {
425-
return distributedTransactionAdmin.getUsersForRole(roleName);
424+
public List<GranteeUserRef> getGranteeUsersForRole(String roleName) throws ExecutionException {
425+
return distributedTransactionAdmin.getGranteeUsersForRole(roleName);
426426
}
427427

428428
@Override

core/src/main/java/com/scalar/db/storage/dynamo/BatchHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ public void handle(List<? extends Mutation> mutations) throws ExecutionException
9696
// If all the reasons of the cancellation are "TransactionConflict", throw
9797
// RetriableExecutionException
9898
throw new RetriableExecutionException(
99-
CoreError.DYNAMO_TRANSACTION_CONFLICT_OCCURRED_IN_MUTATION.buildMessage(
100-
e.getMessage(), e),
99+
CoreError.DYNAMO_TRANSACTION_CONFLICT_OCCURRED_IN_MUTATION.buildMessage(e.getMessage()),
101100
e);
102101
}
103102

core/src/main/java/com/scalar/db/storage/dynamo/DeleteStatementHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ public void handle(Delete delete) throws ExecutionException {
5555
CoreError.NO_MUTATION_APPLIED.buildMessage(), Collections.singletonList(delete), e);
5656
} catch (TransactionConflictException e) {
5757
throw new RetriableExecutionException(
58-
CoreError.DYNAMO_TRANSACTION_CONFLICT_OCCURRED_IN_MUTATION.buildMessage(
59-
e.getMessage(), e),
58+
CoreError.DYNAMO_TRANSACTION_CONFLICT_OCCURRED_IN_MUTATION.buildMessage(e.getMessage()),
6059
e);
6160
} catch (DynamoDbException e) {
6261
throw new ExecutionException(

core/src/main/java/com/scalar/db/storage/dynamo/DynamoAdmin.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ private void createTableInternal(
304304
requestBuilder.tableName(getFullTableName(namespace, table));
305305

306306
try {
307-
if (!(ifNotExists && tableExistsInternal(namespace, table))) {
307+
if (!(ifNotExists && internalTableExists(namespace, table))) {
308308
client.createTable(requestBuilder.build());
309309
waitForTableCreation(namespace, table);
310310
}
@@ -543,14 +543,14 @@ private void createMetadataTableIfNotExists(boolean noBackup) throws ExecutionEx
543543
}
544544

545545
private boolean metadataTableExists() throws ExecutionException {
546-
return tableExistsInternal(Namespace.of(metadataNamespace), METADATA_TABLE);
546+
return internalTableExists(Namespace.of(metadataNamespace), METADATA_TABLE);
547547
}
548548

549549
private boolean namespacesTableExists() throws ExecutionException {
550-
return tableExistsInternal(Namespace.of(metadataNamespace), NAMESPACES_TABLE);
550+
return internalTableExists(Namespace.of(metadataNamespace), NAMESPACES_TABLE);
551551
}
552552

553-
private boolean tableExistsInternal(Namespace namespace, String table) throws ExecutionException {
553+
private boolean internalTableExists(Namespace namespace, String table) throws ExecutionException {
554554
try {
555555
client.describeTable(
556556
DescribeTableRequest.builder().tableName(getFullTableName(namespace, table)).build());

core/src/main/java/com/scalar/db/storage/dynamo/PutStatementHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ public void handle(Put put) throws ExecutionException {
5656
CoreError.NO_MUTATION_APPLIED.buildMessage(), Collections.singletonList(put), e);
5757
} catch (TransactionConflictException e) {
5858
throw new RetriableExecutionException(
59-
CoreError.DYNAMO_TRANSACTION_CONFLICT_OCCURRED_IN_MUTATION.buildMessage(
60-
e.getMessage(), e),
59+
CoreError.DYNAMO_TRANSACTION_CONFLICT_OCCURRED_IN_MUTATION.buildMessage(e.getMessage()),
6160
e);
6261
} catch (DynamoDbException e) {
6362
throw new ExecutionException(

0 commit comments

Comments
 (0)