#NEWLINE# def visit_select( self , select , **kwargs ) : #NEWLINE# #INDENT# 'Look for ``LIMIT`` and OFFSET in a select statement, and if\n        so tries to wrap it in a subquery with ``rownum`` criterion.\n        ' #NEWLINE# if ( not getattr ( select , '_oracle_visit' , None ) ) : #NEWLINE# #INDENT# if ( not self . dialect . use_ansi ) : #NEWLINE# #INDENT# froms = self . _display_froms_for_select ( select , kwargs . get ( 'asfrom' , False ) ) #NEWLINE# whereclause = self . _get_nonansi_join_whereclause ( froms ) #NEWLINE# if ( whereclause is not None ) : #NEWLINE# #INDENT# select = select . where ( whereclause ) #NEWLINE# select . _oracle_visit = True #NEWLINE# #UNINDENT# #UNINDENT# if ( ( select . _limit is not None ) or ( select . _offset is not None ) ) : #NEWLINE# #INDENT# select = select . _generate ( ) #NEWLINE# select . _oracle_visit = True #NEWLINE# limitselect = sql . select ( [ c for c in select . c ] ) #NEWLINE# if ( select . _limit and self . dialect . optimize_limits ) : #NEWLINE# #INDENT# limitselect = limitselect . prefix_with ( ( '/*+ FIRST_ROWS(%d) */' % select . _limit ) ) #NEWLINE# #UNINDENT# limitselect . _oracle_visit = True #NEWLINE# limitselect . _is_wrapper = True #NEWLINE# if ( select . _limit is not None ) : #NEWLINE# #INDENT# max_row = select . _limit #NEWLINE# if ( select . _offset is not None ) : #NEWLINE# #INDENT# max_row += select . _offset #NEWLINE# #UNINDENT# if ( not self . dialect . use_binds_for_limits ) : #NEWLINE# #INDENT# max_row = sql . literal_column ( ( '%d' % max_row ) ) #NEWLINE# #UNINDENT# limitselect . append_whereclause ( ( sql . literal_column ( 'ROWNUM' ) <= max_row ) ) #NEWLINE# #UNINDENT# if ( select . _offset is None ) : #NEWLINE# #INDENT# limitselect . _for_update_arg = select . _for_update_arg #NEWLINE# select = limitselect #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# limitselect = limitselect . column ( sql . literal_column ( 'ROWNUM' ) . label ( 'ora_rn' ) ) #NEWLINE# limitselect . _oracle_visit = True #NEWLINE# limitselect . _is_wrapper = True #NEWLINE# offsetselect = sql . select ( [ c for c in limitselect . c if ( c . key != 'ora_rn' ) ] ) #NEWLINE# offsetselect . _oracle_visit = True #NEWLINE# offsetselect . _is_wrapper = True #NEWLINE# offset_value = select . _offset #NEWLINE# if ( not self . dialect . use_binds_for_limits ) : #NEWLINE# #INDENT# offset_value = sql . literal_column ( ( '%d' % offset_value ) ) #NEWLINE# #UNINDENT# offsetselect . append_whereclause ( ( sql . literal_column ( 'ora_rn' ) > offset_value ) ) #NEWLINE# offsetselect . _for_update_arg = select . _for_update_arg #NEWLINE# select = offsetselect #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# kwargs [ 'iswrapper' ] = getattr ( select , '_is_wrapper' , False ) #NEWLINE# return compiler . SQLCompiler . visit_select ( self , select , ** kwargs )