On 02/03/2014 11:34 AM, Tudor Girba wrote:
- Why is result an instance variable in PGConnection? Making it a
variable always returns the same object when executing a query and that
is a bit of a pain.
Because the PGConnection is designed as an active object, controlled by
a state machine. Depending on the connection state, the result set
associated with the connection is either valid or not valid.
The layer above PGConnection should not hold onto any PGResult directly,
since it's internal data structure of the Postgres client. The object
mapping layer would be expected to copy data values from the result rows.
- Why does the PGResult have the possibility of holding multiple
PGResultSets? When is it possible to have multiple at the same time?
(when you execute a query, the result is being initialized)
IIRC, something like:
connection execute 'select * from foo1; select * from foo2'
will get you multiple result sets.
- When running something like
connection execute: 'select * from ...'
the PGResultSet already includes all rows of the query. Is it not
possible to have a stream-like functionality in which the actual rows
are retrieved only on demand? (a similar functionality exists in DBXTalk)
IIUC (it's been a long time since I looked at it), the V3 protocol has
this streaming support. In the V2 protocol, I think you have to read and
discard the results. As for DBXTalk, it's likely using the V3 protocol.
- What is the difference between PGAsciiRow and PGDataRow?
The message format is documented at:
http://www.postgresql.org/docs/7.1/static/protocol-message-formats.html
I see an AsciiRow and a BinaryRow there, but no DataRow. So, I don't
know where DataRow comes from, unless it's from an even older version of
the protocol docs (original development was done on Postgres version
6.4, IIRC).