aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/lib/pq/notice.go
diff options
context:
space:
mode:
authorGibheer <gibheer+git@zero-knowledge.org>2024-09-05 19:38:25 +0200
committerGibheer <gibheer+git@zero-knowledge.org>2024-09-05 19:38:25 +0200
commit6ea4d2c82de80efc87708e5e182034b7c6c2019e (patch)
tree35c0856a929040216c82153ca62d43b27530a887 /vendor/github.com/lib/pq/notice.go
parent6f64eeace1b66639b9380b44e88a8d54850a4306 (diff)
switch from github.com/lib/pq to github.com/jackc/pgx/v5HEAD20240905master
lib/pq is out of maintenance for some time now, so switch to the newer more active library. Looks like it finally stabilized after a long time.
Diffstat (limited to 'vendor/github.com/lib/pq/notice.go')
-rw-r--r--vendor/github.com/lib/pq/notice.go72
1 files changed, 0 insertions, 72 deletions
diff --git a/vendor/github.com/lib/pq/notice.go b/vendor/github.com/lib/pq/notice.go
deleted file mode 100644
index 70ad122..0000000
--- a/vendor/github.com/lib/pq/notice.go
+++ /dev/null
@@ -1,72 +0,0 @@
-//go:build go1.10
-// +build go1.10
-
-package pq
-
-import (
- "context"
- "database/sql/driver"
-)
-
-// NoticeHandler returns the notice handler on the given connection, if any. A
-// runtime panic occurs if c is not a pq connection. This is rarely used
-// directly, use ConnectorNoticeHandler and ConnectorWithNoticeHandler instead.
-func NoticeHandler(c driver.Conn) func(*Error) {
- return c.(*conn).noticeHandler
-}
-
-// SetNoticeHandler sets the given notice handler on the given connection. A
-// runtime panic occurs if c is not a pq connection. A nil handler may be used
-// to unset it. This is rarely used directly, use ConnectorNoticeHandler and
-// ConnectorWithNoticeHandler instead.
-//
-// Note: Notice handlers are executed synchronously by pq meaning commands
-// won't continue to be processed until the handler returns.
-func SetNoticeHandler(c driver.Conn, handler func(*Error)) {
- c.(*conn).noticeHandler = handler
-}
-
-// NoticeHandlerConnector wraps a regular connector and sets a notice handler
-// on it.
-type NoticeHandlerConnector struct {
- driver.Connector
- noticeHandler func(*Error)
-}
-
-// Connect calls the underlying connector's connect method and then sets the
-// notice handler.
-func (n *NoticeHandlerConnector) Connect(ctx context.Context) (driver.Conn, error) {
- c, err := n.Connector.Connect(ctx)
- if err == nil {
- SetNoticeHandler(c, n.noticeHandler)
- }
- return c, err
-}
-
-// ConnectorNoticeHandler returns the currently set notice handler, if any. If
-// the given connector is not a result of ConnectorWithNoticeHandler, nil is
-// returned.
-func ConnectorNoticeHandler(c driver.Connector) func(*Error) {
- if c, ok := c.(*NoticeHandlerConnector); ok {
- return c.noticeHandler
- }
- return nil
-}
-
-// ConnectorWithNoticeHandler creates or sets the given handler for the given
-// connector. If the given connector is a result of calling this function
-// previously, it is simply set on the given connector and returned. Otherwise,
-// this returns a new connector wrapping the given one and setting the notice
-// handler. A nil notice handler may be used to unset it.
-//
-// The returned connector is intended to be used with database/sql.OpenDB.
-//
-// Note: Notice handlers are executed synchronously by pq meaning commands
-// won't continue to be processed until the handler returns.
-func ConnectorWithNoticeHandler(c driver.Connector, handler func(*Error)) *NoticeHandlerConnector {
- if c, ok := c.(*NoticeHandlerConnector); ok {
- c.noticeHandler = handler
- return c
- }
- return &NoticeHandlerConnector{Connector: c, noticeHandler: handler}
-}