(t *testing.T)
| 840 | } |
| 841 | |
| 842 | func TestFatalRxError(t *testing.T) { |
| 843 | t.Parallel() |
| 844 | |
| 845 | conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE")) |
| 846 | defer closeConn(t, conn) |
| 847 | |
| 848 | pgxtest.SkipCockroachDB(t, conn, "Server does not support pg_terminate_backend() (https://github.com/cockroachdb/cockroach/issues/35897)") |
| 849 | |
| 850 | var wg sync.WaitGroup |
| 851 | wg.Go(func() { |
| 852 | var n int32 |
| 853 | var s string |
| 854 | err := conn.QueryRow(context.Background(), "select 1::int4, pg_sleep(10)::varchar").Scan(&n, &s) |
| 855 | if pgErr, ok := err.(*pgconn.PgError); ok && pgErr.Severity == "FATAL" { |
| 856 | } else { |
| 857 | t.Errorf("Expected QueryRow Scan to return fatal PgError, but instead received %v", err) |
| 858 | return |
| 859 | } |
| 860 | }) |
| 861 | |
| 862 | otherConn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE")) |
| 863 | defer otherConn.Close(context.Background()) |
| 864 | |
| 865 | if _, err := otherConn.Exec(context.Background(), "select pg_terminate_backend($1)", conn.PgConn().PID()); err != nil { |
| 866 | t.Fatalf("Unable to kill backend PostgreSQL process: %v", err) |
| 867 | } |
| 868 | |
| 869 | wg.Wait() |
| 870 | |
| 871 | if !conn.IsClosed() { |
| 872 | t.Fatal("Connection should be closed") |
| 873 | } |
| 874 | } |
| 875 | |
| 876 | func TestFatalTxError(t *testing.T) { |
| 877 | t.Parallel() |
nothing calls this directly
no test coverage detected