Skip to content

Commit

Permalink
Ignore ParamaterStatus messages when handling response (#218)
Browse files Browse the repository at this point in the history
ParameterStatus messages may be generated in response to a SET command or when the administrator sends the SIGHUP signals to the server. They will appear in the query response and should be ignored.
  • Loading branch information
baarde authored Jun 29, 2022
1 parent 489537a commit 9f92317
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sources/PostgreSQL/Connection/PostgreSQLConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public final class PostgreSQLConnection: DatabaseConnection, BasicWorker, Databa
return true
case .error(let e): error = PostgreSQLError.errorResponse(e)
case .notice(let n): debugOnly { WARNING(n.description) }
case .parameterStatus:
break
default: try onResponse(message)
}
return false // request until ready for query
Expand Down
5 changes: 5 additions & 0 deletions Tests/PostgreSQLTests/ConnectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,11 @@ class ConnectionTests: XCTestCase {
XCTAssertEqual(1, result.count)
XCTAssertEqual([nil, "foo", nil, "bar"], result[0].arr)
}

func testParameterStatus() throws {
let conn = try PostgreSQLConnection.makeTest()
try conn.query("SET TIME ZONE 'UTC';") { _ in }.wait()
}
}

extension PostgreSQLConnection {
Expand Down
1 change: 1 addition & 0 deletions Tests/PostgreSQLTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extension ConnectionTests {
("testNull", testNull),
("testNumericDecode", testNumericDecode),
("testOrderBy", testOrderBy),
("testParameterStatus", testParameterStatus),
("testPolygon", testPolygon),
("testRowCodableEmptyKeyed", testRowCodableEmptyKeyed),
("testRowCodableNested", testRowCodableNested),
Expand Down

0 comments on commit 9f92317

Please sign in to comment.