Skip to content

Commit f2b3210

Browse files
committed
Backport better Conn.Query docs
#1358
1 parent eb3f696 commit f2b3210

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

conn.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,13 @@ type QueryResultFormats []int16
535535
// QueryResultFormatsByOID controls the result format (text=0, binary=1) of a query by the result column OID.
536536
type QueryResultFormatsByOID map[uint32]int16
537537

538-
// Query executes sql with args. It is safe to attempt to read from the returned Rows even if an error is returned. The
539-
// error will be the available in rows.Err() after rows are closed. So it is allowed to ignore the error returned from
540-
// Query and handle it in Rows.
538+
// Query sends a query to the server and returns a Rows to read the results. Only errors encountered sending the query
539+
// and initializing Rows will be returned. Err() on the returned Rows must be checked after the Rows is closed to
540+
// determine if the query executed successfully.
541+
//
542+
// The returned Rows must be closed before the connection can be used again. It is safe to attempt to read from the
543+
// returned Rows even if an error is returned. The error will be the available in rows.Err() after rows are closed. It
544+
// is allowed to ignore the error returned from Query and handle it in Rows.
541545
//
542546
// Err() on the returned Rows must be checked after the Rows is closed to determine if the query executed successfully
543547
// as some errors can only be detected by reading the entire response. e.g. A divide by zero error on the last row.

0 commit comments

Comments
 (0)