This method loops through the underlying query, copying its output
records into a temporary table. It then returns a table scan for that
table.

@see Plan#open()
336408
@Override
	public Scan open() {
		Schema sch = p.schema();
		TempTable temp = new TempTable(sch, tx);
		Scan src = p.open();
		UpdateScan dest = temp.open();
		src.beforeFirst();
		while (src.next()) {
			dest.insert();
			for (String fldname : sch.fields())
				dest.setVal(fldname, src.getVal(fldname));
		}
		src.close();
		dest.beforeFirst();
		return dest;
	}
1344883
public InputStream openSerialStream(FieldList record, String strLookupKey)
    {
        try
        {
            String strTableName = this.getFilename(strLookupKey, false);
            String strFilePathName = '/' + Params.TABLE_PATH;
            strFilePathName = Util.addURLParam(strFilePathName, DATA_TYPE, "table");
            strFilePathName = Util.addURLParam(strFilePathName, RECORD_CLASS, record.getClass().getName());
            strFilePathName = Util.addURLParam(strFilePathName, TABLE_NAME, strTableName);
            App app = null;
            if (this.getPDatabaseParent() != null)
                app = (App)this.getPDatabaseParent().getProperty(PhysicalDatabaseParent.APP);
            if (app == null)
                if (record.getOwner() instanceof RecordOwnerParent)
                    if (((RecordOwnerParent)record.getOwner()).getTask() != null)
                        if (((RecordOwnerParent)record.getOwner()).getTask().getApplication() != null)
                            app = ((RecordOwnerParent)record.getOwner()).getTask().getApplication();
            String systemName = null;
            if (app != null)
            {
                strFilePathName = Util.addURLParam(strFilePathName, Params.LANGUAGE, app.getLanguage(true), false);
                systemName = app.getProperty(Constants.SYSTEM_NAME);
            }
            if (systemName == null)
                if (record.getTable() != null)
                    if (record.getTable().getDatabase() != null)
                        if (record.getTable().getDatabase().getDatabaseOwner() != null)
                            systemName = record.getTable().getDatabase().getDatabaseOwner().getProperty(Constants.SYSTEM_NAME);
            strFilePathName = Util.addURLParam(strFilePathName, Constants.SYSTEM_NAME, systemName, false);
            URL url = null;
            if (app == null)
            {
                String strFilePrefix = "http://";
                strFilePrefix += "localhost/" + Constants.DEFAULT_SERVLET;   // Never
                strFilePathName = strFilePrefix + strFilePathName;
                url = new URL(strFilePathName);
            }
            else
            {
                String strServletName = app.getProperty(Params.SERVLET);
                if ((strServletName == null) || (strServletName.length() == 0))
                    if ((app.getProperty(Params.CODEBASE) !=  null) && (app.getProperty(Params.CODEBASE).length() > 0))
                        if (app.getProperty(Params.CODEBASE).indexOf('/') != -1)
                            strServletName = app.getProperty(Params.CODEBASE).substring(app.getProperty(Params.CODEBASE).lastIndexOf('/') + 1) + Constants.DEFAULT_SERVLET;
                if ((strServletName == null) || (strServletName.length() == 0))
                    strServletName = Constants.DEFAULT_SERVLET;
                strFilePathName = strServletName + strFilePathName;

                 url = app.getResourceURL(strFilePathName, null);
            }
            return url.openStream();
        } catch (MalformedURLException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        return null;
    }
581903
public Record openMainRecord()
    {
        String strClassName = this.getProperty(MenuConstants.RECORD);
        Record record = Record.makeRecordFromClassName(strClassName, this);
        return record;
    }
928072
public CompletableFuture<Void> open() {
    CompletableFuture<Void> future = new CompletableFuture<>();
    context.executor().execute(() -> register(new RegisterAttempt(1, future)));
    return future;
  }
498685
public void open() throws DBException
    {
        m_bIsOpen = true;
        this.getRecord().setEditMode(Constants.EDIT_NONE);
        this.setDataSource(null);
    }
1226313
@Override
	public void open() throws IOException, MemoryAllocationException, InterruptedException {
		this.hashJoin.open(this.firstInput, this.secondInput, this.buildSideOuterJoin);
	}
235371
@Override
	public Scan open() {
		Scan s1 = p1.open();
		Scan s2 = p2.open();
		return new ProductScan(s1, s2);
	}
1231446
public IResultSet executeQuery() throws OdaException
	{
		String currentQueryText = queryText;
		if(getMaxRows()!=0){
			currentQueryText = currentQueryText+ " LIMIT "+getMaxRows(); 
		}
		try {
			OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(currentQueryText);
			List<ODocument> dbResult = getOrMakeDBResult(db.command(query).execute(parameters));
			/*
			ArrayList<ODocument> unCachedResult = new ArrayList<ODocument>(dbResult.size());
			for (ODocument oDocument : dbResult) {
				ODocument newDoc = new ODocument();
				for (Entry<String, Object> entry : oDocument) {
					newDoc.field(entry.getKey(),entry.getValue());
				}
				unCachedResult.add(newDoc);
			}*/
			return new ResultSet(dbResult,curMetaData);
		} catch (OCommandSQLParsingException e) {
			throw new OdaException(e);
		}
	}
911598
@Override
	public void open() {
		synchronized (stateLock) {
			if (!closed) {
				throw new IllegalStateException("currently not closed.");
			}
			closed = false;
		}
		
		// create the partitions
		final int partitionFanOut = getPartitioningFanOutNoEstimates(this.availableMemory.size()); 
		createPartitions(partitionFanOut);
		
		// set up the table structure. the write behind buffers are taken away, as are one buffer per partition
		final int numBuckets = getInitialTableSize(this.availableMemory.size(), this.segmentSize, 
			partitionFanOut, this.avgRecordLen);
		
		initTable(numBuckets, (byte) partitionFanOut);
	}
1291048
public Record openMainRecord()
    {
        if (this.getProperty("recordClass") != null)
        {
                String strClassName = this.getProperty("recordClass");
                if (strClassName != null)
                    return Record.makeRecordFromClassName(strClassName, this);
        }
        return super.openMainRecord();
    }
1068329
public SQLiteDatabase openReadOnlyDatabase() {
		lockDb.lock();
		try {
			if (sqliteHelper == null)
				createHelper(options);

			status.set(TypeStatus.READ_ONLY_OPENED);

			if (openCounter.incrementAndGet() == 1) {
				// open new read database
				if (database == null) {
					sqliteHelper.setWriteAheadLoggingEnabled(true);
					database = sqliteHelper.getReadableDatabase();
				}
				if (logEnabled)
					Logger.info("database OPEN %s (connections: %s)", status.get(), (openCounter.intValue() - 1));
			} else {
				if (logEnabled)
					Logger.info("database REUSE %s (connections: %s)", status.get(), (openCounter.intValue() - 1));
			}
		} finally {
			lockDb.unlock();
			lockReadAccess.lock();
		}

		return database;
	}
619729
@Override
	public Scan open() {
		Scan s = p1.open();
		// throws an exception if p2 is not a tableplan
		TableScan ts = (TableScan) tp2.open();
		Index idx = ii.open(tx);
		return new IndexJoinScan(s, idx, joinFields, ts);
	}
787578
public Record openMainRecord()
    {
        String strRecord = this.getProperty(DBParams.RECORD);
        String strPackage = this.getProperty("package");
        if ((strRecord == null) || (strPackage == null))
            return null;
        if (strPackage.startsWith("."))
            strPackage = DBConstants.ROOT_PACKAGE.substring(0, DBConstants.ROOT_PACKAGE.length() - 1) + strPackage;   // Never
        String strRecordClassName = strPackage + '.' + strRecord;
        String oldBaseTableProperty = this.getTask().getApplication().getProperty(DBConstants.BASE_TABLE_ONLY);
        this.getTask().getApplication().setProperty(DBConstants.BASE_TABLE_ONLY, DBConstants.TRUE);
        Record record = Record.makeRecordFromClassName(strRecordClassName, this);
        record.setEnableListeners(false);
        record.setEnableFieldListeners(false);
        // Restore properties
        this.getTask().getApplication().setProperty(DBConstants.BASE_TABLE_ONLY, oldBaseTableProperty);   // Make sure system record owner property is reset also
        return record;
    }
1252687
final void realOpen() throws SQLException {
      if(conn == null) {
         conn = segment.createRealConnection();

         //Don't care about the exact value - randomize with some seconds to make
         //sure connections (if configured) don't expire at the same time even if they
         //are all created at once.
         realOpenTime = Clock.currTimeMillis + rnd.nextInt(120000);
         openStatements.clear(); //If reopen is a result of forceRealClose.
         reopenAttempts = 0;
      }
   }
610752
CloseableIterator<T> createIterator(PreparedQuery<T> preparedQuery, int resultFlags) throws SQLException {
		try {
			SelectIterator<T, ID> iterator =
					statementExecutor.buildIterator(this, connectionSource, preparedQuery, objectCache, resultFlags);
			return iterator;
		} catch (SQLException e) {
			throw SqlExceptionUtil.create("Could not build prepared-query iterator for " + dataClass, e);
		}
	}
728593
public Query<T> build() {
    QueryBean<T> queryBean = new QueryBean<T>();
    queryBean.setStatement(genStatement());
    queryBean.setParams(getParams());
    if (null != limit) {
      queryBean.setLimit(new PageLimit(limit.getPageIndex(), limit.getPageSize()));
    }
    queryBean.setCountStatement(genCountStatement());
    queryBean.setCacheable(cacheable);
    queryBean.setLang(getLang());
    return queryBean;
  }
641282
public String query(String query) {
        try {
            Connection conn = this.tx().getConnection();
            ObjectNode result = this.mapper.createObjectNode();
            ArrayNode dataNode = this.mapper.createArrayNode();
            ArrayNode metaNode = this.mapper.createArrayNode();
            Statement statement = conn.createStatement();
            if (logger.isDebugEnabled()) {
                logger.debug(query);
            }
            ResultSet rs = statement.executeQuery(query);
            ResultSetMetaData rsmd = rs.getMetaData();
            boolean first = true;
            while (rs.next()) {
                int numColumns = rsmd.getColumnCount();
                ObjectNode obj = this.mapper.createObjectNode();
                for (int i = 1; i < numColumns + 1; i++) {
                    String columnName = rsmd.getColumnLabel(i);
                    int type = rsmd.getColumnType(i);
                    //make sure to obtain array using getArray()
                    //At least in H2, this makes a difference...
                    Object o = type == Types.ARRAY ? rs.getArray(i) : rs.getObject(i);
                    this.sqlDialect.putJsonObject(obj, columnName, type, o);
                    if (first) {
                        this.sqlDialect.putJsonMetaObject(this.mapper, metaNode, columnName, type, o);
                    }
                }
                first = false;
                dataNode.add(obj);
            }
            result.set("data", dataNode);
            result.set("meta", metaNode);
            return result.toString();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            this.tx().rollback();
        }
    }