### Home Classes Methods

### In Files

- lib/sequel/adapters/shared/postgres.rb

### Methods

- #commit_prepared_transaction
- #commit_transaction
- #create_function
- #create_function_sql
- #create_language
- #create_language_sql
- #create_schema
- #create_schema_sql
- #create_trigger
- #create_trigger_sql
- #database_error_classes
- #database_type
- #drop_function
- #drop_function_sql
- #drop_language
- #drop_language_sql
- #drop_schema
- #drop_schema_sql
- #drop_trigger
- #drop_trigger_sql
- #filter_schema
- #identifier_input_method_default
- #identifier_output_method_default
- #index_definition_sql
- #indexes
- #insert_result
- #locks
- #log_connection_execute
- #notify
- #pg_class_relname
- #prepared_arg_placeholder
- #primary_key
- #primary_key_sequence
- #remove_cached_schema
- #rename_table_sql
- #reset_primary_key_sequence
- #rollback_prepared_transaction
- #schema_autoincrementing_primary_key?
- #schema_parse_table
- #serial_primary_key_options
- #server_version
- #sql_function_args
- #supports_create_table_if_not_exists?
- #supports_prepared_transactions?
- #supports_savepoints?
- #supports_transaction_isolation_levels?
- #tables
- #type_literal_generic_bignum
- #type_literal_generic_file
- #type_literal_generic_integer
- #type_literal_generic_string
- #views

### Files

- CHANGELOG
- MIT-LICENSE
- README.rdoc
- active_record.rdoc
- advanced_associations.rdoc
- association_basics.rdoc
- cheat_sheet.rdoc
- dataset_basics.rdoc
- dataset_filtering.rdoc
- mass_assignment.rdoc
- migration.rdoc
- model_hooks.rdoc
- opening_databases.rdoc
- prepared_statements.rdoc
- querying.rdoc
- reflection.rdoc
- 1.0.txt
- 1.1.txt
- 1.3.txt
- 1.4.0.txt
- 1.5.0.txt
- 2.0.0.txt
- 2.1.0.txt
- 2.10.0.txt
- 2.11.0.txt
- 2.12.0.txt
- 2.2.0.txt
- 2.3.0.txt
- 2.4.0.txt
- 2.5.0.txt
- 2.6.0.txt
- 2.7.0.txt
- 2.8.0.txt
- 2.9.0.txt
- 3.0.0.txt
- 3.1.0.txt
- 3.10.0.txt
- 3.11.0.txt
- 3.12.0.txt
- 3.13.0.txt
- 3.14.0.txt
- 3.15.0.txt
- 3.16.0.txt
- 3.17.0.txt
- 3.18.0.txt
- 3.19.0.txt
- 3.2.0.txt
- 3.20.0.txt
- 3.21.0.txt
- 3.22.0.txt
- 3.23.0.txt
- 3.24.0.txt
- 3.25.0.txt
- 3.26.0.txt
- 3.27.0.txt
- 3.28.0.txt
- 3.29.0.txt
- 3.3.0.txt
- 3.30.0.txt
- 3.31.0.txt
- 3.32.0.txt
- 3.33.0.txt
- 3.4.0.txt
- 3.5.0.txt
- 3.6.0.txt
- 3.7.0.txt
- 3.8.0.txt
- 3.9.0.txt
- schema_modification.rdoc
- sharding.rdoc
- sql.rdoc
- testing.rdoc
- transactions.rdoc
- validations.rdoc
- virtual_rows.rdoc

### Class Index

Quicksearch

- Sequel
- Sequel::ADO
- Sequel::ADO::Database
- Sequel::ADO::Dataset
- Sequel::ADO::MSSQL
- Sequel::ADO::MSSQL::DatabaseMethods
- Sequel::ADO::MSSQL::Dataset
- Sequel::ASTTransformer
- Sequel::Access
- Sequel::Access::DatabaseMethods
- Sequel::Access::DatasetMethods
- Sequel::Adapter
- Sequel::AdapterNotFound
- Sequel::AdapterNotFound
- Sequel::Amalgalite
- Sequel::Amalgalite::Database
- Sequel::Amalgalite::Dataset
- Sequel::Amalgalite::SequelTypeMap
- Sequel::ArbitraryServers
- Sequel::BasicObject
- Sequel::ColumnsIntrospection
- Sequel::ConnectionPool
- Sequel::ConnectionPool::ClassMethods
- Sequel::DB2
- Sequel::DB2::DB2Error
- Sequel::DB2::Database
- Sequel::DB2::DatabaseMethods
- Sequel::DB2::Dataset
- Sequel::DB2::DatasetMethods
- Sequel::DBI
- Sequel::DBI::Database
- Sequel::DBI::Dataset
- Sequel::DataObjects
- Sequel::DataObjects::Database
- Sequel::DataObjects::Dataset
- Sequel::DataObjects::MySQL
- Sequel::DataObjects::MySQL::DatabaseMethods
- Sequel::DataObjects::MySQL::Dataset
- Sequel::DataObjects::Postgres
- Sequel::DataObjects::Postgres::AdapterMethods
- Sequel::DataObjects::Postgres::DatabaseMethods
- Sequel::DataObjects::Postgres::Dataset
- Sequel::DataObjects::SQLite
- Sequel::DataObjects::SQLite::DatabaseMethods
- Sequel::DataObjects::SQLite::Dataset
- Sequel::Database
- Sequel::DatabaseConnectionError
- Sequel::DatabaseDisconnectError
- Sequel::DatabaseError
- Sequel::Dataset
- Sequel::Dataset
- Sequel::Dataset::ArgumentMapper
- Sequel::Dataset::BindArgumentMethods
- Sequel::Dataset::Pagination
- Sequel::Dataset::PreparedStatementMethods
- Sequel::Dataset::QueryBlockCopy
- Sequel::Dataset::StoredProcedureMethods
- Sequel::Dataset::StoredProcedures
- Sequel::Dataset::TYPE_TRANSLATOR
- Sequel::Dataset::UnnumberedArgumentMapper
- Sequel::EmulateOffsetWithRowNumber
- Sequel::Error
- Sequel::Firebird
- Sequel::Firebird::Database
- Sequel::Firebird::DatabaseMethods
- Sequel::Firebird::Dataset
- Sequel::Firebird::DatasetMethods
- Sequel::HookFailed
- Sequel::HookFailed
- Sequel::IBMDB
- Sequel::IBMDB::Connection
- Sequel::IBMDB::Connection::Error
- Sequel::IBMDB::Database
- Sequel::IBMDB::Dataset
- Sequel::IBMDB::Dataset::CallableStatementMethods
- Sequel::IBMDB::Dataset::PreparedStatementMethods
- Sequel::IBMDB::Statement
- Sequel::Inflections
- Sequel::Informix
- Sequel::Informix::Database
- Sequel::Informix::DatabaseMethods
- Sequel::Informix::Dataset
- Sequel::Informix::DatasetMethods
- Sequel::IntegerMigrator
- Sequel::InvalidOperation
- Sequel::InvalidOperation
- Sequel::InvalidValue
- Sequel::InvalidValue
- Sequel::JDBC
- Sequel::JDBC::AS400
- Sequel::JDBC::AS400::DatabaseMethods
- Sequel::JDBC::AS400::Dataset
- Sequel::JDBC::DB2
- Sequel::JDBC::DB2::DatabaseMethods
- Sequel::JDBC::DB2::Dataset
- Sequel::JDBC::Database
- Sequel::JDBC::Derby
- Sequel::JDBC::Derby::DatabaseMethods
- Sequel::JDBC::Derby::Dataset
- Sequel::JDBC::Firebird
- Sequel::JDBC::Firebird::DatabaseMethods
- Sequel::JDBC::Firebird::Dataset
- Sequel::JDBC::H2
- Sequel::JDBC::H2::DatabaseMethods
- Sequel::JDBC::H2::Dataset
- Sequel::JDBC::HSQLDB
- Sequel::JDBC::HSQLDB::DatabaseMethods
- Sequel::JDBC::HSQLDB::Dataset
- Sequel::JDBC::Informix
- Sequel::JDBC::Informix::DatabaseMethods
- Sequel::JDBC::Informix::Dataset
- Sequel::JDBC::JTDS
- Sequel::JDBC::JTDS::DatabaseMethods
- Sequel::JDBC::JTDS::Dataset
- Sequel::JDBC::JavaLang
- Sequel::JDBC::JavaSQL
- Sequel::JDBC::JavaxNaming
- Sequel::JDBC::MSSQL
- Sequel::JDBC::MSSQL::DatabaseMethods
- Sequel::JDBC::MySQL
- Sequel::JDBC::MySQL::DatabaseMethods
- Sequel::JDBC::MySQL::Dataset
- Sequel::JDBC::Oracle
- Sequel::JDBC::Oracle::DatabaseMethods
- Sequel::JDBC::Oracle::Dataset
- Sequel::JDBC::Postgres
- Sequel::JDBC::Postgres::AdapterMethods
- Sequel::JDBC::Postgres::DatabaseMethods
- Sequel::JDBC::Postgres::Dataset
- Sequel::JDBC::SQLServer
- Sequel::JDBC::SQLServer::DatabaseMethods
- Sequel::JDBC::SQLServer::DatabaseMethods::MetadataDatasetMethods
- Sequel::JDBC::SQLServer::Dataset
- Sequel::JDBC::SQLite
- Sequel::JDBC::SQLite::DatabaseMethods
- Sequel::JDBC::SQLite::Dataset
- Sequel::JDBC::Transactions
- Sequel::LiteralString
- Sequel::LooserTypecasting
- Sequel::MSSQL
- Sequel::MSSQL::DatabaseMethods
- Sequel::MSSQL::DatasetMethods
- Sequel::Metaprogramming
- Sequel::Migration
- Sequel::MigrationAlterTableReverser
- Sequel::MigrationDSL
- Sequel::MigrationReverser
- Sequel::Migrator
- Sequel::Migrator::Error
- Sequel::Mock
- Sequel::Mock::Connection
- Sequel::Mock::Database
- Sequel::Mock::Dataset
- Sequel::Model
- Sequel::Model::Associations
- Sequel::Model::Associations::AssociationDatasetMethods
- Sequel::Model::Associations::AssociationReflection
- Sequel::Model::Associations::ClassMethods
- Sequel::Model::Associations::DatasetMethods
- Sequel::Model::Associations::EagerGraphLoader
- Sequel::Model::Associations::InstanceMethods
- Sequel::Model::Associations::ManyToManyAssociationReflection
- Sequel::Model::Associations::ManyToOneAssociationReflection
- Sequel::Model::Associations::OneToManyAssociationReflection
- Sequel::Model::Associations::OneToOneAssociationReflection
- Sequel::Model::ClassMethods
- Sequel::Model::DatasetMethods
- Sequel::Model::Errors
- Sequel::Model::InstanceMethods
- Sequel::MySQL
- Sequel::MySQL::DatabaseMethods
- Sequel::MySQL::DatasetMethods
- Sequel::MySQL::DatasetMethods::CallableStatementMethods
- Sequel::MySQL::DatasetMethods::PreparedStatementMethods
- Sequel::MySQL::DatasetMethods::StoredProcedureMethods
- Sequel::MySQL::PreparedStatements
- Sequel::MySQL::PreparedStatements::DatabaseMethods
- Sequel::Mysql2
- Sequel::Mysql2::Database
- Sequel::Mysql2::Dataset
- Sequel::NamedTimezones
- Sequel::NoExistingObject
- Sequel::NoExistingObject
- Sequel::NotImplemented
- Sequel::ODBC
- Sequel::ODBC::DB2
- Sequel::ODBC::DB2::DatabaseMethods
- Sequel::ODBC::DB2::Dataset
- Sequel::ODBC::Database
- Sequel::ODBC::Dataset
- Sequel::ODBC::MSSQL
- Sequel::ODBC::MSSQL::DatabaseMethods
- Sequel::ODBC::MSSQL::Dataset
- Sequel::OpenBase
- Sequel::OpenBase::Database
- Sequel::OpenBase::Dataset
- Sequel::Oracle
- Sequel::Oracle::Database
- Sequel::Oracle::DatabaseMethods
- Sequel::Oracle::DatasetMethods
- Sequel::Plugins
- Sequel::Plugins::ActiveModel
- Sequel::Plugins::ActiveModel::ClassMethods
- Sequel::Plugins::ActiveModel::InstanceMethods
- Sequel::Plugins::AssociationAutoreloading
- Sequel::Plugins::AssociationAutoreloading::ClassMethods
- Sequel::Plugins::AssociationDependencies
- Sequel::Plugins::AssociationDependencies::ClassMethods
- Sequel::Plugins::AssociationDependencies::InstanceMethods
- Sequel::Plugins::AssociationPks
- Sequel::Plugins::AssociationPks::ClassMethods
- Sequel::Plugins::AssociationPks::InstanceMethods
- Sequel::Plugins::AssociationProxies
- Sequel::Plugins::AssociationProxies::AssociationProxy
- Sequel::Plugins::AssociationProxies::ClassMethods
- Sequel::Plugins::BooleanReaders
- Sequel::Plugins::BooleanReaders::ClassMethods
- Sequel::Plugins::Caching
- Sequel::Plugins::Caching::ClassMethods
- Sequel::Plugins::Caching::InstanceMethods
- Sequel::Plugins::ClassTableInheritance
- Sequel::Plugins::ClassTableInheritance::ClassMethods
- Sequel::Plugins::ClassTableInheritance::InstanceMethods
- Sequel::Plugins::Composition
- Sequel::Plugins::Composition::ClassMethods
- Sequel::Plugins::Composition::InstanceMethods
- Sequel::Plugins::DatasetAssociations
- Sequel::Plugins::DatasetAssociations::ClassMethods
- Sequel::Plugins::DatasetAssociations::DatasetMethods
- Sequel::Plugins::DefaultsSetter
- Sequel::Plugins::DefaultsSetter::ClassMethods
- Sequel::Plugins::DefaultsSetter::InstanceMethods
- Sequel::Plugins::ForceEncoding
- Sequel::Plugins::ForceEncoding::ClassMethods
- Sequel::Plugins::ForceEncoding::InstanceMethods
- Sequel::Plugins::HookClassMethods
- Sequel::Plugins::HookClassMethods::ClassMethods
- Sequel::Plugins::HookClassMethods::InstanceMethods
- Sequel::Plugins::IdentityMap
- Sequel::Plugins::IdentityMap::ClassMethods
- Sequel::Plugins::IdentityMap::InstanceMethods
- Sequel::Plugins::InstanceFilters
- Sequel::Plugins::InstanceFilters::InstanceMethods
- Sequel::Plugins::InstanceHooks
- Sequel::Plugins::InstanceHooks::InstanceMethods
- Sequel::Plugins::JsonSerializer
- Sequel::Plugins::JsonSerializer::ClassMethods
- Sequel::Plugins::JsonSerializer::DatasetMethods
- Sequel::Plugins::JsonSerializer::InstanceMethods
- Sequel::Plugins::JsonSerializer::Literal
- Sequel::Plugins::LazyAttributes
- Sequel::Plugins::LazyAttributes::ClassMethods
- Sequel::Plugins::LazyAttributes::InstanceMethods
- Sequel::Plugins::List
- Sequel::Plugins::List::ClassMethods
- Sequel::Plugins::List::InstanceMethods
- Sequel::Plugins::ManyThroughMany
- Sequel::Plugins::ManyThroughMany::ClassMethods
- Sequel::Plugins::ManyThroughMany::DatasetMethods
- Sequel::Plugins::ManyThroughMany::ManyThroughManyAssociationReflection
- Sequel::Plugins::NestedAttributes
- Sequel::Plugins::NestedAttributes::ClassMethods
- Sequel::Plugins::NestedAttributes::InstanceMethods
- Sequel::Plugins::OptimisticLocking
- Sequel::Plugins::OptimisticLocking::ClassMethods
- Sequel::Plugins::OptimisticLocking::InstanceMethods
- Sequel::Plugins::PreparedStatements
- Sequel::Plugins::PreparedStatements::ClassMethods
- Sequel::Plugins::PreparedStatements::InstanceMethods
- Sequel::Plugins::PreparedStatementsAssociations
- Sequel::Plugins::PreparedStatementsAssociations::ClassMethods
- Sequel::Plugins::PreparedStatementsAssociations::InstanceMethods
- Sequel::Plugins::PreparedStatementsSafe
- Sequel::Plugins::PreparedStatementsSafe::ClassMethods
- Sequel::Plugins::PreparedStatementsSafe::InstanceMethods
- Sequel::Plugins::PreparedStatementsWithPk
- Sequel::Plugins::PreparedStatementsWithPk::ClassMethods
- Sequel::Plugins::PreparedStatementsWithPk::DatasetMethods
- Sequel::Plugins::RcteTree
- Sequel::Plugins::Schema
- Sequel::Plugins::Schema::ClassMethods
- Sequel::Plugins::Serialization
- Sequel::Plugins::Serialization::ClassMethods
- Sequel::Plugins::Serialization::InstanceMethods
- Sequel::Plugins::SerializationModificationDetection
- Sequel::Plugins::SerializationModificationDetection::InstanceMethods
- Sequel::Plugins::Sharding
- Sequel::Plugins::Sharding::ClassMethods
- Sequel::Plugins::Sharding::DatasetMethods
- Sequel::Plugins::Sharding::InstanceMethods
- Sequel::Plugins::SingleTableInheritance
- Sequel::Plugins::SingleTableInheritance::ClassMethods
- Sequel::Plugins::SingleTableInheritance::InstanceMethods
- Sequel::Plugins::SkipCreateRefresh
- Sequel::Plugins::SkipCreateRefresh::InstanceMethods
- Sequel::Plugins::StringStripper
- Sequel::Plugins::StringStripper::InstanceMethods
- Sequel::Plugins::Subclasses
- Sequel::Plugins::Subclasses::ClassMethods
- Sequel::Plugins::TacticalEagerLoading
- Sequel::Plugins::TacticalEagerLoading::DatasetMethods
- Sequel::Plugins::TacticalEagerLoading::InstanceMethods
- Sequel::Plugins::Timestamps
- Sequel::Plugins::Timestamps::ClassMethods
- Sequel::Plugins::Timestamps::InstanceMethods
- Sequel::Plugins::Touch
- Sequel::Plugins::Touch::ClassMethods
- Sequel::Plugins::Touch::InstanceMethods
- Sequel::Plugins::Tree
- Sequel::Plugins::Tree::ClassMethods
- Sequel::Plugins::Tree::InstanceMethods
- Sequel::Plugins::Tree::SingleRoot
- Sequel::Plugins::Tree::SingleRoot::ClassMethods
- Sequel::Plugins::Tree::SingleRoot::InstanceMethods
- Sequel::Plugins::Tree::TreeMultipleRootError
- Sequel::Plugins::TypecastOnLoad
- Sequel::Plugins::TypecastOnLoad::ClassMethods
- Sequel::Plugins::TypecastOnLoad::InstanceMethods
- Sequel::Plugins::UpdatePrimaryKey
- Sequel::Plugins::UpdatePrimaryKey::ClassMethods
- Sequel::Plugins::UpdatePrimaryKey::InstanceMethods
- Sequel::Plugins::ValidationClassMethods
- Sequel::Plugins::ValidationClassMethods::ClassMethods
- Sequel::Plugins::ValidationClassMethods::ClassMethods::Generator
- Sequel::Plugins::ValidationClassMethods::InstanceMethods
- Sequel::Plugins::ValidationHelpers
- Sequel::Plugins::ValidationHelpers::InstanceMethods
- Sequel::Plugins::XmlSerializer
- Sequel::Plugins::XmlSerializer::ClassMethods
- Sequel::Plugins::XmlSerializer::DatasetMethods
- Sequel::Plugins::XmlSerializer::InstanceMethods
- Sequel::PoolTimeout
- Sequel::PoolTimeout
- Sequel::Postgres
- Sequel::Postgres::AdapterMethods
- Sequel::Postgres::DatabaseMethods
- Sequel::Postgres::DatasetMethods
- Sequel::Postgres::DatasetMethods::PreparedStatementMethods
- Sequel::PrettyTable
- Sequel::Progress
- Sequel::Progress::DatabaseMethods
- Sequel::Progress::DatasetMethods
- Sequel::Qualifier
- Sequel::Rollback
- Sequel::Rollback
- Sequel::SQL
- Sequel::SQL::AliasMethods
- Sequel::SQL::AliasedExpression
- Sequel::SQL::BitwiseMethods
- Sequel::SQL::Blob
- Sequel::SQL::BooleanConstant
- Sequel::SQL::BooleanExpression
- Sequel::SQL::BooleanMethods
- Sequel::SQL::CaseExpression
- Sequel::SQL::Cast
- Sequel::SQL::CastMethods
- Sequel::SQL::ColumnAll
- Sequel::SQL::ComplexExpression
- Sequel::SQL::ComplexExpressionMethods
- Sequel::SQL::Constant
- Sequel::SQL::Constants
- Sequel::SQL::Expression
- Sequel::SQL::Function
- Sequel::SQL::GenericComplexExpression
- Sequel::SQL::GenericExpression
- Sequel::SQL::Identifier
- Sequel::SQL::IdentifierMethods
- Sequel::SQL::InequalityMethods
- Sequel::SQL::JoinClause
- Sequel::SQL::JoinOnClause
- Sequel::SQL::JoinUsingClause
- Sequel::SQL::NegativeBooleanConstant
- Sequel::SQL::NoBooleanInputMethods
- Sequel::SQL::NumericExpression
- Sequel::SQL::NumericMethods
- Sequel::SQL::OrderMethods
- Sequel::SQL::OrderedExpression
- Sequel::SQL::PlaceholderLiteralString
- Sequel::SQL::QualifiedIdentifier
- Sequel::SQL::QualifyingMethods
- Sequel::SQL::StringConcatenationMethods
- Sequel::SQL::StringExpression
- Sequel::SQL::StringMethods
- Sequel::SQL::Subscript
- Sequel::SQL::SubscriptMethods
- Sequel::SQL::ValueList
- Sequel::SQL::ValueList
- Sequel::SQL::VirtualRow
- Sequel::SQL::Window
- Sequel::SQL::WindowFunction
- Sequel::SQLTime
- Sequel::SQLite
- Sequel::SQLite::DatabaseMethods
- Sequel::SQLite::DatasetMethods
- Sequel::Schema
- Sequel::Schema::AlterTableGenerator
- Sequel::Schema::Generator
- Sequel::ServerBlock
- Sequel::ShardedSingleConnectionPool
- Sequel::ShardedThreadedConnectionPool
- Sequel::SimpleMigration
- Sequel::SingleConnectionPool
- Sequel::Swift
- Sequel::Swift::Database
- Sequel::Swift::Dataset
- Sequel::Swift::MySQL
- Sequel::Swift::MySQL::DatabaseMethods
- Sequel::Swift::MySQL::Dataset
- Sequel::Swift::Postgres
- Sequel::Swift::Postgres::AdapterMethods
- Sequel::Swift::Postgres::DatabaseMethods
- Sequel::Swift::Postgres::Dataset
- Sequel::Swift::SQLite
- Sequel::Swift::SQLite::DatabaseMethods
- Sequel::Swift::SQLite::Dataset
- Sequel::ThreadLocalTimezones
- Sequel::ThreadedConnectionPool
- Sequel::ThreadedServerBlock
- Sequel::TimestampMigrator
- Sequel::Timezones
- Sequel::TinyTDS
- Sequel::TinyTDS::Database
- Sequel::TinyTDS::Dataset
- Sequel::TinyTDS::Dataset::ArgumentMapper
- Sequel::TinyTDS::Dataset::PreparedStatementMethods
- Sequel::ToDot
- Sequel::UnbindDuplicate
- Sequel::Unbinder
- Sequel::UndefinedAssociation
- Sequel::UnthreadedServerBlock
- Sequel::ValidationFailed
- Dataset
- Dataset::ArgumentMapper
- Dataset::BindArgumentMethods
- Dataset::PreparedStatementMethods
- String
- String::Inflections
- Array
- FalseClass
- Hash
- NilClass
- Numeric
- Object
- PGconn
- PGresult
- Proc
- Symbol
- TrueClass

No matching classes.

# Sequel::Postgres::DatabaseMethods

Methods shared by Database instances that connect to PostgreSQL.

### Constants

EXCLUDE_SCHEMAS
PREPARED_ARG_PLACEHOLDER
RE_CURRVAL_ERROR
SYSTEM_TABLE_REGEXP

### Public Instance Methods

commit_prepared_transaction(transaction_id) click to toggle source

Commit an existing prepared transaction with the given transaction identifier string.

         # File lib/sequel/adapters/shared/postgres.rb, line 167
    167:       def commit_prepared_transaction(transaction_id)
    168:         run("COMMIT PREPARED #{literal(transaction_id)}")
    169:       end

create_function(name, definition, opts={}) click to toggle source

Creates the function in the database. Arguments:

- name : name of the function to create

- definition : string definition of the function, or object file for a dynamically loaded C function.

- opts : options hash:

  - :args : function arguments, can be either a symbol or string specifying a type or an array of 1-3 elements:

    - element 1 : argument data type

    - element 2 : argument name

    - element 3 : argument mode (e.g. in, out, inout)

  - :behavior : Should be IMMUTABLE, STABLE, or VOLATILE. PostgreSQL assumes VOLATILE by default.

  - :cost : The estimated cost of the function, used by the query planner.

  - :language : The language the function uses. SQL is the default.

  - :link_symbol : For a dynamically loaded see function, the function’s link symbol if different from the definition argument.

  - :returns : The data type returned by the function. If you are using OUT or INOUT argument modes, this is ignored. Otherwise, if this is not specified, void is used by default to specify the function is not supposed to return a value.

  - :rows : The estimated number of rows the function will return. Only use if the function returns SETOF something.

  - :security_definer : Makes the privileges of the function the same as the privileges of the user who defined the function instead of the privileges of the user who runs the function. There are security implications when doing this, see the PostgreSQL documentation.

  - :set : Configuration variables to set while the function is being run, can be a hash or an array of two pairs. search_path is often used here if :security_definer is used.

  - :strict : Makes the function return NULL when any argument is NULL.

         # File lib/sequel/adapters/shared/postgres.rb, line 191
    191:       def create_function(name, definition, opts={})
    192:         self << create_function_sql(name, definition, opts)
    193:       end

create_language(name, opts={}) click to toggle source

Create the procedural language in the database. Arguments:

- name : Name of the procedural language (e.g. plpgsql)

- opts : options hash:

  - :handler : The name of a previously registered function used as a call handler for this language.

  - :replace: Replace the installed language if it already exists (on PostgreSQL 9.0+).

  - :trusted : Marks the language being created as trusted, allowing unprivileged users to create functions using this language.

  - :validator : The name of previously registered function used as a validator of functions defined in this language.

         # File lib/sequel/adapters/shared/postgres.rb, line 202
    202:       def create_language(name, opts={})
    203:         self << create_language_sql(name, opts)
    204:       end

create_schema(name) click to toggle source

Create a schema in the database. Arguments:

- name : Name of the schema (e.g. admin)

         # File lib/sequel/adapters/shared/postgres.rb, line 208
    208:       def create_schema(name)
    209:         self << create_schema_sql(name)
    210:       end

create_trigger(table, name, function, opts={}) click to toggle source

Create a trigger in the database. Arguments:

- table : the table on which this trigger operates

- name : the name of this trigger

- function : the function to call for this trigger, which should return type trigger.

- opts : options hash:

  - :after : Calls the trigger after execution instead of before.

  - :args : An argument or array of arguments to pass to the function.

  - :each_row : Calls the trigger for each row instead of for each statement.

  - :events : Can be :insert, :update, :delete, or an array of any of those. Calls the trigger whenever that type of statement is used. By default, the trigger is called for insert, update, or delete.

         # File lib/sequel/adapters/shared/postgres.rb, line 222
    222:       def create_trigger(table, name, function, opts={})
    223:         self << create_trigger_sql(table, name, function, opts)
    224:       end

database_type() click to toggle source

PostgreSQL uses the :postgres database type.

         # File lib/sequel/adapters/shared/postgres.rb, line 227
    227:       def database_type
    228:         :postgres
    229:       end

drop_function(name, opts={}) click to toggle source

Drops the function from the database. Arguments:

- name : name of the function to drop

- opts : options hash:

  - :args : The arguments for the function. See create_function_sql.

  - :cascade : Drop other objects depending on this function.

  - :if_exists : Don’t raise an error if the function doesn’t exist.

         # File lib/sequel/adapters/shared/postgres.rb, line 237
    237:       def drop_function(name, opts={})
    238:         self << drop_function_sql(name, opts)
    239:       end

drop_language(name, opts={}) click to toggle source

Drops a procedural language from the database. Arguments:

- name : name of the procedural language to drop

- opts : options hash:

  - :cascade : Drop other objects depending on this function.

  - :if_exists : Don’t raise an error if the function doesn’t exist.

         # File lib/sequel/adapters/shared/postgres.rb, line 246
    246:       def drop_language(name, opts={})
    247:         self << drop_language_sql(name, opts)
    248:       end

drop_schema(name, opts={}) click to toggle source

Drops a schema from the database. Arguments:

- name : name of the schema to drop

- opts : options hash:

  - :cascade : Drop all objects in this schema.

  - :if_exists : Don’t raise an error if the schema doesn’t exist.

         # File lib/sequel/adapters/shared/postgres.rb, line 255
    255:       def drop_schema(name, opts={})
    256:         self << drop_schema_sql(name, opts)
    257:       end

drop_trigger(table, name, opts={}) click to toggle source

Drops a trigger from the database. Arguments:

- table : table from which to drop the trigger

- name : name of the trigger to drop

- opts : options hash:

  - :cascade : Drop other objects depending on this function.

  - :if_exists : Don’t raise an error if the function doesn’t exist.

         # File lib/sequel/adapters/shared/postgres.rb, line 265
    265:       def drop_trigger(table, name, opts={})
    266:         self << drop_trigger_sql(table, name, opts)
    267:       end

indexes(table, opts={}) click to toggle source

Use the pg_* system tables to determine indexes on a table

         # File lib/sequel/adapters/shared/postgres.rb, line 270
    270:       def indexes(table, opts={})
    271:         m = output_identifier_meth
    272:         im = input_identifier_meth
    273:         schema, table = schema_and_table(table)
    274:         range = 0...32
    275:         attnums = server_version >= 80100 ? SQL::Function.new(:ANY, :ind__indkey) : range.map{|x| SQL::Subscript.new(:ind__indkey, [x])}
    276:         ds = metadata_dataset.
    277:           from(:pg_class___tab).
    278:           join(:pg_index___ind, :indrelid=>:oid, im.call(table)=>:relname).
    279:           join(:pg_class___indc, :oid=>:indexrelid).
    280:           join(:pg_attribute___att, :attrelid=>:tab__oid, :attnum=>attnums).
    281:           filter(:indc__relkind=>'i', :ind__indisprimary=>false, :indexprs=>nil, :indpred=>nil).
    282:           order(:indc__relname, range.map{|x| [SQL::Subscript.new(:ind__indkey, [x]), x]}.case(32, :att__attnum)).
    283:           select(:indc__relname___name, :ind__indisunique___unique, :att__attname___column)
    284:
    285:         ds.join!(:pg_namespace___nsp, :oid=>:tab__relnamespace, :nspname=>schema.to_s) if schema
    286:         ds.filter!(:indisvalid=>true) if server_version >= 80200
    287:         ds.filter!(:indisready=>true, :indcheckxmin=>false) if server_version >= 80300
    288:
    289:         indexes = {}
    290:         ds.each do |r|
    291:           i = indexes[m.call(r[:name])] ||= {:columns=>[], :unique=>r[:unique]}
    292:           i[:columns] << m.call(r[:column])
    293:         end
    294:         indexes
    295:       end

locks() click to toggle source

Dataset containing all current database locks

         # File lib/sequel/adapters/shared/postgres.rb, line 298
    298:       def locks
    299:         dataset.from(:pg_class).join(:pg_locks, :relation=>:relfilenode).select(:pg_class__relname, Sequel::SQL::ColumnAll.new(:pg_locks))
    300:       end

notify(channel, opts={}) click to toggle source

Notifies the given channel. See the PostgreSQL NOTIFY documentation. Options:

:payload | The payload string to use for the NOTIFY statement. Only supported in PostgreSQL 9.0+.
:server | The server to which to send the NOTIFY statement, if the sharding support is being used.

         # File lib/sequel/adapters/shared/postgres.rb, line 308
    308:       def notify(channel, opts={})
    309:         execute_ddl("NOTIFY #{channel}#{", #{literal(opts[:payload].to_s)}" if opts[:payload]}", opts)
    310:       end

primary_key(table, opts={}) click to toggle source

Return primary key for the given table.

         # File lib/sequel/adapters/shared/postgres.rb, line 313
    313:       def primary_key(table, opts={})
    314:         quoted_table = quote_schema_table(table)
    315:         return @primary_keys[quoted_table] if @primary_keys.include?(quoted_table)
    316:         @primary_keys[quoted_table] = if conn = opts[:conn]
    317:           conn.primary_key(*schema_and_table(table))
    318:         else
    319:           synchronize(opts[:server]){|con| con.primary_key(*schema_and_table(table))}
    320:         end
    321:       end

primary_key_sequence(table, opts={}) click to toggle source

Return the sequence providing the default for the primary key for the given table.

         # File lib/sequel/adapters/shared/postgres.rb, line 324
    324:       def primary_key_sequence(table, opts={})
    325:         quoted_table = quote_schema_table(table)
    326:         return @primary_key_sequences[quoted_table] if @primary_key_sequences.include?(quoted_table)
    327:         @primary_key_sequences[quoted_table] = if conn = opts[:conn]
    328:           conn.sequence(*schema_and_table(table))
    329:         else
    330:           synchronize(opts[:server]){|con| con.sequence(*schema_and_table(table))}
    331:         end
    332:       end

reset_primary_key_sequence(table) click to toggle source

Reset the primary key sequence for the given table, baseing it on the maximum current value of the table’s primary key.

         # File lib/sequel/adapters/shared/postgres.rb, line 336
    336:       def reset_primary_key_sequence(table)
    337:         pk = SQL::Identifier.new(primary_key(table))
    338:         return unless seq = primary_key_sequence(table)
    339:         db = self
    340:         seq_ds = db.from(seq.lit)
    341:         get{setval(seq, db[table].select{coalesce(max(pk)+seq_ds.select{:increment_by}, seq_ds.select(:min_value))}, false)}
    342:       end

rollback_prepared_transaction(transaction_id) click to toggle source

Rollback an existing prepared transaction with the given transaction identifier string.

         # File lib/sequel/adapters/shared/postgres.rb, line 346
    346:       def rollback_prepared_transaction(transaction_id)
    347:         run("ROLLBACK PREPARED #{literal(transaction_id)}")
    348:       end

serial_primary_key_options() click to toggle source

PostgreSQL uses SERIAL psuedo-type instead of AUTOINCREMENT for managing incrementing primary keys.

         # File lib/sequel/adapters/shared/postgres.rb, line 352
    352:       def serial_primary_key_options
    353:         {:primary_key => true, :serial => true, :type=>Integer}
    354:       end

server_version(server=nil) click to toggle source

The version of the PostgreSQL server, used for determining capability.

         # File lib/sequel/adapters/shared/postgres.rb, line 357
    357:       def server_version(server=nil)
    358:         return @server_version if @server_version
    359:         @server_version = synchronize(server) do |conn|
    360:           (conn.server_version rescue nil) if conn.respond_to?(:server_version)
    361:         end
    362:         unless @server_version
    363:           @server_version = if m = /PostgreSQL (\d+)\.(\d+)(?:(?:rc\d+)|\.(\d+))?/.match(fetch('SELECT version()').single_value)
    364:             (m[1].to_i * 10000) + (m[2].to_i * 100) + m[3].to_i
    365:           else
    366:             0
    367:           end
    368:         end
    369:         @server_version
    370:       end

supports_create_table_if_not_exists?() click to toggle source

PostgreSQL supports CREATE TABLE IF NOT EXISTS on 9.1+

         # File lib/sequel/adapters/shared/postgres.rb, line 380
    380:       def supports_create_table_if_not_exists?
    381:         server_version >= 90100
    382:       end

supports_prepared_transactions?() click to toggle source

PostgreSQL supports prepared transactions (two-phase commit) if max_prepared_transactions is greater than 0.

         # File lib/sequel/adapters/shared/postgres.rb, line 374
    374:       def supports_prepared_transactions?
    375:         return @supports_prepared_transactions if defined?(@supports_prepared_transactions)
    376:         @supports_prepared_transactions = self['SHOW max_prepared_transactions'].get.to_i > 0
    377:       end

supports_savepoints?() click to toggle source

PostgreSQL supports savepoints

         # File lib/sequel/adapters/shared/postgres.rb, line 385
    385:       def supports_savepoints?
    386:         true
    387:       end

supports_transaction_isolation_levels?() click to toggle source

PostgreSQL supports transaction isolation levels

         # File lib/sequel/adapters/shared/postgres.rb, line 390
    390:       def supports_transaction_isolation_levels?
    391:         true
    392:       end

tables(opts={}, &block) click to toggle source

Array of symbols specifying table names in the current database. The dataset used is yielded to the block if one is provided, otherwise, an array of symbols of table names is returned.

Options:

- :schema - The schema to search (default_schema by default)

- :server - The server to use

         # File lib/sequel/adapters/shared/postgres.rb, line 401
    401:       def tables(opts={}, &block)
    402:         pg_class_relname('r', opts, &block)
    403:       end

views(opts={}) click to toggle source

Array of symbols specifying view names in the current database.

Options:

- :schema - The schema to search (default_schema by default)

- :server - The server to use

         # File lib/sequel/adapters/shared/postgres.rb, line 410
    410:       def views(opts={})
    411:         pg_class_relname('v', opts)
    412:       end

### Private Instance Methods

commit_transaction(conn, opts={}) click to toggle source

If the :prepare option is given and we aren’t in a savepoint, prepare the transaction for a two-phase commit.

         # File lib/sequel/adapters/shared/postgres.rb, line 418
    418:       def commit_transaction(conn, opts={})
    419:         if (s = opts[:prepare]) && @transactions[conn][:savepoint_level] <= 1
    420:           log_connection_execute(conn, "PREPARE TRANSACTION #{literal(s)}")
    421:         else
    422:           super
    423:         end
    424:       end

create_function_sql(name, definition, opts={}) click to toggle source

SQL statement to create database function.

         # File lib/sequel/adapters/shared/postgres.rb, line 427
    427:       def create_function_sql(name, definition, opts={})
    428:         args = opts[:args]
    429:         if !opts[:args].is_a?(Array) || !opts[:args].any?{|a| Array(a).length == 3 and %OUT INOUT'.include?(a[2].to_s)}
    430:           returns = opts[:returns] || 'void'
    431:         end
    432:         language = opts[:language] || 'SQL'
    433:                 CREATE#{' OR REPLACE' if opts[:replace]} FUNCTION #{name}#{sql_function_args(args)}        #{"RETURNS #{returns}" if returns}        LANGUAGE #{language}        #{opts[:behavior].to_s.upcase if opts[:behavior]}        #{'STRICT' if opts[:strict]}        #{'SECURITY DEFINER' if opts[:security_definer]}        #{"COST #{opts[:cost]}" if opts[:cost]}        #{"ROWS #{opts[:rows]}" if opts[:rows]}        #{opts[:set].map{|k,v| " SET #{k} = #{v}"}.join("\n") if opts[:set]}        AS #{literal(definition.to_s)}#{", #{literal(opts[:link_symbol].to_s)}" if opts[:link_symbol]}
    434:       end

create_language_sql(name, opts={}) click to toggle source

SQL for creating a procedural language.

         # File lib/sequel/adapters/shared/postgres.rb, line 448
    448:       def create_language_sql(name, opts={})
    449:         "CREATE#{' OR REPLACE' if opts[:replace] && server_version >= 90000}#{' TRUSTED' if opts[:trusted]} LANGUAGE #{name}#{" HANDLER #{opts[:handler]}" if opts[:handler]}#{" VALIDATOR #{opts[:validator]}" if opts[:validator]}"
    450:       end

create_schema_sql(name) click to toggle source

SQL for creating a schema.

         # File lib/sequel/adapters/shared/postgres.rb, line 453
    453:       def create_schema_sql(name)
    454:         "CREATE SCHEMA #{quote_identifier(name)}"
    455:       end

create_trigger_sql(table, name, function, opts={}) click to toggle source

SQL for creating a database trigger.

         # File lib/sequel/adapters/shared/postgres.rb, line 458
    458:       def create_trigger_sql(table, name, function, opts={})
    459:         events = opts[:events] ? Array(opts[:events]) : [:insert, :update, :delete]
    460:         whence = opts[:after] ? 'AFTER' : 'BEFORE'
    461:         "CREATE TRIGGER #{name} #{whence} #{events.map{|e| e.to_s.upcase}.join(' OR ')} ON #{quote_schema_table(table)}#{' FOR EACH ROW' if opts[:each_row]} EXECUTE PROCEDURE #{function}(#{Array(opts[:args]).map{|a| literal(a)}.join(', ')})"
    462:       end

database_error_classes() click to toggle source

The errors that the main adapters can raise, depends on the adapter being used

         # File lib/sequel/adapters/shared/postgres.rb, line 465
    465:       def database_error_classes
    466:         CONVERTED_EXCEPTIONS
    467:       end

drop_function_sql(name, opts={}) click to toggle source

SQL for dropping a function from the database.

         # File lib/sequel/adapters/shared/postgres.rb, line 470
    470:       def drop_function_sql(name, opts={})
    471:         "DROP FUNCTION#{' IF EXISTS' if opts[:if_exists]} #{name}#{sql_function_args(opts[:args])}#{' CASCADE' if opts[:cascade]}"
    472:       end

drop_language_sql(name, opts={}) click to toggle source

SQL for dropping a procedural language from the database.

         # File lib/sequel/adapters/shared/postgres.rb, line 475
    475:       def drop_language_sql(name, opts={})
    476:         "DROP LANGUAGE#{' IF EXISTS' if opts[:if_exists]} #{name}#{' CASCADE' if opts[:cascade]}"
    477:       end

drop_schema_sql(name, opts={}) click to toggle source

SQL for dropping a schema from the database.

         # File lib/sequel/adapters/shared/postgres.rb, line 480
    480:       def drop_schema_sql(name, opts={})
    481:         "DROP SCHEMA#{' IF EXISTS' if opts[:if_exists]} #{quote_identifier(name)}#{' CASCADE' if opts[:cascade]}"
    482:       end

drop_trigger_sql(table, name, opts={}) click to toggle source

SQL for dropping a trigger from the database.

         # File lib/sequel/adapters/shared/postgres.rb, line 485
    485:       def drop_trigger_sql(table, name, opts={})
    486:         "DROP TRIGGER#{' IF EXISTS' if opts[:if_exists]} #{name} ON #{quote_schema_table(table)}#{' CASCADE' if opts[:cascade]}"
    487:       end

filter_schema(ds, opts) click to toggle source

If opts includes a :schema option, or a default schema is used, restrict the dataset to that schema. Otherwise, just exclude the default PostgreSQL schemas except for public.

         # File lib/sequel/adapters/shared/postgres.rb, line 491
    491:       def filter_schema(ds, opts)
    492:         if schema = opts[:schema] || default_schema
    493:           ds.filter(:pg_namespace__nspname=>schema.to_s)
    494:         else
    495:           ds.exclude(:pg_namespace__nspname=>EXCLUDE_SCHEMAS)
    496:         end
    497:       end

identifier_input_method_default() click to toggle source

PostgreSQL folds unquoted identifiers to lowercase, so it shouldn’t need to upcase identifiers on input.

         # File lib/sequel/adapters/shared/postgres.rb, line 500
    500:       def identifier_input_method_default
    501:         nil
    502:       end

identifier_output_method_default() click to toggle source

PostgreSQL folds unquoted identifiers to lowercase, so it shouldn’t need to upcase identifiers on output.

         # File lib/sequel/adapters/shared/postgres.rb, line 505
    505:       def identifier_output_method_default
    506:         nil
    507:       end

index_definition_sql(table_name, index) click to toggle source

PostgreSQL specific index SQL.

         # File lib/sequel/adapters/shared/postgres.rb, line 510
    510:       def index_definition_sql(table_name, index)
    511:         cols = index[:columns]
    512:         index_name = index[:name] || default_index_name(table_name, cols)
    513:         expr = if o = index[:opclass]
    514:           "(#{Array(cols).map{|c| "#{literal(c)} #{o}"}.join(', ')})"
    515:         else
    516:           literal(Array(cols))
    517:         end
    518:         unique = "UNIQUE " if index[:unique]
    519:         index_type = index[:type]
    520:         filter = index[:where] || index[:filter]
    521:         filter = " WHERE #{filter_expr(filter)}" if filter
    522:         case index_type
    523:         when :full_text
    524:           expr = "(to_tsvector(#{literal(index[:language] || 'simple')}, #{literal(dataset.send(:full_text_string_join, cols))}))"
    525:           index_type = :gin
    526:         when :spatial
    527:           index_type = :gist
    528:         end
    529:         "CREATE #{unique}INDEX #{quote_identifier(index_name)} ON #{quote_schema_table(table_name)} #{"USING #{index_type} " if index_type}#{expr}#{filter}"
    530:       end

insert_result(conn, table, values) click to toggle source

The result of the insert for the given table and values. If values is an array, assume the first column is the primary key and return that. If values is a hash, lookup the primary key for the table. If the primary key is present in the hash, return its value. Otherwise, look up the sequence for the table’s primary key. If one exists, return the last value the of the sequence for the connection.

         # File lib/sequel/adapters/shared/postgres.rb, line 538
    538:       def insert_result(conn, table, values)
    539:         case values
    540:         when Hash
    541:           return nil unless pk = primary_key(table, :conn=>conn)
    542:           if pk and pkv = values[pk.to_sym]
    543:             pkv
    544:           else
    545:             begin
    546:               if seq = primary_key_sequence(table, :conn=>conn)
    547:                 conn.last_insert_id(seq)
    548:               end
    549:             rescue Exception => e
    550:               raise_error(e, :classes=>CONVERTED_EXCEPTIONS) unless RE_CURRVAL_ERROR.match(e.message)
    551:             end
    552:           end
    553:         when Array
    554:           values.first
    555:         else
    556:           nil
    557:         end
    558:       end

log_connection_execute(conn, sql) click to toggle source

Don’t log, since logging is done by the underlying connection.

         # File lib/sequel/adapters/shared/postgres.rb, line 561
    561:       def log_connection_execute(conn, sql)
    562:         conn.execute(sql)
    563:       end

pg_class_relname(type, opts) click to toggle source

Backbone of the tables and views support.

         # File lib/sequel/adapters/shared/postgres.rb, line 566
    566:       def pg_class_relname(type, opts)
    567:         ds = metadata_dataset.from(:pg_class).filter(:relkind=>type).select(:relname).exclude(SQL::StringExpression.like(:relname, SYSTEM_TABLE_REGEXP)).server(opts[:server]).join(:pg_namespace, :oid=>:relnamespace)
    568:         ds = filter_schema(ds, opts)
    569:         m = output_identifier_meth
    570:         block_given? ? yield(ds) : ds.map{|r| m.call(r[:relname])}
    571:       end

prepared_arg_placeholder() click to toggle source

Use a dollar sign instead of question mark for the argument placeholder.

         # File lib/sequel/adapters/shared/postgres.rb, line 575
    575:       def prepared_arg_placeholder
    576:         PREPARED_ARG_PLACEHOLDER
    577:       end

remove_cached_schema(table) click to toggle source

Remove the cached entries for primary keys and sequences when a table is changed.

         # File lib/sequel/adapters/shared/postgres.rb, line 581
    581:       def remove_cached_schema(table)
    582:         tab = quote_schema_table(table)
    583:         @primary_keys.delete(tab)
    584:         @primary_key_sequences.delete(tab)
    585:         super
    586:       end

rename_table_sql(name, new_name) click to toggle source

SQL DDL statement for renaming a table. PostgreSQL doesn’t allow you to change a table’s schema in a rename table operation, so speciying a new schema in new_name will not have an effect.

         # File lib/sequel/adapters/shared/postgres.rb, line 590
    590:       def rename_table_sql(name, new_name)
    591:         "ALTER TABLE #{quote_schema_table(name)} RENAME TO #{quote_identifier(schema_and_table(new_name).last)}"
    592:       end

schema_autoincrementing_primary_key?(schema) click to toggle source

PostgreSQL’s autoincrementing primary keys are of type integer or bigint using a nextval function call as a default.

         # File lib/sequel/adapters/shared/postgres.rb, line 596
    596:       def schema_autoincrementing_primary_key?(schema)
    597:         super and schema[:db_type] =~ /\A(?:integer|bigint)\z/o and schema[:default]=~/\Anextval/o
    598:       end

schema_parse_table(table_name, opts) click to toggle source

The dataset used for parsing table schemas, using the pg_* system catalogs.

         # File lib/sequel/adapters/shared/postgres.rb, line 601
    601:       def schema_parse_table(table_name, opts)
    602:         m = output_identifier_meth(opts[:dataset])
    603:         m2 = input_identifier_meth(opts[:dataset])
    604:         ds = metadata_dataset.select(:pg_attribute__attname___name,
    605:             SQL::Function.new(:format_type, :pg_type__oid, :pg_attribute__atttypmod).as(:db_type),
    606:             SQL::Function.new(:pg_get_expr, :pg_attrdef__adbin, :pg_class__oid).as(:default),
    607:             SQL::BooleanExpression.new(:NOT, :pg_attribute__attnotnull).as(:allow_null),
    608:             SQL::Function.new(:COALESCE, SQL::BooleanExpression.from_value_pairs(:pg_attribute__attnum => SQL::Function.new(:ANY, :pg_index__indkey)), false).as(:primary_key),
    609:             :pg_namespace__nspname).
    610:           from(:pg_class).
    611:           join(:pg_attribute, :attrelid=>:oid).
    612:           join(:pg_type, :oid=>:atttypid).
    613:           join(:pg_namespace, :oid=>:pg_class__relnamespace).
    614:           left_outer_join(:pg_attrdef, :adrelid=>:pg_class__oid, :adnum=>:pg_attribute__attnum).
    615:           left_outer_join(:pg_index, :indrelid=>:pg_class__oid, :indisprimary=>true).
    616:           filter(:pg_attribute__attisdropped=>false).
    617:           filter{|o| o.pg_attribute__attnum > 0}.
    618:           filter(:pg_class__relname=>m2.call(table_name)).
    619:           order(:pg_attribute__attnum)
    620:         ds = filter_schema(ds, opts)
    621:         current_schema = nil
    622:         ds.map do |row|
    623:           sch = row.delete(:nspname)
    624:           if current_schema
    625:             if sch != current_schema
    626:               raise Error, "columns from tables in two separate schema were returned (please specify a schema): #{current_schema.inspect}, #{sch.inspect}"
    627:             end
    628:           else
    629:             current_schema = sch
    630:           end
    631:           row[:default] = nil if blank_object?(row[:default])
    632:           row[:type] = schema_column_type(row[:db_type])
    633:           [m.call(row.delete(:name)), row]
    634:         end
    635:       end

sql_function_args(args) click to toggle source

Turns an array of argument specifiers into an SQL fragment used for function arguments. See create_function_sql.

         # File lib/sequel/adapters/shared/postgres.rb, line 638
    638:       def sql_function_args(args)
    639:         "(#{Array(args).map{|a| Array(a).reverse.join(' ')}.join(', ')})"
    640:       end

type_literal_generic_bignum(column) click to toggle source

Handle bigserial type if :serial option is present

         # File lib/sequel/adapters/shared/postgres.rb, line 643
    643:       def type_literal_generic_bignum(column)
    644:         column[:serial] ? :bigserial : super
    645:       end

type_literal_generic_file(column) click to toggle source

PostgreSQL uses the bytea data type for blobs

         # File lib/sequel/adapters/shared/postgres.rb, line 648
    648:       def type_literal_generic_file(column)
    649:         :bytea
    650:       end

type_literal_generic_integer(column) click to toggle source

Handle serial type if :serial option is present

         # File lib/sequel/adapters/shared/postgres.rb, line 653
    653:       def type_literal_generic_integer(column)
    654:         column[:serial] ? :serial : super
    655:       end

type_literal_generic_string(column) click to toggle source

PostgreSQL prefers the text datatype. If a fixed size is requested, the char type is used. If the text type is specifically disallowed or there is a size specified, use the varchar type. Otherwise use the type type.

         # File lib/sequel/adapters/shared/postgres.rb, line 661
    661:       def type_literal_generic_string(column)
    662:         if column[:fixed]
    663:           "char(#{column[:size]||255})"
    664:         elsif column[:text] == false or column[:size]
    665:           "varchar(#{column[:size]||255})"
    666:         else
    667:           :text
    668:         end
    669:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.