public SessionInterface reconnect(boolean write) { readSessionState(); close(); Session newSession = (Session) database.getDatabaseEngine().createSession(connectionInfo); newSession.sessionState = sessionState; newSession.recreateSessionState(); if (write) { while (!newSession.database.beforeWriting()) { // wait until we are allowed to write } } return newSession; }
private ValueResultSet getTable( Session session, Expression[] argList, boolean onlyColumnList, boolean distinctRows) { int len = columnList.length; Expression[] header = new Expression[len]; Database db = session.getDatabase(); for (int i = 0; i < len; i++) { Column c = columnList[i]; ExpressionColumn col = new ExpressionColumn(db, c); header[i] = col; } LocalResult result = new LocalResult(session, header, len); if (distinctRows) { result.setDistinct(); } if (!onlyColumnList) { Value[][] list = new Value[len][]; int rows = 0; for (int i = 0; i < len; i++) { Value v = argList[i].getValue(session); if (v == ValueNull.INSTANCE) { list[i] = new Value[0]; } else { ValueArray array = (ValueArray) v.convertTo(Value.ARRAY); Value[] l = array.getList(); list[i] = l; rows = Math.max(rows, l.length); } } for (int row = 0; row < rows; row++) { Value[] r = new Value[len]; for (int j = 0; j < len; j++) { Value[] l = list[j]; Value v; if (l.length <= row) { v = ValueNull.INSTANCE; } else { Column c = columnList[j]; v = l[row]; v = c.convert(v); v = v.convertPrecision(c.getPrecision(), false); v = v.convertScale(true, c.getScale()); } r[j] = v; } result.addRow(r); } } result.done(); ValueResultSet vr = ValueResultSet.get(getSimpleResultSet(result, Integer.MAX_VALUE)); return vr; }