• D
    Drain the COPY on cancellation · 8793c3bd
    Daniel Gustafsson 提交于
    The COPY process isn't finished until PQgetCopyData() returns -1 so
    we must consume all rows sent until we get -1. A single call should
    in most cases do the trick but there are no guarantees so loop around
    consumption until end-of-COPY is signalled. In case of error, break
    out and continue operation to keep current flow, investigating the
    error is probably warranted but handling cases that might fall out is
    a bigger question that this isolated patch.
    
    Also use PQfreemem() for the buffer per the manual. This is the same
    as just free() on Linux/UNIX (while critically different on Windows)
    but we might as well follow the set API to reduce confusion.
    
    Original report by Coverity
    8793c3bd
cdbcopy.c 17.2 KB