Skip to content

Commit f8eb0d0

Browse files
committed
Skip standard_conforming_strings=off on PG19
For the same security reason why standard_conforming_strings=off is disallowed by pgx in combination with the simple query protocol, in PG19 standard_conforming_strings=off won't be allowed anymore at all. See: postgres/postgres@4576208
1 parent 4b429de commit f8eb0d0

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

pgxtest/pgxtest.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,21 @@ func SkipPostgreSQLVersionLessThan(t testing.TB, conn *pgx.Conn, minVersion int6
171171
t.Skipf("Test requires PostgreSQL v%d+", minVersion)
172172
}
173173
}
174+
175+
func SkipPostgreSQLVersionGreaterThan(t testing.TB, conn *pgx.Conn, maxVersion int64) {
176+
serverVersionStr := conn.PgConn().ParameterStatus("server_version")
177+
serverVersionStr = regexp.MustCompile(`^[0-9]+`).FindString(serverVersionStr)
178+
// if not PostgreSQL do nothing
179+
if serverVersionStr == "" {
180+
return
181+
}
182+
183+
serverVersion, err := strconv.ParseInt(serverVersionStr, 10, 64)
184+
if err != nil {
185+
t.Fatalf("postgres version parsed failed: %s", err)
186+
}
187+
188+
if serverVersion > maxVersion {
189+
t.Skipf("Test requires PostgreSQL v%d or lower", maxVersion)
190+
}
191+
}

query_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,6 +2031,7 @@ func TestConnSimpleProtocolRefusesNonStandardConformingStrings(t *testing.T) {
20312031
defer closeConn(t, conn)
20322032

20332033
pgxtest.SkipCockroachDB(t, conn, "Server does not support standard_conforming_strings = off (https://github.com/cockroachdb/cockroach/issues/36215)")
2034+
pgxtest.SkipPostgreSQLVersionGreaterThan(t, conn, 18) // PG19 stopped supporting standard_conforming_strings = off
20342035

20352036
mustExec(t, conn, "set standard_conforming_strings to off")
20362037

0 commit comments

Comments
 (0)