MCPcopy
hub / github.com/jackc/pgx / beginSQL

Method beginSQL

tx.go:56–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54var emptyTxOptions TxOptions
55
56func (txOptions TxOptions) beginSQL() string {
57 if txOptions == emptyTxOptions {
58 return "begin"
59 }
60
61 if txOptions.BeginQuery != "" {
62 return txOptions.BeginQuery
63 }
64
65 var buf strings.Builder
66 buf.Grow(64) // 64 - maximum length of string with available options
67 buf.WriteString("begin")
68
69 if txOptions.IsoLevel != "" {
70 buf.WriteString(" isolation level ")
71 buf.WriteString(string(txOptions.IsoLevel))
72 }
73 if txOptions.AccessMode != "" {
74 buf.WriteByte(' ')
75 buf.WriteString(string(txOptions.AccessMode))
76 }
77 if txOptions.DeferrableMode != "" {
78 buf.WriteByte(' ')
79 buf.WriteString(string(txOptions.DeferrableMode))
80 }
81
82 return buf.String()
83}
84
85var ErrTxClosed = errors.New("tx is closed")
86

Callers 1

BeginTxMethod · 0.80

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected