Close consumes any remaining result data and returns the command tag or error.
()
| 1798 | // Close consumes any remaining result data and returns the command tag or |
| 1799 | // error. |
| 1800 | func (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. |
no test coverage detected