mirror of https://github.com/jackc/pgx.git
Remove Pg prefix for a couple types
parent
31cb2b4e72
commit
c3da7991ba
|
@ -536,8 +536,8 @@ func (pgConn *PgConn) cancelRequest(ctx context.Context) error {
|
||||||
// statements.
|
// statements.
|
||||||
//
|
//
|
||||||
// Prefer ExecParams unless executing arbitrary SQL that may contain multiple queries.
|
// Prefer ExecParams unless executing arbitrary SQL that may contain multiple queries.
|
||||||
func (pgConn *PgConn) Exec(ctx context.Context, sql string) *PgMultiResult {
|
func (pgConn *PgConn) Exec(ctx context.Context, sql string) *MultiResult {
|
||||||
multiResult := &PgMultiResult{
|
multiResult := &MultiResult{
|
||||||
pgConn: pgConn,
|
pgConn: pgConn,
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
cleanupContextDeadline: func() {},
|
cleanupContextDeadline: func() {},
|
||||||
|
@ -593,8 +593,8 @@ func (pgConn *PgConn) Exec(ctx context.Context, sql string) *PgMultiResult {
|
||||||
// binary format. If resultFormats is nil all results will be in text protocol.
|
// binary format. If resultFormats is nil all results will be in text protocol.
|
||||||
//
|
//
|
||||||
// Result must be closed before PgConn can be used again.
|
// Result must be closed before PgConn can be used again.
|
||||||
func (pgConn *PgConn) ExecParams(ctx context.Context, sql string, paramValues [][]byte, paramOIDs []uint32, paramFormats []int16, resultFormats []int16) *PgResult {
|
func (pgConn *PgConn) ExecParams(ctx context.Context, sql string, paramValues [][]byte, paramOIDs []uint32, paramFormats []int16, resultFormats []int16) *Result {
|
||||||
result := &PgResult{
|
result := &Result{
|
||||||
pgConn: pgConn,
|
pgConn: pgConn,
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
cleanupContextDeadline: func() {},
|
cleanupContextDeadline: func() {},
|
||||||
|
@ -649,8 +649,8 @@ func (pgConn *PgConn) ExecParams(ctx context.Context, sql string, paramValues []
|
||||||
// binary format. If resultFormats is nil all results will be in text protocol.
|
// binary format. If resultFormats is nil all results will be in text protocol.
|
||||||
//
|
//
|
||||||
// Result must be closed before PgConn can be used again.
|
// Result must be closed before PgConn can be used again.
|
||||||
func (pgConn *PgConn) ExecPrepared(ctx context.Context, stmtName string, paramValues [][]byte, paramFormats []int16, resultFormats []int16) *PgResult {
|
func (pgConn *PgConn) ExecPrepared(ctx context.Context, stmtName string, paramValues [][]byte, paramFormats []int16, resultFormats []int16) *Result {
|
||||||
result := &PgResult{
|
result := &Result{
|
||||||
pgConn: pgConn,
|
pgConn: pgConn,
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
cleanupContextDeadline: func() {},
|
cleanupContextDeadline: func() {},
|
||||||
|
@ -689,18 +689,18 @@ func (pgConn *PgConn) ExecPrepared(ctx context.Context, stmtName string, paramVa
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
type PgMultiResult struct {
|
type MultiResult struct {
|
||||||
pgConn *PgConn
|
pgConn *PgConn
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
cleanupContextDeadline func()
|
cleanupContextDeadline func()
|
||||||
|
|
||||||
pgResult *PgResult
|
pgResult *Result
|
||||||
|
|
||||||
closed bool
|
closed bool
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mr *PgMultiResult) ReadAll() ([]*BufferedResult, error) {
|
func (mr *MultiResult) ReadAll() ([]*BufferedResult, error) {
|
||||||
var results []*BufferedResult
|
var results []*BufferedResult
|
||||||
|
|
||||||
for mr.NextResult() {
|
for mr.NextResult() {
|
||||||
|
@ -711,7 +711,7 @@ func (mr *PgMultiResult) ReadAll() ([]*BufferedResult, error) {
|
||||||
return results, err
|
return results, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mr *PgMultiResult) receiveMessage() (pgproto3.BackendMessage, error) {
|
func (mr *MultiResult) receiveMessage() (pgproto3.BackendMessage, error) {
|
||||||
msg, err := mr.pgConn.ReceiveMessage()
|
msg, err := mr.pgConn.ReceiveMessage()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -740,8 +740,8 @@ func (mr *PgMultiResult) receiveMessage() (pgproto3.BackendMessage, error) {
|
||||||
return msg, nil
|
return msg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NextResult returns advances the PgMultiResult to the next result and returns true if a result is available.
|
// NextResult returns advances the MultiResult to the next result and returns true if a result is available.
|
||||||
func (mr *PgMultiResult) NextResult() bool {
|
func (mr *MultiResult) NextResult() bool {
|
||||||
for !mr.closed && mr.err == nil {
|
for !mr.closed && mr.err == nil {
|
||||||
msg, err := mr.receiveMessage()
|
msg, err := mr.receiveMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -750,7 +750,7 @@ func (mr *PgMultiResult) NextResult() bool {
|
||||||
|
|
||||||
switch msg := msg.(type) {
|
switch msg := msg.(type) {
|
||||||
case *pgproto3.RowDescription:
|
case *pgproto3.RowDescription:
|
||||||
mr.pgResult = &PgResult{
|
mr.pgResult = &Result{
|
||||||
pgConn: mr.pgConn,
|
pgConn: mr.pgConn,
|
||||||
pgMultiResult: mr,
|
pgMultiResult: mr,
|
||||||
ctx: mr.ctx,
|
ctx: mr.ctx,
|
||||||
|
@ -759,7 +759,7 @@ func (mr *PgMultiResult) NextResult() bool {
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case *pgproto3.CommandComplete:
|
case *pgproto3.CommandComplete:
|
||||||
mr.pgResult = &PgResult{
|
mr.pgResult = &Result{
|
||||||
commandTag: CommandTag(msg.CommandTag),
|
commandTag: CommandTag(msg.CommandTag),
|
||||||
commandConcluded: true,
|
commandConcluded: true,
|
||||||
closed: true,
|
closed: true,
|
||||||
|
@ -773,11 +773,11 @@ func (mr *PgMultiResult) NextResult() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mr *PgMultiResult) Result() *PgResult {
|
func (mr *MultiResult) Result() *Result {
|
||||||
return mr.pgResult
|
return mr.pgResult
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mr *PgMultiResult) Close() error {
|
func (mr *MultiResult) Close() error {
|
||||||
for !mr.closed {
|
for !mr.closed {
|
||||||
_, err := mr.receiveMessage()
|
_, err := mr.receiveMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -788,9 +788,9 @@ func (mr *PgMultiResult) Close() error {
|
||||||
return mr.err
|
return mr.err
|
||||||
}
|
}
|
||||||
|
|
||||||
type PgResult struct {
|
type Result struct {
|
||||||
pgConn *PgConn
|
pgConn *PgConn
|
||||||
pgMultiResult *PgMultiResult
|
pgMultiResult *MultiResult
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
cleanupContextDeadline func()
|
cleanupContextDeadline func()
|
||||||
|
|
||||||
|
@ -809,7 +809,7 @@ type BufferedResult struct {
|
||||||
Err error
|
Err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rr *PgResult) ReadAll() *BufferedResult {
|
func (rr *Result) ReadAll() *BufferedResult {
|
||||||
br := &BufferedResult{}
|
br := &BufferedResult{}
|
||||||
|
|
||||||
for rr.NextRow() {
|
for rr.NextRow() {
|
||||||
|
@ -828,8 +828,8 @@ func (rr *PgResult) ReadAll() *BufferedResult {
|
||||||
return br
|
return br
|
||||||
}
|
}
|
||||||
|
|
||||||
// NextRow advances the PgResult to the next row and returns true if a row is available.
|
// NextRow advances the Result to the next row and returns true if a row is available.
|
||||||
func (rr *PgResult) NextRow() bool {
|
func (rr *Result) NextRow() bool {
|
||||||
for !rr.commandConcluded {
|
for !rr.commandConcluded {
|
||||||
msg, err := rr.receiveMessage()
|
msg, err := rr.receiveMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -847,21 +847,21 @@ func (rr *PgResult) NextRow() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FieldDescriptions returns the field descriptions for the current result set. The returned slice is only valid until
|
// FieldDescriptions returns the field descriptions for the current result set. The returned slice is only valid until
|
||||||
// the PgResult is closed.
|
// the Result is closed.
|
||||||
func (rr *PgResult) FieldDescriptions() []pgproto3.FieldDescription {
|
func (rr *Result) FieldDescriptions() []pgproto3.FieldDescription {
|
||||||
return rr.fieldDescriptions
|
return rr.fieldDescriptions
|
||||||
}
|
}
|
||||||
|
|
||||||
// Values returns the current row data. NextRow must have been previously been called. The returned [][]byte is only
|
// Values returns the current row data. NextRow must have been previously been called. The returned [][]byte is only
|
||||||
// valid until the next NextRow call or the PgResult is closed. However, the underlying byte data is safe to
|
// valid until the next NextRow call or the Result is closed. However, the underlying byte data is safe to
|
||||||
// retain a reference to and mutate.
|
// retain a reference to and mutate.
|
||||||
func (rr *PgResult) Values() [][]byte {
|
func (rr *Result) Values() [][]byte {
|
||||||
return rr.rowValues
|
return rr.rowValues
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close consumes any remaining result data and returns the command tag or
|
// Close consumes any remaining result data and returns the command tag or
|
||||||
// error.
|
// error.
|
||||||
func (rr *PgResult) Close() (CommandTag, error) {
|
func (rr *Result) Close() (CommandTag, error) {
|
||||||
if rr.closed {
|
if rr.closed {
|
||||||
return rr.commandTag, rr.err
|
return rr.commandTag, rr.err
|
||||||
}
|
}
|
||||||
|
@ -893,7 +893,7 @@ func (rr *PgResult) Close() (CommandTag, error) {
|
||||||
return rr.commandTag, rr.err
|
return rr.commandTag, rr.err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rr *PgResult) receiveMessage() (msg pgproto3.BackendMessage, err error) {
|
func (rr *Result) receiveMessage() (msg pgproto3.BackendMessage, err error) {
|
||||||
if rr.pgMultiResult == nil {
|
if rr.pgMultiResult == nil {
|
||||||
msg, err = rr.pgConn.ReceiveMessage()
|
msg, err = rr.pgConn.ReceiveMessage()
|
||||||
} else {
|
} else {
|
||||||
|
@ -927,7 +927,7 @@ func (rr *PgResult) receiveMessage() (msg pgproto3.BackendMessage, err error) {
|
||||||
return msg, nil
|
return msg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rr *PgResult) concludeCommand(commandTag CommandTag, err error) {
|
func (rr *Result) concludeCommand(commandTag CommandTag, err error) {
|
||||||
if rr.commandConcluded {
|
if rr.commandConcluded {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1006,8 +1006,8 @@ func (batch *Batch) ExecPrepared(stmtName string, paramValues [][]byte, paramFor
|
||||||
batch.buf = (&pgproto3.Execute{}).Encode(batch.buf)
|
batch.buf = (&pgproto3.Execute{}).Encode(batch.buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pgConn *PgConn) ExecBatch(ctx context.Context, batch *Batch) *PgMultiResult {
|
func (pgConn *PgConn) ExecBatch(ctx context.Context, batch *Batch) *MultiResult {
|
||||||
multiResult := &PgMultiResult{
|
multiResult := &MultiResult{
|
||||||
pgConn: pgConn,
|
pgConn: pgConn,
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
cleanupContextDeadline: func() {},
|
cleanupContextDeadline: func() {},
|
||||||
|
|
Loading…
Reference in New Issue