void setDatabseObjects(Session session, CompileContext compileContext) { parameters = compileContext.getParameters(); setParameters(); setParameterMetaData(); subqueries = getSubqueries(session); rangeIteratorCount = compileContext.getRangeVarCount(); rangeVariables = compileContext.getRangeVariables(); sequences = compileContext.getSequences(); routines = compileContext.getRoutines(); OrderedHashSet set = new OrderedHashSet(); collectTableNamesForWrite(set); if (set.size() > 0) { writeTableNames = new HsqlName[set.size()]; set.toArray(writeTableNames); set.clear(); } collectTableNamesForRead(set); set.removeAll(writeTableNames); if (set.size() > 0) { readTableNames = new HsqlName[set.size()]; set.toArray(readTableNames); } references = compileContext.getSchemaObjectNames(); if (targetTable != null) { references.add(targetTable.getName()); } }
SubQuery[] getSubqueries(Session session) { OrderedHashSet subQueries = null; for (int i = 0; i < targetRangeVariables.length; i++) { if (targetRangeVariables[i] == null) { continue; } OrderedHashSet set = targetRangeVariables[i].getSubqueries(); subQueries = OrderedHashSet.addAll(subQueries, set); } for (int i = 0; i < updateExpressions.length; i++) { subQueries = updateExpressions[i].collectAllSubqueries(subQueries); } if (insertExpression != null) { subQueries = insertExpression.collectAllSubqueries(subQueries); } if (condition != null) { subQueries = condition.collectAllSubqueries(subQueries); } if (queryExpression != null) { OrderedHashSet set = queryExpression.getSubqueries(); subQueries = OrderedHashSet.addAll(subQueries, set); } if (subQueries == null || subQueries.size() == 0) { return SubQuery.emptySubqueryArray; } SubQuery[] subQueryArray = new SubQuery[subQueries.size()]; subQueries.toArray(subQueryArray); ArraySort.sort(subQueryArray, 0, subQueryArray.length, subQueryArray[0]); for (int i = 0; i < subQueryArray.length; i++) { subQueryArray[i].prepareTable(session); } return subQueryArray; }