'Look for ``LIMIT`` and OFFSET in a select statement, and if
so tries to wrap it in a subquery with ``rownum`` criterion.'

def visit_select(self, select, **kwargs):

    if (not getattr(select, '_oracle_visit', None)):
        if (not self.dialect.use_ansi):
            froms = self._display_froms_for_select(select, kwargs.get('asfrom', False))
            whereclause = self._get_nonansi_join_whereclause(froms)
            if (whereclause is not None):
                select = select.where(whereclause)
                select._oracle_visit = True
        if ((select._limit is not None) or (select._offset is not None)):
            select = select._generate()
            select._oracle_visit = True
            limitselect = sql.select([c for c in select.c])
            if (select._limit and self.dialect.optimize_limits):
                limitselect = limitselect.prefix_with(('/*+    FIRST_ROWS(%d)    */' % select._limit))
            limitselect._oracle_visit = True
            limitselect._is_wrapper = True
            if (select._limit is not None):
                max_row = select._limit
                if (select._offset is not None):
                    max_row += select._offset
                if (not self.dialect.use_binds_for_limits):
                    max_row = sql.literal_column(('%d' % max_row))
                limitselect.append_whereclause((sql.literal_column('ROWNUM') <= max_row))
            if (select._offset is None):
                limitselect._for_update_arg = select._for_update_arg
                select = limitselect
            else:
                limitselect = limitselect.column(sql.literal_column('ROWNUM').label('ora_rn'))
                limitselect._oracle_visit = True
                limitselect._is_wrapper = True
                offsetselect = sql.select([c for c in limitselect.c if (c.key != 'ora_rn')])
                offsetselect._oracle_visit = True
                offsetselect._is_wrapper = True
                offset_value = select._offset
                if (not self.dialect.use_binds_for_limits):
                    offset_value = sql.literal_column(('%d' % offset_value))
                offsetselect.append_whereclause((sql.literal_column('ora_rn') > offset_value))
                offsetselect._for_update_arg = select._for_update_arg
                select = offsetselect
    kwargs['iswrapper'] = getattr(select, '_is_wrapper', False)
    return compiler.SQLCompiler.visit_select(self, select, **kwargs)
