mirror of https://github.com/jackc/pgx.git
CommandTag is string
parent
2f0db78865
commit
8feee74396
|
@ -347,7 +347,7 @@ func (pgConn *PgConn) ParameterStatus(key string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommandTag is the result of an Exec function
|
// CommandTag is the result of an Exec function
|
||||||
type CommandTag []byte
|
type CommandTag string
|
||||||
|
|
||||||
// RowsAffected returns the number of rows affected. If the CommandTag was not
|
// RowsAffected returns the number of rows affected. If the CommandTag was not
|
||||||
// for a row affecting command (e.g. "CREATE TABLE") then it returns 0.
|
// for a row affecting command (e.g. "CREATE TABLE") then it returns 0.
|
||||||
|
@ -361,10 +361,6 @@ func (ct CommandTag) RowsAffected() int64 {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ct CommandTag) String() string {
|
|
||||||
return string(ct)
|
|
||||||
}
|
|
||||||
|
|
||||||
// preferContextOverNetTimeoutError returns ctx.Err() if ctx.Err() is present and err is a net.Error with Timeout() ==
|
// preferContextOverNetTimeoutError returns ctx.Err() if ctx.Err() is present and err is a net.Error with Timeout() ==
|
||||||
// true. Otherwise returns err.
|
// true. Otherwise returns err.
|
||||||
func preferContextOverNetTimeoutError(ctx context.Context, err error) error {
|
func preferContextOverNetTimeoutError(ctx context.Context, err error) error {
|
||||||
|
@ -602,7 +598,7 @@ func (pgConn *PgConn) ExecParams(ctx context.Context, sql string, paramValues []
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
result.concludeCommand(nil, ctx.Err())
|
result.concludeCommand("", ctx.Err())
|
||||||
result.closed = true
|
result.closed = true
|
||||||
return result
|
return result
|
||||||
case pgConn.controller <- result:
|
case pgConn.controller <- result:
|
||||||
|
@ -628,7 +624,7 @@ func (pgConn *PgConn) ExecParams(ctx context.Context, sql string, paramValues []
|
||||||
pgConn.closed = true
|
pgConn.closed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
result.concludeCommand(nil, err)
|
result.concludeCommand("", err)
|
||||||
result.cleanupContextDeadline()
|
result.cleanupContextDeadline()
|
||||||
result.closed = true
|
result.closed = true
|
||||||
<-pgConn.controller
|
<-pgConn.controller
|
||||||
|
@ -658,7 +654,7 @@ func (pgConn *PgConn) ExecPrepared(ctx context.Context, stmtName string, paramVa
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
result.concludeCommand(nil, ctx.Err())
|
result.concludeCommand("", ctx.Err())
|
||||||
result.closed = true
|
result.closed = true
|
||||||
return result
|
return result
|
||||||
case pgConn.controller <- result:
|
case pgConn.controller <- result:
|
||||||
|
@ -680,7 +676,7 @@ func (pgConn *PgConn) ExecPrepared(ctx context.Context, stmtName string, paramVa
|
||||||
pgConn.closed = true
|
pgConn.closed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
result.concludeCommand(nil, err)
|
result.concludeCommand("", err)
|
||||||
result.cleanupContextDeadline()
|
result.cleanupContextDeadline()
|
||||||
result.closed = true
|
result.closed = true
|
||||||
<-pgConn.controller
|
<-pgConn.controller
|
||||||
|
@ -870,7 +866,7 @@ func (rr *ResultReader) Close() (CommandTag, error) {
|
||||||
for !rr.commandConcluded {
|
for !rr.commandConcluded {
|
||||||
_, err := rr.receiveMessage()
|
_, err := rr.receiveMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, rr.err
|
return "", rr.err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -878,7 +874,7 @@ func (rr *ResultReader) Close() (CommandTag, error) {
|
||||||
for {
|
for {
|
||||||
msg, err := rr.receiveMessage()
|
msg, err := rr.receiveMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, rr.err
|
return "", rr.err
|
||||||
}
|
}
|
||||||
|
|
||||||
switch msg.(type) {
|
switch msg.(type) {
|
||||||
|
@ -901,7 +897,7 @@ func (rr *ResultReader) receiveMessage() (msg pgproto3.BackendMessage, err error
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rr.concludeCommand(nil, err)
|
rr.concludeCommand("", err)
|
||||||
rr.cleanupContextDeadline()
|
rr.cleanupContextDeadline()
|
||||||
rr.closed = true
|
rr.closed = true
|
||||||
if rr.multiResultReader == nil {
|
if rr.multiResultReader == nil {
|
||||||
|
@ -921,7 +917,7 @@ func (rr *ResultReader) receiveMessage() (msg pgproto3.BackendMessage, err error
|
||||||
case *pgproto3.CommandComplete:
|
case *pgproto3.CommandComplete:
|
||||||
rr.concludeCommand(CommandTag(msg.CommandTag), nil)
|
rr.concludeCommand(CommandTag(msg.CommandTag), nil)
|
||||||
case *pgproto3.ErrorResponse:
|
case *pgproto3.ErrorResponse:
|
||||||
rr.concludeCommand(nil, errorResponseToPgError(msg))
|
rr.concludeCommand("", errorResponseToPgError(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
return msg, nil
|
return msg, nil
|
||||||
|
|
|
@ -375,7 +375,7 @@ func TestConnExecParamsCanceled(t *testing.T) {
|
||||||
}
|
}
|
||||||
assert.Equal(t, 0, rowCount)
|
assert.Equal(t, 0, rowCount)
|
||||||
commandTag, err := result.Close()
|
commandTag, err := result.Close()
|
||||||
assert.Nil(t, commandTag)
|
assert.Equal(t, pgconn.CommandTag(""), commandTag)
|
||||||
assert.Equal(t, context.DeadlineExceeded, err)
|
assert.Equal(t, context.DeadlineExceeded, err)
|
||||||
|
|
||||||
ensureConnValid(t, pgConn)
|
ensureConnValid(t, pgConn)
|
||||||
|
@ -427,7 +427,7 @@ func TestConnExecPreparedCanceled(t *testing.T) {
|
||||||
}
|
}
|
||||||
assert.Equal(t, 0, rowCount)
|
assert.Equal(t, 0, rowCount)
|
||||||
commandTag, err := result.Close()
|
commandTag, err := result.Close()
|
||||||
assert.Nil(t, commandTag)
|
assert.Equal(t, pgconn.CommandTag(""), commandTag)
|
||||||
assert.Equal(t, context.DeadlineExceeded, err)
|
assert.Equal(t, context.DeadlineExceeded, err)
|
||||||
|
|
||||||
ensureConnValid(t, pgConn)
|
ensureConnValid(t, pgConn)
|
||||||
|
|
Loading…
Reference in New Issue