Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func TestConnSendBatchQueuedQuery(t *testing.T) {

pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
pgxtest.SkipCockroachDB(t, conn, "Server serial type is incompatible with test")
pgxtest.SkipYugabyteDB(t, conn, "Flaky test failure on YugabyteDB")

sql := `create temporary table ledger(
id serial primary key,
Expand Down
21 changes: 19 additions & 2 deletions conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,8 @@ func TestListenNotify(t *testing.T) {
t.Skip("Server does not support LISTEN / NOTIFY (https://github.com/cockroachdb/cockroach/issues/41522)")
}

pgxtest.SkipYugabyteDB(t, listener, "YugabyteDB does not support LISTEN / NOTIFY")

mustExec(t, listener, "listen chat")

notifier := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
Expand Down Expand Up @@ -745,6 +747,7 @@ func TestListenNotifySelfNotification(t *testing.T) {
defer closeConn(t, conn)

pgxtest.SkipCockroachDB(t, conn, "Server does not support LISTEN / NOTIFY (https://github.com/cockroachdb/cockroach/issues/41522)")
pgxtest.SkipYugabyteDB(t, conn, "YugabyteDB does not support LISTEN / NOTIFY")

mustExec(t, conn, "listen self")

Expand Down Expand Up @@ -951,7 +954,8 @@ func TestUnregisteredTypeUsableAsStringArgumentAndBaseResult(t *testing.T) {

pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
pgxtest.SkipCockroachDB(t, conn, "Server does support domain types (https://github.com/cockroachdb/cockroach/issues/27796)")

pgxtest.SkipYugabyteDB(t, conn, "YugabyteDB does not support uint64 domain type")

var n uint64
err := conn.QueryRow(context.Background(), "select $1::uint64", "42").Scan(&n)
if err != nil {
Expand All @@ -970,6 +974,7 @@ func TestDomainType(t *testing.T) {

pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
pgxtest.SkipCockroachDB(t, conn, "Server does support domain types (https://github.com/cockroachdb/cockroach/issues/27796)")
pgxtest.SkipYugabyteDB(t, conn, "YugabyteDB does not support uint64 domain type")

// Domain type uint64 is a PostgreSQL domain of underlying type numeric.

Expand Down Expand Up @@ -1012,6 +1017,9 @@ func TestLoadTypeSameNameInDifferentSchemas(t *testing.T) {
require.NoError(t, err)
defer tx.Rollback(ctx)

_, err = tx.Exec(ctx, `drop schema if exists pgx_a cascade; drop schema if exists pgx_b cascade;`)
require.NoError(t, err)

_, err = tx.Exec(ctx, `create schema pgx_a;
create type pgx_a.point as (a text, b text);
create schema pgx_b;
Expand Down Expand Up @@ -1052,7 +1060,8 @@ func TestLoadCompositeType(t *testing.T) {

pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
pgxtest.SkipCockroachDB(t, conn, "Server does support composite types (https://github.com/cockroachdb/cockroach/issues/27792)")

pgxtest.SkipYugabyteDB(t, conn, "ALTER TYPE DROP ATTRIBUTE not supported yet in YugabyteDB")

tx, err := conn.Begin(ctx)
require.NoError(t, err)
defer tx.Rollback(ctx)
Expand All @@ -1079,6 +1088,9 @@ func TestLoadRangeType(t *testing.T) {
require.NoError(t, err)
defer tx.Rollback(ctx)

_, err = tx.Exec(ctx, "drop type if exists examplefloatrange")
require.NoError(t, err)

_, err = tx.Exec(ctx, "create type examplefloatrange as range (subtype=float8, subtype_diff=float8mi)")
require.NoError(t, err)

Expand Down Expand Up @@ -1114,6 +1126,11 @@ func TestLoadMultiRangeType(t *testing.T) {
require.NoError(t, err)
defer tx.Rollback(ctx)

_, err = tx.Exec(ctx, "drop type if exists examplefloatrange")
require.NoError(t, err)
_, err = tx.Exec(ctx, "drop type if exists examplefloatmultirange")
require.NoError(t, err)

_, err = tx.Exec(ctx, "create type examplefloatrange as range (subtype=float8, subtype_diff=float8mi, multirange_type_name=examplefloatmultirange)")
require.NoError(t, err)

Expand Down
1 change: 1 addition & 0 deletions derived_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

func TestCompositeCodecTranscodeWithLoadTypes(t *testing.T) {
skipCockroachDB(t, "Server does not support composite types (see https://github.com/cockroachdb/cockroach/issues/27792)")
skipYugabyteDB(t, "Flaky test in YugabyteDB")

defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
_, err := conn.Exec(ctx, `
Expand Down
2 changes: 1 addition & 1 deletion internal/sanitize/sanitize_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

"github.com/jackc/pgx/v5/internal/sanitize"
"github.com/yugabyte/pgx/v5/internal/sanitize"
)

var benchmarkSanitizeResult string
Expand Down
2 changes: 1 addition & 1 deletion internal/sanitize/sanitize_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strings"
"testing"

"github.com/jackc/pgx/v5/internal/sanitize"
"github.com/yugabyte/pgx/v5/internal/sanitize"
)

func FuzzQuoteString(f *testing.F) {
Expand Down
5 changes: 4 additions & 1 deletion large_objects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func TestLargeObjects(t *testing.T) {
}

pgxtest.SkipCockroachDB(t, conn, "Server does support large objects")
pgxtest.SkipYugabyteDB(t, conn, "YugabyteDB does not support large objects")

tx, err := conn.Begin(ctx)
if err != nil {
Expand Down Expand Up @@ -54,6 +55,7 @@ func TestLargeObjectsSimpleProtocol(t *testing.T) {
}

pgxtest.SkipCockroachDB(t, conn, "Server does support large objects")
pgxtest.SkipYugabyteDB(t, conn, "YugabyteDB does not support large objects")

tx, err := conn.Begin(ctx)
if err != nil {
Expand Down Expand Up @@ -174,7 +176,8 @@ func TestLargeObjectsMultipleTransactions(t *testing.T) {
}

pgxtest.SkipCockroachDB(t, conn, "Server does support large objects")

pgxtest.SkipYugabyteDB(t, conn, "YugabyteDB does not support large objects")

tx, err := conn.Begin(ctx)
if err != nil {
t.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions multitracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ package multitracer
import (
"context"

"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/yugabyte/pgx/v5"
"github.com/yugabyte/pgx/v5/pgxpool"
)

// Tracer can combine several tracers into one.
Expand Down
6 changes: 3 additions & 3 deletions multitracer/tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"testing"

"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/multitracer"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/yugabyte/pgx/v5"
"github.com/yugabyte/pgx/v5/multitracer"
"github.com/yugabyte/pgx/v5/pgxpool"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion pgconn/ctxwatch/context_watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

"github.com/jackc/pgx/v5/pgconn/ctxwatch"
"github.com/yugabyte/pgx/v5/pgconn/ctxwatch"
"github.com/stretchr/testify/require"
)

Expand Down
8 changes: 8 additions & 0 deletions pgconn/pgconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,10 @@ func TestConnOnNotification(t *testing.T) {
t.Skip("Server does not support LISTEN / NOTIFY (https://github.com/cockroachdb/cockroach/issues/41522)")
}

if strings.Contains(pgConn.ParameterStatus("server_version"), "YB") {
t.Skip("YugabyteDB does not support LISTEN / NOTIFY")
}

_, err = pgConn.Exec(ctx, "listen foo").ReadAll()
require.NoError(t, err)

Expand Down Expand Up @@ -1723,6 +1727,10 @@ func TestConnWaitForNotification(t *testing.T) {
t.Skip("Server does not support LISTEN / NOTIFY (https://github.com/cockroachdb/cockroach/issues/41522)")
}

if strings.Contains(pgConn.ParameterStatus("server_version"), "YB") {
t.Skip("YugabyteDB does not support LISTEN / NOTIFY")
}

_, err = pgConn.Exec(ctx, "listen foo").ReadAll()
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion pgproto3/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package pgproto3_test
import (
"testing"

"github.com/jackc/pgx/v5/pgproto3"
"github.com/yugabyte/pgx/v5/pgproto3"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion pgproto3/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package pgproto3_test
import (
"testing"

"github.com/jackc/pgx/v5/pgproto3"
"github.com/yugabyte/pgx/v5/pgproto3"
"github.com/stretchr/testify/require"
)

Expand Down
4 changes: 2 additions & 2 deletions pgtype/derived_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"testing"

pgx "github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgtype"
pgx "github.com/yugabyte/pgx/v5"
"github.com/yugabyte/pgx/v5/pgtype"
"github.com/stretchr/testify/require"
)

Expand Down
1 change: 1 addition & 0 deletions pgtype/interval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/yugabyte/pgx/v5/pgtype"
"github.com/yugabyte/pgx/v5/pgxtest"
"github.com/stretchr/testify/assert"
)

func TestIntervalCodec(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions pgtype/ltree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

func TestLtreeCodec(t *testing.T) {
skipCockroachDB(t, "Server does not support type ltree")
skipYugabyteDB(t, "YugabyteDB does not support ltree type")

pgxtest.RunValueRoundTripTests(context.Background(), t, defaultConnTestRunner, pgxtest.KnownOIDQueryExecModes, "ltree", []pgxtest.ValueRoundTripTest{
{
Expand Down
13 changes: 13 additions & 0 deletions pgtype/pgtype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"reflect"
"regexp"
"strconv"
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -98,6 +99,18 @@ func skipCockroachDB(t testing.TB, msg string) {
}
}

func skipYugabyteDB(t testing.TB, msg string) {
conn, err := pgx.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
if err != nil {
t.Fatal(err)
}
defer conn.Close(context.Background())

if strings.Contains(conn.PgConn().ParameterStatus("server_version"), "YB") {
t.Skip(msg)
}
}

func skipPostgreSQLVersionLessThan(t testing.TB, minVersion int64) {
conn, err := pgx.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pgtype/uint64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"testing"

"github.com/jackc/pgx/v5/pgtype"
"github.com/jackc/pgx/v5/pgxtest"
"github.com/yugabyte/pgx/v5/pgtype"
"github.com/yugabyte/pgx/v5/pgxtest"
)

func TestUint64Codec(t *testing.T) {
Expand Down
8 changes: 6 additions & 2 deletions pgtype/xml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"encoding/xml"
"testing"

pgx "github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxtest"
pgx "github.com/yugabyte/pgx/v5"
"github.com/yugabyte/pgx/v5/pgxtest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand All @@ -20,6 +20,7 @@ type xmlStruct struct {

func TestXMLCodec(t *testing.T) {
skipCockroachDB(t, "CockroachDB does not support XML.")
skipYugabyteDB(t, "YugabyteDB does not support XML.")
pgxtest.RunValueRoundTripTests(context.Background(), t, defaultConnTestRunner, nil, "xml", []pgxtest.ValueRoundTripTest{
{nil, new(*xmlStruct), isExpectedEq((*xmlStruct)(nil))},
{map[string]any(nil), new(*string), isExpectedEq((*string)(nil))},
Expand Down Expand Up @@ -50,6 +51,7 @@ func TestXMLCodec(t *testing.T) {
// https://github.com/jackc/pgx/issues/1273#issuecomment-1221414648
func TestXMLCodecUnmarshalSQLNull(t *testing.T) {
skipCockroachDB(t, "CockroachDB does not support XML.")
skipYugabyteDB(t, "YugabyteDB does not support XML.")
defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
// Byte arrays are nilified
slice := []byte{10, 4}
Expand Down Expand Up @@ -85,6 +87,7 @@ func TestXMLCodecUnmarshalSQLNull(t *testing.T) {

func TestXMLCodecPointerToPointerToString(t *testing.T) {
skipCockroachDB(t, "CockroachDB does not support XML.")
skipYugabyteDB(t, "YugabyteDB does not support XML.")
defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
var s *string
err := conn.QueryRow(ctx, "select ''::xml").Scan(&s)
Expand All @@ -100,6 +103,7 @@ func TestXMLCodecPointerToPointerToString(t *testing.T) {

func TestXMLCodecDecodeValue(t *testing.T) {
skipCockroachDB(t, "CockroachDB does not support XML.")
skipYugabyteDB(t, "YugabyteDB does not support XML.")
defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, _ testing.TB, conn *pgx.Conn) {
for _, tt := range []struct {
sql string
Expand Down
13 changes: 13 additions & 0 deletions pgx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"os"
"testing"
"strings"

"github.com/yugabyte/pgx/v5"
_ "github.com/yugabyte/pgx/v5/stdlib"
Expand All @@ -20,3 +21,15 @@ func skipCockroachDB(t testing.TB, msg string) {
t.Skip(msg)
}
}

func skipYugabyteDB(t testing.TB, msg string) {
conn, err := pgx.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
if err != nil {
t.Fatal(err)
}
defer conn.Close(context.Background())

if strings.Contains(conn.PgConn().ParameterStatus("server_version"), "YB") {
t.Skip(msg)
}
}
11 changes: 9 additions & 2 deletions pgxpool/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ func TestPoolAcquireChecksIdleConnsWithShouldPing(t *testing.T) {
require.NoError(t, err)
defer controllerConn.Close(ctx)

pgxtest.SkipYugabyteDB(t, controllerConn, "Test timeouts on YugabyteDB")

config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
require.NoError(t, err)

Expand Down Expand Up @@ -243,10 +245,10 @@ func TestPoolAcquireChecksIdleConnsWithShouldPing(t *testing.T) {

// The original 3 conns should have been terminated and the a new conn established for the ping.
require.EqualValues(t, 1, pool.Stat().TotalConns())
c, err := pool.Acquire(ctx)
c, err = pool.Acquire(ctx)
require.NoError(t, err)

cPID := c.Conn().PgConn().PID()
_ = c.Conn().PgConn().PID()
c.Release()

time.Sleep(time.Millisecond * 200)
Expand Down Expand Up @@ -873,6 +875,11 @@ func TestPoolCopyFrom(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
defer cancel()

controllerConn, err := pgx.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
require.NoError(t, err)
defer controllerConn.Close(ctx)
pgxtest.SkipYugabyteDB(t, controllerConn, "Order of rows returned is not guaranteed to match input order")

pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE"))
require.NoError(t, err)
defer pool.Close()
Expand Down
4 changes: 2 additions & 2 deletions pgxpool/tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"testing"
"time"

"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/yugabyte/pgx/v5"
"github.com/yugabyte/pgx/v5/pgxpool"
"github.com/stretchr/testify/require"
)

Expand Down
Loading
Loading