diff --git service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java index 11c96b2..5b2a30c 100644 --- service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java +++ service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java @@ -184,13 +184,18 @@ private OperationHandle executeStatementInternal(String statement, Map tableTypes) throws HiveSQLException { - acquire(); + acquire(); + + OperationManager operationManager = getOperationManager(); + MetadataOperation operation = + operationManager.newGetTablesOperation(getSession(), catalogName, schemaName, tableName, tableTypes); + OperationHandle opHandle = operation.getHandle(); try { - MetadataOperation operation = - getOperationManager().newGetTablesOperation(getSession(), catalogName, schemaName, tableName, tableTypes); operation.run(); - OperationHandle opHandle = operation.getHandle(); opHandleSet.add(opHandle); return opHandle; + } catch (HiveSQLException e) { + operationManager.closeOperation(opHandle); + throw e; } finally { release(); } @@ -257,13 +282,18 @@ public OperationHandle getTables(String catalogName, String schemaName, String t public OperationHandle getTableTypes() throws HiveSQLException { - acquire(); + acquire(); + + OperationManager operationManager = getOperationManager(); + GetTableTypesOperation operation = operationManager.newGetTableTypesOperation(getSession()); + OperationHandle opHandle = operation.getHandle(); try { - GetTableTypesOperation operation = getOperationManager().newGetTableTypesOperation(getSession()); operation.run(); - OperationHandle opHandle = operation.getHandle(); opHandleSet.add(opHandle); return opHandle; + } catch (HiveSQLException e) { + operationManager.closeOperation(opHandle); + throw e; } finally { release(); } @@ -272,13 +302,18 @@ public OperationHandle getTableTypes() public OperationHandle getColumns(String catalogName, String schemaName, String tableName, String columnName) throws HiveSQLException { acquire(); - try { - GetColumnsOperation operation = getOperationManager().newGetColumnsOperation(getSession(), + + OperationManager operationManager = getOperationManager(); + GetColumnsOperation operation = operationManager.newGetColumnsOperation(getSession(), catalogName, schemaName, tableName, columnName); - operation.run(); OperationHandle opHandle = operation.getHandle(); + try { + operation.run(); opHandleSet.add(opHandle); return opHandle; + } catch (HiveSQLException e) { + operationManager.closeOperation(opHandle); + throw e; } finally { release(); } @@ -287,13 +322,18 @@ public OperationHandle getColumns(String catalogName, String schemaName, public OperationHandle getFunctions(String catalogName, String schemaName, String functionName) throws HiveSQLException { acquire(); + + OperationManager operationManager = getOperationManager(); + GetFunctionsOperation operation = operationManager + .newGetFunctionsOperation(getSession(), catalogName, schemaName, functionName); + OperationHandle opHandle = operation.getHandle(); try { - GetFunctionsOperation operation = getOperationManager() - .newGetFunctionsOperation(getSession(), catalogName, schemaName, functionName); operation.run(); - OperationHandle opHandle = operation.getHandle(); opHandleSet.add(opHandle); return opHandle; + } catch (HiveSQLException e) { + operationManager.closeOperation(opHandle); + throw e; } finally { release(); }