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 list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
24,800 | 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 |
24,801 | 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 |
24,802 | 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 |
24,803 | 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 |
24,804 | 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 |
24,805 | 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 |
24,806 | 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 |
24,807 | 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 |
24,808 | 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 |
24,809 | 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 |
24,810 | 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 |
24,811 | 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 |
24,812 | 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 |
24,813 | 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 |
24,814 | 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 |
24,815 | 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 |
24,816 | 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 |
24,817 | 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 |
24,818 | 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 |
24,819 | 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 |
24,820 | 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 |
24,821 | 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 |
24,822 | 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 |
24,823 | 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 |
24,824 | 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 |
24,825 | 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 |
24,826 | 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 |
24,827 | 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 |
24,828 | 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 |
24,829 | 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 |
24,830 | 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 |
24,831 | 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 |
24,832 | 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 |
24,833 | 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 |
24,834 | 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 |
24,835 | 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 |
24,836 | 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 |
24,837 | 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 |
24,838 | 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 |
24,839 | 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 |
24,840 | 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 |
24,841 | 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 |
24,842 | 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 |
24,843 | 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 |
24,844 | 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 |
24,845 | 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 |
24,846 | 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 |
24,847 | 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 |
24,848 | 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 |
24,849 | 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 |
24,850 | 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 |
24,851 | jackc/pgx | copy_from.go | CopyFrom | func (c *Conn) CopyFrom(tableName Identifier, columnNames []string, rowSrc CopyFromSource) (int, error) {
ct := ©From{
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 := ©From{
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 |
24,852 | 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 |
24,853 | 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 |
24,854 | 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 |
24,855 | 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 |
24,856 | 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 |
24,857 | 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 |
24,858 | 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 |
24,859 | 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 |
24,860 | 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 |
24,861 | 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 |
24,862 | 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 |
24,863 | 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 |
24,864 | 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 |
24,865 | 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 |
24,866 | 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 |
24,867 | 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 |
24,868 | 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 |
24,869 | 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 |
24,870 | 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 |
24,871 | 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 |
24,872 | 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 |
24,873 | 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 |
24,874 | 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 |
24,875 | 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 |
24,876 | 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 |
24,877 | 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 |
24,878 | 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 |
24,879 | 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 |
24,880 | 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 |
24,881 | 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 |
24,882 | 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 |
24,883 | 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 |
24,884 | jackc/pgx | pgtype/pguint32.go | Set | func (dst *pguint32) Set(src interface{}) error {
switch value := src.(type) {
case int64:
if value < 0 {
return errors.Errorf("%d is less than minimum value for pguint32", value)
}
if value > math.MaxUint32 {
return errors.Errorf("%d is greater than maximum value for pguint32", value)
}
*dst = pguint... | go | func (dst *pguint32) Set(src interface{}) error {
switch value := src.(type) {
case int64:
if value < 0 {
return errors.Errorf("%d is less than minimum value for pguint32", value)
}
if value > math.MaxUint32 {
return errors.Errorf("%d is greater than maximum value for pguint32", value)
}
*dst = pguint... | [
"func",
"(",
"dst",
"*",
"pguint32",
")",
"Set",
"(",
"src",
"interface",
"{",
"}",
")",
"error",
"{",
"switch",
"value",
":=",
"src",
".",
"(",
"type",
")",
"{",
"case",
"int64",
":",
"if",
"value",
"<",
"0",
"{",
"return",
"errors",
".",
"Error... | // Set converts from src to dst. Note that as pguint32 is not a general
// number type Set does not do automatic type conversion as other number
// types do. | [
"Set",
"converts",
"from",
"src",
"to",
"dst",
".",
"Note",
"that",
"as",
"pguint32",
"is",
"not",
"a",
"general",
"number",
"type",
"Set",
"does",
"not",
"do",
"automatic",
"type",
"conversion",
"as",
"other",
"number",
"types",
"do",
"."
] | 25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc | https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/pguint32.go#L23-L40 |
24,885 | jackc/pgx | pgtype/pguint32.go | AssignTo | func (src *pguint32) AssignTo(dst interface{}) error {
switch v := dst.(type) {
case *uint32:
if src.Status == Present {
*v = src.Uint
} else {
return errors.Errorf("cannot assign %v into %T", src, dst)
}
case **uint32:
if src.Status == Present {
n := src.Uint
*v = &n
} else {
*v = nil
}
... | go | func (src *pguint32) AssignTo(dst interface{}) error {
switch v := dst.(type) {
case *uint32:
if src.Status == Present {
*v = src.Uint
} else {
return errors.Errorf("cannot assign %v into %T", src, dst)
}
case **uint32:
if src.Status == Present {
n := src.Uint
*v = &n
} else {
*v = nil
}
... | [
"func",
"(",
"src",
"*",
"pguint32",
")",
"AssignTo",
"(",
"dst",
"interface",
"{",
"}",
")",
"error",
"{",
"switch",
"v",
":=",
"dst",
".",
"(",
"type",
")",
"{",
"case",
"*",
"uint32",
":",
"if",
"src",
".",
"Status",
"==",
"Present",
"{",
"*",... | // AssignTo assigns from src to dst. Note that as pguint32 is not a general number
// type AssignTo does not do automatic type conversion as other number types do. | [
"AssignTo",
"assigns",
"from",
"src",
"to",
"dst",
".",
"Note",
"that",
"as",
"pguint32",
"is",
"not",
"a",
"general",
"number",
"type",
"AssignTo",
"does",
"not",
"do",
"automatic",
"type",
"conversion",
"as",
"other",
"number",
"types",
"do",
"."
] | 25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc | https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/pguint32.go#L55-L73 |
24,886 | jackc/pgx | stdlib/opendbpool.go | OpenDBFromPool | func OpenDBFromPool(pool *pgx.ConnPool, opts ...OptionOpenDBFromPool) *sql.DB {
c := poolConnector{
pool: pool,
driver: pgxDriver,
}
for _, opt := range opts {
opt(&c)
}
return sql.OpenDB(c)
} | go | func OpenDBFromPool(pool *pgx.ConnPool, opts ...OptionOpenDBFromPool) *sql.DB {
c := poolConnector{
pool: pool,
driver: pgxDriver,
}
for _, opt := range opts {
opt(&c)
}
return sql.OpenDB(c)
} | [
"func",
"OpenDBFromPool",
"(",
"pool",
"*",
"pgx",
".",
"ConnPool",
",",
"opts",
"...",
"OptionOpenDBFromPool",
")",
"*",
"sql",
".",
"DB",
"{",
"c",
":=",
"poolConnector",
"{",
"pool",
":",
"pool",
",",
"driver",
":",
"pgxDriver",
",",
"}",
"\n\n",
"f... | // OpenDBFromPool create a sql.DB connection from a pgx.ConnPool | [
"OpenDBFromPool",
"create",
"a",
"sql",
".",
"DB",
"connection",
"from",
"a",
"pgx",
".",
"ConnPool"
] | 25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc | https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/stdlib/opendbpool.go#L24-L35 |
24,887 | jackc/pgx | pgtype/bytea.go | DecodeText | func (dst *Bytea) DecodeText(ci *ConnInfo, src []byte) error {
if src == nil {
*dst = Bytea{Status: Null}
return nil
}
if len(src) < 2 || src[0] != '\\' || src[1] != 'x' {
return errors.Errorf("invalid hex format")
}
buf := make([]byte, (len(src)-2)/2)
_, err := hex.Decode(buf, src[2:])
if err != nil {
... | go | func (dst *Bytea) DecodeText(ci *ConnInfo, src []byte) error {
if src == nil {
*dst = Bytea{Status: Null}
return nil
}
if len(src) < 2 || src[0] != '\\' || src[1] != 'x' {
return errors.Errorf("invalid hex format")
}
buf := make([]byte, (len(src)-2)/2)
_, err := hex.Decode(buf, src[2:])
if err != nil {
... | [
"func",
"(",
"dst",
"*",
"Bytea",
")",
"DecodeText",
"(",
"ci",
"*",
"ConnInfo",
",",
"src",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"src",
"==",
"nil",
"{",
"*",
"dst",
"=",
"Bytea",
"{",
"Status",
":",
"Null",
"}",
"\n",
"return",
"nil",
"... | // DecodeText only supports the hex format. This has been the default since
// PostgreSQL 9.0. | [
"DecodeText",
"only",
"supports",
"the",
"hex",
"format",
".",
"This",
"has",
"been",
"the",
"default",
"since",
"PostgreSQL",
"9",
".",
"0",
"."
] | 25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc | https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/bytea.go#L72-L90 |
24,888 | jackc/pgx | stdlib/opendb.go | OptionAfterConnect | func OptionAfterConnect(ac func(*pgx.Conn) error) OptionOpenDB {
return func(dc *connector) {
dc.AfterConnect = ac
}
} | go | func OptionAfterConnect(ac func(*pgx.Conn) error) OptionOpenDB {
return func(dc *connector) {
dc.AfterConnect = ac
}
} | [
"func",
"OptionAfterConnect",
"(",
"ac",
"func",
"(",
"*",
"pgx",
".",
"Conn",
")",
"error",
")",
"OptionOpenDB",
"{",
"return",
"func",
"(",
"dc",
"*",
"connector",
")",
"{",
"dc",
".",
"AfterConnect",
"=",
"ac",
"\n",
"}",
"\n",
"}"
] | // OptionAfterConnect provide a callback for after connect. | [
"OptionAfterConnect",
"provide",
"a",
"callback",
"for",
"after",
"connect",
"."
] | 25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc | https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/stdlib/opendb.go#L17-L21 |
24,889 | parnurzeal/gorequest | gorequest_client_go1.3.go | safeModifyHttpClient | func (s *SuperAgent) safeModifyHttpClient() {
if !s.isClone {
return
}
oldClient := s.Client
s.Client = &http.Client{}
s.Client.Jar = oldClient.Jar
s.Client.Transport = oldClient.Transport
s.Client.Timeout = oldClient.Timeout
s.Client.CheckRedirect = oldClient.CheckRedir... | go | func (s *SuperAgent) safeModifyHttpClient() {
if !s.isClone {
return
}
oldClient := s.Client
s.Client = &http.Client{}
s.Client.Jar = oldClient.Jar
s.Client.Transport = oldClient.Transport
s.Client.Timeout = oldClient.Timeout
s.Client.CheckRedirect = oldClient.CheckRedir... | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"safeModifyHttpClient",
"(",
")",
"{",
"if",
"!",
"s",
".",
"isClone",
"{",
"return",
"\n",
"}",
"\n",
"oldClient",
":=",
"s",
".",
"Client",
"\n",
"s",
".",
"Client",
"=",
"&",
"http",
".",
"Client",
"{",
... | // we don't want to mess up other clones when we modify the client..
// so unfortantely we need to create a new client | [
"we",
"don",
"t",
"want",
"to",
"mess",
"up",
"other",
"clones",
"when",
"we",
"modify",
"the",
"client",
"..",
"so",
"unfortantely",
"we",
"need",
"to",
"create",
"a",
"new",
"client"
] | b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest_client_go1.3.go#L13-L23 |
24,890 | parnurzeal/gorequest | gorequest_transport_go1.7.go | safeModifyTransport | func (s *SuperAgent) safeModifyTransport() {
if !s.isClone {
return
}
oldTransport := s.Transport
s.Transport = &http.Transport{
Proxy: oldTransport.Proxy,
Dial: oldTransport.Dial,
DialTLS: oldTransport.DialTLS,
... | go | func (s *SuperAgent) safeModifyTransport() {
if !s.isClone {
return
}
oldTransport := s.Transport
s.Transport = &http.Transport{
Proxy: oldTransport.Proxy,
Dial: oldTransport.Dial,
DialTLS: oldTransport.DialTLS,
... | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"safeModifyTransport",
"(",
")",
"{",
"if",
"!",
"s",
".",
"isClone",
"{",
"return",
"\n",
"}",
"\n",
"oldTransport",
":=",
"s",
".",
"Transport",
"\n",
"s",
".",
"Transport",
"=",
"&",
"http",
".",
"Transpor... | // does a shallow clone of the transport | [
"does",
"a",
"shallow",
"clone",
"of",
"the",
"transport"
] | b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest_transport_go1.7.go#L11-L34 |
24,891 | parnurzeal/gorequest | gorequest.go | New | func New() *SuperAgent {
cookiejarOptions := cookiejar.Options{
PublicSuffixList: publicsuffix.List,
}
jar, _ := cookiejar.New(&cookiejarOptions)
debug := os.Getenv("GOREQUEST_DEBUG") == "1"
s := &SuperAgent{
TargetType: TypeJSON,
Data: make(map[string]interface{}),
Header: ... | go | func New() *SuperAgent {
cookiejarOptions := cookiejar.Options{
PublicSuffixList: publicsuffix.List,
}
jar, _ := cookiejar.New(&cookiejarOptions)
debug := os.Getenv("GOREQUEST_DEBUG") == "1"
s := &SuperAgent{
TargetType: TypeJSON,
Data: make(map[string]interface{}),
Header: ... | [
"func",
"New",
"(",
")",
"*",
"SuperAgent",
"{",
"cookiejarOptions",
":=",
"cookiejar",
".",
"Options",
"{",
"PublicSuffixList",
":",
"publicsuffix",
".",
"List",
",",
"}",
"\n",
"jar",
",",
"_",
":=",
"cookiejar",
".",
"New",
"(",
"&",
"cookiejarOptions",... | // Used to create a new SuperAgent object. | [
"Used",
"to",
"create",
"a",
"new",
"SuperAgent",
"object",
"."
] | b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L99-L130 |
24,892 | parnurzeal/gorequest | gorequest.go | copyRetryable | func copyRetryable(old superAgentRetryable) superAgentRetryable {
newRetryable := old
newRetryable.RetryableStatus = make([]int, len(old.RetryableStatus))
for i := range old.RetryableStatus {
newRetryable.RetryableStatus[i] = old.RetryableStatus[i]
}
return newRetryable
} | go | func copyRetryable(old superAgentRetryable) superAgentRetryable {
newRetryable := old
newRetryable.RetryableStatus = make([]int, len(old.RetryableStatus))
for i := range old.RetryableStatus {
newRetryable.RetryableStatus[i] = old.RetryableStatus[i]
}
return newRetryable
} | [
"func",
"copyRetryable",
"(",
"old",
"superAgentRetryable",
")",
"superAgentRetryable",
"{",
"newRetryable",
":=",
"old",
"\n",
"newRetryable",
".",
"RetryableStatus",
"=",
"make",
"(",
"[",
"]",
"int",
",",
"len",
"(",
"old",
".",
"RetryableStatus",
")",
")",... | // just need to change the array pointer? | [
"just",
"need",
"to",
"change",
"the",
"array",
"pointer?"
] | b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L194-L201 |
24,893 | parnurzeal/gorequest | gorequest.go | SetCurlCommand | func (s *SuperAgent) SetCurlCommand(enable bool) *SuperAgent {
s.CurlCommand = enable
return s
} | go | func (s *SuperAgent) SetCurlCommand(enable bool) *SuperAgent {
s.CurlCommand = enable
return s
} | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"SetCurlCommand",
"(",
"enable",
"bool",
")",
"*",
"SuperAgent",
"{",
"s",
".",
"CurlCommand",
"=",
"enable",
"\n",
"return",
"s",
"\n",
"}"
] | // Enable the curlcommand mode which display a CURL command line | [
"Enable",
"the",
"curlcommand",
"mode",
"which",
"display",
"a",
"CURL",
"command",
"line"
] | b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L248-L251 |
24,894 | parnurzeal/gorequest | gorequest.go | SetDoNotClearSuperAgent | func (s *SuperAgent) SetDoNotClearSuperAgent(enable bool) *SuperAgent {
s.DoNotClearSuperAgent = enable
return s
} | go | func (s *SuperAgent) SetDoNotClearSuperAgent(enable bool) *SuperAgent {
s.DoNotClearSuperAgent = enable
return s
} | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"SetDoNotClearSuperAgent",
"(",
"enable",
"bool",
")",
"*",
"SuperAgent",
"{",
"s",
".",
"DoNotClearSuperAgent",
"=",
"enable",
"\n",
"return",
"s",
"\n",
"}"
] | // Enable the DoNotClear mode for not clearing super agent and reuse for the next request | [
"Enable",
"the",
"DoNotClear",
"mode",
"for",
"not",
"clearing",
"super",
"agent",
"and",
"reuse",
"for",
"the",
"next",
"request"
] | b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L254-L257 |
24,895 | parnurzeal/gorequest | gorequest.go | ClearSuperAgent | func (s *SuperAgent) ClearSuperAgent() {
if s.DoNotClearSuperAgent {
return
}
s.Url = ""
s.Method = ""
s.Header = http.Header{}
s.Data = make(map[string]interface{})
s.SliceData = []interface{}{}
s.FormData = url.Values{}
s.QueryData = url.Values{}
s.FileData = make([]File, 0)
s.BounceToRawString = false
... | go | func (s *SuperAgent) ClearSuperAgent() {
if s.DoNotClearSuperAgent {
return
}
s.Url = ""
s.Method = ""
s.Header = http.Header{}
s.Data = make(map[string]interface{})
s.SliceData = []interface{}{}
s.FormData = url.Values{}
s.QueryData = url.Values{}
s.FileData = make([]File, 0)
s.BounceToRawString = false
... | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"ClearSuperAgent",
"(",
")",
"{",
"if",
"s",
".",
"DoNotClearSuperAgent",
"{",
"return",
"\n",
"}",
"\n",
"s",
".",
"Url",
"=",
"\"",
"\"",
"\n",
"s",
".",
"Method",
"=",
"\"",
"\"",
"\n",
"s",
".",
"Head... | // Clear SuperAgent data for another new request. | [
"Clear",
"SuperAgent",
"data",
"for",
"another",
"new",
"request",
"."
] | b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L265-L283 |
24,896 | parnurzeal/gorequest | gorequest.go | CustomMethod | func (s *SuperAgent) CustomMethod(method, targetUrl string) *SuperAgent {
switch method {
case POST:
return s.Post(targetUrl)
case GET:
return s.Get(targetUrl)
case HEAD:
return s.Head(targetUrl)
case PUT:
return s.Put(targetUrl)
case DELETE:
return s.Delete(targetUrl)
case PATCH:
return s.Patch(targ... | go | func (s *SuperAgent) CustomMethod(method, targetUrl string) *SuperAgent {
switch method {
case POST:
return s.Post(targetUrl)
case GET:
return s.Get(targetUrl)
case HEAD:
return s.Head(targetUrl)
case PUT:
return s.Put(targetUrl)
case DELETE:
return s.Delete(targetUrl)
case PATCH:
return s.Patch(targ... | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"CustomMethod",
"(",
"method",
",",
"targetUrl",
"string",
")",
"*",
"SuperAgent",
"{",
"switch",
"method",
"{",
"case",
"POST",
":",
"return",
"s",
".",
"Post",
"(",
"targetUrl",
")",
"\n",
"case",
"GET",
":",... | // Just a wrapper to initialize SuperAgent instance by method string | [
"Just",
"a",
"wrapper",
"to",
"initialize",
"SuperAgent",
"instance",
"by",
"method",
"string"
] | b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L286-L309 |
24,897 | parnurzeal/gorequest | gorequest.go | RedirectPolicy | func (s *SuperAgent) RedirectPolicy(policy func(req Request, via []Request) error) *SuperAgent {
s.safeModifyHttpClient()
s.Client.CheckRedirect = func(r *http.Request, v []*http.Request) error {
vv := make([]Request, len(v))
for i, r := range v {
vv[i] = Request(r)
}
return policy(Request(r), vv)
}
retu... | go | func (s *SuperAgent) RedirectPolicy(policy func(req Request, via []Request) error) *SuperAgent {
s.safeModifyHttpClient()
s.Client.CheckRedirect = func(r *http.Request, v []*http.Request) error {
vv := make([]Request, len(v))
for i, r := range v {
vv[i] = Request(r)
}
return policy(Request(r), vv)
}
retu... | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"RedirectPolicy",
"(",
"policy",
"func",
"(",
"req",
"Request",
",",
"via",
"[",
"]",
"Request",
")",
"error",
")",
"*",
"SuperAgent",
"{",
"s",
".",
"safeModifyHttpClient",
"(",
")",
"\n",
"s",
".",
"Client",
... | // RedirectPolicy accepts a function to define how to handle redirects. If the
// policy function returns an error, the next Request is not made and the previous
// request is returned.
//
// The policy function's arguments are the Request about to be made and the
// past requests in order of oldest first. | [
"RedirectPolicy",
"accepts",
"a",
"function",
"to",
"define",
"how",
"to",
"handle",
"redirects",
".",
"If",
"the",
"policy",
"function",
"returns",
"an",
"error",
"the",
"next",
"Request",
"is",
"not",
"made",
"and",
"the",
"previous",
"request",
"is",
"ret... | b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L649-L659 |
24,898 | parnurzeal/gorequest | gorequest.go | EndStruct | func (s *SuperAgent) EndStruct(v interface{}, callback ...func(response Response, v interface{}, body []byte, errs []error)) (Response, []byte, []error) {
resp, body, errs := s.EndBytes()
if errs != nil {
return nil, body, errs
}
err := json.Unmarshal(body, &v)
if err != nil {
s.Errors = append(s.Errors, err)
... | go | func (s *SuperAgent) EndStruct(v interface{}, callback ...func(response Response, v interface{}, body []byte, errs []error)) (Response, []byte, []error) {
resp, body, errs := s.EndBytes()
if errs != nil {
return nil, body, errs
}
err := json.Unmarshal(body, &v)
if err != nil {
s.Errors = append(s.Errors, err)
... | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"EndStruct",
"(",
"v",
"interface",
"{",
"}",
",",
"callback",
"...",
"func",
"(",
"response",
"Response",
",",
"v",
"interface",
"{",
"}",
",",
"body",
"[",
"]",
"byte",
",",
"errs",
"[",
"]",
"error",
")"... | // EndStruct should be used when you want the body as a struct. The callbacks work the same way as with `End`, except that a struct is used instead of a string. | [
"EndStruct",
"should",
"be",
"used",
"when",
"you",
"want",
"the",
"body",
"as",
"a",
"struct",
".",
"The",
"callbacks",
"work",
"the",
"same",
"way",
"as",
"with",
"End",
"except",
"that",
"a",
"struct",
"is",
"used",
"instead",
"of",
"a",
"string",
"... | b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L1124-L1139 |
24,899 | parnurzeal/gorequest | gorequest.go | AsCurlCommand | func (s *SuperAgent) AsCurlCommand() (string, error) {
req, err := s.MakeRequest()
if err != nil {
return "", err
}
cmd, err := http2curl.GetCurlCommand(req)
if err != nil {
return "", err
}
return cmd.String(), nil
} | go | func (s *SuperAgent) AsCurlCommand() (string, error) {
req, err := s.MakeRequest()
if err != nil {
return "", err
}
cmd, err := http2curl.GetCurlCommand(req)
if err != nil {
return "", err
}
return cmd.String(), nil
} | [
"func",
"(",
"s",
"*",
"SuperAgent",
")",
"AsCurlCommand",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"s",
".",
"MakeRequest",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
... | // AsCurlCommand returns a string representing the runnable `curl' command
// version of the request. | [
"AsCurlCommand",
"returns",
"a",
"string",
"representing",
"the",
"runnable",
"curl",
"command",
"version",
"of",
"the",
"request",
"."
] | b0604454e3c35c21d4c86e4771dc1e24c896cdd3 | https://github.com/parnurzeal/gorequest/blob/b0604454e3c35c21d4c86e4771dc1e24c896cdd3/gorequest.go#L1405-L1415 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.