@Override public ResultMessage execute(QueryState state, QueryOptions options) throws RequestValidationException { announceMigration(false); return indexedCF == null ? null : new ResultMessage.SchemaChange(changeEvent()); }
public Event.SchemaChange announceMigration(QueryState queryState, boolean isLocalOnly) throws InvalidRequestException, ConfigurationException { CFMetaData cfm = lookupIndexedTable(Schema.instance.getKSMetaData(keyspace())); if (cfm == null) return null; CFMetaData updatedCfm = dropIndex(cfm); MigrationManager.announceColumnFamilyUpdate(updatedCfm, isLocalOnly); // Dropping an index is akin to updating the CF // Note that we shouldn't call columnFamily() at this point because the index has been dropped and the call to lookupIndexedTable() // in that method would now throw. return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, Event.SchemaChange.Target.TABLE, updatedCfm.ksName, cfm.cfName); }
public Event.SchemaChange changeEvent() { // Dropping an index is akin to updating the CF return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, Event.SchemaChange.Target.TABLE, keyspace(), columnFamily()); }
public String columnFamily() { CFMetaData cfm = lookupIndexedTable(Schema.instance.getKSMetaData(keyspace())); return cfm == null ? null : cfm.cfName; }
state._fsp--; expr = new DropIndexStatement(index, ifExists);
public String columnFamily() { CFMetaData cfm = lookupIndexedTable(); return cfm == null ? null : cfm.cfName; }
@Override public ResultMessage execute(QueryState state, QueryOptions options, long queryStartNanoTime) throws RequestValidationException { Event.SchemaChange ce = announceMigration(state, false); return ce == null ? null : new ResultMessage.SchemaChange(ce); }
/** * The table for which the index should be dropped, or null if the index doesn't exist * * @return the metadata for the table containing the dropped index, or {@code null} * if the index to drop cannot be found but "IF EXISTS" is set on the statement. * * @throws InvalidRequestException if the index cannot be found and "IF EXISTS" is not * set on the statement. */ private CFMetaData lookupIndexedTable() { KeyspaceMetadata ksm = Schema.instance.getKSMetaData(keyspace()); if (ksm == null) throw new KeyspaceNotDefinedException("Keyspace " + keyspace() + " does not exist"); return ksm.findIndexedTable(indexName) .orElseGet(() -> { if (ifExists) return null; else throw new InvalidRequestException(String.format("Index '%s' could not be found in any " + "of the tables of keyspace '%s'", indexName, keyspace())); }); } }
private CFMetaData findIndexedCF() throws InvalidRequestException { KSMetaData ksm = Schema.instance.getKSMetaData(keyspace()); if (ksm == null) throw new KeyspaceNotDefinedException("Keyspace " + keyspace() + " does not exist"); for (CFMetaData cfm : ksm.cfMetaData().values()) { if (findIndexedColumn(cfm) != null) return cfm; } if (ifExists) return null; else throw new InvalidRequestException("Index '" + indexName + "' could not be found in any of the tables of keyspace '" + keyspace() + '\''); }
public void checkAccess(ClientState state) throws UnauthorizedException, InvalidRequestException { CFMetaData cfm = lookupIndexedTable(Schema.instance.getKSMetaData(keyspace())); if (cfm == null) return; state.hasColumnFamilyAccess(cfm.ksName, cfm.cfName, Permission.ALTER); }
state._fsp--; expr = new DropIndexStatement(index, ifExists);
public String columnFamily() { CFMetaData cfm = lookupIndexedTable(); return cfm == null ? null : cfm.cfName; }
@Override public ResultMessage execute(QueryState state, QueryOptions options, long queryStartNanoTime) throws RequestValidationException { Event.SchemaChange ce = announceMigration(state, false); return ce == null ? null : new ResultMessage.SchemaChange(ce); }
/** * The table for which the index should be dropped, or null if the index doesn't exist * * @return the metadata for the table containing the dropped index, or {@code null} * if the index to drop cannot be found but "IF EXISTS" is set on the statement. * * @throws InvalidRequestException if the index cannot be found and "IF EXISTS" is not * set on the statement. */ private CFMetaData lookupIndexedTable(KeyspaceMetadata ksm) { if (ksm == null) throw new KeyspaceNotDefinedException("Keyspace " + keyspace() + " does not exist"); return ksm.findIndexedTable(indexName) .orElseGet(() -> { if (ifExists) return null; else throw new InvalidRequestException(String.format("Index '%s' could not be found in any " + "of the tables of keyspace '%s'", indexName, keyspace())); }); } }
state._fsp--; expr = new DropIndexStatement(index, ifExists);
public void checkAccess(ClientState state) throws UnauthorizedException, InvalidRequestException { CFMetaData cfm = lookupIndexedTable(); if (cfm == null) return; state.hasColumnFamilyAccess(cfm.ksName, cfm.cfName, Permission.ALTER); }
@Override public ResultMessage execute(QueryState state, QueryOptions options, long queryStartNanoTime) throws RequestValidationException { Event.SchemaChange ce = announceMigration(state, false); return ce == null ? null : new ResultMessage.SchemaChange(ce); }
/** * The table for which the index should be dropped, or null if the index doesn't exist * * @return the metadata for the table containing the dropped index, or {@code null} * if the index to drop cannot be found but "IF EXISTS" is set on the statement. * * @throws InvalidRequestException if the index cannot be found and "IF EXISTS" is not * set on the statement. */ private CFMetaData lookupIndexedTable() { KeyspaceMetadata ksm = Schema.instance.getKSMetaData(keyspace()); if (ksm == null) throw new KeyspaceNotDefinedException("Keyspace " + keyspace() + " does not exist"); return ksm.findIndexedTable(indexName) .orElseGet(() -> { if (ifExists) return null; else throw new InvalidRequestException(String.format("Index '%s' could not be found in any " + "of the tables of keyspace '%s'", indexName, keyspace())); }); } }
state._fsp--; expr = new DropIndexStatement(index, ifExists);
public void checkAccess(ClientState state) throws UnauthorizedException, InvalidRequestException { CFMetaData cfm = lookupIndexedTable(); if (cfm == null) return; state.hasColumnFamilyAccess(cfm.ksName, cfm.cfName, Permission.ALTER); }