protected final TupleTable getTupleTable()
	throws SQLException
	{
		if(m_table == null)
		{
			Portal portal = this.getPortal();
			if(portal.isAtEnd())
				return null;

			int mx;
			int fetchSize = this.getFetchSize();
			if(m_maxRows > 0)
			{
				mx = m_maxRows - portal.getPortalPos();
				if(mx <= 0)
					return null;
				if(mx > fetchSize)
					mx = fetchSize;
			}
			else
				mx = fetchSize;

			try
			{
				int result = portal.fetch(true, mx);
				if(result > 0)
					m_table = SPI.getTupTable(m_tupleDesc);
				m_tableRow = -1;
			}
			finally
			{
				SPI.freeTupTable();
			}
		}
		return m_table;
	}