Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -276,24 +276,22 @@ private InternalScanner getRepairScanner(RegionCoprocessorEnvironment env, Store
scan.addFamily(s.getColumnFamilyDescriptor().getName());
}
}
try {
PhoenixConnection conn = QueryUtil.getConnectionOnServer(env.getConfiguration())
.unwrap(PhoenixConnection.class);
try (PhoenixConnection conn = QueryUtil.getConnectionOnServer(
env.getConfiguration()).unwrap(PhoenixConnection.class)) {
PTable dataPTable = IndexUtil.getPDataTable(conn, env.getRegion().getTableDescriptor());
final List<IndexMaintainer> maintainers = Lists
.newArrayListWithExpectedSize(dataPTable.getIndexes().size());
.newArrayListWithExpectedSize(dataPTable.getIndexes().size());
for (PTable index : dataPTable.getIndexes()) {
if (index.getIndexType() == IndexType.LOCAL) {
maintainers.add(index.getIndexMaintainer(dataPTable, conn));
}
}
return new DataTableLocalIndexRegionScanner(env.getRegion().getScanner(scan), env.getRegion(),
maintainers, store.getColumnFamilyDescriptor().getName(),env.getConfiguration());


return new DataTableLocalIndexRegionScanner(
env.getRegion().getScanner(scan), env.getRegion(), maintainers,
store.getColumnFamilyDescriptor().getName(),
env.getConfiguration());
} catch (SQLException e) {
throw new IOException(e);

}
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,23 +132,27 @@ public MetaDataMutationResult validateWithChildViews(PTable table, List<PTable>
if (existingViewColumn != null && view.getViewStatement() != null) {
ParseNode viewWhere =
new SQLParser(view.getViewStatement()).parseQuery().getWhere();
PhoenixConnection conn = QueryUtil.getConnectionOnServer(conf).unwrap(
PhoenixConnection.class);
PhoenixStatement statement = new PhoenixStatement(conn);
TableRef baseTableRef = new TableRef(view);
ColumnResolver columnResolver = FromCompiler.getResolver(baseTableRef);
StatementContext context = new StatementContext(statement, columnResolver);
Expression whereExpression = WhereCompiler.compile(context, viewWhere);
Expression colExpression =
new ColumnRef(baseTableRef, existingViewColumn.getPosition())
.newColumnExpression();
MetaDataEndpointImpl.ColumnFinder columnFinder =
new MetaDataEndpointImpl.ColumnFinder(colExpression);
whereExpression.accept(columnFinder);
if (columnFinder.getColumnFound()) {
return new MetaDataProtocol.MetaDataMutationResult(
try (PhoenixConnection conn =
QueryUtil.getConnectionOnServer(conf)
.unwrap(PhoenixConnection.class)) {
PhoenixStatement statement = new PhoenixStatement(conn);
TableRef baseTableRef = new TableRef(view);
ColumnResolver columnResolver =
FromCompiler.getResolver(baseTableRef);
StatementContext context =
new StatementContext(statement, columnResolver);
Expression whereExpression =
WhereCompiler.compile(context, viewWhere);
Expression colExpression = new ColumnRef(baseTableRef,
existingViewColumn.getPosition()).newColumnExpression();
MetaDataEndpointImpl.ColumnFinder columnFinder =
new MetaDataEndpointImpl.ColumnFinder(colExpression);
whereExpression.accept(columnFinder);
if (columnFinder.getColumnFound()) {
return new MetaDataProtocol.MetaDataMutationResult(
MetaDataProtocol.MutationCode.UNALLOWED_TABLE_MUTATION,
EnvironmentEdgeManager.currentTimeMillis(), table);
}
}
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -2290,16 +2290,16 @@ public void dropTable(RpcController controller, DropTableRequest request,
&& (clientVersion >= MIN_SPLITTABLE_SYSTEM_CATALOG ||
SchemaUtil.getPhysicalTableName(SYSTEM_CHILD_LINK_NAME_BYTES,
env.getConfiguration()).equals(hTable.getName()))) {
try {
PhoenixConnection conn =
QueryUtil.getConnectionOnServer(env.getConfiguration())
.unwrap(PhoenixConnection.class);
try (PhoenixConnection conn =
QueryUtil.getConnectionOnServer(env.getConfiguration())
.unwrap(PhoenixConnection.class)) {
Task.addTask(conn, PTable.TaskType.DROP_CHILD_VIEWS,
Bytes.toString(tenantIdBytes), Bytes.toString(schemaName),
Bytes.toString(tableOrViewName),
PTable.TaskStatus.CREATED.toString(),
null, null, null, null,
this.accessCheckEnabled);
Bytes.toString(tenantIdBytes),
Bytes.toString(schemaName),
Bytes.toString(tableOrViewName),
PTable.TaskStatus.CREATED.toString(),
null, null, null, null,
this.accessCheckEnabled);
} catch (Throwable t) {
LOGGER.error("Adding a task to drop child views failed!", t);
}
Expand DownExpand Up@@ -3201,6 +3201,9 @@ else if (isCoveredColumn) {
invalidateList.add(new ImmutableBytesPtr(indexKey));
}
}
if (connection != null) {
connection.close();
}
return null;
}

Expand DownExpand Up@@ -3268,6 +3271,9 @@ else if (isCoveredColumn) {
index.getSchemaName().getBytes() : ByteUtil.EMPTY_BYTE_ARRAY, index.getTableName().getBytes());
}
}
if (connection != null) {
connection.close();
}
return null;
}

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,8 +77,8 @@ protected void setup(Context context) throws IOException, InterruptedException {
for (Map.Entry<String, String> entry : conf) {
clientInfos.setProperty(entry.getKey(), entry.getValue());
}
try {
PhoenixConnection conn = (PhoenixConnection) QueryUtil.getConnectionOnServer(clientInfos, conf);
try (PhoenixConnection conn = (PhoenixConnection) QueryUtil
.getConnectionOnServer(clientInfos, conf)) {
builder = conn.getKeyValueBuilder();
final String tableNamesConf = conf.get(FormatToBytesWritableMapper.TABLE_NAMES_CONFKEY);
final String logicalNamesConf = conf.get(FormatToBytesWritableMapper.LOGICAL_NAMES_CONFKEY);
Expand Down