Class PGconn
In: ext/pg.c
Parent: Object

The class to access PostgreSQL RDBMS, based on the libpq interface, provides convenient OO methods to interact with PostgreSQL.

For example, to send query to the database on the localhost:

   require 'pg'
   conn = PGconn.open(:dbname => 'test')
   res = conn.exec('SELECT $1 AS a, $2 AS b, $3 AS c',[1, 2, nil])
   # Equivalent to:
   #  res  = conn.exec('SELECT 1 AS a, 2 AS b, NULL AS c')

See the PGresult class for information on working with the results of a query.

Methods

async_exec   async_query   backend_pid   block   cancel   close   conndefaults   conndefaults   connect_poll   connect_start   connection_needs_password   connection_used_password   consume_input   db   describe_portal   describe_prepared   encrypt_password   error_message   escape   escape_bytea   escape_bytea   escape_string   escape_string   exec   exec_prepared   external_encoding   finish   flush   get_client_encoding   get_copy_data   get_last_result   get_result   host   internal_encoding   internal_encoding=   is_busy   isnonblocking   isthreadsafe   lo_close   lo_creat   lo_create   lo_export   lo_import   lo_lseek   lo_open   lo_read   lo_seek   lo_tell   lo_truncate   lo_unlink   lo_write   loclose   locreat   locreate   loexport   loimport   lolseek   loopen   loread   loseek   lotell   lotruncate   lounlink   lowrite   make_empty_pgresult   new   nonblocking?   notifies   notifies_wait   options   parameter_status   pass   port   prepare   protocol_version   put_copy_data   put_copy_end   query   quote_ident   quote_ident   reset   reset_poll   reset_start   send_describe_portal   send_describe_prepared   send_prepare   send_query   send_query_prepared   server_version   set_client_encoding   set_error_verbosity   set_notice_processor   set_notice_receiver   setnonblocking   socket   status   trace   transaction   transaction_status   tty   unescape_bytea   unescape_bytea   untrace   user   wait_for_notify  

Constants

VERSION = rb_str_new2(VERSION)   Library version
CONNECTION_OK = INT2FIX(CONNECTION_OK)   Connection succeeded
CONNECTION_BAD = INT2FIX(CONNECTION_BAD)   Connection failed
CONNECTION_STARTED = INT2FIX(CONNECTION_STARTED)   Waiting for connection to be made.
CONNECTION_MADE = INT2FIX(CONNECTION_MADE)   Connection OK; waiting to send.
CONNECTION_AWAITING_RESPONSE = INT2FIX(CONNECTION_AWAITING_RESPONSE)   Waiting for a response from the server.
CONNECTION_AUTH_OK = INT2FIX(CONNECTION_AUTH_OK)   Received authentication; waiting for backend start-up to finish.
CONNECTION_SSL_STARTUP = INT2FIX(CONNECTION_SSL_STARTUP)   Negotiating SSL encryption.
CONNECTION_SETENV = INT2FIX(CONNECTION_SETENV)   Negotiating environment-driven parameter settings.
PGRES_POLLING_READING = INT2FIX(PGRES_POLLING_READING)   Async connection is waiting to read
PGRES_POLLING_WRITING = INT2FIX(PGRES_POLLING_WRITING)   Async connection is waiting to write
PGRES_POLLING_FAILED = INT2FIX(PGRES_POLLING_FAILED)   Async connection failed or was reset
PGRES_POLLING_OK = INT2FIX(PGRES_POLLING_OK)   Async connection succeeded
PQTRANS_IDLE = INT2FIX(PQTRANS_IDLE)   Transaction is currently idle (transaction_status)
PQTRANS_ACTIVE = INT2FIX(PQTRANS_ACTIVE)   Transaction is currently active; query has been sent to the server, but not yet completed. (transaction_status)
PQTRANS_INTRANS = INT2FIX(PQTRANS_INTRANS)   Transaction is currently idle, in a valid transaction block (transaction_status)
PQTRANS_INERROR = INT2FIX(PQTRANS_INERROR)   Transaction is currently idle, in a failed transaction block (transaction_status)
PQTRANS_UNKNOWN = INT2FIX(PQTRANS_UNKNOWN)   Transaction‘s connection is bad (transaction_status)
PQERRORS_TERSE = INT2FIX(PQERRORS_TERSE)   Terse error verbosity level (set_error_verbosity)
PQERRORS_DEFAULT = INT2FIX(PQERRORS_DEFAULT)   Default error verbosity level (set_error_verbosity)
PQERRORS_VERBOSE = INT2FIX(PQERRORS_VERBOSE)   Verbose error verbosity level (set_error_verbosity)
INV_WRITE = INT2FIX(INV_WRITE)   Flag for lo_creat, lo_open — open for writing
INV_READ = INT2FIX(INV_READ)   Flag for lo_creat, lo_open — open for reading
SEEK_SET = INT2FIX(SEEK_SET)   Flag for lo_lseek — seek from object start
SEEK_CUR = INT2FIX(SEEK_CUR)   Flag for lo_lseek — seek from current position
SEEK_END = INT2FIX(SEEK_END)   Flag for lo_lseek — seek from object end

Public Class methods

Returns an array of hashes. Each hash has the keys:

+:keyword+
the name of the option
+:envvar+
the environment variable to fall back to
+:compiled+
the compiled in option as a secondary fallback
+:val+
the option‘s current value, or nil if not known
+:label+
the label for the field
+:dispchar+
"" for normal, "D" for debug, and "*" for password
+:dispsize+
field size

This is an asynchronous version of PGconn.connect().

Use PGconn#connect_poll to poll the status of the connection.

NOTE: this does not set the connection‘s client_encoding for you if Encoding.default_internal is set. To set it after the connection is established, call PGconn#internal_encoding=. You can also set it automatically by setting ENV[‘PGCLIENTENCODING’], or include the ‘options’ connection parameter.

This function is intended to be used by client applications that send commands like: +ALTER USER joe PASSWORD ‘pwd’+. The arguments are the cleartext password, and the SQL name of the user it is for.

Return value is the encrypted password.

Connection instance method for versions of 8.1 and higher of libpq uses PQescapeByteaConn, which is safer. Avoid calling as a class method, the class method uses the deprecated PQescapeBytea() API function.

Use the instance method version of this function, it is safer than the class method.

Escapes binary data for use within an SQL command with the type bytea.

Certain byte values must be escaped (but all byte values may be escaped) when used as part of a bytea literal in an SQL statement. In general, to escape a byte, it is converted into the three digit octal number equal to the octet value, and preceded by two backslashes. The single quote (’) and backslash (\) characters have special alternative escape sequences. escape_bytea performs this operation, escaping only the minimally required bytes.

Consider using exec_params, which avoids the need for passing values inside of SQL commands.

Connection instance method for versions of 8.1 and higher of libpq uses PQescapeStringConn, which is safer. Avoid calling as a class method, the class method uses the deprecated PQescapeString() API function.

Returns a SQL-safe version of the String str. This is the preferred way to make strings safe for inclusion in SQL queries.

Consider using exec_params, which avoids the need for passing values inside of SQL commands.

Encoding of escaped string will be equal to client encoding of connection.

Returns true if libpq is thread safe, false otherwise.

Create a connection to the specified server.

host
server hostname
hostaddr
server address (avoids hostname lookup, overrides host)
port
server port number
dbname
connecting database name
user
login user name
password
login password
connect_timeout
maximum time to wait for connection to succeed
options
backend options
tty
(ignored in newer versions of PostgreSQL)
sslmode
(disable|allow|prefer|require)
krbsrvname
kerberos service name
gsslib
GSS library to use for GSSAPI authentication
service
service name to use for additional parameters

Examples:

  # As a Hash
  PGconn.connect( :dbname => 'test', :port => 5432 )

  # As a String
  PGconn.connect( "dbname=test port=5432" )

  # As an Array
  PGconn.connect( nil, 5432, nil, nil, 'test', nil, nil )

If the Ruby default internal encoding is set (i.e., Encoding.default_internal != nil), the connection will have its client_encoding set accordingly.

@raises [PGError] if the connection fails.

Returns a string that is safe for inclusion in a SQL query as an identifier. Note: this is not a quote function for values, but for identifiers.

For example, in a typical SQL query: SELECT FOO FROM MYTABLE The identifier FOO is folded to lower case, so it actually means foo. If you really want to access the case-sensitive field name FOO, use this function like PGconn.quote_ident(‘FOO’), which will return "FOO" (with double-quotes). PostgreSQL will see the double-quotes, and it will not fold to lower case.

Similarly, this function also protects against special characters, and other things that might allow SQL injection if the identifier comes from an untrusted source.

Converts an escaped string representation of binary data into binary data — the reverse of escape_bytea. This is needed when retrieving bytea data in text format, but not when retrieving it in binary format.

Public Instance methods

This function has the same behavior as +PGconn#exec+, except that it‘s implemented using asynchronous command processing and ruby‘s rb_thread_select in order to allow other threads to process while waiting for the server to complete the request.

async_query(...)

Alias for async_exec

Returns the process ID of the backend server process for this connection. Note that this is a PID on database server host.

Blocks until the server is no longer busy, or until the optional timeout is reached, whichever comes first. timeout is measured in seconds and can be fractional.

Returns false if timeout is reached, true otherwise.

If true is returned, +conn.is_busy+ will return false and +conn.get_result+ will not block.

Requests cancellation of the command currently being processed.

Returns nil on success, or a string containing the error message if a failure occurs.

close()

Alias for finish

Returns an array of hashes. Each hash has the keys:

+:keyword+
the name of the option
+:envvar+
the environment variable to fall back to
+:compiled+
the compiled in option as a secondary fallback
+:val+
the option‘s current value, or nil if not known
+:label+
the label for the field
+:dispchar+
"" for normal, "D" for debug, and "*" for password
+:dispsize+
field size

Returns one of:

PGRES_POLLING_READING
wait until the socket is ready to read
PGRES_POLLING_WRITING
wait until the socket is ready to write
PGRES_POLLING_FAILED
the asynchronous connection has failed
PGRES_POLLING_OK
the asynchronous connection is ready

Example:

  conn = PGconn.connect_start("dbname=mydatabase")
  socket = IO.for_fd(conn.socket)
  status = conn.connect_poll
  while(status != PGconn::PGRES_POLLING_OK) do
    # do some work while waiting for the connection to complete
    if(status == PGconn::PGRES_POLLING_READING)
      if(not select([socket], [], [], 10.0))
        raise "Asynchronous connection timed out!"
      end
    elsif(status == PGconn::PGRES_POLLING_WRITING)
      if(not select([], [socket], [], 10.0))
        raise "Asynchronous connection timed out!"
      end
    end
    status = conn.connect_poll
  end
  # now conn.status == CONNECTION_OK, and connection
  # is ready.

Returns true if the authentication method required a password, but none was available. false otherwise.

Returns true if the authentication method used a caller-supplied password, false otherwise.

If input is available from the server, consume it. After calling consume_input, you can check is_busy or notifies to see if the state has changed.

Returns the connected database name.

Retrieve information about the portal portal_name.

Retrieve information about the prepared statement statement_name.

Returns the error message about connection.

escape(p1)

Alias for escape_string

Connection instance method for versions of 8.1 and higher of libpq uses PQescapeByteaConn, which is safer. Avoid calling as a class method, the class method uses the deprecated PQescapeBytea() API function.

Use the instance method version of this function, it is safer than the class method.

Escapes binary data for use within an SQL command with the type bytea.

Certain byte values must be escaped (but all byte values may be escaped) when used as part of a bytea literal in an SQL statement. In general, to escape a byte, it is converted into the three digit octal number equal to the octet value, and preceded by two backslashes. The single quote (’) and backslash (\) characters have special alternative escape sequences. escape_bytea performs this operation, escaping only the minimally required bytes.

Consider using exec_params, which avoids the need for passing values inside of SQL commands.

Connection instance method for versions of 8.1 and higher of libpq uses PQescapeStringConn, which is safer. Avoid calling as a class method, the class method uses the deprecated PQescapeString() API function.

Returns a SQL-safe version of the String str. This is the preferred way to make strings safe for inclusion in SQL queries.

Consider using exec_params, which avoids the need for passing values inside of SQL commands.

Encoding of escaped string will be equal to client encoding of connection.

Sends SQL query request specified by sql to PostgreSQL. Returns a PGresult instance on success. On failure, it raises a PGError exception.

params is an optional array of the bind parameters for the SQL query. Each element of the params array may be either:

  a hash of the form:
    {:value  => String (value of bind parameter)
     :type   => Fixnum (oid of type of bind parameter)
     :format => Fixnum (0 for text, 1 for binary)
    }
  or, it may be a String. If it is a string, that is equivalent to the hash:
    { :value => <string value>, :type => 0, :format => 0 }

PostgreSQL bind parameters are represented as $1, $1, $2, etc., inside the SQL query. The 0th element of the params array is bound to $1, the 1st element is bound to $2, etc. nil is treated as NULL.

If the types are not specified, they will be inferred by PostgreSQL. Instead of specifying type oids, it‘s recommended to simply add explicit casts in the query to ensure that the right type is used.

For example: "SELECT $1::int"

The optional result_format should be 0 for text results, 1 for binary.

If the optional code block is given, it will be passed result as an argument, and the PGresult object will automatically be cleared when the block terminates. In this instance, conn.exec returns the value of the block.

Execute prepared named statement specified by statement_name. Returns a PGresult instance on success. On failure, it raises a PGError exception.

params is an array of the optional bind parameters for the SQL query. Each element of the params array may be either:

  a hash of the form:
    {:value  => String (value of bind parameter)
     :format => Fixnum (0 for text, 1 for binary)
    }
  or, it may be a String. If it is a string, that is equivalent to the hash:
    { :value => <string value>, :format => 0 }

PostgreSQL bind parameters are represented as $1, $1, $2, etc., inside the SQL query. The 0th element of the params array is bound to $1, the 1st element is bound to $2, etc. nil is treated as NULL.

The optional result_format should be 0 for text results, 1 for binary.

If the optional code block is given, it will be passed result as an argument, and the PGresult object will automatically be cleared when the block terminates. In this instance, conn.exec_prepared returns the value of the block.

defined in Ruby 1.9 or later.

  • Returns the server_encoding of the connected database as a Ruby Encoding object.
  • Maps ‘SQL_ASCII’ to ASCII-8BIT.

Closes the backend connection.

Attempts to flush any queued output data to the server. Returns true if data is successfully flushed, false if not (can only return false if connection is nonblocking. Raises PGError exception if some other failure occurred.

Returns the client encoding as a String.

Return a string containing one row of data, nil if the copy is done, or false if the call would block (only possible if async is true).

This function retrieves all available results on the current connection (from previously issued asynchronous commands like +send_query()+) and returns the last non-NULL result, or nil if no results are available.

This function is similar to +PGconn#get_result+ except that it is designed to get one and only one result.

Blocks waiting for the next result from a call to +PGconn#send_query+ (or another asynchronous command), and returns it. Returns nil if no more results are available.

Note: call this function repeatedly until it returns nil, or else you will not be able to issue further commands.

If the optional code block is given, it will be passed result as an argument, and the PGresult object will automatically be cleared when the block terminates. In this instance, conn.exec returns the value of the block.

Returns the connected server name.

defined in Ruby 1.9 or later.

Returns:

  • an Encoding - client_encoding of the connection as a Ruby Encoding object.
  • nil - the client_encoding is ‘SQL_ASCII‘

A wrapper of +PGconn#set_client_encoding+. defined in Ruby 1.9 or later.

value can be one of:

  • an Encoding
  • a String - a name of Encoding
  • nil - sets ‘SQL_ASCII’ to the client_encoding.

Returns true if a command is busy, that is, if PQgetResult would block. Otherwise returns false.

Returns true if a command is busy, that is, if PQgetResult would block. Otherwise returns false.

Closes the postgres large object of lo_desc.

Creates a large object with mode mode. Returns a large object Oid. On failure, it raises PGError exception.

Creates a large object with oid oid. Returns the large object Oid. On failure, it raises PGError exception.

Saves a large object of oid to a file.

Import a file to a large object. Returns a large object Oid.

On failure, it raises a PGError exception.

Move the large object pointer lo_desc to offset offset. Valid values for whence are SEEK_SET, SEEK_CUR, and SEEK_END. (Or 0, 1, or 2.)

Open a large object of oid. Returns a large object descriptor instance on success. The mode argument specifies the mode for the opened large object,which is either INV_READ, or INV_WRITE.

If mode is omitted, the default is INV_READ.

Attempts to read len bytes from large object lo_desc, returns resulting data.

lo_seek(p1, p2, p3)

Alias for lo_lseek

Returns the current position of the large object lo_desc.

Truncates the large object lo_desc to size len.

Unlinks (deletes) the postgres large object of oid.

Writes the string buffer to the large object lo_desc. Returns the number of bytes written.

loclose(p1)

Alias for lo_close

locreat(...)

Alias for lo_creat

locreate(p1)

Alias for lo_create

loexport(p1, p2)

Alias for lo_export

loimport(p1)

Alias for lo_import

lolseek(p1, p2, p3)

Alias for lo_lseek

loopen(...)

Alias for lo_open

loread(p1, p2)

Alias for lo_read

loseek(p1, p2, p3)

Alias for lo_lseek

lotell(p1)

Alias for lo_tell

lotruncate(p1, p2)

Alias for lo_truncate

lounlink(p1)

Alias for lo_unlink

lowrite(p1, p2)

Alias for lo_write

Constructs and empty PGresult with status status. status may be one of:

  • PGRES_EMPTY_QUERY
  • PGRES_COMMAND_OK
  • PGRES_TUPLES_OK
  • PGRES_COPY_OUT
  • PGRES_COPY_IN
  • PGRES_BAD_RESPONSE
  • PGRES_NONFATAL_ERROR
  • PGRES_FATAL_ERROR
nonblocking?()

Alias for isnonblocking

Returns a hash of the unprocessed notifiers. If there is no unprocessed notifier, it returns nil.

notifies_wait(...)

Alias for wait_for_notify

Returns backend option string.

Returns the setting of parameter param_name, where param_name is one of

  • server_version
  • server_encoding
  • client_encoding
  • is_superuser
  • session_authorization
  • DateStyle
  • TimeZone
  • integer_datetimes
  • standard_conforming_strings

Returns nil if the value of the parameter is not known.

Returns the authenticated user name.

Returns the connected server port number.

Prepares statement sql with name name to be executed later. Returns a PGresult instance on success. On failure, it raises a PGError exception.

param_types is an optional parameter to specify the Oids of the types of the parameters.

If the types are not specified, they will be inferred by PostgreSQL. Instead of specifying type oids, it‘s recommended to simply add explicit casts in the query to ensure that the right type is used.

For example: "SELECT $1::int"

PostgreSQL bind parameters are represented as $1, $1, $2, etc., inside the SQL query.

The 3.0 protocol will normally be used when communicating with PostgreSQL 7.4 or later servers; pre-7.4 servers support only protocol 2.0. (Protocol 1.0 is obsolete and not supported by libpq.)

Transmits buffer as copy data to the server. Returns true if the data was sent, false if it was not sent (false is only possible if the connection is in nonblocking mode, and this command would block).

Raises an exception if an error occurs.

Sends end-of-data indication to the server.

error_message is an optional parameter, and if set, forces the COPY command to fail with the string error_message.

Returns true if the end-of-data was sent, false if it was not sent (false is only possible if the connection is in nonblocking mode, and this command would block).

query(...)

Alias for exec

Returns a string that is safe for inclusion in a SQL query as an identifier. Note: this is not a quote function for values, but for identifiers.

For example, in a typical SQL query: SELECT FOO FROM MYTABLE The identifier FOO is folded to lower case, so it actually means foo. If you really want to access the case-sensitive field name FOO, use this function like PGconn.quote_ident(‘FOO’), which will return "FOO" (with double-quotes). PostgreSQL will see the double-quotes, and it will not fold to lower case.

Similarly, this function also protects against special characters, and other things that might allow SQL injection if the identifier comes from an untrusted source.

Resets the backend connection. This method closes the backend connection and tries to re-connect.

Checks the status of a connection reset operation. See PGconn#connect_start and PGconn#connect_poll for usage information and return values.

Initiate a connection reset in a nonblocking manner. This will close the current connection and attempt to reconnect using the same connection parameters. Use PGconn#reset_poll to check the status of the connection reset.

Asynchronously send command to the server. Does not block. Use in combination with +conn.get_result+.

Asynchronously send command to the server. Does not block. Use in combination with +conn.get_result+.

Prepares statement sql with name name to be executed later. Sends prepare command asynchronously, and returns immediately. On failure, it raises a PGError exception.

param_types is an optional parameter to specify the Oids of the types of the parameters.

If the types are not specified, they will be inferred by PostgreSQL. Instead of specifying type oids, it‘s recommended to simply add explicit casts in the query to ensure that the right type is used.

For example: "SELECT $1::int"

PostgreSQL bind parameters are represented as $1, $1, $2, etc., inside the SQL query.

Sends SQL query request specified by sql to PostgreSQL for asynchronous processing, and immediately returns. On failure, it raises a PGError exception.

params is an optional array of the bind parameters for the SQL query. Each element of the params array may be either:

  a hash of the form:
    {:value  => String (value of bind parameter)
     :type   => Fixnum (oid of type of bind parameter)
     :format => Fixnum (0 for text, 1 for binary)
    }
  or, it may be a String. If it is a string, that is equivalent to the hash:
    { :value => <string value>, :type => 0, :format => 0 }

PostgreSQL bind parameters are represented as $1, $1, $2, etc., inside the SQL query. The 0th element of the params array is bound to $1, the 1st element is bound to $2, etc. nil is treated as NULL.

If the types are not specified, they will be inferred by PostgreSQL. Instead of specifying type oids, it‘s recommended to simply add explicit casts in the query to ensure that the right type is used.

For example: "SELECT $1::int"

The optional result_format should be 0 for text results, 1 for binary.

Execute prepared named statement specified by statement_name asynchronously, and returns immediately. On failure, it raises a PGError exception.

params is an array of the optional bind parameters for the SQL query. Each element of the params array may be either:

  a hash of the form:
    {:value  => String (value of bind parameter)
     :format => Fixnum (0 for text, 1 for binary)
    }
  or, it may be a String. If it is a string, that is equivalent to the hash:
    { :value => <string value>, :format => 0 }

PostgreSQL bind parameters are represented as $1, $1, $2, etc., inside the SQL query. The 0th element of the params array is bound to $1, the 1st element is bound to $2, etc. nil is treated as NULL.

The optional result_format should be 0 for text results, 1 for binary.

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.

Sets the client encoding to the encoding String.

Sets connection‘s verbosity to verbosity and returns the previous setting. Available settings are:

  • PQERRORS_TERSE
  • PQERRORS_DEFAULT
  • PQERRORS_VERBOSE

Notice and warning messages generated by the server are not returned by the query execution functions, since they do not imply failure of the query. Instead they are passed to a notice handling function, and execution continues normally after the handler returns. The default notice handling function prints the message on stderr, but the application can override this behavior by supplying its own handling function.

This function takes a new block to act as the handler, which should accept a single parameter that will be a PGresult object, and returns the Proc object previously set, or nil if it was previously the default.

If you pass no arguments, it will reset the handler to the default.

Notice and warning messages generated by the server are not returned by the query execution functions, since they do not imply failure of the query. Instead they are passed to a notice handling function, and execution continues normally after the handler returns. The default notice handling function prints the message on stderr, but the application can override this behavior by supplying its own handling function.

This function takes a new block to act as the handler, which should accept a single parameter that will be a PGresult object, and returns the Proc object previously set, or nil if it was previously the default.

If you pass no arguments, it will reset the handler to the default.

Sets the nonblocking status of the connection. In the blocking state, calls to PGconn#send_query will block until the message is sent to the server, but will not wait for the query results. In the nonblocking state, calls to PGconn#send_query will return an error if the socket is not ready for writing. Note: This function does not affect PGconn#exec, because that function doesn‘t return until the server has processed the query and returned the results. Returns nil.

Returns the socket‘s file descriptor for this connection.

Returns status of connection : CONNECTION_OK or CONNECTION_BAD

Enables tracing message passing between backend. The trace message will be written to the stream stream, which must implement a method fileno that returns a writable file descriptor.

Executes a BEGIN at the start of the block, and a COMMIT at the end of the block, or ROLLBACK if any exception occurs.

returns one of the following statuses:

  PQTRANS_IDLE    = 0 (connection idle)
  PQTRANS_ACTIVE  = 1 (command in progress)
  PQTRANS_INTRANS = 2 (idle, within transaction block)
  PQTRANS_INERROR = 3 (idle, within failed transaction)
  PQTRANS_UNKNOWN = 4 (cannot determine status)

Returns the connected pgtty. (Obsolete)

Converts an escaped string representation of binary data into binary data — the reverse of escape_bytea. This is needed when retrieving bytea data in text format, but not when retrieving it in binary format.

Disables the message tracing.

Returns the authenticated user name.

Blocks while waiting for notification(s), or until the optional timeout is reached, whichever comes first. timeout is measured in seconds and can be fractional.

Returns nil if timeout is reached, the name of the NOTIFY event otherwise. If used in block form, passes the name of the NOTIFY event and the generating pid into the block.

[Validate]