123456789_123456789_123456789_123456789_123456789_

Module: PG

Overview

The top-level PG namespace.

Constant Summary

Constants - Included

CONNECTION_ALLOCATED, CONNECTION_AUTH_OK, CONNECTION_AWAITING_RESPONSE, CONNECTION_BAD, CONNECTION_CHECK_STANDBY, CONNECTION_CHECK_TARGET, CONNECTION_CHECK_WRITABLE, CONNECTION_CONSUME, CONNECTION_GSS_STARTUP, CONNECTION_MADE, CONNECTION_NEEDED, CONNECTION_OK, CONNECTION_SETENV, CONNECTION_SSL_STARTUP, CONNECTION_STARTED, DEF_PGPORT, INVALID_OID, INV_READ, INV_WRITE, InvalidOid, PGRES_BAD_RESPONSE, PGRES_COMMAND_OK, PGRES_COPY_BOTH, PGRES_COPY_IN, PGRES_COPY_OUT, PGRES_EMPTY_QUERY, PGRES_FATAL_ERROR, PGRES_NONFATAL_ERROR, PGRES_PIPELINE_ABORTED, PGRES_PIPELINE_SYNC, PGRES_POLLING_FAILED, PGRES_POLLING_OK, PGRES_POLLING_READING, PGRES_POLLING_WRITING, PGRES_SINGLE_TUPLE, PGRES_TUPLES_CHUNK, PGRES_TUPLES_OK, PG_DIAG_COLUMN_NAME, PG_DIAG_CONSTRAINT_NAME, PG_DIAG_CONTEXT, PG_DIAG_DATATYPE_NAME, PG_DIAG_INTERNAL_POSITION, PG_DIAG_INTERNAL_QUERY, PG_DIAG_MESSAGE_DETAIL, PG_DIAG_MESSAGE_HINT, PG_DIAG_MESSAGE_PRIMARY, PG_DIAG_SCHEMA_NAME, PG_DIAG_SEVERITY, PG_DIAG_SEVERITY_NONLOCALIZED, PG_DIAG_SOURCE_FILE, PG_DIAG_SOURCE_FUNCTION, PG_DIAG_SOURCE_LINE, PG_DIAG_SQLSTATE, PG_DIAG_STATEMENT_POSITION, PG_DIAG_TABLE_NAME, PQERRORS_DEFAULT, PQERRORS_SQLSTATE, PQERRORS_TERSE, PQERRORS_VERBOSE, PQPING_NO_ATTEMPT, PQPING_NO_RESPONSE, PQPING_OK, PQPING_REJECT, PQSHOW_CONTEXT_ALWAYS, PQSHOW_CONTEXT_ERRORS, PQSHOW_CONTEXT_NEVER, PQTRANS_ACTIVE, PQTRANS_IDLE, PQTRANS_INERROR, PQTRANS_INTRANS, PQTRANS_UNKNOWN, PQ_PIPELINE_ABORTED, PQ_PIPELINE_OFF, PQ_PIPELINE_ON, SEEK_CUR, SEEK_END, SEEK_SET

Class Method Summary

Class Method Details

.connect(*args, &block)

Convenience alias for Connection.new.

[ GitHub ]

  
# File 'lib/pg.rb', line 66

def self.connect( *args, &block )
	Connection.new( *args, &block )
end

.init_openssl(do_ssl, do_crypto) ⇒ nil

Allows applications to select which security libraries to initialize.

If your application initializes libssl and/or libcrypto libraries and libpq is built with SSL support, you should call init_openssl() to tell libpq that the libssl and/or libcrypto libraries have been initialized by your application, so that libpq will not also initialize those libraries.

When do_ssl is true, libpq will initialize the OpenSSL library before first opening a database connection. When do_crypto is true, the libcrypto library will be initialized. By default (if init_openssl() is not called), both libraries are initialized. When SSL support is not compiled in, this function is present but does nothing.

If your application uses and initializes either OpenSSL or its underlying libcrypto library, you must call this function with false for the appropriate parameter(s) before first opening a database connection. Also be sure that you have done that initialization before opening a database connection.

[ GitHub ]

  
# File 'ext/pg.c', line 303

static VALUE
pg_s_init_openssl(VALUE self, VALUE do_ssl, VALUE do_crypto)
{
	UNUSED( self );
	PQinitOpenSSL(pg_to_bool_int(do_ssl), pg_to_bool_int(do_crypto));
	return Qnil;
}

.init_ssl(do_ssl) ⇒ nil

Allows applications to select which security libraries to initialize.

This function is equivalent to PG.init_openssl(do_ssl, do_ssl) . It is sufficient for applications that initialize both or neither of OpenSSL and libcrypto.

[ GitHub ]

  
# File 'ext/pg.c', line 321

static VALUE
pg_s_init_ssl(VALUE self, VALUE do_ssl)
{
	UNUSED( self );
	PQinitSSL(pg_to_bool_int(do_ssl));
	return Qnil;
}

.isthreadsafeBoolean .is_threadsafe?Boolean .threadsafe?Boolean

Returns true if libpq is thread-safe, false otherwise.

[ GitHub ]

  
# File 'ext/pg.c', line 261

static VALUE
pg_s_threadsafe_p(VALUE self)
{
	UNUSED( self );
	return PQisthreadsafe() ? Qtrue : Qfalse;
}

.library_versionInteger

Get the version of the libpq library in use. The number is formed by converting the major, minor, and revision numbers into two-decimal- digit numbers and appending them together. For example, version 7.4.2 will be returned as 70402, and version 8.1 will be returned as 80100 (leading zeroes are not shown). Zero is returned if the connection is bad.

[ GitHub ]

  
# File 'ext/pg.c', line 245

static VALUE
pg_s_library_version(VALUE self)
{
	UNUSED( self );
	return INT2NUM(PQlibVersion());
}

.make_shareable(obj)

See additional method definition at line 71.

[ GitHub ]

  
# File 'lib/pg.rb', line 75

def self.make_shareable(obj)
	Ractor.make_shareable(obj)
end

.require_bigdecimal_without_warning

Ruby-3.4+ prints a warning, if bigdecimal is required but not in the Gemfile. But it’s a false positive, since we enable bigdecimal depending features only if it’s available. And most people don’t need these features.

[ GitHub ]

  
# File 'lib/pg.rb', line 137

def self.require_bigdecimal_without_warning
	oldverb, $VERBOSE = $VERBOSE, nil
	require "bigdecimal"
ensure
	$VERBOSE = oldverb
end

.version_string(include_buildnum = nil)

Get the PG library version.

include_buildnum is no longer used and any value passed will be ignored.

[ GitHub ]

  
# File 'lib/pg.rb', line 60

def self.version_string( include_buildnum=nil )
	"%s %s" % [ self.name, VERSION ]
end