Class | PGconn |
In: |
postgres.c
|
Parent: | Object |
CONNECTION_OK | = | INT2FIX(CONNECTION_OK) |
CONNECTION_BAD | = | INT2FIX(CONNECTION_BAD) |
Returns a SQL-safe version of the String str. Unlike quote, does not wrap the String in ’…’.
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.
See the PostgreSQL documentation on PQescapeBytea for more information.
If obj is a Number, String, Array, nil, true, or false then quote returns a String representation of that object safe for use in PostgreSQL.
If obj is not one of the above classes and a block is supplied to quote, the block is invoked, passing along the object. The return value from the block is returned as a string.
If obj is not one of the recognized classes andno block is supplied, a PGError is raised.
When true (default), results are translated to appropriate ruby class. When false, results are returned as Strings.
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.
See the PostgreSQL documentation on PQunescapeBytea for more information.
Reads a line from the backend server into internal buffer. Returns nil for EOF, +0+ for success, +1+ for buffer overflowed. You need to ensure single "." from backend to confirm transmission completion. The sample program psql.rb (see source for postgres) treats this copy protocol right.
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.
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.)
Sends the string to the backend server. Users must send a single "." to denote the end of data transmission.
Sends SQL query request specified by sql to the PostgreSQL. Returns an Array as the resulting tuple on success. On failure, it returns nil, and the error details can be obtained by error.
bind_values represents values for the PostgreSQL bind parameters found in the sql. PostgreSQL bind parameters are presented as $1, $1, $2, etc.
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.
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)
See the PostgreSQL documentation on PQtransactionStatus for more information.