You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Query() returns a Rows interface (implemented by baseRows in conn.go), and rows.Next() is pointing to the first ResultReader.
every consequent call to rows.Next() will return the next row of this first ResultResult
if running multiple queries in a single query, results of multi query are stored in MultiResultReader
However, this MultiResultReader is never exposed to the client, so it looks like client cannot call NextResultReader() and obtain results from next reader.
Even though in v5, Rows interface has a Conn(). that exposes the internal PgConn which in turn has the MultiResultReader, this is still private for the client (application code)
running multi statements usingQueryExecModeSimpleProtocol
How can one access all results from MultiResultReader?
The text was updated successfully, but these errors were encountered:
If your application knows what queries it is sending it should use a batch instead of Query. Query is generally intended for running a single query. As I'm guessing you discovered multiple queries only works with QueryExecModeSimpleProtocol. And that is more like "it happens to work", rather than being an encouraged use case.
But if your program doesn't know what it is running and it still needs to iterate over the results, then you need to go down to the underlying pgconn.Conn and call Exec. You can either directly handle the results (since you don't know what queries were run you probably just want the values rather than scanning into anything) or you can use RowsFromResultReader to get a Rows and handle it with that.
Query() returns a Rows interface (implemented by baseRows in conn.go), and rows.Next() is pointing to the first ResultReader.
every consequent call to rows.Next() will return the next row of this first ResultResult
if running multiple queries in a single query, results of multi query are stored in MultiResultReader
However, this MultiResultReader is never exposed to the client, so it looks like client cannot call NextResultReader() and obtain results from next reader.
Even though in v5, Rows interface has a Conn(). that exposes the internal PgConn which in turn has the MultiResultReader, this is still private for the client (application code)
running multi statements using
QueryExecModeSimpleProtocol
How can one access all results from MultiResultReader?
The text was updated successfully, but these errors were encountered: