public synchronized void writeToCopy ( CopyOperationImpl op , byte [ ] data , int off , int siz ) throws SQLException { if ( ! hasLock ( op ) ) { throw new PSQLException ( GT . tr ( "Tried to write to an inactive copy operation" ) , PSQLState . OBJECT_NOT_IN_STATE ) ; } LOGGER . log ( Level . FINEST , " FE=> CopyData({0})" , siz ) ; try { pgStream . sendChar ( ' ' ) ; pgStream . sendInteger4 ( siz + 4 ) ; pgStream . send ( data , off , siz ) ; processCopyResults ( op , false ) ; // collect any pending notifications without blocking } catch ( IOException ioe ) { throw new PSQLException ( GT . tr ( "Database connection failed when writing to copy" ) , PSQLState . CONNECTION_FAILURE , ioe ) ; } }
Sends data during a live COPY IN operation . Only unlocks the connection if server suddenly returns CommandComplete which should not happen