private int childCount;
ResultTempTable(Session session, SortOrder sort) {
this.session = session;
this.sort = sort;
Database db = session.getDatabase();
Schema schema = db.getSchema(Constants.SCHEMA_MAIN);
Column column = new Column(COLUMN_NAME, Value.ARRAY);
column.setNullable(false);
CreateTableData data = new CreateTableData();
data.columns.add(column);
data.id = db.allocateObjectId();
data.tableName = "TEMP_RESULT_SET_" + data.id;
data.temporary = true;
data.persistIndexes = false;
data.persistData = true;
data.create = true;
data.session = session;
table = (TableBase) schema.createTable(data);
int indexId = db.allocateObjectId();
IndexColumn indexColumn = new IndexColumn();
indexColumn.column = column;
indexColumn.columnName = COLUMN_NAME;
IndexType indexType;
indexType = IndexType.createPrimaryKey(true, false);
IndexColumn[] indexCols = { indexColumn };
index = db.createPersistentIndex(table, indexId, data.tableName, indexCols, indexType, true, session);
index.setTemporary(true);
table.getIndexes().add(index);
parent = null;
}