# File lib/active_record/connection_adapters/postgresql_adapter.rb, line 788
      def table_exists?(name)
        schema, table = Utils.extract_schema_and_table(name.to_s)
        return false unless table

        binds = [[nil, table]]
        binds << [nil, schema] if schema

        exec_query("SELECT COUNT(*)\nFROM pg_class c\nLEFT JOIN pg_namespace n ON n.oid = c.relnamespace\nWHERE c.relkind in ('v','r')\nAND c.relname = '\#{table.gsub(/(^\"|\"$)/,'')}'\nAND n.nspname = \#{schema ? \"'\#{schema}'\" : 'ANY (current_schemas(false))'}\n", 'SCHEMA').rows.first[0].to_i > 0
      end