@Override boolean nextImpl() { row = null; if (result != null && result.next()) { values = result.currentRow(); } else { values = null; } return values != null; }
private void nextCursor() { if (inList != null) { while (inListIndex < inList.length) { Value v = inList[inListIndex++]; if (v != ValueNull.INSTANCE) { find(v); break; } } } else if (inResult != null) { while (inResult.next()) { Value v = inResult.currentRow()[0]; if (v != ValueNull.INSTANCE) { if (inResultTested == null) { inResultTested = new HashSet<>(); } if (inResultTested.add(v)) { find(v); break; } } } } }
private boolean nextRow() { if (result.isLazy() && stat.isCancelled()) { throw DbException.get(ErrorCode.STATEMENT_WAS_CANCELED); } boolean next = result.next(); if (!next && !scrollable) { result.close(); } return next; }
@Override protected Value[] fetchNextRow() { if (rightDone) { return null; } if (!leftDone) { if (l == null) { l = left.query(0); l.reset(); } if (l.next()) { return l.currentRow(); } leftDone = true; } if (r == null) { r = right.query(0); r.reset(); } if (r.next()) { return r.currentRow(); } rightDone = true; return null; }
/** * Read the session state if necessary. */ public void readSessionState() { if (!sessionStateChanged || sessionStateUpdating) { return; } sessionStateChanged = false; sessionState = New.arrayList(); CommandInterface ci = prepareCommand( "SELECT * FROM INFORMATION_SCHEMA.SESSION_STATE", Integer.MAX_VALUE); ResultInterface result = ci.executeQuery(0, false); while (result.next()) { Value[] row = result.currentRow(); sessionState.add(row[1].getString()); } }
private Value getValueSlow(ResultInterface rows, Value l) { // this only returns the correct result if the result has at least one // row, and if l is not null boolean hasNull = false; boolean result = all; while (rows.next()) { boolean value; Value r = rows.currentRow()[0]; if (r == ValueNull.INSTANCE) { value = false; hasNull = true; } else { value = Comparison.compareNotNull(database, l, r, compareType); } if (!value && all) { result = false; break; } else if (value && !all) { result = true; break; } } if (!result && hasNull) { return ValueNull.INSTANCE; } return ValueBoolean.get(result); }
Value[] targetRowIdValue = null; while (rows.next()) { countTargetRowsFound++; targetRowIdValue = rows.currentRow();
private void sendRow(ResultInterface result) throws IOException { if (result.next()) { transfer.writeBoolean(true); Value[] v = result.currentRow(); for (int i = 0; i < result.getVisibleColumnCount(); i++) { if (clientVersion >= Constants.TCP_PROTOCOL_VERSION_12) { transfer.writeValue(v[i]); } else { writeValue(v[i]); } } } else { transfer.writeBoolean(false); } }
/** * Read the serializer name from the persistent database settings. * * @return the serializer */ private String readSerializationSettings() { String javaObjectSerializerFQN = null; CommandInterface ci = prepareCommand( "SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS "+ " WHERE NAME='JAVA_OBJECT_SERIALIZER'", Integer.MAX_VALUE); try { ResultInterface result = ci.executeQuery(0, false); if (result.next()) { Value[] row = result.currentRow(); javaObjectSerializerFQN = row[0].getString(); } } finally { ci.close(); } return javaObjectSerializerFQN; }
private void checkNoNullValues(Table table) { String sql = "SELECT COUNT(*) FROM " + table.getSQL() + " WHERE " + oldColumn.getSQL() + " IS NULL"; Prepared command = session.prepare(sql); ResultInterface result = command.query(0); result.next(); if (result.currentRow()[0].getInt() > 0) { throw DbException.get( ErrorCode.COLUMN_CONTAINS_NULL_VALUES_1, oldColumn.getSQL()); } }
/** * Returns true if the database is read-only. * * @return if the database is read-only * @throws SQLException if the connection is closed */ @Override public boolean isReadOnly() throws SQLException { try { debugCodeCall("isReadOnly"); checkClosed(); getReadOnly = prepareCommand("CALL READONLY()", getReadOnly); ResultInterface result = getReadOnly.executeQuery(0, false); result.next(); return result.currentRow()[0].getBoolean(); } catch (Exception e) { throw logAndConvert(e); } }
@Override public Value getValue(Session session) { query.setSession(session); try (ResultInterface result = query.query(2)) { Value v; if (!result.next()) { v = ValueNull.INSTANCE; } else { Value[] values = result.currentRow(); if (result.getVisibleColumnCount() == 1) { v = values[0]; } else { v = ValueArray.get(values); } if (result.hasNext()) { throw DbException.get(ErrorCode.SCALAR_SUBQUERY_CONTAINS_MORE_THAN_ONE_ROW); } } return v; } }
@Override public void checkExistingData(Session session) { if (session.getDatabase().isStarting()) { // don't check at startup return; } String sql = "SELECT 1 FROM " + filter.getTable().getSQL() + " WHERE NOT(" + expr.getSQL() + ")"; ResultInterface r = session.prepare(sql).query(1); if (r.next()) { throw DbException.get(ErrorCode.CHECK_CONSTRAINT_VIOLATED_1, getName()); } }
/** * INTERNAL */ int getQueryTimeout() throws SQLException { try { if (queryTimeoutCache == -1) { checkClosed(); getQueryTimeout = prepareCommand( "SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS " + "WHERE NAME=?", getQueryTimeout); getQueryTimeout.getParameters().get(0) .setValue(ValueString.get("QUERY_TIMEOUT"), false); ResultInterface result = getQueryTimeout.executeQuery(0, false); result.next(); int queryTimeout = result.currentRow()[0].getInt(); result.close(); if (queryTimeout != 0) { // round to the next second, otherwise 999 millis would // return 0 seconds queryTimeout = (queryTimeout + 999) / 1000; } queryTimeoutCache = queryTimeout; } return queryTimeoutCache; } catch (Exception e) { throw logAndConvert(e); } }
/** * Gets the current catalog name. * * @return the catalog name * @throws SQLException if the connection is closed */ @Override public String getCatalog() throws SQLException { try { debugCodeCall("getCatalog"); checkClosed(); if (catalog == null) { CommandInterface cat = prepareCommand("CALL DATABASE()", Integer.MAX_VALUE); ResultInterface result = cat.executeQuery(0, false); result.next(); catalog = result.currentRow()[0].getString(); cat.close(); } return catalog; } catch (Exception e) { throw logAndConvert(e); } }
getLockMode = prepareCommand("CALL LOCK_MODE()", getLockMode); ResultInterface result = getLockMode.executeQuery(0, false); result.next(); int lockMode = result.currentRow()[0].getInt(); result.close();
@Override public boolean next() { while (true) { boolean res = result.next(); if (!res) { if (index.isRecursive()) {
@Override public int update() { // clear list of source table keys & rowids we have processed already targetRowidsRemembered.clear(); if (targetTableFilter != null) { targetTableFilter.startQuery(session); targetTableFilter.reset(); } if (sourceTableFilter != null) { sourceTableFilter.startQuery(session); sourceTableFilter.reset(); } sourceQueryRowNumber = 0; checkRights(); setCurrentRowNumber(0); // process source select query data for row creation ResultInterface rows = query.query(0); targetTable.fire(session, evaluateTriggerMasks(), true); targetTable.lock(session, true, false); while (rows.next()) { sourceQueryRowNumber++; Value[] sourceRowValues = rows.currentRow(); Row sourceRow = new RowImpl(sourceRowValues, 0); setCurrentRowNumber(sourceQueryRowNumber); merge(sourceRow); } rows.close(); targetTable.fire(session, evaluateTriggerMasks(), false); return countUpdatedRows; }
String sql = buff.toString(); ResultInterface r = session.prepare(sql).query(1); if (r.next()) { throw DbException.get(ErrorCode.REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1, getShortDescription(null, null));