<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -623,6 +623,19 @@ module ActiveRecord
         end
       end
 
+      # Returns the current database name.
+      def current_database
+        query('select current_database()')[0][0]
+      end
+
+      # Returns the current database encoding format.
+      def encoding
+        query(&lt;&lt;-end_sql)[0][0]
+          SELECT pg_encoding_to_char(pg_database.encoding) FROM pg_database
+          WHERE pg_database.datname LIKE '#{current_database}'
+        end_sql
+      end
+
       # Sets the schema search path to a string of comma-separated schema names.
       # Names beginning with $ have to be quoted (e.g. $user =&gt; '$user').
       # See: http://www.postgresql.org/docs/current/static/ddl-schemas.html</diff>
      <filename>activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -65,6 +65,12 @@ class AdapterTest &lt; ActiveRecord::TestCase
     end
   end
 
+  if current_adapter?(:PostgreSQLAdapter)
+    def test_encoding
+      assert_not_nil @connection.encoding
+    end
+  end
+
   def test_table_alias
     def @connection.test_table_alias_length() 10; end
     class &lt;&lt; @connection</diff>
      <filename>activerecord/test/cases/adapter_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -141,6 +141,9 @@ namespace :db do
     when 'mysql'
       ActiveRecord::Base.establish_connection(config)
       puts ActiveRecord::Base.connection.charset
+    when 'postgresql'
+      ActiveRecord::Base.establish_connection(config)
+      puts ActiveRecord::Base.connection.encoding
     else
       puts 'sorry, your database adapter is not supported yet, feel free to submit a patch'
     end</diff>
      <filename>railties/lib/tasks/databases.rake</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>cleanlogs.sh</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>5c086070824bf7dd2bc4c9ce97956d82ac3fa206</id>
    </parent>
  </parents>
  <author>
    <name>Sebastian A. Espindola</name>
    <email>sespindola@gmail.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/0176e6adb388998414083e99523de318d3b8ca49</url>
  <id>0176e6adb388998414083e99523de318d3b8ca49</id>
  <committed-date>2008-07-13T20:11:52-07:00</committed-date>
  <authored-date>2008-07-07T21:14:11-07:00</authored-date>
  <message>Added db:charset support to PostgreSQL. [#556 state:resolved]

Signed-off-by: Pratik Naik &lt;pratiknaik@gmail.com&gt;</message>
  <tree>5ba0497b13764584a43a50b7cd98f2b1b4bf8d07</tree>
  <committer>
    <name>Pratik Naik</name>
    <email>pratiknaik@gmail.com</email>
  </committer>
</commit>
