id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
146,800
davecgh/go-spew
spew/format.go
constructOrigFormat
func (f *formatState) constructOrigFormat(verb rune) (format string) { buf := bytes.NewBuffer(percentBytes) for _, flag := range supportedFlags { if f.fs.Flag(int(flag)) { buf.WriteRune(flag) } } if width, ok := f.fs.Width(); ok { buf.WriteString(strconv.Itoa(width)) } if precision, ok := f.fs.Precisi...
go
func (f *formatState) constructOrigFormat(verb rune) (format string) { buf := bytes.NewBuffer(percentBytes) for _, flag := range supportedFlags { if f.fs.Flag(int(flag)) { buf.WriteRune(flag) } } if width, ok := f.fs.Width(); ok { buf.WriteString(strconv.Itoa(width)) } if precision, ok := f.fs.Precisi...
[ "func", "(", "f", "*", "formatState", ")", "constructOrigFormat", "(", "verb", "rune", ")", "(", "format", "string", ")", "{", "buf", ":=", "bytes", ".", "NewBuffer", "(", "percentBytes", ")", "\n\n", "for", "_", ",", "flag", ":=", "range", "supportedFla...
// constructOrigFormat recreates the original format string including precision // and width information to pass along to the standard fmt package. This allows // automatic deferral of all format strings this package doesn't support.
[ "constructOrigFormat", "recreates", "the", "original", "format", "string", "including", "precision", "and", "width", "information", "to", "pass", "along", "to", "the", "standard", "fmt", "package", ".", "This", "allows", "automatic", "deferral", "of", "all", "form...
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/format.go#L65-L87
146,801
davecgh/go-spew
spew/format.go
unpackValue
func (f *formatState) unpackValue(v reflect.Value) reflect.Value { if v.Kind() == reflect.Interface { f.ignoreNextType = false if !v.IsNil() { v = v.Elem() } } return v }
go
func (f *formatState) unpackValue(v reflect.Value) reflect.Value { if v.Kind() == reflect.Interface { f.ignoreNextType = false if !v.IsNil() { v = v.Elem() } } return v }
[ "func", "(", "f", "*", "formatState", ")", "unpackValue", "(", "v", "reflect", ".", "Value", ")", "reflect", ".", "Value", "{", "if", "v", ".", "Kind", "(", ")", "==", "reflect", ".", "Interface", "{", "f", ".", "ignoreNextType", "=", "false", "\n", ...
// unpackValue returns values inside of non-nil interfaces when possible and // ensures that types for values which have been unpacked from an interface // are displayed when the show types flag is also set. // This is useful for data types like structs, arrays, slices, and maps which // can contain varying types packe...
[ "unpackValue", "returns", "values", "inside", "of", "non", "-", "nil", "interfaces", "when", "possible", "and", "ensures", "that", "types", "for", "values", "which", "have", "been", "unpacked", "from", "an", "interface", "are", "displayed", "when", "the", "sho...
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/format.go#L94-L102
146,802
davecgh/go-spew
spew/format.go
formatPtr
func (f *formatState) formatPtr(v reflect.Value) { // Display nil if top level pointer is nil. showTypes := f.fs.Flag('#') if v.IsNil() && (!showTypes || f.ignoreNextType) { f.fs.Write(nilAngleBytes) return } // Remove pointers at or below the current depth from map used to detect // circular refs. for k, d...
go
func (f *formatState) formatPtr(v reflect.Value) { // Display nil if top level pointer is nil. showTypes := f.fs.Flag('#') if v.IsNil() && (!showTypes || f.ignoreNextType) { f.fs.Write(nilAngleBytes) return } // Remove pointers at or below the current depth from map used to detect // circular refs. for k, d...
[ "func", "(", "f", "*", "formatState", ")", "formatPtr", "(", "v", "reflect", ".", "Value", ")", "{", "// Display nil if top level pointer is nil.", "showTypes", ":=", "f", ".", "fs", ".", "Flag", "(", "'#'", ")", "\n", "if", "v", ".", "IsNil", "(", ")", ...
// formatPtr handles formatting of pointers by indirecting them as necessary.
[ "formatPtr", "handles", "formatting", "of", "pointers", "by", "indirecting", "them", "as", "necessary", "." ]
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/format.go#L105-L195
146,803
davecgh/go-spew
spew/format.go
Format
func (f *formatState) Format(fs fmt.State, verb rune) { f.fs = fs // Use standard formatting for verbs that are not v. if verb != 'v' { format := f.constructOrigFormat(verb) fmt.Fprintf(fs, format, f.value) return } if f.value == nil { if fs.Flag('#') { fs.Write(interfaceBytes) } fs.Write(nilAngle...
go
func (f *formatState) Format(fs fmt.State, verb rune) { f.fs = fs // Use standard formatting for verbs that are not v. if verb != 'v' { format := f.constructOrigFormat(verb) fmt.Fprintf(fs, format, f.value) return } if f.value == nil { if fs.Flag('#') { fs.Write(interfaceBytes) } fs.Write(nilAngle...
[ "func", "(", "f", "*", "formatState", ")", "Format", "(", "fs", "fmt", ".", "State", ",", "verb", "rune", ")", "{", "f", ".", "fs", "=", "fs", "\n\n", "// Use standard formatting for verbs that are not v.", "if", "verb", "!=", "'v'", "{", "format", ":=", ...
// Format satisfies the fmt.Formatter interface. See NewFormatter for usage // details.
[ "Format", "satisfies", "the", "fmt", ".", "Formatter", "interface", ".", "See", "NewFormatter", "for", "usage", "details", "." ]
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/format.go#L371-L390
146,804
davecgh/go-spew
spew/format.go
newFormatter
func newFormatter(cs *ConfigState, v interface{}) fmt.Formatter { fs := &formatState{value: v, cs: cs} fs.pointers = make(map[uintptr]int) return fs }
go
func newFormatter(cs *ConfigState, v interface{}) fmt.Formatter { fs := &formatState{value: v, cs: cs} fs.pointers = make(map[uintptr]int) return fs }
[ "func", "newFormatter", "(", "cs", "*", "ConfigState", ",", "v", "interface", "{", "}", ")", "fmt", ".", "Formatter", "{", "fs", ":=", "&", "formatState", "{", "value", ":", "v", ",", "cs", ":", "cs", "}", "\n", "fs", ".", "pointers", "=", "make", ...
// newFormatter is a helper function to consolidate the logic from the various // public methods which take varying config states.
[ "newFormatter", "is", "a", "helper", "function", "to", "consolidate", "the", "logic", "from", "the", "various", "public", "methods", "which", "take", "varying", "config", "states", "." ]
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/format.go#L394-L398
146,805
davecgh/go-spew
spew/dump.go
indent
func (d *dumpState) indent() { if d.ignoreNextIndent { d.ignoreNextIndent = false return } d.w.Write(bytes.Repeat([]byte(d.cs.Indent), d.depth)) }
go
func (d *dumpState) indent() { if d.ignoreNextIndent { d.ignoreNextIndent = false return } d.w.Write(bytes.Repeat([]byte(d.cs.Indent), d.depth)) }
[ "func", "(", "d", "*", "dumpState", ")", "indent", "(", ")", "{", "if", "d", ".", "ignoreNextIndent", "{", "d", ".", "ignoreNextIndent", "=", "false", "\n", "return", "\n", "}", "\n", "d", ".", "w", ".", "Write", "(", "bytes", ".", "Repeat", "(", ...
// indent performs indentation according to the depth level and cs.Indent // option.
[ "indent", "performs", "indentation", "according", "to", "the", "depth", "level", "and", "cs", ".", "Indent", "option", "." ]
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/dump.go#L62-L68
146,806
davecgh/go-spew
spew/dump.go
unpackValue
func (d *dumpState) unpackValue(v reflect.Value) reflect.Value { if v.Kind() == reflect.Interface && !v.IsNil() { v = v.Elem() } return v }
go
func (d *dumpState) unpackValue(v reflect.Value) reflect.Value { if v.Kind() == reflect.Interface && !v.IsNil() { v = v.Elem() } return v }
[ "func", "(", "d", "*", "dumpState", ")", "unpackValue", "(", "v", "reflect", ".", "Value", ")", "reflect", ".", "Value", "{", "if", "v", ".", "Kind", "(", ")", "==", "reflect", ".", "Interface", "&&", "!", "v", ".", "IsNil", "(", ")", "{", "v", ...
// unpackValue returns values inside of non-nil interfaces when possible. // This is useful for data types like structs, arrays, slices, and maps which // can contain varying types packed inside an interface.
[ "unpackValue", "returns", "values", "inside", "of", "non", "-", "nil", "interfaces", "when", "possible", ".", "This", "is", "useful", "for", "data", "types", "like", "structs", "arrays", "slices", "and", "maps", "which", "can", "contain", "varying", "types", ...
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/dump.go#L73-L78
146,807
davecgh/go-spew
spew/dump.go
dumpPtr
func (d *dumpState) dumpPtr(v reflect.Value) { // Remove pointers at or below the current depth from map used to detect // circular refs. for k, depth := range d.pointers { if depth >= d.depth { delete(d.pointers, k) } } // Keep list of all dereferenced pointers to show later. pointerChain := make([]uintp...
go
func (d *dumpState) dumpPtr(v reflect.Value) { // Remove pointers at or below the current depth from map used to detect // circular refs. for k, depth := range d.pointers { if depth >= d.depth { delete(d.pointers, k) } } // Keep list of all dereferenced pointers to show later. pointerChain := make([]uintp...
[ "func", "(", "d", "*", "dumpState", ")", "dumpPtr", "(", "v", "reflect", ".", "Value", ")", "{", "// Remove pointers at or below the current depth from map used to detect", "// circular refs.", "for", "k", ",", "depth", ":=", "range", "d", ".", "pointers", "{", "i...
// dumpPtr handles formatting of pointers by indirecting them as necessary.
[ "dumpPtr", "handles", "formatting", "of", "pointers", "by", "indirecting", "them", "as", "necessary", "." ]
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/dump.go#L81-L157
146,808
davecgh/go-spew
spew/dump.go
fdump
func fdump(cs *ConfigState, w io.Writer, a ...interface{}) { for _, arg := range a { if arg == nil { w.Write(interfaceBytes) w.Write(spaceBytes) w.Write(nilAngleBytes) w.Write(newlineBytes) continue } d := dumpState{w: w, cs: cs} d.pointers = make(map[uintptr]int) d.dump(reflect.ValueOf(arg))...
go
func fdump(cs *ConfigState, w io.Writer, a ...interface{}) { for _, arg := range a { if arg == nil { w.Write(interfaceBytes) w.Write(spaceBytes) w.Write(nilAngleBytes) w.Write(newlineBytes) continue } d := dumpState{w: w, cs: cs} d.pointers = make(map[uintptr]int) d.dump(reflect.ValueOf(arg))...
[ "func", "fdump", "(", "cs", "*", "ConfigState", ",", "w", "io", ".", "Writer", ",", "a", "...", "interface", "{", "}", ")", "{", "for", "_", ",", "arg", ":=", "range", "a", "{", "if", "arg", "==", "nil", "{", "w", ".", "Write", "(", "interfaceB...
// fdump is a helper function to consolidate the logic from the various public // methods which take varying writers and config states.
[ "fdump", "is", "a", "helper", "function", "to", "consolidate", "the", "logic", "from", "the", "various", "public", "methods", "which", "take", "varying", "writers", "and", "config", "states", "." ]
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/dump.go#L453-L468
146,809
davecgh/go-spew
spew/dump.go
Sdump
func Sdump(a ...interface{}) string { var buf bytes.Buffer fdump(&Config, &buf, a...) return buf.String() }
go
func Sdump(a ...interface{}) string { var buf bytes.Buffer fdump(&Config, &buf, a...) return buf.String() }
[ "func", "Sdump", "(", "a", "...", "interface", "{", "}", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "fdump", "(", "&", "Config", ",", "&", "buf", ",", "a", "...", ")", "\n", "return", "buf", ".", "String", "(", ")", "\n", "...
// Sdump returns a string with the passed arguments formatted exactly the same // as Dump.
[ "Sdump", "returns", "a", "string", "with", "the", "passed", "arguments", "formatted", "exactly", "the", "same", "as", "Dump", "." ]
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/dump.go#L478-L482
146,810
jackc/pgx
pgtype/uuid.go
parseUUID
func parseUUID(src string) (dst [16]byte, err error) { if len(src) < 36 { return dst, errors.Errorf("cannot parse UUID %v", src) } src = src[0:8] + src[9:13] + src[14:18] + src[19:23] + src[24:] buf, err := hex.DecodeString(src) if err != nil { return dst, err } copy(dst[:], buf) return dst, err }
go
func parseUUID(src string) (dst [16]byte, err error) { if len(src) < 36 { return dst, errors.Errorf("cannot parse UUID %v", src) } src = src[0:8] + src[9:13] + src[14:18] + src[19:23] + src[24:] buf, err := hex.DecodeString(src) if err != nil { return dst, err } copy(dst[:], buf) return dst, err }
[ "func", "parseUUID", "(", "src", "string", ")", "(", "dst", "[", "16", "]", "byte", ",", "err", "error", ")", "{", "if", "len", "(", "src", ")", "<", "36", "{", "return", "dst", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "src", ")", ...
// parseUUID converts a string UUID in standard form to a byte array.
[ "parseUUID", "converts", "a", "string", "UUID", "in", "standard", "form", "to", "a", "byte", "array", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/uuid.go#L89-L101
146,811
jackc/pgx
pgtype/uuid.go
encodeUUID
func encodeUUID(src [16]byte) string { return fmt.Sprintf("%x-%x-%x-%x-%x", src[0:4], src[4:6], src[6:8], src[8:10], src[10:16]) }
go
func encodeUUID(src [16]byte) string { return fmt.Sprintf("%x-%x-%x-%x-%x", src[0:4], src[4:6], src[6:8], src[8:10], src[10:16]) }
[ "func", "encodeUUID", "(", "src", "[", "16", "]", "byte", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "src", "[", "0", ":", "4", "]", ",", "src", "[", "4", ":", "6", "]", ",", "src", "[", "6", ":", "8", "]", ...
// encodeUUID converts a uuid byte array to UUID standard string form.
[ "encodeUUID", "converts", "a", "uuid", "byte", "array", "to", "UUID", "standard", "string", "form", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/uuid.go#L104-L106
146,812
jackc/pgx
pgtype/pgtype.go
DeepCopy
func (ci *ConnInfo) DeepCopy() *ConnInfo { ci2 := &ConnInfo{ oidToDataType: make(map[OID]*DataType, len(ci.oidToDataType)), nameToDataType: make(map[string]*DataType, len(ci.nameToDataType)), reflectTypeToDataType: make(map[reflect.Type]*DataType, len(ci.reflectTypeToDataType)), } for _, dt := ...
go
func (ci *ConnInfo) DeepCopy() *ConnInfo { ci2 := &ConnInfo{ oidToDataType: make(map[OID]*DataType, len(ci.oidToDataType)), nameToDataType: make(map[string]*DataType, len(ci.nameToDataType)), reflectTypeToDataType: make(map[reflect.Type]*DataType, len(ci.reflectTypeToDataType)), } for _, dt := ...
[ "func", "(", "ci", "*", "ConnInfo", ")", "DeepCopy", "(", ")", "*", "ConnInfo", "{", "ci2", ":=", "&", "ConnInfo", "{", "oidToDataType", ":", "make", "(", "map", "[", "OID", "]", "*", "DataType", ",", "len", "(", "ci", ".", "oidToDataType", ")", ")...
// DeepCopy makes a deep copy of the ConnInfo.
[ "DeepCopy", "makes", "a", "deep", "copy", "of", "the", "ConnInfo", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/pgtype.go#L192-L208
146,813
jackc/pgx
pgtype/timestamp.go
Set
func (dst *Timestamp) Set(src interface{}) error { if src == nil { *dst = Timestamp{Status: Null} return nil } switch value := src.(type) { case time.Time: *dst = Timestamp{Time: time.Date(value.Year(), value.Month(), value.Day(), value.Hour(), value.Minute(), value.Second(), value.Nanosecond(), time.UTC), S...
go
func (dst *Timestamp) Set(src interface{}) error { if src == nil { *dst = Timestamp{Status: Null} return nil } switch value := src.(type) { case time.Time: *dst = Timestamp{Time: time.Date(value.Year(), value.Month(), value.Day(), value.Hour(), value.Minute(), value.Second(), value.Nanosecond(), time.UTC), S...
[ "func", "(", "dst", "*", "Timestamp", ")", "Set", "(", "src", "interface", "{", "}", ")", "error", "{", "if", "src", "==", "nil", "{", "*", "dst", "=", "Timestamp", "{", "Status", ":", "Null", "}", "\n", "return", "nil", "\n", "}", "\n\n", "switc...
// Set converts src into a Timestamp and stores in dst. If src is a // time.Time in a non-UTC time zone, the time zone is discarded.
[ "Set", "converts", "src", "into", "a", "Timestamp", "and", "stores", "in", "dst", ".", "If", "src", "is", "a", "time", ".", "Time", "in", "a", "non", "-", "UTC", "time", "zone", "the", "time", "zone", "is", "discarded", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/timestamp.go#L27-L44
146,814
jackc/pgx
pgtype/timestamp.go
DecodeText
func (dst *Timestamp) DecodeText(ci *ConnInfo, src []byte) error { if src == nil { *dst = Timestamp{Status: Null} return nil } sbuf := string(src) switch sbuf { case "infinity": *dst = Timestamp{Status: Present, InfinityModifier: Infinity} case "-infinity": *dst = Timestamp{Status: Present, InfinityModif...
go
func (dst *Timestamp) DecodeText(ci *ConnInfo, src []byte) error { if src == nil { *dst = Timestamp{Status: Null} return nil } sbuf := string(src) switch sbuf { case "infinity": *dst = Timestamp{Status: Present, InfinityModifier: Infinity} case "-infinity": *dst = Timestamp{Status: Present, InfinityModif...
[ "func", "(", "dst", "*", "Timestamp", ")", "DecodeText", "(", "ci", "*", "ConnInfo", ",", "src", "[", "]", "byte", ")", "error", "{", "if", "src", "==", "nil", "{", "*", "dst", "=", "Timestamp", "{", "Status", ":", "Null", "}", "\n", "return", "n...
// DecodeText decodes from src into dst. The decoded time is considered to // be in UTC.
[ "DecodeText", "decodes", "from", "src", "into", "dst", ".", "The", "decoded", "time", "is", "considered", "to", "be", "in", "UTC", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/timestamp.go#L84-L106
146,815
jackc/pgx
pgtype/timestamp.go
EncodeText
func (src *Timestamp) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) { switch src.Status { case Null: return nil, nil case Undefined: return nil, errUndefined } if src.Time.Location() != time.UTC { return nil, errors.Errorf("cannot encode non-UTC time into timestamp") } var s string switch src.Inf...
go
func (src *Timestamp) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) { switch src.Status { case Null: return nil, nil case Undefined: return nil, errUndefined } if src.Time.Location() != time.UTC { return nil, errors.Errorf("cannot encode non-UTC time into timestamp") } var s string switch src.Inf...
[ "func", "(", "src", "*", "Timestamp", ")", "EncodeText", "(", "ci", "*", "ConnInfo", ",", "buf", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "switch", "src", ".", "Status", "{", "case", "Null", ":", "return", "nil", ",",...
// EncodeText writes the text encoding of src into w. If src.Time is not in // the UTC time zone it returns an error.
[ "EncodeText", "writes", "the", "text", "encoding", "of", "src", "into", "w", ".", "If", "src", ".", "Time", "is", "not", "in", "the", "UTC", "time", "zone", "it", "returns", "an", "error", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/timestamp.go#L138-L161
146,816
jackc/pgx
pgtype/timestamp.go
EncodeBinary
func (src *Timestamp) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { switch src.Status { case Null: return nil, nil case Undefined: return nil, errUndefined } if src.Time.Location() != time.UTC { return nil, errors.Errorf("cannot encode non-UTC time into timestamp") } var microsecSinceY2K int64 ...
go
func (src *Timestamp) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) { switch src.Status { case Null: return nil, nil case Undefined: return nil, errUndefined } if src.Time.Location() != time.UTC { return nil, errors.Errorf("cannot encode non-UTC time into timestamp") } var microsecSinceY2K int64 ...
[ "func", "(", "src", "*", "Timestamp", ")", "EncodeBinary", "(", "ci", "*", "ConnInfo", ",", "buf", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "switch", "src", ".", "Status", "{", "case", "Null", ":", "return", "nil", ",...
// EncodeBinary writes the binary encoding of src into w. If src.Time is not in // the UTC time zone it returns an error.
[ "EncodeBinary", "writes", "the", "binary", "encoding", "of", "src", "into", "w", ".", "If", "src", ".", "Time", "is", "not", "in", "the", "UTC", "time", "zone", "it", "returns", "an", "error", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/timestamp.go#L165-L188
146,817
jackc/pgx
batch.go
Queue
func (b *Batch) Queue(query string, arguments []interface{}, parameterOIDs []pgtype.OID, resultFormatCodes []int16) { b.items = append(b.items, &batchItem{ query: query, arguments: arguments, parameterOIDs: parameterOIDs, resultFormatCodes: resultFormatCodes, }) }
go
func (b *Batch) Queue(query string, arguments []interface{}, parameterOIDs []pgtype.OID, resultFormatCodes []int16) { b.items = append(b.items, &batchItem{ query: query, arguments: arguments, parameterOIDs: parameterOIDs, resultFormatCodes: resultFormatCodes, }) }
[ "func", "(", "b", "*", "Batch", ")", "Queue", "(", "query", "string", ",", "arguments", "[", "]", "interface", "{", "}", ",", "parameterOIDs", "[", "]", "pgtype", ".", "OID", ",", "resultFormatCodes", "[", "]", "int16", ")", "{", "b", ".", "items", ...
// Queue queues a query to batch b. parameterOIDs are required if there are // parameters and query is not the name of a prepared statement. // resultFormatCodes are required if there is a result.
[ "Queue", "queues", "a", "query", "to", "batch", "b", ".", "parameterOIDs", "are", "required", "if", "there", "are", "parameters", "and", "query", "is", "not", "the", "name", "of", "a", "prepared", "statement", ".", "resultFormatCodes", "are", "required", "if...
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/batch.go#L49-L56
146,818
jackc/pgx
batch.go
ExecResults
func (b *Batch) ExecResults() (CommandTag, error) { if b.err != nil { return "", b.err } select { case <-b.ctx.Done(): b.die(b.ctx.Err()) return "", b.ctx.Err() default: } if err := b.ensureCommandComplete(); err != nil { b.die(err) return "", err } b.resultsRead++ b.pendingCommandComplete = tru...
go
func (b *Batch) ExecResults() (CommandTag, error) { if b.err != nil { return "", b.err } select { case <-b.ctx.Done(): b.die(b.ctx.Err()) return "", b.ctx.Err() default: } if err := b.ensureCommandComplete(); err != nil { b.die(err) return "", err } b.resultsRead++ b.pendingCommandComplete = tru...
[ "func", "(", "b", "*", "Batch", ")", "ExecResults", "(", ")", "(", "CommandTag", ",", "error", ")", "{", "if", "b", ".", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "b", ".", "err", "\n", "}", "\n\n", "select", "{", "case", "<-", "b", ...
// ExecResults reads the results from the next query in the batch as if the // query has been sent with Exec.
[ "ExecResults", "reads", "the", "results", "from", "the", "next", "query", "in", "the", "batch", "as", "if", "the", "query", "has", "been", "sent", "with", "Exec", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/batch.go#L163-L200
146,819
jackc/pgx
batch.go
QueryResults
func (b *Batch) QueryResults() (*Rows, error) { rows := b.conn.getRows("batch query", nil) if b.err != nil { rows.fatal(b.err) return rows, b.err } select { case <-b.ctx.Done(): b.die(b.ctx.Err()) rows.fatal(b.err) return rows, b.ctx.Err() default: } if err := b.ensureCommandComplete(); err != nil ...
go
func (b *Batch) QueryResults() (*Rows, error) { rows := b.conn.getRows("batch query", nil) if b.err != nil { rows.fatal(b.err) return rows, b.err } select { case <-b.ctx.Done(): b.die(b.ctx.Err()) rows.fatal(b.err) return rows, b.ctx.Err() default: } if err := b.ensureCommandComplete(); err != nil ...
[ "func", "(", "b", "*", "Batch", ")", "QueryResults", "(", ")", "(", "*", "Rows", ",", "error", ")", "{", "rows", ":=", "b", ".", "conn", ".", "getRows", "(", "\"", "\"", ",", "nil", ")", "\n\n", "if", "b", ".", "err", "!=", "nil", "{", "rows"...
// QueryResults reads the results from the next query in the batch as if the // query has been sent with Query.
[ "QueryResults", "reads", "the", "results", "from", "the", "next", "query", "in", "the", "batch", "as", "if", "the", "query", "has", "been", "sent", "with", "Query", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/batch.go#L204-L240
146,820
jackc/pgx
batch.go
QueryRowResults
func (b *Batch) QueryRowResults() *Row { rows, _ := b.QueryResults() return (*Row)(rows) }
go
func (b *Batch) QueryRowResults() *Row { rows, _ := b.QueryResults() return (*Row)(rows) }
[ "func", "(", "b", "*", "Batch", ")", "QueryRowResults", "(", ")", "*", "Row", "{", "rows", ",", "_", ":=", "b", ".", "QueryResults", "(", ")", "\n", "return", "(", "*", "Row", ")", "(", "rows", ")", "\n\n", "}" ]
// QueryRowResults reads the results from the next query in the batch as if the // query has been sent with QueryRow.
[ "QueryRowResults", "reads", "the", "results", "from", "the", "next", "query", "in", "the", "batch", "as", "if", "the", "query", "has", "been", "sent", "with", "QueryRow", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/batch.go#L244-L248
146,821
jackc/pgx
batch.go
Close
func (b *Batch) Close() (err error) { if b.err != nil { return b.err } defer func() { err = b.conn.termContext(err) if b.conn != nil && b.connPool != nil { b.connPool.Release(b.conn) } }() for i := b.resultsRead; i < len(b.items); i++ { if _, err = b.ExecResults(); err != nil { return err } } ...
go
func (b *Batch) Close() (err error) { if b.err != nil { return b.err } defer func() { err = b.conn.termContext(err) if b.conn != nil && b.connPool != nil { b.connPool.Release(b.conn) } }() for i := b.resultsRead; i < len(b.items); i++ { if _, err = b.ExecResults(); err != nil { return err } } ...
[ "func", "(", "b", "*", "Batch", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "if", "b", ".", "err", "!=", "nil", "{", "return", "b", ".", "err", "\n", "}", "\n\n", "defer", "func", "(", ")", "{", "err", "=", "b", ".", "conn", ".",...
// Close closes the batch operation. Any error that occured during a batch // operation may have made it impossible to resyncronize the connection with the // server. In this case the underlying connection will have been closed.
[ "Close", "closes", "the", "batch", "operation", ".", "Any", "error", "that", "occured", "during", "a", "batch", "operation", "may", "have", "made", "it", "impossible", "to", "resyncronize", "the", "connection", "with", "the", "server", ".", "In", "this", "ca...
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/batch.go#L253-L276
146,822
jackc/pgx
tx.go
Begin
func (c *Conn) Begin() (*Tx, error) { return c.BeginEx(context.Background(), nil) }
go
func (c *Conn) Begin() (*Tx, error) { return c.BeginEx(context.Background(), nil) }
[ "func", "(", "c", "*", "Conn", ")", "Begin", "(", ")", "(", "*", "Tx", ",", "error", ")", "{", "return", "c", ".", "BeginEx", "(", "context", ".", "Background", "(", ")", ",", "nil", ")", "\n", "}" ]
// Begin starts a transaction with the default transaction mode for the // current connection. To use a specific transaction mode see BeginEx.
[ "Begin", "starts", "a", "transaction", "with", "the", "default", "transaction", "mode", "for", "the", "current", "connection", ".", "To", "use", "a", "specific", "transaction", "mode", "see", "BeginEx", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/tx.go#L84-L86
146,823
jackc/pgx
tx.go
CommitEx
func (tx *Tx) CommitEx(ctx context.Context) error { if tx.status != TxStatusInProgress { return ErrTxClosed } commandTag, err := tx.conn.ExecEx(ctx, "commit", nil) if err == nil && commandTag == "COMMIT" { tx.status = TxStatusCommitSuccess } else if err == nil && commandTag == "ROLLBACK" { tx.status = TxSta...
go
func (tx *Tx) CommitEx(ctx context.Context) error { if tx.status != TxStatusInProgress { return ErrTxClosed } commandTag, err := tx.conn.ExecEx(ctx, "commit", nil) if err == nil && commandTag == "COMMIT" { tx.status = TxStatusCommitSuccess } else if err == nil && commandTag == "ROLLBACK" { tx.status = TxSta...
[ "func", "(", "tx", "*", "Tx", ")", "CommitEx", "(", "ctx", "context", ".", "Context", ")", "error", "{", "if", "tx", ".", "status", "!=", "TxStatusInProgress", "{", "return", "ErrTxClosed", "\n", "}", "\n\n", "commandTag", ",", "err", ":=", "tx", ".", ...
// CommitEx commits the transaction with a context.
[ "CommitEx", "commits", "the", "transaction", "with", "a", "context", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/tx.go#L120-L143
146,824
jackc/pgx
tx.go
RollbackEx
func (tx *Tx) RollbackEx(ctx context.Context) error { if tx.status != TxStatusInProgress { return ErrTxClosed } _, tx.err = tx.conn.ExecEx(ctx, "rollback", nil) if tx.err == nil { tx.status = TxStatusRollbackSuccess } else { tx.status = TxStatusRollbackFailure // A rollback failure leaves the connection i...
go
func (tx *Tx) RollbackEx(ctx context.Context) error { if tx.status != TxStatusInProgress { return ErrTxClosed } _, tx.err = tx.conn.ExecEx(ctx, "rollback", nil) if tx.err == nil { tx.status = TxStatusRollbackSuccess } else { tx.status = TxStatusRollbackFailure // A rollback failure leaves the connection i...
[ "func", "(", "tx", "*", "Tx", ")", "RollbackEx", "(", "ctx", "context", ".", "Context", ")", "error", "{", "if", "tx", ".", "status", "!=", "TxStatusInProgress", "{", "return", "ErrTxClosed", "\n", "}", "\n\n", "_", ",", "tx", ".", "err", "=", "tx", ...
// RollbackEx is the context version of Rollback
[ "RollbackEx", "is", "the", "context", "version", "of", "Rollback" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/tx.go#L156-L175
146,825
jackc/pgx
pgtype/convert.go
underlyingNumberType
func underlyingNumberType(val interface{}) (interface{}, bool) { refVal := reflect.ValueOf(val) switch refVal.Kind() { case reflect.Ptr: if refVal.IsNil() { return nil, false } convVal := refVal.Elem().Interface() return convVal, true case reflect.Int: convVal := int(refVal.Int()) return convVal, re...
go
func underlyingNumberType(val interface{}) (interface{}, bool) { refVal := reflect.ValueOf(val) switch refVal.Kind() { case reflect.Ptr: if refVal.IsNil() { return nil, false } convVal := refVal.Elem().Interface() return convVal, true case reflect.Int: convVal := int(refVal.Int()) return convVal, re...
[ "func", "underlyingNumberType", "(", "val", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "bool", ")", "{", "refVal", ":=", "reflect", ".", "ValueOf", "(", "val", ")", "\n\n", "switch", "refVal", ".", "Kind", "(", ")", "{", "case", "re...
// underlyingNumberType gets the underlying type that can be converted to Int2, Int4, Int8, Float4, or Float8
[ "underlyingNumberType", "gets", "the", "underlying", "type", "that", "can", "be", "converted", "to", "Int2", "Int4", "Int8", "Float4", "or", "Float8" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/convert.go#L16-L68
146,826
jackc/pgx
pgtype/convert.go
underlyingBoolType
func underlyingBoolType(val interface{}) (interface{}, bool) { refVal := reflect.ValueOf(val) switch refVal.Kind() { case reflect.Ptr: if refVal.IsNil() { return nil, false } convVal := refVal.Elem().Interface() return convVal, true case reflect.Bool: convVal := refVal.Bool() return convVal, reflect...
go
func underlyingBoolType(val interface{}) (interface{}, bool) { refVal := reflect.ValueOf(val) switch refVal.Kind() { case reflect.Ptr: if refVal.IsNil() { return nil, false } convVal := refVal.Elem().Interface() return convVal, true case reflect.Bool: convVal := refVal.Bool() return convVal, reflect...
[ "func", "underlyingBoolType", "(", "val", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "bool", ")", "{", "refVal", ":=", "reflect", ".", "ValueOf", "(", "val", ")", "\n\n", "switch", "refVal", ".", "Kind", "(", ")", "{", "case", "refl...
// underlyingBoolType gets the underlying type that can be converted to Bool
[ "underlyingBoolType", "gets", "the", "underlying", "type", "that", "can", "be", "converted", "to", "Bool" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/convert.go#L71-L87
146,827
jackc/pgx
pgtype/convert.go
underlyingPtrType
func underlyingPtrType(val interface{}) (interface{}, bool) { refVal := reflect.ValueOf(val) switch refVal.Kind() { case reflect.Ptr: if refVal.IsNil() { return nil, false } convVal := refVal.Elem().Interface() return convVal, true } return nil, false }
go
func underlyingPtrType(val interface{}) (interface{}, bool) { refVal := reflect.ValueOf(val) switch refVal.Kind() { case reflect.Ptr: if refVal.IsNil() { return nil, false } convVal := refVal.Elem().Interface() return convVal, true } return nil, false }
[ "func", "underlyingPtrType", "(", "val", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "bool", ")", "{", "refVal", ":=", "reflect", ".", "ValueOf", "(", "val", ")", "\n\n", "switch", "refVal", ".", "Kind", "(", ")", "{", "case", "refle...
// underlyingPtrType dereferences a pointer
[ "underlyingPtrType", "dereferences", "a", "pointer" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/convert.go#L130-L143
146,828
jackc/pgx
pgtype/convert.go
underlyingTimeType
func underlyingTimeType(val interface{}) (interface{}, bool) { refVal := reflect.ValueOf(val) switch refVal.Kind() { case reflect.Ptr: if refVal.IsNil() { return time.Time{}, false } convVal := refVal.Elem().Interface() return convVal, true } timeType := reflect.TypeOf(time.Time{}) if refVal.Type().C...
go
func underlyingTimeType(val interface{}) (interface{}, bool) { refVal := reflect.ValueOf(val) switch refVal.Kind() { case reflect.Ptr: if refVal.IsNil() { return time.Time{}, false } convVal := refVal.Elem().Interface() return convVal, true } timeType := reflect.TypeOf(time.Time{}) if refVal.Type().C...
[ "func", "underlyingTimeType", "(", "val", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "bool", ")", "{", "refVal", ":=", "reflect", ".", "ValueOf", "(", "val", ")", "\n\n", "switch", "refVal", ".", "Kind", "(", ")", "{", "case", "refl...
// underlyingTimeType gets the underlying type that can be converted to time.Time
[ "underlyingTimeType", "gets", "the", "underlying", "type", "that", "can", "be", "converted", "to", "time", ".", "Time" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/convert.go#L146-L164
146,829
jackc/pgx
pgtype/convert.go
underlyingSliceType
func underlyingSliceType(val interface{}) (interface{}, bool) { refVal := reflect.ValueOf(val) switch refVal.Kind() { case reflect.Ptr: if refVal.IsNil() { return nil, false } convVal := refVal.Elem().Interface() return convVal, true case reflect.Slice: baseSliceType := reflect.SliceOf(refVal.Type().E...
go
func underlyingSliceType(val interface{}) (interface{}, bool) { refVal := reflect.ValueOf(val) switch refVal.Kind() { case reflect.Ptr: if refVal.IsNil() { return nil, false } convVal := refVal.Elem().Interface() return convVal, true case reflect.Slice: baseSliceType := reflect.SliceOf(refVal.Type().E...
[ "func", "underlyingSliceType", "(", "val", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "bool", ")", "{", "refVal", ":=", "reflect", ".", "ValueOf", "(", "val", ")", "\n\n", "switch", "refVal", ".", "Kind", "(", ")", "{", "case", "ref...
// underlyingSliceType gets the underlying slice type
[ "underlyingSliceType", "gets", "the", "underlying", "slice", "type" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/convert.go#L167-L186
146,830
jackc/pgx
pgtype/bpchar.go
AssignTo
func (src *BPChar) AssignTo(dst interface{}) error { if src.Status == Present { switch v := dst.(type) { case *rune: runes := []rune(src.String) if len(runes) == 1 { *v = runes[0] return nil } } } return (*Text)(src).AssignTo(dst) }
go
func (src *BPChar) AssignTo(dst interface{}) error { if src.Status == Present { switch v := dst.(type) { case *rune: runes := []rune(src.String) if len(runes) == 1 { *v = runes[0] return nil } } } return (*Text)(src).AssignTo(dst) }
[ "func", "(", "src", "*", "BPChar", ")", "AssignTo", "(", "dst", "interface", "{", "}", ")", "error", "{", "if", "src", ".", "Status", "==", "Present", "{", "switch", "v", ":=", "dst", ".", "(", "type", ")", "{", "case", "*", "rune", ":", "runes",...
// AssignTo assigns from src to dst.
[ "AssignTo", "assigns", "from", "src", "to", "dst", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/bpchar.go#L22-L34
146,831
jackc/pgx
log/zerologadapter/adapter.go
NewLogger
func NewLogger(logger zerolog.Logger) *Logger { return &Logger{ logger: logger.With().Str("module", "pgx").Logger(), } }
go
func NewLogger(logger zerolog.Logger) *Logger { return &Logger{ logger: logger.With().Str("module", "pgx").Logger(), } }
[ "func", "NewLogger", "(", "logger", "zerolog", ".", "Logger", ")", "*", "Logger", "{", "return", "&", "Logger", "{", "logger", ":", "logger", ".", "With", "(", ")", ".", "Str", "(", "\"", "\"", ",", "\"", "\"", ")", ".", "Logger", "(", ")", ",", ...
// NewLogger accepts a zerolog.Logger as input and returns a new custom pgx // logging fascade as output.
[ "NewLogger", "accepts", "a", "zerolog", ".", "Logger", "as", "input", "and", "returns", "a", "new", "custom", "pgx", "logging", "fascade", "as", "output", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/log/zerologadapter/adapter.go#L15-L19
146,832
jackc/pgx
messages.go
appendParse
func appendParse(buf []byte, name string, query string, parameterOIDs []pgtype.OID) []byte { buf = append(buf, 'P') sp := len(buf) buf = pgio.AppendInt32(buf, -1) buf = append(buf, name...) buf = append(buf, 0) buf = append(buf, query...) buf = append(buf, 0) buf = pgio.AppendInt16(buf, int16(len(parameterOIDs...
go
func appendParse(buf []byte, name string, query string, parameterOIDs []pgtype.OID) []byte { buf = append(buf, 'P') sp := len(buf) buf = pgio.AppendInt32(buf, -1) buf = append(buf, name...) buf = append(buf, 0) buf = append(buf, query...) buf = append(buf, 0) buf = pgio.AppendInt16(buf, int16(len(parameterOIDs...
[ "func", "appendParse", "(", "buf", "[", "]", "byte", ",", "name", "string", ",", "query", "string", ",", "parameterOIDs", "[", "]", "pgtype", ".", "OID", ")", "[", "]", "byte", "{", "buf", "=", "append", "(", "buf", ",", "'P'", ")", "\n", "sp", "...
// appendParse appends a PostgreSQL wire protocol parse message to buf and returns it.
[ "appendParse", "appends", "a", "PostgreSQL", "wire", "protocol", "parse", "message", "to", "buf", "and", "returns", "it", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/messages.go#L113-L129
146,833
jackc/pgx
messages.go
appendDescribe
func appendDescribe(buf []byte, objectType byte, name string) []byte { buf = append(buf, 'D') sp := len(buf) buf = pgio.AppendInt32(buf, -1) buf = append(buf, objectType) buf = append(buf, name...) buf = append(buf, 0) pgio.SetInt32(buf[sp:], int32(len(buf[sp:]))) return buf }
go
func appendDescribe(buf []byte, objectType byte, name string) []byte { buf = append(buf, 'D') sp := len(buf) buf = pgio.AppendInt32(buf, -1) buf = append(buf, objectType) buf = append(buf, name...) buf = append(buf, 0) pgio.SetInt32(buf[sp:], int32(len(buf[sp:]))) return buf }
[ "func", "appendDescribe", "(", "buf", "[", "]", "byte", ",", "objectType", "byte", ",", "name", "string", ")", "[", "]", "byte", "{", "buf", "=", "append", "(", "buf", ",", "'D'", ")", "\n", "sp", ":=", "len", "(", "buf", ")", "\n", "buf", "=", ...
// appendDescribe appends a PostgreSQL wire protocol describe message to buf and returns it.
[ "appendDescribe", "appends", "a", "PostgreSQL", "wire", "protocol", "describe", "message", "to", "buf", "and", "returns", "it", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/messages.go#L132-L142
146,834
jackc/pgx
messages.go
appendSync
func appendSync(buf []byte) []byte { buf = append(buf, 'S') buf = pgio.AppendInt32(buf, 4) return buf }
go
func appendSync(buf []byte) []byte { buf = append(buf, 'S') buf = pgio.AppendInt32(buf, 4) return buf }
[ "func", "appendSync", "(", "buf", "[", "]", "byte", ")", "[", "]", "byte", "{", "buf", "=", "append", "(", "buf", ",", "'S'", ")", "\n", "buf", "=", "pgio", ".", "AppendInt32", "(", "buf", ",", "4", ")", "\n\n", "return", "buf", "\n", "}" ]
// appendSync appends a PostgreSQL wire protocol sync message to buf and returns it.
[ "appendSync", "appends", "a", "PostgreSQL", "wire", "protocol", "sync", "message", "to", "buf", "and", "returns", "it", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/messages.go#L145-L150
146,835
jackc/pgx
messages.go
appendBind
func appendBind( buf []byte, destinationPortal, preparedStatement string, connInfo *pgtype.ConnInfo, parameterOIDs []pgtype.OID, arguments []interface{}, resultFormatCodes []int16, ) ([]byte, error) { buf = append(buf, 'B') sp := len(buf) buf = pgio.AppendInt32(buf, -1) buf = append(buf, destinationPortal......
go
func appendBind( buf []byte, destinationPortal, preparedStatement string, connInfo *pgtype.ConnInfo, parameterOIDs []pgtype.OID, arguments []interface{}, resultFormatCodes []int16, ) ([]byte, error) { buf = append(buf, 'B') sp := len(buf) buf = pgio.AppendInt32(buf, -1) buf = append(buf, destinationPortal......
[ "func", "appendBind", "(", "buf", "[", "]", "byte", ",", "destinationPortal", ",", "preparedStatement", "string", ",", "connInfo", "*", "pgtype", ".", "ConnInfo", ",", "parameterOIDs", "[", "]", "pgtype", ".", "OID", ",", "arguments", "[", "]", "interface", ...
// appendBind appends a PostgreSQL wire protocol bind message to buf and returns it.
[ "appendBind", "appends", "a", "PostgreSQL", "wire", "protocol", "bind", "message", "to", "buf", "and", "returns", "it", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/messages.go#L153-L197
146,836
jackc/pgx
messages.go
appendExecute
func appendExecute(buf []byte, portal string, maxRows uint32) []byte { buf = append(buf, 'E') sp := len(buf) buf = pgio.AppendInt32(buf, -1) buf = append(buf, portal...) buf = append(buf, 0) buf = pgio.AppendUint32(buf, maxRows) pgio.SetInt32(buf[sp:], int32(len(buf[sp:]))) return buf }
go
func appendExecute(buf []byte, portal string, maxRows uint32) []byte { buf = append(buf, 'E') sp := len(buf) buf = pgio.AppendInt32(buf, -1) buf = append(buf, portal...) buf = append(buf, 0) buf = pgio.AppendUint32(buf, maxRows) pgio.SetInt32(buf[sp:], int32(len(buf[sp:]))) return buf }
[ "func", "appendExecute", "(", "buf", "[", "]", "byte", ",", "portal", "string", ",", "maxRows", "uint32", ")", "[", "]", "byte", "{", "buf", "=", "append", "(", "buf", ",", "'E'", ")", "\n", "sp", ":=", "len", "(", "buf", ")", "\n", "buf", "=", ...
// appendExecute appends a PostgreSQL wire protocol execute message to buf and returns it.
[ "appendExecute", "appends", "a", "PostgreSQL", "wire", "protocol", "execute", "message", "to", "buf", "and", "returns", "it", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/messages.go#L216-L228
146,837
jackc/pgx
messages.go
appendQuery
func appendQuery(buf []byte, query string) []byte { buf = append(buf, 'Q') sp := len(buf) buf = pgio.AppendInt32(buf, -1) buf = append(buf, query...) buf = append(buf, 0) pgio.SetInt32(buf[sp:], int32(len(buf[sp:]))) return buf }
go
func appendQuery(buf []byte, query string) []byte { buf = append(buf, 'Q') sp := len(buf) buf = pgio.AppendInt32(buf, -1) buf = append(buf, query...) buf = append(buf, 0) pgio.SetInt32(buf[sp:], int32(len(buf[sp:]))) return buf }
[ "func", "appendQuery", "(", "buf", "[", "]", "byte", ",", "query", "string", ")", "[", "]", "byte", "{", "buf", "=", "append", "(", "buf", ",", "'Q'", ")", "\n", "sp", ":=", "len", "(", "buf", ")", "\n", "buf", "=", "pgio", ".", "AppendInt32", ...
// appendQuery appends a PostgreSQL wire protocol query message to buf and returns it.
[ "appendQuery", "appends", "a", "PostgreSQL", "wire", "protocol", "query", "message", "to", "buf", "and", "returns", "it", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/messages.go#L231-L240
146,838
jackc/pgx
stdlib/sql.go
ConnectionString
func (c *DriverConfig) ConnectionString(original string) string { if c.driver == nil { panic("DriverConfig must be registered before calling ConnectionString") } buf := make([]byte, 9) binary.BigEndian.PutUint64(buf[1:], uint64(c.id)) buf = append(buf, original...) return string(buf) }
go
func (c *DriverConfig) ConnectionString(original string) string { if c.driver == nil { panic("DriverConfig must be registered before calling ConnectionString") } buf := make([]byte, 9) binary.BigEndian.PutUint64(buf[1:], uint64(c.id)) buf = append(buf, original...) return string(buf) }
[ "func", "(", "c", "*", "DriverConfig", ")", "ConnectionString", "(", "original", "string", ")", "string", "{", "if", "c", ".", "driver", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "buf", ":=", "make", "(", "[", "]", "byte",...
// ConnectionString encodes the DriverConfig into the original connection // string. DriverConfig must be registered before calling ConnectionString.
[ "ConnectionString", "encodes", "the", "DriverConfig", "into", "the", "original", "connection", "string", ".", "DriverConfig", "must", "be", "registered", "before", "calling", "ConnectionString", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/stdlib/sql.go#L188-L197
146,839
jackc/pgx
stdlib/sql.go
ColumnTypeDatabaseTypeName
func (r *Rows) ColumnTypeDatabaseTypeName(index int) string { return strings.ToUpper(r.rows.FieldDescriptions()[index].DataTypeName) }
go
func (r *Rows) ColumnTypeDatabaseTypeName(index int) string { return strings.ToUpper(r.rows.FieldDescriptions()[index].DataTypeName) }
[ "func", "(", "r", "*", "Rows", ")", "ColumnTypeDatabaseTypeName", "(", "index", "int", ")", "string", "{", "return", "strings", ".", "ToUpper", "(", "r", ".", "rows", ".", "FieldDescriptions", "(", ")", "[", "index", "]", ".", "DataTypeName", ")", "\n", ...
// ColumnTypeDatabaseTypeName return the database system type name.
[ "ColumnTypeDatabaseTypeName", "return", "the", "database", "system", "type", "name", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/stdlib/sql.go#L491-L493
146,840
jackc/pgx
stdlib/sql.go
ColumnTypeLength
func (r *Rows) ColumnTypeLength(index int) (int64, bool) { return r.rows.FieldDescriptions()[index].Length() }
go
func (r *Rows) ColumnTypeLength(index int) (int64, bool) { return r.rows.FieldDescriptions()[index].Length() }
[ "func", "(", "r", "*", "Rows", ")", "ColumnTypeLength", "(", "index", "int", ")", "(", "int64", ",", "bool", ")", "{", "return", "r", ".", "rows", ".", "FieldDescriptions", "(", ")", "[", "index", "]", ".", "Length", "(", ")", "\n", "}" ]
// ColumnTypeLength returns the length of the column type if the column is a // variable length type. If the column is not a variable length type ok // should return false.
[ "ColumnTypeLength", "returns", "the", "length", "of", "the", "column", "type", "if", "the", "column", "is", "a", "variable", "length", "type", ".", "If", "the", "column", "is", "not", "a", "variable", "length", "type", "ok", "should", "return", "false", "....
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/stdlib/sql.go#L498-L500
146,841
jackc/pgx
stdlib/sql.go
ColumnTypePrecisionScale
func (r *Rows) ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool) { return r.rows.FieldDescriptions()[index].PrecisionScale() }
go
func (r *Rows) ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool) { return r.rows.FieldDescriptions()[index].PrecisionScale() }
[ "func", "(", "r", "*", "Rows", ")", "ColumnTypePrecisionScale", "(", "index", "int", ")", "(", "precision", ",", "scale", "int64", ",", "ok", "bool", ")", "{", "return", "r", ".", "rows", ".", "FieldDescriptions", "(", ")", "[", "index", "]", ".", "P...
// ColumnTypePrecisionScale should return the precision and scale for decimal // types. If not applicable, ok should be false.
[ "ColumnTypePrecisionScale", "should", "return", "the", "precision", "and", "scale", "for", "decimal", "types", ".", "If", "not", "applicable", "ok", "should", "be", "false", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/stdlib/sql.go#L504-L506
146,842
jackc/pgx
stdlib/sql.go
ColumnTypeScanType
func (r *Rows) ColumnTypeScanType(index int) reflect.Type { return r.rows.FieldDescriptions()[index].Type() }
go
func (r *Rows) ColumnTypeScanType(index int) reflect.Type { return r.rows.FieldDescriptions()[index].Type() }
[ "func", "(", "r", "*", "Rows", ")", "ColumnTypeScanType", "(", "index", "int", ")", "reflect", ".", "Type", "{", "return", "r", ".", "rows", ".", "FieldDescriptions", "(", ")", "[", "index", "]", ".", "Type", "(", ")", "\n", "}" ]
// ColumnTypeScanType returns the value type that can be used to scan types into.
[ "ColumnTypeScanType", "returns", "the", "value", "type", "that", "can", "be", "used", "to", "scan", "types", "into", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/stdlib/sql.go#L509-L511
146,843
jackc/pgx
examples/url_shortener/main.go
afterConnect
func afterConnect(conn *pgx.Conn) (err error) { _, err = conn.Prepare("getUrl", ` select url from shortened_urls where id=$1 `) if err != nil { return } _, err = conn.Prepare("deleteUrl", ` delete from shortened_urls where id=$1 `) if err != nil { return } _, err = conn.Prepare("putUrl", ` ...
go
func afterConnect(conn *pgx.Conn) (err error) { _, err = conn.Prepare("getUrl", ` select url from shortened_urls where id=$1 `) if err != nil { return } _, err = conn.Prepare("deleteUrl", ` delete from shortened_urls where id=$1 `) if err != nil { return } _, err = conn.Prepare("putUrl", ` ...
[ "func", "afterConnect", "(", "conn", "*", "pgx", ".", "Conn", ")", "(", "err", "error", ")", "{", "_", ",", "err", "=", "conn", ".", "Prepare", "(", "\"", "\"", ",", "`\n select url from shortened_urls where id=$1\n `", ")", "\n", "if", "err", "!=", ...
// afterConnect creates the prepared statements that this application uses
[ "afterConnect", "creates", "the", "prepared", "statements", "that", "this", "application", "uses" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/examples/url_shortener/main.go#L16-L36
146,844
jackc/pgx
chunkreader/chunkreader.go
Next
func (r *ChunkReader) Next(n int) (buf []byte, err error) { // n bytes already in buf if (r.wp - r.rp) >= n { buf = r.buf[r.rp : r.rp+n] r.rp += n return buf, err } // available space in buf is less than n if len(r.buf) < n { r.copyBufContents(r.newBuf(n)) } // buf is large enough, but need to shift fi...
go
func (r *ChunkReader) Next(n int) (buf []byte, err error) { // n bytes already in buf if (r.wp - r.rp) >= n { buf = r.buf[r.rp : r.rp+n] r.rp += n return buf, err } // available space in buf is less than n if len(r.buf) < n { r.copyBufContents(r.newBuf(n)) } // buf is large enough, but need to shift fi...
[ "func", "(", "r", "*", "ChunkReader", ")", "Next", "(", "n", "int", ")", "(", "buf", "[", "]", "byte", ",", "err", "error", ")", "{", "// n bytes already in buf", "if", "(", "r", ".", "wp", "-", "r", ".", "rp", ")", ">=", "n", "{", "buf", "=", ...
// Next returns buf filled with the next n bytes. If an error occurs, buf will // be nil.
[ "Next", "returns", "buf", "filled", "with", "the", "next", "n", "bytes", ".", "If", "an", "error", "occurs", "buf", "will", "be", "nil", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/chunkreader/chunkreader.go#L43-L70
146,845
jackc/pgx
conn.go
Sanitize
func (ident Identifier) Sanitize() string { parts := make([]string, len(ident)) for i := range ident { parts[i] = `"` + strings.Replace(ident[i], `"`, `""`, -1) + `"` } return strings.Join(parts, ".") }
go
func (ident Identifier) Sanitize() string { parts := make([]string, len(ident)) for i := range ident { parts[i] = `"` + strings.Replace(ident[i], `"`, `""`, -1) + `"` } return strings.Join(parts, ".") }
[ "func", "(", "ident", "Identifier", ")", "Sanitize", "(", ")", "string", "{", "parts", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "ident", ")", ")", "\n", "for", "i", ":=", "range", "ident", "{", "parts", "[", "i", "]", "=", "`\"`", ...
// Sanitize returns a sanitized string safe for SQL interpolation.
[ "Sanitize", "returns", "a", "sanitized", "string", "safe", "for", "SQL", "interpolation", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn.go#L190-L196
146,846
jackc/pgx
conn.go
Connect
func Connect(config ConnConfig) (c *Conn, err error) { return connect(config, minimalConnInfo) }
go
func Connect(config ConnConfig) (c *Conn, err error) { return connect(config, minimalConnInfo) }
[ "func", "Connect", "(", "config", "ConnConfig", ")", "(", "c", "*", "Conn", ",", "err", "error", ")", "{", "return", "connect", "(", "config", ",", "minimalConnInfo", ")", "\n", "}" ]
// Connect establishes a connection with a PostgreSQL server using config. // config.Host must be specified. config.User will default to the OS user name. // Other config fields are optional.
[ "Connect", "establishes", "a", "connection", "with", "a", "PostgreSQL", "server", "using", "config", ".", "config", ".", "Host", "must", "be", "specified", ".", "config", ".", "User", "will", "default", "to", "the", "OS", "user", "name", ".", "Other", "con...
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn.go#L225-L227
146,847
jackc/pgx
conn.go
initConnInfoEnumArray
func (c *Conn) initConnInfoEnumArray(cinfo *pgtype.ConnInfo) error { nameOIDs := make(map[string]pgtype.OID, 16) rows, err := c.Query(`select t.oid, t.typname from pg_type t join pg_type base_type on t.typelem=base_type.oid where t.typtype = 'b' and base_type.typtype = 'e'`) if err != nil { return err } for...
go
func (c *Conn) initConnInfoEnumArray(cinfo *pgtype.ConnInfo) error { nameOIDs := make(map[string]pgtype.OID, 16) rows, err := c.Query(`select t.oid, t.typname from pg_type t join pg_type base_type on t.typelem=base_type.oid where t.typtype = 'b' and base_type.typtype = 'e'`) if err != nil { return err } for...
[ "func", "(", "c", "*", "Conn", ")", "initConnInfoEnumArray", "(", "cinfo", "*", "pgtype", ".", "ConnInfo", ")", "error", "{", "nameOIDs", ":=", "make", "(", "map", "[", "string", "]", "pgtype", ".", "OID", ",", "16", ")", "\n", "rows", ",", "err", ...
// initConnInfoEnumArray introspects for arrays of enums and registers a data type for them.
[ "initConnInfoEnumArray", "introspects", "for", "arrays", "of", "enums", "and", "registers", "a", "data", "type", "for", "them", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn.go#L459-L493
146,848
jackc/pgx
conn.go
initConnInfoDomains
func (c *Conn) initConnInfoDomains(cinfo *pgtype.ConnInfo) error { type domain struct { oid pgtype.OID name pgtype.Text baseOID pgtype.OID } domains := make([]*domain, 0, 16) rows, err := c.Query(`select t.oid, t.typname, t.typbasetype from pg_type t join pg_type base_type on t.typbasetype=base_typ...
go
func (c *Conn) initConnInfoDomains(cinfo *pgtype.ConnInfo) error { type domain struct { oid pgtype.OID name pgtype.Text baseOID pgtype.OID } domains := make([]*domain, 0, 16) rows, err := c.Query(`select t.oid, t.typname, t.typbasetype from pg_type t join pg_type base_type on t.typbasetype=base_typ...
[ "func", "(", "c", "*", "Conn", ")", "initConnInfoDomains", "(", "cinfo", "*", "pgtype", ".", "ConnInfo", ")", "error", "{", "type", "domain", "struct", "{", "oid", "pgtype", ".", "OID", "\n", "name", "pgtype", ".", "Text", "\n", "baseOID", "pgtype", "....
// initConnInfoDomains introspects for domains and registers a data type for them.
[ "initConnInfoDomains", "introspects", "for", "domains", "and", "registers", "a", "data", "type", "for", "them", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn.go#L496-L539
146,849
jackc/pgx
conn.go
crateDBTypesQuery
func (c *Conn) crateDBTypesQuery(err error) (*pgtype.ConnInfo, error) { // CrateDB 2.1.6 is a database that implements the PostgreSQL wire protocol, // but not perfectly. In particular, the pg_catalog schema containing the // pg_type table is not visible by default and the pg_type.typtype column is // not implement...
go
func (c *Conn) crateDBTypesQuery(err error) (*pgtype.ConnInfo, error) { // CrateDB 2.1.6 is a database that implements the PostgreSQL wire protocol, // but not perfectly. In particular, the pg_catalog schema containing the // pg_type table is not visible by default and the pg_type.typtype column is // not implement...
[ "func", "(", "c", "*", "Conn", ")", "crateDBTypesQuery", "(", "err", "error", ")", "(", "*", "pgtype", ".", "ConnInfo", ",", "error", ")", "{", "// CrateDB 2.1.6 is a database that implements the PostgreSQL wire protocol,", "// but not perfectly. In particular, the pg_catal...
// crateDBTypesQuery checks if the given err is likely to be the result of // CrateDB not implementing the pg_types table correctly. If yes, a CrateDB // specific query against pg_types is executed and its results are returned. If // not, the original error is returned.
[ "crateDBTypesQuery", "checks", "if", "the", "given", "err", "is", "likely", "to", "be", "the", "result", "of", "CrateDB", "not", "implementing", "the", "pg_types", "table", "correctly", ".", "If", "yes", "a", "CrateDB", "specific", "query", "against", "pg_type...
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn.go#L545-L609
146,850
jackc/pgx
conn.go
LocalAddr
func (c *Conn) LocalAddr() (net.Addr, error) { if !c.IsAlive() { return nil, errors.New("connection not ready") } return c.conn.LocalAddr(), nil }
go
func (c *Conn) LocalAddr() (net.Addr, error) { if !c.IsAlive() { return nil, errors.New("connection not ready") } return c.conn.LocalAddr(), nil }
[ "func", "(", "c", "*", "Conn", ")", "LocalAddr", "(", ")", "(", "net", ".", "Addr", ",", "error", ")", "{", "if", "!", "c", ".", "IsAlive", "(", ")", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "r...
// LocalAddr returns the underlying connection's local address
[ "LocalAddr", "returns", "the", "underlying", "connection", "s", "local", "address" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn.go#L617-L622
146,851
jackc/pgx
conn.go
Close
func (c *Conn) Close() (err error) { c.mux.Lock() defer c.mux.Unlock() if c.status < connStatusIdle { return nil } c.status = connStatusClosed defer func() { c.conn.Close() c.causeOfDeath = errors.New("Closed") if c.shouldLog(LogLevelInfo) { c.log(LogLevelInfo, "closed connection", nil) } }() er...
go
func (c *Conn) Close() (err error) { c.mux.Lock() defer c.mux.Unlock() if c.status < connStatusIdle { return nil } c.status = connStatusClosed defer func() { c.conn.Close() c.causeOfDeath = errors.New("Closed") if c.shouldLog(LogLevelInfo) { c.log(LogLevelInfo, "closed connection", nil) } }() er...
[ "func", "(", "c", "*", "Conn", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "c", ".", "mux", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mux", ".", "Unlock", "(", ")", "\n\n", "if", "c", ".", "status", "<", "connStatusIdle", "{...
// Close closes a connection. It is safe to call Close on a already closed // connection.
[ "Close", "closes", "a", "connection", ".", "It", "is", "safe", "to", "call", "Close", "on", "a", "already", "closed", "connection", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn.go#L626-L667
146,852
jackc/pgx
conn.go
Merge
func (old ConnConfig) Merge(other ConnConfig) ConnConfig { cc := old if other.Host != "" { cc.Host = other.Host } if other.Port != 0 { cc.Port = other.Port } if other.Database != "" { cc.Database = other.Database } if other.User != "" { cc.User = other.User } if other.Password != "" { cc.Password =...
go
func (old ConnConfig) Merge(other ConnConfig) ConnConfig { cc := old if other.Host != "" { cc.Host = other.Host } if other.Port != 0 { cc.Port = other.Port } if other.Database != "" { cc.Database = other.Database } if other.User != "" { cc.User = other.User } if other.Password != "" { cc.Password =...
[ "func", "(", "old", "ConnConfig", ")", "Merge", "(", "other", "ConnConfig", ")", "ConnConfig", "{", "cc", ":=", "old", "\n\n", "if", "other", ".", "Host", "!=", "\"", "\"", "{", "cc", ".", "Host", "=", "other", ".", "Host", "\n", "}", "\n", "if", ...
// Merge returns a new ConnConfig with the attributes of old and other // combined. When an attribute is set on both, other takes precedence. // // As a security precaution, if the other TLSConfig is nil, all old TLS // attributes will be preserved.
[ "Merge", "returns", "a", "new", "ConnConfig", "with", "the", "attributes", "of", "old", "and", "other", "combined", ".", "When", "an", "attribute", "is", "set", "on", "both", "other", "takes", "precedence", ".", "As", "a", "security", "precaution", "if", "...
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn.go#L674-L721
146,853
jackc/pgx
conn.go
ParseURI
func ParseURI(uri string) (ConnConfig, error) { var cp ConnConfig url, err := url.Parse(uri) if err != nil { return cp, err } if url.User != nil { cp.User = url.User.Username() cp.Password, _ = url.User.Password() } parts := strings.SplitN(url.Host, ":", 2) cp.Host = parts[0] if len(parts) == 2 { p,...
go
func ParseURI(uri string) (ConnConfig, error) { var cp ConnConfig url, err := url.Parse(uri) if err != nil { return cp, err } if url.User != nil { cp.User = url.User.Username() cp.Password, _ = url.User.Password() } parts := strings.SplitN(url.Host, ":", 2) cp.Host = parts[0] if len(parts) == 2 { p,...
[ "func", "ParseURI", "(", "uri", "string", ")", "(", "ConnConfig", ",", "error", ")", "{", "var", "cp", "ConnConfig", "\n\n", "url", ",", "err", ":=", "url", ".", "Parse", "(", "uri", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cp", ",", ...
// ParseURI parses a database URI into ConnConfig // // Query parameters not used by the connection process are parsed into ConnConfig.RuntimeParams.
[ "ParseURI", "parses", "a", "database", "URI", "into", "ConnConfig", "Query", "parameters", "not", "used", "by", "the", "connection", "process", "are", "parsed", "into", "ConnConfig", ".", "RuntimeParams", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn.go#L726-L797
146,854
jackc/pgx
conn.go
ParseConnectionString
func ParseConnectionString(s string) (ConnConfig, error) { if u, err := url.Parse(s); err == nil && u.Scheme != "" { return ParseURI(s) } return ParseDSN(s) }
go
func ParseConnectionString(s string) (ConnConfig, error) { if u, err := url.Parse(s); err == nil && u.Scheme != "" { return ParseURI(s) } return ParseDSN(s) }
[ "func", "ParseConnectionString", "(", "s", "string", ")", "(", "ConnConfig", ",", "error", ")", "{", "if", "u", ",", "err", ":=", "url", ".", "Parse", "(", "s", ")", ";", "err", "==", "nil", "&&", "u", ".", "Scheme", "!=", "\"", "\"", "{", "retur...
// ParseConnectionString parses either a URI or a DSN connection string. // see ParseURI and ParseDSN for details.
[ "ParseConnectionString", "parses", "either", "a", "URI", "or", "a", "DSN", "connection", "string", ".", "see", "ParseURI", "and", "ParseDSN", "for", "details", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn.go#L870-L875
146,855
jackc/pgx
conn.go
Deallocate
func (c *Conn) Deallocate(name string) error { return c.deallocateContext(context.Background(), name) }
go
func (c *Conn) Deallocate(name string) error { return c.deallocateContext(context.Background(), name) }
[ "func", "(", "c", "*", "Conn", ")", "Deallocate", "(", "name", "string", ")", "error", "{", "return", "c", ".", "deallocateContext", "(", "context", ".", "Background", "(", ")", ",", "name", ")", "\n", "}" ]
// Deallocate released a prepared statement
[ "Deallocate", "released", "a", "prepared", "statement" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn.go#L1155-L1157
146,856
jackc/pgx
conn.go
Unlisten
func (c *Conn) Unlisten(channel string) error { _, err := c.Exec("unlisten " + quoteIdentifier(channel)) if err != nil { return err } delete(c.channels, channel) return nil }
go
func (c *Conn) Unlisten(channel string) error { _, err := c.Exec("unlisten " + quoteIdentifier(channel)) if err != nil { return err } delete(c.channels, channel) return nil }
[ "func", "(", "c", "*", "Conn", ")", "Unlisten", "(", "channel", "string", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "Exec", "(", "\"", "\"", "+", "quoteIdentifier", "(", "channel", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return"...
// Unlisten unsubscribes from a listen channel
[ "Unlisten", "unsubscribes", "from", "a", "listen", "channel" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn.go#L1231-L1239
146,857
jackc/pgx
conn.go
WaitForNotification
func (c *Conn) WaitForNotification(ctx context.Context) (notification *Notification, err error) { // Return already received notification immediately if len(c.notifications) > 0 { notification := c.notifications[0] c.notifications = c.notifications[1:] return notification, nil } err = c.waitForPreviousCancel...
go
func (c *Conn) WaitForNotification(ctx context.Context) (notification *Notification, err error) { // Return already received notification immediately if len(c.notifications) > 0 { notification := c.notifications[0] c.notifications = c.notifications[1:] return notification, nil } err = c.waitForPreviousCancel...
[ "func", "(", "c", "*", "Conn", ")", "WaitForNotification", "(", "ctx", "context", ".", "Context", ")", "(", "notification", "*", "Notification", ",", "err", "error", ")", "{", "// Return already received notification immediately", "if", "len", "(", "c", ".", "...
// WaitForNotification waits for a PostgreSQL notification.
[ "WaitForNotification", "waits", "for", "a", "PostgreSQL", "notification", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn.go#L1242-L1293
146,858
jackc/pgx
conn.go
processContextFreeMsg
func (c *Conn) processContextFreeMsg(msg pgproto3.BackendMessage) (err error) { switch msg := msg.(type) { case *pgproto3.ErrorResponse: return c.rxErrorResponse(msg) case *pgproto3.NoticeResponse: c.rxNoticeResponse(msg) case *pgproto3.NotificationResponse: c.rxNotificationResponse(msg) case *pgproto3.Ready...
go
func (c *Conn) processContextFreeMsg(msg pgproto3.BackendMessage) (err error) { switch msg := msg.(type) { case *pgproto3.ErrorResponse: return c.rxErrorResponse(msg) case *pgproto3.NoticeResponse: c.rxNoticeResponse(msg) case *pgproto3.NotificationResponse: c.rxNotificationResponse(msg) case *pgproto3.Ready...
[ "func", "(", "c", "*", "Conn", ")", "processContextFreeMsg", "(", "msg", "pgproto3", ".", "BackendMessage", ")", "(", "err", "error", ")", "{", "switch", "msg", ":=", "msg", ".", "(", "type", ")", "{", "case", "*", "pgproto3", ".", "ErrorResponse", ":"...
// Processes messages that are not exclusive to one context such as // authentication or query response. The response to these messages is the same // regardless of when they occur. It also ignores messages that are only // meaningful in a given context. These messages can occur due to a context // deadline interruptin...
[ "Processes", "messages", "that", "are", "not", "exclusive", "to", "one", "context", "such", "as", "authentication", "or", "query", "response", ".", "The", "response", "to", "these", "messages", "is", "the", "same", "regardless", "of", "when", "they", "occur", ...
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn.go#L1383-L1398
146,859
jackc/pgx
conn.go
SetLogger
func (c *Conn) SetLogger(logger Logger) Logger { oldLogger := c.logger c.logger = logger return oldLogger }
go
func (c *Conn) SetLogger(logger Logger) Logger { oldLogger := c.logger c.logger = logger return oldLogger }
[ "func", "(", "c", "*", "Conn", ")", "SetLogger", "(", "logger", "Logger", ")", "Logger", "{", "oldLogger", ":=", "c", ".", "logger", "\n", "c", ".", "logger", "=", "logger", "\n", "return", "oldLogger", "\n", "}" ]
// SetLogger replaces the current logger and returns the previous logger.
[ "SetLogger", "replaces", "the", "current", "logger", "and", "returns", "the", "previous", "logger", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn.go#L1630-L1634
146,860
jackc/pgx
conn.go
SetLogLevel
func (c *Conn) SetLogLevel(lvl LogLevel) (LogLevel, error) { oldLvl := c.logLevel if lvl < LogLevelNone || lvl > LogLevelTrace { return oldLvl, ErrInvalidLogLevel } c.logLevel = lvl return lvl, nil }
go
func (c *Conn) SetLogLevel(lvl LogLevel) (LogLevel, error) { oldLvl := c.logLevel if lvl < LogLevelNone || lvl > LogLevelTrace { return oldLvl, ErrInvalidLogLevel } c.logLevel = lvl return lvl, nil }
[ "func", "(", "c", "*", "Conn", ")", "SetLogLevel", "(", "lvl", "LogLevel", ")", "(", "LogLevel", ",", "error", ")", "{", "oldLvl", ":=", "c", ".", "logLevel", "\n\n", "if", "lvl", "<", "LogLevelNone", "||", "lvl", ">", "LogLevelTrace", "{", "return", ...
// SetLogLevel replaces the current log level and returns the previous log // level.
[ "SetLogLevel", "replaces", "the", "current", "log", "level", "and", "returns", "the", "previous", "log", "level", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn.go#L1638-L1647
146,861
jackc/pgx
conn.go
WaitUntilReady
func (c *Conn) WaitUntilReady(ctx context.Context) error { err := c.waitForPreviousCancelQuery(ctx) if err != nil { return err } return c.ensureConnectionReadyForQuery() }
go
func (c *Conn) WaitUntilReady(ctx context.Context) error { err := c.waitForPreviousCancelQuery(ctx) if err != nil { return err } return c.ensureConnectionReadyForQuery() }
[ "func", "(", "c", "*", "Conn", ")", "WaitUntilReady", "(", "ctx", "context", ".", "Context", ")", "error", "{", "err", ":=", "c", ".", "waitForPreviousCancelQuery", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n...
// WaitUntilReady will return when the connection is ready for another query
[ "WaitUntilReady", "will", "return", "when", "the", "connection", "is", "ready", "for", "another", "query" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn.go#L1904-L1910
146,862
jackc/pgx
replication.go
SendStandbyStatus
func (rc *ReplicationConn) SendStandbyStatus(k *StandbyStatus) (err error) { buf := rc.wbuf buf = append(buf, copyData) sp := len(buf) buf = pgio.AppendInt32(buf, -1) buf = append(buf, standbyStatusUpdate) buf = pgio.AppendInt64(buf, int64(k.WalWritePosition)) buf = pgio.AppendInt64(buf, int64(k.WalFlushPositio...
go
func (rc *ReplicationConn) SendStandbyStatus(k *StandbyStatus) (err error) { buf := rc.wbuf buf = append(buf, copyData) sp := len(buf) buf = pgio.AppendInt32(buf, -1) buf = append(buf, standbyStatusUpdate) buf = pgio.AppendInt64(buf, int64(k.WalWritePosition)) buf = pgio.AppendInt64(buf, int64(k.WalFlushPositio...
[ "func", "(", "rc", "*", "ReplicationConn", ")", "SendStandbyStatus", "(", "k", "*", "StandbyStatus", ")", "(", "err", "error", ")", "{", "buf", ":=", "rc", ".", "wbuf", "\n", "buf", "=", "append", "(", "buf", ",", "copyData", ")", "\n", "sp", ":=", ...
// Send standby status to the server, which both acts as a keepalive // message to the server, as well as carries the WAL position of the // client, which then updates the server's replication slot position.
[ "Send", "standby", "status", "to", "the", "server", "which", "both", "acts", "as", "a", "keepalive", "message", "to", "the", "server", "as", "well", "as", "carries", "the", "WAL", "position", "of", "the", "client", "which", "then", "updates", "the", "serve...
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/replication.go#L193-L214
146,863
jackc/pgx
replication.go
CreateReplicationSlot
func (rc *ReplicationConn) CreateReplicationSlot(slotName, outputPlugin string) (err error) { _, err = rc.Exec(fmt.Sprintf("CREATE_REPLICATION_SLOT %s LOGICAL %s NOEXPORT_SNAPSHOT", slotName, outputPlugin)) return }
go
func (rc *ReplicationConn) CreateReplicationSlot(slotName, outputPlugin string) (err error) { _, err = rc.Exec(fmt.Sprintf("CREATE_REPLICATION_SLOT %s LOGICAL %s NOEXPORT_SNAPSHOT", slotName, outputPlugin)) return }
[ "func", "(", "rc", "*", "ReplicationConn", ")", "CreateReplicationSlot", "(", "slotName", ",", "outputPlugin", "string", ")", "(", "err", "error", ")", "{", "_", ",", "err", "=", "rc", ".", "Exec", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s...
// Create the replication slot, using the given name and output plugin.
[ "Create", "the", "replication", "slot", "using", "the", "given", "name", "and", "output", "plugin", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/replication.go#L443-L446
146,864
jackc/pgx
replication.go
CreateReplicationSlotEx
func (rc *ReplicationConn) CreateReplicationSlotEx(slotName, outputPlugin string) (consistentPoint string, snapshotName string, err error) { var dummy string var rows *Rows rows, err = rc.sendReplicationModeQuery(fmt.Sprintf("CREATE_REPLICATION_SLOT %s LOGICAL %s", slotName, outputPlugin)) defer rows.Close() for r...
go
func (rc *ReplicationConn) CreateReplicationSlotEx(slotName, outputPlugin string) (consistentPoint string, snapshotName string, err error) { var dummy string var rows *Rows rows, err = rc.sendReplicationModeQuery(fmt.Sprintf("CREATE_REPLICATION_SLOT %s LOGICAL %s", slotName, outputPlugin)) defer rows.Close() for r...
[ "func", "(", "rc", "*", "ReplicationConn", ")", "CreateReplicationSlotEx", "(", "slotName", ",", "outputPlugin", "string", ")", "(", "consistentPoint", "string", ",", "snapshotName", "string", ",", "err", "error", ")", "{", "var", "dummy", "string", "\n", "var...
// Create the replication slot, using the given name and output plugin, and return the consistent_point and snapshot_name values.
[ "Create", "the", "replication", "slot", "using", "the", "given", "name", "and", "output", "plugin", "and", "return", "the", "consistent_point", "and", "snapshot_name", "values", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/replication.go#L449-L458
146,865
jackc/pgx
replication.go
DropReplicationSlot
func (rc *ReplicationConn) DropReplicationSlot(slotName string) (err error) { _, err = rc.Exec(fmt.Sprintf("DROP_REPLICATION_SLOT %s", slotName)) return }
go
func (rc *ReplicationConn) DropReplicationSlot(slotName string) (err error) { _, err = rc.Exec(fmt.Sprintf("DROP_REPLICATION_SLOT %s", slotName)) return }
[ "func", "(", "rc", "*", "ReplicationConn", ")", "DropReplicationSlot", "(", "slotName", "string", ")", "(", "err", "error", ")", "{", "_", ",", "err", "=", "rc", ".", "Exec", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "slotName", ")", ")", "...
// Drop the replication slot for the given name
[ "Drop", "the", "replication", "slot", "for", "the", "given", "name" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/replication.go#L461-L464
146,866
jackc/pgx
auth_scram.go
scramAuth
func (c *Conn) scramAuth(serverAuthMechanisms []string) error { sc, err := newScramClient(serverAuthMechanisms, c.config.Password) if err != nil { return err } // Send client-first-message in a SASLInitialResponse saslInitialResponse := &pgproto3.SASLInitialResponse{ AuthMechanism: "SCRAM-SHA-256", Data: ...
go
func (c *Conn) scramAuth(serverAuthMechanisms []string) error { sc, err := newScramClient(serverAuthMechanisms, c.config.Password) if err != nil { return err } // Send client-first-message in a SASLInitialResponse saslInitialResponse := &pgproto3.SASLInitialResponse{ AuthMechanism: "SCRAM-SHA-256", Data: ...
[ "func", "(", "c", "*", "Conn", ")", "scramAuth", "(", "serverAuthMechanisms", "[", "]", "string", ")", "error", "{", "sc", ",", "err", ":=", "newScramClient", "(", "serverAuthMechanisms", ",", "c", ".", "config", ".", "Password", ")", "\n", "if", "err", ...
// Perform SCRAM authentication.
[ "Perform", "SCRAM", "authentication", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/auth_scram.go#L32-L73
146,867
jackc/pgx
copy_from.go
CopyFrom
func (c *Conn) CopyFrom(tableName Identifier, columnNames []string, rowSrc CopyFromSource) (int, error) { ct := &copyFrom{ conn: c, tableName: tableName, columnNames: columnNames, rowSrc: rowSrc, readerErrChan: make(chan error), } return ct.run() }
go
func (c *Conn) CopyFrom(tableName Identifier, columnNames []string, rowSrc CopyFromSource) (int, error) { ct := &copyFrom{ conn: c, tableName: tableName, columnNames: columnNames, rowSrc: rowSrc, readerErrChan: make(chan error), } return ct.run() }
[ "func", "(", "c", "*", "Conn", ")", "CopyFrom", "(", "tableName", "Identifier", ",", "columnNames", "[", "]", "string", ",", "rowSrc", "CopyFromSource", ")", "(", "int", ",", "error", ")", "{", "ct", ":=", "&", "copyFrom", "{", "conn", ":", "c", ",",...
// CopyFrom uses the PostgreSQL copy protocol to perform bulk data insertion. // It returns the number of rows copied and an error. // // 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 en...
[ "CopyFrom", "uses", "the", "PostgreSQL", "copy", "protocol", "to", "perform", "bulk", "data", "insertion", ".", "It", "returns", "the", "number", "of", "rows", "copied", "and", "an", "error", ".", "CopyFrom", "requires", "all", "values", "use", "the", "binar...
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/copy_from.go#L274-L284
146,868
jackc/pgx
copy_from.go
CopyFromReader
func (c *Conn) CopyFromReader(r io.Reader, sql string) (CommandTag, error) { if err := c.sendSimpleQuery(sql); err != nil { return "", err } if err := c.readUntilCopyInResponse(); err != nil { return "", err } buf := c.wbuf buf = append(buf, copyData) sp := len(buf) for { n, err := r.Read(buf[5:cap(buf)...
go
func (c *Conn) CopyFromReader(r io.Reader, sql string) (CommandTag, error) { if err := c.sendSimpleQuery(sql); err != nil { return "", err } if err := c.readUntilCopyInResponse(); err != nil { return "", err } buf := c.wbuf buf = append(buf, copyData) sp := len(buf) for { n, err := r.Read(buf[5:cap(buf)...
[ "func", "(", "c", "*", "Conn", ")", "CopyFromReader", "(", "r", "io", ".", "Reader", ",", "sql", "string", ")", "(", "CommandTag", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "sendSimpleQuery", "(", "sql", ")", ";", "err", "!=", "nil", "...
// CopyFromReader uses the PostgreSQL textual format of the copy protocol
[ "CopyFromReader", "uses", "the", "PostgreSQL", "textual", "format", "of", "the", "copy", "protocol" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/copy_from.go#L287-L338
146,869
jackc/pgx
query.go
Close
func (rows *Rows) Close() { if rows.closed { return } if rows.unlockConn { rows.conn.unlock() rows.unlockConn = false } rows.closed = true rows.err = rows.conn.termContext(rows.err) if rows.err == nil { if rows.conn.shouldLog(LogLevelInfo) { endTime := time.Now() rows.conn.log(LogLevelInfo, "Qu...
go
func (rows *Rows) Close() { if rows.closed { return } if rows.unlockConn { rows.conn.unlock() rows.unlockConn = false } rows.closed = true rows.err = rows.conn.termContext(rows.err) if rows.err == nil { if rows.conn.shouldLog(LogLevelInfo) { endTime := time.Now() rows.conn.log(LogLevelInfo, "Qu...
[ "func", "(", "rows", "*", "Rows", ")", "Close", "(", ")", "{", "if", "rows", ".", "closed", "{", "return", "\n", "}", "\n\n", "if", "rows", ".", "unlockConn", "{", "rows", ".", "conn", ".", "unlock", "(", ")", "\n", "rows", ".", "unlockConn", "="...
// Close closes the rows, making the connection ready for use again. It is safe // to call Close after rows is already closed.
[ "Close", "closes", "the", "rows", "making", "the", "connection", "ready", "for", "use", "again", ".", "It", "is", "safe", "to", "call", "Close", "after", "rows", "is", "already", "closed", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/query.go#L67-L97
146,870
jackc/pgx
query.go
fatal
func (rows *Rows) fatal(err error) { if rows.err != nil { return } rows.err = err rows.Close() }
go
func (rows *Rows) fatal(err error) { if rows.err != nil { return } rows.err = err rows.Close() }
[ "func", "(", "rows", "*", "Rows", ")", "fatal", "(", "err", "error", ")", "{", "if", "rows", ".", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "rows", ".", "err", "=", "err", "\n", "rows", ".", "Close", "(", ")", "\n", "}" ]
// fatal signals an error occurred after the query was sent to the server. It // closes the rows automatically.
[ "fatal", "signals", "an", "error", "occurred", "after", "the", "query", "was", "sent", "to", "the", "server", ".", "It", "closes", "the", "rows", "automatically", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/query.go#L105-L112
146,871
jackc/pgx
query.go
Next
func (rows *Rows) Next() bool { if rows.closed { return false } rows.rowCount++ rows.columnIdx = 0 for { msg, err := rows.conn.rxMsg() if err != nil { rows.fatal(err) return false } switch msg := msg.(type) { case *pgproto3.RowDescription: rows.fields = rows.conn.rxRowDescription(msg) fo...
go
func (rows *Rows) Next() bool { if rows.closed { return false } rows.rowCount++ rows.columnIdx = 0 for { msg, err := rows.conn.rxMsg() if err != nil { rows.fatal(err) return false } switch msg := msg.(type) { case *pgproto3.RowDescription: rows.fields = rows.conn.rxRowDescription(msg) fo...
[ "func", "(", "rows", "*", "Rows", ")", "Next", "(", ")", "bool", "{", "if", "rows", ".", "closed", "{", "return", "false", "\n", "}", "\n\n", "rows", ".", "rowCount", "++", "\n", "rows", ".", "columnIdx", "=", "0", "\n\n", "for", "{", "msg", ",",...
// Next prepares the next row for reading. It returns true if there is another // row and false if no more rows are available. It automatically closes rows // when all rows are read.
[ "Next", "prepares", "the", "next", "row", "for", "reading", ".", "It", "returns", "true", "if", "there", "is", "another", "row", "and", "false", "if", "no", "more", "rows", "are", "available", ".", "It", "automatically", "closes", "rows", "when", "all", ...
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/query.go#L117-L168
146,872
jackc/pgx
query.go
Values
func (rows *Rows) Values() ([]interface{}, error) { if rows.closed { return nil, errors.New("rows is closed") } values := make([]interface{}, 0, len(rows.fields)) for range rows.fields { buf, fd, _ := rows.nextColumn() if buf == nil { values = append(values, nil) continue } if dt, ok := rows.con...
go
func (rows *Rows) Values() ([]interface{}, error) { if rows.closed { return nil, errors.New("rows is closed") } values := make([]interface{}, 0, len(rows.fields)) for range rows.fields { buf, fd, _ := rows.nextColumn() if buf == nil { values = append(values, nil) continue } if dt, ok := rows.con...
[ "func", "(", "rows", "*", "Rows", ")", "Values", "(", ")", "(", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "if", "rows", ".", "closed", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "v...
// Values returns an array of the row values
[ "Values", "returns", "an", "array", "of", "the", "row", "values" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/query.go#L276-L328
146,873
jackc/pgx
large_objects.go
LargeObjects
func (tx *Tx) LargeObjects() (*LargeObjects, error) { if tx.conn.fp == nil { tx.conn.fp = newFastpath(tx.conn) } if _, exists := tx.conn.fp.fns["lo_open"]; !exists { res, err := tx.Query(largeObjectFns) if err != nil { return nil, err } if err := tx.conn.fp.addFunctions(res); err != nil { return nil,...
go
func (tx *Tx) LargeObjects() (*LargeObjects, error) { if tx.conn.fp == nil { tx.conn.fp = newFastpath(tx.conn) } if _, exists := tx.conn.fp.fns["lo_open"]; !exists { res, err := tx.Query(largeObjectFns) if err != nil { return nil, err } if err := tx.conn.fp.addFunctions(res); err != nil { return nil,...
[ "func", "(", "tx", "*", "Tx", ")", "LargeObjects", "(", ")", "(", "*", "LargeObjects", ",", "error", ")", "{", "if", "tx", ".", "conn", ".", "fp", "==", "nil", "{", "tx", ".", "conn", ".", "fp", "=", "newFastpath", "(", "tx", ".", "conn", ")", ...
// LargeObjects returns a LargeObjects instance for the transaction.
[ "LargeObjects", "returns", "a", "LargeObjects", "instance", "for", "the", "transaction", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/large_objects.go#L36-L54
146,874
jackc/pgx
large_objects.go
Create
func (o *LargeObjects) Create(id pgtype.OID) (pgtype.OID, error) { newOID, err := fpInt32(o.fp.CallFn("lo_create", []fpArg{fpIntArg(int32(id))})) return pgtype.OID(newOID), err }
go
func (o *LargeObjects) Create(id pgtype.OID) (pgtype.OID, error) { newOID, err := fpInt32(o.fp.CallFn("lo_create", []fpArg{fpIntArg(int32(id))})) return pgtype.OID(newOID), err }
[ "func", "(", "o", "*", "LargeObjects", ")", "Create", "(", "id", "pgtype", ".", "OID", ")", "(", "pgtype", ".", "OID", ",", "error", ")", "{", "newOID", ",", "err", ":=", "fpInt32", "(", "o", ".", "fp", ".", "CallFn", "(", "\"", "\"", ",", "[",...
// Create creates a new large object. If id is zero, the server assigns an // unused OID.
[ "Create", "creates", "a", "new", "large", "object", ".", "If", "id", "is", "zero", "the", "server", "assigns", "an", "unused", "OID", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/large_objects.go#L65-L68
146,875
jackc/pgx
large_objects.go
Open
func (o *LargeObjects) Open(oid pgtype.OID, mode LargeObjectMode) (*LargeObject, error) { fd, err := fpInt32(o.fp.CallFn("lo_open", []fpArg{fpIntArg(int32(oid)), fpIntArg(int32(mode))})) return &LargeObject{fd: fd, lo: o}, err }
go
func (o *LargeObjects) Open(oid pgtype.OID, mode LargeObjectMode) (*LargeObject, error) { fd, err := fpInt32(o.fp.CallFn("lo_open", []fpArg{fpIntArg(int32(oid)), fpIntArg(int32(mode))})) return &LargeObject{fd: fd, lo: o}, err }
[ "func", "(", "o", "*", "LargeObjects", ")", "Open", "(", "oid", "pgtype", ".", "OID", ",", "mode", "LargeObjectMode", ")", "(", "*", "LargeObject", ",", "error", ")", "{", "fd", ",", "err", ":=", "fpInt32", "(", "o", ".", "fp", ".", "CallFn", "(", ...
// Open opens an existing large object with the given mode.
[ "Open", "opens", "an", "existing", "large", "object", "with", "the", "given", "mode", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/large_objects.go#L71-L74
146,876
jackc/pgx
large_objects.go
Unlink
func (o *LargeObjects) Unlink(oid pgtype.OID) error { _, err := o.fp.CallFn("lo_unlink", []fpArg{fpIntArg(int32(oid))}) return err }
go
func (o *LargeObjects) Unlink(oid pgtype.OID) error { _, err := o.fp.CallFn("lo_unlink", []fpArg{fpIntArg(int32(oid))}) return err }
[ "func", "(", "o", "*", "LargeObjects", ")", "Unlink", "(", "oid", "pgtype", ".", "OID", ")", "error", "{", "_", ",", "err", ":=", "o", ".", "fp", ".", "CallFn", "(", "\"", "\"", ",", "[", "]", "fpArg", "{", "fpIntArg", "(", "int32", "(", "oid",...
// Unlink removes a large object from the database.
[ "Unlink", "removes", "a", "large", "object", "from", "the", "database", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/large_objects.go#L77-L80
146,877
jackc/pgx
large_objects.go
Write
func (o *LargeObject) Write(p []byte) (int, error) { n, err := fpInt32(o.lo.fp.CallFn("lowrite", []fpArg{fpIntArg(o.fd), p})) return int(n), err }
go
func (o *LargeObject) Write(p []byte) (int, error) { n, err := fpInt32(o.lo.fp.CallFn("lowrite", []fpArg{fpIntArg(o.fd), p})) return int(n), err }
[ "func", "(", "o", "*", "LargeObject", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "n", ",", "err", ":=", "fpInt32", "(", "o", ".", "lo", ".", "fp", ".", "CallFn", "(", "\"", "\"", ",", "[", "]", "fpArg...
// Write writes p to the large object and returns the number of bytes written // and an error if not all of p was written.
[ "Write", "writes", "p", "to", "the", "large", "object", "and", "returns", "the", "number", "of", "bytes", "written", "and", "an", "error", "if", "not", "all", "of", "p", "was", "written", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/large_objects.go#L96-L99
146,878
jackc/pgx
large_objects.go
Seek
func (o *LargeObject) Seek(offset int64, whence int) (n int64, err error) { if o.lo.Has64 { n, err = fpInt64(o.lo.fp.CallFn("lo_lseek64", []fpArg{fpIntArg(o.fd), fpInt64Arg(offset), fpIntArg(int32(whence))})) } else { var n32 int32 n32, err = fpInt32(o.lo.fp.CallFn("lo_lseek", []fpArg{fpIntArg(o.fd), fpIntArg(i...
go
func (o *LargeObject) Seek(offset int64, whence int) (n int64, err error) { if o.lo.Has64 { n, err = fpInt64(o.lo.fp.CallFn("lo_lseek64", []fpArg{fpIntArg(o.fd), fpInt64Arg(offset), fpIntArg(int32(whence))})) } else { var n32 int32 n32, err = fpInt32(o.lo.fp.CallFn("lo_lseek", []fpArg{fpIntArg(o.fd), fpIntArg(i...
[ "func", "(", "o", "*", "LargeObject", ")", "Seek", "(", "offset", "int64", ",", "whence", "int", ")", "(", "n", "int64", ",", "err", "error", ")", "{", "if", "o", ".", "lo", ".", "Has64", "{", "n", ",", "err", "=", "fpInt64", "(", "o", ".", "...
// Seek moves the current location pointer to the new location specified by offset.
[ "Seek", "moves", "the", "current", "location", "pointer", "to", "the", "new", "location", "specified", "by", "offset", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/large_objects.go#L111-L120
146,879
jackc/pgx
large_objects.go
Tell
func (o *LargeObject) Tell() (n int64, err error) { if o.lo.Has64 { n, err = fpInt64(o.lo.fp.CallFn("lo_tell64", []fpArg{fpIntArg(o.fd)})) } else { var n32 int32 n32, err = fpInt32(o.lo.fp.CallFn("lo_tell", []fpArg{fpIntArg(o.fd)})) n = int64(n32) } return }
go
func (o *LargeObject) Tell() (n int64, err error) { if o.lo.Has64 { n, err = fpInt64(o.lo.fp.CallFn("lo_tell64", []fpArg{fpIntArg(o.fd)})) } else { var n32 int32 n32, err = fpInt32(o.lo.fp.CallFn("lo_tell", []fpArg{fpIntArg(o.fd)})) n = int64(n32) } return }
[ "func", "(", "o", "*", "LargeObject", ")", "Tell", "(", ")", "(", "n", "int64", ",", "err", "error", ")", "{", "if", "o", ".", "lo", ".", "Has64", "{", "n", ",", "err", "=", "fpInt64", "(", "o", ".", "lo", ".", "fp", ".", "CallFn", "(", "\"...
// Tell returns the current read or write location of the large object // descriptor.
[ "Tell", "returns", "the", "current", "read", "or", "write", "location", "of", "the", "large", "object", "descriptor", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/large_objects.go#L124-L133
146,880
jackc/pgx
large_objects.go
Truncate
func (o *LargeObject) Truncate(size int64) (err error) { if o.lo.Has64 { _, err = o.lo.fp.CallFn("lo_truncate64", []fpArg{fpIntArg(o.fd), fpInt64Arg(size)}) } else { _, err = o.lo.fp.CallFn("lo_truncate", []fpArg{fpIntArg(o.fd), fpIntArg(int32(size))}) } return }
go
func (o *LargeObject) Truncate(size int64) (err error) { if o.lo.Has64 { _, err = o.lo.fp.CallFn("lo_truncate64", []fpArg{fpIntArg(o.fd), fpInt64Arg(size)}) } else { _, err = o.lo.fp.CallFn("lo_truncate", []fpArg{fpIntArg(o.fd), fpIntArg(int32(size))}) } return }
[ "func", "(", "o", "*", "LargeObject", ")", "Truncate", "(", "size", "int64", ")", "(", "err", "error", ")", "{", "if", "o", ".", "lo", ".", "Has64", "{", "_", ",", "err", "=", "o", ".", "lo", ".", "fp", ".", "CallFn", "(", "\"", "\"", ",", ...
// Trunctes the large object to size.
[ "Trunctes", "the", "large", "object", "to", "size", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/large_objects.go#L136-L143
146,881
jackc/pgx
large_objects.go
Close
func (o *LargeObject) Close() error { _, err := o.lo.fp.CallFn("lo_close", []fpArg{fpIntArg(o.fd)}) return err }
go
func (o *LargeObject) Close() error { _, err := o.lo.fp.CallFn("lo_close", []fpArg{fpIntArg(o.fd)}) return err }
[ "func", "(", "o", "*", "LargeObject", ")", "Close", "(", ")", "error", "{", "_", ",", "err", ":=", "o", ".", "lo", ".", "fp", ".", "CallFn", "(", "\"", "\"", ",", "[", "]", "fpArg", "{", "fpIntArg", "(", "o", ".", "fd", ")", "}", ")", "\n",...
// Close closees the large object descriptor.
[ "Close", "closees", "the", "large", "object", "descriptor", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/large_objects.go#L146-L149
146,882
jackc/pgx
values.go
chooseParameterFormatCode
func chooseParameterFormatCode(ci *pgtype.ConnInfo, oid pgtype.OID, arg interface{}) int16 { switch arg.(type) { case pgtype.BinaryEncoder: return BinaryFormatCode case string, *string, pgtype.TextEncoder: return TextFormatCode } if dt, ok := ci.DataTypeForOID(oid); ok { if _, ok := dt.Value.(pgtype.BinaryE...
go
func chooseParameterFormatCode(ci *pgtype.ConnInfo, oid pgtype.OID, arg interface{}) int16 { switch arg.(type) { case pgtype.BinaryEncoder: return BinaryFormatCode case string, *string, pgtype.TextEncoder: return TextFormatCode } if dt, ok := ci.DataTypeForOID(oid); ok { if _, ok := dt.Value.(pgtype.BinaryE...
[ "func", "chooseParameterFormatCode", "(", "ci", "*", "pgtype", ".", "ConnInfo", ",", "oid", "pgtype", ".", "OID", ",", "arg", "interface", "{", "}", ")", "int16", "{", "switch", "arg", ".", "(", "type", ")", "{", "case", "pgtype", ".", "BinaryEncoder", ...
// chooseParameterFormatCode determines the correct format code for an // argument to a prepared statement. It defaults to TextFormatCode if no // determination can be made.
[ "chooseParameterFormatCode", "determines", "the", "correct", "format", "code", "for", "an", "argument", "to", "a", "prepared", "statement", ".", "It", "defaults", "to", "TextFormatCode", "if", "no", "determination", "can", "be", "made", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/values.go#L220-L235
146,883
jackc/pgx
internal/sanitize/sanitize.go
SanitizeSQL
func SanitizeSQL(sql string, args ...interface{}) (string, error) { query, err := NewQuery(sql) if err != nil { return "", err } return query.Sanitize(args...) }
go
func SanitizeSQL(sql string, args ...interface{}) (string, error) { query, err := NewQuery(sql) if err != nil { return "", err } return query.Sanitize(args...) }
[ "func", "SanitizeSQL", "(", "sql", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "query", ",", "err", ":=", "NewQuery", "(", "sql", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ...
// SanitizeSQL replaces placeholder values with args. It quotes and escapes args // as necessary. This function is only safe when standard_conforming_strings is // on.
[ "SanitizeSQL", "replaces", "placeholder", "values", "with", "args", ".", "It", "quotes", "and", "escapes", "args", "as", "necessary", ".", "This", "function", "is", "only", "safe", "when", "standard_conforming_strings", "is", "on", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/internal/sanitize/sanitize.go#L231-L237
146,884
jackc/pgx
conn_pool.go
NewConnPool
func NewConnPool(config ConnPoolConfig) (p *ConnPool, err error) { p = new(ConnPool) p.config = config.ConnConfig p.connInfo = minimalConnInfo p.maxConnections = config.MaxConnections if p.maxConnections == 0 { p.maxConnections = 5 } if p.maxConnections < 1 { return nil, errors.New("MaxConnections must be at...
go
func NewConnPool(config ConnPoolConfig) (p *ConnPool, err error) { p = new(ConnPool) p.config = config.ConnConfig p.connInfo = minimalConnInfo p.maxConnections = config.MaxConnections if p.maxConnections == 0 { p.maxConnections = 5 } if p.maxConnections < 1 { return nil, errors.New("MaxConnections must be at...
[ "func", "NewConnPool", "(", "config", "ConnPoolConfig", ")", "(", "p", "*", "ConnPool", ",", "err", "error", ")", "{", "p", "=", "new", "(", "ConnPool", ")", "\n", "p", ".", "config", "=", "config", ".", "ConnConfig", "\n", "p", ".", "connInfo", "=",...
// NewConnPool creates a new ConnPool. config.ConnConfig is passed through to // Connect directly.
[ "NewConnPool", "creates", "a", "new", "ConnPool", ".", "config", ".", "ConnConfig", "is", "passed", "through", "to", "Connect", "directly", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn_pool.go#L58-L103
146,885
jackc/pgx
conn_pool.go
Acquire
func (p *ConnPool) Acquire() (*Conn, error) { p.cond.L.Lock() c, err := p.acquire(nil) p.cond.L.Unlock() return c, err }
go
func (p *ConnPool) Acquire() (*Conn, error) { p.cond.L.Lock() c, err := p.acquire(nil) p.cond.L.Unlock() return c, err }
[ "func", "(", "p", "*", "ConnPool", ")", "Acquire", "(", ")", "(", "*", "Conn", ",", "error", ")", "{", "p", ".", "cond", ".", "L", ".", "Lock", "(", ")", "\n", "c", ",", "err", ":=", "p", ".", "acquire", "(", "nil", ")", "\n", "p", ".", "...
// Acquire takes exclusive use of a connection until it is released.
[ "Acquire", "takes", "exclusive", "use", "of", "a", "connection", "until", "it", "is", "released", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn_pool.go#L106-L111
146,886
jackc/pgx
conn_pool.go
deadlinePassed
func (p *ConnPool) deadlinePassed(deadline *time.Time) bool { return deadline != nil && time.Now().After(*deadline) }
go
func (p *ConnPool) deadlinePassed(deadline *time.Time) bool { return deadline != nil && time.Now().After(*deadline) }
[ "func", "(", "p", "*", "ConnPool", ")", "deadlinePassed", "(", "deadline", "*", "time", ".", "Time", ")", "bool", "{", "return", "deadline", "!=", "nil", "&&", "time", ".", "Now", "(", ")", ".", "After", "(", "*", "deadline", ")", "\n", "}" ]
// deadlinePassed returns true if the given deadline has passed.
[ "deadlinePassed", "returns", "true", "if", "the", "given", "deadline", "has", "passed", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn_pool.go#L114-L116
146,887
jackc/pgx
conn_pool.go
acquire
func (p *ConnPool) acquire(deadline *time.Time) (*Conn, error) { if p.closed { return nil, ErrClosedPool } // A connection is available // The pool works like a queue. Available connection will be returned // from the head. A new connection will be added to the tail. numAvailable := len(p.availableConnections)...
go
func (p *ConnPool) acquire(deadline *time.Time) (*Conn, error) { if p.closed { return nil, ErrClosedPool } // A connection is available // The pool works like a queue. Available connection will be returned // from the head. A new connection will be added to the tail. numAvailable := len(p.availableConnections)...
[ "func", "(", "p", "*", "ConnPool", ")", "acquire", "(", "deadline", "*", "time", ".", "Time", ")", "(", "*", "Conn", ",", "error", ")", "{", "if", "p", ".", "closed", "{", "return", "nil", ",", "ErrClosedPool", "\n", "}", "\n\n", "// A connection is ...
// acquire performs acquision assuming pool is already locked
[ "acquire", "performs", "acquision", "assuming", "pool", "is", "already", "locked" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn_pool.go#L119-L188
146,888
jackc/pgx
conn_pool.go
Release
func (p *ConnPool) Release(conn *Conn) { if conn.ctxInProgress { panic("should never release when context is in progress") } if conn.txStatus != 'I' { conn.Exec("rollback") } if len(conn.channels) > 0 { if err := conn.Unlisten("*"); err != nil { conn.die(err) } conn.channels = make(map[string]struct...
go
func (p *ConnPool) Release(conn *Conn) { if conn.ctxInProgress { panic("should never release when context is in progress") } if conn.txStatus != 'I' { conn.Exec("rollback") } if len(conn.channels) > 0 { if err := conn.Unlisten("*"); err != nil { conn.die(err) } conn.channels = make(map[string]struct...
[ "func", "(", "p", "*", "ConnPool", ")", "Release", "(", "conn", "*", "Conn", ")", "{", "if", "conn", ".", "ctxInProgress", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "conn", ".", "txStatus", "!=", "'I'", "{", "conn", ".", "Exec"...
// Release gives up use of a connection.
[ "Release", "gives", "up", "use", "of", "a", "connection", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn_pool.go#L191-L224
146,889
jackc/pgx
conn_pool.go
removeFromAllConnections
func (p *ConnPool) removeFromAllConnections(conn *Conn) bool { for i, c := range p.allConnections { if conn == c { p.allConnections = append(p.allConnections[:i], p.allConnections[i+1:]...) return true } } return false }
go
func (p *ConnPool) removeFromAllConnections(conn *Conn) bool { for i, c := range p.allConnections { if conn == c { p.allConnections = append(p.allConnections[:i], p.allConnections[i+1:]...) return true } } return false }
[ "func", "(", "p", "*", "ConnPool", ")", "removeFromAllConnections", "(", "conn", "*", "Conn", ")", "bool", "{", "for", "i", ",", "c", ":=", "range", "p", ".", "allConnections", "{", "if", "conn", "==", "c", "{", "p", ".", "allConnections", "=", "appe...
// removeFromAllConnections Removes the given connection from the list. // It returns true if the connection was found and removed or false otherwise.
[ "removeFromAllConnections", "Removes", "the", "given", "connection", "from", "the", "list", ".", "It", "returns", "true", "if", "the", "connection", "was", "found", "and", "removed", "or", "false", "otherwise", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn_pool.go#L228-L236
146,890
jackc/pgx
conn_pool.go
Close
func (p *ConnPool) Close() { p.cond.L.Lock() defer p.cond.L.Unlock() p.closed = true for _, c := range p.availableConnections { _ = c.Close() } // This will cause any checked out connections to be closed on release p.resetCount++ }
go
func (p *ConnPool) Close() { p.cond.L.Lock() defer p.cond.L.Unlock() p.closed = true for _, c := range p.availableConnections { _ = c.Close() } // This will cause any checked out connections to be closed on release p.resetCount++ }
[ "func", "(", "p", "*", "ConnPool", ")", "Close", "(", ")", "{", "p", ".", "cond", ".", "L", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "cond", ".", "L", ".", "Unlock", "(", ")", "\n\n", "p", ".", "closed", "=", "true", "\n\n", "for", "...
// Close ends the use of a connection pool. It prevents any new connections from // being acquired and closes available underlying connections. Any acquired // connections will be closed when they are released.
[ "Close", "ends", "the", "use", "of", "a", "connection", "pool", ".", "It", "prevents", "any", "new", "connections", "from", "being", "acquired", "and", "closes", "available", "underlying", "connections", ".", "Any", "acquired", "connections", "will", "be", "cl...
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn_pool.go#L241-L253
146,891
jackc/pgx
conn_pool.go
invalidateAcquired
func (p *ConnPool) invalidateAcquired() { p.resetCount++ for _, c := range p.availableConnections { c.poolResetCount = p.resetCount } p.allConnections = p.allConnections[:len(p.availableConnections)] copy(p.allConnections, p.availableConnections) }
go
func (p *ConnPool) invalidateAcquired() { p.resetCount++ for _, c := range p.availableConnections { c.poolResetCount = p.resetCount } p.allConnections = p.allConnections[:len(p.availableConnections)] copy(p.allConnections, p.availableConnections) }
[ "func", "(", "p", "*", "ConnPool", ")", "invalidateAcquired", "(", ")", "{", "p", ".", "resetCount", "++", "\n\n", "for", "_", ",", "c", ":=", "range", "p", ".", "availableConnections", "{", "c", ".", "poolResetCount", "=", "p", ".", "resetCount", "\n"...
// invalidateAcquired causes all acquired connections to be closed when released. // The pool must already be locked.
[ "invalidateAcquired", "causes", "all", "acquired", "connections", "to", "be", "closed", "when", "released", ".", "The", "pool", "must", "already", "be", "locked", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn_pool.go#L277-L286
146,892
jackc/pgx
conn_pool.go
Stat
func (p *ConnPool) Stat() (s ConnPoolStat) { p.cond.L.Lock() defer p.cond.L.Unlock() s.MaxConnections = p.maxConnections s.CurrentConnections = len(p.allConnections) s.AvailableConnections = len(p.availableConnections) return }
go
func (p *ConnPool) Stat() (s ConnPoolStat) { p.cond.L.Lock() defer p.cond.L.Unlock() s.MaxConnections = p.maxConnections s.CurrentConnections = len(p.allConnections) s.AvailableConnections = len(p.availableConnections) return }
[ "func", "(", "p", "*", "ConnPool", ")", "Stat", "(", ")", "(", "s", "ConnPoolStat", ")", "{", "p", ".", "cond", ".", "L", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "cond", ".", "L", ".", "Unlock", "(", ")", "\n\n", "s", ".", "MaxConnect...
// Stat returns connection pool statistics
[ "Stat", "returns", "connection", "pool", "statistics" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn_pool.go#L289-L297
146,893
jackc/pgx
conn_pool.go
Exec
func (p *ConnPool) Exec(sql string, arguments ...interface{}) (commandTag CommandTag, err error) { var c *Conn if c, err = p.Acquire(); err != nil { return } defer p.Release(c) return c.Exec(sql, arguments...) }
go
func (p *ConnPool) Exec(sql string, arguments ...interface{}) (commandTag CommandTag, err error) { var c *Conn if c, err = p.Acquire(); err != nil { return } defer p.Release(c) return c.Exec(sql, arguments...) }
[ "func", "(", "p", "*", "ConnPool", ")", "Exec", "(", "sql", "string", ",", "arguments", "...", "interface", "{", "}", ")", "(", "commandTag", "CommandTag", ",", "err", "error", ")", "{", "var", "c", "*", "Conn", "\n", "if", "c", ",", "err", "=", ...
// Exec acquires a connection, delegates the call to that connection, and releases the connection
[ "Exec", "acquires", "a", "connection", "delegates", "the", "call", "to", "that", "connection", "and", "releases", "the", "connection" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn_pool.go#L354-L362
146,894
jackc/pgx
conn_pool.go
Begin
func (p *ConnPool) Begin() (*Tx, error) { return p.BeginEx(context.Background(), nil) }
go
func (p *ConnPool) Begin() (*Tx, error) { return p.BeginEx(context.Background(), nil) }
[ "func", "(", "p", "*", "ConnPool", ")", "Begin", "(", ")", "(", "*", "Tx", ",", "error", ")", "{", "return", "p", ".", "BeginEx", "(", "context", ".", "Background", "(", ")", ",", "nil", ")", "\n", "}" ]
// Begin acquires a connection and begins a transaction on it. When the // transaction is closed the connection will be automatically released.
[ "Begin", "acquires", "a", "connection", "and", "begins", "a", "transaction", "on", "it", ".", "When", "the", "transaction", "is", "closed", "the", "connection", "will", "be", "automatically", "released", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn_pool.go#L427-L429
146,895
jackc/pgx
conn_pool.go
Deallocate
func (p *ConnPool) Deallocate(name string) (err error) { p.cond.L.Lock() defer p.cond.L.Unlock() for _, c := range p.availableConnections { if err := c.Deallocate(name); err != nil { return err } } p.invalidateAcquired() delete(p.preparedStatements, name) return nil }
go
func (p *ConnPool) Deallocate(name string) (err error) { p.cond.L.Lock() defer p.cond.L.Unlock() for _, c := range p.availableConnections { if err := c.Deallocate(name); err != nil { return err } } p.invalidateAcquired() delete(p.preparedStatements, name) return nil }
[ "func", "(", "p", "*", "ConnPool", ")", "Deallocate", "(", "name", "string", ")", "(", "err", "error", ")", "{", "p", ".", "cond", ".", "L", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "cond", ".", "L", ".", "Unlock", "(", ")", "\n\n", "f...
// Deallocate releases a prepared statement from all connections in the pool.
[ "Deallocate", "releases", "a", "prepared", "statement", "from", "all", "connections", "in", "the", "pool", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn_pool.go#L498-L512
146,896
jackc/pgx
conn_pool.go
BeginEx
func (p *ConnPool) BeginEx(ctx context.Context, txOptions *TxOptions) (*Tx, error) { for { c, err := p.Acquire() if err != nil { return nil, err } tx, err := c.BeginEx(ctx, txOptions) if err != nil { alive := c.IsAlive() p.Release(c) // If connection is still alive then the error is not somethi...
go
func (p *ConnPool) BeginEx(ctx context.Context, txOptions *TxOptions) (*Tx, error) { for { c, err := p.Acquire() if err != nil { return nil, err } tx, err := c.BeginEx(ctx, txOptions) if err != nil { alive := c.IsAlive() p.Release(c) // If connection is still alive then the error is not somethi...
[ "func", "(", "p", "*", "ConnPool", ")", "BeginEx", "(", "ctx", "context", ".", "Context", ",", "txOptions", "*", "TxOptions", ")", "(", "*", "Tx", ",", "error", ")", "{", "for", "{", "c", ",", "err", ":=", "p", ".", "Acquire", "(", ")", "\n", "...
// BeginEx acquires a connection and starts a transaction with txOptions // determining the transaction mode. When the transaction is closed the // connection will be automatically released.
[ "BeginEx", "acquires", "a", "connection", "and", "starts", "a", "transaction", "with", "txOptions", "determining", "the", "transaction", "mode", ".", "When", "the", "transaction", "is", "closed", "the", "connection", "will", "be", "automatically", "released", "." ...
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn_pool.go#L517-L542
146,897
jackc/pgx
conn_pool.go
CopyFrom
func (p *ConnPool) CopyFrom(tableName Identifier, columnNames []string, rowSrc CopyFromSource) (int, error) { c, err := p.Acquire() if err != nil { return 0, err } defer p.Release(c) return c.CopyFrom(tableName, columnNames, rowSrc) }
go
func (p *ConnPool) CopyFrom(tableName Identifier, columnNames []string, rowSrc CopyFromSource) (int, error) { c, err := p.Acquire() if err != nil { return 0, err } defer p.Release(c) return c.CopyFrom(tableName, columnNames, rowSrc) }
[ "func", "(", "p", "*", "ConnPool", ")", "CopyFrom", "(", "tableName", "Identifier", ",", "columnNames", "[", "]", "string", ",", "rowSrc", "CopyFromSource", ")", "(", "int", ",", "error", ")", "{", "c", ",", "err", ":=", "p", ".", "Acquire", "(", ")"...
// CopyFrom acquires a connection, delegates the call to that connection, and releases the connection
[ "CopyFrom", "acquires", "a", "connection", "delegates", "the", "call", "to", "that", "connection", "and", "releases", "the", "connection" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn_pool.go#L545-L553
146,898
jackc/pgx
conn_pool.go
CopyFromReader
func (p *ConnPool) CopyFromReader(r io.Reader, sql string) (CommandTag, error) { c, err := p.Acquire() if err != nil { return "", err } defer p.Release(c) return c.CopyFromReader(r, sql) }
go
func (p *ConnPool) CopyFromReader(r io.Reader, sql string) (CommandTag, error) { c, err := p.Acquire() if err != nil { return "", err } defer p.Release(c) return c.CopyFromReader(r, sql) }
[ "func", "(", "p", "*", "ConnPool", ")", "CopyFromReader", "(", "r", "io", ".", "Reader", ",", "sql", "string", ")", "(", "CommandTag", ",", "error", ")", "{", "c", ",", "err", ":=", "p", ".", "Acquire", "(", ")", "\n", "if", "err", "!=", "nil", ...
// CopyFromReader acquires a connection, delegates the call to that connection, and releases the connection
[ "CopyFromReader", "acquires", "a", "connection", "delegates", "the", "call", "to", "that", "connection", "and", "releases", "the", "connection" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn_pool.go#L556-L564
146,899
jackc/pgx
conn_pool.go
CopyToWriter
func (p *ConnPool) CopyToWriter(w io.Writer, sql string, args ...interface{}) (CommandTag, error) { c, err := p.Acquire() if err != nil { return "", err } defer p.Release(c) return c.CopyToWriter(w, sql, args...) }
go
func (p *ConnPool) CopyToWriter(w io.Writer, sql string, args ...interface{}) (CommandTag, error) { c, err := p.Acquire() if err != nil { return "", err } defer p.Release(c) return c.CopyToWriter(w, sql, args...) }
[ "func", "(", "p", "*", "ConnPool", ")", "CopyToWriter", "(", "w", "io", ".", "Writer", ",", "sql", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "CommandTag", ",", "error", ")", "{", "c", ",", "err", ":=", "p", ".", "Acquire", "(...
// CopyToWriter acquires a connection, delegates the call to that connection, and releases the connection
[ "CopyToWriter", "acquires", "a", "connection", "delegates", "the", "call", "to", "that", "connection", "and", "releases", "the", "connection" ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/conn_pool.go#L567-L575