2
0

Add CopyFrom to pool

This commit is contained in:
Jack Christensen
2019-04-25 15:35:53 -05:00
parent 7b1272d254
commit d93de3fdc7
11 changed files with 134 additions and 8 deletions
+3 -3
View File
@@ -57,7 +57,7 @@ type copyFrom struct {
readerErrChan chan error
}
func (ct *copyFrom) run(ctx context.Context) (int, error) {
func (ct *copyFrom) run(ctx context.Context) (int64, error) {
quotedTableName := ct.tableName.Sanitize()
cbuf := &bytes.Buffer{}
for i, cn := range ct.columnNames {
@@ -113,7 +113,7 @@ func (ct *copyFrom) run(ctx context.Context) (int, error) {
commandTag, err := ct.conn.pgConn.CopyFrom(ctx, r, fmt.Sprintf("copy %s ( %s ) from stdin binary;", quotedTableName, quotedColumnNames))
return int(commandTag.RowsAffected()), err
return commandTag.RowsAffected(), err
}
func (ct *copyFrom) buildCopyBuf(buf []byte, ps *PreparedStatement) (bool, []byte, error) {
@@ -149,7 +149,7 @@ func (ct *copyFrom) buildCopyBuf(buf []byte, ps *PreparedStatement) (bool, []byt
// CopyFrom requires all values use the binary format. Almost all types
// implemented by pgx use the binary format by default. Types implementing
// Encoder can only be used if they encode to the binary format.
func (c *Conn) CopyFrom(ctx context.Context, tableName Identifier, columnNames []string, rowSrc CopyFromSource) (int, error) {
func (c *Conn) CopyFrom(ctx context.Context, tableName Identifier, columnNames []string, rowSrc CopyFromSource) (int64, error) {
ct := &copyFrom{
conn: c,
tableName: tableName,