PostgreSQL loadable plugin
Source
func (conn *PGConn) QueryRowByName(ctx context.Context, queryName string, args ...interface{}) (row *sql.Row, err error) {
/*
** Zabbix
** Copyright 2001-2024 Zabbix SIA
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**/
package plugin
import (
"context"
"database/sql"
"fmt"
"net"
"net/url"
"path/filepath"
"strings"
"sync"
"time"
"github.com/jackc/pgx/v4/pgxpool"
"github.com/jackc/pgx/v4/stdlib"
"github.com/omeid/go-yarn"
"golang.zabbix.com/sdk/metric"
"golang.zabbix.com/sdk/tlsconfig"
"golang.zabbix.com/sdk/uri"
"golang.zabbix.com/sdk/zbxerr"
)
const (
// pgx dns field names
password = "password"
sslMode = "sslmode"
rootCA = "sslrootcert"
cert = "sslcert"
key = "sslkey"
cacheMode = "statement_cache_mode"
// connType
disable = "disable"
require = "require"
verifyCa = "verify-ca"
verifyFull = "verify-full"
MinSupportedPGVersion = 100000
)
type PostgresClient interface {
Query(ctx context.Context, query string, args ...interface{}) (rows *sql.Rows, err error)
QueryByName(ctx context.Context, queryName string, args ...interface{}) (rows *sql.Rows, err error)
QueryRow(ctx context.Context, query string, args ...interface{}) (row *sql.Row, err error)
QueryRowByName(ctx context.Context, queryName string, args ...interface{}) (row *sql.Row, err error)
PostgresVersion() int