public Object getFieldValue(_Fields field) { switch (field) { case ROWS: return getRows(); case FLAGS: return getFlags(); case CURSOR_ID: return getCursorId(); case STATEMENT_ID: return getStatementId(); case CONN_ID: return getConnId(); case TOKEN: return getToken(); case SOURCE: return getSource(); case OFFSET: return getOffset(); case METADATA: return getMetadata(); case CURSOR_NAME: return getCursorName(); case WARNINGS: return getWarnings(); case ROW_IDS_FOR_UPDATE_OR_DELETE: return getRowIdsForUpdateOrDelete(); } throw new IllegalStateException(); }
case ROWS: if (value == null) { unsetRows(); } else { setRows((List<Row>)value); unsetFlags(); } else { setFlags((Byte)value); unsetCursorId(); } else { setCursorId((Long)value); unsetStatementId(); } else { setStatementId((Long)value); unsetConnId(); } else { setConnId((Long)value); unsetToken(); } else { setToken((ByteBuffer)value); unsetSource(); } else { setSource((HostAddress)value);
@Override protected final void setCurrentRowSet(RowSet rs) { if (rs != null && (rs.getMetadata() != null || rs.getRowsSize() > 0)) { final long stmtId = rs.getStatementId(); if (stmtId != snappydataConstants.INVALID_ID) { this.statementId = stmtId; } this.currentRowSet = rs; // source host connection cannot change for prepared statements on // execution (only on re-prepare) } else { this.currentRowSet = null; } }
boolean isLastBatch = true; try { RowSet result = createEmptyRowSet().setConnId(connId); final boolean isForwardOnly = rs.getType() == ResultSet.TYPE_FORWARD_ONLY; columnCount, connHolder.useStringForDecimal()); if (holder == null) { // skip sending descriptors for scrollCursor result.setMetadata(descriptors); result.setOffset(Math.max(0, rs.getRow() - 1)); } else if (offset == 0) { if (holder == null) { // first call to create result set result.setOffset(0); } else { result.setOffset(holder.rsOffset); result.setOffset(Math.max(0, rs.getRow() - 1)); final List<Row> rows = result.getRows(); final boolean dynamicResults = estmt != null && estmt.hasDynamicResults(); if (dynamicResults) flags |= snappydataConstants.ROWSET_HAS_MORE_ROWSETS; result.setFlags(flags); fillWarnings(result, rs); result.setCursorId(INVALID_ID); result.setStatementId(INVALID_ID); } else { if (holder == null) {
final void setSourceConnection(RowSet rs) throws SnappyException { final HostConnection source = this.currentHostConnection; rs.setConnId(source.connId); rs.setToken(source.token); rs.setSource(source.hostAddr); // initialize finalizers for LOBs in the rows, if any final List<Row> rows = rs.rows; if (rows != null && rows.size() > 0) { // create LOBs for each row, if any try { for (Row row : rows) { row.initializeLobs(this); } } catch (SQLException sqle) { SnappyExceptionData data = new SnappyExceptionData(sqle.getMessage(), sqle.getErrorCode()).setSqlState(sqle.getSQLState()); SnappyException se = new SnappyException(data, source.toString()); se.initCause(sqle); throw se; } } }
/** * {@inheritDoc} */ @Override public void clearWarnings() throws SQLException { final RowSet rs = this.currentRowSet; if (rs != null) { rs.setWarnings(null); } this.warnings = null; }
/** * {@inheritDoc} */ @Override public SQLWarning getWarnings() throws SQLException { final RowSet rs = this.currentRowSet; SnappyExceptionData warning; if (rs != null) { warning = rs.getWarnings(); } else { warning = this.warnings; } if (warning != null) { return ThriftExceptionUtil.newSQLWarning(warning, null); } return null; }
protected void setCurrentRowSet(RowSet rs) { if (rs != null && (rs.getMetadata() != null || rs.getRowsSize() > 0)) { this.currentRowSet = rs; this.statementId = rs.statementId; setCurrentSource(snappydataConstants.BULK_CLOSE_STATEMENT, rs.statementId, rs); } else { this.currentRowSet = null; setCurrentSource(snappydataConstants.BULK_CLOSE_STATEMENT, snappydataConstants.INVALID_ID, null); } }
private void initRowSet(RowSet rs) { // copy metadata from previous RowSet if not set by server if (rs.metadata == null) { rs.setMetadata(this.rowSet.metadata); } this.rowSet = rs; this.numColumns = rs.metadata.size(); this.cursorId = rs.cursorId; setCurrentSource(snappydataConstants.BULK_CLOSE_RESULTSET, rs.cursorId, rs); }
public RowSet deepCopy() { return new RowSet(this); }
@Override public String getSchema() throws SQLException { String defaultSchema = this.clientService.getCurrentDefaultSchema(); if (defaultSchema != null) { return defaultSchema; } super.lock(); try { checkClosedConnection(); RowSet rs = this.clientService .executeQuery("VALUES CURRENT SCHEMA", null); List<Row> rows = rs.getRows(); if (rows != null && rows.size() > 0) { return (String)rows.get(0).getObject(0); } else { return null; } } catch (SnappyException se) { throw informListeners(ThriftExceptionUtil.newSQLException(se)); } finally { super.unlock(); } }
/** * {@inheritDoc} */ @Override public void clearWarnings() throws SQLException { checkClosed(); this.rowSet.setWarnings(null); }
/** * {@inheritDoc} */ @Override public SQLWarning getWarnings() throws SQLException { checkClosed(); SnappyExceptionData warnings = this.rowSet.getWarnings(); if (warnings != null) { return ThriftExceptionUtil.newSQLWarning(warnings, null); } else { return null; } }
case 1: // RESULT_SET if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.resultSet = new RowSet(); struct.resultSet.read(iprot); struct.setResultSetIsSet(true); } else { case 5: // GENERATED_KEYS if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.generatedKeys = new RowSet(); struct.generatedKeys.read(iprot); struct.setGeneratedKeysIsSet(true); } else {
private void fillWarnings(RowSet rs, ResultSet resultSet) throws SQLException { SQLWarning warnings = resultSet.getWarnings(); if (warnings != null) { rs.setWarnings(snappyWarning(warnings)); } }
/** * {@inheritDoc} */ @Override public ResultSet executeQuery(String sql) throws SQLException { checkClosed(); reset(); try { RowSet rs = this.service.executeQuery(sql, getAttributes()); clearPendingTransactionAttrs(); setCurrentRowSet(rs); this.warnings = rs.getWarnings(); return new ClientResultSet(this.conn, this, rs); } catch (SnappyException se) { throw ThriftExceptionUtil.newSQLException(se); } }