Fix heuristic index access control issues
This commit is contained in:
parent
befa40040a
commit
56cca3c088
|
|
@ -281,12 +281,12 @@ public class LegacyAccessControl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkCanCreateIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName indexName)
|
||||
public void checkCanCreateIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName tableName)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkCanDropIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName indexName)
|
||||
public void checkCanDropIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName tableName)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -509,12 +509,12 @@ public class SqlStandardAccessControl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkCanCreateIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName indexName)
|
||||
public void checkCanCreateIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName tableName)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkCanDropIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName indexName)
|
||||
public void checkCanDropIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName tableName)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class IndexCache
|
|||
if (PropertyService.getBooleanProperty(HetuConstant.FILTER_ENABLED)) {
|
||||
loadDelay = PropertyService.getDurationProperty(HetuConstant.FILTER_CACHE_LOADING_DELAY).toMillis();
|
||||
// in millisecond
|
||||
Long refreshRate = Math.min(loadDelay / 2, 5000L);
|
||||
long refreshRate = Math.max(loadDelay / 2, 5000L);
|
||||
int numThreads = Math.min(Runtime.getRuntime().availableProcessors(), PropertyService.getLongProperty(HetuConstant.FILTER_CACHE_LOADING_THREADS).intValue());
|
||||
executor = Executors.newScheduledThreadPool(numThreads, threadFactory);
|
||||
CacheBuilder<IndexCacheKey, List<IndexMetadata>> cacheBuilder = CacheBuilder.newBuilder()
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import io.prestosql.metadata.Metadata;
|
|||
import io.prestosql.metadata.QualifiedObjectName;
|
||||
import io.prestosql.security.AccessControl;
|
||||
import io.prestosql.spi.heuristicindex.IndexClient;
|
||||
import io.prestosql.spi.heuristicindex.IndexRecord;
|
||||
import io.prestosql.sql.analyzer.SemanticException;
|
||||
import io.prestosql.sql.tree.DropIndex;
|
||||
import io.prestosql.sql.tree.Expression;
|
||||
|
|
@ -34,7 +35,6 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import static com.google.common.util.concurrent.Futures.immediateFuture;
|
||||
import static io.prestosql.metadata.MetadataUtil.createQualifiedObjectName;
|
||||
import static io.prestosql.sql.analyzer.SemanticErrorCode.MISSING_INDEX;
|
||||
|
||||
public class DropIndexTask
|
||||
|
|
@ -52,16 +52,17 @@ public class DropIndexTask
|
|||
IndexClient indexClient = heuristicIndexerManager.getIndexClient();
|
||||
String indexName = statement.getIndexName().toString();
|
||||
|
||||
Session session = stateMachine.getSession();
|
||||
QualifiedObjectName fullObjectName = createQualifiedObjectName(session, statement, statement.getIndexName());
|
||||
|
||||
accessControl.checkCanDropIndex(session.getRequiredTransactionId(), session.getIdentity(), fullObjectName);
|
||||
|
||||
try {
|
||||
IndexRecord record = indexClient.getIndexRecord(indexName);
|
||||
// check indexName exist, call heuristic index api to drop index
|
||||
if (indexClient.getIndexRecord(indexName) == null) {
|
||||
if (record == null) {
|
||||
throw new SemanticException(MISSING_INDEX, statement, "Index '%s' does not exists", indexName);
|
||||
}
|
||||
|
||||
QualifiedObjectName fullObjectName = QualifiedObjectName.valueOf(record.table);
|
||||
Session session = stateMachine.getSession();
|
||||
accessControl.checkCanDropIndex(session.getRequiredTransactionId(), session.getIdentity(), fullObjectName);
|
||||
|
||||
List<String> partitions = Collections.emptyList();
|
||||
if (statement.getPartitions().isPresent()) {
|
||||
partitions = HeuristicIndexUtils.extractPartitions(statement.getPartitions().get());
|
||||
|
|
|
|||
|
|
@ -15,10 +15,8 @@
|
|||
package io.prestosql.execution;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import io.prestosql.Session;
|
||||
import io.prestosql.heuristicindex.HeuristicIndexerManager;
|
||||
import io.prestosql.metadata.Metadata;
|
||||
import io.prestosql.metadata.QualifiedObjectName;
|
||||
import io.prestosql.security.AccessControl;
|
||||
import io.prestosql.sql.tree.Expression;
|
||||
import io.prestosql.sql.tree.RenameIndex;
|
||||
|
|
@ -27,7 +25,6 @@ import io.prestosql.transaction.TransactionManager;
|
|||
import java.util.List;
|
||||
|
||||
import static com.google.common.util.concurrent.Futures.immediateFuture;
|
||||
import static io.prestosql.metadata.MetadataUtil.createQualifiedObjectName;
|
||||
|
||||
public class RenameIndexTask
|
||||
implements DataDefinitionTask<RenameIndex>
|
||||
|
|
@ -41,12 +38,6 @@ public class RenameIndexTask
|
|||
@Override
|
||||
public ListenableFuture<?> execute(RenameIndex statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine, List<Expression> parameters, HeuristicIndexerManager heuristicIndexerManager)
|
||||
{
|
||||
Session session = stateMachine.getSession();
|
||||
QualifiedObjectName oldIndexName = createQualifiedObjectName(session, statement, statement.getSource());
|
||||
QualifiedObjectName newIndexName = createQualifiedObjectName(session, statement, statement.getTarget());
|
||||
|
||||
accessControl.checkCanRenameIndex(session.getRequiredTransactionId(), session.getIdentity(), oldIndexName, newIndexName);
|
||||
|
||||
return immediateFuture(null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class IndexCache
|
|||
if (PropertyService.getBooleanProperty(HetuConstant.FILTER_ENABLED)) {
|
||||
loadDelay = PropertyService.getDurationProperty(HetuConstant.FILTER_CACHE_LOADING_DELAY).toMillis();
|
||||
// in millisecond
|
||||
long refreshRate = Math.min(loadDelay / 2, 5000L);
|
||||
long refreshRate = Math.max(loadDelay / 2, 5000L);
|
||||
int numThreads = Math.min(Runtime.getRuntime().availableProcessors(), PropertyService.getLongProperty(HetuConstant.FILTER_CACHE_LOADING_THREADS).intValue());
|
||||
executor = Executors.newScheduledThreadPool(numThreads, threadFactory);
|
||||
CacheBuilder<IndexCacheKey, List<IndexMetadata>> cacheBuilder = CacheBuilder.newBuilder()
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
package io.prestosql.operator;
|
||||
|
||||
import io.airlift.log.Logger;
|
||||
import io.airlift.slice.Slice;
|
||||
import io.prestosql.heuristicindex.HeuristicIndexerManager;
|
||||
import io.prestosql.spi.HetuConstant;
|
||||
|
|
@ -52,6 +53,7 @@ public class CreateIndexOperator
|
|||
private final CreateIndexMetadata createIndexMetadata;
|
||||
private final HeuristicIndexerManager heuristicIndexerManager;
|
||||
private final AtomicBoolean recordCreated;
|
||||
private static final Logger LOG = Logger.get(CreateIndexOperator.class);
|
||||
|
||||
public CreateIndexOperator(
|
||||
OperatorContext operatorContext,
|
||||
|
|
@ -199,8 +201,7 @@ public class CreateIndexOperator
|
|||
break;
|
||||
}
|
||||
default:
|
||||
new IOException("Create level not supported");
|
||||
break;
|
||||
throw new IllegalArgumentException("Create level not supported");
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
|
|
|||
|
|
@ -214,14 +214,14 @@ public interface AccessControl
|
|||
*
|
||||
* @throws io.prestosql.spi.security.AccessDeniedException if not allowed
|
||||
*/
|
||||
void checkCanCreateIndex(TransactionId transactionId, Identity identity, QualifiedObjectName indexName);
|
||||
void checkCanCreateIndex(TransactionId transactionId, Identity identity, QualifiedObjectName tableName);
|
||||
|
||||
/**
|
||||
* Check if identity is allowed to drop the specified index.
|
||||
*
|
||||
* @throws io.prestosql.spi.security.AccessDeniedException if not allowed
|
||||
*/
|
||||
void checkCanDropIndex(TransactionId transactionId, Identity identity, QualifiedObjectName indexName);
|
||||
void checkCanDropIndex(TransactionId transactionId, Identity identity, QualifiedObjectName tableName);
|
||||
|
||||
/**
|
||||
* Check if identity is allowed to rename the specified index.
|
||||
|
|
@ -233,12 +233,12 @@ public interface AccessControl
|
|||
/**
|
||||
* Check if identity is allowed to update the specified index.
|
||||
*/
|
||||
default void checkCanUpdateIndex(TransactionId transactionId, Identity identity, QualifiedObjectName indexName) {}
|
||||
default void checkCanUpdateIndex(TransactionId transactionId, Identity identity, QualifiedObjectName tableName) {}
|
||||
|
||||
/**
|
||||
* Check if identity is allowed to show the specified index.
|
||||
*/
|
||||
void checkCanShowIndex(TransactionId transactionId, Identity identity, QualifiedObjectName indexName);
|
||||
void checkCanShowIndex(TransactionId transactionId, Identity identity, QualifiedObjectName tableName);
|
||||
|
||||
/**
|
||||
* Check if identity is allowed to create the specified view.
|
||||
|
|
|
|||
|
|
@ -520,34 +520,34 @@ public class AccessControlManager
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkCanCreateIndex(TransactionId transactionId, Identity identity, QualifiedObjectName indexName)
|
||||
public void checkCanCreateIndex(TransactionId transactionId, Identity identity, QualifiedObjectName tableName)
|
||||
{
|
||||
requireNonNull(identity, "identity is null");
|
||||
requireNonNull(indexName, "indexName is null");
|
||||
requireNonNull(tableName, "tableName is null");
|
||||
|
||||
authenticationCheck(() -> checkCanAccessCatalog(identity, indexName.getCatalogName()));
|
||||
authenticationCheck(() -> checkCanAccessCatalog(identity, tableName.getCatalogName()));
|
||||
|
||||
authorizationCheck(() -> systemAccessControl.get().checkCanCreateIndex(identity, indexName.asCatalogSchemaTableName()));
|
||||
authorizationCheck(() -> systemAccessControl.get().checkCanCreateIndex(identity, tableName.asCatalogSchemaTableName()));
|
||||
|
||||
CatalogAccessControlEntry entry = getConnectorAccessControl(transactionId, indexName.getCatalogName());
|
||||
CatalogAccessControlEntry entry = getConnectorAccessControl(transactionId, tableName.getCatalogName());
|
||||
if (entry != null) {
|
||||
authorizationCheck(() -> entry.getAccessControl().checkCanCreateIndex(entry.getTransactionHandle(transactionId), identity.toConnectorIdentity(indexName.getCatalogName()), indexName.asSchemaTableName()));
|
||||
authorizationCheck(() -> entry.getAccessControl().checkCanCreateIndex(entry.getTransactionHandle(transactionId), identity.toConnectorIdentity(tableName.getCatalogName()), tableName.asSchemaTableName()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkCanDropIndex(TransactionId transactionId, Identity identity, QualifiedObjectName indexName)
|
||||
public void checkCanDropIndex(TransactionId transactionId, Identity identity, QualifiedObjectName tableName)
|
||||
{
|
||||
requireNonNull(identity, "identity is null");
|
||||
requireNonNull(indexName, "indexName is null");
|
||||
requireNonNull(tableName, "tableName is null");
|
||||
|
||||
authenticationCheck(() -> checkCanAccessCatalog(identity, indexName.getCatalogName()));
|
||||
authenticationCheck(() -> checkCanAccessCatalog(identity, tableName.getCatalogName()));
|
||||
|
||||
authorizationCheck(() -> systemAccessControl.get().checkCanDropIndex(identity, indexName.asCatalogSchemaTableName()));
|
||||
authorizationCheck(() -> systemAccessControl.get().checkCanDropIndex(identity, tableName.asCatalogSchemaTableName()));
|
||||
|
||||
CatalogAccessControlEntry entry = getConnectorAccessControl(transactionId, indexName.getCatalogName());
|
||||
CatalogAccessControlEntry entry = getConnectorAccessControl(transactionId, tableName.getCatalogName());
|
||||
if (entry != null) {
|
||||
authorizationCheck(() -> entry.getAccessControl().checkCanDropIndex(entry.getTransactionHandle(transactionId), identity.toConnectorIdentity(indexName.getCatalogName()), indexName.asSchemaTableName()));
|
||||
authorizationCheck(() -> entry.getAccessControl().checkCanDropIndex(entry.getTransactionHandle(transactionId), identity.toConnectorIdentity(tableName.getCatalogName()), tableName.asSchemaTableName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -569,36 +569,36 @@ public class AccessControlManager
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkCanUpdateIndex(TransactionId transactionId, Identity identity, QualifiedObjectName indexName)
|
||||
public void checkCanUpdateIndex(TransactionId transactionId, Identity identity, QualifiedObjectName tableName)
|
||||
{
|
||||
requireNonNull(identity, "identity is null");
|
||||
requireNonNull(indexName, "indexName is null");
|
||||
requireNonNull(tableName, "tableName is null");
|
||||
|
||||
authenticationCheck(() -> checkCanAccessCatalog(identity, indexName.getCatalogName()));
|
||||
authenticationCheck(() -> checkCanAccessCatalog(identity, tableName.getCatalogName()));
|
||||
|
||||
authorizationCheck(() -> systemAccessControl.get().checkCanUpdateIndex(identity, indexName.asCatalogSchemaTableName()));
|
||||
CatalogAccessControlEntry entry = getConnectorAccessControl(transactionId, indexName.getCatalogName());
|
||||
authorizationCheck(() -> systemAccessControl.get().checkCanUpdateIndex(identity, tableName.asCatalogSchemaTableName()));
|
||||
CatalogAccessControlEntry entry = getConnectorAccessControl(transactionId, tableName.getCatalogName());
|
||||
if (entry != null) {
|
||||
authorizationCheck(() -> entry.getAccessControl().checkCanUpdateIndex(entry.getTransactionHandle(transactionId), identity.toConnectorIdentity(indexName.getCatalogName()), indexName.asSchemaTableName()));
|
||||
authorizationCheck(() -> entry.getAccessControl().checkCanUpdateIndex(entry.getTransactionHandle(transactionId), identity.toConnectorIdentity(tableName.getCatalogName()), tableName.asSchemaTableName()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkCanShowIndex(TransactionId transactionId, Identity identity, QualifiedObjectName indexName)
|
||||
public void checkCanShowIndex(TransactionId transactionId, Identity identity, QualifiedObjectName tableName)
|
||||
{
|
||||
requireNonNull(identity, "identity is null");
|
||||
|
||||
if (indexName == null) {
|
||||
if (tableName == null) {
|
||||
authenticationCheck(() -> systemAccessControl.get().checkCanShowIndex(identity, null));
|
||||
return;
|
||||
}
|
||||
|
||||
authenticationCheck(() -> checkCanAccessCatalog(identity, indexName.getCatalogName()));
|
||||
authenticationCheck(() -> checkCanAccessCatalog(identity, tableName.getCatalogName()));
|
||||
|
||||
authenticationCheck(() -> systemAccessControl.get().checkCanShowIndex(identity, indexName.asCatalogSchemaTableName()));
|
||||
CatalogAccessControlEntry entry = getConnectorAccessControl(transactionId, indexName.getCatalogName());
|
||||
authenticationCheck(() -> systemAccessControl.get().checkCanShowIndex(identity, tableName.asCatalogSchemaTableName()));
|
||||
CatalogAccessControlEntry entry = getConnectorAccessControl(transactionId, tableName.getCatalogName());
|
||||
if (entry != null) {
|
||||
authenticationCheck(() -> entry.getAccessControl().checkCanShowIndex(entry.getTransactionHandle(transactionId), identity.toConnectorIdentity(indexName.getCatalogName()), indexName.asSchemaTableName()));
|
||||
authenticationCheck(() -> entry.getAccessControl().checkCanShowIndex(entry.getTransactionHandle(transactionId), identity.toConnectorIdentity(tableName.getCatalogName()), tableName.asSchemaTableName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,12 +146,12 @@ public class AllowAllAccessControl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkCanCreateIndex(TransactionId transactionId, Identity identity, QualifiedObjectName indexName)
|
||||
public void checkCanCreateIndex(TransactionId transactionId, Identity identity, QualifiedObjectName tableName)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkCanDropIndex(TransactionId transactionId, Identity identity, QualifiedObjectName indexName)
|
||||
public void checkCanDropIndex(TransactionId transactionId, Identity identity, QualifiedObjectName tableName)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -161,7 +161,7 @@ public class AllowAllAccessControl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkCanShowIndex(TransactionId transactionId, Identity identity, QualifiedObjectName indexName)
|
||||
public void checkCanShowIndex(TransactionId transactionId, Identity identity, QualifiedObjectName tableName)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -205,15 +205,15 @@ public class DenyAllAccessControl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkCanCreateIndex(TransactionId transactionId, Identity identity, QualifiedObjectName indexName)
|
||||
public void checkCanCreateIndex(TransactionId transactionId, Identity identity, QualifiedObjectName tableName)
|
||||
{
|
||||
denyCreateIndex(indexName.toString());
|
||||
denyCreateIndex(tableName.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkCanDropIndex(TransactionId transactionId, Identity identity, QualifiedObjectName indexName)
|
||||
public void checkCanDropIndex(TransactionId transactionId, Identity identity, QualifiedObjectName tableName)
|
||||
{
|
||||
denyDropIndex(indexName.toString());
|
||||
denyDropIndex(tableName.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -223,9 +223,9 @@ public class DenyAllAccessControl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkCanShowIndex(TransactionId transactionId, Identity identity, QualifiedObjectName indexName)
|
||||
public void checkCanShowIndex(TransactionId transactionId, Identity identity, QualifiedObjectName tableName)
|
||||
{
|
||||
denyShowIndex(indexName.toString());
|
||||
denyShowIndex(tableName.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ import io.prestosql.sql.tree.Table;
|
|||
import io.prestosql.sql.tree.TableSubquery;
|
||||
import io.prestosql.sql.tree.Unnest;
|
||||
import io.prestosql.sql.tree.Update;
|
||||
import io.prestosql.sql.tree.UpdateIndex;
|
||||
import io.prestosql.sql.tree.Use;
|
||||
import io.prestosql.sql.tree.VacuumTable;
|
||||
import io.prestosql.sql.tree.Values;
|
||||
|
|
@ -806,6 +807,12 @@ class StatementAnalyzer
|
|||
return createAndAssignScope(node, scope);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Scope visitUpdateIndex(UpdateIndex node, Optional<Scope> scope)
|
||||
{
|
||||
return createAndAssignScope(node, scope);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Scope visitComment(Comment node, Optional<Scope> scope)
|
||||
{
|
||||
|
|
@ -1034,11 +1041,8 @@ class StatementAnalyzer
|
|||
{
|
||||
if (analysis.getOriginalStatement() instanceof CreateIndex) {
|
||||
CreateIndex createIndex = (CreateIndex) analysis.getOriginalStatement();
|
||||
// check can create index
|
||||
QualifiedObjectName indexFullName = MetadataUtil.createQualifiedObjectName(session, createIndex, createIndex.getIndexName());
|
||||
accessControl.checkCanCreateIndex(session.getRequiredTransactionId(), session.getIdentity(), indexFullName);
|
||||
// check index parameters validate
|
||||
QualifiedObjectName tableFullName = MetadataUtil.createQualifiedObjectName(session, createIndex, createIndex.getTableName());
|
||||
accessControl.checkCanCreateIndex(session.getRequiredTransactionId(), session.getIdentity(), tableFullName);
|
||||
String tableName = tableFullName.toString();
|
||||
// check whether catalog support create index
|
||||
if (!metadata.isHeuristicIndexSupported(session, tableFullName)) {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import io.prestosql.execution.TableCacheInfo;
|
|||
import io.prestosql.execution.warnings.WarningCollector;
|
||||
import io.prestosql.heuristicindex.HeuristicIndexerManager;
|
||||
import io.prestosql.metadata.Metadata;
|
||||
import io.prestosql.metadata.MetadataUtil;
|
||||
import io.prestosql.metadata.QualifiedObjectName;
|
||||
import io.prestosql.metadata.SessionPropertyManager.SessionPropertyValue;
|
||||
import io.prestosql.metadata.TableHandle;
|
||||
|
|
@ -87,6 +86,7 @@ import io.prestosql.sql.tree.TableElement;
|
|||
import io.prestosql.sql.tree.Values;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -642,20 +642,23 @@ final class ShowQueriesRewrite
|
|||
@Override
|
||||
protected Node visitShowIndex(ShowIndex node, Void context)
|
||||
{
|
||||
if (node.getIndexName() == null) {
|
||||
accessControl.checkCanShowIndex(session.getRequiredTransactionId(), session.getIdentity(), null);
|
||||
}
|
||||
else {
|
||||
QualifiedObjectName indexFullName = MetadataUtil.createQualifiedObjectName(session, node, QualifiedName.of(node.getIndexName()));
|
||||
accessControl.checkCanShowIndex(session.getRequiredTransactionId(), session.getIdentity(), indexFullName);
|
||||
}
|
||||
|
||||
List<IndexRecord> indexRecords = null;
|
||||
List<IndexRecord> indexRecords;
|
||||
try {
|
||||
indexRecords = readIndexRecords(node.getIndexName());
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new UncheckedIOException("Error reading index records, ", e);
|
||||
}
|
||||
|
||||
// Access Control
|
||||
if (node.getIndexName() == null) {
|
||||
accessControl.checkCanShowIndex(session.getRequiredTransactionId(), session.getIdentity(), null);
|
||||
}
|
||||
else {
|
||||
for (IndexRecord record : indexRecords) {
|
||||
QualifiedObjectName indexFullName = QualifiedObjectName.valueOf(record.table);
|
||||
accessControl.checkCanShowIndex(session.getRequiredTransactionId(), session.getIdentity(), indexFullName);
|
||||
}
|
||||
}
|
||||
|
||||
ImmutableList.Builder<Expression> rows = ImmutableList.builder();
|
||||
|
|
|
|||
|
|
@ -183,12 +183,12 @@ public class TestingRangerAccessControl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkCanCreateIndex(TransactionId transactionId, Identity identity, QualifiedObjectName indexName)
|
||||
public void checkCanCreateIndex(TransactionId transactionId, Identity identity, QualifiedObjectName tableName)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkCanDropIndex(TransactionId transactionId, Identity identity, QualifiedObjectName indexName)
|
||||
public void checkCanDropIndex(TransactionId transactionId, Identity identity, QualifiedObjectName tableName)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -198,7 +198,7 @@ public class TestingRangerAccessControl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkCanShowIndex(TransactionId transactionId, Identity identity, QualifiedObjectName indexName)
|
||||
public void checkCanShowIndex(TransactionId transactionId, Identity identity, QualifiedObjectName tableName)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ import io.prestosql.sql.tree.TransactionMode;
|
|||
import io.prestosql.sql.tree.Union;
|
||||
import io.prestosql.sql.tree.Unnest;
|
||||
import io.prestosql.sql.tree.Update;
|
||||
import io.prestosql.sql.tree.UpdateIndex;
|
||||
import io.prestosql.sql.tree.Use;
|
||||
import io.prestosql.sql.tree.Values;
|
||||
import io.prestosql.sql.tree.With;
|
||||
|
|
@ -873,6 +874,13 @@ public final class SqlFormatter
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void visitUpdateIndex(UpdateIndex node, Integer context)
|
||||
{
|
||||
append(context, "UPDATE INDEX ");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void visitShowIndex(ShowIndex node, Integer context)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -203,12 +203,12 @@ public class AllowAllAccessControl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkCanCreateIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName indexName)
|
||||
public void checkCanCreateIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName tableName)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkCanDropIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName indexName)
|
||||
public void checkCanDropIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName tableName)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -310,12 +310,12 @@ public class FileBasedAccessControl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkCanCreateIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName indexName)
|
||||
public void checkCanCreateIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName tableName)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkCanDropIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName indexName)
|
||||
public void checkCanDropIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName tableName)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -252,15 +252,15 @@ public abstract class ForwardingConnectorAccessControl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkCanCreateIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName indexName)
|
||||
public void checkCanCreateIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName tableName)
|
||||
{
|
||||
delegate().checkCanCreateIndex(transactionHandle, identity, indexName);
|
||||
delegate().checkCanCreateIndex(transactionHandle, identity, tableName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkCanDropIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName indexName)
|
||||
public void checkCanDropIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName tableName)
|
||||
{
|
||||
delegate().checkCanDropIndex(transactionHandle, identity, indexName);
|
||||
delegate().checkCanDropIndex(transactionHandle, identity, tableName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -274,9 +274,9 @@ public interface ConnectorAccessControl
|
|||
*
|
||||
* @throws io.prestosql.spi.security.AccessDeniedException if not allowed
|
||||
*/
|
||||
default void checkCanCreateIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName indexName)
|
||||
default void checkCanCreateIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName tableName)
|
||||
{
|
||||
denyCreateIndex(indexName.toString());
|
||||
denyCreateIndex(tableName.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -284,9 +284,9 @@ public interface ConnectorAccessControl
|
|||
*
|
||||
* @throws io.prestosql.spi.security.AccessDeniedException if not allowed
|
||||
*/
|
||||
default void checkCanDropIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName indexName)
|
||||
default void checkCanDropIndex(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName tableName)
|
||||
{
|
||||
denyDropIndex(indexName.toString());
|
||||
denyDropIndex(tableName.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -226,9 +226,9 @@ public class AccessDeniedException
|
|||
throw new AccessDeniedException("Cannot create index");
|
||||
}
|
||||
|
||||
public static void denyCreateIndex(String indexName)
|
||||
public static void denyCreateIndex(String tableName)
|
||||
{
|
||||
denyCreateIndex(indexName, null);
|
||||
denyCreateIndex(tableName, null);
|
||||
}
|
||||
|
||||
public static void denyCreateIndex(String indexName, String extraInfo)
|
||||
|
|
|
|||
Loading…
Reference in New Issue