Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8794

Show
Ignore:
Timestamp:
02/03/08 12:11:52 (5 months ago)
Author:
bitsweat
Message:

MySQL: memoize column and table name quoting to reduce garbage

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb

    r8757 r8794  
    156156        "Broken pipe", 
    157157        "Lost connection to MySQL server during query", 
    158         "MySQL server has gone away" 
    159       ] 
     158        "MySQL server has gone away" ] 
     159 
     160      QUOTED_TRUE, QUOTED_FALSE = '1', '0' 
    160161 
    161162      def initialize(connection, logger, connection_options, config) 
    162163        super(connection, logger) 
    163164        @connection_options, @config = connection_options, config 
    164  
     165        @quoted_column_names, @quoted_table_names = {}, {} 
    165166        connect 
    166167      end 
     
    206207 
    207208      def quote_column_name(name) #:nodoc: 
    208         "`#{name}`" 
     209        @quoted_column_names[name] ||= "`#{name}`" 
    209210      end 
    210211 
    211212      def quote_table_name(name) #:nodoc: 
    212         quote_column_name(name).gsub('.', '`.`') 
     213        @quoted_table_names[name] ||= quote_column_name(name).gsub('.', '`.`') 
    213214      end 
    214215 
     
    218219 
    219220      def quoted_true 
    220         "1" 
     221        QUOTED_TRUE 
    221222      end 
    222223 
    223224      def quoted_false 
    224         "0" 
     225        QUOTED_FALSE 
    225226      end 
    226227