Changing SendBytesWithResults to ReceiveResults (that only does the reading).
This commit is contained in:
committed by
Jack Christensen
parent
1debbfeec4
commit
5db484908c
@@ -904,14 +904,12 @@ func (pgConn *PgConn) Exec(ctx context.Context, sql string) *MultiResultReader {
|
|||||||
return multiResult
|
return multiResult
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendBytesWithResults sends buf to the PostgreSQL server. It must only be used when the connection is not busy. e.g. It is as
|
// ReceiveResults reads the result that might be returned by Postgres after a SendBytes
|
||||||
// error to call SendBytes while reading the result of a query.
|
// (e.a. after sending a CopyDone in a copy-both situation).
|
||||||
//
|
//
|
||||||
// This is a very low level method that requires deep understanding of the PostgreSQL wire protocol to use correctly.
|
// This is a very low level method that requires deep understanding of the PostgreSQL wire protocol to use correctly.
|
||||||
// See https://www.postgresql.org/docs/current/protocol.html.
|
// See https://www.postgresql.org/docs/current/protocol.html.
|
||||||
//
|
func (pgConn *PgConn) ReceiveResults(ctx context.Context) *MultiResultReader {
|
||||||
// So far this only seems required with CopyDone handling.
|
|
||||||
func (pgConn *PgConn) SendBytesWithResults(ctx context.Context, buf []byte) *MultiResultReader {
|
|
||||||
if err := pgConn.lock(); err != nil {
|
if err := pgConn.lock(); err != nil {
|
||||||
return &MultiResultReader{
|
return &MultiResultReader{
|
||||||
closed: true,
|
closed: true,
|
||||||
@@ -936,16 +934,6 @@ func (pgConn *PgConn) SendBytesWithResults(ctx context.Context, buf []byte) *Mul
|
|||||||
pgConn.contextWatcher.Watch(ctx)
|
pgConn.contextWatcher.Watch(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err := pgConn.conn.Write(buf)
|
|
||||||
if err != nil {
|
|
||||||
pgConn.asyncClose()
|
|
||||||
pgConn.contextWatcher.Unwatch()
|
|
||||||
multiResult.closed = true
|
|
||||||
multiResult.err = &writeError{err: err, safeToRetry: n == 0}
|
|
||||||
pgConn.unlock()
|
|
||||||
return multiResult
|
|
||||||
}
|
|
||||||
|
|
||||||
return multiResult
|
return multiResult
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user