package pgconn

import (
	
	
	
	
	
	
	
)
SafeToRetry checks if the err is guaranteed to have occurred before sending any data to the server.
func ( error) bool {
	if ,  := .(interface{ () bool });  {
		return .()
	}
	return false
}
Timeout checks if err was was caused by a timeout. To be specific, it is true if err is or was caused by a context.Canceled, context.DeadlineExceeded or an implementer of net.Error where Timeout() is true.
func ( error) bool {
	if errors.Is(, context.Canceled) || errors.Is(, context.DeadlineExceeded) {
		return true
	}

	var  net.Error
	return errors.As(, &) && .Timeout()
}
PgError represents an error reported by the PostgreSQL server. See http://www.postgresql.org/docs/11/static/protocol-error-fields.html for detailed field description.
SQLState returns the SQLState of the error.
func ( *PgError) () string {
	return .Code
}

type connectError struct {
	config *Config
	msg    string
	err    error
}

func ( *connectError) () string {
	 := &strings.Builder{}
	fmt.Fprintf(, "failed to connect to `host=%s user=%s database=%s`: %s", .config.Host, .config.User, .config.Database, .msg)
	if .err != nil {
		fmt.Fprintf(, " (%s)", .err.Error())
	}
	return .String()
}

func ( *connectError) () error {
	return .err
}

type connLockError struct {
	status string
}

func ( *connLockError) () bool {
	return true // a lock failure by definition happens before the connection is used.
}

func ( *connLockError) () string {
	return .status
}

type parseConfigError struct {
	connString string
	msg        string
	err        error
}

func ( *parseConfigError) () string {
	 := redactPW(.connString)
	if .err == nil {
		return fmt.Sprintf("cannot parse `%s`: %s", , .msg)
	}
	return fmt.Sprintf("cannot parse `%s`: %s (%s)", , .msg, .err.Error())
}

func ( *parseConfigError) () error {
	return .err
}

type pgconnError struct {
	msg         string
	err         error
	safeToRetry bool
}

func ( *pgconnError) () string {
	if .msg == "" {
		return .err.Error()
	}
	if .err == nil {
		return .msg
	}
	return fmt.Sprintf("%s: %s", .msg, .err.Error())
}

func ( *pgconnError) () bool {
	return .safeToRetry
}

func ( *pgconnError) () error {
	return .err
}

type contextAlreadyDoneError struct {
	err error
}

func ( *contextAlreadyDoneError) () string {
	return fmt.Sprintf("context already done: %s", .err.Error())
}

func ( *contextAlreadyDoneError) () bool {
	return true
}

func ( *contextAlreadyDoneError) () error {
	return .err
}

type writeError struct {
	err         error
	safeToRetry bool
}

func ( *writeError) () string {
	return fmt.Sprintf("write failed: %s", .err.Error())
}

func ( *writeError) () bool {
	return .safeToRetry
}

func ( *writeError) () error {
	return .err
}

func ( string) string {
	if strings.HasPrefix(, "postgres://") || strings.HasPrefix(, "postgresql://") {
		if ,  := url.Parse();  == nil {
			return redactURL()
		}
	}
	 := regexp.MustCompile(`password='[^']*'`)
	 = .ReplaceAllLiteralString(, "password=xxxxx")
	 := regexp.MustCompile(`password=[^ ]*`)
	 = .ReplaceAllLiteralString(, "password=xxxxx")
	 := regexp.MustCompile(`:[^:@]+?@`)
	 = .ReplaceAllLiteralString(, ":xxxxxx@")
	return 
}

func ( *url.URL) string {
	if  == nil {
		return ""
	}
	if ,  := .User.Password();  {
		.User = url.UserPassword(.User.Username(), "xxxxx")
	}
	return .String()