public QueryPlan compilePlan(PhoenixStatement stmt, Sequence.ValueOp seqAction) throws SQLException { CompilableStatement compilableStmt = getStatement(); StatementPlan compilePlan = compilableStmt.compilePlan(stmt, Sequence.ValueOp.VALIDATE_SEQUENCE);
@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++; } } }
public QueryPlan compilePlan(PhoenixStatement stmt, Sequence.ValueOp seqAction) throws SQLException { CompilableStatement compilableStmt = getStatement(); StatementPlan compilePlan = compilableStmt.compilePlan(stmt, Sequence.ValueOp.VALIDATE_SEQUENCE);
public QueryPlan compilePlan(PhoenixStatement stmt, Sequence.ValueOp seqAction) throws SQLException { CompilableStatement compilableStmt = getStatement(); StatementPlan compilePlan = compilableStmt.compilePlan(stmt, Sequence.ValueOp.VALIDATE_SEQUENCE);
@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 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 ParameterMetaData getParameterMetaData() throws SQLException { 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 { StatementPlan plan = statement.compilePlan(this, Sequence.ValueOp.VALIDATE_SEQUENCE); return plan.getParameterMetaData(); } finally { int lastSetBit = 0; while ((lastSetBit = unsetParams.nextSetBit(lastSetBit)) != -1) { params.set(lastSetBit, BindManager.UNBOUND_PARAMETER); lastSetBit++; } } }
@Override public ParameterMetaData getParameterMetaData() throws SQLException { 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 { StatementPlan plan = statement.compilePlan(this, Sequence.ValueOp.VALIDATE_SEQUENCE); return plan.getParameterMetaData(); } finally { int lastSetBit = 0; while ((lastSetBit = unsetParams.nextSetBit(lastSetBit)) != -1) { params.set(lastSetBit, BindManager.UNBOUND_PARAMETER); lastSetBit++; } } }
@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; }
@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; }
@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; }
@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; }
@Override public int getBindCount() { return getStatement().getBindCount(); }
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; }
protected QueryPlan optimizeQuery(CompilableStatement stmt) throws SQLException { QueryPlan plan = stmt.compilePlan(this, Sequence.ValueOp.VALIDATE_SEQUENCE); return connection.getQueryServices().getOptimizer().optimize(this, plan); }
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; }
protected QueryPlan optimizeQuery(CompilableStatement stmt) throws SQLException { QueryPlan plan = stmt.compilePlan(this, Sequence.ValueOp.VALIDATE_SEQUENCE); return connection.getQueryServices().getOptimizer().optimize(this, plan); }
@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() 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); }
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); }