MCPcopy Create free account
hub / github.com/PostHog/duckgres / Read

Method Read

server/conn_copy.go:841–881  ·  view source on GitHub ↗
(p []byte)

Source from the content-addressed store, hash-verified

839 "column_list_specified", columnList != "",
840 )
841 c.logWorkerStatementStarted(workerStatement)
842 result, err := c.executor.Exec(copySQL)
843 var copyRowsAffected int64
844 if result != nil {
845 copyRowsAffected, _ = result.RowsAffected()
846 }
847 c.logWorkerStatementFinished(workerStatement, loadStart, copyRowsAffected, err)
848 if err != nil {
849 c.logger().Error("COPY FROM STDIN DuckDB COPY failed.", "error", err)
850 errMsg := fmt.Sprintf("COPY failed: %v", err)
851 c.sendError("ERROR", "22P02", errMsg)
852 c.setTxError()
853 c.logQuery(copyStartTime, query, query, "COPY", 0, int64(rowCount), "22P02", errMsg, "simple")
854 _ = c.writeReadyForQuery(c.txStatus)
855 _ = c.flushWriter()
856 return nil
857 }
858
859 rowCount = int(copyRowsAffected)
860
861 totalElapsed := time.Since(copyStartTime)
862 loadElapsed := time.Since(loadStart)
863 c.logger().Info("COPY FROM STDIN completed.", "rows", rowCount, "total_duration", totalElapsed, "load_duration", loadElapsed)
864
865 _ = c.writeCommandComplete(fmt.Sprintf("COPY %d", rowCount))
866 c.logQuery(copyStartTime, query, query, "COPY", 0, int64(rowCount), "", "", "simple")
867 _ = c.writeReadyForQuery(c.txStatus)
868 _ = c.flushWriter()
869 return nil
870
871 case wire.MsgCopyFail:
872 // Client cancelled COPY
873 errMsg := string(bytes.TrimRight(body, "\x00"))
874 exception := fmt.Sprintf("COPY failed: %s", errMsg)
875 c.sendError("ERROR", "57014", exception)
876 c.setTxError()
877 c.logQuery(copyStartTime, query, query, "COPY", 0, int64(rowCount), "57014", exception, "simple")
878 _ = c.writeReadyForQuery(c.txStatus)
879 _ = c.flushWriter()
880 return nil
881
882 default:
883 errMsg := fmt.Sprintf("unexpected message type during COPY: %c", msgType)
884 c.sendError("ERROR", "08P01", errMsg)

Callers 15

TestLatencyProxyFunction · 0.45
copyWithLatencyFunction · 0.45
loadQueryResultsFunction · 0.45
handleParseMethod · 0.45
handleExecuteMethod · 0.45
handleBindMethod · 0.45
TestParseMultiLineCSVFunction · 0.45
parseCopyLineMethod · 0.45
CopyFromStdinMethod · 0.45
SealMethod · 0.45

Calls 2

ReadMessageFunction · 0.92
armIdleReadDeadlineMethod · 0.80

Tested by 3

TestLatencyProxyFunction · 0.36
TestParseMultiLineCSVFunction · 0.36