@Override public ResultSetMetaData getMetaData() throws SQLException { if (statement.getOperation().isMutation()) { return null; } int paramCount = statement.getBindCount(); List<Object> params = this.getParameters(); BitSet unsetParams = new BitSet(statement.getBindCount()); for (int i = 0; i < paramCount; i++) { if ( params.get(i) == BindManager.UNBOUND_PARAMETER) { unsetParams.set(i); params.set(i, null); } } try { // Just compile top level query without optimizing to get ResultSetMetaData QueryPlan plan = statement.compilePlan(this, Sequence.ValueOp.VALIDATE_SEQUENCE); return new PhoenixResultSetMetaData(this.getConnection(), plan.getProjector()); } finally { int lastSetBit = 0; while ((lastSetBit = unsetParams.nextSetBit(lastSetBit)) != -1) { params.set(lastSetBit, BindManager.UNBOUND_PARAMETER); lastSetBit++; } } }
@Override public ResultSet executeQuery(String sql) throws SQLException { if (logger.isDebugEnabled()) { logger.debug(LogUtil.addCustomAnnotations("Execute query: " + sql, connection)); } CompilableStatement stmt = parseStatement(sql); if (stmt.getOperation().isMutation()) { throw new ExecuteQueryNotApplicableException(sql); } return executeQuery(stmt,createQueryLogger(stmt,sql)); }
@Override public int executeUpdate(String sql) throws SQLException { CompilableStatement stmt = parseStatement(sql); if (!stmt.getOperation().isMutation) { throw new ExecuteUpdateNotApplicableException(sql); } if (!batch.isEmpty()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH) .build().buildException(); } int updateCount = executeMutation(stmt); flushIfNecessary(); return updateCount; }
boolean execute(boolean batched) throws SQLException { throwIfUnboundParameters(); if (!batched && statement.getOperation().isMutation() && !batch.isEmpty()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH) .build().buildException(); } if (statement.getOperation().isMutation()) { executeMutation(statement); return false; } executeQuery(statement, createQueryLogger(statement,query)); return true; }
@Override public ResultSet executeQuery(String sql) throws SQLException { if (logger.isDebugEnabled()) { logger.debug(LogUtil.addCustomAnnotations("Execute query: " + sql, connection)); } CompilableStatement stmt = parseStatement(sql); if (stmt.getOperation().isMutation()) { throw new ExecuteQueryNotApplicableException(sql); } return executeQuery(stmt,createQueryLogger(stmt,sql)); }
public MutationPlan compileMutation(CompilableStatement stmt, String query) throws SQLException { if (!stmt.getOperation().isMutation()) { throw new ExecuteUpdateNotApplicableException(query); } return stmt.compilePlan(this, Sequence.ValueOp.VALIDATE_SEQUENCE); }
public QueryPlan compileQuery(CompilableStatement stmt, String query) throws SQLException { if (stmt.getOperation().isMutation()) { throw new ExecuteQueryNotApplicableException(query); } return stmt.compilePlan(this, Sequence.ValueOp.VALIDATE_SEQUENCE); }
@Override public int executeUpdate() throws SQLException { throwIfUnboundParameters(); if (!statement.getOperation().isMutation()) { throw new ExecuteUpdateNotApplicableException(statement.getOperation()); } if (!batch.isEmpty()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH) .build().buildException(); } return executeMutation(statement); }
@Override public int executeUpdate() throws SQLException { throwIfUnboundParameters(); if (!statement.getOperation().isMutation()) { throw new ExecuteUpdateNotApplicableException(statement.getOperation()); } if (!batch.isEmpty()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH) .build().buildException(); } return executeMutation(statement); }
@Override public ResultSet executeQuery() throws SQLException { throwIfUnboundParameters(); if (statement.getOperation().isMutation()) { throw new ExecuteQueryNotApplicableException(statement.getOperation()); } return executeQuery(statement,createQueryLogger(statement,query)); }
public QueryPlan compileQuery(CompilableStatement stmt, String query) throws SQLException { if (stmt.getOperation().isMutation()) { throw new ExecuteQueryNotApplicableException(query); } return stmt.compilePlan(this, Sequence.ValueOp.VALIDATE_SEQUENCE); }
@Override public ResultSet executeQuery() throws SQLException { throwIfUnboundParameters(); if (statement.getOperation().isMutation()) { throw new ExecuteQueryNotApplicableException(statement.getOperation()); } return executeQuery(statement,createQueryLogger(statement,query)); }
@Override public ResultSet executeQuery(String sql) throws SQLException { if (logger.isDebugEnabled()) { logger.debug(LogUtil.addCustomAnnotations("Execute query: " + sql, connection)); } CompilableStatement stmt = parseStatement(sql); if (stmt.getOperation().isMutation()) { throw new ExecuteQueryNotApplicableException(sql); } return executeQuery(stmt,createQueryLogger(stmt,sql)); }
public MutationPlan compileMutation(CompilableStatement stmt, String query) throws SQLException { if (!stmt.getOperation().isMutation()) { throw new ExecuteUpdateNotApplicableException(query); } return stmt.compilePlan(this, Sequence.ValueOp.VALIDATE_SEQUENCE); }
@Override public boolean execute(String sql) throws SQLException { CompilableStatement stmt = parseStatement(sql); if (stmt.getOperation().isMutation()) { if (!batch.isEmpty()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH) .build().buildException(); } executeMutation(stmt); flushIfNecessary(); return false; } executeQuery(stmt,createQueryLogger(stmt,sql)); return true; }
boolean execute(boolean batched) throws SQLException { throwIfUnboundParameters(); if (!batched && statement.getOperation().isMutation() && !batch.isEmpty()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH) .build().buildException(); } if (statement.getOperation().isMutation()) { executeMutation(statement); return false; } executeQuery(statement, createQueryLogger(statement,query)); return true; }
@Override public int executeUpdate() throws SQLException { throwIfUnboundParameters(); if (!statement.getOperation().isMutation()) { throw new ExecuteUpdateNotApplicableException(statement.getOperation()); } if (!batch.isEmpty()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH) .build().buildException(); } return executeMutation(statement); }
@Override public ResultSet executeQuery() throws SQLException { throwIfUnboundParameters(); if (statement.getOperation().isMutation()) { throw new ExecuteQueryNotApplicableException(statement.getOperation()); } return executeQuery(statement,createQueryLogger(statement,query)); }
public QueryPlan compileQuery(CompilableStatement stmt, String query) throws SQLException { if (stmt.getOperation().isMutation()) { throw new ExecuteQueryNotApplicableException(query); } return stmt.compilePlan(this, Sequence.ValueOp.VALIDATE_SEQUENCE); }
public MutationPlan compileMutation(CompilableStatement stmt, String query) throws SQLException { if (!stmt.getOperation().isMutation()) { throw new ExecuteUpdateNotApplicableException(query); } return stmt.compilePlan(this, Sequence.ValueOp.VALIDATE_SEQUENCE); }