MCPcopy
hub / github.com/jackc/pgx / Close

Method Close

pgconn/pgconn.go:1800–1833  ·  view source on GitHub ↗

Close consumes any remaining result data and returns the command tag or error.

()

Source from the content-addressed store, hash-verified

1798// Close consumes any remaining result data and returns the command tag or
1799// error.
1800func (rr *ResultReader) Close() (CommandTag, error) {
1801 if rr.closed {
1802 return rr.commandTag, rr.err
1803 }
1804 rr.closed = true
1805
1806 for !rr.commandConcluded {
1807 _, err := rr.receiveMessage()
1808 if err != nil {
1809 return CommandTag{}, rr.err
1810 }
1811 }
1812
1813 if rr.multiResultReader == nil && rr.pipeline == nil {
1814 for {
1815 msg, err := rr.receiveMessage()
1816 if err != nil {
1817 return CommandTag{}, rr.err
1818 }
1819
1820 switch msg := msg.(type) {
1821 // Detect a deferred constraint violation where the ErrorResponse is sent after CommandComplete.
1822 case *pgproto3.ErrorResponse:
1823 rr.err = ErrorResponseToPgError(msg)
1824 case *pgproto3.ReadyForQuery:
1825 rr.pgConn.contextWatcher.Unwatch()
1826 rr.pgConn.unlock()
1827 return rr.commandTag, rr.err
1828 }
1829 }
1830 }
1831
1832 return rr.commandTag, rr.err
1833}
1834
1835// readUntilRowDescription ensures the ResultReader's fieldDescriptions are loaded. It does not return an error as any
1836// error will be stored in the ResultReader.

Callers 1

ReadMethod · 0.95

Calls 4

receiveMessageMethod · 0.95
ErrorResponseToPgErrorFunction · 0.85
UnwatchMethod · 0.80
unlockMethod · 0.80

Tested by

no test coverage detected